diff options
-rw-r--r-- | include/clang/Lex/PPCallbacks.h | 42 | ||||
-rw-r--r-- | include/clang/Lex/PreprocessingRecord.h | 5 | ||||
-rw-r--r-- | lib/Frontend/PrintPreprocessedOutput.cpp | 17 | ||||
-rw-r--r-- | lib/Lex/PPDirectives.cpp | 9 | ||||
-rw-r--r-- | lib/Lex/PreprocessingRecord.cpp | 9 |
5 files changed, 38 insertions, 44 deletions
diff --git a/include/clang/Lex/PPCallbacks.h b/include/clang/Lex/PPCallbacks.h index 1946515302..fcfbc11c98 100644 --- a/include/clang/Lex/PPCallbacks.h +++ b/include/clang/Lex/PPCallbacks.h @@ -113,17 +113,16 @@ public: /// MacroExpands - This is called by /// Preprocessor::HandleMacroExpandedIdentifier when a macro invocation is /// found. - virtual void MacroExpands(const Token &Id, const MacroInfo* MI) { + virtual void MacroExpands(const Token &MacroNameTok, const MacroInfo* MI) { } /// MacroDefined - This hook is called whenever a macro definition is seen. - virtual void MacroDefined(const IdentifierInfo *II, const MacroInfo *MI) { + virtual void MacroDefined(const Token &MacroNameTok, const MacroInfo *MI) { } /// MacroUndefined - This hook is called whenever a macro #undef is seen. /// MI is released immediately following this callback. - virtual void MacroUndefined(SourceLocation Loc, const IdentifierInfo *II, - const MacroInfo *MI) { + virtual void MacroUndefined(const Token &MacroNameTok, const MacroInfo *MI) { } /// If -- This hook is called whenever an #if is seen. @@ -141,13 +140,13 @@ public: /// Ifdef -- This hook is called whenever an #ifdef is seen. /// \param Loc The location of the token being tested. /// \param II Information on the token being tested. - virtual void Ifdef(SourceLocation Loc, const IdentifierInfo* II) { + virtual void Ifdef(const Token &MacroNameTok) { } /// Ifndef -- This hook is called whenever an #ifndef is seen. /// \param Loc The location of the token being tested. /// \param II Information on the token being tested. - virtual void Ifndef(SourceLocation Loc, const IdentifierInfo* II) { + virtual void Ifndef(const Token &MacroNameTok) { } /// Else -- This hook is called whenever an #else is seen. @@ -205,20 +204,19 @@ public: Second->PragmaMessage(Loc, Str); } - virtual void MacroExpands(const Token &Id, const MacroInfo* MI) { - First->MacroExpands(Id, MI); - Second->MacroExpands(Id, MI); + virtual void MacroExpands(const Token &MacroNameTok, const MacroInfo* MI) { + First->MacroExpands(MacroNameTok, MI); + Second->MacroExpands(MacroNameTok, MI); } - virtual void MacroDefined(const IdentifierInfo *II, const MacroInfo *MI) { - First->MacroDefined(II, MI); - Second->MacroDefined(II, MI); + virtual void MacroDefined(const Token &MacroNameTok, const MacroInfo *MI) { + First->MacroDefined(MacroNameTok, MI); + Second->MacroDefined(MacroNameTok, MI); } - virtual void MacroUndefined(SourceLocation Loc, const IdentifierInfo *II, - const MacroInfo *MI) { - First->MacroUndefined(Loc, II, MI); - Second->MacroUndefined(Loc, II, MI); + virtual void MacroUndefined(const Token &MacroNameTok, const MacroInfo *MI) { + First->MacroUndefined(MacroNameTok, MI); + Second->MacroUndefined(MacroNameTok, MI); } /// If -- This hook is called whenever an #if is seen. @@ -234,15 +232,15 @@ public: } /// Ifdef -- This hook is called whenever an #ifdef is seen. - virtual void Ifdef(SourceLocation Loc, const IdentifierInfo* II) { - First->Ifdef(Loc, II); - Second->Ifdef(Loc, II); + virtual void Ifdef(const Token &MacroNameTok) { + First->Ifdef(MacroNameTok); + Second->Ifdef(MacroNameTok); } /// Ifndef -- This hook is called whenever an #ifndef is seen. - virtual void Ifndef(SourceLocation Loc, const IdentifierInfo* II) { - First->Ifndef(Loc, II); - Second->Ifndef(Loc, II); + virtual void Ifndef(const Token &MacroNameTok) { + First->Ifndef(MacroNameTok); + Second->Ifndef(MacroNameTok); } /// Else -- This hook is called whenever an #else is seen. diff --git a/include/clang/Lex/PreprocessingRecord.h b/include/clang/Lex/PreprocessingRecord.h index 69a2f18035..01ac79d3d4 100644 --- a/include/clang/Lex/PreprocessingRecord.h +++ b/include/clang/Lex/PreprocessingRecord.h @@ -325,9 +325,8 @@ namespace clang { MacroDefinition *findMacroDefinition(const MacroInfo *MI); virtual void MacroExpands(const Token &Id, const MacroInfo* MI); - virtual void MacroDefined(const IdentifierInfo *II, const MacroInfo *MI); - virtual void MacroUndefined(SourceLocation Loc, const IdentifierInfo *II, - const MacroInfo *MI); + virtual void MacroDefined(const Token &Id, const MacroInfo *MI); + virtual void MacroUndefined(const Token &Id, const MacroInfo *MI); virtual void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok, llvm::StringRef FileName, diff --git a/lib/Frontend/PrintPreprocessedOutput.cpp b/lib/Frontend/PrintPreprocessedOutput.cpp index 429999cd5e..7494bd3002 100644 --- a/lib/Frontend/PrintPreprocessedOutput.cpp +++ b/lib/Frontend/PrintPreprocessedOutput.cpp @@ -147,11 +147,10 @@ public: void HandleNewlinesInToken(const char *TokStr, unsigned Len); /// MacroDefined - This hook is called whenever a macro definition is seen. - void MacroDefined(const IdentifierInfo *II, const MacroInfo *MI); + void MacroDefined(const Token &MacroNameTok, const MacroInfo *MI); /// MacroUndefined - This hook is called whenever a macro #undef is seen. - void MacroUndefined(SourceLocation Loc, const IdentifierInfo *II, - const MacroInfo *MI); + void MacroUndefined(const Token &MacroNameTok, const MacroInfo *MI); }; } // end anonymous namespace @@ -323,7 +322,7 @@ void PrintPPOutputPPCallbacks::Ident(SourceLocation Loc, const std::string &S) { } /// MacroDefined - This hook is called whenever a macro definition is seen. -void PrintPPOutputPPCallbacks::MacroDefined(const IdentifierInfo *II, +void PrintPPOutputPPCallbacks::MacroDefined(const Token &MacroNameTok, const MacroInfo *MI) { // Only print out macro definitions in -dD mode. if (!DumpDefines || @@ -331,18 +330,17 @@ void PrintPPOutputPPCallbacks::MacroDefined(const IdentifierInfo *II, MI->isBuiltinMacro()) return; MoveToLine(MI->getDefinitionLoc()); - PrintMacroDefinition(*II, *MI, PP, OS); + PrintMacroDefinition(*MacroNameTok.getIdentifierInfo(), *MI, PP, OS); EmittedMacroOnThisLine = true; } -void PrintPPOutputPPCallbacks::MacroUndefined(SourceLocation Loc, - const IdentifierInfo *II, +void PrintPPOutputPPCallbacks::MacroUndefined(const Token &MacroNameTok, const MacroInfo *MI) { // Only print out macro definitions in -dD mode. if (!DumpDefines) return; - MoveToLine(Loc); - OS << "#undef " << II->getName(); + MoveToLine(MacroNameTok.getLocation()); + OS << "#undef " << MacroNameTok.getIdentifierInfo()->getName(); EmittedMacroOnThisLine = true; } @@ -616,4 +614,3 @@ void clang::DoPrintPreprocessedInput(Preprocessor &PP, llvm::raw_ostream *OS, PrintPreprocessedTokens(PP, Tok, Callbacks, *OS); *OS << '\n'; } - diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp index 7aa3b31bc7..ee8883b8b2 100644 --- a/lib/Lex/PPDirectives.cpp +++ b/lib/Lex/PPDirectives.cpp @@ -1532,7 +1532,7 @@ void Preprocessor::HandleDefineDirective(Token &DefineTok) { // If the callbacks want to know, tell them about the macro definition. if (Callbacks) - Callbacks->MacroDefined(MacroNameTok.getIdentifierInfo(), MI); + Callbacks->MacroDefined(MacroNameTok, MI); } /// HandleUndefDirective - Implements #undef. @@ -1561,8 +1561,7 @@ void Preprocessor::HandleUndefDirective(Token &UndefTok) { // If the callbacks want to know, tell them about the macro #undef. if (Callbacks) - Callbacks->MacroUndefined(MacroNameTok.getLocation(), - MacroNameTok.getIdentifierInfo(), MI); + Callbacks->MacroUndefined(MacroNameTok, MI); // Free macro definition. ReleaseMacroInfo(MI); @@ -1633,9 +1632,9 @@ void Preprocessor::HandleIfdefDirective(Token &Result, bool isIfndef, if (Callbacks) { if (isIfndef) - Callbacks->Ifndef(MacroNameTok.getLocation(), MII); + Callbacks->Ifndef(MacroNameTok); else - Callbacks->Ifdef(MacroNameTok.getLocation(), MII); + Callbacks->Ifdef(MacroNameTok); } } diff --git a/lib/Lex/PreprocessingRecord.cpp b/lib/Lex/PreprocessingRecord.cpp index f6036ef779..3a43ac11e4 100644 --- a/lib/Lex/PreprocessingRecord.cpp +++ b/lib/Lex/PreprocessingRecord.cpp @@ -127,17 +127,18 @@ void PreprocessingRecord::MacroExpands(const Token &Id, const MacroInfo* MI) { Def)); } -void PreprocessingRecord::MacroDefined(const IdentifierInfo *II, +void PreprocessingRecord::MacroDefined(const Token &Id, const MacroInfo *MI) { SourceRange R(MI->getDefinitionLoc(), MI->getDefinitionEndLoc()); MacroDefinition *Def - = new (*this) MacroDefinition(II, MI->getDefinitionLoc(), R); + = new (*this) MacroDefinition(Id.getIdentifierInfo(), + MI->getDefinitionLoc(), + R); MacroDefinitions[MI] = Def; PreprocessedEntities.push_back(Def); } -void PreprocessingRecord::MacroUndefined(SourceLocation Loc, - const IdentifierInfo *II, +void PreprocessingRecord::MacroUndefined(const Token &Id, const MacroInfo *MI) { llvm::DenseMap<const MacroInfo *, MacroDefinition *>::iterator Pos = MacroDefinitions.find(MI); |