[PATCH] D64741: [clangd] Added highlighting for tokens that are macro arguments.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 17 02:15:24 PDT 2019


hokein added inline comments.


================
Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:170
+        return;
+      Loc = SM.getSpellingLoc(Loc);
+    }
----------------
jvikstrom wrote:
> hokein wrote:
> > The Loc here maybe not in the main file, considering the case
> > 
> > ```
> > // in .h
> > #define DEFINE(X) in X;
> > #define DEFINE_Y DEFINE(Y)
> > 
> > // in .cc
> > 
> > DEFINE_Y
> > ```
> The spelling loc is still going to be in `DEFINE_Y` I think. And we only highlight arguments in macros. (Added a testcase though)
ok, I don't have an exact case for macros now, but my gut feeling tells me we will encounter cases where the Loc is not in main file.

here is a test case for declarations, we will visit the `foo()` decl in `test.h` as well. This could be addressed in a separate patch.

```
// test.h
void foo();

// test.cc
#include "test.h"
void foo() {}
```



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64741





More information about the cfe-commits mailing list