Skip to content

Commit bc3d715

Browse files
don't collect bases for types without definitions
rdar://123430367
1 parent 0a94992 commit bc3d715

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

clang/include/clang/ExtractAPI/ExtractAPIVisitor.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ class ExtractAPIVisitorBase : public RecursiveASTVisitor<Derived> {
173173

174174
protected:
175175
SmallVector<SymbolReference> getBases(const CXXRecordDecl *Decl) {
176+
if (!Decl->isCompleteDefinition()) {
177+
return {};
178+
}
179+
176180
// FIXME: store AccessSpecifier given by inheritance
177181
SmallVector<SymbolReference> Bases;
178182
for (const auto &BaseSpecifier : Decl->bases()) {

clang/test/Index/extract-api-cursor-cpp.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ class MyClass {
1313
my_vec myVec;
1414
};
1515

16+
struct OuterStruct {
17+
struct InnerStruct;
18+
int outer_field;
19+
};
20+
1621
// RUN: c-index-test -single-symbol-sgf-at=%s:13:7 local %s | FileCheck --check-prefix=CHECK-VEC-TYPE %s
1722
// CHECK-VEC-TYPE: "parentContexts":[{"kind":"c++.typealias","name":"my_vec","usr":"c:@my_vec"}]
1823
// CHECK-VEC-TYPE: "declarationFragments":[{"kind":"keyword","spelling":"typedef"},{"kind":"text","spelling":" "},{"kind":"typeIdentifier","preciseIdentifier":"c:@ST>1#T@basic_vector","spelling":"basic_vector"},{"kind":"text","spelling":"<"},{"kind":"typeIdentifier","preciseIdentifier":"c:I","spelling":"int"},{"kind":"text","spelling":"> "},{"kind":"identifier","spelling":"my_vec"},{"kind":"text","spelling":";"}]
@@ -27,3 +32,10 @@ class MyClass {
2732
// CHECK-MYVEC: "kind":{"displayName":"Instance Property","identifier":"c++.property"}
2833
// CHECK-MYVEC: "title":"myVec"
2934
// CHECK-MYVEC: "pathComponents":["MyClass","myVec"]
35+
36+
// RUN: c-index-test -single-symbol-sgf-at=%s:17:17 local %s | FileCheck --check-prefix=CHECK-INNER %s
37+
// CHECK-INNER: "parentContexts":[{"kind":"c++.struct","name":"OuterStruct","usr":"c:@S@OuterStruct"},{"kind":"c++.struct","name":"InnerStruct","usr":"c:@S@OuterStruct@S@InnerStruct"}]
38+
// CHECK-INNER: "identifier":{"interfaceLanguage":"c++","precise":"c:@S@OuterStruct@S@InnerStruct"}
39+
// CHECK-INNER: "kind":{"displayName":"Structure","identifier":"c++.struct"}
40+
// CHECK-INNER: "title":"InnerStruct"
41+
// CHECK-INNER: "pathComponents":["OuterStruct","InnerStruct"]

0 commit comments

Comments
 (0)