If the source code is compilable-but-layering-violation, we still want
the tool to be functional on it (rather than bailing out).
Differential Revision: https://reviews.llvm.org/D154477
--- /dev/null
+#pragma once
+class A {};
--- /dev/null
+module XA {
+}
--- /dev/null
+// RUN: cp %s %t.cpp
+// RUN: clang-include-cleaner -edit %t.cpp -- -I%S/Inputs/modules -fimplicit-module-maps -fmodules-strict-decluse -fmodule-name=XA
+// RUN: FileCheck --match-full-lines --check-prefix=EDIT %s < %t.cpp
+
+// Verify the tool still works on compilable-but-layering-violation code.
+#include "a.h"
+// EDIT-NOT: {{^}}#include "a.h"{{$}}
RecordedPP PP;
PragmaIncludes PI;
+ bool BeginInvocation(CompilerInstance &CI) override {
+ // We only perform include-cleaner analysis. So we disable diagnostics that
+ // won't affect our analysis to make the tool more robust against
+ // in-development code.
+ CI.getLangOpts().ModulesDeclUse = false;
+ CI.getLangOpts().ModulesStrictDeclUse = false;
+ return true;
+ }
+
void ExecuteAction() override {
auto &P = getCompilerInstance().getPreprocessor();
P.addPPCallbacks(PP.record(P));