r354942 - [index] Improve indexing support for MSPropertyDecl.

Volodymyr Sapsai via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 26 17:04:53 PST 2019


Author: vsapsai
Date: Tue Feb 26 17:04:53 2019
New Revision: 354942

URL: http://llvm.org/viewvc/llvm-project?rev=354942&view=rev
Log:
[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


Added:
    cfe/trunk/test/Index/ms-property.cpp
Modified:
    cfe/trunk/lib/Index/IndexDecl.cpp
    cfe/trunk/lib/Index/IndexSymbol.cpp

Modified: cfe/trunk/lib/Index/IndexDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexDecl.cpp?rev=354942&r1=354941&r2=354942&view=diff
==============================================================================
--- cfe/trunk/lib/Index/IndexDecl.cpp (original)
+++ cfe/trunk/lib/Index/IndexDecl.cpp Tue Feb 26 17:04:53 2019
@@ -324,6 +324,7 @@ public:
   }
 
   bool VisitMSPropertyDecl(const MSPropertyDecl *D) {
+    TRY_DECL(D, IndexCtx.handleDecl(D));
     handleDeclarator(D);
     return true;
   }

Modified: cfe/trunk/lib/Index/IndexSymbol.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexSymbol.cpp?rev=354942&r1=354941&r2=354942&view=diff
==============================================================================
--- cfe/trunk/lib/Index/IndexSymbol.cpp (original)
+++ cfe/trunk/lib/Index/IndexSymbol.cpp Tue Feb 26 17:04:53 2019
@@ -324,6 +324,14 @@ SymbolInfo index::getSymbolInfo(const De
       Info.Kind = SymbolKind::Variable;
       Info.Lang = SymbolLanguage::CXX;
       break;
+    case Decl::MSProperty:
+      Info.Kind = SymbolKind::InstanceProperty;
+      if (const CXXRecordDecl *CXXRec =
+              dyn_cast<CXXRecordDecl>(D->getDeclContext())) {
+        if (!CXXRec->isCLike())
+          Info.Lang = SymbolLanguage::CXX;
+      }
+      break;
     default:
       break;
     }

Added: cfe/trunk/test/Index/ms-property.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/ms-property.cpp?rev=354942&view=auto
==============================================================================
--- cfe/trunk/test/Index/ms-property.cpp (added)
+++ cfe/trunk/test/Index/ms-property.cpp Tue Feb 26 17:04:53 2019
@@ -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:.*]] | <no-cgname> | 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:.*]] | <no-cgname> | 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]] | <no-cgname> | 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]] | <no-cgname> | 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]]
+}




More information about the cfe-commits mailing list