From 248d1c65f1ce5bc04b892998b2c2061e6a5f8e1c Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 5 Aug 2010 03:00:22 +0000 Subject: [PATCH] Add const to compileProgram and to the various test functions in CrashDebugger. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110306 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/bugpoint/BugDriver.h | 2 +- tools/bugpoint/CrashDebugger.cpp | 26 ++++++++++++++------------ tools/bugpoint/ExecutionDriver.cpp | 2 +- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/tools/bugpoint/BugDriver.h b/tools/bugpoint/BugDriver.h index 96113552d60..fb5ae2959c8 100644 --- a/tools/bugpoint/BugDriver.h +++ b/tools/bugpoint/BugDriver.h @@ -165,7 +165,7 @@ public: /// setting Error if an error occurs. This is used for code generation /// crash testing. /// - void compileProgram(Module *M, std::string *Error); + void compileProgram(Module *M, std::string *Error) const; /// executeProgram - This method runs "Program", capturing the output of the /// program to a file. A recommended filename may be optionally specified. diff --git a/tools/bugpoint/CrashDebugger.cpp b/tools/bugpoint/CrashDebugger.cpp index c4232033890..f96554b6f82 100644 --- a/tools/bugpoint/CrashDebugger.cpp +++ b/tools/bugpoint/CrashDebugger.cpp @@ -106,10 +106,10 @@ namespace { /// class ReduceCrashingGlobalVariables : public ListReducer { BugDriver &BD; - bool (*TestFn)(BugDriver &, Module *); + bool (*TestFn)(const BugDriver &, Module *); public: ReduceCrashingGlobalVariables(BugDriver &bd, - bool (*testFn)(BugDriver &, Module *)) + bool (*testFn)(const BugDriver &, Module *)) : BD(bd), TestFn(testFn) {} virtual TestResult doTest(std::vector &Prefix, @@ -176,10 +176,10 @@ namespace llvm { /// class ReduceCrashingFunctions : public ListReducer { BugDriver &BD; - bool (*TestFn)(BugDriver &, Module *); + bool (*TestFn)(const BugDriver &, Module *); public: ReduceCrashingFunctions(BugDriver &bd, - bool (*testFn)(BugDriver &, Module *)) + bool (*testFn)(const BugDriver &, Module *)) : BD(bd), TestFn(testFn) {} virtual TestResult doTest(std::vector &Prefix, @@ -249,9 +249,10 @@ namespace { /// class ReduceCrashingBlocks : public ListReducer { BugDriver &BD; - bool (*TestFn)(BugDriver &, Module *); + bool (*TestFn)(const BugDriver &, Module *); public: - ReduceCrashingBlocks(BugDriver &bd, bool (*testFn)(BugDriver &, Module *)) + ReduceCrashingBlocks(BugDriver &bd, + bool (*testFn)(const BugDriver &, Module *)) : BD(bd), TestFn(testFn) {} virtual TestResult doTest(std::vector &Prefix, @@ -348,10 +349,10 @@ namespace { /// class ReduceCrashingInstructions : public ListReducer { BugDriver &BD; - bool (*TestFn)(BugDriver &, Module *); + bool (*TestFn)(const BugDriver &, Module *); public: - ReduceCrashingInstructions(BugDriver &bd, bool (*testFn)(BugDriver &, - Module *)) + ReduceCrashingInstructions(BugDriver &bd, + bool (*testFn)(const BugDriver &, Module *)) : BD(bd), TestFn(testFn) {} virtual TestResult doTest(std::vector &Prefix, @@ -422,7 +423,8 @@ bool ReduceCrashingInstructions::TestInsts(std::vector /// DebugACrash - Given a predicate that determines whether a component crashes /// on a program, try to destructively reduce the program while still keeping /// the predicate true. -static bool DebugACrash(BugDriver &BD, bool (*TestFn)(BugDriver &, Module *), +static bool DebugACrash(BugDriver &BD, + bool (*TestFn)(const BugDriver &, Module *), std::string &Error) { // See if we can get away with nuking some of the global variable initializers // in the program... @@ -607,7 +609,7 @@ ExitLoops: return false; } -static bool TestForOptimizerCrash(BugDriver &BD, Module *M) { +static bool TestForOptimizerCrash(const BugDriver &BD, Module *M) { return BD.runPasses(M); } @@ -635,7 +637,7 @@ bool BugDriver::debugOptimizerCrash(const std::string &ID) { return Success; } -static bool TestForCodeGenCrash(BugDriver &BD, Module *M) { +static bool TestForCodeGenCrash(const BugDriver &BD, Module *M) { std::string Error; BD.compileProgram(M, &Error); if (!Error.empty()) { diff --git a/tools/bugpoint/ExecutionDriver.cpp b/tools/bugpoint/ExecutionDriver.cpp index 28f61c8fe67..73124849324 100644 --- a/tools/bugpoint/ExecutionDriver.cpp +++ b/tools/bugpoint/ExecutionDriver.cpp @@ -293,7 +293,7 @@ bool BugDriver::initializeExecutionEnvironment() { /// setting Error if an error occurs. This is used for code generation /// crash testing. /// -void BugDriver::compileProgram(Module *M, std::string *Error) { +void BugDriver::compileProgram(Module *M, std::string *Error) const { // Emit the program to a bitcode file... sys::Path BitcodeFile (OutputPrefix + "-test-program.bc"); std::string ErrMsg;