From 17a0a297a03a5425d9603b4193fd6d266e7cc518 Mon Sep 17 00:00:00 2001 From: Qing Yang Date: Thu, 22 Apr 2021 10:08:36 -0400 Subject: [PATCH] check global function pointer for write function --- tools/include/eosio/codegen.hpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tools/include/eosio/codegen.hpp b/tools/include/eosio/codegen.hpp index d661598f9..f3013b709 100644 --- a/tools/include/eosio/codegen.hpp +++ b/tools/include/eosio/codegen.hpp @@ -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())) { @@ -369,6 +373,21 @@ namespace eosio { namespace cdt { if (auto* fd = dyn_cast(decl)) { if (fd->getNameInfo().getAsString() == "apply") apply_was_found = true; + } else if (auto* vd = dyn_cast(decl)) { + if (vd->hasGlobalStorage()) { + if (Expr *init = vd->getInit()) { + while (ImplicitCastExpr *ice = dyn_cast(init)) { + init = ice->getSubExpr(); + } + if (DeclRefExpr *dre = dyn_cast(init)) { + if (FunctionDecl *fd = dyn_cast(dre->getFoundDecl())) { + if (func_calls.count(fd) != 0) { + indi_func_map[vd] = fd; + } + } + } + } + } } return true; }