[PATCH] D66928: [clangd] Collecting main file macro expansion locations in ParsedAST.

Johan Vikström via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 29 10:07:38 PDT 2019


jvikstrom marked an inline comment as done.
jvikstrom added inline comments.


================
Comment at: clang-tools-extra/clangd/unittests/ClangdUnitTests.cpp:260
+    // Macros from token concatenations included.
+    #define CONCAT(X) X##1()
+    #define MACRO1() 123
----------------
ilya-biryukov wrote:
> Could we also test?
> ```
> #define PREPEND(X) Foo##X
> ```
> 
> It'll probably be the same, but still interesting to see whether it's any differnet.
So it turns out that the tests weren't actually passing before, must have accidentally forgot to save the file or something before compiling. Anyways tokens from concatenations are not included right now (which for highlighting is probably what we want, we don't highlight types/names that are from macro concatenations either)

But the reason they are not are because:
* They do not pass the `isInsideMainFile` check. Their file id is set to something that prints `<scratch space>` when dumped
* Even if they did pass the check the SourceLocation does not seem to be correct. They return the same SourceLocation as the parent `CONCAT` or `PREPEND`

Don't know how to fix any of this, and don't know if we actually want to collect these expansions either.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66928





More information about the cfe-commits mailing list