Replace all uses of NULL with nullptr.

llvm-svn: 153677
diff --git a/lld/lib/Core/NativeReader.cpp b/lld/lib/Core/NativeReader.cpp
index f3548d6..1bb0d55 100644
--- a/lld/lib/Core/NativeReader.cpp
+++ b/lld/lib/Core/NativeReader.cpp
@@ -349,7 +349,7 @@
     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 @@
     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 @@
     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 @@
     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 @@
     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 @@
   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 @@
   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 @@
 
   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 617431e..1354184 100644
--- a/lld/lib/Core/Resolver.cpp
+++ b/lld/lib/Core/Resolver.cpp
@@ -205,7 +205,7 @@
         // 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 @@
 // 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 @@
 
   // 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 @@
   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 @@
   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 @@
 // 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 bec7100..277ce3b 100644
--- a/lld/lib/Core/SymbolTable.cpp
+++ b/lld/lib/Core/SymbolTable.cpp
@@ -126,7 +126,7 @@
 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 @@
       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 @@
       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 @@
 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 @@
   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 86d2a8c..31f09f9 100644
--- a/lld/lib/Core/YamlKeyValues.cpp
+++ b/lld/lib/Core/YamlKeyValues.cpp
@@ -69,12 +69,12 @@
   { "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 @@
 }
 
 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 @@
   { "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 @@
 }
 
 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 @@
   { "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 @@
 }
 
 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 @@
   { "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 @@
 }
 
 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 @@
   { "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 @@
 }
 
 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 @@
   { "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 @@
 }
 
 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 @@
   { "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 @@
 }
 
 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 @@
   { "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 @@
 }
 
 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 @@
   { "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 @@
 }
 
 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 c4c826d..3bfa0cf 100644
--- a/lld/lib/Core/YamlReader.cpp
+++ b/lld/lib/Core/YamlReader.cpp
@@ -43,7 +43,7 @@
     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 @@
   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 @@
         *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 @@
     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 @@
       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 @@
 
 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 @@
   }
 
   virtual llvm::StringRef name() const {
-    if ( _name == NULL )
+    if (_name == nullptr)
       return llvm::StringRef();
     else
       return _name;
@@ -441,7 +441,7 @@
   }
   
  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 @@
 
 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 @@
 
 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 @@
   }
  
   // 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 @@
   _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::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 @@
   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 @@
     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 @@
   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 7f9b0c3..15ebe62 100644
--- a/lld/lib/Core/YamlWriter.cpp
+++ b/lld/lib/Core/YamlWriter.cpp
@@ -333,7 +333,7 @@
             << _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);