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

Patch from Eugene Zelenko!

llvm-svn: 249111
This commit is contained in:
Rui Ueyama 2015-10-02 00:36:00 +00:00
parent 42562c38f5
commit 43155d0d48
5 changed files with 6 additions and 21 deletions

View File

@ -234,7 +234,7 @@ private:
read();
if (Tok.K != Comma) {
unget();
Commit = 0;
Commit = nullptr;
return;
}
readAsInt(Commit);

View File

@ -73,7 +73,7 @@ bool Driver::link(LinkingContext &ctx, raw_ostream &diagnostics) {
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, raw_ostream &diagnostics) {
return true;
}
} // namespace
} // anonymous namespace

View File

@ -235,7 +235,7 @@ std::string ELFLinkingContext::demangle(StringRef symbolName) const {
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.

View File

@ -407,7 +407,7 @@ void LayoutPass::buildOrdinalOverrideMap(SimpleFile::DefinedAtomRange &range) {
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())

View File

@ -74,7 +74,6 @@ bool MachOLinkingContext::parsePackedVersion(StringRef str, uint32_t &result) {
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(Arch arch) {
llvm_unreachable("Unknown arch type");
}
bool MachOLinkingContext::is64Bit() const {
return is64Bit(_arch);
}
@ -357,9 +354,6 @@ StringRef MachOLinkingContext::binderSymbolName() const {
return archHandler().stubInfo().binderSymbolName;
}
bool MachOLinkingContext::minOS(StringRef mac, StringRef iOS) const {
uint32_t parsedVersion;
switch (_os) {
@ -489,7 +483,6 @@ void MachOLinkingContext::addFrameworkSearchDir(StringRef fwPath,
_frameworkDirs.push_back(fwPath);
}
ErrorOr<StringRef>
MachOLinkingContext::searchDirForLibrary(StringRef path,
StringRef libName) const {
@ -518,8 +511,6 @@ MachOLinkingContext::searchDirForLibrary(StringRef path,
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::searchLibrary(StringRef libName) const {
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::loadIndirectDylib(StringRef path) {
return result;
}
MachODylibFile* MachOLinkingContext::findIndirectDylib(StringRef path) {
// See if already loaded.
auto pos = _pathToDylibMap.find(path);
@ -728,7 +717,6 @@ void MachOLinkingContext::createImplicitFiles(
}
}
void MachOLinkingContext::registerDylib(MachODylibFile *dylib,
bool upward) const {
std::lock_guard<std::mutex> lock(_dylibsMutex);
@ -741,7 +729,6 @@ void MachOLinkingContext::registerDylib(MachODylibFile *dylib,
_upwardDylibs.insert(dylib);
}
bool MachOLinkingContext::isUpwardDylib(StringRef installName) const {
for (MachODylibFile *dylib : _upwardDylibs) {
if (dylib->installName().equals(installName))
@ -756,7 +743,6 @@ ArchHandler &MachOLinkingContext::archHandler() const {
return *_archHandler;
}
void MachOLinkingContext::addSectionAlignment(StringRef seg, StringRef sect,
uint16_t align) {
SectionAlign entry = { seg, sect, align };
@ -774,7 +760,6 @@ bool MachOLinkingContext::sectionAligned(StringRef seg, StringRef sect,
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::demangle(StringRef symbolName) const {
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);