aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex/TokenLexer.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-02-15 20:52:18 +0000
committerChris Lattner <sabre@nondot.org>2009-02-15 20:52:18 +0000
commite7fb48466afcbf2c4ccdfa658824282fdc3c512c (patch)
tree4c2ea5e76f59eb02d41ce34a981cf1c19227ec87 /lib/Lex/TokenLexer.cpp
parent3ada6ffd92e02b02f1cdb3c2044aab24dbe0b755 (diff)
track "just a little more" location information for macro instantiations.
Now instead of just tracking the expansion history, also track the full range of the macro that got replaced. For object-like macros, this doesn't change anything. For _Pragma and function-like macros, this means we track the locations of the ')'. This is required for PR3579 because apparently GCC uses the line of the ')' of a function-like macro as the location to expand __LINE__ to. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64601 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/TokenLexer.cpp')
-rw-r--r--lib/Lex/TokenLexer.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/Lex/TokenLexer.cpp b/lib/Lex/TokenLexer.cpp
index 3ca0fcfa05..f0e2fbdfa6 100644
--- a/lib/Lex/TokenLexer.cpp
+++ b/lib/Lex/TokenLexer.cpp
@@ -23,7 +23,7 @@ using namespace clang;
/// Create a TokenLexer for the specified macro with the specified actual
/// arguments. Note that this ctor takes ownership of the ActualArgs pointer.
-void TokenLexer::Init(Token &Tok, MacroArgs *Actuals) {
+void TokenLexer::Init(Token &Tok, SourceLocation ILEnd, MacroArgs *Actuals) {
// If the client is reusing a TokenLexer, make sure to free any memory
// associated with it.
destroy();
@@ -32,7 +32,8 @@ void TokenLexer::Init(Token &Tok, MacroArgs *Actuals) {
ActualArgs = Actuals;
CurToken = 0;
- InstantiateLoc = Tok.getLocation();
+ InstantiateLocStart = Tok.getLocation();
+ InstantiateLocEnd = ILEnd;
AtStartOfLine = Tok.isAtStartOfLine();
HasLeadingSpace = Tok.hasLeadingSpace();
Tokens = &*Macro->tokens_begin();
@@ -68,7 +69,7 @@ void TokenLexer::Init(const Token *TokArray, unsigned NumToks,
DisableMacroExpansion = disableMacroExpansion;
NumTokens = NumToks;
CurToken = 0;
- InstantiateLoc = SourceLocation();
+ InstantiateLocStart = InstantiateLocEnd = SourceLocation();
AtStartOfLine = false;
HasLeadingSpace = false;
@@ -313,11 +314,12 @@ void TokenLexer::Lex(Token &Tok) {
// diagnostics for the expanded token should appear as if they came from
// InstantiationLoc. Pull this information together into a new SourceLocation
// that captures all of this.
- if (InstantiateLoc.isValid()) { // Don't do this for token streams.
- SourceManager &SrcMgr = PP.getSourceManager();
- Tok.setLocation(SrcMgr.createInstantiationLoc(Tok.getLocation(),
- InstantiateLoc,
- Tok.getLength()));
+ if (InstantiateLocStart.isValid()) { // Don't do this for token streams.
+ SourceManager &SM = PP.getSourceManager();
+ Tok.setLocation(SM.createInstantiationLoc(Tok.getLocation(),
+ InstantiateLocStart,
+ InstantiateLocEnd,
+ Tok.getLength()));
}
// If this is the first token, set the lexical properties of the token to