From: Volodymyr Sapsai Date: Wed, 27 Feb 2019 01:04:53 +0000 (+0000) Subject: [index] Improve indexing support for MSPropertyDecl. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=33184f7554f5ed63b09b958bcb406a154cca99ae;p=clang [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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@354942 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Index/IndexDecl.cpp b/lib/Index/IndexDecl.cpp index 36f93106ff..d7835c51d0 100644 --- a/lib/Index/IndexDecl.cpp +++ b/lib/Index/IndexDecl.cpp @@ -324,6 +324,7 @@ public: } bool VisitMSPropertyDecl(const MSPropertyDecl *D) { + TRY_DECL(D, IndexCtx.handleDecl(D)); handleDeclarator(D); return true; } diff --git a/lib/Index/IndexSymbol.cpp b/lib/Index/IndexSymbol.cpp index 915f8e9a9d..218f89360b 100644 --- a/lib/Index/IndexSymbol.cpp +++ b/lib/Index/IndexSymbol.cpp @@ -324,6 +324,14 @@ SymbolInfo index::getSymbolInfo(const Decl *D) { Info.Kind = SymbolKind::Variable; Info.Lang = SymbolLanguage::CXX; break; + case Decl::MSProperty: + Info.Kind = SymbolKind::InstanceProperty; + if (const CXXRecordDecl *CXXRec = + dyn_cast(D->getDeclContext())) { + if (!CXXRec->isCLike()) + Info.Lang = SymbolLanguage::CXX; + } + break; default: break; } diff --git a/test/Index/ms-property.cpp b/test/Index/ms-property.cpp new file mode 100644 index 0000000000..55c701e796 --- /dev/null +++ b/test/Index/ms-property.cpp @@ -0,0 +1,32 @@ +// RUN: c-index-test core -print-source-symbols -- -fms-extensions -fno-ms-compatibility %s | FileCheck %s + +// CHECK: [[@LINE+1]]:8 | struct/C++ | Simple | [[Simple_USR:.*]] | | Def | rel: 0 +struct Simple { + int GetX() const; + // CHECK: [[@LINE-1]]:7 | instance-method/C++ | GetX | [[GetX_USR:.*]] | __ZNK6Simple4GetXEv | Decl,RelChild | rel: 1 + // CHECK-NEXT: RelChild | Simple | [[Simple_USR]] + + void PutX(int i); + // CHECK: [[@LINE-1]]:8 | instance-method/C++ | PutX | [[PutX_USR:.*]] | __ZN6Simple4PutXEi | Decl,RelChild | rel: 1 + // CHECK-NEXT: RelChild | Simple | [[Simple_USR]] + + __declspec(property(get=GetX, put=PutX)) int propX; + // CHECK: [[@LINE-1]]:48 | instance-property/C++ | propX | [[propX_USR:.*]] | | Def,RelChild | rel: 1 + // CHECK-NEXT: RelChild | Simple | [[Simple_USR]] +}; + +// CHECK: [[@LINE+1]]:5 | function/C | test | [[test_USR:.*]] | __Z4testv | Def | rel: 0 +int test() { + Simple s; + s.propX = 5; + // CHECK: [[@LINE-1]]:5 | instance-property/C++ | propX | [[propX_USR]] | | Ref,RelCont | rel: 1 + // CHECK-NEXT: RelCont | test | [[test_USR]] + // CHECK: [[@LINE-3]]:5 | instance-method/C++ | PutX | [[PutX_USR]] | __ZN6Simple4PutXEi | Ref,Call,RelCall,RelCont | rel: 1 + // CHECK-NEXT: RelCall,RelCont | test | [[test_USR]] + + return s.propX; + // CHECK: [[@LINE-1]]:12 | instance-property/C++ | propX | [[propX_USR]] | | Ref,RelCont | rel: 1 + // CHECK-NEXT: RelCont | test | [[test_USR]] + // CHECK: [[@LINE-3]]:12 | instance-method/C++ | GetX | [[GetX_USR]] | __ZNK6Simple4GetXEv | Ref,Call,RelCall,RelCont | rel: 1 + // CHECK-NEXT: RelCall,RelCont | test | [[test_USR]] +}