[llvm] [NFC][bugpoint] Namespace cleanup in `bugpoint` (PR #168921)
Rahul Joshi via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 20 09:57:52 PST 2025
https://github.com/jurahul created https://github.com/llvm/llvm-project/pull/168921
Add declaration of command line options to BugDriver.h and remove extern declarations in individual .cpp files.
>From 403b5dc033f663887cb74160a22d69eac5326e2b Mon Sep 17 00:00:00 2001
From: Rahul Joshi <rjoshi at nvidia.com>
Date: Thu, 20 Nov 2025 09:53:44 -0800
Subject: [PATCH] [NFC][bugpoint] Namespace cleanup in `bugpoint`
Add declaration of command line options to BugDriver.h and remove
extern declarations in individual .cpp files.
---
llvm/tools/bugpoint/BugDriver.h | 5 +++++
llvm/tools/bugpoint/CrashDebugger.cpp | 4 +---
llvm/tools/bugpoint/ExecutionDriver.cpp | 17 +++++++----------
llvm/tools/bugpoint/ExtractFunction.cpp | 3 ---
llvm/tools/bugpoint/Miscompilation.cpp | 5 -----
llvm/tools/bugpoint/OptimizerDriver.cpp | 4 ----
6 files changed, 13 insertions(+), 25 deletions(-)
diff --git a/llvm/tools/bugpoint/BugDriver.h b/llvm/tools/bugpoint/BugDriver.h
index ca57405f9d770..71a5aa14bbb2e 100644
--- a/llvm/tools/bugpoint/BugDriver.h
+++ b/llvm/tools/bugpoint/BugDriver.h
@@ -16,6 +16,7 @@
#define LLVM_TOOLS_BUGPOINT_BUGDRIVER_H
#include "llvm/IR/ValueMap.h"
+#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Transforms/Utils/ValueMapper.h"
@@ -41,6 +42,10 @@ extern bool DisableSimplifyCFG;
///
extern bool BugpointIsInterrupted;
+/// Command line options used across files.
+extern cl::list<std::string> InputArgv;
+extern cl::opt<std::string> OutputPrefix;
+
class BugDriver {
LLVMContext &Context;
const char *ToolName; // argv[0] of bugpoint
diff --git a/llvm/tools/bugpoint/CrashDebugger.cpp b/llvm/tools/bugpoint/CrashDebugger.cpp
index 240300b324367..1c2f1704f868e 100644
--- a/llvm/tools/bugpoint/CrashDebugger.cpp
+++ b/llvm/tools/bugpoint/CrashDebugger.cpp
@@ -87,10 +87,9 @@ static bool isValidModule(std::unique_ptr<Module> &M,
return false;
}
-namespace llvm {
// Note this class needs to be in llvm namespace since its declared as a friend
// of BugDriver.
-class ReducePassList : public ListReducer<std::string> {
+class llvm::ReducePassList : public ListReducer<std::string> {
BugDriver &BD;
public:
@@ -102,7 +101,6 @@ class ReducePassList : public ListReducer<std::string> {
Expected<TestResult> doTest(std::vector<std::string> &Removed,
std::vector<std::string> &Kept) override;
};
-} // namespace llvm
Expected<ReducePassList::TestResult>
ReducePassList::doTest(std::vector<std::string> &Prefix,
diff --git a/llvm/tools/bugpoint/ExecutionDriver.cpp b/llvm/tools/bugpoint/ExecutionDriver.cpp
index 8c6b7fbe50c7c..96eeb35b4db70 100644
--- a/llvm/tools/bugpoint/ExecutionDriver.cpp
+++ b/llvm/tools/bugpoint/ExecutionDriver.cpp
@@ -13,7 +13,6 @@
#include "BugDriver.h"
#include "ToolRunner.h"
-#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/FileUtilities.h"
#include "llvm/Support/Program.h"
@@ -102,15 +101,13 @@ static cl::opt<std::string> CustomExecCommand(
// Anything specified after the --args option are taken as arguments to the
// program being debugged.
-namespace llvm {
-cl::list<std::string> InputArgv("args", cl::Positional,
- cl::desc("<program arguments>..."),
- cl::PositionalEatsArgs);
-
-cl::opt<std::string>
- OutputPrefix("output-prefix", cl::init("bugpoint"),
- cl::desc("Prefix to use for outputs (default: 'bugpoint')"));
-} // namespace llvm
+cl::list<std::string> llvm::InputArgv("args", cl::Positional,
+ cl::desc("<program arguments>..."),
+ cl::PositionalEatsArgs);
+
+cl::opt<std::string> llvm::OutputPrefix(
+ "output-prefix", cl::init("bugpoint"),
+ cl::desc("Prefix to use for outputs (default: 'bugpoint')"));
static cl::list<std::string> ToolArgv("tool-args", cl::Positional,
cl::desc("<tool arguments>..."),
diff --git a/llvm/tools/bugpoint/ExtractFunction.cpp b/llvm/tools/bugpoint/ExtractFunction.cpp
index 3206589ff38f2..31cdd0d43f2fc 100644
--- a/llvm/tools/bugpoint/ExtractFunction.cpp
+++ b/llvm/tools/bugpoint/ExtractFunction.cpp
@@ -36,9 +36,6 @@ using namespace llvm;
#define DEBUG_TYPE "bugpoint"
bool llvm::DisableSimplifyCFG = false;
-namespace llvm {
-extern cl::opt<std::string> OutputPrefix;
-} // namespace llvm
static cl::opt<bool>
NoDCE("disable-dce",
diff --git a/llvm/tools/bugpoint/Miscompilation.cpp b/llvm/tools/bugpoint/Miscompilation.cpp
index a7f1643aecf15..dcad126d87865 100644
--- a/llvm/tools/bugpoint/Miscompilation.cpp
+++ b/llvm/tools/bugpoint/Miscompilation.cpp
@@ -28,11 +28,6 @@
using namespace llvm;
-namespace llvm {
-extern cl::opt<std::string> OutputPrefix;
-extern cl::list<std::string> InputArgv;
-} // end namespace llvm
-
static cl::opt<bool> DisableLoopExtraction(
"disable-loop-extraction",
cl::desc("Don't extract loops when searching for miscompilations"),
diff --git a/llvm/tools/bugpoint/OptimizerDriver.cpp b/llvm/tools/bugpoint/OptimizerDriver.cpp
index bf2e8c0b4a910..191f87c08a0f6 100644
--- a/llvm/tools/bugpoint/OptimizerDriver.cpp
+++ b/llvm/tools/bugpoint/OptimizerDriver.cpp
@@ -34,10 +34,6 @@ using namespace llvm;
#define DEBUG_TYPE "bugpoint"
-namespace llvm {
-extern cl::opt<std::string> OutputPrefix;
-}
-
static cl::opt<std::string>
OptCmd("opt-command", cl::init(""),
cl::desc("Path to opt. (default: search path "
More information about the llvm-commits
mailing list