diff options
-rw-r--r-- | lld/include/lld/Core/AbsoluteAtom.h | 2 | ||||
-rw-r--r-- | lld/include/lld/Core/Platform.h | 2 | ||||
-rw-r--r-- | lld/include/lld/Core/Reference.h | 2 | ||||
-rw-r--r-- | lld/include/lld/Core/SharedLibraryAtom.h | 4 | ||||
-rw-r--r-- | lld/include/lld/Core/SymbolTable.h | 4 | ||||
-rw-r--r-- | lld/include/lld/Core/UndefinedAtom.h | 8 | ||||
-rw-r--r-- | lld/lib/Core/NativeReader.cpp | 28 | ||||
-rw-r--r-- | lld/lib/Core/Resolver.cpp | 16 | ||||
-rw-r--r-- | lld/lib/Core/SymbolTable.cpp | 16 | ||||
-rw-r--r-- | lld/lib/Core/YamlKeyValues.cpp | 56 | ||||
-rw-r--r-- | lld/lib/Core/YamlReader.cpp | 54 | ||||
-rw-r--r-- | lld/lib/Core/YamlWriter.cpp | 2 | ||||
-rw-r--r-- | lld/lib/Passes/GOTPass.cpp | 10 | ||||
-rw-r--r-- | lld/lib/Passes/StubsPass.cpp | 6 | ||||
-rw-r--r-- | lld/tools/lld-core/lld-core.cpp | 30 |
15 files changed, 121 insertions, 119 deletions
diff --git a/lld/include/lld/Core/AbsoluteAtom.h b/lld/include/lld/Core/AbsoluteAtom.h index 774fc96efac..5fa71764852 100644 --- a/lld/include/lld/Core/AbsoluteAtom.h +++ b/lld/include/lld/Core/AbsoluteAtom.h @@ -23,7 +23,7 @@ public: } /// like dynamic_cast, if atom is definitionAbsolute - /// returns atom cast to AbsoluteAtom*, else returns NULL + /// returns atom cast to AbsoluteAtom*, else returns nullptr virtual const AbsoluteAtom* absoluteAtom() const { return this; } diff --git a/lld/include/lld/Core/Platform.h b/lld/include/lld/Core/Platform.h index 85bc904d3d1..62305a248cf 100644 --- a/lld/include/lld/Core/Platform.h +++ b/lld/include/lld/Core/Platform.h @@ -52,7 +52,7 @@ public: /// @brief if target must have some atoms, denote here virtual bool getImplicitDeadStripRoots(std::vector<const DefinedAtom *>&) = 0; - /// @brief return entry point for output file (e.g. "main") or NULL + /// @brief return entry point for output file (e.g. "main") or nullptr virtual llvm::StringRef entryPointName() = 0; /// @brief for iterating must-be-defined symbols ("main" or -u command line diff --git a/lld/include/lld/Core/Reference.h b/lld/include/lld/Core/Reference.h index 1af5fdc9559..00e643f3fd4 100644 --- a/lld/include/lld/Core/Reference.h +++ b/lld/include/lld/Core/Reference.h @@ -48,7 +48,7 @@ public: virtual uint64_t offsetInAtom() const = 0; /// If the reference is an edge to another Atom, then this returns the - /// other Atom. Otherwise, it returns NULL. + /// other Atom. Otherwise, it returns nullptr. virtual const class Atom * target() const = 0; /// During linking, the linker may merge graphs which coalesces some nodes diff --git a/lld/include/lld/Core/SharedLibraryAtom.h b/lld/include/lld/Core/SharedLibraryAtom.h index 344fab170bd..62381f31314 100644 --- a/lld/include/lld/Core/SharedLibraryAtom.h +++ b/lld/include/lld/Core/SharedLibraryAtom.h @@ -27,7 +27,7 @@ public: } /// like dynamic_cast, if atom is definitionSharedLibrary - /// returns atom cast to SharedLibraryAtom*, else returns NULL + /// returns atom cast to SharedLibraryAtom*, else returns nullptr virtual const SharedLibraryAtom* sharedLibraryAtom() const { return this; } @@ -38,7 +38,7 @@ public: virtual llvm::StringRef loadName() const = 0; /// Returns if shared library symbol can be missing at runtime and if - /// so the loader should silently resolve address of symbol to be NULL. + /// so the loader should silently resolve address of symbol to be nullptr. virtual bool canBeNullAtRuntime() const = 0; protected: diff --git a/lld/include/lld/Core/SymbolTable.h b/lld/include/lld/Core/SymbolTable.h index 3b4d9300228..b4418702b17 100644 --- a/lld/include/lld/Core/SymbolTable.h +++ b/lld/include/lld/Core/SymbolTable.h @@ -52,7 +52,7 @@ public: /// UndefinedAtom bool isDefined(llvm::StringRef sym); - /// @brief returns atom in symbol table for specified name (or NULL) + /// @brief returns atom in symbol table for specified name (or nullptr) const Atom *findByName(llvm::StringRef sym); /// @brief returns vector of remaining UndefinedAtoms @@ -79,7 +79,7 @@ private: StringRefMappingInfo> NameToAtom; struct AtomMappingInfo { - static const DefinedAtom * getEmptyKey() { return NULL; } + static const DefinedAtom * getEmptyKey() { return nullptr; } static const DefinedAtom * getTombstoneKey() { return (DefinedAtom*)(-1); } static unsigned getHashValue(const DefinedAtom * const Val); static bool isEqual(const DefinedAtom * const LHS, diff --git a/lld/include/lld/Core/UndefinedAtom.h b/lld/include/lld/Core/UndefinedAtom.h index 42212d5e94a..933b205a18c 100644 --- a/lld/include/lld/Core/UndefinedAtom.h +++ b/lld/include/lld/Core/UndefinedAtom.h @@ -23,23 +23,23 @@ public: } /// like dynamic_cast, if atom is definitionUndefined - /// returns atom cast to UndefinedAtom*, else returns NULL + /// returns atom cast to UndefinedAtom*, else returns nullptr virtual const UndefinedAtom* undefinedAtom() const { return this; } /// Whether this undefined symbol needs to be resolved, - /// or whether it can just evaluate to NULL. + /// or whether it can just evaluate to nullptr. /// This concept is often called "weak", but that term /// is overloaded to mean other things too. enum CanBeNull { /// Normal symbols must be resolved at build time canBeNullNever, - /// This symbol can be missing at runtime and will evalute to NULL. + /// This symbol can be missing at runtime and will evalute to nullptr. /// That is, the static linker still must find a definition (usually /// is some shared library), but at runtime, the dynamic loader - /// will allow the symbol to be missing and resolved to NULL. + /// will allow the symbol to be missing and resolved to nullptr. /// /// On Darwin this is generated using a function prototype with /// __attribute__((weak_import)). diff --git a/lld/lib/Core/NativeReader.cpp b/lld/lib/Core/NativeReader.cpp index f3548d65620..1bb0d554979 100644 --- a/lld/lib/Core/NativeReader.cpp +++ b/lld/lib/Core/NativeReader.cpp @@ -349,7 +349,7 @@ private: size_t atomsArraySize = chunk->elementCount * atomSize; uint8_t* atomsStart = reinterpret_cast<uint8_t*> (operator new(atomsArraySize, std::nothrow)); - if (atomsStart == NULL ) + if (atomsStart == nullptr) return make_error_code(native_reader_error::memory_error); const size_t ivarElementSize = chunk->fileSize / chunk->elementCount; @@ -387,7 +387,7 @@ private: size_t atomsArraySize = chunk->elementCount * atomSize; uint8_t* atomsStart = reinterpret_cast<uint8_t*> (operator new(atomsArraySize, std::nothrow)); - if (atomsStart == NULL ) + if (atomsStart == nullptr) return make_error_code(native_reader_error::memory_error); const size_t ivarElementSize = chunk->fileSize / chunk->elementCount; @@ -418,7 +418,7 @@ private: size_t atomsArraySize = chunk->elementCount * atomSize; uint8_t* atomsStart = reinterpret_cast<uint8_t*> (operator new(atomsArraySize, std::nothrow)); - if (atomsStart == NULL ) + if (atomsStart == nullptr) return make_error_code(native_reader_error::memory_error); const size_t ivarElementSize = chunk->fileSize / chunk->elementCount; @@ -449,7 +449,7 @@ private: size_t atomsArraySize = chunk->elementCount * atomSize; uint8_t* atomsStart = reinterpret_cast<uint8_t*> (operator new(atomsArraySize, std::nothrow)); - if (atomsStart == NULL ) + if (atomsStart == nullptr) return make_error_code(native_reader_error::memory_error); const size_t ivarElementSize = chunk->fileSize / chunk->elementCount; @@ -484,7 +484,7 @@ private: size_t refsArraySize = chunk->elementCount * refSize; uint8_t* refsStart = reinterpret_cast<uint8_t*> (operator new(refsArraySize, std::nothrow)); - if (refsStart == NULL ) + if (refsStart == nullptr) return make_error_code(native_reader_error::memory_error); const size_t ivarElementSize = chunk->fileSize / chunk->elementCount; @@ -621,15 +621,15 @@ private: NativeFile(std::unique_ptr<llvm::MemoryBuffer> mb, llvm::StringRef path) : lld::File(path), _buffer(std::move(mb)), // NativeFile now takes ownership of buffer - _header(NULL), - _targetsTable(NULL), + _header(nullptr), + _targetsTable(nullptr), _targetsTableCount(0), - _strings(NULL), + _strings(nullptr), _stringsMaxOffset(0), - _addends(NULL), + _addends(nullptr), _addendsMaxIndex(0), - _contentStart(NULL), - _contentEnd(NULL) + _contentStart(nullptr), + _contentEnd(nullptr) { _header = reinterpret_cast<const NativeFileHeader*> (_buffer->getBufferStart()); @@ -638,7 +638,7 @@ private: template <typename T> class AtomArray : public File::atom_collection<T> { public: - AtomArray() : _arrayStart(NULL), _arrayEnd(NULL), + AtomArray() : _arrayStart(nullptr), _arrayEnd(nullptr), _elementSize(0), _elementCount(0) { } virtual atom_iterator<T> begin() const { @@ -663,8 +663,8 @@ private: struct IvarArray { IvarArray() : - arrayStart(NULL), - arrayEnd(NULL), + arrayStart(nullptr), + arrayEnd(nullptr), elementSize(0), elementCount(0) { } diff --git a/lld/lib/Core/Resolver.cpp b/lld/lib/Core/Resolver.cpp index 617431eb68d..13541840736 100644 --- a/lld/lib/Core/Resolver.cpp +++ b/lld/lib/Core/Resolver.cpp @@ -205,7 +205,7 @@ void Resolver::resolveUndefines() { // this tentative, so check again llvm::StringRef tentName = (*dit)->name(); const Atom *curAtom = _symbolTable.findByName(tentName); - assert(curAtom != NULL); + assert(curAtom != nullptr); if ( const DefinedAtom* curDefAtom = curAtom->definedAtom() ) { if (curDefAtom->merge() == DefinedAtom::mergeAsTentative ) _inputFiles.searchLibraries(tentName, searchDylibs, @@ -236,10 +236,10 @@ void Resolver::updateReferences() { // for dead code stripping, recursively mark atom "live" void Resolver::markLive(const Atom &atom, WhyLiveBackChain *previous) { // if -why_live cares about this symbol, then dump chain - if ((previous->referer != NULL) && _platform.printWhyLive(atom.name())) { + if ((previous->referer != nullptr) && _platform.printWhyLive(atom.name())) { llvm::errs() << atom.name() << " from " << atom.file().path() << "\n"; int depth = 1; - for (WhyLiveBackChain *p = previous; p != NULL; + for (WhyLiveBackChain *p = previous; p != nullptr; p = p->previous, ++depth) { for (int i = depth; i > 0; --i) llvm::errs() << " "; @@ -279,7 +279,7 @@ void Resolver::deadStripOptimize() { // add entry point (main) to live roots const Atom *entry = this->entryPoint(); - if (entry != NULL) + if (entry != nullptr) _deadStripRoots.insert(entry); // add -exported_symbols_list, -init, and -u entries to live roots @@ -300,7 +300,7 @@ void Resolver::deadStripOptimize() { for (std::set<const Atom *>::iterator it = _deadStripRoots.begin(); it != _deadStripRoots.end(); ++it) { WhyLiveBackChain rootChain; - rootChain.previous = NULL; + rootChain.previous = nullptr; rootChain.referer = *it; this->markLive(**it, &rootChain); } @@ -343,7 +343,7 @@ void Resolver::checkDylibSymbolCollisions() { for (std::vector<const Atom *>::const_iterator it = _atoms.begin(); it != _atoms.end(); ++it) { const DefinedAtom* defAtom = (*it)->definedAtom(); - if ( defAtom == NULL ) + if (defAtom == nullptr) continue; if ( defAtom->merge() != DefinedAtom::mergeAsTentative ) continue; @@ -358,10 +358,10 @@ void Resolver::checkDylibSymbolCollisions() { // get "main" atom for linkage unit const Atom *Resolver::entryPoint() { llvm::StringRef symbolName = _platform.entryPointName(); - if (symbolName != NULL) + if (symbolName != nullptr) return _symbolTable.findByName(symbolName); - return NULL; + return nullptr; } // give platform a chance to tweak the set of atoms diff --git a/lld/lib/Core/SymbolTable.cpp b/lld/lib/Core/SymbolTable.cpp index bec71006faa..277ce3b60e7 100644 --- a/lld/lib/Core/SymbolTable.cpp +++ b/lld/lib/Core/SymbolTable.cpp @@ -126,7 +126,7 @@ static MergeResolution mergeSelect(DefinedAtom::Merge first, void SymbolTable::addByName(const Atom & newAtom) { llvm::StringRef name = newAtom.name(); const Atom *existing = this->findByName(name); - if (existing == NULL) { + if (existing == nullptr) { // Name is not in symbol table yet, add it associate with this atom. _nameTable[name] = &newAtom; } @@ -162,8 +162,8 @@ void SymbolTable::addByName(const Atom & newAtom) { case NCR_DupUndef: { const UndefinedAtom* existingUndef = existing->undefinedAtom(); const UndefinedAtom* newUndef = newAtom.undefinedAtom(); - assert(existingUndef != NULL); - assert(newUndef != NULL); + assert(existingUndef != nullptr); + assert(newUndef != nullptr); if ( existingUndef->canBeNull() == newUndef->canBeNull() ) { useNew = false; } @@ -178,8 +178,8 @@ void SymbolTable::addByName(const Atom & newAtom) { case NCR_DupShLib: { const SharedLibraryAtom* existingShLib = existing->sharedLibraryAtom(); const SharedLibraryAtom* newShLib = newAtom.sharedLibraryAtom(); - assert(existingShLib != NULL); - assert(newShLib != NULL); + assert(existingShLib != nullptr); + assert(newShLib != nullptr); if ( (existingShLib->canBeNullAtRuntime() == newShLib->canBeNullAtRuntime()) && existingShLib->loadName().equals(newShLib->loadName()) ) { @@ -263,13 +263,13 @@ void SymbolTable::addByContent(const DefinedAtom & newAtom) { const Atom *SymbolTable::findByName(llvm::StringRef sym) { NameToAtom::iterator pos = _nameTable.find(sym); if (pos == _nameTable.end()) - return NULL; + return nullptr; return pos->second; } bool SymbolTable::isDefined(llvm::StringRef sym) { const Atom *atom = this->findByName(sym); - if (atom == NULL) + if (atom == nullptr) return false; if (atom->definition() == Atom::definitionUndefined) return false; @@ -292,7 +292,7 @@ void SymbolTable::undefines(std::vector<const Atom *> &undefs) { for (NameToAtom::iterator it = _nameTable.begin(), end = _nameTable.end(); it != end; ++it) { const Atom *atom = it->second; - assert(atom != NULL); + assert(atom != nullptr); if (atom->definition() == Atom::definitionUndefined) undefs.push_back(atom); } diff --git a/lld/lib/Core/YamlKeyValues.cpp b/lld/lib/Core/YamlKeyValues.cpp index 86d2a8cd694..31f09f92e89 100644 --- a/lld/lib/Core/YamlKeyValues.cpp +++ b/lld/lib/Core/YamlKeyValues.cpp @@ -69,12 +69,12 @@ static const DefinitionMapping defMappings[] = { { "absolute", Atom::definitionAbsolute }, { "undefined", Atom::definitionUndefined }, { "shared-library", Atom::definitionSharedLibrary }, - { NULL, Atom::definitionRegular } + { nullptr, Atom::definitionRegular } }; Atom::Definition KeyValues::definition(const char* s) { - for (const DefinitionMapping* p = defMappings; p->string != NULL; ++p) { + for (const DefinitionMapping* p = defMappings; p->string != nullptr; ++p) { if ( strcmp(p->string, s) == 0 ) return p->value; } @@ -82,7 +82,7 @@ Atom::Definition KeyValues::definition(const char* s) } const char* KeyValues::definition(Atom::Definition s) { - for (const DefinitionMapping* p = defMappings; p->string != NULL; ++p) { + for (const DefinitionMapping* p = defMappings; p->string != nullptr; ++p) { if ( p->value == s ) return p->string; } @@ -102,12 +102,12 @@ static const ScopeMapping scopeMappings[] = { { "global", DefinedAtom::scopeGlobal }, { "hidden", DefinedAtom::scopeLinkageUnit }, { "static", DefinedAtom::scopeTranslationUnit }, - { NULL, DefinedAtom::scopeGlobal } + { nullptr, DefinedAtom::scopeGlobal } }; DefinedAtom::Scope KeyValues::scope(const char* s) { - for (const ScopeMapping* p = scopeMappings; p->string != NULL; ++p) { + for (const ScopeMapping* p = scopeMappings; p->string != nullptr; ++p) { if ( strcmp(p->string, s) == 0 ) return p->value; } @@ -115,7 +115,7 @@ DefinedAtom::Scope KeyValues::scope(const char* s) } const char* KeyValues::scope(DefinedAtom::Scope s) { - for (const ScopeMapping* p = scopeMappings; p->string != NULL; ++p) { + for (const ScopeMapping* p = scopeMappings; p->string != nullptr; ++p) { if ( p->value == s ) return p->string; } @@ -161,12 +161,12 @@ static const ContentTypeMapping typeMappings[] = { { "tlv-data", DefinedAtom::typeTLVInitialData }, { "tlv-zero-fill", DefinedAtom::typeTLVInitialZeroFill }, { "tlv-init-ptr", DefinedAtom::typeTLVInitializerPtr }, - { NULL, DefinedAtom::typeUnknown } + { nullptr, DefinedAtom::typeUnknown } }; DefinedAtom::ContentType KeyValues::contentType(const char* s) { - for (const ContentTypeMapping* p = typeMappings; p->string != NULL; ++p) { + for (const ContentTypeMapping* p = typeMappings; p->string != nullptr; ++p) { if ( strcmp(p->string, s) == 0 ) return p->value; } @@ -174,7 +174,7 @@ DefinedAtom::ContentType KeyValues::contentType(const char* s) } const char* KeyValues::contentType(DefinedAtom::ContentType s) { - for (const ContentTypeMapping* p = typeMappings; p->string != NULL; ++p) { + for (const ContentTypeMapping* p = typeMappings; p->string != nullptr; ++p) { if ( p->value == s ) return p->string; } @@ -196,12 +196,13 @@ static const DeadStripMapping deadStripMappings[] = { { "normal", DefinedAtom::deadStripNormal }, { "never", DefinedAtom::deadStripNever }, { "always", DefinedAtom::deadStripAlways }, - { NULL, DefinedAtom::deadStripNormal } + { nullptr, DefinedAtom::deadStripNormal } }; DefinedAtom::DeadStripKind KeyValues::deadStripKind(const char* s) { - for (const DeadStripMapping* p = deadStripMappings; p->string != NULL; ++p) { + for (const DeadStripMapping* p = deadStripMappings; p->string != nullptr; ++p) + { if ( strcmp(p->string, s) == 0 ) return p->value; } @@ -209,7 +210,8 @@ DefinedAtom::DeadStripKind KeyValues::deadStripKind(const char* s) } const char* KeyValues::deadStripKind(DefinedAtom::DeadStripKind dsk) { - for (const DeadStripMapping* p = deadStripMappings; p->string != NULL; ++p) { + for (const DeadStripMapping* p = deadStripMappings; p->string != nullptr; ++p) + { if ( p->value == dsk ) return p->string; } @@ -229,12 +231,12 @@ static const InterposableMapping interMappings[] = { { "no", DefinedAtom::interposeNo }, { "yes", DefinedAtom::interposeYes }, { "yesAndWeak", DefinedAtom::interposeYesAndRuntimeWeak }, - { NULL, DefinedAtom::interposeNo } + { nullptr, DefinedAtom::interposeNo } }; DefinedAtom::Interposable KeyValues::interposable(const char* s) { - for (const InterposableMapping* p = interMappings; p->string != NULL; ++p) { + for (const InterposableMapping* p = interMappings; p->string != nullptr; ++p){ if ( strcmp(p->string, s) == 0 ) return p->value; } @@ -242,7 +244,7 @@ DefinedAtom::Interposable KeyValues::interposable(const char* s) } const char* KeyValues::interposable(DefinedAtom::Interposable in) { - for (const InterposableMapping* p = interMappings; p->string != NULL; ++p) { + for (const InterposableMapping* p = interMappings; p->string != nullptr; ++p){ if ( p->value == in ) return p->string; } @@ -264,12 +266,12 @@ static const MergeMapping mergeMappings[] = { { "asTentative", DefinedAtom::mergeAsTentative }, { "asWeak", DefinedAtom::mergeAsWeak }, { "asAddressedWeak",DefinedAtom::mergeAsWeakAndAddressUsed }, - { NULL, DefinedAtom::mergeNo } + { nullptr, DefinedAtom::mergeNo } }; DefinedAtom::Merge KeyValues::merge(const char* s) { - for (const MergeMapping* p = mergeMappings; p->string != NULL; ++p) { + for (const MergeMapping* p = mergeMappings; p->string != nullptr; ++p) { if ( strcmp(p->string, s) == 0 ) return p->value; } @@ -277,7 +279,7 @@ DefinedAtom::Merge KeyValues::merge(const char* s) } const char* KeyValues::merge(DefinedAtom::Merge in) { - for (const MergeMapping* p = mergeMappings; p->string != NULL; ++p) { + for (const MergeMapping* p = mergeMappings; p->string != nullptr; ++p) { if ( p->value == in ) return p->string; } @@ -298,12 +300,12 @@ static const SectionChoiceMapping sectMappings[] = { { "content", DefinedAtom::sectionBasedOnContent }, { "custom", DefinedAtom::sectionCustomPreferred }, { "custom-required", DefinedAtom::sectionCustomRequired }, - { NULL, DefinedAtom::sectionBasedOnContent } + { nullptr, DefinedAtom::sectionBasedOnContent } }; DefinedAtom::SectionChoice KeyValues::sectionChoice(const char* s) { - for (const SectionChoiceMapping* p = sectMappings; p->string != NULL; ++p) { + for (const SectionChoiceMapping* p = sectMappings; p->string != nullptr; ++p){ if ( strcmp(p->string, s) == 0 ) return p->value; } @@ -311,7 +313,7 @@ DefinedAtom::SectionChoice KeyValues::sectionChoice(const char* s) } const char* KeyValues::sectionChoice(DefinedAtom::SectionChoice s) { - for (const SectionChoiceMapping* p = sectMappings; p->string != NULL; ++p) { + for (const SectionChoiceMapping* p = sectMappings; p->string != nullptr; ++p){ if ( p->value == s ) return p->string; } @@ -335,12 +337,12 @@ static const PermissionsMapping permMappings[] = { { "custom-required", DefinedAtom::permR_X }, { "custom-required", DefinedAtom::permRW_ }, { "custom-required", DefinedAtom::permRW_L }, - { NULL, DefinedAtom::perm___ } + { nullptr, DefinedAtom::perm___ } }; DefinedAtom::ContentPermissions KeyValues::permissions(const char* s) { - for (const PermissionsMapping* p = permMappings; p->string != NULL; ++p) { + for (const PermissionsMapping* p = permMappings; p->string != nullptr; ++p) { if ( strcmp(p->string, s) == 0 ) return p->value; } @@ -348,7 +350,7 @@ DefinedAtom::ContentPermissions KeyValues::permissions(const char* s) } const char* KeyValues::permissions(DefinedAtom::ContentPermissions s) { - for (const PermissionsMapping* p = permMappings; p->string != NULL; ++p) { + for (const PermissionsMapping* p = permMappings; p->string != nullptr; ++p) { if ( p->value == s ) return p->string; } @@ -402,13 +404,13 @@ static const CanBeNullMapping cbnMappings[] = { { "never", UndefinedAtom::canBeNullNever }, { "at-runtime", UndefinedAtom::canBeNullAtRuntime }, { "at-buildtime", UndefinedAtom::canBeNullAtBuildtime }, - { NULL, UndefinedAtom::canBeNullNever } + { nullptr, UndefinedAtom::canBeNullNever } }; UndefinedAtom::CanBeNull KeyValues::canBeNull(const char* s) { - for (const CanBeNullMapping* p = cbnMappings; p->string != NULL; ++p) { + for (const CanBeNullMapping* p = cbnMappings; p->string != nullptr; ++p) { if ( strcmp(p->string, s) == 0 ) return p->value; } @@ -416,7 +418,7 @@ UndefinedAtom::CanBeNull KeyValues::canBeNull(const char* s) } const char* KeyValues::canBeNull(UndefinedAtom::CanBeNull c) { - for (const CanBeNullMapping* p = cbnMappings; p->string != NULL; ++p) { + for (const CanBeNullMapping* p = cbnMappings; p->string != nullptr; ++p) { if ( p->value == c ) return p->string; } diff --git a/lld/lib/Core/YamlReader.cpp b/lld/lib/Core/YamlReader.cpp index c4c826d6f6e..3bfa0cfe712 100644 --- a/lld/lib/Core/YamlReader.cpp +++ b/lld/lib/Core/YamlReader.cpp @@ -43,7 +43,7 @@ public: Entry(const char *k, const char *v, std::vector<uint8_t>* vs, int d, bool bd, bool bs) : key(strdup(k)) - , value(v ? strdup(v) : NULL) + , value(v ? strdup(v) : nullptr) , valueSequenceBytes(vs) , depth(d) , beginSequence(bs) @@ -79,12 +79,12 @@ void YAML::parse(llvm::MemoryBuffer *mb, std::vector<const Entry *> &entries) { State state = start; char key[64]; char value[64]; - char *p = NULL; + char *p = nullptr; unsigned int lineNumber = 1; int depth = 0; bool nextKeyIsStartOfDocument = false; bool nextKeyIsStartOfSequence = false; - std::vector<uint8_t>* sequenceBytes = NULL; + std::vector<uint8_t>* sequenceBytes = nullptr; unsigned contentByte = 0; for (const char *s = mb->getBufferStart(); s < mb->getBufferEnd(); ++s) { char c = *s; @@ -183,7 +183,7 @@ void YAML::parse(llvm::MemoryBuffer *mb, std::vector<const Entry *> &entries) { *p++ = c; state = inValue; } else if (c == '\n') { - entries.push_back(new Entry(key, "", NULL, depth, + entries.push_back(new Entry(key, "", nullptr, depth, nextKeyIsStartOfDocument, nextKeyIsStartOfSequence)); nextKeyIsStartOfSequence = false; @@ -205,7 +205,7 @@ void YAML::parse(llvm::MemoryBuffer *mb, std::vector<const Entry *> &entries) { case inValue: if (c == '\n') { *p = '\0'; - entries.push_back(new Entry(key, value, NULL, depth, + entries.push_back(new Entry(key, value, nullptr, depth, nextKeyIsStartOfDocument, nextKeyIsStartOfSequence)); nextKeyIsStartOfSequence = false; @@ -240,7 +240,7 @@ void YAML::parse(llvm::MemoryBuffer *mb, std::vector<const Entry *> &entries) { break; case inValueSequenceEnd: if (c == '\n') { - entries.push_back(new Entry(key, NULL, sequenceBytes, depth, + entries.push_back(new Entry(key, nullptr, sequenceBytes, depth, nextKeyIsStartOfDocument, nextKeyIsStartOfSequence)); nextKeyIsStartOfSequence = false; @@ -257,7 +257,7 @@ void YAML::parse(llvm::MemoryBuffer *mb, std::vector<const Entry *> &entries) { class YAMLReference : public Reference { public: - YAMLReference() : _target(NULL), _targetName(NULL), + YAMLReference() : _target(nullptr), _targetName(nullptr), _offsetInAtom(0), _addend(0), _kind(0) { } virtual uint64_t offsetInAtom() const { @@ -386,7 +386,7 @@ public: } virtual llvm::StringRef name() const { - if ( _name == NULL ) + if (_name == nullptr) return llvm::StringRef(); else return _name; @@ -441,7 +441,7 @@ public: } llvm::ArrayRef<uint8_t> rawContent() const { - if ( _content != NULL ) + if (_content != nullptr) return llvm::ArrayRef<uint8_t>(*_content); else return llvm::ArrayRef<uint8_t>(); @@ -615,7 +615,7 @@ Atom* YAMLFile::findAtom(const char* name) { void YAMLFile::addDefinedAtom(YAMLDefinedAtom* atom, const char* refName) { _definedAtoms._atoms.push_back(atom); - assert(refName != NULL); + assert(refName != nullptr); _nameToAtomMapping.push_back(NameAtomPair(refName, atom)); } @@ -676,14 +676,14 @@ public: YAMLAtomState::YAMLAtomState(Platform& platform) : _platform(platform) - , _name(NULL) - , _refName(NULL) - , _sectionName(NULL) - , _loadName(NULL) + , _name(nullptr) + , _refName(nullptr) + , _sectionName(nullptr) + , _loadName(nullptr) , _size(0) , _value(0) , _ordinal(0) - , _content(NULL) + , _content(nullptr) , _alignment(0, 0) , _definition(KeyValues::definitionDefault) , _scope(KeyValues::scopeDefault) @@ -728,14 +728,14 @@ void YAMLAtomState::makeAtom(YAMLFile& f) { } // reset state for next atom - _name = NULL; - _refName = NULL; - _sectionName = NULL; - _loadName = NULL; + _name = nullptr; + _refName = nullptr; + _sectionName = nullptr; + _loadName = nullptr; _size = 0; _value = 0; _ordinal = 0; - _content = NULL; + _content = nullptr; _alignment.powerOf2= 0; _alignment.modulus = 0; _definition = KeyValues::definitionDefault; @@ -749,8 +749,8 @@ void YAMLAtomState::makeAtom(YAMLFile& f) { _isThumb = KeyValues::isThumbDefault; _isAlias = KeyValues::isAliasDefault; _canBeNull = KeyValues::canBeNullDefault; - _ref._target = NULL; - _ref._targetName = NULL; + _ref._target = nullptr; + _ref._targetName = nullptr; _ref._addend = 0; _ref._offsetInAtom = 0; _ref._kind = 0; @@ -781,8 +781,8 @@ void YAMLAtomState::setFixupTarget(const char *s) { void YAMLAtomState::addFixup(YAMLFile *f) { f->_references.push_back(_ref); // clear for next ref - _ref._target = NULL; - _ref._targetName = NULL; + _ref._target = nullptr; + _ref._targetName = nullptr; _ref._addend = 0; _ref._offsetInAtom = 0; _ref._kind = 0; @@ -803,7 +803,7 @@ llvm::error_code parseObjectText( llvm::MemoryBuffer *mb std::vector<const YAML::Entry *> entries; YAML::parse(mb, entries); - YAMLFile *file = NULL; + YAMLFile *file = nullptr; YAMLAtomState atomState(platform); bool inAtoms = false; bool inFixups = false; @@ -818,7 +818,7 @@ llvm::error_code parseObjectText( llvm::MemoryBuffer *mb const YAML::Entry *entry = *it; if (entry->beginDocument) { - if (file != NULL) { + if (file != nullptr) { if (haveAtom) { atomState.makeAtom(*file); haveAtom = false; @@ -976,7 +976,7 @@ llvm::error_code parseObjectText( llvm::MemoryBuffer *mb if (haveAtom) { atomState.makeAtom(*file); } - if ( file != NULL ) { + if (file != nullptr) { file->bindTargetReferences(); result.push_back(file); } diff --git a/lld/lib/Core/YamlWriter.cpp b/lld/lib/Core/YamlWriter.cpp index 7f9b0c3170e..15ebe6213d2 100644 --- a/lld/lib/Core/YamlWriter.cpp +++ b/lld/lib/Core/YamlWriter.cpp @@ -333,7 +333,7 @@ public: << _platform.kindToString(ref->kind()) << "\n"; const Atom* target = ref->target(); - if ( target != NULL ) { + if (target != nullptr) { llvm::StringRef refName = target->name(); if ( _rnb.hasRefName(target) ) refName = _rnb.refName(target); diff --git a/lld/lib/Passes/GOTPass.cpp b/lld/lib/Passes/GOTPass.cpp index 4cb5ce16db3..0d92a1e1d1f 100644 --- a/lld/lib/Passes/GOTPass.cpp +++ b/lld/lib/Passes/GOTPass.cpp @@ -56,14 +56,14 @@ void GOTPass::perform() { bool canBypassGOT; if ( _platform.isGOTAccess(ref->kind(), canBypassGOT) ) { const Atom* target = ref->target(); - assert(target != NULL); + assert(target != nullptr); const DefinedAtom* defTarget = target->definedAtom(); bool replaceTargetWithGOTAtom = false; if ( target->definition() == Atom::definitionSharedLibrary ) { // Accesses to shared library symbols must go through GOT. replaceTargetWithGOTAtom = true; } - else if ( (defTarget != NULL) + else if ( (defTarget != nullptr) && (defTarget->interposable() != DefinedAtom::interposeNo) ) { // Accesses to interposable symbols in same linkage unit // must also go through GOT. @@ -78,19 +78,19 @@ void GOTPass::perform() { } if ( replaceTargetWithGOTAtom ) { // Replace the target with a reference to a GOT entry. - const DefinedAtom* gotEntry = NULL; + const DefinedAtom* gotEntry = nullptr; auto pos = targetToGOT.find(target); if ( pos == targetToGOT.end() ) { // This is no existing GOT entry. Create a new one. gotEntry = _platform.makeGOTEntry(*target, _file); - assert(gotEntry != NULL); + assert(gotEntry != nullptr); assert(gotEntry->contentType() == DefinedAtom::typeGOT); targetToGOT[target] = gotEntry; } else { // Reuse an existing GOT entry. gotEntry = pos->second; - assert(gotEntry != NULL); + assert(gotEntry != nullptr); } // Switch reference to GOT atom. (const_cast<Reference*>(ref))->setTarget(gotEntry); diff --git a/lld/lib/Passes/StubsPass.cpp b/lld/lib/Passes/StubsPass.cpp index 0026074698d..32d906d5d50 100644 --- a/lld/lib/Passes/StubsPass.cpp +++ b/lld/lib/Passes/StubsPass.cpp @@ -42,7 +42,7 @@ void StubsPass::perform() { // Look at call-sites. if ( _platform.isCallSite(ref->kind()) ) { const Atom* target = ref->target(); - assert(target != NULL); + assert(target != nullptr); bool replaceCalleeWithStub = false; if ( target->definition() == Atom::definitionSharedLibrary ) { // Calls to shared libraries go through stubs. @@ -63,14 +63,14 @@ void StubsPass::perform() { if ( pos == targetToStub.end() ) { // This is no existing stub. Create a new one. stub = _platform.makeStub(*target, _file); - assert(stub != NULL); + assert(stub != nullptr); assert(stub->contentType() == DefinedAtom::typeStub); targetToStub[target] = stub; } else { // Reuse an existing stub. stub = pos->second; - assert(stub != NULL); + assert(stub != nullptr); } // Switch call site to reference stub atom. (const_cast<Reference*>(ref))->setTarget(stub); diff --git a/lld/tools/lld-core/lld-core.cpp b/lld/tools/lld-core/lld-core.cpp index b893e6466e9..c3955e6ba4f 100644 --- a/lld/tools/lld-core/lld-core.cpp +++ b/lld/tools/lld-core/lld-core.cpp @@ -119,15 +119,15 @@ public: } virtual reference_iterator referencesBegin() const { - return reference_iterator(*this, NULL); + return reference_iterator(*this, nullptr); } virtual reference_iterator referencesEnd() const { - return reference_iterator(*this, NULL); + return reference_iterator(*this, nullptr); } virtual const Reference* derefIterator(const void* iter) const { - return NULL; + return nullptr; } virtual void incrementIterator(const void*& iter) const { @@ -218,15 +218,15 @@ public: } virtual reference_iterator referencesBegin() const { - return reference_iterator(*this, NULL); + return reference_iterator(*this, nullptr); } virtual reference_iterator referencesEnd() const { - return reference_iterator(*this, NULL); + return reference_iterator(*this, nullptr); } virtual const Reference* derefIterator(const void* iter) const { - return NULL; + return nullptr; } virtual void incrementIterator(const void*& iter) const { @@ -283,18 +283,18 @@ public: return false; } - // return entry point for output file (e.g. "main") or NULL + // return entry point for output file (e.g. "main") or nullptr virtual llvm::StringRef entryPointName() { - return NULL; + return nullptr; } // for iterating must-be-defined symbols ("main" or -u command line option) typedef llvm::StringRef const *UndefinesIterator; virtual UndefinesIterator initialUndefinesBegin() const { - return NULL; + return nullptr; } virtual UndefinesIterator initialUndefinesEnd() const { - return NULL; + return nullptr; } // if platform wants resolvers to search libraries for overrides @@ -353,7 +353,7 @@ public: static const KindMapping _s_kindMappings[]; virtual Reference::Kind kindFromString(llvm::StringRef kindName) { - for (const KindMapping* p = _s_kindMappings; p->string != NULL; ++p) { + for (const KindMapping* p = _s_kindMappings; p->string != nullptr; ++p) { if ( kindName.equals(p->string) ) return p->value; } @@ -364,7 +364,7 @@ public: } virtual llvm::StringRef kindToString(Reference::Kind value) { - for (const KindMapping* p = _s_kindMappings; p->string != NULL; ++p) { + for (const KindMapping* p = _s_kindMappings; p->string != nullptr; ++p) { if ( value == p->value) return p->string; } @@ -376,7 +376,7 @@ public: } virtual bool isCallSite(Reference::Kind kind) { - for (const KindMapping* p = _s_kindMappings; p->string != NULL; ++p) { + for (const KindMapping* p = _s_kindMappings; p->string != nullptr; ++p) { if ( kind == p->value ) return p->isBranch; } @@ -384,7 +384,7 @@ public: } virtual bool isGOTAccess(Reference::Kind kind, bool& canBypassGOT) { - for (const KindMapping* p = _s_kindMappings; p->string != NULL; ++p) { + for (const KindMapping* p = _s_kindMappings; p->string != nullptr; ++p) { if ( kind == p->value ) { canBypassGOT = p->isGotLoad; return p->isGotUse; @@ -422,7 +422,7 @@ const TestingPlatform::KindMapping TestingPlatform::_s_kindMappings[] = { { "gotLoad32", 3, false, true, true }, { "gotUse32", 4, false, false, true }, { "lea32wasGot", 5, false, false, false }, - { NULL, 0, false, false, false } + { nullptr, 0, false, false, false } }; |