- Add 'CurPPLexer' to Preprocessor to keep track of the current
PreprocessorLexer, which will either be a 'Lexer' or 'PTHLexer'. - Added stub field 'CurPTHLexer' to keep track of the current PTHLexer. - Modified IncludeStackInfo to track both the current PTHLexer and current PreprocessorLexer. llvm-svn: 59472
This commit is contained in:
parent
180afd2c55
commit
68ef9fc6ae
|
@ -15,6 +15,7 @@
|
||||||
#define LLVM_CLANG_LEX_PREPROCESSOR_H
|
#define LLVM_CLANG_LEX_PREPROCESSOR_H
|
||||||
|
|
||||||
#include "clang/Lex/Lexer.h"
|
#include "clang/Lex/Lexer.h"
|
||||||
|
#include "clang/Lex/PTHLexer.h"
|
||||||
#include "clang/Lex/PPCallbacks.h"
|
#include "clang/Lex/PPCallbacks.h"
|
||||||
#include "clang/Lex/TokenLexer.h"
|
#include "clang/Lex/TokenLexer.h"
|
||||||
#include "clang/Basic/IdentifierTable.h"
|
#include "clang/Basic/IdentifierTable.h"
|
||||||
|
@ -93,9 +94,20 @@ class Preprocessor {
|
||||||
PragmaNamespace *PragmaHandlers;
|
PragmaNamespace *PragmaHandlers;
|
||||||
|
|
||||||
/// CurLexer - This is the current top of the stack that we're lexing from if
|
/// CurLexer - This is the current top of the stack that we're lexing from if
|
||||||
/// not expanding a macro. One of CurLexer and CurTokenLexer must be null.
|
/// not expanding a macro and we are lexing directly from source code.
|
||||||
|
/// Only one of CurLexer, CurPTHLexer, or CurTokenLexer will be non-null.
|
||||||
llvm::OwningPtr<Lexer> CurLexer;
|
llvm::OwningPtr<Lexer> CurLexer;
|
||||||
|
|
||||||
|
/// CurPTHLexer - This is the current top of stack that we're lexing from if
|
||||||
|
/// not expanding from a macro and we are lexing from a PTH cache.
|
||||||
|
/// Only one of CurLexer, CurPTHLexer, or CurTokenLexer will be non-null.
|
||||||
|
llvm::OwningPtr<PTHLexer> CurPTHLexer;
|
||||||
|
|
||||||
|
/// CurPPLexer - This is the current top of the stack what we're lexing from
|
||||||
|
/// if not expanding a macro. This is an alias for either CurLexer or
|
||||||
|
/// CurPTHLexer.
|
||||||
|
PreprocessorLexer* CurPPLexer;
|
||||||
|
|
||||||
/// CurLookup - The DirectoryLookup structure used to find the current
|
/// CurLookup - The DirectoryLookup structure used to find the current
|
||||||
/// FileEntry, if CurLexer is non-null and if applicable. This allows us to
|
/// FileEntry, if CurLexer is non-null and if applicable. This allows us to
|
||||||
/// implement #include_next and find directory-specific properties.
|
/// implement #include_next and find directory-specific properties.
|
||||||
|
@ -110,11 +122,15 @@ class Preprocessor {
|
||||||
/// CurLexer/CurTokenLexer.
|
/// CurLexer/CurTokenLexer.
|
||||||
struct IncludeStackInfo {
|
struct IncludeStackInfo {
|
||||||
Lexer *TheLexer;
|
Lexer *TheLexer;
|
||||||
const DirectoryLookup *TheDirLookup;
|
PTHLexer *ThePTHLexer;
|
||||||
|
PreprocessorLexer *ThePPLexer;
|
||||||
TokenLexer *TheTokenLexer;
|
TokenLexer *TheTokenLexer;
|
||||||
IncludeStackInfo(Lexer *L, const DirectoryLookup *D, TokenLexer *TL)
|
const DirectoryLookup *TheDirLookup;
|
||||||
: TheLexer(L), TheDirLookup(D), TheTokenLexer(TL) {
|
|
||||||
}
|
IncludeStackInfo(Lexer *L, PTHLexer* P, PreprocessorLexer* PPL,
|
||||||
|
TokenLexer* TL, const DirectoryLookup *D)
|
||||||
|
: TheLexer(L), ThePTHLexer(P), ThePPLexer(PPL), TheTokenLexer(TL),
|
||||||
|
TheDirLookup(D) {}
|
||||||
};
|
};
|
||||||
std::vector<IncludeStackInfo> IncludeMacroStack;
|
std::vector<IncludeStackInfo> IncludeMacroStack;
|
||||||
|
|
||||||
|
@ -485,14 +501,19 @@ public:
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void PushIncludeMacroStack() {
|
void PushIncludeMacroStack() {
|
||||||
IncludeMacroStack.push_back(IncludeStackInfo(CurLexer.take(), CurDirLookup,
|
IncludeMacroStack.push_back(IncludeStackInfo(CurLexer.take(),
|
||||||
CurTokenLexer.take()));
|
CurPTHLexer.take(),
|
||||||
|
CurPPLexer,
|
||||||
|
CurTokenLexer.take(),
|
||||||
|
CurDirLookup));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopIncludeMacroStack() {
|
void PopIncludeMacroStack() {
|
||||||
CurLexer.reset(IncludeMacroStack.back().TheLexer);
|
CurLexer.reset(IncludeMacroStack.back().TheLexer);
|
||||||
CurDirLookup = IncludeMacroStack.back().TheDirLookup;
|
CurPTHLexer.reset(IncludeMacroStack.back().ThePTHLexer);
|
||||||
|
CurPPLexer = IncludeMacroStack.back().ThePPLexer;
|
||||||
CurTokenLexer.reset(IncludeMacroStack.back().TheTokenLexer);
|
CurTokenLexer.reset(IncludeMacroStack.back().TheTokenLexer);
|
||||||
|
CurDirLookup = IncludeMacroStack.back().TheDirLookup;
|
||||||
IncludeMacroStack.pop_back();
|
IncludeMacroStack.pop_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,7 @@ void Preprocessor::EnterSourceFileWithLexer(Lexer *TheLexer,
|
||||||
PushIncludeMacroStack();
|
PushIncludeMacroStack();
|
||||||
|
|
||||||
CurLexer.reset(TheLexer);
|
CurLexer.reset(TheLexer);
|
||||||
|
CurPPLexer = TheLexer;
|
||||||
CurDirLookup = CurDir;
|
CurDirLookup = CurDir;
|
||||||
|
|
||||||
// Notify the client, if desired, that we are in a new source file.
|
// Notify the client, if desired, that we are in a new source file.
|
||||||
|
|
Loading…
Reference in New Issue