Preprocessor::getCurrentFileLexer() now returns a PreprocessorLexer* instead of

a Lexer*. This means it will either return the current (normal) file Lexer or a
PTHLexer.

llvm-svn: 59694
This commit is contained in:
Ted Kremenek 2008-11-20 01:49:44 +00:00
parent 300590b584
commit b33ce32bda
2 changed files with 7 additions and 6 deletions

View File

@ -211,7 +211,7 @@ public:
/// getCurrentLexer - Return the current file lexer being lexed from. Note
/// that this ignores any potentially active macro expansions and _Pragma
/// expansions going on at the time.
Lexer *getCurrentFileLexer() const;
PreprocessorLexer *getCurrentFileLexer() const;
/// getPPCallbacks/setPPCallbacks - Accessors for preprocessor callbacks.
/// Note that this class takes ownership of any PPCallbacks object given to

View File

@ -43,14 +43,15 @@ bool Preprocessor::isInPrimaryFile() const {
/// getCurrentLexer - Return the current file lexer being lexed from. Note
/// that this ignores any potentially active macro expansions and _Pragma
/// expansions going on at the time.
Lexer *Preprocessor::getCurrentFileLexer() const {
if (CurLexer && !CurLexer->Is_PragmaLexer) return CurLexer.get();
PreprocessorLexer *Preprocessor::getCurrentFileLexer() const {
if (IsNonPragmaNonMacroLexer())
return CurPPLexer;
// Look for a stacked lexer.
for (unsigned i = IncludeMacroStack.size(); i != 0; --i) {
Lexer *L = IncludeMacroStack[i-1].TheLexer;
if (L && !L->Is_PragmaLexer) // Ignore macro & _Pragma expansions.
return L;
const IncludeStackInfo& ISI = IncludeMacroStack[i-1];
if (IsNonPragmaNonMacroLexer(ISI))
return ISI.ThePPLexer;
}
return 0;
}