File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -193,8 +193,11 @@ class DocumentOutline {
193193 enum class VisitKind { No, OnlyDecl, DeclAndChildren };
194194
195195 void traverseDecl (Decl *D, std::vector<DocumentSymbol> &Results) {
196- if (auto *Templ = llvm::dyn_cast<TemplateDecl>(D))
197- D = Templ->getTemplatedDecl ();
196+ if (auto *Templ = llvm::dyn_cast<TemplateDecl>(D)) {
197+ // TemplatedDecl might be null, e.g. concepts.
198+ if (auto *TD = Templ->getTemplatedDecl ())
199+ D = TD;
200+ }
198201 auto *ND = llvm::dyn_cast<NamedDecl>(D);
199202 if (!ND)
200203 return ;
Original file line number Diff line number Diff line change @@ -449,6 +449,15 @@ TEST_F(DocumentSymbolsTest, DeclarationDefinition) {
449449 SymNameRange (Main.range (" def" )))));
450450}
451451
452+ TEST_F (DocumentSymbolsTest, Concepts) {
453+ CDB.ExtraClangFlags = {" -std=c++2a" };
454+ std::string FilePath = testPath (" foo.cpp" );
455+ addFile (FilePath,
456+ " template <typename T> concept C = requires(T t) { t.foo(); };" );
457+
458+ EXPECT_THAT (getSymbols (FilePath), ElementsAre (WithName (" C" )));
459+ }
460+
452461TEST_F (DocumentSymbolsTest, ExternSymbol) {
453462 std::string FilePath = testPath (" foo.cpp" );
454463 addFile (testPath (" foo.h" ), R"cpp(
You can’t perform that action at this time.
0 commit comments