mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-11 10:26:44 +00:00
[clangd] Fix DocumentOutline for concepts
Summary: Fixes https://github.com/clangd/clangd/issues/256 Reviewers: kbobyrev Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D73056
This commit is contained in:
parent
04de24e690
commit
fb3d9153c0
@ -193,8 +193,11 @@ private:
|
||||
enum class VisitKind { No, OnlyDecl, DeclAndChildren };
|
||||
|
||||
void traverseDecl(Decl *D, std::vector<DocumentSymbol> &Results) {
|
||||
if (auto *Templ = llvm::dyn_cast<TemplateDecl>(D))
|
||||
D = Templ->getTemplatedDecl();
|
||||
if (auto *Templ = llvm::dyn_cast<TemplateDecl>(D)) {
|
||||
// TemplatedDecl might be null, e.g. concepts.
|
||||
if (auto *TD = Templ->getTemplatedDecl())
|
||||
D = TD;
|
||||
}
|
||||
auto *ND = llvm::dyn_cast<NamedDecl>(D);
|
||||
if (!ND)
|
||||
return;
|
||||
|
@ -449,6 +449,15 @@ TEST_F(DocumentSymbolsTest, DeclarationDefinition) {
|
||||
SymNameRange(Main.range("def")))));
|
||||
}
|
||||
|
||||
TEST_F(DocumentSymbolsTest, Concepts) {
|
||||
CDB.ExtraClangFlags = {"-std=c++2a"};
|
||||
std::string FilePath = testPath("foo.cpp");
|
||||
addFile(FilePath,
|
||||
"template <typename T> concept C = requires(T t) { t.foo(); };");
|
||||
|
||||
EXPECT_THAT(getSymbols(FilePath), ElementsAre(WithName("C")));
|
||||
}
|
||||
|
||||
TEST_F(DocumentSymbolsTest, ExternSymbol) {
|
||||
std::string FilePath = testPath("foo.cpp");
|
||||
addFile(testPath("foo.h"), R"cpp(
|
||||
|
Loading…
x
Reference in New Issue
Block a user