[lld] r249111 - [LLD] Fix Clang-tidy modernize-use-nullptr warnings; other minor cleanups.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 1 17:36:01 PDT 2015


Author: ruiu
Date: Thu Oct  1 19:36:00 2015
New Revision: 249111

URL: http://llvm.org/viewvc/llvm-project?rev=249111&view=rev
Log:
[LLD] Fix Clang-tidy modernize-use-nullptr warnings; other minor cleanups.

Patch from Eugene Zelenko!

Modified:
    lld/trunk/COFF/ModuleDef.cpp
    lld/trunk/lib/Driver/Driver.cpp
    lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
    lld/trunk/lib/ReaderWriter/MachO/LayoutPass.cpp
    lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp

Modified: lld/trunk/COFF/ModuleDef.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/ModuleDef.cpp?rev=249111&r1=249110&r2=249111&view=diff
==============================================================================
--- lld/trunk/COFF/ModuleDef.cpp (original)
+++ lld/trunk/COFF/ModuleDef.cpp Thu Oct  1 19:36:00 2015
@@ -234,7 +234,7 @@ private:
     read();
     if (Tok.K != Comma) {
       unget();
-      Commit = 0;
+      Commit = nullptr;
       return;
     }
     readAsInt(Commit);

Modified: lld/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/Driver.cpp?rev=249111&r1=249110&r2=249111&view=diff
==============================================================================
--- lld/trunk/lib/Driver/Driver.cpp (original)
+++ lld/trunk/lib/Driver/Driver.cpp Thu Oct  1 19:36:00 2015
@@ -73,7 +73,7 @@ bool Driver::link(LinkingContext &ctx, r
     args[0] = "lld (LLVM option parsing)";
     for (unsigned i = 0; i != numArgs; ++i)
       args[i + 1] = ctx.llvmOptions()[i];
-    args[numArgs + 1] = 0;
+    args[numArgs + 1] = nullptr;
     llvm::cl::ParseCommandLineOptions(numArgs + 1, args);
   }
   if (ctx.getNodes().empty())
@@ -136,4 +136,4 @@ bool Driver::link(LinkingContext &ctx, r
   return true;
 }
 
-} // namespace
+} // anonymous namespace

