Skip to content

Commit 3a695e1

Browse files
authored
[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.
1 parent 6626e6a commit 3a695e1

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

llvm/lib/Bitcode/Reader/MetadataLoader.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "llvm/Bitcode/BitcodeReader.h"
2626
#include "llvm/Bitcode/LLVMBitCodes.h"
2727
#include "llvm/Bitstream/BitstreamReader.h"
28+
#include "llvm/IR/Argument.h"
2829
#include "llvm/IR/AutoUpgrade.h"
2930
#include "llvm/IR/BasicBlock.h"
3031
#include "llvm/IR/Constants.h"
@@ -58,9 +59,6 @@
5859
#include <tuple>
5960
#include <utility>
6061
#include <vector>
61-
namespace llvm {
62-
class Argument;
63-
}
6462

6563
using namespace llvm;
6664

@@ -83,8 +81,6 @@ static cl::opt<bool> DisableLazyLoading(
8381

8482
namespace {
8583

86-
static int64_t unrotateSign(uint64_t U) { return (U & 1) ? ~(U >> 1) : U >> 1; }
87-
8884
class BitcodeReaderMetadataList {
8985
/// Array of metadata references.
9086
///
@@ -129,10 +125,7 @@ class BitcodeReaderMetadataList {
129125
void pop_back() { MetadataPtrs.pop_back(); }
130126
bool empty() const { return MetadataPtrs.empty(); }
131127

132-
Metadata *operator[](unsigned i) const {
133-
assert(i < MetadataPtrs.size());
134-
return MetadataPtrs[i];
135-
}
128+
Metadata *operator[](unsigned i) const { return MetadataPtrs[i]; }
136129

137130
Metadata *lookup(unsigned I) const {
138131
if (I < MetadataPtrs.size())
@@ -178,6 +171,9 @@ class BitcodeReaderMetadataList {
178171
private:
179172
Metadata *resolveTypeRefArray(Metadata *MaybeTuple);
180173
};
174+
} // namespace
175+
176+
static int64_t unrotateSign(uint64_t U) { return (U & 1) ? ~(U >> 1) : U >> 1; }
181177

182178
void BitcodeReaderMetadataList::assignValue(Metadata *MD, unsigned Idx) {
183179
if (auto *MDN = dyn_cast<MDNode>(MD))
@@ -392,8 +388,6 @@ void PlaceholderQueue::flush(BitcodeReaderMetadataList &MetadataList) {
392388
}
393389
}
394390

395-
} // anonymous namespace
396-
397391
static Error error(const Twine &Message) {
398392
return make_error<StringError>(
399393
Message, make_error_code(BitcodeError::CorruptedBitcode));

0 commit comments

Comments
 (0)