[cfe-commits] r133804 - in /cfe/trunk: lib/Lex/Lexer.cpp test/Parser/recovery.c
Argyrios Kyrtzidis
akyrtzi at gmail.com
Fri Jun 24 10:58:59 PDT 2011
Author: akirtzidis
Date: Fri Jun 24 12:58:59 2011
New Revision: 133804
URL: http://llvm.org/viewvc/llvm-project?rev=133804&view=rev
Log:
Allow Lexer::getLocForEndOfToken to return the location just passed the macro instantiation
if the location given points at the last token of the macro instantiation.
Fixes rdar://9045701.
Modified:
cfe/trunk/lib/Lex/Lexer.cpp
cfe/trunk/test/Parser/recovery.c
Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=133804&r1=133803&r2=133804&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Fri Jun 24 12:58:59 2011
@@ -679,9 +679,17 @@
SourceLocation Lexer::getLocForEndOfToken(SourceLocation Loc, unsigned Offset,
const SourceManager &SM,
const LangOptions &Features) {
- if (Loc.isInvalid() || !Loc.isFileID())
+ if (Loc.isInvalid())
return SourceLocation();
-
+
+ if (Loc.isMacroID()) {
+ if (Offset > 0 || !SM.isAtEndOfMacroInstantiation(Loc))
+ return SourceLocation(); // Points inside the macro instantiation.
+
+ // Continue and find the location just after the macro instantiation.
+ Loc = SM.getInstantiationRange(Loc).second;
+ }
+
unsigned Len = Lexer::MeasureTokenLength(Loc, SM, Features);
if (Len > Offset)
Len = Len - Offset;
Modified: cfe/trunk/test/Parser/recovery.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/recovery.c?rev=133804&r1=133803&r2=133804&view=diff
==============================================================================
--- cfe/trunk/test/Parser/recovery.c (original)
+++ cfe/trunk/test/Parser/recovery.c Fri Jun 24 12:58:59 2011
@@ -74,6 +74,11 @@
X = 4 // expected-error{{expected ';' after expression}}
}
+// rdar://9045701
+void test9045701(int x) {
+#define VALUE 0
+ x = VALUE // expected-error{{expected ';' after expression}}
+}
// rdar://7980651
typedef int intptr_t; // expected-note {{'intptr_t' declared here}}
More information about the cfe-commits
mailing list