[cfe-commits] r129872 - in /cfe/trunk: test/Index/cindex-on-invalid.m tools/libclang/CIndex.cpp
Douglas Gregor
dgregor at apple.com
Wed Apr 20 14:16:21 PDT 2011
Author: dgregor
Date: Wed Apr 20 16:16:21 2011
New Revision: 129872
URL: http://llvm.org/viewvc/llvm-project?rev=129872&view=rev
Log:
When translating a Clang source range into a libclang source range,
adjust the a ending macro location to the end of the instantiation
location before adjusting it to the end of the token. Fixes
<rdar://problem/9021561>.
Modified:
cfe/trunk/test/Index/cindex-on-invalid.m
cfe/trunk/tools/libclang/CIndex.cpp
Modified: cfe/trunk/test/Index/cindex-on-invalid.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/cindex-on-invalid.m?rev=129872&r1=129871&r2=129872&view=diff
==============================================================================
--- cfe/trunk/test/Index/cindex-on-invalid.m (original)
+++ cfe/trunk/test/Index/cindex-on-invalid.m Wed Apr 20 16:16:21 2011
@@ -6,8 +6,16 @@
}
int foo;
+
+#define NO 0
+
+void f(int y) {
+ if (y = NO);
+}
+
int
// CHECK: cindex-on-invalid.m:5:8: error: use of undeclared label 'exit'
-// CHECK: cindex-on-invalid.m:13:1: error: expected identifier or '('
+// CHECK: cindex-on-invalid.m:13:9:{13:7-13:13}
+// CHECK: cindex-on-invalid.m:21:1: error: expected identifier or '('
Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=129872&r1=129871&r2=129872&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Wed Apr 20 16:16:21 2011
@@ -116,7 +116,7 @@
// location accordingly.
SourceLocation EndLoc = R.getEnd();
if (EndLoc.isValid() && EndLoc.isMacroID())
- EndLoc = SM.getSpellingLoc(EndLoc);
+ EndLoc = SM.getInstantiationRange(EndLoc).second;
if (R.isTokenRange() && !EndLoc.isInvalid() && EndLoc.isFileID()) {
unsigned Length = Lexer::MeasureTokenLength(EndLoc, SM, LangOpts);
EndLoc = EndLoc.getFileLocWithOffset(Length);
More information about the cfe-commits
mailing list