Sunday, 15 January 2012

c++ - getting parameter information from FunctionDecl class in clang -



c++ - getting parameter information from FunctionDecl class in clang -

how parameter info string functiondecl class in clang . i'm trying getting confused many inheritances. compiler saying getreturntype() not fellow member of functiondecl doxygen documentation says otherwise . please help. http://clang.llvm.org/doxygen/classclang_1_1functiondecl.html

using namespace std; using namespace clang; using namespace clang::driver; using namespace clang::tooling; using namespace llvm; ....... class examplevisitor : public recursiveastvisitor<examplevisitor> { ...... virtual bool visitfunctiondecl(functiondecl *func) { numfunctions++; string funcname = func->getnameinfo().getname().getasstring(); string retname = func->getreturntype().getasstring(); ... homecoming true; } }

errors:-

‘class clang::functiondecl’ has no fellow member named ‘getreturntype’

depending if need qualified or unqualified name, can stringify homecoming type , parameter names follows

std::string rettype = f->getreturntype().getasstring(); std::string arg0; if(f->getnumparams() > 0) arg0 = f->parameters()[0]->getqualifiednameasstring();

check out getasstring() method provided.

edit: after comments figured out don't have latest clang source code. please check out before retrying. luck!

c++ clang libtooling

No comments:

Post a Comment