This revision was automatically updated to reflect the committed changes. Closed by commit rG67e94c9dc8ff: [include-cleaner] Ignore the layering-violation errors for the standalone tool (authored by hokein).
Changed prior to commit: https://reviews.llvm.org/D154477?vs=537240&id=537292#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D154477/new/ https://reviews.llvm.org/D154477 Files: clang-tools-extra/include-cleaner/test/Inputs/modules/a.h clang-tools-extra/include-cleaner/test/Inputs/modules/module.map clang-tools-extra/include-cleaner/test/module.cpp clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp Index: clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp =================================================================== --- clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp +++ clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp @@ -95,6 +95,15 @@ 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)); Index: clang-tools-extra/include-cleaner/test/module.cpp =================================================================== --- /dev/null +++ clang-tools-extra/include-cleaner/test/module.cpp @@ -0,0 +1,7 @@ +// 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"{{$}} Index: clang-tools-extra/include-cleaner/test/Inputs/modules/module.map =================================================================== --- /dev/null +++ clang-tools-extra/include-cleaner/test/Inputs/modules/module.map @@ -0,0 +1,2 @@ +module XA { +} Index: clang-tools-extra/include-cleaner/test/Inputs/modules/a.h =================================================================== --- /dev/null +++ clang-tools-extra/include-cleaner/test/Inputs/modules/a.h @@ -0,0 +1,2 @@ +#pragma once +class A {};
Index: clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp =================================================================== --- clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp +++ clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp @@ -95,6 +95,15 @@ 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)); Index: clang-tools-extra/include-cleaner/test/module.cpp =================================================================== --- /dev/null +++ clang-tools-extra/include-cleaner/test/module.cpp @@ -0,0 +1,7 @@ +// 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"{{$}} Index: clang-tools-extra/include-cleaner/test/Inputs/modules/module.map =================================================================== --- /dev/null +++ clang-tools-extra/include-cleaner/test/Inputs/modules/module.map @@ -0,0 +1,2 @@ +module XA { +} Index: clang-tools-extra/include-cleaner/test/Inputs/modules/a.h =================================================================== --- /dev/null +++ clang-tools-extra/include-cleaner/test/Inputs/modules/a.h @@ -0,0 +1,2 @@ +#pragma once +class A {};
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits