[llvm] [NFC][LLVM][IRTests] Namespace cleanup (PR #196806)

via llvm-commits llvm-commits at lists.llvm.org
Sun May 10 08:09:43 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-ir

Author: Rahul Joshi (jurahul)

<details>
<summary>Changes</summary>

Remove llvm namespace surrounding entire .cpp files and instead use `using namespace` in these files.

---
Full diff: https://github.com/llvm/llvm-project/pull/196806.diff


6 Files Affected:

- (modified) llvm/unittests/IR/BasicBlockTest.cpp (+2-2) 
- (modified) llvm/unittests/IR/ConstantsTest.cpp (+2-2) 
- (modified) llvm/unittests/IR/DroppedVariableStatsIRTest.cpp (-3) 
- (modified) llvm/unittests/IR/InstructionsTest.cpp (+3-3) 
- (modified) llvm/unittests/IR/TimePassesTest.cpp (+5-4) 
- (modified) llvm/unittests/IR/VerifierTest.cpp (+1-2) 


``````````diff
diff --git a/llvm/unittests/IR/BasicBlockTest.cpp b/llvm/unittests/IR/BasicBlockTest.cpp
index d1824ba837843..0f5497abaa9c0 100644
--- a/llvm/unittests/IR/BasicBlockTest.cpp
+++ b/llvm/unittests/IR/BasicBlockTest.cpp
@@ -21,7 +21,8 @@
 #include "gtest/gtest.h"
 #include <memory>
 
-namespace llvm {
+using namespace llvm;
+
 namespace {
 
 TEST(BasicBlockTest, PhiRange) {
@@ -546,4 +547,3 @@ TEST(BasicBlockTest, DiscardValueNames2) {
 }
 
 } // End anonymous namespace.
-} // End llvm namespace.
diff --git a/llvm/unittests/IR/ConstantsTest.cpp b/llvm/unittests/IR/ConstantsTest.cpp
index b97d38a7b37ad..6716ec581bd06 100644
--- a/llvm/unittests/IR/ConstantsTest.cpp
+++ b/llvm/unittests/IR/ConstantsTest.cpp
@@ -19,7 +19,8 @@
 #include "llvm/Support/SourceMgr.h"
 #include "gtest/gtest.h"
 
-namespace llvm {
+using namespace llvm;
+
 namespace {
 
 // Check that use count checks treat ConstantData like they have no uses.
@@ -920,4 +921,3 @@ TEST(ConstantsTest, ToConstantRangeConstantByteVector) {
 }
 
 } // end anonymous namespace
-} // end namespace llvm
diff --git a/llvm/unittests/IR/DroppedVariableStatsIRTest.cpp b/llvm/unittests/IR/DroppedVariableStatsIRTest.cpp
index 20c66b93fcb1a..03e6f429e14f8 100644
--- a/llvm/unittests/IR/DroppedVariableStatsIRTest.cpp
+++ b/llvm/unittests/IR/DroppedVariableStatsIRTest.cpp
@@ -24,8 +24,6 @@
 #include <llvm/Support/raw_ostream.h>
 
 using namespace llvm;
-namespace llvm {
-void initializePassTest1Pass(PassRegistry &);
 
 static std::unique_ptr<Module> parseIR(LLVMContext &C, const char *IR) {
   SMDiagnostic Err;
@@ -34,7 +32,6 @@ static std::unique_ptr<Module> parseIR(LLVMContext &C, const char *IR) {
     Err.print("AbstractCallSiteTests", errs());
   return Mod;
 }
-} // namespace llvm
 
 namespace {
 
diff --git a/llvm/unittests/IR/InstructionsTest.cpp b/llvm/unittests/IR/InstructionsTest.cpp
index b01569d216676..1c4361e4c0f20 100644
--- a/llvm/unittests/IR/InstructionsTest.cpp
+++ b/llvm/unittests/IR/InstructionsTest.cpp
@@ -33,8 +33,7 @@
 #include "gtest/gtest.h"
 #include <memory>
 
-namespace llvm {
-namespace {
+using namespace llvm;
 
 static std::unique_ptr<Module> parseIR(LLVMContext &C, const char *IR) {
   SMDiagnostic Err;
@@ -44,6 +43,8 @@ static std::unique_ptr<Module> parseIR(LLVMContext &C, const char *IR) {
   return Mod;
 }
 
+namespace {
+
 TEST(InstructionsTest, ReturnInst) {
   LLVMContext C;
 
@@ -2011,4 +2012,3 @@ TEST(InstructionsTest, StripAndAccumulateConstantOffset) {
 }
 
 } // end anonymous namespace
-} // end namespace llvm
diff --git a/llvm/unittests/IR/TimePassesTest.cpp b/llvm/unittests/IR/TimePassesTest.cpp
index 1faaf68f80a67..d5649427851f5 100644
--- a/llvm/unittests/IR/TimePassesTest.cpp
+++ b/llvm/unittests/IR/TimePassesTest.cpp
@@ -29,6 +29,8 @@ namespace llvm {
 void initializePass1Pass(PassRegistry &);
 void initializePass2Pass(PassRegistry &);
 
+} // namespace llvm
+
 namespace {
 struct Pass1 : public ModulePass {
   static char ID;
@@ -56,7 +58,6 @@ struct Pass2 : public ModulePass {
 };
 char Pass2::ID;
 } // namespace
-} // namespace llvm
 
 INITIALIZE_PASS(Pass1, "Pass1", "Pass1", false, false)
 INITIALIZE_PASS(Pass2, "Pass2", "Pass2", false, false)
@@ -75,8 +76,8 @@ TEST(TimePassesTest, LegacyCustomOut) {
 
   // Setup pass manager
   legacy::PassManager PM1;
-  PM1.add(new llvm::Pass1());
-  PM1.add(new llvm::Pass2());
+  PM1.add(new Pass1());
+  PM1.add(new Pass2());
 
   // Enable time-passes and run passes.
   TimePassesIsEnabled = true;
@@ -100,7 +101,7 @@ TEST(TimePassesTest, LegacyCustomOut) {
 
   // Now run just a single pass to populate timers again.
   legacy::PassManager PM2;
-  PM2.add(new llvm::Pass2());
+  PM2.add(new Pass2());
   PM2.run(M);
 
   // Generate report again.
diff --git a/llvm/unittests/IR/VerifierTest.cpp b/llvm/unittests/IR/VerifierTest.cpp
index 1e31fc5e06f65..529ab56f25247 100644
--- a/llvm/unittests/IR/VerifierTest.cpp
+++ b/llvm/unittests/IR/VerifierTest.cpp
@@ -21,7 +21,7 @@
 #include "llvm/IR/Module.h"
 #include "gtest/gtest.h"
 
-namespace llvm {
+using namespace llvm;
 namespace {
 
 TEST(VerifierTest, Branch_i1) {
@@ -538,4 +538,3 @@ TEST(VerifierTest, DeeplyNested) {
 }
 
 } // end anonymous namespace
-} // end namespace llvm

``````````

</details>


https://github.com/llvm/llvm-project/pull/196806


More information about the llvm-commits mailing list