[cfe-users] finding source-range of a macro-parameter name
folkert via cfe-users
cfe-users at lists.llvm.org
Mon Oct 17 06:43:55 PDT 2016
Hi,
Given:
#define W(A) while(A)
void myfunc()
{
W(1) {
}
}
I would like retrieve a string for the "1" parameter of the while-macro.
Usually I would use:
Lexer::getSourceText(CharSourceRange::getCharRange(sr), sm, LangOptions(), 0);
(with 'sr' being a SourceRange and sm a SourceManager object).
to retrieve part of the original source-code. This works fine for e.g.
int a = 1; but fails for #defines.
I tried getLocStart, getLocation, tried using Lexer::getLocForEndOfToken
and sm.getSpellingLoc but everything ends up with an empty string ("").
Any suggestions?
regards
More information about the cfe-users
mailing list