[llvm-branch-commits] [cfe-branch] r115432 - in /cfe/branches/Apple/whitney: test/Index/load-stmts.cpp tools/libclang/CIndex.cpp

Daniel Dunbar daniel at zuster.org
Sat Oct 2 16:23:48 PDT 2010


Author: ddunbar
Date: Sat Oct  2 18:23:48 2010
New Revision: 115432

URL: http://llvm.org/viewvc/llvm-project?rev=115432&view=rev
Log:
Merge r115419:
--
Author: Douglas Gregor <dgregor at apple.com>
Date:   Sat Oct 2 19:51:13 2010 +0000

    Provide proper source location and range information for C++ base
    specifier cursors in libclang. FIXME -=2, fixes the rest of
    <rdar://problem/8274883>.

Modified:
    cfe/branches/Apple/whitney/test/Index/load-stmts.cpp
    cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp

Modified: cfe/branches/Apple/whitney/test/Index/load-stmts.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/test/Index/load-stmts.cpp?rev=115432&r1=115431&r2=115432&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/test/Index/load-stmts.cpp (original)
+++ cfe/branches/Apple/whitney/test/Index/load-stmts.cpp Sat Oct  2 18:23:48 2010
@@ -152,12 +152,12 @@
 // CHECK: load-stmts.cpp:18:7: ClassDecl=B:18:7 (Definition) Extent=[18:1 - 20:2]
 // CHECK: load-stmts.cpp:19:8: CXXMethod=doB:19:8 Extent=[19:8 - 19:13]
 // CHECK: load-stmts.cpp:22:7: ClassDecl=C:22:7 (Definition) Extent=[22:1 - 24:2]
-// CHECK: <invalid loc>:0:0: C++ base class specifier=class A:14:7 [access=public isVirtual=false]
-// CHECK: <invalid loc>:0:0: C++ base class specifier=class B:18:7 [access=private isVirtual=false]
+// CHECK: load-stmts.cpp:22:18: C++ base class specifier=class A:14:7 [access=public isVirtual=false]
+// CHECK: load-stmts.cpp:22:29: C++ base class specifier=class B:18:7 [access=private isVirtual=false]
 // CHECK: load-stmts.cpp:23:8: CXXMethod=doC:23:8 Extent=[23:8 - 23:13]
 // CHECK: load-stmts.cpp:26:7: ClassDecl=D:26:7 (Definition) Extent=[26:1 - 26:49]
-// CHECK: <invalid loc>:0:0: C++ base class specifier=class C:22:7 [access=public isVirtual=true]
-// CHECK: <invalid loc>:0:0: C++ base class specifier=class A:14:7 [access=private isVirtual=true]
+// CHECK: load-stmts.cpp:26:26: C++ base class specifier=class C:22:7 [access=public isVirtual=true]
+// CHECK: load-stmts.cpp:26:45: C++ base class specifier=class A:14:7 [access=private isVirtual=true]
 // CHECK: load-stmts.cpp:33:7: VarDecl=typeid_marker:33:7 (Definition)
 // CHECK: load-stmts.cpp:34:10: TypeRef=class C:22:7 Extent=[34:10 - 34:11]
 // CHECK: load-stmts.cpp:35:10: DeclRefExpr=c:32:20 Extent=[35:10 - 35:11]

Modified: cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp?rev=115432&r1=115431&r2=115432&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp (original)
+++ cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp Sat Oct  2 18:23:48 2010
@@ -2959,8 +2959,16 @@
     }
 
     case CXCursor_CXXBaseSpecifier: {
-      // FIXME: Figure out what location to return for a CXXBaseSpecifier.
-      return clang_getNullLocation();
+      CXXBaseSpecifier *BaseSpec = getCursorCXXBaseSpecifier(C);
+      if (!BaseSpec)
+        return clang_getNullLocation();
+      
+      if (TypeSourceInfo *TSInfo = BaseSpec->getTypeSourceInfo())
+        return cxloc::translateSourceLocation(getCursorContext(C),
+                                            TSInfo->getTypeLoc().getBeginLoc());
+      
+      return cxloc::translateSourceLocation(getCursorContext(C),
+                                        BaseSpec->getSourceRange().getBegin());
     }
 
     case CXCursor_LabelRef: {
@@ -3039,8 +3047,7 @@
       return getCursorMemberRef(C).second;
 
     case CXCursor_CXXBaseSpecifier:
-      // FIXME: Figure out what source range to use for a CXBaseSpecifier.
-      return SourceRange();
+      return getCursorCXXBaseSpecifier(C)->getSourceRange();
 
     case CXCursor_LabelRef:
       return getCursorLabelRef(C).second;





More information about the llvm-branch-commits mailing list