78
78
79
79
using namespace llvm ;
80
80
81
- static const char LintAbortOnErrorArgName[] = " lint-abort-on-error" ;
82
- static cl::opt<bool >
83
- LintAbortOnError (LintAbortOnErrorArgName, cl::init(false ),
84
- cl::desc(" In the Lint pass, abort on errors." ));
85
-
86
81
namespace {
87
82
namespace MemRef {
88
83
static const unsigned Read = 1 ;
@@ -747,20 +742,26 @@ PreservedAnalyses LintPass::run(Function &F, FunctionAnalysisManager &AM) {
747
742
Lint L (Mod, DL, AA, AC, DT, TLI);
748
743
L.visit (F);
749
744
dbgs () << L.MessagesStr .str ();
750
- if (LintAbortOnError && !L.MessagesStr .str ().empty ())
751
- report_fatal_error (Twine (" Linter found errors, aborting. (enabled by --" ) +
752
- LintAbortOnErrorArgName + " )" ,
753
- false );
745
+ if (AbortOnError && !L.MessagesStr .str ().empty ())
746
+ report_fatal_error (
747
+ " linter found errors, aborting. (enabled by abort-on-error)" , false );
754
748
return PreservedAnalyses::all ();
755
749
}
756
750
751
+ void LintPass::printPipeline (
752
+ raw_ostream &OS, function_ref<StringRef(StringRef)> MapClassName2PassName) {
753
+ PassInfoMixin<LintPass>::printPipeline (OS, MapClassName2PassName);
754
+ if (AbortOnError)
755
+ OS << " <abort-on-error>" ;
756
+ }
757
+
757
758
// ===----------------------------------------------------------------------===//
758
759
// Implement the public interfaces to this file...
759
760
// ===----------------------------------------------------------------------===//
760
761
761
762
// / lintFunction - Check a function for errors, printing messages on stderr.
762
763
// /
763
- void llvm::lintFunction (const Function &f) {
764
+ void llvm::lintFunction (const Function &f, bool AbortOnError ) {
764
765
Function &F = const_cast <Function &>(f);
765
766
assert (!F.isDeclaration () && " Cannot lint external functions" );
766
767
@@ -775,14 +776,14 @@ void llvm::lintFunction(const Function &f) {
775
776
AA.registerFunctionAnalysis <TypeBasedAA>();
776
777
return AA;
777
778
});
778
- LintPass ().run (F, FAM);
779
+ LintPass (AbortOnError ).run (F, FAM);
779
780
}
780
781
781
782
// / lintModule - Check a module for errors, printing messages on stderr.
782
783
// /
783
- void llvm::lintModule (const Module &M) {
784
+ void llvm::lintModule (const Module &M, bool AbortOnError ) {
784
785
for (const Function &F : M) {
785
786
if (!F.isDeclaration ())
786
- lintFunction (F);
787
+ lintFunction (F, AbortOnError );
787
788
}
788
789
}
0 commit comments