[cfe-users] got wrong parameter type using clang

henry ding via cfe-users cfe-users at lists.llvm.org
Tue Dec 10 22:45:08 PST 2019


simple test.cpp:
void test(std::string xx,string bb,int aa){}

clang usage:
int getFuncInfo(Rewriter* TheRewrite,clang::ASTContext *Context, const
FunctionDecl *func,FuncNode &node){
    clang::LangOptions LangOpts;
    LangOpts.CPlusPlus = true;
    Policy.FullyQualifiedName = 1;
   .............................................................
  . ..........................................................
   for(unsigned int i=0; i<func->getNumParams(); i++)
           {
                 string t =
QualType::getAsString(func->getParamDecl(i)->getType().split(),Policy);
                string n =
func->getParamDecl(i)->getName();//func->parameters()[i]->getQualifiedNameAsString()
                 cout << t + "#" + n << endl;
         }
}

But,i got:
int#xx  //should string#xx
int#bb //should string#bb
int#aa

Has anyone encountered this situation ?


More information about the cfe-users mailing list