[PATCH] D131175: [clangd] Use the "macro" semantic token for pre-defined identifiers
Christian Kandeler via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 4 08:57:42 PDT 2022
ckandeler created this revision.
ckandeler added reviewers: sammccall, nridge.
Herald added subscribers: usaxena95, kadircet, arphaman.
Herald added a project: All.
ckandeler requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.
This matches user expectations.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D131175
Files:
clang-tools-extra/clangd/SemanticHighlighting.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
@@ -841,6 +841,12 @@
$Function_deprecated[[Foo]]($Parameter[[x]]);
}
)cpp",
+ // Predefined identifiers
+ R"cpp(
+ void $Function_decl[[Foo]]() {
+ const char *$LocalVariable_decl_readonly[[s]] = $Macro[[__func__]];
+ }
+ )cpp",
// Explicit template specialization
R"cpp(
struct $Class_decl[[Base]]{};
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===================================================================
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -542,6 +542,11 @@
return Base::TraverseConstructorInitializer(Init);
}
+ bool VisitPredefinedExpr(PredefinedExpr *E) {
+ H.addToken(E->getLocation(), HighlightingKind::Macro);
+ return true;
+ }
+
bool VisitCallExpr(CallExpr *E) {
// Highlighting parameters passed by non-const reference does not really
// make sense for literals...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131175.450006.patch
Type: text/x-patch
Size: 1274 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220804/202aa7fa/attachment.bin>
More information about the cfe-commits
mailing list