[clang-tools-extra] [clangd] Add config option to allow detection of unused system headers (PR #87208)

Vadim D. via cfe-commits cfe-commits at lists.llvm.org
Fri May 10 17:28:41 PDT 2024


================
@@ -135,6 +135,21 @@ TEST(IncludeCleaner, GetUnusedHeaders) {
                            Pointee(writtenInclusion("\"dir/unused.h\""))));
 }
 
+TEST(IncludeCleaner, SystemUnusedHeaders) {
+  auto TU = TestTU::withCode(R"cpp(
+    #include <system_header.h>
+    #include <system_unused.h>
+    SystemClass x;
+  )cpp");
+  TU.AdditionalFiles["system/system_header.h"] = guard("class SystemClass {};");
+  TU.AdditionalFiles["system/system_unused.h"] = guard("");
+  TU.ExtraArgs = {"-isystem", testPath("system")};
----------------
vvd170501 wrote:

I've copied `-isystem` from the `GetUnusedHeaders` test.
If `AnalyzeSystemHeaders` / `AnalyzeAngledIncludes` must work for inclusions of any type, then maybe it'd be better to test both `-I` and `-isystem`?

https://github.com/llvm/llvm-project/pull/87208


More information about the cfe-commits mailing list