From 714a03ad3b05693b5a216d0e14e6b92b7e65f07f Mon Sep 17 00:00:00 2001 From: Kristof Umann Date: Wed, 31 Oct 2018 17:19:20 +0000 Subject: [PATCH] [Lex] Make MacroDirective::findDirectiveAtLoc take const SourceManager I'm currently working on including macro expansions in the Static Analyzer's plist output, where I can only access a const SourceManager. Differential Revision: https://reviews.llvm.org/D53940 llvm-svn: 345741 --- clang/include/clang/Lex/MacroInfo.h | 3 ++- clang/lib/Lex/MacroInfo.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/clang/include/clang/Lex/MacroInfo.h b/clang/include/clang/Lex/MacroInfo.h index 0cc1cb92e67e..a06de132b496 100644 --- a/clang/include/clang/Lex/MacroInfo.h +++ b/clang/include/clang/Lex/MacroInfo.h @@ -395,7 +395,8 @@ public: /// Find macro definition active in the specified source location. If /// this macro was not defined there, return NULL. - const DefInfo findDirectiveAtLoc(SourceLocation L, SourceManager &SM) const; + const DefInfo findDirectiveAtLoc(SourceLocation L, + const SourceManager &SM) const; void dump() const; diff --git a/clang/lib/Lex/MacroInfo.cpp b/clang/lib/Lex/MacroInfo.cpp index 4ed69ecc465d..434c12007596 100644 --- a/clang/lib/Lex/MacroInfo.cpp +++ b/clang/lib/Lex/MacroInfo.cpp @@ -200,7 +200,8 @@ MacroDirective::DefInfo MacroDirective::getDefinition() { } const MacroDirective::DefInfo -MacroDirective::findDirectiveAtLoc(SourceLocation L, SourceManager &SM) const { +MacroDirective::findDirectiveAtLoc(SourceLocation L, + const SourceManager &SM) const { assert(L.isValid() && "SourceLocation is invalid."); for (DefInfo Def = getDefinition(); Def; Def = Def.getPreviousDefinition()) { if (Def.getLocation().isInvalid() || // For macros defined on the command line.