Skip to content

Commit 4b0f7f9

Browse files
committedFeb 27, 2019
[index] Improve indexing support for MSPropertyDecl.
Currently the symbol for MSPropertyDecl has kind `SymbolKind::Unknown` which can trip up various indexing tools. rdar://problem/46764224 Reviewers: akyrtzi, benlangmuir, jkorous Reviewed By: jkorous Subscribers: dexonsmith, cfe-commits, jkorous, jdoerfert, arphaman Differential Revision: https://reviews.llvm.org/D57628 llvm-svn: 354942
1 parent bb11115 commit 4b0f7f9

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed
 

‎clang/lib/Index/IndexDecl.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ class IndexingDeclVisitor : public ConstDeclVisitor<IndexingDeclVisitor, bool> {
324324
}
325325

326326
bool VisitMSPropertyDecl(const MSPropertyDecl *D) {
327+
TRY_DECL(D, IndexCtx.handleDecl(D));
327328
handleDeclarator(D);
328329
return true;
329330
}

‎clang/lib/Index/IndexSymbol.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,14 @@ SymbolInfo index::getSymbolInfo(const Decl *D) {
324324
Info.Kind = SymbolKind::Variable;
325325
Info.Lang = SymbolLanguage::CXX;
326326
break;
327+
case Decl::MSProperty:
328+
Info.Kind = SymbolKind::InstanceProperty;
329+
if (const CXXRecordDecl *CXXRec =
330+
dyn_cast<CXXRecordDecl>(D->getDeclContext())) {
331+
if (!CXXRec->isCLike())
332+
Info.Lang = SymbolLanguage::CXX;
333+
}
334+
break;
327335
default:
328336
break;
329337
}

‎clang/test/Index/ms-property.cpp

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// RUN: c-index-test core -print-source-symbols -- -fms-extensions -fno-ms-compatibility %s | FileCheck %s
2+
3+
// CHECK: [[@LINE+1]]:8 | struct/C++ | Simple | [[Simple_USR:.*]] | <no-cgname> | Def | rel: 0
4+
struct Simple {
5+
int GetX() const;
6+
// CHECK: [[@LINE-1]]:7 | instance-method/C++ | GetX | [[GetX_USR:.*]] | __ZNK6Simple4GetXEv | Decl,RelChild | rel: 1
7+
// CHECK-NEXT: RelChild | Simple | [[Simple_USR]]
8+
9+
void PutX(int i);
10+
// CHECK: [[@LINE-1]]:8 | instance-method/C++ | PutX | [[PutX_USR:.*]] | __ZN6Simple4PutXEi | Decl,RelChild | rel: 1
11+
// CHECK-NEXT: RelChild | Simple | [[Simple_USR]]
12+
13+
__declspec(property(get=GetX, put=PutX)) int propX;
14+
// CHECK: [[@LINE-1]]:48 | instance-property/C++ | propX | [[propX_USR:.*]] | <no-cgname> | Def,RelChild | rel: 1
15+
// CHECK-NEXT: RelChild | Simple | [[Simple_USR]]
16+
};
17+
18+
// CHECK: [[@LINE+1]]:5 | function/C | test | [[test_USR:.*]] | __Z4testv | Def | rel: 0
19+
int test() {
20+
Simple s;
21+
s.propX = 5;
22+
// CHECK: [[@LINE-1]]:5 | instance-property/C++ | propX | [[propX_USR]] | <no-cgname> | Ref,RelCont | rel: 1
23+
// CHECK-NEXT: RelCont | test | [[test_USR]]
24+
// CHECK: [[@LINE-3]]:5 | instance-method/C++ | PutX | [[PutX_USR]] | __ZN6Simple4PutXEi | Ref,Call,RelCall,RelCont | rel: 1
25+
// CHECK-NEXT: RelCall,RelCont | test | [[test_USR]]
26+
27+
return s.propX;
28+
// CHECK: [[@LINE-1]]:12 | instance-property/C++ | propX | [[propX_USR]] | <no-cgname> | Ref,RelCont | rel: 1
29+
// CHECK-NEXT: RelCont | test | [[test_USR]]
30+
// CHECK: [[@LINE-3]]:12 | instance-method/C++ | GetX | [[GetX_USR]] | __ZNK6Simple4GetXEv | Ref,Call,RelCall,RelCont | rel: 1
31+
// CHECK-NEXT: RelCall,RelCont | test | [[test_USR]]
32+
}

0 commit comments

Comments
 (0)
Please sign in to comment.