[PATCH] D66995: [clangd] Add highlighting for macro expansions.

Johan Vikström via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 30 06:54:39 PDT 2019


jvikstrom added inline comments.


================
Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:469
+  case HighlightingKind::MacroExpansion:
+    return "entity.name.function.preprocessor.expansion.cpp";
   case HighlightingKind::NumKinds:
----------------
ilya-biryukov wrote:
> Is there a place on the internet with conventional textmate scope names?
> Or do we come up with these on our own?
This is from the vscode c++ extension. (we mostly use the same scopes as in that extension, but in a few cases we have our own scopes as there aren't any in vscode)


================
Comment at: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp:394
       #define DEF_MULTIPLE(X) namespace X { class X { int X; }; }
       #define DEF_CLASS(T) class T {};
+      $MacroExpansion[[DEF_MULTIPLE]](XYZ);
----------------
hokein wrote:
> ilya-biryukov wrote:
> > Similar to how we highlight everything else, we should also highlight macro declarations and usages (i.e. expansions in the same way).
> > Could we add the corresponding highlightings?
> > ```
> > #define $Macro[[DEF_CLASS]](T) class T T{}
> > $Macro[[DEF_CLASS]](A);
> > ```
> +1, I think we could name the HighlightingKind as `Macro` instead of `MacroExpansion`  (even through we don't highlighting the macro def yet).
We don't seem to collect information about where macro declarations are in the code in ParsedAST.
Added a fixme to add it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66995





More information about the cfe-commits mailing list