Search code examples
llvmautomated-refactoring

cant get the type of a callExpr argument


I'm trying to get the type of a argument from a call expression to later use that type in a rewriter. here's what i have:

const clang::Expr *const *FuncArgs = CallExpress.getArgs();

std::string QTString = FuncArgs[0]->getType().getBaseTypeIdentifier()->getName().str();

when I run this, it compiles and links fine but then when i run it i get a segmentaion fault. turns this segmentation fault happens when i call getName. my question are first, what am doing wrong? and if I'm going about this correcly. are there other ways of acquiring the QT from an argument in a callExpr?


Solution

  • I finally found the answer. you could just call getType and then call getAsString to get the type as string given that you already have FuncArgs from the original question.