[clang-tools-extra] [clangd] Handle IndirectFieldDecl in kindForDecl (PR #80588)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Feb 3 23:24:47 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clangd
Author: Nathan Ridge (HighCommander4)
<details>
<summary>Changes</summary>
Fixes https://github.com/clangd/clangd/issues/1925
---
Full diff: https://github.com/llvm/llvm-project/pull/80588.diff
2 Files Affected:
- (modified) clang-tools-extra/clangd/SemanticHighlighting.cpp (+1-1)
- (modified) clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp (+15)
``````````diff
diff --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp b/clang-tools-extra/clangd/SemanticHighlighting.cpp
index 37939d36425a9..078b40c9db148 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..baac122d2137b 100644
--- a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -1076,6 +1076,21 @@ sizeof...($TemplateParameter[[Elements]]);
using $Class[[Y]]$Bracket[[<]]0$Bracket[[>]]::$Unknown_dependentName[[xxx]];
};
};
+ )cpp",
+ 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.
``````````
</details>
https://github.com/llvm/llvm-project/pull/80588
More information about the cfe-commits
mailing list