summaryrefslogtreecommitdiffstats
path: root/include/clang/Lex/Lexer.h
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2016-01-26 02:51:55 +0000
committerRichard Trieu <rtrieu@google.com>2016-01-26 02:51:55 +0000
commit3eb0f55c2626d98b95cee1c8f7574718d8d0f0cd (patch)
treea08049cc2d83bf7ed9a390f5aaa1c1ae4d8b723b /include/clang/Lex/Lexer.h
parent24991d8d54dffcfd0b9f3cc499f0ad07b0f670be (diff)
Fix -Wnull-conversion for long macros.
Move the function to get a macro name from DiagnosticRenderer.cpp to Lexer.cpp so that other files can use it. Lexer now has two functions to get the immediate macro name, the newly added one is better for diagnostic purposes. Make -Wnull-conversion use this function for better NULL macro detection. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@258778 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Lex/Lexer.h')
-rw-r--r--include/clang/Lex/Lexer.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/include/clang/Lex/Lexer.h b/include/clang/Lex/Lexer.h
index 12565d0b14..830c25a2e4 100644
--- a/include/clang/Lex/Lexer.h
+++ b/include/clang/Lex/Lexer.h
@@ -410,6 +410,26 @@ public:
const SourceManager &SM,
const LangOptions &LangOpts);
+ /// \brief Retrieve the name of the immediate macro expansion.
+ ///
+ /// This routine starts from a source location, and finds the name of the
+ /// macro responsible for its immediate expansion. It looks through any
+ /// intervening macro argument expansions to compute this. It returns a
+ /// StringRef which refers to the SourceManager-owned buffer of the source
+ /// where that macro name is spelled. Thus, the result shouldn't out-live
+ /// that SourceManager.
+ ///
+ /// This differs from Lexer::getImmediateMacroName in that any macro argument
+ /// location will result in the topmost function macro that accepted it.
+ /// e.g.
+ /// \code
+ /// MAC1( MAC2(foo) )
+ /// \endcode
+ /// for location of 'foo' token, this function will return "MAC1" while
+ /// Lexer::getImmediateMacroName will return "MAC2".
+ static StringRef getImmediateMacroNameForDiagnostics(
+ SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts);
+
/// \brief Compute the preamble of the given file.
///
/// The preamble of a file contains the initial comments, include directives,