Skip to content

Commit

Permalink
[clangd] Handle the missing injectedClassNameType in targetDecl.
Browse files Browse the repository at this point in the history
Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

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

(cherry picked from commit 5d4e899)
  • Loading branch information
hokein committed Jun 10, 2020
1 parent 2378a6e commit 7918dbd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions clang-tools-extra/clangd/FindTarget.cpp
Expand Up @@ -373,6 +373,11 @@ struct TargetFinder {
void VisitTagType(const TagType *TT) {
Outer.add(TT->getAsTagDecl(), Flags);
}

void VisitInjectedClassNameType(const InjectedClassNameType *ICNT) {
Outer.add(ICNT->getDecl(), Flags);
}

void VisitDecltypeType(const DecltypeType *DTT) {
Outer.add(DTT->getUnderlyingType(), Flags | Rel::Underlying);
}
Expand Down
8 changes: 8 additions & 0 deletions clang-tools-extra/clangd/unittests/FindTargetTests.cpp
Expand Up @@ -286,6 +286,14 @@ TEST_F(TargetDeclTest, Types) {
)cpp";
// FIXME: We don't do a good job printing TemplateTypeParmDecls, apparently!
EXPECT_DECLS("SizeOfPackExpr", "");

Code = R"cpp(
template <typename T>
class Foo {
void f([[Foo]] x);
};
)cpp";
EXPECT_DECLS("InjectedClassNameTypeLoc", "class Foo");
}

TEST_F(TargetDeclTest, ClassTemplate) {
Expand Down

0 comments on commit 7918dbd

Please sign in to comment.