[PATCH] D70740: [clangd] Find reference to template parameter in 'sizeof...' expression
Nathan Ridge via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Nov 30 21:11:07 PST 2019
nridge updated this revision to Diff 231608.
nridge added a comment.
Address review comment
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D70740/new/
https://reviews.llvm.org/D70740
Files:
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/unittests/FindTargetTests.cpp
clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -625,6 +625,13 @@
$InactiveCode[[]] #else
int $Variable[[Active2]];
#endif
+ )cpp",
+ // Argument to 'sizeof...'
+ R"cpp(
+ template <typename... $TemplateParameter[[Elements]]>
+ struct $Class[[TupleSize]] {
+ static const int $StaticField[[size]] = sizeof...($TemplateParameter[[Elements]]);
+ };
)cpp"};
for (const auto &TestCase : TestCases) {
checkHighlightings(TestCase);
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -260,6 +260,15 @@
)cpp";
// FIXME: deduced type missing in AST. https://llvm.org/PR42914
EXPECT_DECLS("AutoTypeLoc");
+
+ Code = R"cpp(
+ template <typename... E>
+ struct S {
+ static const int size = sizeof...([[E]]);
+ };
+ )cpp";
+ // FIXME: We don't do a good job printing TemplateTypeParmDecls, apparently!
+ EXPECT_DECLS("SizeOfPackExpr", "");
}
TEST_F(TargetDeclTest, ClassTemplate) {
Index: clang-tools-extra/clangd/FindTarget.cpp
===================================================================
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -194,6 +194,9 @@
for (auto *D : OE->decls())
Outer.add(D, Flags);
}
+ void VisitSizeOfPackExpr(const SizeOfPackExpr *SE) {
+ Outer.add(SE->getPack(), Flags);
+ }
void VisitCXXConstructExpr(const CXXConstructExpr *CCE) {
Outer.add(CCE->getConstructor(), Flags);
}
@@ -491,6 +494,13 @@
llvm::SmallVector<const NamedDecl *, 1>(
E->decls().begin(), E->decls().end())});
}
+
+ void VisitSizeOfPackExpr(const SizeOfPackExpr *E) {
+ Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
+ E->getPackLoc(),
+ /*IsDecl=*/false,
+ {E->getPack()}});
+ }
};
Visitor V;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70740.231608.patch
Type: text/x-patch
Size: 2429 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191201/ee024841/attachment-0001.bin>
More information about the cfe-commits
mailing list