diff --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp b/clang-tools-extra/clangd/SemanticHighlighting.cpp --- a/clang-tools-extra/clangd/SemanticHighlighting.cpp +++ b/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... diff --git a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp --- a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp +++ b/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]]{};