summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/SemanticHighlighting.cpp
diff options
context:
space:
mode:
authorIlya Biryukov <ibiryukov@google.com>2019-10-28 11:31:06 +0100
committerIlya Biryukov <ibiryukov@google.com>2019-10-28 12:03:09 +0100
commitc814f4c4592cf0a6049a56b09442369d8e6eb9d7 (patch)
tree32f3e5d598341f8055f3b12a29336a2bd5a988cd /clang-tools-extra/clangd/SemanticHighlighting.cpp
parent5d35b7d9e1a34b45c19609f754050e4263bee4ce (diff)
downloadbcm5719-llvm-c814f4c4592cf0a6049a56b09442369d8e6eb9d7.tar.gz
bcm5719-llvm-c814f4c4592cf0a6049a56b09442369d8e6eb9d7.zip
[clangd] Do not highlight keywords in semantic highlighting
Summary: Editors are good at highlightings the keywords themselves. Note that this only affects highlightings of builtin types spelled out as keywords in the source code. Highlightings of typedefs to builtin types are unchanged. Reviewers: hokein Reviewed By: hokein Subscribers: merge_guards_bot, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69431
Diffstat (limited to 'clang-tools-extra/clangd/SemanticHighlighting.cpp')
-rw-r--r--clang-tools-extra/clangd/SemanticHighlighting.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp b/clang-tools-extra/clangd/SemanticHighlighting.cpp
index 61074852e36..464cbc4fcf8 100644
--- a/clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -49,7 +49,7 @@ llvm::Optional<HighlightingKind> kindForDecl(const NamedDecl *D) {
return HighlightingKind::Typedef;
}
// We highlight class decls, constructor decls and destructor decls as
- // `Class` type. The destructor decls are handled in `VisitTypeLoc` (we
+ // `Class` type. The destructor decls are handled in `VisitTagTypeLoc` (we
// will visit a TypeLoc where the underlying Type is a CXXRecordDecl).
if (auto *RD = llvm::dyn_cast<RecordDecl>(D)) {
// We don't want to highlight lambdas like classes.
@@ -214,25 +214,27 @@ public:
return true;
}
- bool WalkUpFromTagTypeLoc(TagTypeLoc L) {
+ bool VisitTagTypeLoc(TagTypeLoc L) {
if (L.isDefinition())
return true; // Definition will be highligthed by VisitNamedDecl.
- return RecursiveASTVisitor::WalkUpFromTagTypeLoc(L);
+ if (auto K = kindForType(L.getTypePtr()))
+ addToken(L.getBeginLoc(), *K);
+ return true;
}
- bool WalkUpFromElaboratedTypeLoc(ElaboratedTypeLoc L) {
- // Avoid highlighting 'struct' or 'enum' keywords.
+ bool VisitDecltypeTypeLoc(DecltypeTypeLoc L) {
+ if (auto K = kindForType(L.getTypePtr()))
+ addToken(L.getBeginLoc(), *K);
return true;
}
- bool WalkUpFromDependentNameTypeLoc(DependentNameTypeLoc L) {
+ bool VisitDependentNameTypeLoc(DependentNameTypeLoc L) {
addToken(L.getNameLoc(), HighlightingKind::DependentType);
return true;
}
- bool VisitTypeLoc(TypeLoc TL) {
- if (auto K = kindForType(TL.getTypePtr()))
- addToken(TL.getBeginLoc(), *K);
+ bool VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TL) {
+ addToken(TL.getBeginLoc(), HighlightingKind::TemplateParameter);
return true;
}
OpenPOWER on IntegriCloud