[PATCH] D111698: [clangd] IncludeCleaner: Handle macros coming from ScratchBuffer

Kirill Bobyrev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 13 07:12:28 PDT 2021


kbobyrev added inline comments.


================
Comment at: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp:170
 
+TEST(IncludeCleaner, ScratchBuffer) {
+  TestTU TU;
----------------
sammccall wrote:
> this doesn't seem to test very much, a comment should indicate that this is guarding against a crash.
> 
> Ideally we'd (also?) have a test that calls findReferencedFiles and actually assert which IDs we get, rather than run some big blob of code and hope not to crash.
Good point, I just ran into this for D111711:

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

foo.cpp
```
void foo() {}
```

`computeUnusedIncludes()` does not return `foo.h` but it wasn't processed (e.g. its ID was never in the `ReferencedFiles` in the first place) :(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111698



More information about the cfe-commits mailing list