r305504 - [index] Index static_assert declarations

Alex Lorenz via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 15 13:50:43 PDT 2017


Author: arphaman
Date: Thu Jun 15 15:50:43 2017
New Revision: 305504

URL: http://llvm.org/viewvc/llvm-project?rev=305504&view=rev
Log:
[index] Index static_assert declarations

static_assert declarations have to be visited while indexing so that we can
gather the references to declarations that are present in their assert
expression.

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

Modified:
    cfe/trunk/lib/Index/IndexDecl.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=305504&r1=305503&r2=305504&view=diff
==============================================================================
--- cfe/trunk/lib/Index/IndexDecl.cpp (original)
+++ cfe/trunk/lib/Index/IndexDecl.cpp Thu Jun 15 15:50:43 2017
@@ -682,6 +682,13 @@ public:
   bool VisitImportDecl(const ImportDecl *D) {
     return IndexCtx.importedModule(D);
   }
+
+  bool VisitStaticAssertDecl(const StaticAssertDecl *D) {
+    IndexCtx.indexBody(D->getAssertExpr(),
+                       dyn_cast<NamedDecl>(D->getDeclContext()),
+                       D->getLexicalDeclContext());
+    return true;
+  }
 };
 
 } // anonymous namespace

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=305504&r1=305503&r2=305504&view=diff
==============================================================================
--- cfe/trunk/test/Index/Core/index-source.cpp (original)
+++ cfe/trunk/test/Index/Core/index-source.cpp Thu Jun 15 15:50:43 2017
@@ -433,3 +433,19 @@ template<typename T>
 T varDecl = T();
 
 } // end namespace ensureDefaultTemplateParamsAreRecordedOnce
+
+struct StaticAssertRef {
+  static constexpr bool constVar = true;
+};
+
+static_assert(StaticAssertRef::constVar, "index static asserts");
+// CHECK: [[@LINE-1]]:32 | static-property/C++ | constVar | c:@S at StaticAssertRef@constVar | __ZN15StaticAssertRef8constVarE | Ref | rel: 0
+// CHECK: [[@LINE-2]]:15 | struct/C++ | StaticAssertRef | c:@S at StaticAssertRef | <no-cgname> | Ref | rel: 0
+
+void staticAssertInFn() {
+  static_assert(StaticAssertRef::constVar, "index static asserts");
+// CHECK: [[@LINE-1]]:34 | static-property/C++ | constVar | c:@S at StaticAssertRef@constVar | __ZN15StaticAssertRef8constVarE | Ref,RelCont | rel: 1
+// CHECK-NEXT: RelCont | staticAssertInFn | c:@F at 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#
+}




More information about the cfe-commits mailing list