File tree 2 files changed +14
-2
lines changed
2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -193,8 +193,11 @@ class DocumentOutline {
193
193
enum class VisitKind { No, OnlyDecl, DeclAndChildren };
194
194
195
195
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
+ }
198
201
auto *ND = llvm::dyn_cast<NamedDecl>(D);
199
202
if (!ND)
200
203
return ;
Original file line number Diff line number Diff line change @@ -449,6 +449,15 @@ TEST_F(DocumentSymbolsTest, DeclarationDefinition) {
449
449
SymNameRange (Main.range (" def" )))));
450
450
}
451
451
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
+
452
461
TEST_F (DocumentSymbolsTest, ExternSymbol) {
453
462
std::string FilePath = testPath (" foo.cpp" );
454
463
addFile (testPath (" foo.h" ), R"cpp(
You can’t perform that action at this time.
0 commit comments