Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
check global function pointer for write function
Browse files Browse the repository at this point in the history
  • Loading branch information
bogniq committed Apr 22, 2021
1 parent d8a16d3 commit 17a0a29
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tools/include/eosio/codegen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,10 @@ namespace eosio { namespace cdt {
}
}

void process_class() {
// TODO(handel member variables)
}

virtual bool VisitFunctionDecl(FunctionDecl* func_decl) {
SourceManager &sm = get_rewriter().getSourceMgr();
if (sm.isInSystemHeader(func_decl->getLocation()) || sm.isInExternCSystemHeader(func_decl->getLocation())) {
Expand All @@ -369,6 +373,21 @@ namespace eosio { namespace cdt {
if (auto* fd = dyn_cast<clang::FunctionDecl>(decl)) {
if (fd->getNameInfo().getAsString() == "apply")
apply_was_found = true;
} else if (auto* vd = dyn_cast<VarDecl>(decl)) {
if (vd->hasGlobalStorage()) {
if (Expr *init = vd->getInit()) {
while (ImplicitCastExpr *ice = dyn_cast<ImplicitCastExpr>(init)) {
init = ice->getSubExpr();
}
if (DeclRefExpr *dre = dyn_cast<DeclRefExpr>(init)) {
if (FunctionDecl *fd = dyn_cast<FunctionDecl>(dre->getFoundDecl())) {
if (func_calls.count(fd) != 0) {
indi_func_map[vd] = fd;
}
}
}
}
}
}
return true;
}
Expand Down

0 comments on commit 17a0a29

Please sign in to comment.