summaryrefslogtreecommitdiffstats
path: root/clang/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
commit9dc9c206d3a2b2a35e5a9dfd407c1741bcee9ecf (patch)
tree9a5ffe0af544a4d1975e85a8fd2b3d9e447be977 /clang/lib/Lex/TokenLexer.cpp
parent7f543ba9fa1dc3dde925ea32d77a64c2bff84115 (diff)
downloadbcm5719-llvm-9dc9c206d3a2b2a35e5a9dfd407c1741bcee9ecf.tar.gz
bcm5719-llvm-9dc9c206d3a2b2a35e5a9dfd407c1741bcee9ecf.zip
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. llvm-svn: 64601
Diffstat (limited to 'clang/lib/Lex/TokenLexer.cpp')
-rw-r--r--clang/lib/Lex/TokenLexer.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/clang/lib/Lex/TokenLexer.cpp b/clang/lib/Lex/TokenLexer.cpp
index 3ca0fcfa05d..f0e2fbdfa62 100644
--- a/clang/lib/Lex/TokenLexer.cpp
+++ b/clang/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
OpenPOWER on IntegriCloud