[llvm] 3a695e1 - [NFC][LLVM] Namespace cleanup in MetadataLoader.cpp (#157595)

via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 15 10:32:49 PDT 2025


Author: Rahul Joshi
Date: 2025-09-15T10:32:45-07:00
New Revision: 3a695e1abebac0c8e9816e1649ef8032c5ffdc4b

URL: https://github.com/llvm/llvm-project/commit/3a695e1abebac0c8e9816e1649ef8032c5ffdc4b
DIFF: https://github.com/llvm/llvm-project/commit/3a695e1abebac0c8e9816e1649ef8032c5ffdc4b.diff

LOG: [NFC][LLVM] Namespace cleanup in MetadataLoader.cpp (#157595)

- Remove forward declaration of `llvm::Argument` and include Argument.h
instead.
- Restrict scope of anonymous namespaces to just class declarations.
- Move local static function out of anonymous namespace.
- Remove a redundant assert when indexing a vector.

Added: 
    

Modified: 
    llvm/lib/Bitcode/Reader/MetadataLoader.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
index a5cedadd30981..22c7fa5f515ee 100644
--- a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
+++ b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
@@ -25,6 +25,7 @@
 #include "llvm/Bitcode/BitcodeReader.h"
 #include "llvm/Bitcode/LLVMBitCodes.h"
 #include "llvm/Bitstream/BitstreamReader.h"
+#include "llvm/IR/Argument.h"
 #include "llvm/IR/AutoUpgrade.h"
 #include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/Constants.h"
@@ -58,9 +59,6 @@
 #include <tuple>
 #include <utility>
 #include <vector>
-namespace llvm {
-class Argument;
-}
 
 using namespace llvm;
 
@@ -83,8 +81,6 @@ static cl::opt<bool> DisableLazyLoading(
 
 namespace {
 
-static int64_t unrotateSign(uint64_t U) { return (U & 1) ? ~(U >> 1) : U >> 1; }
-
 class BitcodeReaderMetadataList {
   /// Array of metadata references.
   ///
@@ -129,10 +125,7 @@ class BitcodeReaderMetadataList {
   void pop_back() { MetadataPtrs.pop_back(); }
   bool empty() const { return MetadataPtrs.empty(); }
 
-  Metadata *operator[](unsigned i) const {
-    assert(i < MetadataPtrs.size());
-    return MetadataPtrs[i];
-  }
+  Metadata *operator[](unsigned i) const { return MetadataPtrs[i]; }
 
   Metadata *lookup(unsigned I) const {
     if (I < MetadataPtrs.size())
@@ -178,6 +171,9 @@ class BitcodeReaderMetadataList {
 private:
   Metadata *resolveTypeRefArray(Metadata *MaybeTuple);
 };
+} // namespace
+
+static int64_t unrotateSign(uint64_t U) { return (U & 1) ? ~(U >> 1) : U >> 1; }
 
 void BitcodeReaderMetadataList::assignValue(Metadata *MD, unsigned Idx) {
   if (auto *MDN = dyn_cast<MDNode>(MD))
@@ -392,8 +388,6 @@ void PlaceholderQueue::flush(BitcodeReaderMetadataList &MetadataList) {
   }
 }
 
-} // anonymous namespace
-
 static Error error(const Twine &Message) {
   return make_error<StringError>(
       Message, make_error_code(BitcodeError::CorruptedBitcode));


        


More information about the llvm-commits mailing list