[cfe-dev] get sizeof(*) 's value

huc1985 huc1985 at 163.com
Mon Mar 25 18:46:33 PDT 2013


I wirte the VisitCallExpr() like this. But I can't find the Expr's AstContext
to use EvaluateAsInt() Function. How to do next´╝č

bool VisitCallExpr(CallExpr *expr){
        FunctionDecl* call = expr->getDirectCallee();
        if (call->getNameAsString() == "malloc"){
            for (int i=0;i < expr->getNumArgs();i++){
                Expr* arg = expr->getArg(i);
                Stmt::StmtClass stmt = arg->getStmtClass();
                if (arg->getStmtClass() ==
Stmt::UnaryExprOrTypeTraitExprClass){
                    UnaryExprOrTypeTraitExpr* de_expr =
dyn_cast<UnaryExprOrTypeTraitExpr>(arg);
                    //get the size
                    de_expr->EvaluateAsInt();//Problem
                }
             }
         }
}

Thanks a lot ~

Chen.



--
View this message in context: http://clang-developers.42468.n3.nabble.com/get-sizeof-s-value-tp4031125p4031131.html
Sent from the Clang Developers mailing list archive at Nabble.com.




More information about the cfe-dev mailing list