]> granicus.if.org Git - clang/commitdiff
When translating a Clang source range into a libclang source range,
authorDouglas Gregor <dgregor@apple.com>
Wed, 20 Apr 2011 21:16:21 +0000 (21:16 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 20 Apr 2011 21:16:21 +0000 (21:16 +0000)
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>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129872 91177308-0d34-0410-b5e6-96231b3b80d8

test/Index/cindex-on-invalid.m
tools/libclang/CIndex.cpp

index d223c2ad590e66940878aba02d823240767c05d6..6eff24baf8085056f9f17301912d295272dc4b5d 100644 (file)
@@ -6,8 +6,16 @@ void test() {
 }
 
 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 '('
 
index ce02088281403eb1d32c0a8e1e628888222f1474..870e6b20187d146a5f9ad557877c4070ef2f107c 100644 (file)
@@ -116,7 +116,7 @@ CXSourceRange cxloc::translateSourceRange(const SourceManager &SM,
   // 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);