summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2014-04-07 04:17:22 +0000
committerCraig Topper <craig.topper@gmail.com>2014-04-07 04:17:22 +0000
commit34bc6b6e787f27b5c9e05c82de4c1b4ac9b117bc (patch)
tree8b1bfdc38d13cfbca1dbd93a0e77e8d1b89385c7 /lib
parentb81024bc6ef83ee4242b4fab77784a0b5ad4e1b8 (diff)
downloadllvm-34bc6b6e787f27b5c9e05c82de4c1b4ac9b117bc.tar.gz
llvm-34bc6b6e787f27b5c9e05c82de4c1b4ac9b117bc.tar.bz2
llvm-34bc6b6e787f27b5c9e05c82de4c1b4ac9b117bc.tar.xz
[C++11] Make use of 'nullptr' in the Support library.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205697 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Support/APFloat.cpp6
-rw-r--r--lib/Support/APInt.cpp12
-rw-r--r--lib/Support/Allocator.cpp6
-rw-r--r--lib/Support/CommandLine.cpp66
-rw-r--r--lib/Support/CrashRecoveryContext.cpp12
-rw-r--r--lib/Support/DataExtractor.cpp4
-rw-r--r--lib/Support/DataStream.cpp2
-rw-r--r--lib/Support/Dwarf.cpp44
-rw-r--r--lib/Support/DynamicLibrary.cpp10
-rw-r--r--lib/Support/ErrorHandling.cpp6
-rw-r--r--lib/Support/FileOutputBuffer.cpp2
-rw-r--r--lib/Support/FoldingSet.cpp21
-rw-r--r--lib/Support/FormattedStream.cpp2
-rw-r--r--lib/Support/GraphWriter.cpp6
-rw-r--r--lib/Support/IntervalMap.cpp2
-rw-r--r--lib/Support/LineIterator.cpp7
-rw-r--r--lib/Support/LockFileManager.cpp2
-rw-r--r--lib/Support/ManagedStatic.cpp14
-rw-r--r--lib/Support/MemoryBuffer.cpp6
-rw-r--r--lib/Support/Mutex.cpp2
-rw-r--r--lib/Support/Path.cpp2
-rw-r--r--lib/Support/PrettyStackTrace.cpp4
-rw-r--r--lib/Support/RWMutex.cpp4
-rw-r--r--lib/Support/Regex.cpp2
-rw-r--r--lib/Support/SearchForAddressOfSpecialSymbol.cpp2
-rw-r--r--lib/Support/SmallPtrSet.cpp2
-rw-r--r--lib/Support/SourceMgr.cpp4
-rw-r--r--lib/Support/StringMap.cpp10
-rw-r--r--lib/Support/StringRef.cpp4
-rw-r--r--lib/Support/TargetRegistry.cpp20
-rw-r--r--lib/Support/ThreadLocal.cpp4
-rw-r--r--lib/Support/Threading.cpp6
-rw-r--r--lib/Support/Timer.cpp16
-rw-r--r--lib/Support/Triple.cpp6
-rw-r--r--lib/Support/YAMLParser.cpp44
-rw-r--r--lib/Support/YAMLTraits.cpp4
36 files changed, 184 insertions, 182 deletions
diff --git a/lib/Support/APFloat.cpp b/lib/Support/APFloat.cpp
index 85ce31bcab..e1fd3c602b 100644
--- a/lib/Support/APFloat.cpp
+++ b/lib/Support/APFloat.cpp
@@ -1679,7 +1679,7 @@ APFloat::multiply(const APFloat &rhs, roundingMode rounding_mode)
fs = multiplySpecials(rhs);
if (isFiniteNonZero()) {
- lostFraction lost_fraction = multiplySignificand(rhs, 0);
+ lostFraction lost_fraction = multiplySignificand(rhs, nullptr);
fs = normalize(rounding_mode, lost_fraction);
if (lost_fraction != lfExactlyZero)
fs = (opStatus) (fs | opInexact);
@@ -2439,7 +2439,7 @@ APFloat::roundSignificandWithExponent(const integerPart *decSigParts,
if (exp >= 0) {
/* multiplySignificand leaves the precision-th bit set to 1. */
- calcLostFraction = decSig.multiplySignificand(pow5, NULL);
+ calcLostFraction = decSig.multiplySignificand(pow5, nullptr);
powHUerr = powStatus != opOK;
} else {
calcLostFraction = decSig.divideSignificand(pow5);
@@ -3795,7 +3795,7 @@ APFloat::opStatus APFloat::next(bool nextDown) {
if (isSignaling()) {
result = opInvalidOp;
// For consistency, propagate the sign of the sNaN to the qNaN.
- makeNaN(false, isNegative(), 0);
+ makeNaN(false, isNegative(), nullptr);
}
break;
case fcZero:
diff --git a/lib/Support/APInt.cpp b/lib/Support/APInt.cpp
index 0c4672582b..6dafe9ec3c 100644
--- a/lib/Support/APInt.cpp
+++ b/lib/Support/APInt.cpp
@@ -1683,10 +1683,10 @@ void APInt::divide(const APInt LHS, unsigned lhsWords,
// Allocate space for the temporary values we need either on the stack, if
// it will fit, or on the heap if it won't.
unsigned SPACE[128];
- unsigned *U = 0;
- unsigned *V = 0;
- unsigned *Q = 0;
- unsigned *R = 0;
+ unsigned *U = nullptr;
+ unsigned *V = nullptr;
+ unsigned *Q = nullptr;
+ unsigned *R = nullptr;
if ((Remainder?4:3)*n+2*m+1 <= 128) {
U = &SPACE[0];
V = &SPACE[m+n+1];
@@ -1872,7 +1872,7 @@ APInt APInt::udiv(const APInt& RHS) const {
// We have to compute it the hard way. Invoke the Knuth divide algorithm.
APInt Quotient(1,0); // to hold result.
- divide(*this, lhsWords, RHS, rhsWords, &Quotient, 0);
+ divide(*this, lhsWords, RHS, rhsWords, &Quotient, nullptr);
return Quotient;
}
@@ -1920,7 +1920,7 @@ APInt APInt::urem(const APInt& RHS) const {
// We have to compute it the hard way. Invoke the Knuth divide algorithm.
APInt Remainder(1,0);
- divide(*this, lhsWords, RHS, rhsWords, 0, &Remainder);
+ divide(*this, lhsWords, RHS, rhsWords, nullptr, &Remainder);
return Remainder;
}
diff --git a/lib/Support/Allocator.cpp b/lib/Support/Allocator.cpp
index 7e177481cb..11f7ba80a6 100644
--- a/lib/Support/Allocator.cpp
+++ b/lib/Support/Allocator.cpp
@@ -28,7 +28,7 @@ MallocSlabAllocator::~MallocSlabAllocator() { }
MemSlab *MallocSlabAllocator::Allocate(size_t Size) {
MemSlab *Slab = (MemSlab*)Allocator.Allocate(Size, 0);
Slab->Size = Size;
- Slab->NextPtr = 0;
+ Slab->NextPtr = nullptr;
return Slab;
}
@@ -39,7 +39,7 @@ void MallocSlabAllocator::Deallocate(MemSlab *Slab) {
void BumpPtrAllocatorBase::PrintStats() const {
unsigned NumSlabs = 0;
size_t TotalMemory = 0;
- for (MemSlab *Slab = CurSlab; Slab != 0; Slab = Slab->NextPtr) {
+ for (MemSlab *Slab = CurSlab; Slab != nullptr; Slab = Slab->NextPtr) {
TotalMemory += Slab->Size;
++NumSlabs;
}
@@ -53,7 +53,7 @@ void BumpPtrAllocatorBase::PrintStats() const {
size_t BumpPtrAllocatorBase::getTotalMemory() const {
size_t TotalMemory = 0;
- for (MemSlab *Slab = CurSlab; Slab != 0; Slab = Slab->NextPtr) {
+ for (MemSlab *Slab = CurSlab; Slab != nullptr; Slab = Slab->NextPtr) {
TotalMemory += Slab->Size;
}
return TotalMemory;
diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp
index b3c2614ec9..04a40b46f1 100644
--- a/lib/Support/CommandLine.cpp
+++ b/lib/Support/CommandLine.cpp
@@ -81,7 +81,7 @@ void StringSaver::anchor() {}
// Globals for name and overview of program. Program name is not a string to
// avoid static ctor/dtor issues.
static char ProgramName[80] = "<premain>";
-static const char *ProgramOverview = 0;
+static const char *ProgramOverview = nullptr;
// This collects additional help to be printed.
static ManagedStatic<std::vector<const char*> > MoreHelp;
@@ -100,7 +100,7 @@ void cl::MarkOptionsChanged() {
/// RegisteredOptionList - This is the list of the command line options that
/// have statically constructed themselves.
-static Option *RegisteredOptionList = 0;
+static Option *RegisteredOptionList = nullptr;
void Option::addArgument() {
assert(NextRegistered == 0 && "argument multiply registered!");
@@ -144,7 +144,7 @@ static void GetOptionInfo(SmallVectorImpl<Option*> &PositionalOpts,
SmallVectorImpl<Option*> &SinkOpts,
StringMap<Option*> &OptionsMap) {
SmallVector<const char*, 16> OptionNames;
- Option *CAOpt = 0; // The ConsumeAfter option if it exists.
+ Option *CAOpt = nullptr; // The ConsumeAfter option if it exists.
for (Option *O = RegisteredOptionList; O; O = O->getNextRegisteredOption()) {
// If this option wants to handle multiple option names, get the full set.
// This handles enum options like "-O1 -O2" etc.
@@ -189,7 +189,7 @@ static void GetOptionInfo(SmallVectorImpl<Option*> &PositionalOpts,
static Option *LookupOption(StringRef &Arg, StringRef &Value,
const StringMap<Option*> &OptionsMap) {
// Reject all dashes.
- if (Arg.empty()) return 0;
+ if (Arg.empty()) return nullptr;
size_t EqualPos = Arg.find('=');
@@ -197,14 +197,14 @@ static Option *LookupOption(StringRef &Arg, StringRef &Value,
if (EqualPos == StringRef::npos) {
// Look up the option.
StringMap<Option*>::const_iterator I = OptionsMap.find(Arg);
- return I != OptionsMap.end() ? I->second : 0;
+ return I != OptionsMap.end() ? I->second : nullptr;
}
// If the argument before the = is a valid option name, we match. If not,
// return Arg unmolested.
StringMap<Option*>::const_iterator I =
OptionsMap.find(Arg.substr(0, EqualPos));
- if (I == OptionsMap.end()) return 0;
+ if (I == OptionsMap.end()) return nullptr;
Value = Arg.substr(EqualPos+1);
Arg = Arg.substr(0, EqualPos);
@@ -219,7 +219,7 @@ static Option *LookupNearestOption(StringRef Arg,
const StringMap<Option*> &OptionsMap,
std::string &NearestString) {
// Reject all dashes.
- if (Arg.empty()) return 0;
+ if (Arg.empty()) return nullptr;
// Split on any equal sign.
std::pair<StringRef, StringRef> SplitArg = Arg.split('=');
@@ -227,7 +227,7 @@ static Option *LookupNearestOption(StringRef Arg,
StringRef &RHS = SplitArg.second;
// Find the closest match.
- Option *Best = 0;
+ Option *Best = nullptr;
unsigned BestDistance = 0;
for (StringMap<Option*>::const_iterator it = OptionsMap.begin(),
ie = OptionsMap.end(); it != ie; ++it) {
@@ -300,7 +300,7 @@ static inline bool ProvideOption(Option *Handler, StringRef ArgName,
// Enforce value requirements
switch (Handler->getValueExpectedFlag()) {
case ValueRequired:
- if (Value.data() == 0) { // No value specified?
+ if (Value.data() == nullptr) { // No value specified?
if (i+1 >= argc)
return Handler->error("requires a value!");
// Steal the next argument, like for '-o filename'
@@ -349,7 +349,7 @@ static inline bool ProvideOption(Option *Handler, StringRef ArgName,
static bool ProvidePositionalOption(Option *Handler, StringRef Arg, int i) {
int Dummy = i;
- return ProvideOption(Handler, Handler->ArgStr, Arg, 0, 0, Dummy);
+ return ProvideOption(Handler, Handler->ArgStr, Arg, 0, nullptr, Dummy);
}
@@ -385,7 +385,7 @@ static Option *getOptionPred(StringRef Name, size_t &Length,
Length = Name.size();
return OMI->second; // Found one!
}
- return 0; // No option found!
+ return nullptr; // No option found!
}
/// HandlePrefixedOrGroupedOption - The specified argument string (which started
@@ -395,12 +395,12 @@ static Option *getOptionPred(StringRef Name, size_t &Length,
static Option *HandlePrefixedOrGroupedOption(StringRef &Arg, StringRef &Value,
bool &ErrorParsing,
const StringMap<Option*> &OptionsMap) {
- if (Arg.size() == 1) return 0;
+ if (Arg.size() == 1) return nullptr;
// Do the lookup!
size_t Length = 0;
Option *PGOpt = getOptionPred(Arg, Length, isPrefixedOrGrouping, OptionsMap);
- if (PGOpt == 0) return 0;
+ if (PGOpt == nullptr) return nullptr;
// If the option is a prefixed option, then the value is simply the
// rest of the name... so fall through to later processing, by
@@ -427,7 +427,7 @@ static Option *HandlePrefixedOrGroupedOption(StringRef &Arg, StringRef &Value,
"Option can not be cl::Grouping AND cl::ValueRequired!");
int Dummy = 0;
ErrorParsing |= ProvideOption(PGOpt, OneArgName,
- StringRef(), 0, 0, Dummy);
+ StringRef(), 0, nullptr, Dummy);
// Get the next grouping option.
PGOpt = getOptionPred(Arg, Length, isGrouping, OptionsMap);
@@ -760,7 +760,7 @@ void cl::ParseCommandLineOptions(int argc, const char * const *argv,
// Determine whether or not there are an unlimited number of positionals
bool HasUnlimitedPositionals = false;
- Option *ConsumeAfterOpt = 0;
+ Option *ConsumeAfterOpt = nullptr;
if (!PositionalOpts.empty()) {
if (PositionalOpts[0]->getNumOccurrencesFlag() == cl::ConsumeAfter) {
assert(PositionalOpts.size() > 1 &&
@@ -770,7 +770,7 @@ void cl::ParseCommandLineOptions(int argc, const char * const *argv,
// Calculate how many positional values are _required_.
bool UnboundedFound = false;
- for (size_t i = ConsumeAfterOpt != 0, e = PositionalOpts.size();
+ for (size_t i = ConsumeAfterOpt != nullptr, e = PositionalOpts.size();
i != e; ++i) {
Option *Opt = PositionalOpts[i];
if (RequiresValue(Opt))
@@ -806,13 +806,13 @@ void cl::ParseCommandLineOptions(int argc, const char * const *argv,
// If the program has named positional arguments, and the name has been run
// across, keep track of which positional argument was named. Otherwise put
// the positional args into the PositionalVals list...
- Option *ActivePositionalArg = 0;
+ Option *ActivePositionalArg = nullptr;
// Loop over all of the arguments... processing them.
bool DashDashFound = false; // Have we read '--'?
for (int i = 1; i < argc; ++i) {
- Option *Handler = 0;
- Option *NearestHandler = 0;
+ Option *Handler = nullptr;
+ Option *NearestHandler = nullptr;
std::string NearestHandlerString;
StringRef Value;
StringRef ArgName = "";
@@ -846,7 +846,7 @@ void cl::ParseCommandLineOptions(int argc, const char * const *argv,
// the consume after option... if it's specified...
//
if (PositionalVals.size() >= NumPositionalRequired &&
- ConsumeAfterOpt != 0) {
+ ConsumeAfterOpt != nullptr) {
for (++i; i < argc; ++i)
PositionalVals.push_back(std::make_pair(argv[i],i));
break; // Handle outside of the argument processing loop...
@@ -884,18 +884,18 @@ void cl::ParseCommandLineOptions(int argc, const char * const *argv,
Handler = LookupOption(ArgName, Value, Opts);
// Check to see if this "option" is really a prefixed or grouped argument.
- if (Handler == 0)
+ if (Handler == nullptr)
Handler = HandlePrefixedOrGroupedOption(ArgName, Value,
ErrorParsing, Opts);
// Otherwise, look for the closest available option to report to the user
// in the upcoming error.
- if (Handler == 0 && SinkOpts.empty())
+ if (Handler == nullptr && SinkOpts.empty())
NearestHandler = LookupNearestOption(ArgName, Opts,
NearestHandlerString);
}
- if (Handler == 0) {
+ if (Handler == nullptr) {
if (SinkOpts.empty()) {
errs() << ProgramName << ": Unknown command line argument '"
<< argv[i] << "'. Try: '" << argv[0] << " -help'\n";
@@ -939,7 +939,7 @@ void cl::ParseCommandLineOptions(int argc, const char * const *argv,
<< " positional arguments: See: " << argv[0] << " -help\n";
ErrorParsing = true;
- } else if (ConsumeAfterOpt == 0) {
+ } else if (ConsumeAfterOpt == nullptr) {
// Positional args have already been handled if ConsumeAfter is specified.
unsigned ValNo = 0, NumVals = static_cast<unsigned>(PositionalVals.size());
for (size_t i = 0, e = PositionalOpts.size(); i != e; ++i) {
@@ -1044,7 +1044,7 @@ void cl::ParseCommandLineOptions(int argc, const char * const *argv,
//
bool Option::error(const Twine &Message, StringRef ArgName) {
- if (ArgName.data() == 0) ArgName = ArgStr;
+ if (ArgName.data() == nullptr) ArgName = ArgStr;
if (ArgName.empty())
errs() << HelpStr; // Be nice for positional arguments
else
@@ -1455,12 +1455,12 @@ public:
outs() << "USAGE: " << ProgramName << " [options]";
// Print out the positional options.
- Option *CAOpt = 0; // The cl::ConsumeAfter option, if it exists...
+ Option *CAOpt = nullptr; // The cl::ConsumeAfter option, if it exists...
if (!PositionalOpts.empty() &&
PositionalOpts[0]->getNumOccurrencesFlag() == ConsumeAfter)
CAOpt = PositionalOpts[0];
- for (size_t i = CAOpt != 0, e = PositionalOpts.size(); i != e; ++i) {
+ for (size_t i = CAOpt != nullptr, e = PositionalOpts.size(); i != e; ++i) {
if (PositionalOpts[i]->ArgStr[0])
outs() << " --" << PositionalOpts[i]->ArgStr;
outs() << " " << PositionalOpts[i]->HelpStr;
@@ -1555,7 +1555,7 @@ protected:
outs() << (*Category)->getName() << ":\n";
// Check if description is set.
- if ((*Category)->getDescription() != 0)
+ if ((*Category)->getDescription() != nullptr)
outs() << (*Category)->getDescription() << "\n\n";
else
outs() << "\n";
@@ -1686,9 +1686,9 @@ void cl::PrintOptionValues() {
Opts[i].second->printOptionValue(MaxArgLen, PrintAllOptions);
}
-static void (*OverrideVersionPrinter)() = 0;
+static void (*OverrideVersionPrinter)() = nullptr;
-static std::vector<void (*)()>* ExtraVersionPrinters = 0;
+static std::vector<void (*)()>* ExtraVersionPrinters = nullptr;
namespace {
class VersionPrinter {
@@ -1721,7 +1721,7 @@ public:
void operator=(bool OptionWasSpecified) {
if (!OptionWasSpecified) return;
- if (OverrideVersionPrinter != 0) {
+ if (OverrideVersionPrinter != nullptr) {
(*OverrideVersionPrinter)();
exit(0);
}
@@ -1729,7 +1729,7 @@ public:
// Iterate over any registered extra printers and call them to add further
// information.
- if (ExtraVersionPrinters != 0) {
+ if (ExtraVersionPrinters != nullptr) {
outs() << '\n';
for (std::vector<void (*)()>::iterator I = ExtraVersionPrinters->begin(),
E = ExtraVersionPrinters->end();
@@ -1779,7 +1779,7 @@ void cl::SetVersionPrinter(void (*func)()) {
}
void cl::AddExtraVersionPrinter(void (*func)()) {
- if (ExtraVersionPrinters == 0)
+ if (ExtraVersionPrinters == nullptr)
ExtraVersionPrinters = new std::vector<void (*)()>;
ExtraVersionPrinters->push_back(func);
diff --git a/lib/Support/CrashRecoveryContext.cpp b/lib/Support/CrashRecoveryContext.cpp
index ccc00894fb..513875d4de 100644
--- a/lib/Support/CrashRecoveryContext.cpp
+++ b/lib/Support/CrashRecoveryContext.cpp
@@ -89,16 +89,16 @@ CrashRecoveryContext::~CrashRecoveryContext() {
}
bool CrashRecoveryContext::isRecoveringFromCrash() {
- return tlIsRecoveringFromCrash->get() != 0;
+ return tlIsRecoveringFromCrash->get() != nullptr;
}
CrashRecoveryContext *CrashRecoveryContext::GetCurrent() {
if (!gCrashRecoveryEnabled)
- return 0;
+ return nullptr;
const CrashRecoveryContextImpl *CRCI = CurrentContext->get();
if (!CRCI)
- return 0;
+ return nullptr;
return CRCI->CRC;
}
@@ -120,7 +120,7 @@ CrashRecoveryContext::unregisterCleanup(CrashRecoveryContextCleanup *cleanup) {
if (cleanup == head) {
head = cleanup->next;
if (head)
- head->prev = 0;
+ head->prev = nullptr;
}
else {
cleanup->prev->next = cleanup->next;
@@ -261,7 +261,7 @@ static void CrashRecoverySignalHandler(int Signal) {
sigset_t SigMask;
sigemptyset(&SigMask);
sigaddset(&SigMask, Signal);
- sigprocmask(SIG_UNBLOCK, &SigMask, 0);
+ sigprocmask(SIG_UNBLOCK, &SigMask, nullptr);
if (CRCI)
const_cast<CrashRecoveryContextImpl*>(CRCI)->HandleCrash();
@@ -296,7 +296,7 @@ void CrashRecoveryContext::Disable() {
// Restore the previous signal handlers.
for (unsigned i = 0; i != NumSignals; ++i)
- sigaction(Signals[i], &PrevActions[i], 0);
+ sigaction(Signals[i], &PrevActions[i], nullptr);
}
#endif
diff --git a/lib/Support/DataExtractor.cpp b/lib/Support/DataExtractor.cpp
index a564d211b1..7b829215d2 100644
--- a/lib/Support/DataExtractor.cpp
+++ b/lib/Support/DataExtractor.cpp
@@ -44,7 +44,7 @@ static T *getUs(uint32_t *offset_ptr, T *dst, uint32_t count,
// success
return dst;
}
- return NULL;
+ return nullptr;
}
uint8_t DataExtractor::getU8(uint32_t *offset_ptr) const {
@@ -125,7 +125,7 @@ const char *DataExtractor::getCStr(uint32_t *offset_ptr) const {
*offset_ptr = pos + 1;
return Data.data() + offset;
}
- return NULL;
+ return nullptr;
}
uint64_t DataExtractor::getULEB128(uint32_t *offset_ptr) const {
diff --git a/lib/Support/DataStream.cpp b/lib/Support/DataStream.cpp
index 1caeddfe24..cb36d9c0c0 100644
--- a/lib/Support/DataStream.cpp
+++ b/lib/Support/DataStream.cpp
@@ -83,7 +83,7 @@ DataStreamer *getDataFileStreamer(const std::string &Filename,
if (error_code e = s->OpenFile(Filename)) {
*StrError = std::string("Could not open ") + Filename + ": " +
e.message() + "\n";
- return NULL;
+ return nullptr;
}
return s;
}
diff --git a/lib/Support/Dwarf.cpp b/lib/Support/Dwarf.cpp
index 6604cc73fa..c9efa61afe 100644
--- a/lib/Support/Dwarf.cpp
+++ b/lib/Support/Dwarf.cpp
@@ -100,7 +100,7 @@ const char *llvm::dwarf::TagString(unsigned Tag) {
return "DW_TAG_GNU_formal_parameter_pack";
case DW_TAG_APPLE_property: return "DW_TAG_APPLE_property";
}
- return 0;
+ return nullptr;
}
/// ChildrenString - Return the string for the specified children flag.
@@ -110,7 +110,7 @@ const char *llvm::dwarf::ChildrenString(unsigned Children) {
case DW_CHILDREN_no: return "DW_CHILDREN_no";
case DW_CHILDREN_yes: return "DW_CHILDREN_yes";
}
- return 0;
+ return nullptr;
}
/// AttributeString - Return the string for the specified attribute.
@@ -271,7 +271,7 @@ const char *llvm::dwarf::AttributeString(unsigned Attribute) {
case DW_AT_GNU_pubnames: return "DW_AT_GNU_pubnames";
case DW_AT_GNU_pubtypes: return "DW_AT_GNU_pubtypes";
}
- return 0;
+ return nullptr;
}
/// FormEncodingString - Return the string for the specified form encoding.
@@ -308,7 +308,7 @@ const char *llvm::dwarf::FormEncodingString(unsigned Encoding) {
case DW_FORM_GNU_addr_index: return "DW_FORM_GNU_addr_index";
case DW_FORM_GNU_str_index: return "DW_FORM_GNU_str_index";
}
- return 0;
+ return nullptr;
}
/// OperationEncodingString - Return the string for the specified operation
@@ -477,7 +477,7 @@ const char *llvm::dwarf::OperationEncodingString(unsigned Encoding) {
case DW_OP_GNU_addr_index: return "DW_OP_GNU_addr_index";
case DW_OP_GNU_const_index: return "DW_OP_GNU_const_index";
}
- return 0;
+ return nullptr;
}
/// AttributeEncodingString - Return the string for the specified attribute
@@ -503,7 +503,7 @@ const char *llvm::dwarf::AttributeEncodingString(unsigned Encoding) {
case DW_ATE_lo_user: return "DW_ATE_lo_user";
case DW_ATE_hi_user: return "DW_ATE_hi_user";
}
- return 0;
+ return nullptr;
}
/// DecimalSignString - Return the string for the specified decimal sign
@@ -516,7 +516,7 @@ const char *llvm::dwarf::DecimalSignString(unsigned Sign) {
case DW_DS_leading_separate: return "DW_DS_leading_separate";
case DW_DS_trailing_separate: return "DW_DS_trailing_separate";
}
- return 0;
+ return nullptr;
}
/// EndianityString - Return the string for the specified endianity.
@@ -529,7 +529,7 @@ const char *llvm::dwarf::EndianityString(unsigned Endian) {
case DW_END_lo_user: return "DW_END_lo_user";
case DW_END_hi_user: return "DW_END_hi_user";
}
- return 0;
+ return nullptr;
}
/// AccessibilityString - Return the string for the specified accessibility.
@@ -541,7 +541,7 @@ const char *llvm::dwarf::AccessibilityString(unsigned Access) {
case DW_ACCESS_protected: return "DW_ACCESS_protected";
case DW_ACCESS_private: return "DW_ACCESS_private";
}
- return 0;
+ return nullptr;
}
/// VisibilityString - Return the string for the specified visibility.
@@ -552,7 +552,7 @@ const char *llvm::dwarf::VisibilityString(unsigned Visibility) {
case DW_VIS_exported: return "DW_VIS_exported";
case DW_VIS_qualified: return "DW_VIS_qualified";
}
- return 0;
+ return nullptr;
}
/// VirtualityString - Return the string for the specified virtuality.
@@ -563,7 +563,7 @@ const char *llvm::dwarf::VirtualityString(unsigned Virtuality) {
case DW_VIRTUALITY_virtual: return "DW_VIRTUALITY_virtual";
case DW_VIRTUALITY_pure_virtual: return "DW_VIRTUALITY_pure_virtual";
}
- return 0;
+ return nullptr;
}
/// LanguageString - Return the string for the specified language.
@@ -600,7 +600,7 @@ const char *llvm::dwarf::LanguageString(unsigned Language) {
case DW_LANG_lo_user: return "DW_LANG_lo_user";
case DW_LANG_hi_user: return "DW_LANG_hi_user";
}
- return 0;
+ return nullptr;
}
/// CaseString - Return the string for the specified identifier case.
@@ -612,7 +612,7 @@ const char *llvm::dwarf::CaseString(unsigned Case) {
case DW_ID_down_case: return "DW_ID_down_case";
case DW_ID_case_insensitive: return "DW_ID_case_insensitive";
}
- return 0;
+ return nullptr;
}
/// ConventionString - Return the string for the specified calling convention.
@@ -625,7 +625,7 @@ const char *llvm::dwarf::ConventionString(unsigned Convention) {
case DW_CC_lo_user: return "DW_CC_lo_user";
case DW_CC_hi_user: return "DW_CC_hi_user";
}
- return 0;
+ return nullptr;
}
/// InlineCodeString - Return the string for the specified inline code.
@@ -637,7 +637,7 @@ const char *llvm::dwarf::InlineCodeString(unsigned Code) {
case DW_INL_declared_not_inlined: return "DW_INL_declared_not_inlined";
case DW_INL_declared_inlined: return "DW_INL_declared_inlined";
}
- return 0;
+ return nullptr;
}
/// ArrayOrderString - Return the string for the specified array order.
@@ -647,7 +647,7 @@ const char *llvm::dwarf::ArrayOrderString(unsigned Order) {
case DW_ORD_row_major: return "DW_ORD_row_major";
case DW_ORD_col_major: return "DW_ORD_col_major";
}
- return 0;
+ return nullptr;
}
/// DiscriminantString - Return the string for the specified discriminant
@@ -657,7 +657,7 @@ const char *llvm::dwarf::DiscriminantString(unsigned Discriminant) {
case DW_DSC_label: return "DW_DSC_label";
case DW_DSC_range: return "DW_DSC_range";
}
- return 0;
+ return nullptr;
}
/// LNStandardString - Return the string for the specified line number standard.
@@ -677,7 +677,7 @@ const char *llvm::dwarf::LNStandardString(unsigned Standard) {
case DW_LNS_set_epilogue_begin: return "DW_LNS_set_epilogue_begin";
case DW_LNS_set_isa: return "DW_LNS_set_isa";
}
- return 0;
+ return nullptr;
}
/// LNExtendedString - Return the string for the specified line number extended
@@ -692,7 +692,7 @@ const char *llvm::dwarf::LNExtendedString(unsigned Encoding) {
case DW_LNE_lo_user: return "DW_LNE_lo_user";
case DW_LNE_hi_user: return "DW_LNE_hi_user";
}
- return 0;
+ return nullptr;
}
/// MacinfoString - Return the string for the specified macinfo type encodings.
@@ -706,7 +706,7 @@ const char *llvm::dwarf::MacinfoString(unsigned Encoding) {
case DW_MACINFO_end_file: return "DW_MACINFO_end_file";
case DW_MACINFO_vendor_ext: return "DW_MACINFO_vendor_ext";
}
- return 0;
+ return nullptr;
}
/// CallFrameString - Return the string for the specified call frame instruction
@@ -745,7 +745,7 @@ const char *llvm::dwarf::CallFrameString(unsigned Encoding) {
case DW_CFA_lo_user: return "DW_CFA_lo_user";
case DW_CFA_hi_user: return "DW_CFA_hi_user";
}
- return 0;
+ return nullptr;
}
const char *llvm::dwarf::AtomTypeString(unsigned AT) {
@@ -761,7 +761,7 @@ const char *llvm::dwarf::AtomTypeString(unsigned AT) {
case DW_ATOM_type_flags:
return "DW_ATOM_type_flags";
}
- return 0;
+ return nullptr;
}
const char *llvm::dwarf::GDBIndexEntryKindString(GDBIndexEntryKind Kind) {
diff --git a/lib/Support/DynamicLibrary.cpp b/lib/Support/DynamicLibrary.cpp
index 5d77153a18..e4a438585b 100644
--- a/lib/Support/DynamicLibrary.cpp
+++ b/lib/Support/DynamicLibrary.cpp
@@ -51,14 +51,14 @@ using namespace llvm::sys;
//=== independent code.
//===----------------------------------------------------------------------===//
-static DenseSet<void *> *OpenedHandles = 0;
+static DenseSet<void *> *OpenedHandles = nullptr;
DynamicLibrary DynamicLibrary::getPermanentLibrary(const char *filename,
std::string *errMsg) {
SmartScopedLock<true> lock(*SymbolsMutex);
void *handle = dlopen(filename, RTLD_LAZY|RTLD_GLOBAL);
- if (handle == 0) {
+ if (handle == nullptr) {
if (errMsg) *errMsg = dlerror();
return DynamicLibrary();
}
@@ -70,7 +70,7 @@ DynamicLibrary DynamicLibrary::getPermanentLibrary(const char *filename,
handle = RTLD_DEFAULT;
#endif
- if (OpenedHandles == 0)
+ if (OpenedHandles == nullptr)
OpenedHandles = new DenseSet<void *>();
// If we've already loaded this library, dlclose() the handle in order to
@@ -83,7 +83,7 @@ DynamicLibrary DynamicLibrary::getPermanentLibrary(const char *filename,
void *DynamicLibrary::getAddressOfSymbol(const char *symbolName) {
if (!isValid())
- return NULL;
+ return nullptr;
return dlsym(Data, symbolName);
}
@@ -166,7 +166,7 @@ void* DynamicLibrary::SearchForAddressOfSymbol(const char *symbolName) {
#endif
#undef EXPLICIT_SYMBOL
- return 0;
+ return nullptr;
}
#endif // LLVM_ON_WIN32
diff --git a/lib/Support/ErrorHandling.cpp b/lib/Support/ErrorHandling.cpp
index 1aa8303b9e..342c4f05cc 100644
--- a/lib/Support/ErrorHandling.cpp
+++ b/lib/Support/ErrorHandling.cpp
@@ -34,8 +34,8 @@
using namespace llvm;
-static fatal_error_handler_t ErrorHandler = 0;
-static void *ErrorHandlerUserData = 0;
+static fatal_error_handler_t ErrorHandler = nullptr;
+static void *ErrorHandlerUserData = nullptr;
void llvm::install_fatal_error_handler(fatal_error_handler_t handler,
void *user_data) {
@@ -47,7 +47,7 @@ void llvm::install_fatal_error_handler(fatal_error_handler_t handler,
}
void llvm::remove_fatal_error_handler() {
- ErrorHandler = 0;
+ ErrorHandler = nullptr;
}
void llvm::report_fatal_error(const char *Reason, bool GenCrashDiag) {
diff --git a/lib/Support/FileOutputBuffer.cpp b/lib/Support/FileOutputBuffer.cpp
index 8f2c9fcce0..7e922df135 100644
--- a/lib/Support/FileOutputBuffer.cpp
+++ b/lib/Support/FileOutputBuffer.cpp
@@ -97,7 +97,7 @@ error_code FileOutputBuffer::create(StringRef FilePath,
error_code FileOutputBuffer::commit(int64_t NewSmallerSize) {
// Unmap buffer, letting OS flush dirty pages to file on disk.
- Region.reset(0);
+ Region.reset(nullptr);
// If requested, resize file as part of commit.
if ( NewSmallerSize != -1 ) {
diff --git a/lib/Support/FoldingSet.cpp b/lib/Support/FoldingSet.cpp
index 145f12dc1e..0367c7ce45 100644
--- a/lib/Support/FoldingSet.cpp
+++ b/lib/Support/FoldingSet.cpp
@@ -190,7 +190,7 @@ FoldingSetNodeID::Intern(BumpPtrAllocator &Allocator) const {
static FoldingSetImpl::Node *GetNextPtr(void *NextInBucketPtr) {
// The low bit is set if this is the pointer back to the bucket.
if (reinterpret_cast<intptr_t>(NextInBucketPtr) & 1)
- return 0;
+ return nullptr;
return static_cast<FoldingSetImpl::Node*>(NextInBucketPtr);
}
@@ -262,7 +262,7 @@ void FoldingSetImpl::GrowHashTable() {
while (Node *NodeInBucket = GetNextPtr(Probe)) {
// Figure out the next link, remove NodeInBucket from the old link.
Probe = NodeInBucket->getNextInBucket();
- NodeInBucket->SetNextInBucket(0);
+ NodeInBucket->SetNextInBucket(nullptr);
// Insert the node into the new bucket, after recomputing the hash.
InsertNode(NodeInBucket,
@@ -285,7 +285,7 @@ FoldingSetImpl::Node
void **Bucket = GetBucketFor(IDHash, Buckets, NumBuckets);
void *Probe = *Bucket;
- InsertPos = 0;
+ InsertPos = nullptr;
FoldingSetNodeID TempID;
while (Node *NodeInBucket = GetNextPtr(Probe)) {
@@ -298,7 +298,7 @@ FoldingSetImpl::Node
// Didn't find the node, return null with the bucket as the InsertPos.
InsertPos = Bucket;
- return 0;
+ return nullptr;
}
/// InsertNode - Insert the specified node into the folding set, knowing that it
@@ -323,7 +323,7 @@ void FoldingSetImpl::InsertNode(Node *N, void *InsertPos) {
// If this is the first insertion into this bucket, its next pointer will be
// null. Pretend as if it pointed to itself, setting the low bit to indicate
// that it is a pointer to the bucket.
- if (Next == 0)
+ if (Next == nullptr)
Next = reinterpret_cast<void*>(reinterpret_cast<intptr_t>(Bucket)|1);
// Set the node's next pointer, and make the bucket point to the node.
@@ -337,10 +337,10 @@ bool FoldingSetImpl::RemoveNode(Node *N) {
// Because each bucket is a circular list, we don't need to compute N's hash
// to remove it.
void *Ptr = N->getNextInBucket();
- if (Ptr == 0) return false; // Not in folding set.
+ if (Ptr == nullptr) return false; // Not in folding set.
--NumNodes;
- N->SetNextInBucket(0);
+ N->SetNextInBucket(nullptr);
// Remember what N originally pointed to, either a bucket or another node.
void *NodeNextPtr = Ptr;
@@ -390,7 +390,7 @@ FoldingSetImpl::Node *FoldingSetImpl::GetOrInsertNode(FoldingSetImpl::Node *N) {
FoldingSetIteratorImpl::FoldingSetIteratorImpl(void **Bucket) {
// Skip to the first non-null non-self-cycle bucket.
while (*Bucket != reinterpret_cast<void*>(-1) &&
- (*Bucket == 0 || GetNextPtr(*Bucket) == 0))
+ (*Bucket == nullptr || GetNextPtr(*Bucket) == nullptr))
++Bucket;
NodePtr = static_cast<FoldingSetNode*>(*Bucket);
@@ -410,7 +410,7 @@ void FoldingSetIteratorImpl::advance() {
do {
++Bucket;
} while (*Bucket != reinterpret_cast<void*>(-1) &&
- (*Bucket == 0 || GetNextPtr(*Bucket) == 0));
+ (*Bucket == nullptr || GetNextPtr(*Bucket) == nullptr));
NodePtr = static_cast<FoldingSetNode*>(*Bucket);
}
@@ -420,5 +420,6 @@ void FoldingSetIteratorImpl::advance() {
// FoldingSetBucketIteratorImpl Implementation
FoldingSetBucketIteratorImpl::FoldingSetBucketIteratorImpl(void **Bucket) {
- Ptr = (*Bucket == 0 || GetNextPtr(*Bucket) == 0) ? (void*) Bucket : *Bucket;
+ Ptr = (*Bucket == nullptr || GetNextPtr(*Bucket) == nullptr) ? (void*) Bucket
+ : *Bucket;
}
diff --git a/lib/Support/FormattedStream.cpp b/lib/Support/FormattedStream.cpp
index 9febf664f2..618ec2673a 100644
--- a/lib/Support/FormattedStream.cpp
+++ b/lib/Support/FormattedStream.cpp
@@ -81,7 +81,7 @@ void formatted_raw_ostream::write_impl(const char *Ptr, size_t Size) {
TheStream->write(Ptr, Size);
// Reset the scanning pointer.
- Scanned = 0;
+ Scanned = nullptr;
}
/// fouts() - This returns a reference to a formatted_raw_ostream for
diff --git a/lib/Support/GraphWriter.cpp b/lib/Support/GraphWriter.cpp
index 83aa25507f..f5b2943e86 100644
--- a/lib/Support/GraphWriter.cpp
+++ b/lib/Support/GraphWriter.cpp
@@ -83,7 +83,7 @@ static bool LLVM_ATTRIBUTE_UNUSED
ExecGraphViewer(StringRef ExecPath, std::vector<const char*> &args,
StringRef Filename, bool wait, std::string &ErrMsg) {
if (wait) {
- if (sys::ExecuteAndWait(ExecPath, &args[0],0,0,0,0,&ErrMsg)) {
+ if (sys::ExecuteAndWait(ExecPath, &args[0],nullptr,nullptr,0,0,&ErrMsg)) {
errs() << "Error: " << ErrMsg << "\n";
return false;
}
@@ -91,7 +91,7 @@ ExecGraphViewer(StringRef ExecPath, std::vector<const char*> &args,
errs() << " done. \n";
}
else {
- sys::ExecuteNoWait(ExecPath, &args[0],0,0,0,&ErrMsg);
+ sys::ExecuteNoWait(ExecPath, &args[0],nullptr,nullptr,0,&ErrMsg);
errs() << "Remember to erase graph file: " << Filename.str() << "\n";
}
return true;
@@ -108,7 +108,7 @@ void llvm::DisplayGraph(StringRef FilenameRef, bool wait,
std::vector<const char*> args;
args.push_back(Graphviz.c_str());
args.push_back(Filename.c_str());
- args.push_back(0);
+ args.push_back(nullptr);
errs() << "Running 'Graphviz' program... ";
if (!ExecGraphViewer(Graphviz, args, Filename, wait, ErrMsg))
diff --git a/lib/Support/IntervalMap.cpp b/lib/Support/IntervalMap.cpp
index 4dfcc404ca..e11a7f2eb8 100644
--- a/lib/Support/IntervalMap.cpp
+++ b/lib/Support/IntervalMap.cpp
@@ -58,7 +58,7 @@ void Path::moveLeft(unsigned Level) {
}
} else if (height() < Level)
// end() may have created a height=0 path.
- path.resize(Level + 1, Entry(0, 0, 0));
+ path.resize(Level + 1, Entry(nullptr, 0, 0));
// NR is the subtree containing our left sibling.
--path[l].offset;
diff --git a/lib/Support/LineIterator.cpp b/lib/Support/LineIterator.cpp
index 056d817526..947a8fb606 100644
--- a/lib/Support/LineIterator.cpp
+++ b/lib/Support/LineIterator.cpp
@@ -13,9 +13,10 @@
using namespace llvm;
line_iterator::line_iterator(const MemoryBuffer &Buffer, char CommentMarker)
- : Buffer(Buffer.getBufferSize() ? &Buffer : 0),
+ : Buffer(Buffer.getBufferSize() ? &Buffer : nullptr),
CommentMarker(CommentMarker), LineNumber(1),
- CurrentLine(Buffer.getBufferSize() ? Buffer.getBufferStart() : 0, 0) {
+ CurrentLine(Buffer.getBufferSize() ? Buffer.getBufferStart() : nullptr,
+ 0) {
// Ensure that if we are constructed on a non-empty memory buffer that it is
// a null terminated buffer.
if (Buffer.getBufferSize()) {
@@ -53,7 +54,7 @@ void line_iterator::advance() {
if (*Pos == '\0') {
// We've hit the end of the buffer, reset ourselves to the end state.
- Buffer = 0;
+ Buffer = nullptr;
CurrentLine = StringRef();
return;
}
diff --git a/lib/Support/LockFileManager.cpp b/lib/Support/LockFileManager.cpp
index fb07801a14..9b4bfbe819 100644
--- a/lib/Support/LockFileManager.cpp
+++ b/lib/Support/LockFileManager.cpp
@@ -196,7 +196,7 @@ LockFileManager::WaitForUnlockResult LockFileManager::waitForUnlock() {
#if LLVM_ON_WIN32
Sleep(Interval);
#else
- nanosleep(&Interval, NULL);
+ nanosleep(&Interval, nullptr);
#endif
bool LockFileJustDisappeared = false;
diff --git a/lib/Support/ManagedStatic.cpp b/lib/Support/ManagedStatic.cpp
index 098cccb68d..e358fe8c5c 100644
--- a/lib/Support/ManagedStatic.cpp
+++ b/lib/Support/ManagedStatic.cpp
@@ -17,15 +17,15 @@
#include <cassert>
using namespace llvm;
-static const ManagedStaticBase *StaticList = 0;
+static const ManagedStaticBase *StaticList = nullptr;
void ManagedStaticBase::RegisterManagedStatic(void *(*Creator)(),
void (*Deleter)(void*)) const {
if (llvm_is_multithreaded()) {
llvm_acquire_global_lock();
- if (Ptr == 0) {
- void* tmp = Creator ? Creator() : 0;
+ if (Ptr == nullptr) {
+ void* tmp = Creator ? Creator() : nullptr;
TsanHappensBefore(this);
sys::MemoryFence();
@@ -47,7 +47,7 @@ void ManagedStaticBase::RegisterManagedStatic(void *(*Creator)(),
} else {
assert(Ptr == 0 && DeleterFn == 0 && Next == 0 &&
"Partially initialized ManagedStatic!?");
- Ptr = Creator ? Creator() : 0;
+ Ptr = Creator ? Creator() : nullptr;
DeleterFn = Deleter;
// Add to list of managed statics.
@@ -62,14 +62,14 @@ void ManagedStaticBase::destroy() const {
"Not destroyed in reverse order of construction?");
// Unlink from list.
StaticList = Next;
- Next = 0;
+ Next = nullptr;
// Destroy memory.
DeleterFn(Ptr);
// Cleanup.
- Ptr = 0;
- DeleterFn = 0;
+ Ptr = nullptr;
+ DeleterFn = nullptr;
}
/// llvm_shutdown - Deallocate and destroy all ManagedStatic variables.
diff --git a/lib/Support/MemoryBuffer.cpp b/lib/Support/MemoryBuffer.cpp
index 2d593a8f41..773ccfd6f7 100644
--- a/lib/Support/MemoryBuffer.cpp
+++ b/lib/Support/MemoryBuffer.cpp
@@ -117,7 +117,7 @@ MemoryBuffer *MemoryBuffer::getMemBuffer(StringRef InputData,
MemoryBuffer *MemoryBuffer::getMemBufferCopy(StringRef InputData,
StringRef BufferName) {
MemoryBuffer *Buf = getNewUninitMemBuffer(InputData.size(), BufferName);
- if (!Buf) return 0;
+ if (!Buf) return nullptr;
memcpy(const_cast<char*>(Buf->getBufferStart()), InputData.data(),
InputData.size());
return Buf;
@@ -137,7 +137,7 @@ MemoryBuffer *MemoryBuffer::getNewUninitMemBuffer(size_t Size,
RoundUpToAlignment(sizeof(MemoryBufferMem) + BufferName.size() + 1, 16);
size_t RealLen = AlignedStringLen + Size + 1;
char *Mem = static_cast<char*>(operator new(RealLen, std::nothrow));
- if (!Mem) return 0;
+ if (!Mem) return nullptr;
// The name is stored after the class itself.
CopyStringRef(Mem + sizeof(MemoryBufferMem), BufferName);
@@ -155,7 +155,7 @@ MemoryBuffer *MemoryBuffer::getNewUninitMemBuffer(size_t Size,
/// the MemoryBuffer object.
MemoryBuffer *MemoryBuffer::getNewMemBuffer(size_t Size, StringRef BufferName) {
MemoryBuffer *SB = getNewUninitMemBuffer(Size, BufferName);
- if (!SB) return 0;
+ if (!SB) return nullptr;
memset(const_cast<char*>(SB->getBufferStart()), 0, Size);
return SB;
}
diff --git a/lib/Support/Mutex.cpp b/lib/Support/Mutex.cpp
index 37c9d73dae..292d32a2fb 100644
--- a/lib/Support/Mutex.cpp
+++ b/lib/Support/Mutex.cpp
@@ -42,7 +42,7 @@ using namespace sys;
// Construct a Mutex using pthread calls
MutexImpl::MutexImpl( bool recursive)
- : data_(0)
+ : data_(nullptr)
{
// Declare the pthread_mutex data structures
pthread_mutex_t* mutex =
diff --git a/lib/Support/Path.cpp b/lib/Support/Path.cpp
index 5b73631d98..d345829d4d 100644
--- a/lib/Support/Path.cpp
+++ b/lib/Support/Path.cpp
@@ -577,7 +577,7 @@ void system_temp_directory(bool erasedOnReboot, SmallVectorImpl<char> &result) {
// macros defined in <unistd.h> on darwin >= 9
int ConfName = erasedOnReboot? _CS_DARWIN_USER_TEMP_DIR
: _CS_DARWIN_USER_CACHE_DIR;
- size_t ConfLen = confstr(ConfName, 0, 0);
+ size_t ConfLen = confstr(ConfName, nullptr, 0);
if (ConfLen > 0) {
do {
result.resize(ConfLen);
diff --git a/lib/Support/PrettyStackTrace.cpp b/lib/Support/PrettyStackTrace.cpp
index d4e205cdb3..aef02e990a 100644
--- a/lib/Support/PrettyStackTrace.cpp
+++ b/lib/Support/PrettyStackTrace.cpp
@@ -46,7 +46,7 @@ static unsigned PrintStack(const PrettyStackTraceEntry *Entry, raw_ostream &OS){
/// PrintCurStackTrace - Print the current stack trace to the specified stream.
static void PrintCurStackTrace(raw_ostream &OS) {
// Don't print an empty trace.
- if (PrettyStackTraceHead->get() == 0) return;
+ if (PrettyStackTraceHead->get() == nullptr) return;
// If there are pretty stack frames registered, walk and emit them.
OS << "Stack dump:\n";
@@ -136,7 +136,7 @@ void PrettyStackTraceProgram::print(raw_ostream &OS) const {
}
static bool RegisterCrashPrinter() {
- sys::AddSignalHandler(CrashHandler, 0);
+ sys::AddSignalHandler(CrashHandler, nullptr);
return false;
}
diff --git a/lib/Support/RWMutex.cpp b/lib/Support/RWMutex.cpp
index 6a34f2d085..f42be5af50 100644
--- a/lib/Support/RWMutex.cpp
+++ b/lib/Support/RWMutex.cpp
@@ -44,7 +44,7 @@ using namespace sys;
// Construct a RWMutex using pthread calls
RWMutexImpl::RWMutexImpl()
- : data_(0)
+ : data_(nullptr)
{
// Declare the pthread_rwlock data structures
pthread_rwlock_t* rwlock =
@@ -56,7 +56,7 @@ RWMutexImpl::RWMutexImpl()
#endif
// Initialize the rwlock
- int errorcode = pthread_rwlock_init(rwlock, NULL);
+ int errorcode = pthread_rwlock_init(rwlock, nullptr);
(void)errorcode;
assert(errorcode == 0);
diff --git a/lib/Support/Regex.cpp b/lib/Support/Regex.cpp
index 1115534427..f7fe1e4c79 100644
--- a/lib/Support/Regex.cpp
+++ b/lib/Support/Regex.cpp
@@ -43,7 +43,7 @@ bool Regex::isValid(std::string &Error) {
if (!error)
return true;
- size_t len = llvm_regerror(error, preg, NULL, 0);
+ size_t len = llvm_regerror(error, preg, nullptr, 0);
Error.resize(len - 1);
llvm_regerror(error, preg, &Error[0], len);
diff --git a/lib/Support/SearchForAddressOfSpecialSymbol.cpp b/lib/Support/SearchForAddressOfSpecialSymbol.cpp
index 2d23902bb8..55f3320f64 100644
--- a/lib/Support/SearchForAddressOfSpecialSymbol.cpp
+++ b/lib/Support/SearchForAddressOfSpecialSymbol.cpp
@@ -48,7 +48,7 @@ static void *DoSearch(const char* symbolName) {
#endif
#undef EXPLICIT_SYMBOL
- return 0;
+ return nullptr;
}
namespace llvm {
diff --git a/lib/Support/SmallPtrSet.cpp b/lib/Support/SmallPtrSet.cpp
index 844e41696f..a80e095ec3 100644
--- a/lib/Support/SmallPtrSet.cpp
+++ b/lib/Support/SmallPtrSet.cpp
@@ -103,7 +103,7 @@ const void * const *SmallPtrSetImplBase::FindBucketFor(const void *Ptr) const {
unsigned ArraySize = CurArraySize;
unsigned ProbeAmt = 1;
const void *const *Array = CurArray;
- const void *const *Tombstone = 0;
+ const void *const *Tombstone = nullptr;
while (1) {
// Found Ptr's bucket?
if (Array[Bucket] == Ptr)
diff --git a/lib/Support/SourceMgr.cpp b/lib/Support/SourceMgr.cpp
index 4bfd96abe5..4aa6ff7d31 100644
--- a/lib/Support/SourceMgr.cpp
+++ b/lib/Support/SourceMgr.cpp
@@ -114,7 +114,7 @@ SourceMgr::getLineAndColumn(SMLoc Loc, int BufferID) const {
if (*Ptr == '\n') ++LineNo;
// Allocate the line number cache if it doesn't exist.
- if (LineNoCache == 0)
+ if (LineNoCache == nullptr)
LineNoCache = new LineNoCacheTy();
// Update the line # cache.
@@ -228,7 +228,7 @@ void SourceMgr::PrintMessage(raw_ostream &OS, SMLoc Loc,
PrintIncludeStack(getBufferInfo(CurBuf).IncludeLoc, OS);
}
- Diagnostic.print(0, OS, ShowColors);
+ Diagnostic.print(nullptr, OS, ShowColors);
}
void SourceMgr::PrintMessage(SMLoc Loc, SourceMgr::DiagKind Kind,
diff --git a/lib/Support/StringMap.cpp b/lib/Support/StringMap.cpp
index 9ac1f867fd..30b6abb3b4 100644
--- a/lib/Support/StringMap.cpp
+++ b/lib/Support/StringMap.cpp
@@ -27,7 +27,7 @@ StringMapImpl::StringMapImpl(unsigned InitSize, unsigned itemSize) {
}
// Otherwise, initialize it with zero buckets to avoid the allocation.
- TheTable = 0;
+ TheTable = nullptr;
NumBuckets = 0;
NumItems = 0;
NumTombstones = 0;
@@ -70,7 +70,7 @@ unsigned StringMapImpl::LookupBucketFor(StringRef Name) {
while (1) {
StringMapEntryBase *BucketItem = TheTable[BucketNo];
// If we found an empty bucket, this key isn't in the table yet, return it.
- if (LLVM_LIKELY(BucketItem == 0)) {
+ if (LLVM_LIKELY(BucketItem == nullptr)) {
// If we found a tombstone, we want to reuse the tombstone instead of an
// empty bucket. This reduces probing.
if (FirstTombstone != -1) {
@@ -124,7 +124,7 @@ int StringMapImpl::FindKey(StringRef Key) const {
while (1) {
StringMapEntryBase *BucketItem = TheTable[BucketNo];
// If we found an empty bucket, this key isn't in the table yet, return.
- if (LLVM_LIKELY(BucketItem == 0))
+ if (LLVM_LIKELY(BucketItem == nullptr))
return -1;
if (BucketItem == getTombstoneVal()) {
@@ -166,7 +166,7 @@ void StringMapImpl::RemoveKey(StringMapEntryBase *V) {
/// table, returning it. If the key is not in the table, this returns null.
StringMapEntryBase *StringMapImpl::RemoveKey(StringRef Key) {
int Bucket = FindKey(Key);
- if (Bucket == -1) return 0;
+ if (Bucket == -1) return nullptr;
StringMapEntryBase *Result = TheTable[Bucket];
TheTable[Bucket] = getTombstoneVal();
@@ -212,7 +212,7 @@ void StringMapImpl::RehashTable() {
// Fast case, bucket available.
unsigned FullHash = HashTable[I];
unsigned NewBucket = FullHash & (NewSize-1);
- if (NewTableArray[NewBucket] == 0) {
+ if (NewTableArray[NewBucket] == nullptr) {
NewTableArray[FullHash & (NewSize-1)] = Bucket;
NewHashArray[FullHash & (NewSize-1)] = FullHash;
continue;
diff --git a/lib/Support/StringRef.cpp b/lib/Support/StringRef.cpp
index bd2a37bb5e..cde8258dec 100644
--- a/lib/Support/StringRef.cpp
+++ b/lib/Support/StringRef.cpp
@@ -281,7 +281,7 @@ void StringRef::split(SmallVectorImpl<StringRef> &A,
// rest.data() is used to distinguish cases like "a," that splits into
// "a" + "" and "a" that splits into "a" + 0.
for (int splits = 0;
- rest.data() != NULL && (MaxSplit < 0 || splits < MaxSplit);
+ rest.data() != nullptr && (MaxSplit < 0 || splits < MaxSplit);
++splits) {
std::pair<StringRef, StringRef> p = rest.split(Separators);
@@ -290,7 +290,7 @@ void StringRef::split(SmallVectorImpl<StringRef> &A,
rest = p.second;
}
// If we have a tail left, add it.
- if (rest.data() != NULL && (rest.size() != 0 || KeepEmpty))
+ if (rest.data() != nullptr && (rest.size() != 0 || KeepEmpty))
A.push_back(rest);
}
diff --git a/lib/Support/TargetRegistry.cpp b/lib/Support/TargetRegistry.cpp
index 8d91a53c22..5b0e4a30a9 100644
--- a/lib/Support/TargetRegistry.cpp
+++ b/lib/Support/TargetRegistry.cpp
@@ -17,7 +17,7 @@
using namespace llvm;
// Clients are responsible for avoid race conditions in registration.
-static Target *FirstTarget = 0;
+static Target *FirstTarget = nullptr;
TargetRegistry::iterator TargetRegistry::begin() {
return iterator(FirstTarget);
@@ -29,7 +29,7 @@ const Target *TargetRegistry::lookupTarget(const std::string &ArchName,
// Allocate target machine. First, check whether the user has explicitly
// specified an architecture to compile for. If so we have to look it up by
// name, because it might be a backend that has no mapping to a target triple.
- const Target *TheTarget = 0;
+ const Target *TheTarget = nullptr;
if (!ArchName.empty()) {
for (TargetRegistry::iterator it = TargetRegistry::begin(),
ie = TargetRegistry::end(); it != ie; ++it) {
@@ -41,7 +41,7 @@ const Target *TargetRegistry::lookupTarget(const std::string &ArchName,
if (!TheTarget) {
Error = "error: invalid target '" + ArchName + "'.\n";
- return 0;
+ return nullptr;
}
// Adjust the triple to match (if known), otherwise stick with the
@@ -53,11 +53,11 @@ const Target *TargetRegistry::lookupTarget(const std::string &ArchName,
// Get the target specific parser.
std::string TempError;
TheTarget = TargetRegistry::lookupTarget(TheTriple.getTriple(), TempError);
- if (TheTarget == 0) {
+ if (TheTarget == nullptr) {
Error = ": error: unable to get target for '"
+ TheTriple.getTriple()
+ "', see --version and --triple.\n";
- return 0;
+ return nullptr;
}
}
@@ -69,16 +69,16 @@ const Target *TargetRegistry::lookupTarget(const std::string &TT,
// Provide special warning when no targets are initialized.
if (begin() == end()) {
Error = "Unable to find target for this triple (no targets are registered)";
- return 0;
+ return nullptr;
}
- const Target *Matching = 0;
+ const Target *Matching = nullptr;
Triple::ArchType Arch = Triple(TT).getArch();
for (iterator it = begin(), ie = end(); it != ie; ++it) {
if (it->ArchMatchFn(Arch)) {
if (Matching) {
Error = std::string("Cannot choose between targets \"") +
Matching->Name + "\" and \"" + it->Name + "\"";
- return 0;
+ return nullptr;
}
Matching = &*it;
}
@@ -87,7 +87,7 @@ const Target *TargetRegistry::lookupTarget(const std::string &TT,
if (!Matching) {
Error = "No available targets are compatible with this triple, "
"see -version for the available targets.";
- return 0;
+ return nullptr;
}
return Matching;
@@ -121,7 +121,7 @@ const Target *TargetRegistry::getClosestTargetForJIT(std::string &Error) {
if (TheTarget && !TheTarget->hasJIT()) {
Error = "No JIT compatible target available for this host";
- return 0;
+ return nullptr;
}
return TheTarget;
diff --git a/lib/Support/ThreadLocal.cpp b/lib/Support/ThreadLocal.cpp
index aebbcad25c..2dec9eb417 100644
--- a/lib/Support/ThreadLocal.cpp
+++ b/lib/Support/ThreadLocal.cpp
@@ -53,7 +53,7 @@ using namespace sys;
ThreadLocalImpl::ThreadLocalImpl() : data() {
static_assert(sizeof(pthread_key_t) <= sizeof(data), "size too big");
pthread_key_t* key = reinterpret_cast<pthread_key_t*>(&data);
- int errorcode = pthread_key_create(key, NULL);
+ int errorcode = pthread_key_create(key, nullptr);
assert(errorcode == 0);
(void) errorcode;
}
@@ -78,7 +78,7 @@ const void* ThreadLocalImpl::getInstance() {
}
void ThreadLocalImpl::removeInstance() {
- setInstance(0);
+ setInstance(nullptr);
}
}
diff --git a/lib/Support/Threading.cpp b/lib/Support/Threading.cpp
index 9d7ac6c18d..1acfa79b11 100644
--- a/lib/Support/Threading.cpp
+++ b/lib/Support/Threading.cpp
@@ -21,7 +21,7 @@ using namespace llvm;
static bool multithreaded_mode = false;
-static sys::Mutex* global_lock = 0;
+static sys::Mutex* global_lock = nullptr;
bool llvm::llvm_start_multithreaded() {
#if LLVM_ENABLE_THREADS != 0
@@ -73,7 +73,7 @@ struct ThreadInfo {
static void *ExecuteOnThread_Dispatch(void *Arg) {
ThreadInfo *TI = reinterpret_cast<ThreadInfo*>(Arg);
TI->UserFn(TI->UserData);
- return 0;
+ return nullptr;
}
void llvm::llvm_execute_on_thread(void (*Fn)(void*), void *UserData,
@@ -97,7 +97,7 @@ void llvm::llvm_execute_on_thread(void (*Fn)(void*), void *UserData,
goto error;
// Wait for the thread and clean up.
- ::pthread_join(Thread, 0);
+ ::pthread_join(Thread, nullptr);
error:
::pthread_attr_destroy(&Attr);
diff --git a/lib/Support/Timer.cpp b/lib/Support/Timer.cpp
index 7cf4d372a5..c2ce90c858 100644
--- a/lib/Support/Timer.cpp
+++ b/lib/Support/Timer.cpp
@@ -77,7 +77,7 @@ raw_ostream *llvm::CreateInfoOutputFile() {
}
-static TimerGroup *DefaultTimerGroup = 0;
+static TimerGroup *DefaultTimerGroup = nullptr;
static TimerGroup *getDefaultTimerGroup() {
TimerGroup *tmp = DefaultTimerGroup;
sys::MemoryFence();
@@ -235,11 +235,11 @@ static Timer &getNamedRegionTimer(StringRef Name) {
NamedRegionTimer::NamedRegionTimer(StringRef Name,
bool Enabled)
- : TimeRegion(!Enabled ? 0 : &getNamedRegionTimer(Name)) {}
+ : TimeRegion(!Enabled ? nullptr : &getNamedRegionTimer(Name)) {}
NamedRegionTimer::NamedRegionTimer(StringRef Name, StringRef GroupName,
bool Enabled)
- : TimeRegion(!Enabled ? 0 : &NamedGroupedTimers->get(Name, GroupName)) {}
+ : TimeRegion(!Enabled ? nullptr : &NamedGroupedTimers->get(Name, GroupName)){}
//===----------------------------------------------------------------------===//
// TimerGroup Implementation
@@ -247,10 +247,10 @@ NamedRegionTimer::NamedRegionTimer(StringRef Name, StringRef GroupName,
/// TimerGroupList - This is the global list of TimerGroups, maintained by the
/// TimerGroup ctor/dtor and is protected by the TimerLock lock.
-static TimerGroup *TimerGroupList = 0;
+static TimerGroup *TimerGroupList = nullptr;
TimerGroup::TimerGroup(StringRef name)
- : Name(name.begin(), name.end()), FirstTimer(0) {
+ : Name(name.begin(), name.end()), FirstTimer(nullptr) {
// Add the group to TimerGroupList.
sys::SmartScopedLock<true> L(*TimerLock);
@@ -264,7 +264,7 @@ TimerGroup::TimerGroup(StringRef name)
TimerGroup::~TimerGroup() {
// If the timer group is destroyed before the timers it owns, accumulate and
// print the timing data.
- while (FirstTimer != 0)
+ while (FirstTimer != nullptr)
removeTimer(*FirstTimer);
// Remove the group from the TimerGroupList.
@@ -282,7 +282,7 @@ void TimerGroup::removeTimer(Timer &T) {
if (T.Started)
TimersToPrint.push_back(std::make_pair(T.Time, T.Name));
- T.TG = 0;
+ T.TG = nullptr;
// Unlink the timer from our list.
*T.Prev = T.Next;
@@ -291,7 +291,7 @@ void TimerGroup::removeTimer(Timer &T) {
// Print the report when all timers in this group are destroyed if some of
// them were started.
- if (FirstTimer != 0 || TimersToPrint.empty())
+ if (FirstTimer != nullptr || TimersToPrint.empty())
return;
raw_ostream *OutStream = CreateInfoOutputFile();
diff --git a/lib/Support/Triple.cpp b/lib/Support/Triple.cpp
index 71abb9d165..e65d02b52f 100644
--- a/lib/Support/Triple.cpp
+++ b/lib/Support/Triple.cpp
@@ -57,7 +57,7 @@ const char *Triple::getArchTypeName(ArchType Kind) {
const char *Triple::getArchTypePrefix(ArchType Kind) {
switch (Kind) {
default:
- return 0;
+ return nullptr;
case aarch64:
case aarch64_be: return "aarch64";
@@ -210,7 +210,7 @@ Triple::ArchType Triple::getArchTypeForLLVMName(StringRef Name) {
// Returns architecture name that is understood by the target assembler.
const char *Triple::getArchNameForAssembler() {
if (!isOSDarwin() && getVendor() != Triple::Apple)
- return NULL;
+ return nullptr;
return StringSwitch<const char*>(getArchName())
.Case("i386", "i386")
@@ -232,7 +232,7 @@ const char *Triple::getArchNameForAssembler() {
.Case("amdil", "amdil")
.Case("spir", "spir")
.Case("spir64", "spir64")
- .Default(NULL);
+ .Default(nullptr);
}
static Triple::ArchType parseArch(StringRef ArchName) {
diff --git a/lib/Support/YAMLParser.cpp b/lib/Support/YAMLParser.cpp
index 73ce5e009b..573bb47868 100644
--- a/lib/Support/YAMLParser.cpp
+++ b/lib/Support/YAMLParser.cpp
@@ -1876,14 +1876,14 @@ Node *KeyValueNode::getValue() {
void MappingNode::increment() {
if (failed()) {
IsAtEnd = true;
- CurrentEntry = 0;
+ CurrentEntry = nullptr;
return;
}
if (CurrentEntry) {
CurrentEntry->skip();
if (Type == MT_Inline) {
IsAtEnd = true;
- CurrentEntry = 0;
+ CurrentEntry = nullptr;
return;
}
}
@@ -1896,13 +1896,13 @@ void MappingNode::increment() {
case Token::TK_BlockEnd:
getNext();
IsAtEnd = true;
- CurrentEntry = 0;
+ CurrentEntry = nullptr;
break;
default:
setError("Unexpected token. Expected Key or Block End", T);
case Token::TK_Error:
IsAtEnd = true;
- CurrentEntry = 0;
+ CurrentEntry = nullptr;
}
} else {
switch (T.Kind) {
@@ -1915,14 +1915,14 @@ void MappingNode::increment() {
case Token::TK_Error:
// Set this to end iterator.
IsAtEnd = true;
- CurrentEntry = 0;
+ CurrentEntry = nullptr;
break;
default:
setError( "Unexpected token. Expected Key, Flow Entry, or Flow "
"Mapping End."
, T);
IsAtEnd = true;
- CurrentEntry = 0;
+ CurrentEntry = nullptr;
}
}
}
@@ -1930,7 +1930,7 @@ void MappingNode::increment() {
void SequenceNode::increment() {
if (failed()) {
IsAtEnd = true;
- CurrentEntry = 0;
+ CurrentEntry = nullptr;
return;
}
if (CurrentEntry)
@@ -1941,37 +1941,37 @@ void SequenceNode::increment() {
case Token::TK_BlockEntry:
getNext();
CurrentEntry = parseBlockNode();
- if (CurrentEntry == 0) { // An error occurred.
+ if (CurrentEntry == nullptr) { // An error occurred.
IsAtEnd = true;
- CurrentEntry = 0;
+ CurrentEntry = nullptr;
}
break;
case Token::TK_BlockEnd:
getNext();
IsAtEnd = true;
- CurrentEntry = 0;
+ CurrentEntry = nullptr;
break;
default:
setError( "Unexpected token. Expected Block Entry or Block End."
, T);
case Token::TK_Error:
IsAtEnd = true;
- CurrentEntry = 0;
+ CurrentEntry = nullptr;
}
} else if (SeqType == ST_Indentless) {
switch (T.Kind) {
case Token::TK_BlockEntry:
getNext();
CurrentEntry = parseBlockNode();
- if (CurrentEntry == 0) { // An error occurred.
+ if (CurrentEntry == nullptr) { // An error occurred.
IsAtEnd = true;
- CurrentEntry = 0;
+ CurrentEntry = nullptr;
}
break;
default:
case Token::TK_Error:
IsAtEnd = true;
- CurrentEntry = 0;
+ CurrentEntry = nullptr;
}
} else if (SeqType == ST_Flow) {
switch (T.Kind) {
@@ -1985,7 +1985,7 @@ void SequenceNode::increment() {
case Token::TK_Error:
// Set this to end iterator.
IsAtEnd = true;
- CurrentEntry = 0;
+ CurrentEntry = nullptr;
break;
case Token::TK_StreamEnd:
case Token::TK_DocumentEnd:
@@ -1993,13 +1993,13 @@ void SequenceNode::increment() {
setError("Could not find closing ]!", T);
// Set this to end iterator.
IsAtEnd = true;
- CurrentEntry = 0;
+ CurrentEntry = nullptr;
break;
default:
if (!WasPreviousTokenFlowEntry) {
setError("Expected , between entries!", T);
IsAtEnd = true;
- CurrentEntry = 0;
+ CurrentEntry = nullptr;
break;
}
// Otherwise it must be a flow entry.
@@ -2013,7 +2013,7 @@ void SequenceNode::increment() {
}
}
-Document::Document(Stream &S) : stream(S), Root(0) {
+Document::Document(Stream &S) : stream(S), Root(nullptr) {
// Tag maps starts with two default mappings.
TagMap["!"] = "!";
TagMap["!!"] = "tag:yaml.org,2002:";
@@ -2070,7 +2070,7 @@ parse_property:
case Token::TK_Anchor:
if (AnchorInfo.Kind == Token::TK_Anchor) {
setError("Already encountered an anchor for this node!", T);
- return 0;
+ return nullptr;
}
AnchorInfo = getNext(); // Consume TK_Anchor.
T = peekNext();
@@ -2078,7 +2078,7 @@ parse_property:
case Token::TK_Tag:
if (TagInfo.Kind == Token::TK_Tag) {
setError("Already encountered a tag for this node!", T);
- return 0;
+ return nullptr;
}
TagInfo = getNext(); // Consume TK_Tag.
T = peekNext();
@@ -2146,10 +2146,10 @@ parse_property:
// !!null null.
return new (NodeAllocator) NullNode(stream.CurrentDoc);
case Token::TK_Error:
- return 0;
+ return nullptr;
}
llvm_unreachable("Control flow shouldn't reach here.");
- return 0;
+ return nullptr;
}
bool Document::parseDirectives() {
diff --git a/lib/Support/YAMLTraits.cpp b/lib/Support/YAMLTraits.cpp
index 5472e0e1dd..38f3ec7c7f 100644
--- a/lib/Support/YAMLTraits.cpp
+++ b/lib/Support/YAMLTraits.cpp
@@ -47,7 +47,7 @@ Input::Input(StringRef InputContent,
void *DiagHandlerCtxt)
: IO(Ctxt),
Strm(new Stream(InputContent, SrcMgr)),
- CurrentNode(NULL) {
+ CurrentNode(nullptr) {
if (DiagHandler)
SrcMgr.setDiagHandler(DiagHandler, DiagHandlerCtxt);
DocIterator = Strm->begin();
@@ -351,7 +351,7 @@ Input::HNode *Input::createHNodes(Node *N) {
return new EmptyHNode(N);
} else {
setError(N, "unknown node kind");
- return NULL;
+ return nullptr;
}
}