From: Douglas Gregor Date: Sat, 2 Oct 2010 19:51:13 +0000 (+0000) Subject: Provide proper source location and range information for C++ base X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1b0f7af64113b63253ced088a2bc64eb98e6f388;p=clang Provide proper source location and range information for C++ base specifier cursors in libclang. FIXME -=2, fixes the rest of . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@115419 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Index/load-stmts.cpp b/test/Index/load-stmts.cpp index e07c7920e1..49791222cf 100644 --- a/test/Index/load-stmts.cpp +++ b/test/Index/load-stmts.cpp @@ -152,12 +152,12 @@ void considered_harmful(int x) { // 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: :0:0: C++ base class specifier=class A:14:7 [access=public isVirtual=false] -// CHECK: :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: :0:0: C++ base class specifier=class C:22:7 [access=public isVirtual=true] -// CHECK: :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] diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 908b99d4e1..04d0bc50d6 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -2969,8 +2969,16 @@ CXSourceLocation clang_getCursorLocation(CXCursor C) { } 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: { @@ -3049,8 +3057,7 @@ static SourceRange getRawCursorExtent(CXCursor C) { 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;