aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object/TapiFile.cpp
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2020-06-12 00:01:54 -0700
committerJonas Devlieghere <jonas@devlieghere.com>2020-06-12 00:03:32 -0700
commit425c6f079b9c7a2b70407843e89eb67a7b32032d (patch)
tree7616cc2ef5dd1153902ec457e6cd79ba9d2b026e /llvm/lib/Object/TapiFile.cpp
parentc35ed40f4f1bd8afd709c5342b36f33c7c5b0fbd (diff)
downloadllvm-425c6f079b9c7a2b70407843e89eb67a7b32032d.zip
llvm-425c6f079b9c7a2b70407843e89eb67a7b32032d.tar.gz
llvm-425c6f079b9c7a2b70407843e89eb67a7b32032d.tar.bz2
[llvm/Object] Reimplment basic_symbol_iterator in TapiFile
Use indices into the Symbols vector instead of casting the objects in the vector and dereferencing std::vector::end(). This change is NFC modulo the Windows failure reported by llvm-clang-x86_64-expensive-checks-win. Differential revision: https://reviews.llvm.org/D81717
Diffstat (limited to 'llvm/lib/Object/TapiFile.cpp')
-rw-r--r--llvm/lib/Object/TapiFile.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/llvm/lib/Object/TapiFile.cpp b/llvm/lib/Object/TapiFile.cpp
index c732a8e..7a36199 100644
--- a/llvm/lib/Object/TapiFile.cpp
+++ b/llvm/lib/Object/TapiFile.cpp
@@ -75,30 +75,28 @@ TapiFile::TapiFile(MemoryBufferRef Source, const InterfaceFile &interface,
TapiFile::~TapiFile() = default;
-void TapiFile::moveSymbolNext(DataRefImpl &DRI) const {
- const auto *Sym = reinterpret_cast<const Symbol *>(DRI.p);
- DRI.p = reinterpret_cast<uintptr_t>(++Sym);
-}
+void TapiFile::moveSymbolNext(DataRefImpl &DRI) const { DRI.d.a++; }
Error TapiFile::printSymbolName(raw_ostream &OS, DataRefImpl DRI) const {
- const auto *Sym = reinterpret_cast<const Symbol *>(DRI.p);
- OS << Sym->Prefix << Sym->Name;
+ assert(DRI.d.a < Symbols.size() && "Attempt to access symbol out of bounds");
+ const Symbol &Sym = Symbols[DRI.d.a];
+ OS << Sym.Prefix << Sym.Name;
return Error::success();
}
Expected<uint32_t> TapiFile::getSymbolFlags(DataRefImpl DRI) const {
- const auto *Sym = reinterpret_cast<const Symbol *>(DRI.p);
- return Sym->Flags;
+ assert(DRI.d.a < Symbols.size() && "Attempt to access symbol out of bounds");
+ return Symbols[DRI.d.a].Flags;
}
basic_symbol_iterator TapiFile::symbol_begin() const {
DataRefImpl DRI;
- DRI.p = reinterpret_cast<uintptr_t>(&*Symbols.begin());
+ DRI.d.a = 0;
return BasicSymbolRef{DRI, this};
}
basic_symbol_iterator TapiFile::symbol_end() const {
DataRefImpl DRI;
- DRI.p = reinterpret_cast<uintptr_t>(&*Symbols.end());
+ DRI.d.a = Symbols.size();
return BasicSymbolRef{DRI, this};
}