[PATCH] D67901: [clangd] Improve semantic highlighting in dependent contexts (fixes #154)

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 2 01:54:09 PDT 2019


ilya-biryukov added inline comments.


================
Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:219
+  bool VisitDependentNameTypeLoc(DependentNameTypeLoc L) {
+    addToken(L.getNameLoc(), HighlightingKind::DependentType);
+    return true;
----------------
nridge wrote:
> hokein wrote:
> > nit: we have `kindForType` for hanlding all types, so I'd move the logic of detecting the dependent type there.
> I did try this, but it doesn't quite work, because `VisitTypeLoc` adds the highlighting to the `TypeLoc`'s `getBeginLoc()`. For something like `typename T::type`, that highlights the `typename` token rather than the `type` token. By contrast, here I add the highlighting to the `DependentNameTypeLoc`'s `getNameLoc()` which will correctly highlight the `type` token.
You'd want to implement `WalkUpFromDependentNameTypeLoc` instead of `Visit*` to avoid adding extra highlightings in `VisitTypeLoc`.

In fact, I'm surprised we're not seeing them now.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67901/new/

https://reviews.llvm.org/D67901





More information about the cfe-commits mailing list