diff options
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/ARCMigrate/ARCMT.cpp | 2 | ||||
| -rw-r--r-- | clang/lib/Frontend/PrintPreprocessedOutput.cpp | 4 | ||||
| -rw-r--r-- | clang/lib/Lex/PPConditionalDirectiveRecord.cpp | 4 | ||||
| -rw-r--r-- | clang/lib/Lex/PPDirectives.cpp | 13 | ||||
| -rw-r--r-- | clang/lib/Lex/PPExpressions.cpp | 4 | ||||
| -rw-r--r-- | clang/lib/Lex/PPMacroExpansion.cpp | 14 | ||||
| -rw-r--r-- | clang/lib/Lex/PreprocessingRecord.cpp | 23 |
7 files changed, 27 insertions, 37 deletions
diff --git a/clang/lib/ARCMigrate/ARCMT.cpp b/clang/lib/ARCMigrate/ARCMT.cpp index 0a61cfea6c4..f266eaf8396 100644 --- a/clang/lib/ARCMigrate/ARCMT.cpp +++ b/clang/lib/ARCMigrate/ARCMT.cpp @@ -432,7 +432,7 @@ public: ARCMTMacroTrackerPPCallbacks(std::vector<SourceLocation> &ARCMTMacroLocs) : ARCMTMacroLocs(ARCMTMacroLocs) { } - void MacroExpands(const Token &MacroNameTok, const MacroDirective *MD, + void MacroExpands(const Token &MacroNameTok, const MacroDefinition &MD, SourceRange Range, const MacroArgs *Args) override { if (MacroNameTok.getIdentifierInfo()->getName() == getARCMTMacroName()) ARCMTMacroLocs.push_back(MacroNameTok.getLocation()); diff --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp b/clang/lib/Frontend/PrintPreprocessedOutput.cpp index b5e5d0aa037..8ca36489ee4 100644 --- a/clang/lib/Frontend/PrintPreprocessedOutput.cpp +++ b/clang/lib/Frontend/PrintPreprocessedOutput.cpp @@ -170,7 +170,7 @@ public: /// MacroUndefined - This hook is called whenever a macro #undef is seen. void MacroUndefined(const Token &MacroNameTok, - const MacroDirective *MD) override; + const MacroDefinition &MD) override; }; } // end anonymous namespace @@ -361,7 +361,7 @@ void PrintPPOutputPPCallbacks::MacroDefined(const Token &MacroNameTok, } void PrintPPOutputPPCallbacks::MacroUndefined(const Token &MacroNameTok, - const MacroDirective *MD) { + const MacroDefinition &MD) { // Only print out macro definitions in -dD mode. if (!DumpDefines) return; diff --git a/clang/lib/Lex/PPConditionalDirectiveRecord.cpp b/clang/lib/Lex/PPConditionalDirectiveRecord.cpp index 99b87a0a152..12a77849b8b 100644 --- a/clang/lib/Lex/PPConditionalDirectiveRecord.cpp +++ b/clang/lib/Lex/PPConditionalDirectiveRecord.cpp @@ -84,14 +84,14 @@ void PPConditionalDirectiveRecord::If(SourceLocation Loc, void PPConditionalDirectiveRecord::Ifdef(SourceLocation Loc, const Token &MacroNameTok, - const MacroDirective *MD) { + const MacroDefinition &MD) { addCondDirectiveLoc(CondDirectiveLoc(Loc, CondDirectiveStack.back())); CondDirectiveStack.push_back(Loc); } void PPConditionalDirectiveRecord::Ifndef(SourceLocation Loc, const Token &MacroNameTok, - const MacroDirective *MD) { + const MacroDefinition &MD) { addCondDirectiveLoc(CondDirectiveLoc(Loc, CondDirectiveStack.back())); CondDirectiveStack.push_back(Loc); } diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index e1a67f9e9d1..d1c89062761 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -2293,17 +2293,15 @@ void Preprocessor::HandleUndefDirective(Token &UndefTok) { // Okay, we have a valid identifier to undef. auto *II = MacroNameTok.getIdentifierInfo(); + auto MD = getMacroDefinition(II); // If the callbacks want to know, tell them about the macro #undef. // Note: no matter if the macro was defined or not. - if (Callbacks) { - // FIXME: Tell callbacks about module macros. - MacroDirective *MD = getLocalMacroDirective(II); + if (Callbacks) Callbacks->MacroUndefined(MacroNameTok, MD); - } // If the macro is not defined, this is a noop undef, just return. - const MacroInfo *MI = getMacroInfo(II); + const MacroInfo *MI = MD.getMacroInfo(); if (!MI) return; @@ -2348,7 +2346,8 @@ void Preprocessor::HandleIfdefDirective(Token &Result, bool isIfndef, CheckEndOfDirective(isIfndef ? "ifndef" : "ifdef"); IdentifierInfo *MII = MacroNameTok.getIdentifierInfo(); - MacroInfo *MI = getMacroInfo(MII); + auto MD = getMacroDefinition(MII); + MacroInfo *MI = MD.getMacroInfo(); if (CurPPLexer->getConditionalStackDepth() == 0) { // If the start of a top-level #ifdef and if the macro is not defined, @@ -2367,8 +2366,6 @@ void Preprocessor::HandleIfdefDirective(Token &Result, bool isIfndef, markMacroAsUsed(MI); if (Callbacks) { - // FIXME: Tell callbacks about module macros. - MacroDirective *MD = getLocalMacroDirective(MII); if (isIfndef) Callbacks->Ifndef(DirectiveTok.getLocation(), MacroNameTok, MD); else diff --git a/clang/lib/Lex/PPExpressions.cpp b/clang/lib/Lex/PPExpressions.cpp index 411a5012241..44513023395 100644 --- a/clang/lib/Lex/PPExpressions.cpp +++ b/clang/lib/Lex/PPExpressions.cpp @@ -142,9 +142,7 @@ static bool EvaluateDefined(PPValue &Result, Token &PeekTok, DefinedTracker &DT, // Invoke the 'defined' callback. if (PPCallbacks *Callbacks = PP.getPPCallbacks()) { - // FIXME: Tell callbacks about module macros. - MacroDirective *MD = Macro.getLocalDirective(); - Callbacks->Defined(macroToken, MD, + Callbacks->Defined(macroToken, Macro, SourceRange(beginLoc, PeekTok.getLocation())); } diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp index edeed42c17e..5af0205af37 100644 --- a/clang/lib/Lex/PPMacroExpansion.cpp +++ b/clang/lib/Lex/PPMacroExpansion.cpp @@ -419,10 +419,9 @@ bool Preprocessor::HandleMacroExpandedIdentifier(Token &Identifier, // If this is a builtin macro, like __LINE__ or _Pragma, handle it specially. if (MI->isBuiltinMacro()) { - // FIXME: Tell callbacks about module macros. - if (Callbacks) Callbacks->MacroExpands(Identifier, M.getLocalDirective(), - Identifier.getLocation(), - /*Args=*/nullptr); + if (Callbacks) + Callbacks->MacroExpands(Identifier, M, Identifier.getLocation(), + /*Args=*/nullptr); ExpandBuiltinMacro(Identifier); return true; } @@ -468,13 +467,10 @@ bool Preprocessor::HandleMacroExpandedIdentifier(Token &Identifier, // reading the function macro arguments. To ensure, in that case, that // MacroExpands callbacks still happen in source order, queue this // callback to have it happen after the function macro callback. - // FIXME: Tell callbacks about module macros. DelayedMacroExpandsCallbacks.push_back( - MacroExpandsInfo(Identifier, M.getLocalDirective(), ExpansionRange)); + MacroExpandsInfo(Identifier, M, ExpansionRange)); } else { - // FIXME: Tell callbacks about module macros. - Callbacks->MacroExpands(Identifier, M.getLocalDirective(), ExpansionRange, - Args); + Callbacks->MacroExpands(Identifier, M, ExpansionRange, Args); if (!DelayedMacroExpandsCallbacks.empty()) { for (unsigned i=0, e = DelayedMacroExpandsCallbacks.size(); i!=e; ++i) { MacroExpandsInfo &Info = DelayedMacroExpandsCallbacks[i]; diff --git a/clang/lib/Lex/PreprocessingRecord.cpp b/clang/lib/Lex/PreprocessingRecord.cpp index fd4bed17797..a423041a2d9 100644 --- a/clang/lib/Lex/PreprocessingRecord.cpp +++ b/clang/lib/Lex/PreprocessingRecord.cpp @@ -381,27 +381,27 @@ void PreprocessingRecord::addMacroExpansion(const Token &Id, } void PreprocessingRecord::Ifdef(SourceLocation Loc, const Token &MacroNameTok, - const MacroDirective *MD) { + const MacroDefinition &MD) { // This is not actually a macro expansion but record it as a macro reference. if (MD) - addMacroExpansion(MacroNameTok, MD->getMacroInfo(), + addMacroExpansion(MacroNameTok, MD.getMacroInfo(), MacroNameTok.getLocation()); } void PreprocessingRecord::Ifndef(SourceLocation Loc, const Token &MacroNameTok, - const MacroDirective *MD) { + const MacroDefinition &MD) { // This is not actually a macro expansion but record it as a macro reference. if (MD) - addMacroExpansion(MacroNameTok, MD->getMacroInfo(), + addMacroExpansion(MacroNameTok, MD.getMacroInfo(), MacroNameTok.getLocation()); } void PreprocessingRecord::Defined(const Token &MacroNameTok, - const MacroDirective *MD, + const MacroDefinition &MD, SourceRange Range) { // This is not actually a macro expansion but record it as a macro reference. if (MD) - addMacroExpansion(MacroNameTok, MD->getMacroInfo(), + addMacroExpansion(MacroNameTok, MD.getMacroInfo(), MacroNameTok.getLocation()); } @@ -409,10 +409,11 @@ void PreprocessingRecord::SourceRangeSkipped(SourceRange Range) { SkippedRanges.push_back(Range); } -void PreprocessingRecord::MacroExpands(const Token &Id,const MacroDirective *MD, +void PreprocessingRecord::MacroExpands(const Token &Id, + const MacroDefinition &MD, SourceRange Range, const MacroArgs *Args) { - addMacroExpansion(Id, MD->getMacroInfo(), Range); + addMacroExpansion(Id, MD.getMacroInfo(), Range); } void PreprocessingRecord::MacroDefined(const Token &Id, @@ -426,10 +427,8 @@ void PreprocessingRecord::MacroDefined(const Token &Id, } void PreprocessingRecord::MacroUndefined(const Token &Id, - const MacroDirective *MD) { - // Note: MI may be null (when #undef'ining an undefined macro). - if (MD) - MacroDefinitions.erase(MD->getMacroInfo()); + const MacroDefinition &MD) { + MD.forAllDefinitions([&](MacroInfo *MI) { MacroDefinitions.erase(MI); }); } void PreprocessingRecord::InclusionDirective( |

