summaryrefslogtreecommitdiffstats
path: root/lld/lib/Core
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2012-04-02 23:56:36 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2012-04-02 23:56:36 +0000
commitb495562b5d94b249968c1314dff0defb6682fb3d (patch)
tree651511ebcd895567ae05f5cec7571cfbc0b8eba4 /lld/lib/Core
parent51e318737a880f9102ee7aaff4de86e4b95d464a (diff)
downloadbcm5719-llvm-b495562b5d94b249968c1314dff0defb6682fb3d.tar.gz
bcm5719-llvm-b495562b5d94b249968c1314dff0defb6682fb3d.zip
Use the LLVM RTTI library.
llvm-svn: 153912
Diffstat (limited to 'lld/lib/Core')
-rw-r--r--lld/lib/Core/Resolver.cpp32
-rw-r--r--lld/lib/Core/SymbolTable.cpp13
2 files changed, 25 insertions, 20 deletions
diff --git a/lld/lib/Core/Resolver.cpp b/lld/lib/Core/Resolver.cpp
index 13541840736..cbef66f6597 100644
--- a/lld/lib/Core/Resolver.cpp
+++ b/lld/lib/Core/Resolver.cpp
@@ -15,6 +15,7 @@
#include "lld/Core/SymbolTable.h"
#include "lld/Core/UndefinedAtom.h"
+#include "llvm/Support/Casting.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
@@ -33,7 +34,7 @@ public:
if ( _liveAtoms.count(atom) )
return false;
// don't remove if marked never-dead-strip
- if ( const DefinedAtom* defAtom = atom->definedAtom() ) {
+ if (const DefinedAtom* defAtom = llvm::dyn_cast<DefinedAtom>(atom)) {
if ( defAtom->deadStrip() == DefinedAtom::deadStripNever )
return false;
}
@@ -194,7 +195,7 @@ void Resolver::resolveUndefines() {
std::vector<const Atom *> tents;
for (std::vector<const Atom *>::iterator ait = _atoms.begin();
ait != _atoms.end(); ++ait) {
- if ( const DefinedAtom* defAtom = (*ait)->definedAtom() ) {
+ if (const DefinedAtom* defAtom = llvm::dyn_cast<DefinedAtom>(*ait)) {
if ( defAtom->merge() == DefinedAtom::mergeAsTentative )
tents.push_back(defAtom);
}
@@ -206,7 +207,8 @@ void Resolver::resolveUndefines() {
llvm::StringRef tentName = (*dit)->name();
const Atom *curAtom = _symbolTable.findByName(tentName);
assert(curAtom != nullptr);
- if ( const DefinedAtom* curDefAtom = curAtom->definedAtom() ) {
+ if (const DefinedAtom* curDefAtom =
+ llvm::dyn_cast<DefinedAtom>(curAtom)) {
if (curDefAtom->merge() == DefinedAtom::mergeAsTentative )
_inputFiles.searchLibraries(tentName, searchDylibs,
true, true, *this);
@@ -221,7 +223,7 @@ void Resolver::resolveUndefines() {
// to the new defined atom
void Resolver::updateReferences() {
for (auto ait = _atoms.begin(); ait != _atoms.end(); ++ait) {
- if ( const DefinedAtom* defAtom = (*ait)->definedAtom() ) {
+ if (const DefinedAtom* defAtom = llvm::dyn_cast<DefinedAtom>(*ait)) {
for (auto rit=defAtom->referencesBegin(), end=defAtom->referencesEnd();
rit != end; ++rit) {
const Reference* ref = *rit;
@@ -259,7 +261,7 @@ void Resolver::markLive(const Atom &atom, WhyLiveBackChain *previous) {
WhyLiveBackChain thisChain;
thisChain.previous = previous;
thisChain.referer = &atom;
- if ( const DefinedAtom* defAtom = atom.definedAtom() ) {
+ if ( const DefinedAtom* defAtom = llvm::dyn_cast<DefinedAtom>(&atom)) {
for (auto rit=defAtom->referencesBegin(), end=defAtom->referencesEnd();
rit != end; ++rit) {
const Reference* ref = *rit;
@@ -342,7 +344,7 @@ void Resolver::removeCoalescedAwayAtoms() {
void Resolver::checkDylibSymbolCollisions() {
for (std::vector<const Atom *>::const_iterator it = _atoms.begin();
it != _atoms.end(); ++it) {
- const DefinedAtom* defAtom = (*it)->definedAtom();
+ const DefinedAtom* defAtom = llvm::dyn_cast<DefinedAtom>(*it);
if (defAtom == nullptr)
continue;
if ( defAtom->merge() != DefinedAtom::mergeAsTentative )
@@ -389,25 +391,23 @@ void Resolver::resolve() {
}
void Resolver::MergedFile::addAtom(const Atom& atom) {
- if ( const DefinedAtom* defAtom = atom.definedAtom() ) {
+ if (const DefinedAtom* defAtom = llvm::dyn_cast<DefinedAtom>(&atom)) {
_definedAtoms._atoms.push_back(defAtom);
- }
- else if ( const UndefinedAtom* undefAtom = atom.undefinedAtom() ) {
+ } else if (const UndefinedAtom* undefAtom =
+ llvm::dyn_cast<UndefinedAtom>(&atom)) {
_undefinedAtoms._atoms.push_back(undefAtom);
- }
- else if ( const SharedLibraryAtom* slAtom = atom.sharedLibraryAtom() ) {
+ } else if (const SharedLibraryAtom* slAtom =
+ llvm::dyn_cast<SharedLibraryAtom>(&atom)) {
_sharedLibraryAtoms._atoms.push_back(slAtom);
- }
- else if ( const AbsoluteAtom* abAtom = atom.absoluteAtom() ) {
+ } else if (const AbsoluteAtom* abAtom = llvm::dyn_cast<AbsoluteAtom>(&atom)) {
_absoluteAtoms._atoms.push_back(abAtom);
- }
- else {
+ } else {
assert(0 && "atom has unknown definition kind");
}
}
void Resolver::MergedFile::addAtoms(std::vector<const Atom*>& all) {
- for(std::vector<const Atom*>::iterator it=all.begin(); it != all.end(); ++it) {
+ for(std::vector<const Atom*>::iterator it=all.begin(); it != all.end(); ++it){
this->addAtom(**it);
}
}
diff --git a/lld/lib/Core/SymbolTable.cpp b/lld/lib/Core/SymbolTable.cpp
index 277ce3b60e7..b748e00b671 100644
--- a/lld/lib/Core/SymbolTable.cpp
+++ b/lld/lib/Core/SymbolTable.cpp
@@ -20,6 +20,7 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMapInfo.h"
+#include "llvm/Support/Casting.h"
#include "llvm/Support/ErrorHandling.h"
#include <algorithm>
@@ -160,8 +161,10 @@ void SymbolTable::addByName(const Atom & newAtom) {
}
break;
case NCR_DupUndef: {
- const UndefinedAtom* existingUndef = existing->undefinedAtom();
- const UndefinedAtom* newUndef = newAtom.undefinedAtom();
+ const UndefinedAtom* existingUndef =
+ llvm::dyn_cast<UndefinedAtom>(existing);
+ const UndefinedAtom* newUndef =
+ llvm::dyn_cast<UndefinedAtom>(&newAtom);
assert(existingUndef != nullptr);
assert(newUndef != nullptr);
if ( existingUndef->canBeNull() == newUndef->canBeNull() ) {
@@ -176,8 +179,10 @@ void SymbolTable::addByName(const Atom & newAtom) {
}
break;
case NCR_DupShLib: {
- const SharedLibraryAtom* existingShLib = existing->sharedLibraryAtom();
- const SharedLibraryAtom* newShLib = newAtom.sharedLibraryAtom();
+ const SharedLibraryAtom* existingShLib =
+ llvm::dyn_cast<SharedLibraryAtom>(existing);
+ const SharedLibraryAtom* newShLib =
+ llvm::dyn_cast<SharedLibraryAtom>(&newAtom);
assert(existingShLib != nullptr);
assert(newShLib != nullptr);
if ( (existingShLib->canBeNullAtRuntime()
OpenPOWER on IntegriCloud