Refactor and comment Atom attributes. Replace combine() with internalName() and mergeDuplicates()
llvm-svn: 146958
diff --git a/lld/lib/Core/Atom.cpp b/lld/lib/Core/Atom.cpp
index 482a21f..889ec09 100644
--- a/lld/lib/Core/Atom.cpp
+++ b/lld/lib/Core/Atom.cpp
@@ -32,6 +32,10 @@
return llvm::ArrayRef<uint8_t>();
}
+ Atom::ContentPermissions Atom::permissions() const {
+ return perm___;
+ }
+
Reference::iterator Atom::referencesBegin() const {
return 0;
}
diff --git a/lld/lib/Core/SymbolTable.cpp b/lld/lib/Core/SymbolTable.cpp
index 3b77062..ebd4c0b 100644
--- a/lld/lib/Core/SymbolTable.cpp
+++ b/lld/lib/Core/SymbolTable.cpp
@@ -26,15 +26,11 @@
void SymbolTable::add(const Atom &atom) {
assert(atom.scope() != Atom::scopeTranslationUnit);
- switch (atom.combine()) {
- case Atom::combineNever:
- case Atom::combineByName:
+ if ( !atom.internalName() ) {
this->addByName(atom);
- break;
- case Atom::combineByTypeContent:
- case Atom::combineByTypeContentDeep:
+ }
+ else if ( atom.mergeDuplicates() ) {
// TO DO: support constants merging
- break;
}
}
@@ -46,27 +42,31 @@
NCR_Error
};
-static NameCollisionResolution cases[5][5] = {
- //regular tentative absolute undef sharedLib
+static NameCollisionResolution cases[6][6] = {
+ //regular weak tentative absolute undef sharedLib
{
// first is regular
- NCR_Error, NCR_First, NCR_Error, NCR_First, NCR_First
+ NCR_Error, NCR_First, NCR_First, NCR_Error, NCR_First, NCR_First
+ },
+ {
+ // first is weak
+ NCR_Second, NCR_Weak, NCR_Larger, NCR_Error, NCR_First, NCR_First
},
{
// first is tentative
- NCR_Second, NCR_Larger, NCR_Error, NCR_First, NCR_First
+ NCR_Second, NCR_Second, NCR_Larger, NCR_Error, NCR_First, NCR_First
},
{
// first is absolute
- NCR_Error, NCR_Error, NCR_Error, NCR_First, NCR_First
+ NCR_Error, NCR_Error, NCR_Error, NCR_Error, NCR_First, NCR_First
},
{
// first is undef
- NCR_Second, NCR_Second, NCR_Second, NCR_First, NCR_Second
+ NCR_Second, NCR_Second, NCR_Second, NCR_Second, NCR_First, NCR_Second
},
{
// first is sharedLib
- NCR_Second, NCR_Second, NCR_Second, NCR_First, NCR_First
+ NCR_Second, NCR_Second, NCR_Second, NCR_Second, NCR_First, NCR_First
}
};
diff --git a/lld/lib/Core/YamlReader.cpp b/lld/lib/Core/YamlReader.cpp
index 9b093e4..c95e061 100644
--- a/lld/lib/Core/YamlReader.cpp
+++ b/lld/lib/Core/YamlReader.cpp
@@ -239,18 +239,17 @@
class YAMLAtom : public Atom {
public:
YAMLAtom( Definition d
- , Combine c
, Scope s
, ContentType ct
, SectionChoice sc
- , bool uvn
- , bool dds
+ , bool intn
+ , DeadStripKind dsk
, bool tb
, bool al
, Alignment a
, YAMLFile *f
, const char *n)
- : Atom(d, c, s, ct, sc, uvn, dds, tb, al, a)
+ : Atom(d, s, ct, sc, intn, dsk, tb, al, a)
, _file(f)
, _name(n)
, _size(0)
@@ -322,13 +321,13 @@
private:
const char *_name;
Atom::Alignment _align;
- Atom::Combine _combine;
Atom::ContentType _type;
Atom::Scope _scope;
Atom::Definition _def;
Atom::SectionChoice _sectionChoice;
+ bool _internalName;
bool _userVisibleName;
- bool _dontDeadStrip;
+ Atom::DeadStripKind _dontDeadStrip;
bool _thumb;
bool _alias;
Reference _ref;
@@ -337,11 +336,10 @@
YAMLAtomState::YAMLAtomState()
: _name(NULL)
, _align(0, 0)
- , _combine(Atom::combineNever)
, _type(Atom::typeData)
, _scope(Atom::scopeGlobal)
, _userVisibleName(true)
- , _dontDeadStrip(false)
+ , _dontDeadStrip(Atom::deadStripNormal)
, _thumb(false)
, _alias(false) {
_ref.target = NULL;
@@ -352,8 +350,8 @@
}
void YAMLAtomState::makeAtom(YAMLFile *f) {
- Atom *a = new YAMLAtom(_def, _combine, _scope, _type, _sectionChoice,
- _userVisibleName, _dontDeadStrip, _thumb, _alias,
+ Atom *a = new YAMLAtom(_def, _scope, _type, _sectionChoice,
+ _internalName, _dontDeadStrip, _thumb, _alias,
_align, f, _name);
f->_atoms.push_back(a);
@@ -362,13 +360,12 @@
_name = NULL;
_align.powerOf2 = 0;
_align.modulus = 0;
- _combine = Atom::combineNever;
_type = Atom::typeData;
_scope = Atom::scopeGlobal;
_def = Atom::definitionRegular;
_sectionChoice = Atom::sectionBasedOnContent;
- _userVisibleName = true;
- _dontDeadStrip = false;
+ _internalName = false;
+ _dontDeadStrip = Atom::deadStripNormal;
_thumb = false;
_alias = false;
_ref.target = NULL;
diff --git a/lld/lib/Core/YamlWriter.cpp b/lld/lib/Core/YamlWriter.cpp
index ae27c7e..711fd1a 100644
--- a/lld/lib/Core/YamlWriter.cpp
+++ b/lld/lib/Core/YamlWriter.cpp
@@ -29,8 +29,8 @@
virtual void doFile(const class File &) { }
virtual void doAtom(const class Atom &atom) {
_out << " - name: " << atom.name() << "\n";
+ _out << " internal-name:" << atom.internalName() << "\n";
_out << " definition: " << definitionString(atom.definition()) <<"\n";
- _out << " user-visible:" << atom.userVisibleName() << "\n";
_out << " scope: " << scopeString(atom.scope()) << "\n";
_out << " type: " << typeString(atom.contentType()) << "\n";
if (atom.referencesBegin() != atom.referencesEnd()) {