[clang-tools-extra] 0a888fa - [clangd] Handle IndirectFieldDecl in kindForDecl (#80588)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 5 00:22:21 PST 2024
Author: Nathan Ridge
Date: 2024-02-05T03:22:17-05:00
New Revision: 0a888fade2600dce737bc356a158e44c8f59b616
URL: https://github.com/llvm/llvm-project/commit/0a888fade2600dce737bc356a158e44c8f59b616
DIFF: https://github.com/llvm/llvm-project/commit/0a888fade2600dce737bc356a158e44c8f59b616.diff
LOG: [clangd] Handle IndirectFieldDecl in kindForDecl (#80588)
Fixes https://github.com/clangd/clangd/issues/1925
Added:
Modified:
clang-tools-extra/clangd/SemanticHighlighting.cpp
clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp b/clang-tools-extra/clangd/SemanticHighlighting.cpp
index ee3772e3d380c..08f99e11ac9be 100644
--- a/clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -136,7 +136,7 @@ std::optional<HighlightingKind> kindForDecl(const NamedDecl *D,
if (auto *OMD = dyn_cast<ObjCMethodDecl>(D))
return OMD->isClassMethod() ? HighlightingKind::StaticMethod
: HighlightingKind::Method;
- if (isa<FieldDecl, ObjCPropertyDecl>(D))
+ if (isa<FieldDecl, IndirectFieldDecl, ObjCPropertyDecl>(D))
return HighlightingKind::Field;
if (isa<EnumDecl>(D))
return HighlightingKind::Enum;
diff --git a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
index da12accc7898b..4156921d83edf 100644
--- a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -1076,6 +1076,22 @@ sizeof...($TemplateParameter[[Elements]]);
using $Class[[Y]]$Bracket[[<]]0$Bracket[[>]]::$Unknown_dependentName[[xxx]];
};
};
+ )cpp",
+ // Heuristically resolved IndirectFieldDecl
+ R"cpp(
+ template $Bracket[[<]]typename $TemplateParameter_def[[T]]$Bracket[[>]]
+ struct $Class_def[[Base]] {
+ struct {
+ int $Field_decl[[waldo]];
+ };
+ };
+ template $Bracket[[<]]typename $TemplateParameter_def[[T]]$Bracket[[>]]
+ struct $Class_def[[Derived]] : $Class[[Base]]$Bracket[[<]]$TemplateParameter[[T]]$Bracket[[>]] {
+ using $Class[[Base]]$Bracket[[<]]$TemplateParameter[[T]]$Bracket[[>]]::$Field_dependentName[[waldo]];
+ void $Method_def[[foo]]() {
+ $Field_dependentName[[waldo]];
+ }
+ };
)cpp"};
for (const auto &TestCase : TestCases)
// Mask off scope modifiers to keep the tests manageable.
More information about the cfe-commits
mailing list