r305508 - [index] Record C++17 global binding declarations

Alex Lorenz via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 15 14:19:01 PDT 2017


Author: arphaman
Date: Thu Jun 15 16:19:01 2017
New Revision: 305508

URL: http://llvm.org/viewvc/llvm-project?rev=305508&view=rev
Log:
[index] Record C++17 global binding declarations

The global C++17 binding declarations should be indexed as variable symbols.

Differential Revision: https://reviews.llvm.org/D33920

Modified:
    cfe/trunk/lib/Index/IndexDecl.cpp
    cfe/trunk/lib/Index/IndexSymbol.cpp
    cfe/trunk/test/Index/Core/index-source.cpp

Modified: cfe/trunk/lib/Index/IndexDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexDecl.cpp?rev=305508&r1=305507&r2=305508&view=diff
==============================================================================
--- cfe/trunk/lib/Index/IndexDecl.cpp (original)
+++ cfe/trunk/lib/Index/IndexDecl.cpp Thu Jun 15 16:19:01 2017
@@ -293,6 +293,12 @@ public:
     return true;
   }
 
+  bool VisitDecompositionDecl(const DecompositionDecl *D) {
+    for (const auto *Binding : D->bindings())
+      TRY_DECL(Binding, IndexCtx.handleDecl(Binding));
+    return Base::VisitDecompositionDecl(D);
+  }
+
   bool VisitFieldDecl(const FieldDecl *D) {
     SmallVector<SymbolRelation, 4> Relations;
     gatherTemplatePseudoOverrides(D, Relations);

Modified: cfe/trunk/lib/Index/IndexSymbol.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexSymbol.cpp?rev=305508&r1=305507&r2=305508&view=diff
==============================================================================
--- cfe/trunk/lib/Index/IndexSymbol.cpp (original)
+++ cfe/trunk/lib/Index/IndexSymbol.cpp Thu Jun 15 16:19:01 2017
@@ -301,6 +301,10 @@ SymbolInfo index::getSymbolInfo(const De
       Info.Kind = SymbolKind::TypeAlias;
       Info.Lang = SymbolLanguage::CXX;
       break;
+    case Decl::Binding:
+      Info.Kind = SymbolKind::Variable;
+      Info.Lang = SymbolLanguage::CXX;
+      break;
     default:
       break;
     }

Modified: cfe/trunk/test/Index/Core/index-source.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.cpp?rev=305508&r1=305507&r2=305508&view=diff
==============================================================================
--- cfe/trunk/test/Index/Core/index-source.cpp (original)
+++ cfe/trunk/test/Index/Core/index-source.cpp Thu Jun 15 16:19:01 2017
@@ -1,4 +1,4 @@
-// RUN: c-index-test core -print-source-symbols -- %s -std=c++14 -target x86_64-apple-macosx10.7 | FileCheck %s
+// RUN: c-index-test core -print-source-symbols -- %s -std=c++1z -target x86_64-apple-macosx10.7 | FileCheck %s
 
 // CHECK: [[@LINE+1]]:7 | class/C++ | Cls | [[Cls_USR:.*]] | <no-cgname> | Def | rel: 0
 class Cls { public:
@@ -449,3 +449,29 @@ void staticAssertInFn() {
 // CHECK: [[@LINE-3]]:17 | struct/C++ | StaticAssertRef | c:@S at StaticAssertRef | <no-cgname> | Ref,RelCont | rel: 1
 // CHECK-NEXT: RelCont | staticAssertInFn | c:@F at staticAssertInFn#
 }
+
+namespace cpp17structuredBinding {
+
+struct Cpp17StructuredBinding {
+  int x, y;
+
+  Cpp17StructuredBinding(int x, int y): x(x), y(y) { }
+};
+
+auto [structuredBinding1, structuredBinding2] = Cpp17StructuredBinding(Record::C, 0);
+// CHECK: [[@LINE-1]]:7 | variable/C++ | structuredBinding1 | c:@N at cpp17structuredBinding@structuredBinding1 | <no-cgname> | Decl,RelChild | rel: 1
+// CHECK-NEXT: RelChild | cpp17structuredBinding | c:@N at cpp17structuredBinding
+// CHECK: [[@LINE-3]]:27 | variable/C++ | structuredBinding2 | c:@N at cpp17structuredBinding@structuredBinding2 | <no-cgname> | Decl,RelChild | rel: 1
+// CHECK-NEXT: RelChild | cpp17structuredBinding | c:@N at cpp17structuredBinding
+
+void localStructuredBindingAndRef() {
+  int ref = structuredBinding1;
+// CHECK: [[@LINE-1]]:13 | variable/C++ | structuredBinding1 | c:@N at cpp17structuredBinding@structuredBinding1 | <no-cgname> | Ref,Read,RelCont | rel: 1
+// CHECK-NEXT: RelCont | localStructuredBindingAndRef | c:@N at cpp17structuredBinding@F at localStructuredBindingAndRef#
+  auto [localBinding1, localBinding2] = Cpp17StructuredBinding(ref, structuredBinding2);
+// CHECK: [[@LINE-1]]:69 | variable/C++ | structuredBinding2 | c:@N at cpp17structuredBinding@structuredBinding2 | <no-cgname> | Ref,Read,RelCont | rel: 1
+// CHECK-NEXT: RelCont | localStructuredBindingAndRef | c:@N at cpp17structuredBinding@F at localStructuredBindingAndRef#
+// CHECK-NOT: localBinding
+}
+
+}




More information about the cfe-commits mailing list