diff options
| author | Alex Lorenz <arphaman@gmail.com> | 2017-06-15 20:50:43 +0000 |
|---|---|---|
| committer | Alex Lorenz <arphaman@gmail.com> | 2017-06-15 20:50:43 +0000 |
| commit | 60aac43813beccb33f72d15967ae4f21a789238d (patch) | |
| tree | 6764f2f3ed7a84e2f5dd8490bc6a46fe1f669f54 | |
| parent | 7a27a26db0135772ce5c7c01e2a77ddc577846a7 (diff) | |
| download | bcm5719-llvm-60aac43813beccb33f72d15967ae4f21a789238d.tar.gz bcm5719-llvm-60aac43813beccb33f72d15967ae4f21a789238d.zip | |
[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
llvm-svn: 305504
| -rw-r--r-- | clang/lib/Index/IndexDecl.cpp | 7 | ||||
| -rw-r--r-- | clang/test/Index/Core/index-source.cpp | 16 |
2 files changed, 23 insertions, 0 deletions
diff --git a/clang/lib/Index/IndexDecl.cpp b/clang/lib/Index/IndexDecl.cpp index 870b4e4fe82..c4e9a1a10a3 100644 --- a/clang/lib/Index/IndexDecl.cpp +++ b/clang/lib/Index/IndexDecl.cpp @@ -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 diff --git a/clang/test/Index/Core/index-source.cpp b/clang/test/Index/Core/index-source.cpp index 8b049314ffb..61b7b00463a 100644 --- a/clang/test/Index/Core/index-source.cpp +++ b/clang/test/Index/Core/index-source.cpp @@ -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@StaticAssertRef@constVar | __ZN15StaticAssertRef8constVarE | Ref | rel: 0 +// CHECK: [[@LINE-2]]:15 | struct/C++ | StaticAssertRef | c:@S@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@StaticAssertRef@constVar | __ZN15StaticAssertRef8constVarE | Ref,RelCont | rel: 1 +// CHECK-NEXT: RelCont | staticAssertInFn | c:@F@staticAssertInFn# +// CHECK: [[@LINE-3]]:17 | struct/C++ | StaticAssertRef | c:@S@StaticAssertRef | <no-cgname> | Ref,RelCont | rel: 1 +// CHECK-NEXT: RelCont | staticAssertInFn | c:@F@staticAssertInFn# +} |

