[cfe-dev] disable macro expansion when raw lexing ?
kwadwo amankwa
que at lunarblack.com
Tue Oct 7 03:23:08 PDT 2014
Hi,
Wrote some code that lexes a file to find the last '#include' token .
when I test the code everthing works fine except when it lexes a
built-in header which it expands and then begins parsing resulting in a
'fatal error: 'stddef.h' file not found' error . I tried to disable
macro expansion by setting the Token::DisableExpand flag but this
doesn't seem to do the trick. Can I get some advice on this please?
Code is shown below
while (1) {
Token tok;
lex->LexFromRawLexer(tok);
if (tok.is(tok::eof))
break;
if(tok.is(tok::hash))
{
tok.setFlag(Token::DisableExpand);
lex->LexFromRawLexer(tok);
if(tok.isNot(tok::raw_identifier)|| tok.isAnnotation() )
{
tok.setFlag(Token::DisableExpand);
if(IdentifierInfo *II = tok.getIdentifierInfo())
{
lastIncludeLoc = tok.getLocation();
}
}
}
More information about the cfe-dev
mailing list