Skip to content

Commit bf91a62

Browse files
authored
[NFC][bugpoint] Namespace cleanup in bugpoint (#168921)
Add declaration of command line options to BugDriver.h and remove extern declarations in individual .cpp files.
1 parent 9e2ca0d commit bf91a62

File tree

6 files changed

+13
-25
lines changed

6 files changed

+13
-25
lines changed

llvm/tools/bugpoint/BugDriver.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#define LLVM_TOOLS_BUGPOINT_BUGDRIVER_H
1717

1818
#include "llvm/IR/ValueMap.h"
19+
#include "llvm/Support/CommandLine.h"
1920
#include "llvm/Support/Error.h"
2021
#include "llvm/Support/FileSystem.h"
2122
#include "llvm/Transforms/Utils/ValueMapper.h"
@@ -41,6 +42,10 @@ extern bool DisableSimplifyCFG;
4142
///
4243
extern bool BugpointIsInterrupted;
4344

45+
/// Command line options used across files.
46+
extern cl::list<std::string> InputArgv;
47+
extern cl::opt<std::string> OutputPrefix;
48+
4449
class BugDriver {
4550
LLVMContext &Context;
4651
const char *ToolName; // argv[0] of bugpoint

llvm/tools/bugpoint/CrashDebugger.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,9 @@ static bool isValidModule(std::unique_ptr<Module> &M,
8787
return false;
8888
}
8989

90-
namespace llvm {
9190
// Note this class needs to be in llvm namespace since its declared as a friend
9291
// of BugDriver.
93-
class ReducePassList : public ListReducer<std::string> {
92+
class llvm::ReducePassList : public ListReducer<std::string> {
9493
BugDriver &BD;
9594

9695
public:
@@ -102,7 +101,6 @@ class ReducePassList : public ListReducer<std::string> {
102101
Expected<TestResult> doTest(std::vector<std::string> &Removed,
103102
std::vector<std::string> &Kept) override;
104103
};
105-
} // namespace llvm
106104

107105
Expected<ReducePassList::TestResult>
108106
ReducePassList::doTest(std::vector<std::string> &Prefix,

llvm/tools/bugpoint/ExecutionDriver.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
#include "BugDriver.h"
1515
#include "ToolRunner.h"
16-
#include "llvm/Support/CommandLine.h"
1716
#include "llvm/Support/Debug.h"
1817
#include "llvm/Support/FileUtilities.h"
1918
#include "llvm/Support/Program.h"
@@ -102,15 +101,13 @@ static cl::opt<std::string> CustomExecCommand(
102101

103102
// Anything specified after the --args option are taken as arguments to the
104103
// program being debugged.
105-
namespace llvm {
106-
cl::list<std::string> InputArgv("args", cl::Positional,
107-
cl::desc("<program arguments>..."),
108-
cl::PositionalEatsArgs);
109-
110-
cl::opt<std::string>
111-
OutputPrefix("output-prefix", cl::init("bugpoint"),
112-
cl::desc("Prefix to use for outputs (default: 'bugpoint')"));
113-
} // namespace llvm
104+
cl::list<std::string> llvm::InputArgv("args", cl::Positional,
105+
cl::desc("<program arguments>..."),
106+
cl::PositionalEatsArgs);
107+
108+
cl::opt<std::string> llvm::OutputPrefix(
109+
"output-prefix", cl::init("bugpoint"),
110+
cl::desc("Prefix to use for outputs (default: 'bugpoint')"));
114111

115112
static cl::list<std::string> ToolArgv("tool-args", cl::Positional,
116113
cl::desc("<tool arguments>..."),

llvm/tools/bugpoint/ExtractFunction.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ using namespace llvm;
3636
#define DEBUG_TYPE "bugpoint"
3737

3838
bool llvm::DisableSimplifyCFG = false;
39-
namespace llvm {
40-
extern cl::opt<std::string> OutputPrefix;
41-
} // namespace llvm
4239

4340
static cl::opt<bool>
4441
NoDCE("disable-dce",

llvm/tools/bugpoint/Miscompilation.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@
2828

2929
using namespace llvm;
3030

31-
namespace llvm {
32-
extern cl::opt<std::string> OutputPrefix;
33-
extern cl::list<std::string> InputArgv;
34-
} // end namespace llvm
35-
3631
static cl::opt<bool> DisableLoopExtraction(
3732
"disable-loop-extraction",
3833
cl::desc("Don't extract loops when searching for miscompilations"),

llvm/tools/bugpoint/OptimizerDriver.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ using namespace llvm;
3434

3535
#define DEBUG_TYPE "bugpoint"
3636

37-
namespace llvm {
38-
extern cl::opt<std::string> OutputPrefix;
39-
}
40-
4137
static cl::opt<std::string>
4238
OptCmd("opt-command", cl::init(""),
4339
cl::desc("Path to opt. (default: search path "

0 commit comments

Comments
 (0)