[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 03:13:36 PDT 2019
jvikstrom added inline comments.
================
Comment at: clang-tools-extra/clangd/unittests/ClangdUnitTests.cpp:248
+TEST(ClangdUnitTest, CollectsMainFileMacroExpansions) {
+ Annotations TestCase(R"cpp(
+ #define MACRO_ARGS(X, Y) X Y
----------------
ilya-biryukov wrote:
> Could you add a few more interesting cases?
>
> 1. Macros outside the main file **and** the preamble:
> ```
> // foo.inc
> int a = ID(1);
>
> // foo.cpp
> #define ID(X) X
>
> int b;
> #include "foo.inc"
> ```
>
> 2. macro expansions from token concatenations
> ```
> #define FOO(X) X##1()
> #define MACRO1() 123
>
> int a = FOO(MACRO);
> ```
> 3. Macro names inside other macros:
> ```
> #define FOO BAR
> #define BAR 1
>
>
> int a = FOO; // should BAR at line 1 be highlighted?
>
> ```
>
> 4. #include not part of the preamble:
> ```
> #define FOO 1
>
> // Preamble ends here.
> int a = 10;
> #include "some_file_with_macros.h" // <-- should not get any macros from here
> ```
Does clangd handle `.inc` files differently from `.h`? Because if it doesn't shouldn't ` case 1 cover case 4 as well ?
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