Modified: lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp?rev=249111&r1=249110&r2=249111&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp Thu Oct  1 19:36:00 2015
@@ -235,7 +235,7 @@ std::string ELFLinkingContext::demangle(
   const char *cstr = nullTermSym.data();
   int status;
   char *demangled = abi::__cxa_demangle(cstr, nullptr, nullptr, &status);
-  if (demangled == NULL)
+  if (!demangled)
     return symbolName;
   std::string result(demangled);
   // __cxa_demangle() always uses a malloc'ed buffer to return the result.

Modified: lld/trunk/lib/ReaderWriter/MachO/LayoutPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/LayoutPass.cpp?rev=249111&r1=249110&r2=249111&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/LayoutPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/LayoutPass.cpp Thu Oct  1 19:36:00 2015
@@ -407,7 +407,7 @@ void LayoutPass::buildOrdinalOverrideMap
     AtomToAtomT::iterator start = _followOnRoots.find(atom);
     if (start == _followOnRoots.end())
       continue;
-    for (const DefinedAtom *nextAtom = start->second; nextAtom != NULL;
+    for (const DefinedAtom *nextAtom = start->second; nextAtom;
          nextAtom = _followOnNexts[nextAtom]) {
       AtomToOrdinalT::iterator pos = _ordinalOverrideMap.find(nextAtom);
       if (pos == _ordinalOverrideMap.end())

Modified: lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp?rev=249111&r1=249110&r2=249111&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp Thu Oct  1 19:36:00 2015
@@ -74,7 +74,6 @@ bool MachOLinkingContext::parsePackedVer
   return false;
 }
 
-
 MachOLinkingContext::ArchInfo MachOLinkingContext::_s_archInfos[] = {
   { "x86_64", arch_x86_64, true,  CPU_TYPE_X86_64,  CPU_SUBTYPE_X86_64_ALL },
   { "i386",   arch_x86,    true,  CPU_TYPE_I386,    CPU_SUBTYPE_X86_ALL },
@@ -273,8 +272,6 @@ bool MachOLinkingContext::isBigEndian(Ar
   llvm_unreachable("Unknown arch type");
 }
 
-
-
 bool MachOLinkingContext::is64Bit() const {
   return is64Bit(_arch);
 }
@@ -357,9 +354,6 @@ StringRef MachOLinkingContext::binderSym
   return archHandler().stubInfo().binderSymbolName;
 }
 
-
-
-
 bool MachOLinkingContext::minOS(StringRef mac, StringRef iOS) const {
   uint32_t parsedVersion;
   switch (_os) {
@@ -489,7 +483,6 @@ void MachOLinkingContext::addFrameworkSe
     _frameworkDirs.push_back(fwPath);
 }
 
-
 ErrorOr<StringRef>
 MachOLinkingContext::searchDirForLibrary(StringRef path,
                                          StringRef libName) const {
@@ -518,8 +511,6 @@ MachOLinkingContext::searchDirForLibrary
   return make_error_code(llvm::errc::no_such_file_or_directory);
 }
 
-
-
 ErrorOr<StringRef> MachOLinkingContext::searchLibrary(StringRef libName) const {
   SmallString<256> path;
   for (StringRef dir : searchDirs()) {
@@ -531,7 +522,6 @@ ErrorOr<StringRef> MachOLinkingContext::
   return make_error_code(llvm::errc::no_such_file_or_directory);
 }
 
-
 ErrorOr<StringRef> MachOLinkingContext::findPathForFramework(StringRef fwName) const{
   SmallString<256> fullPath;
   for (StringRef dir : frameworkDirs()) {
@@ -653,7 +643,6 @@ MachODylibFile* MachOLinkingContext::loa
   return result;
 }
 
-
 MachODylibFile* MachOLinkingContext::findIndirectDylib(StringRef path) {
   // See if already loaded.
   auto pos = _pathToDylibMap.find(path);
@@ -728,7 +717,6 @@ void MachOLinkingContext::createImplicit
   }
 }
 
-
 void MachOLinkingContext::registerDylib(MachODylibFile *dylib,
                                         bool upward) const {
   std::lock_guard<std::mutex> lock(_dylibsMutex);
@@ -741,7 +729,6 @@ void MachOLinkingContext::registerDylib(
     _upwardDylibs.insert(dylib);
 }
 
-
 bool MachOLinkingContext::isUpwardDylib(StringRef installName) const {
   for (MachODylibFile *dylib : _upwardDylibs) {
     if (dylib->installName().equals(installName))
@@ -756,7 +743,6 @@ ArchHandler &MachOLinkingContext::archHa
   return *_archHandler;
 }
 
-
 void MachOLinkingContext::addSectionAlignment(StringRef seg, StringRef sect,
                                               uint16_t align) {
   SectionAlign entry = { seg, sect, align };
@@ -774,7 +760,6 @@ bool MachOLinkingContext::sectionAligned
   return false;
 }
 
-
 void MachOLinkingContext::addExportSymbol(StringRef sym) {
   // Support old crufty export lists with bogus entries.
   if (sym.endswith(".eh") || sym.startswith(".objc_category_name_")) {
@@ -829,7 +814,7 @@ std::string MachOLinkingContext::demangl
   const char *cstr = nullTermSym.data() + 1;
   int status;
   char *demangled = abi::__cxa_demangle(cstr, nullptr, nullptr, &status);
-  if (demangled != NULL) {
+  if (demangled) {
     std::string result(demangled);
     // __cxa_demangle() always uses a malloc'ed buffer to return the result.
     free(demangled);




More information about the llvm-commits mailing list