APInt fill(64, type);
return getQNaN(Sem, Negative, &fill);
} else {
- return getQNaN(Sem, Negative, 0);
+ return getQNaN(Sem, Negative, nullptr);
}
}
/// Factory for QNaN values.
static APFloat getQNaN(const fltSemantics &Sem, bool Negative = false,
- const APInt *payload = 0) {
+ const APInt *payload = nullptr) {
return makeNaN(Sem, false, Negative, payload);
}
/// Factory for SNaN values.
static APFloat getSNaN(const fltSemantics &Sem, bool Negative = false,
- const APInt *payload = 0) {
+ const APInt *payload = nullptr) {
return makeNaN(Sem, true, Negative, payload);
}
void makeLargest(bool Neg = false);
void makeSmallest(bool Neg = false);
- void makeNaN(bool SNaN = false, bool Neg = false, const APInt *fill = 0);
+ void makeNaN(bool SNaN = false, bool Neg = false,
+ const APInt *fill = nullptr);
static APFloat makeNaN(const fltSemantics &Sem, bool SNaN, bool Negative,
const APInt *fill);
void makeInf(bool Neg = false);
/*implicit*/ ArrayRef() : Data(0), Length(0) {}
/// Construct an empty ArrayRef from None.
- /*implicit*/ ArrayRef(NoneType) : Data(0), Length(0) {}
+ /*implicit*/ ArrayRef(NoneType) : Data(nullptr), Length(0) {}
/// Construct an ArrayRef from a single element.
/*implicit*/ ArrayRef(const T &OneElt)
const unsigned NumBuckets = getNumBuckets();
if (NumBuckets == 0) {
- FoundBucket = 0;
+ FoundBucket = nullptr;
return false;
}
// FoundTombstone - Keep track of whether we find a tombstone while probing.
- const BucketT *FoundTombstone = 0;
+ const BucketT *FoundTombstone = nullptr;
const KeyT EmptyKey = getEmptyKey();
const KeyT TombstoneKey = getTombstoneKey();
assert(!KeyInfoT::isEqual(Val, EmptyKey) &&
bool allocateBuckets(unsigned Num) {
NumBuckets = Num;
if (NumBuckets == 0) {
- Buckets = 0;
+ Buckets = nullptr;
return false;
}
public:
- Node() : NextInFoldingSetBucket(0) {}
+ Node() : NextInFoldingSetBucket(nullptr) {}
// Accessors
void *getNextInBucket() const { return NextInFoldingSetBucket; }
const unsigned *Data;
size_t Size;
public:
- FoldingSetNodeIDRef() : Data(0), Size(0) {}
+ FoldingSetNodeIDRef() : Data(nullptr), Size(0) {}
FoldingSetNodeIDRef(const unsigned *D, size_t S) : Data(D), Size(S) {}
/// ComputeHash - Compute a strong hash value for this FoldingSetNodeIDRef,
public:
typedef T element_type;
- explicit IntrusiveRefCntPtr() : Obj(0) {}
+ explicit IntrusiveRefCntPtr() : Obj(nullptr) {}
IntrusiveRefCntPtr(T* obj) : Obj(obj) {
retain();
}
IntrusiveRefCntPtr(IntrusiveRefCntPtr&& S) : Obj(S.Obj) {
- S.Obj = 0;
+ S.Obj = nullptr;
}
template <class X>
typedef T* (IntrusiveRefCntPtr::*unspecified_bool_type) () const;
operator unspecified_bool_type() const {
- return Obj == 0 ? 0 : &IntrusiveRefCntPtr::getPtr;
+ return Obj == nullptr ? nullptr : &IntrusiveRefCntPtr::getPtr;
}
void swap(IntrusiveRefCntPtr& other) {
void reset() {
release();
- Obj = 0;
+ Obj = nullptr;
}
void resetWithoutRelease() {
protected:
explicit StringMapImpl(unsigned itemSize) : ItemSize(itemSize) {
// Initialize the map with zero buckets to allocation.
- TheTable = 0;
+ TheTable = nullptr;
NumBuckets = 0;
NumItems = 0;
NumTombstones = 0;
if (Bucket && Bucket != getTombstoneVal()) {
static_cast<MapEntryTy*>(Bucket)->Destroy(Allocator);
}
- Bucket = 0;
+ Bucket = nullptr;
}
NumItems = 0;
public:
typedef StringMapEntry<ValueTy> value_type;
- StringMapConstIterator() : Ptr(0) { }
+ StringMapConstIterator() : Ptr(nullptr) { }
explicit StringMapConstIterator(StringMapEntryBase **Bucket,
bool NoAdvance = false)
private:
void AdvancePastEmptyBuckets() {
- while (*Ptr == 0 || *Ptr == StringMapImpl::getTombstoneVal())
+ while (*Ptr == nullptr || *Ptr == StringMapImpl::getTombstoneVal())
++Ptr;
}
};
/// @{
/// Construct an empty string ref.
- /*implicit*/ StringRef() : Data(0), Length(0) {}
+ /*implicit*/ StringRef() : Data(nullptr), Length(0) {}
/// Construct a string ref from a cstring.
/*implicit*/ StringRef(const char *Str)
/// str - Get the contents as an std::string.
std::string str() const {
- if (Data == 0) return std::string();
+ if (Data == nullptr) return std::string();
return std::string(Data, Length);
}
public:
explicit StringSwitch(StringRef S)
- : Str(S), Result(0) { }
+ : Str(S), Result(nullptr) { }
template<unsigned N>
StringSwitch& Case(const char (&S)[N], const T& Value) {
static Twine utohexstr(const uint64_t &Val) {
Child LHS, RHS;
LHS.uHex = &Val;
- RHS.twine = 0;
+ RHS.twine = nullptr;
return Twine(LHS, UHexKind, RHS, EmptyKind);
}
ilist_iterator(pointer NP) : NodePtr(NP) {}
ilist_iterator(reference NR) : NodePtr(&NR) {}
- ilist_iterator() : NodePtr(0) {}
+ ilist_iterator() : NodePtr(nullptr) {}
// This is templated so that we can allow constructing a const iterator from
// a nonconst iterator...
// Miscellaneous inspection routines.
size_type max_size() const { return size_type(-1); }
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const {
- return Head == 0 || Head == getTail();
+ return Head == nullptr || Head == getTail();
}
// Front and back accessor functions...
// an ilist (and potentially deleted) with iterators still pointing at it.
// When those iterators are incremented or decremented, they will assert on
// the null next/prev pointer instead of "usually working".
- this->setNext(Node, 0);
- this->setPrev(Node, 0);
+ this->setNext(Node, nullptr);
+ this->setPrev(Node, nullptr);
return Node;
}
NodeTy *getPrev() { return Prev; }
const NodeTy *getPrev() const { return Prev; }
void setPrev(NodeTy *P) { Prev = P; }
- ilist_half_node() : Prev(0) {}
+ ilist_half_node() : Prev(nullptr) {}
};
template<typename NodeTy>
const NodeTy *getNext() const { return Next; }
void setNext(NodeTy *N) { Next = N; }
protected:
- ilist_node() : Next(0) {}
+ ilist_node() : Next(nullptr) {}
public:
/// @name Adjacent Node Accessors
/// Used so that we can compute how much space was wasted.
size_t BytesAllocated;
- BumpPtrAllocatorBase() : CurSlab(0), BytesAllocated(0) {}
+ BumpPtrAllocatorBase() : CurSlab(nullptr), BytesAllocated(0) {}
};
/// \brief Allocate memory in an ever growing pool, as if by bump-pointer.
if (!CurSlab)
return;
DeallocateSlabs(CurSlab->NextPtr);
- CurSlab->NextPtr = 0;
+ CurSlab->NextPtr = nullptr;
CurPtr = (char *)(CurSlab + 1);
End = ((char *)CurSlab) + CurSlab->Size;
BytesAllocated = 0;
template <class X, class Y>
LLVM_ATTRIBUTE_UNUSED_RESULT inline typename cast_retty<X, Y *>::ret_type
dyn_cast(Y *Val) {
- return isa<X>(Val) ? cast<X>(Val) : 0;
+ return isa<X>(Val) ? cast<X>(Val) : nullptr;
}
// dyn_cast_or_null<X> - Functionally identical to dyn_cast, except that a null
template <class X, class Y>
LLVM_ATTRIBUTE_UNUSED_RESULT inline typename cast_retty<X, Y *>::ret_type
dyn_cast_or_null(Y *Val) {
- return (Val && isa<X>(Val)) ? cast<X>(Val) : 0;
+ return (Val && isa<X>(Val)) ? cast<X>(Val) : nullptr;
}
} // End llvm namespace
// ParseCommandLineOptions - Command line option processing entry point.
//
void ParseCommandLineOptions(int argc, const char * const *argv,
- const char *Overview = 0);
+ const char *Overview = nullptr);
//===----------------------------------------------------------------------===//
// ParseEnvironmentOptions - Environment variable option processing alternate
// entry point.
//
void ParseEnvironmentOptions(const char *progName, const char *envvar,
- const char *Overview = 0);
+ const char *Overview = nullptr);
///===---------------------------------------------------------------------===//
/// SetVersionPrinter - Override the default (LLVM specific) version printer
const char *const Description;
void registerCategory();
public:
- OptionCategory(const char *const Name, const char *const Description = 0)
+ OptionCategory(const char *const Name, const char *const Description = nullptr)
: Name(Name), Description(Description) { registerCategory(); }
const char *getName() const { return Name; }
const char *getDescription() const { return Description; }
enum OptionHidden Hidden)
: NumOccurrences(0), Occurrences(OccurrencesFlag), Value(0),
HiddenFlag(Hidden), Formatting(NormalFormatting), Misc(0),
- Position(0), AdditionalVals(0), NextRegistered(0),
+ Position(0), AdditionalVals(0), NextRegistered(nullptr),
ArgStr(""), HelpStr(""), ValueStr(""), Category(&GeneralCategory) {
}
}
// getValueName - Do not print =<value> at all.
- const char *getValueName() const override { return 0; }
+ const char *getValueName() const override { return nullptr; }
void printOptionDiff(const Option &O, bool V, OptVal Default,
size_t GlobalWidth) const;
}
// getValueName - Do not print =<value> at all.
- const char *getValueName() const override { return 0; }
+ const char *getValueName() const override { return nullptr; }
void printOptionDiff(const Option &O, boolOrDefault V, OptVal Default,
size_t GlobalWidth) const;
"or cl::init specified before cl::location()!!");
}
public:
- opt_storage() : Location(0) {}
+ opt_storage() : Location(nullptr) {}
bool setLocation(Option &O, DataType &L) {
if (Location)
}
public:
- bits_storage() : Location(0) {}
+ bits_storage() : Location(nullptr) {}
bool setLocation(Option &O, unsigned &L) {
if (Location)
void done() {
if (!hasArgStr())
error("cl::alias must have argument name specified!");
- if (AliasFor == 0)
+ if (AliasFor == nullptr)
error("cl::alias must have an cl::aliasopt(option) specified!");
addArgument();
}
// One option...
template<class M0t>
- explicit alias(const M0t &M0) : Option(Optional, Hidden), AliasFor(0) {
+ explicit alias(const M0t &M0) : Option(Optional, Hidden), AliasFor(nullptr) {
apply(M0, this);
done();
}
// Two options...
template<class M0t, class M1t>
- alias(const M0t &M0, const M1t &M1) : Option(Optional, Hidden), AliasFor(0) {
+ alias(const M0t &M0, const M1t &M1)
+ : Option(Optional, Hidden), AliasFor(nullptr) {
apply(M0, this); apply(M1, this);
done();
}
// Three options...
template<class M0t, class M1t, class M2t>
alias(const M0t &M0, const M1t &M1, const M2t &M2)
- : Option(Optional, Hidden), AliasFor(0) {
+ : Option(Optional, Hidden), AliasFor(nullptr) {
apply(M0, this); apply(M1, this); apply(M2, this);
done();
}
// Four options...
template<class M0t, class M1t, class M2t, class M3t>
alias(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3)
- : Option(Optional, Hidden), AliasFor(0) {
+ : Option(Optional, Hidden), AliasFor(nullptr) {
apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this);
done();
}
};
public:
- CrashRecoveryContext() : Impl(0), head(0) {}
+ CrashRecoveryContext() : Impl(nullptr), head(nullptr) {}
~CrashRecoveryContext();
void registerCleanup(CrashRecoveryContextCleanup *cleanup);
/// It is safe to call this function multiple times for the same library.
/// @brief Open a dynamic library permanently.
static DynamicLibrary getPermanentLibrary(const char *filename,
- std::string *errMsg = 0);
+ std::string *errMsg = nullptr);
/// This function permanently loads the dynamic library at the given path.
/// Use this instead of getPermanentLibrary() when you won't need to get
///
/// It is safe to call this function multiple times for the same library.
static bool LoadLibraryPermanently(const char *Filename,
- std::string *ErrMsg = 0) {
+ std::string *ErrMsg = nullptr) {
return !getPermanentLibrary(Filename, ErrMsg).isValid();
}
/// \param user_data - An argument which will be passed to the install error
/// handler.
void install_fatal_error_handler(fatal_error_handler_t handler,
- void *user_data = 0);
+ void *user_data = nullptr);
/// Restores default error handling behaviour.
/// This must not be called between llvm_start_multithreaded() and
/// remove_fatal_error_handler in its destructor.
struct ScopedFatalErrorHandler {
explicit ScopedFatalErrorHandler(fatal_error_handler_t handler,
- void *user_data = 0) {
+ void *user_data = nullptr) {
install_fatal_error_handler(handler, user_data);
}
/// This function calls abort(), and prints the optional message to stderr.
/// Use the llvm_unreachable macro (that adds location info), instead of
/// calling this function directly.
- LLVM_ATTRIBUTE_NORETURN void llvm_unreachable_internal(const char *msg=0,
- const char *file=0,
- unsigned line=0);
+ LLVM_ATTRIBUTE_NORETURN void
+ llvm_unreachable_internal(const char *msg=nullptr, const char *file=nullptr,
+ unsigned line=0);
}
/// Marks that the current location is not supposed to be reachable.
}
/// Construct end iterator.
- directory_iterator() : State(0) {}
+ directory_iterator() : State(nullptr) {}
// No operator++ because we need error_code.
directory_iterator &increment(error_code &ec) {
bool operator==(const directory_iterator &RHS) const {
if (State == RHS.State)
return true;
- if (RHS.State == 0)
+ if (RHS.State == nullptr)
return State->CurrentEntry == directory_entry();
- if (State == 0)
+ if (State == nullptr)
return RHS.State->CurrentEntry == directory_entry();
return State->CurrentEntry == RHS.State->CurrentEntry;
}
int DiffFilesWithTolerance(StringRef FileA,
StringRef FileB,
double AbsTol, double RelTol,
- std::string *Error = 0);
+ std::string *Error = nullptr);
/// FileRemover - This class is a simple object meant to be stack allocated.
/// underneath it.
///
formatted_raw_ostream(raw_ostream &Stream, bool Delete = false)
- : raw_ostream(), TheStream(0), DeleteStream(false), Position(0, 0) {
+ : raw_ostream(), TheStream(nullptr), DeleteStream(false), Position(0, 0) {
setStream(Stream, Delete);
}
explicit formatted_raw_ostream()
- : raw_ostream(), TheStream(0), DeleteStream(false), Position(0, 0) {
- Scanned = 0;
+ : raw_ostream(), TheStream(nullptr), DeleteStream(false), Position(0, 0) {
+ Scanned = nullptr;
}
~formatted_raw_ostream() {
SetUnbuffered();
TheStream->SetUnbuffered();
- Scanned = 0;
+ Scanned = nullptr;
}
/// PadToColumn - Align the output to some column number. If the current
/// emitSimpleNode - Outputs a simple (non-record) node
void emitSimpleNode(const void *ID, const std::string &Attr,
- const std::string &Label, unsigned NumEdgeSources = 0,
- const std::vector<std::string> *EdgeSourceLabels = 0) {
+ const std::string &Label, unsigned NumEdgeSources = 0,
+ const std::vector<std::string> *EdgeSourceLabels = nullptr) {
O << "\tNode" << ID << "[ ";
if (!Attr.empty())
O << Attr << ",";
/// Utility function to decode a ULEB128 value.
-inline uint64_t decodeULEB128(const uint8_t *p, unsigned *n = 0) {
+inline uint64_t decodeULEB128(const uint8_t *p, unsigned *n = nullptr) {
const uint8_t *orig_p = p;
uint64_t Value = 0;
unsigned Shift = 0;
public:
/// \brief Default construct an "end" iterator.
- line_iterator() : Buffer(0) {}
+ line_iterator() : Buffer(nullptr) {}
/// \brief Construct a new iterator around some memory buffer.
explicit line_iterator(const MemoryBuffer &Buffer, char CommentMarker = '\0');
void RegisterManagedStatic(void *(*creator)(), void (*deleter)(void*)) const;
public:
/// isConstructed - Return true if this object has not been created yet.
- bool isConstructed() const { return Ptr != 0; }
+ bool isConstructed() const { return Ptr != nullptr; }
void destroy() const;
};
/// @brief Memory block abstraction.
class MemoryBlock {
public:
- MemoryBlock() : Address(0), Size(0) { }
+ MemoryBlock() : Address(nullptr), Size(0) { }
MemoryBlock(void *addr, size_t size) : Address(addr), Size(size) { }
void *base() const { return Address; }
size_t size() const { return Size; }
/// @brief Allocate Read/Write/Execute memory.
static MemoryBlock AllocateRWX(size_t NumBytes,
const MemoryBlock *NearBlock,
- std::string *ErrMsg = 0);
+ std::string *ErrMsg = nullptr);
/// This method releases a block of Read/Write/Execute memory that was
/// allocated with the AllocateRWX method. It should not be used to
/// On success, this returns false, otherwise it returns true and fills
/// in *ErrMsg.
/// @brief Release Read/Write/Execute memory.
- static bool ReleaseRWX(MemoryBlock &block, std::string *ErrMsg = 0);
+ static bool ReleaseRWX(MemoryBlock &block, std::string *ErrMsg = nullptr);
/// InvalidateInstructionCache - Before the JIT can run a block of code
/// setExecutable - Before the JIT can run a block of code, it has to be
/// given read and executable privilege. Return true if it is already r-x
/// or the system is able to change its previlege.
- static bool setExecutable(MemoryBlock &M, std::string *ErrMsg = 0);
+ static bool setExecutable(MemoryBlock &M, std::string *ErrMsg = nullptr);
/// setWritable - When adding to a block of code, the JIT may need
/// to mark a block of code as RW since the protections are on page
/// boundaries, and the JIT internal allocations are not page aligned.
- static bool setWritable(MemoryBlock &M, std::string *ErrMsg = 0);
+ static bool setWritable(MemoryBlock &M, std::string *ErrMsg = nullptr);
/// setRangeExecutable - Mark the page containing a range of addresses
/// as executable.
const char **args, ///< A vector of strings that are passed to the
///< program. The first element should be the name of the program.
///< The list *must* be terminated by a null char* entry.
- const char **env = 0, ///< An optional vector of strings to use for
+ const char **env = nullptr, ///< An optional vector of strings to use for
///< the program's environment. If not provided, the current program's
///< environment will be used.
- const StringRef **redirects = 0, ///< An optional array of pointers to
- ///< paths. If the array is null, no redirection is done. The array
+ const StringRef **redirects = nullptr, ///< An optional array of pointers
+ ///< to paths. If the array is null, no redirection is done. The array
///< should have a size of at least three. The inferior process's
///< stdin(0), stdout(1), and stderr(2) will be redirected to the
///< corresponding paths.
///< of memory can be allocated by process. If memory usage will be
///< higher limit, the child is killed and this call returns. If zero
///< - no memory limit.
- std::string *ErrMsg = 0, ///< If non-zero, provides a pointer to a string
- ///< instance in which error messages will be returned. If the string
- ///< is non-empty upon return an error occurred while invoking the
+ std::string *ErrMsg = nullptr, ///< If non-zero, provides a pointer to a
+ ///< string instance in which error messages will be returned. If the
+ ///< string is non-empty upon return an error occurred while invoking the
///< program.
- bool *ExecutionFailed = 0);
+ bool *ExecutionFailed = nullptr);
/// Similar to ExecuteAndWait, but returns immediately.
/// @returns The \see ProcessInfo of the newly launced process.
/// Wait until the process finished execution or win32 CloseHandle() API on
/// ProcessInfo.ProcessHandle to avoid memory leaks.
ProcessInfo
- ExecuteNoWait(StringRef Program, const char **args, const char **env = 0,
- const StringRef **redirects = 0, unsigned memoryLimit = 0,
- std::string *ErrMsg = 0, bool *ExecutionFailed = 0);
+ ExecuteNoWait(StringRef Program, const char **args, const char **env = nullptr,
+ const StringRef **redirects = nullptr, unsigned memoryLimit = 0,
+ std::string *ErrMsg = nullptr, bool *ExecutionFailed = nullptr);
/// Return true if the given arguments fit within system-specific
/// argument length limits.
///< will perform a non-blocking wait on the child process.
bool WaitUntilTerminates, ///< If true, ignores \p SecondsToWait and waits
///< until child has terminated.
- std::string *ErrMsg = 0 ///< If non-zero, provides a pointer to a string
- ///< instance in which error messages will be returned. If the string
- ///< is non-empty upon return an error occurred while invoking the
+ std::string *ErrMsg = nullptr ///< If non-zero, provides a pointer to a
+ ///< string instance in which error messages will be returned. If the
+ ///< string is non-empty upon return an error occurred while invoking the
///< program.
);
}
Regex(Regex &®ex) {
preg = regex.preg;
error = regex.error;
- regex.preg = NULL;
+ regex.preg = nullptr;
}
~Regex();
/// the first group is always the entire pattern.
///
/// This returns true on a successful match.
- bool match(StringRef String, SmallVectorImpl<StringRef> *Matches = 0);
+ bool match(StringRef String, SmallVectorImpl<StringRef> *Matches = nullptr);
/// sub - Return the result of replacing the first match of the regex in
/// \p String with the \p Repl string. Backreferences like "\0" in the
/// \param Error If non-null, any errors in the substitution (invalid
/// backreferences, trailing backslashes) will be recorded as a non-empty
/// string.
- std::string sub(StringRef Repl, StringRef String, std::string *Error = 0);
+ std::string sub(StringRef Repl, StringRef String,
+ std::string *Error = nullptr);
/// \brief If this function returns true, ^Str$ is an extended regular
/// expression that matches Str and only Str.
class SMLoc {
const char *Ptr;
public:
- SMLoc() : Ptr(0) {}
+ SMLoc() : Ptr(nullptr) {}
- bool isValid() const { return Ptr != 0; }
+ bool isValid() const { return Ptr != nullptr; }
bool operator==(const SMLoc &RHS) const { return RHS.Ptr == Ptr; }
bool operator!=(const SMLoc &RHS) const { return RHS.Ptr != Ptr; }
/// This function registers signal handlers to ensure that if a signal gets
/// delivered that the named file is removed.
/// @brief Remove a file if a fatal signal occurs.
- bool RemoveFileOnSignal(StringRef Filename, std::string* ErrMsg = 0);
+ bool RemoveFileOnSignal(StringRef Filename, std::string* ErrMsg = nullptr);
/// This function removes a file from the list of files to be removed on
/// signal delivery.
SourceMgr(const SourceMgr&) LLVM_DELETED_FUNCTION;
void operator=(const SourceMgr&) LLVM_DELETED_FUNCTION;
public:
- SourceMgr() : LineNoCache(0), DiagHandler(0), DiagContext(0) {}
+ SourceMgr()
+ : LineNoCache(nullptr), DiagHandler(nullptr), DiagContext(nullptr) {}
~SourceMgr();
void setIncludeDirs(const std::vector<std::string> &Dirs) {
/// setDiagHandler - Specify a diagnostic handler to be invoked every time
/// PrintMessage is called. Ctx is passed into the handler when it is invoked.
- void setDiagHandler(DiagHandlerTy DH, void *Ctx = 0) {
+ void setDiagHandler(DiagHandlerTy DH, void *Ctx = nullptr) {
DiagHandler = DH;
DiagContext = Ctx;
}
public:
// Null diagnostic.
SMDiagnostic()
- : SM(0), LineNo(0), ColumnNo(0), Kind(SourceMgr::DK_Error) {}
+ : SM(nullptr), LineNo(0), ColumnNo(0), Kind(SourceMgr::DK_Error) {}
// Diagnostic with no location (e.g. file not found, command line arg error).
SMDiagnostic(StringRef filename, SourceMgr::DiagKind Knd, StringRef Msg)
- : SM(0), Filename(filename), LineNo(-1), ColumnNo(-1), Kind(Knd),
+ : SM(nullptr), Filename(filename), LineNo(-1), ColumnNo(-1), Kind(Knd),
Message(Msg) {}
// Diagnostic with a location.
// the memory doesn't go away/get reallocated, but it's
// not currently necessary. Users that need the pointer don't stream.
assert(0 && "getPointer in streaming memory objects not allowed");
- return NULL;
+ return nullptr;
}
bool isValidAddress(uint64_t address) const override;
bool isObjectEnd(uint64_t address) const override;
unsigned Refcount; ///< Number of referencing PooledStringPtrs.
public:
- PooledString() : Pool(0), Refcount(0) { }
+ PooledString() : Pool(nullptr), Refcount(0) { }
};
friend class PooledStringPtr;
entry_t *S;
public:
- PooledStringPtr() : S(0) {}
+ PooledStringPtr() : S(nullptr) {}
explicit PooledStringPtr(entry_t *E) : S(E) {
if (S) ++S->getValue().Refcount;
S->getValue().Pool->InternTable.remove(S);
S->Destroy();
}
- S = 0;
+ S = nullptr;
}
~PooledStringPtr() { clear(); }
}
inline const char *operator*() const { return begin(); }
- inline operator bool() const { return S != 0; }
+ inline operator bool() const { return S != nullptr; }
inline bool operator==(const PooledStringPtr &That) { return S == That.S; }
inline bool operator!=(const PooledStringPtr &That) { return S != That.S; }
public:
Target()
- : AsmStreamerCtorFn(0), MCRelocationInfoCtorFn(0),
- MCSymbolizerCtorFn(0) {}
+ : AsmStreamerCtorFn(nullptr), MCRelocationInfoCtorFn(nullptr),
+ MCSymbolizerCtorFn(nullptr) {}
/// @name Target Information
/// @{
bool hasJIT() const { return HasJIT; }
/// hasTargetMachine - Check if this target supports code generation.
- bool hasTargetMachine() const { return TargetMachineCtorFn != 0; }
+ bool hasTargetMachine() const { return TargetMachineCtorFn != nullptr; }
/// hasMCAsmBackend - Check if this target supports .o generation.
- bool hasMCAsmBackend() const { return MCAsmBackendCtorFn != 0; }
+ bool hasMCAsmBackend() const { return MCAsmBackendCtorFn != nullptr; }
/// @}
/// @name Feature Constructors
MCAsmInfo *createMCAsmInfo(const MCRegisterInfo &MRI,
StringRef Triple) const {
if (!MCAsmInfoCtorFn)
- return 0;
+ return nullptr;
return MCAsmInfoCtorFn(MRI, Triple);
}
CodeModel::Model CM,
CodeGenOpt::Level OL) const {
if (!MCCodeGenInfoCtorFn)
- return 0;
+ return nullptr;
return MCCodeGenInfoCtorFn(Triple, RM, CM, OL);
}
///
MCInstrInfo *createMCInstrInfo() const {
if (!MCInstrInfoCtorFn)
- return 0;
+ return nullptr;
return MCInstrInfoCtorFn();
}
///
MCInstrAnalysis *createMCInstrAnalysis(const MCInstrInfo *Info) const {
if (!MCInstrAnalysisCtorFn)
- return 0;
+ return nullptr;
return MCInstrAnalysisCtorFn(Info);
}
///
MCRegisterInfo *createMCRegInfo(StringRef Triple) const {
if (!MCRegInfoCtorFn)
- return 0;
+ return nullptr;
return MCRegInfoCtorFn(Triple);
}
MCSubtargetInfo *createMCSubtargetInfo(StringRef Triple, StringRef CPU,
StringRef Features) const {
if (!MCSubtargetInfoCtorFn)
- return 0;
+ return nullptr;
return MCSubtargetInfoCtorFn(Triple, CPU, Features);
}
CodeModel::Model CM = CodeModel::Default,
CodeGenOpt::Level OL = CodeGenOpt::Default) const {
if (!TargetMachineCtorFn)
- return 0;
+ return nullptr;
return TargetMachineCtorFn(*this, Triple, CPU, Features, Options,
RM, CM, OL);
}
MCAsmBackend *createMCAsmBackend(const MCRegisterInfo &MRI,
StringRef Triple, StringRef CPU) const {
if (!MCAsmBackendCtorFn)
- return 0;
+ return nullptr;
return MCAsmBackendCtorFn(*this, MRI, Triple, CPU);
}
MCAsmParser &Parser,
const MCInstrInfo &MII) const {
if (!MCAsmParserCtorFn)
- return 0;
+ return nullptr;
return MCAsmParserCtorFn(STI, Parser, MII);
}
/// takes ownership of the MCStreamer object.
AsmPrinter *createAsmPrinter(TargetMachine &TM, MCStreamer &Streamer) const{
if (!AsmPrinterCtorFn)
- return 0;
+ return nullptr;
return AsmPrinterCtorFn(TM, Streamer);
}
MCDisassembler *createMCDisassembler(const MCSubtargetInfo &STI) const {
if (!MCDisassemblerCtorFn)
- return 0;
+ return nullptr;
return MCDisassemblerCtorFn(*this, STI);
}
const MCRegisterInfo &MRI,
const MCSubtargetInfo &STI) const {
if (!MCInstPrinterCtorFn)
- return 0;
+ return nullptr;
return MCInstPrinterCtorFn(*this, SyntaxVariant, MAI, MII, MRI, STI);
}
const MCSubtargetInfo &STI,
MCContext &Ctx) const {
if (!MCCodeEmitterCtorFn)
- return 0;
+ return nullptr;
return MCCodeEmitterCtorFn(II, MRI, STI, Ctx);
}
bool RelaxAll,
bool NoExecStack) const {
if (!MCObjectStreamerCtorFn)
- return 0;
+ return nullptr;
return MCObjectStreamerCtorFn(*this, TT, Ctx, TAB, _OS, _Emitter, STI,
RelaxAll, NoExecStack);
}
explicit iterator(Target *T) : Current(T) {}
friend struct TargetRegistry;
public:
- iterator() : Current(0) {}
+ iterator() : Current(nullptr) {}
bool operator==(const iterator &x) const {
return Current == x.Current;
Timer **Prev, *Next; // Doubly linked list of timers in the group.
public:
- explicit Timer(StringRef N) : TG(0) { init(N); }
- Timer(StringRef N, TimerGroup &tg) : TG(0) { init(N, tg); }
- Timer(const Timer &RHS) : TG(0) {
+ explicit Timer(StringRef N) : TG(nullptr) { init(N); }
+ Timer(StringRef N, TimerGroup &tg) : TG(nullptr) { init(N, tg); }
+ Timer(const Timer &RHS) : TG(nullptr) {
assert(RHS.TG == 0 && "Can only copy uninitialized timers");
}
const Timer &operator=(const Timer &T) {
~Timer();
// Create an uninitialized timer, client must use 'init'.
- explicit Timer() : TG(0) {}
+ explicit Timer() : TG(nullptr) {}
void init(StringRef N);
void init(StringRef N, TimerGroup &tg);
const std::string &getName() const { return Name; }
- bool isInitialized() const { return TG != 0; }
+ bool isInitialized() const { return TG != nullptr; }
/// startTimer - Start the timer running. Time between calls to
/// startTimer/stopTimer is counted by the Timer class. Note that these calls
void anchor() override;
public:
KeyValueNode(std::unique_ptr<Document> &D)
- : Node(NK_KeyValue, D, StringRef(), StringRef()), Key(0), Value(0) {}
+ : Node(NK_KeyValue, D, StringRef(), StringRef()), Key(nullptr),
+ Value(nullptr) {}
/// @brief Parse and return the key.
///
class basic_collection_iterator
: public std::iterator<std::forward_iterator_tag, ValueT> {
public:
- basic_collection_iterator() : Base(0) {}
+ basic_collection_iterator() : Base(nullptr) {}
basic_collection_iterator(BaseT *B) : Base(B) {}
ValueT *operator ->() const {
assert(Base && "Attempted to advance iterator past end!");
Base->increment();
// Create an end iterator.
- if (Base->CurrentEntry == 0)
- Base = 0;
+ if (Base->CurrentEntry == nullptr)
+ Base = nullptr;
return *this;
}
MappingNode(std::unique_ptr<Document> &D, StringRef Anchor, StringRef Tag,
MappingType MT)
: Node(NK_Mapping, D, Anchor, Tag), Type(MT), IsAtBeginning(true),
- IsAtEnd(false), CurrentEntry(0) {}
+ IsAtEnd(false), CurrentEntry(nullptr) {}
friend class basic_collection_iterator<MappingNode, KeyValueNode>;
typedef basic_collection_iterator<MappingNode, KeyValueNode> iterator;
: Node(NK_Sequence, D, Anchor, Tag), SeqType(ST), IsAtBeginning(true),
IsAtEnd(false),
WasPreviousTokenFlowEntry(true), // Start with an imaginary ','.
- CurrentEntry(0) {}
+ CurrentEntry(nullptr) {}
friend class basic_collection_iterator<SequenceNode, Node>;
typedef basic_collection_iterator<SequenceNode, Node> iterator;
/// @brief Iterator abstraction for Documents over a Stream.
class document_iterator {
public:
- document_iterator() : Doc(0) {}
+ document_iterator() : Doc(nullptr) {}
document_iterator(std::unique_ptr<Document> &D) : Doc(&D) {}
bool operator ==(const document_iterator &Other) {
document_iterator operator ++() {
assert(Doc != 0 && "incrementing iterator past the end.");
if (!(*Doc)->skip()) {
- Doc->reset(0);
+ Doc->reset(nullptr);
} else {
Stream &S = (*Doc)->stream;
Doc->reset(new Document(S));
static double test(...);
public:
- static bool const value = (sizeof(test<ScalarTraits<T> >(0,0)) == 1);
+ static bool const value =
+ (sizeof(test<ScalarTraits<T> >(nullptr,nullptr)) == 1);
};
class IO {
public:
- IO(void *Ctxt=NULL);
+ IO(void *Ctxt=nullptr);
virtual ~IO();
virtual bool outputting() = 0;
// user-data. The DiagHandler can be specified to provide
// alternative error reporting.
Input(StringRef InputContent,
- void *Ctxt = NULL,
- SourceMgr::DiagHandlerTy DiagHandler = NULL,
- void *DiagHandlerCtxt = NULL);
+ void *Ctxt = nullptr,
+ SourceMgr::DiagHandlerTy DiagHandler = nullptr,
+ void *DiagHandlerCtxt = nullptr);
~Input();
// Check if there was an syntax or semantic error during parsing.
///
class Output : public IO {
public:
- Output(llvm::raw_ostream &, void *Ctxt=NULL);
+ Output(llvm::raw_ostream &, void *Ctxt=nullptr);
virtual ~Output();
bool outputting() override;
circular_raw_ostream(raw_ostream &Stream, const char *Header,
size_t BuffSize = 0, bool Owns = REFERENCE_ONLY)
: raw_ostream(/*unbuffered*/true),
- TheStream(0),
+ TheStream(nullptr),
OwnsStream(Owns),
BufferSize(BuffSize),
- BufferArray(0),
+ BufferArray(nullptr),
Filled(false),
Banner(Header) {
if (BufferSize != 0)
}
explicit circular_raw_ostream()
: raw_ostream(/*unbuffered*/true),
- TheStream(0),
+ TheStream(nullptr),
OwnsStream(REFERENCE_ONLY),
- BufferArray(0),
+ BufferArray(nullptr),
Filled(false),
Banner("") {
Cur = BufferArray;
explicit raw_ostream(bool unbuffered=false)
: BufferMode(unbuffered ? Unbuffered : InternalBuffer) {
// Start out ready to flush.
- OutBufStart = OutBufEnd = OutBufCur = 0;
+ OutBufStart = OutBufEnd = OutBufCur = nullptr;
}
virtual ~raw_ostream();
size_t GetBufferSize() const {
// If we're supposed to be buffered but haven't actually gotten around
// to allocating the buffer yet, return the value that would be used.
- if (BufferMode != Unbuffered && OutBufStart == 0)
+ if (BufferMode != Unbuffered && OutBufStart == nullptr)
return preferred_buffer_size();
// Otherwise just return the size of the allocated buffer.
/// set to unbuffered.
void SetUnbuffered() {
flush();
- SetBufferAndMode(0, 0, Unbuffered);
+ SetBufferAndMode(nullptr, 0, Unbuffered);
}
size_t GetNumBytesInBuffer() const {
static void unspecified_bool_true() {}
operator unspecified_bool_type() const { // true if error
- return _val_ == 0 ? 0 : unspecified_bool_true;
+ return _val_ == 0 ? nullptr : unspecified_bool_true;
}
};
static void unspecified_bool_true() {}
operator unspecified_bool_type() const { // true if error
- return _val_ == 0 ? 0 : unspecified_bool_true;
+ return _val_ == 0 ? nullptr : unspecified_bool_true;
}
};
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);
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);
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:
// 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];
// 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;
}
// 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;
}
MemSlab *MallocSlabAllocator::Allocate(size_t Size) {
MemSlab *Slab = (MemSlab*)Allocator.Allocate(Size, 0);
Slab->Size = Size;
- Slab->NextPtr = 0;
+ Slab->NextPtr = nullptr;
return 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;
}
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;
// 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;
/// 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!");
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.
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('=');
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);
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('=');
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) {
// 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'
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);
}
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
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
"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);
// 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 &&
// 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))
// 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 = "";
// 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...
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";
<< " 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) {
//
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
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;
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";
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 {
void operator=(bool OptionWasSpecified) {
if (!OptionWasSpecified) return;
- if (OverrideVersionPrinter != 0) {
+ if (OverrideVersionPrinter != nullptr) {
(*OverrideVersionPrinter)();
exit(0);
}
// 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();
}
void cl::AddExtraVersionPrinter(void (*func)()) {
- if (ExtraVersionPrinters == 0)
+ if (ExtraVersionPrinters == nullptr)
ExtraVersionPrinters = new std::vector<void (*)()>;
ExtraVersionPrinters->push_back(func);
}
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;
}
if (cleanup == head) {
head = cleanup->next;
if (head)
- head->prev = 0;
+ head->prev = nullptr;
}
else {
cleanup->prev->next = cleanup->next;
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();
// 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
// success
return dst;
}
- return NULL;
+ return nullptr;
}
uint8_t DataExtractor::getU8(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 {
if (error_code e = s->OpenFile(Filename)) {
*StrError = std::string("Could not open ") + Filename + ": " +
e.message() + "\n";
- return NULL;
+ return nullptr;
}
return s;
}
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.
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.
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.
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
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
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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
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.
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
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.
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
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) {
case DW_ATOM_type_flags:
return "DW_ATOM_type_flags";
}
- return 0;
+ return nullptr;
}
const char *llvm::dwarf::GDBIndexEntryKindString(GDBIndexEntryKind Kind) {
//=== 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();
}
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
void *DynamicLibrary::getAddressOfSymbol(const char *symbolName) {
if (!isValid())
- return NULL;
+ return nullptr;
return dlsym(Data, symbolName);
}
#endif
#undef EXPLICIT_SYMBOL
- return 0;
+ return nullptr;
}
#endif // LLVM_ON_WIN32
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) {
}
void llvm::remove_fatal_error_handler() {
- ErrorHandler = 0;
+ ErrorHandler = nullptr;
}
void llvm::report_fatal_error(const char *Reason, bool GenCrashDiag) {
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 ) {
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);
}
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,
void **Bucket = GetBucketFor(IDHash, Buckets, NumBuckets);
void *Probe = *Bucket;
- InsertPos = 0;
+ InsertPos = nullptr;
FoldingSetNodeID TempID;
while (Node *NodeInBucket = GetNextPtr(Probe)) {
// 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
// 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.
// 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;
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);
do {
++Bucket;
} while (*Bucket != reinterpret_cast<void*>(-1) &&
- (*Bucket == 0 || GetNextPtr(*Bucket) == 0));
+ (*Bucket == nullptr || GetNextPtr(*Bucket) == nullptr));
NodePtr = static_cast<FoldingSetNode*>(*Bucket);
}
// FoldingSetBucketIteratorImpl Implementation
FoldingSetBucketIteratorImpl::FoldingSetBucketIteratorImpl(void **Bucket) {
- Ptr = (*Bucket == 0 || GetNextPtr(*Bucket) == 0) ? (void*) Bucket : *Bucket;
+ Ptr = (*Bucket == nullptr || GetNextPtr(*Bucket) == nullptr) ? (void*) Bucket
+ : *Bucket;
}
TheStream->write(Ptr, Size);
// Reset the scanning pointer.
- Scanned = 0;
+ Scanned = nullptr;
}
/// fouts() - This returns a reference to a formatted_raw_ostream for
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;
}
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;
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))
}
} 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;
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()) {
if (*Pos == '\0') {
// We've hit the end of the buffer, reset ourselves to the end state.
- Buffer = 0;
+ Buffer = nullptr;
CurrentLine = StringRef();
return;
}
#if LLVM_ON_WIN32
Sleep(Interval);
#else
- nanosleep(&Interval, NULL);
+ nanosleep(&Interval, nullptr);
#endif
bool LockFileJustDisappeared = false;
#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();
} 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.
"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.
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;
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);
/// 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;
}
// Construct a Mutex using pthread calls
MutexImpl::MutexImpl( bool recursive)
- : data_(0)
+ : data_(nullptr)
{
// Declare the pthread_mutex data structures
pthread_mutex_t* mutex =
// 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);
/// 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";
}
static bool RegisterCrashPrinter() {
- sys::AddSignalHandler(CrashHandler, 0);
+ sys::AddSignalHandler(CrashHandler, nullptr);
return false;
}
// Construct a RWMutex using pthread calls
RWMutexImpl::RWMutexImpl()
- : data_(0)
+ : data_(nullptr)
{
// Declare the pthread_rwlock data structures
pthread_rwlock_t* rwlock =
#endif
// Initialize the rwlock
- int errorcode = pthread_rwlock_init(rwlock, NULL);
+ int errorcode = pthread_rwlock_init(rwlock, nullptr);
(void)errorcode;
assert(errorcode == 0);
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);
#endif
#undef EXPLICIT_SYMBOL
- return 0;
+ return nullptr;
}
namespace llvm {
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)
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.
PrintIncludeStack(getBufferInfo(CurBuf).IncludeLoc, OS);
}
- Diagnostic.print(0, OS, ShowColors);
+ Diagnostic.print(nullptr, OS, ShowColors);
}
void SourceMgr::PrintMessage(SMLoc Loc, SourceMgr::DiagKind Kind,
}
// Otherwise, initialize it with zero buckets to avoid the allocation.
- TheTable = 0;
+ TheTable = nullptr;
NumBuckets = 0;
NumItems = 0;
NumTombstones = 0;
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) {
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()) {
/// 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();
// 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;
// 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);
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);
}
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);
// 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) {
if (!TheTarget) {
Error = "error: invalid target '" + ArchName + "'.\n";
- return 0;
+ return nullptr;
}
// Adjust the triple to match (if known), otherwise stick with the
// 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;
}
}
// 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;
}
if (!Matching) {
Error = "No available targets are compatible with this triple, "
"see -version for the available targets.";
- return 0;
+ return nullptr;
}
return Matching;
if (TheTarget && !TheTarget->hasJIT()) {
Error = "No JIT compatible target available for this host";
- return 0;
+ return nullptr;
}
return TheTarget;
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;
}
}
void ThreadLocalImpl::removeInstance() {
- setInstance(0);
+ setInstance(nullptr);
}
}
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
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,
goto error;
// Wait for the thread and clean up.
- ::pthread_join(Thread, 0);
+ ::pthread_join(Thread, nullptr);
error:
::pthread_attr_destroy(&Attr);
}
-static TimerGroup *DefaultTimerGroup = 0;
+static TimerGroup *DefaultTimerGroup = nullptr;
static TimerGroup *getDefaultTimerGroup() {
TimerGroup *tmp = DefaultTimerGroup;
sys::MemoryFence();
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
/// 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);
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.
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;
// 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();
const char *Triple::getArchTypePrefix(ArchType Kind) {
switch (Kind) {
default:
- return 0;
+ return nullptr;
case aarch64:
case aarch64_be: return "aarch64";
// 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")
.Case("amdil", "amdil")
.Case("spir", "spir")
.Case("spir64", "spir64")
- .Default(NULL);
+ .Default(nullptr);
}
static Triple::ArchType parseArch(StringRef ArchName) {
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;
}
}
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) {
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;
}
}
}
void SequenceNode::increment() {
if (failed()) {
IsAtEnd = true;
- CurrentEntry = 0;
+ CurrentEntry = nullptr;
return;
}
if (CurrentEntry)
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) {
case Token::TK_Error:
// Set this to end iterator.
IsAtEnd = true;
- CurrentEntry = 0;
+ CurrentEntry = nullptr;
break;
case Token::TK_StreamEnd:
case Token::TK_DocumentEnd:
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.
}
}
-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:";
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();
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();
// !!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() {
void *DiagHandlerCtxt)
: IO(Ctxt),
Strm(new Stream(InputContent, SrcMgr)),
- CurrentNode(NULL) {
+ CurrentNode(nullptr) {
if (DiagHandler)
SrcMgr.setDiagHandler(DiagHandler, DiagHandlerCtxt);
DocIterator = Strm->begin();
return new EmptyHNode(N);
} else {
setError(N, "unknown node kind");
- return NULL;
+ return nullptr;
}
}