llvm.org GIT mirror llvm / 34bc6b6
[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 Craig Topper 6 years ago
75 changed file(s) with 338 addition(s) and 330 deletion(s). Raw diff Collapse all Expand all
235235 APInt fill(64, type);
236236 return getQNaN(Sem, Negative, &fill);
237237 } else {
238 return getQNaN(Sem, Negative, 0);
238 return getQNaN(Sem, Negative, nullptr);
239239 }
240240 }
241241
242242 /// Factory for QNaN values.
243243 static APFloat getQNaN(const fltSemantics &Sem, bool Negative = false,
244 const APInt *payload = 0) {
244 const APInt *payload = nullptr) {
245245 return makeNaN(Sem, false, Negative, payload);
246246 }
247247
248248 /// Factory for SNaN values.
249249 static APFloat getSNaN(const fltSemantics &Sem, bool Negative = false,
250 const APInt *payload = 0) {
250 const APInt *payload = nullptr) {
251251 return makeNaN(Sem, true, Negative, payload);
252252 }
253253
499499
500500 void makeLargest(bool Neg = false);
501501 void makeSmallest(bool Neg = false);
502 void makeNaN(bool SNaN = false, bool Neg = false, const APInt *fill = 0);
502 void makeNaN(bool SNaN = false, bool Neg = false,
503 const APInt *fill = nullptr);
503504 static APFloat makeNaN(const fltSemantics &Sem, bool SNaN, bool Negative,
504505 const APInt *fill);
505506 void makeInf(bool Neg = false);
5151 /*implicit*/ ArrayRef() : Data(0), Length(0) {}
5252
5353 /// Construct an empty ArrayRef from None.
54 /*implicit*/ ArrayRef(NoneType) : Data(0), Length(0) {}
54 /*implicit*/ ArrayRef(NoneType) : Data(nullptr), Length(0) {}
5555
5656 /// Construct an ArrayRef from a single element.
5757 /*implicit*/ ArrayRef(const T &OneElt)
460460 const unsigned NumBuckets = getNumBuckets();
461461
462462 if (NumBuckets == 0) {
463 FoundBucket = 0;
463 FoundBucket = nullptr;
464464 return false;
465465 }
466466
467467 // FoundTombstone - Keep track of whether we find a tombstone while probing.
468 const BucketT *FoundTombstone = 0;
468 const BucketT *FoundTombstone = nullptr;
469469 const KeyT EmptyKey = getEmptyKey();
470470 const KeyT TombstoneKey = getTombstoneKey();
471471 assert(!KeyInfoT::isEqual(Val, EmptyKey) &&
664664 bool allocateBuckets(unsigned Num) {
665665 NumBuckets = Num;
666666 if (NumBuckets == 0) {
667 Buckets = 0;
667 Buckets = nullptr;
668668 return false;
669669 }
670670
136136
137137 public:
138138
139 Node() : NextInFoldingSetBucket(0) {}
139 Node() : NextInFoldingSetBucket(nullptr) {}
140140
141141 // Accessors
142142 void *getNextInBucket() const { return NextInFoldingSetBucket; }
268268 const unsigned *Data;
269269 size_t Size;
270270 public:
271 FoldingSetNodeIDRef() : Data(0), Size(0) {}
271 FoldingSetNodeIDRef() : Data(nullptr), Size(0) {}
272272 FoldingSetNodeIDRef(const unsigned *D, size_t S) : Data(D), Size(S) {}
273273
274274 /// ComputeHash - Compute a strong hash value for this FoldingSetNodeIDRef,
138138 public:
139139 typedef T element_type;
140140
141 explicit IntrusiveRefCntPtr() : Obj(0) {}
141 explicit IntrusiveRefCntPtr() : Obj(nullptr) {}
142142
143143 IntrusiveRefCntPtr(T* obj) : Obj(obj) {
144144 retain();
149149 }
150150
151151 IntrusiveRefCntPtr(IntrusiveRefCntPtr&& S) : Obj(S.Obj) {
152 S.Obj = 0;
152 S.Obj = nullptr;
153153 }
154154
155155 template
178178
179179 typedef T* (IntrusiveRefCntPtr::*unspecified_bool_type) () const;
180180 operator unspecified_bool_type() const {
181 return Obj == 0 ? 0 : &IntrusiveRefCntPtr::getPtr;
181 return Obj == nullptr ? nullptr : &IntrusiveRefCntPtr::getPtr;
182182 }
183183
184184 void swap(IntrusiveRefCntPtr& other) {
189189
190190 void reset() {
191191 release();
192 Obj = 0;
192 Obj = nullptr;
193193 }
194194
195195 void resetWithoutRelease() {
4949 protected:
5050 explicit StringMapImpl(unsigned itemSize) : ItemSize(itemSize) {
5151 // Initialize the map with zero buckets to allocation.
52 TheTable = 0;
52 TheTable = nullptr;
5353 NumBuckets = 0;
5454 NumItems = 0;
5555 NumTombstones = 0;
329329 if (Bucket && Bucket != getTombstoneVal()) {
330330 static_cast(Bucket)->Destroy(Allocator);
331331 }
332 Bucket = 0;
332 Bucket = nullptr;
333333 }
334334
335335 NumItems = 0;
409409 public:
410410 typedef StringMapEntry value_type;
411411
412 StringMapConstIterator() : Ptr(0) { }
412 StringMapConstIterator() : Ptr(nullptr) { }
413413
414414 explicit StringMapConstIterator(StringMapEntryBase **Bucket,
415415 bool NoAdvance = false)
442442
443443 private:
444444 void AdvancePastEmptyBuckets() {
445 while (*Ptr == 0 || *Ptr == StringMapImpl::getTombstoneVal())
445 while (*Ptr == nullptr || *Ptr == StringMapImpl::getTombstoneVal())
446446 ++Ptr;
447447 }
448448 };
6969 /// @{
7070
7171 /// Construct an empty string ref.
72 /*implicit*/ StringRef() : Data(0), Length(0) {}
72 /*implicit*/ StringRef() : Data(nullptr), Length(0) {}
7373
7474 /// Construct a string ref from a cstring.
7575 /*implicit*/ StringRef(const char *Str)
185185
186186 /// str - Get the contents as an std::string.
187187 std::string str() const {
188 if (Data == 0) return std::string();
188 if (Data == nullptr) return std::string();
189189 return std::string(Data, Length);
190190 }
191191
4848
4949 public:
5050 explicit StringSwitch(StringRef S)
51 : Str(S), Result(0) { }
51 : Str(S), Result(nullptr) { }
5252
5353 template
5454 StringSwitch& Case(const char (&S)[N], const T& Value) {
373373 static Twine utohexstr(const uint64_t &Val) {
374374 Child LHS, RHS;
375375 LHS.uHex = &Val;
376 RHS.twine = 0;
376 RHS.twine = nullptr;
377377 return Twine(LHS, UHexKind, RHS, EmptyKind);
378378 }
379379
174174
175175 ilist_iterator(pointer NP) : NodePtr(NP) {}
176176 ilist_iterator(reference NR) : NodePtr(&NR) {}
177 ilist_iterator() : NodePtr(0) {}
177 ilist_iterator() : NodePtr(nullptr) {}
178178
179179 // This is templated so that we can allow constructing a const iterator from
180180 // a nonconst iterator...
382382 // Miscellaneous inspection routines.
383383 size_type max_size() const { return size_type(-1); }
384384 bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const {
385 return Head == 0 || Head == getTail();
385 return Head == nullptr || Head == getTail();
386386 }
387387
388388 // Front and back accessor functions...
450450 // an ilist (and potentially deleted) with iterators still pointing at it.
451451 // When those iterators are incremented or decremented, they will assert on
452452 // the null next/prev pointer instead of "usually working".
453 this->setNext(Node, 0);
454 this->setPrev(Node, 0);
453 this->setNext(Node, nullptr);
454 this->setPrev(Node, nullptr);
455455 return Node;
456456 }
457457
2929 NodeTy *getPrev() { return Prev; }
3030 const NodeTy *getPrev() const { return Prev; }
3131 void setPrev(NodeTy *P) { Prev = P; }
32 ilist_half_node() : Prev(0) {}
32 ilist_half_node() : Prev(nullptr) {}
3333 };
3434
3535 template
4747 const NodeTy *getNext() const { return Next; }
4848 void setNext(NodeTy *N) { Next = N; }
4949 protected:
50 ilist_node() : Next(0) {}
50 ilist_node() : Next(nullptr) {}
5151
5252 public:
5353 /// @name Adjacent Node Accessors
105105 /// Used so that we can compute how much space was wasted.
106106 size_t BytesAllocated;
107107
108 BumpPtrAllocatorBase() : CurSlab(0), BytesAllocated(0) {}
108 BumpPtrAllocatorBase() : CurSlab(nullptr), BytesAllocated(0) {}
109109 };
110110
111111 /// \brief Allocate memory in an ever growing pool, as if by bump-pointer.
141141 if (!CurSlab)
142142 return;
143143 DeallocateSlabs(CurSlab->NextPtr);
144 CurSlab->NextPtr = 0;
144 CurSlab->NextPtr = nullptr;
145145 CurPtr = (char *)(CurSlab + 1);
146146 End = ((char *)CurSlab) + CurSlab->Size;
147147 BytesAllocated = 0;
274274 template
275275 LLVM_ATTRIBUTE_UNUSED_RESULT inline typename cast_retty::ret_type
276276 dyn_cast(Y *Val) {
277 return isa(Val) ? cast(Val) : 0;
277 return isa(Val) ? cast(Val) : nullptr;
278278 }
279279
280280 // dyn_cast_or_null - Functionally identical to dyn_cast, except that a null
283283 template
284284 LLVM_ATTRIBUTE_UNUSED_RESULT inline typename cast_retty::ret_type
285285 dyn_cast_or_null(Y *Val) {
286 return (Val && isa(Val)) ? cast(Val) : 0;
286 return (Val && isa(Val)) ? cast(Val) : nullptr;
287287 }
288288
289289 } // End llvm namespace
4040 // ParseCommandLineOptions - Command line option processing entry point.
4141 //
4242 void ParseCommandLineOptions(int argc, const char * const *argv,
43 const char *Overview = 0);
43 const char *Overview = nullptr);
4444
4545 //===----------------------------------------------------------------------===//
4646 // ParseEnvironmentOptions - Environment variable option processing alternate
4747 // entry point.
4848 //
4949 void ParseEnvironmentOptions(const char *progName, const char *envvar,
50 const char *Overview = 0);
50 const char *Overview = nullptr);
5151
5252 ///===---------------------------------------------------------------------===//
5353 /// SetVersionPrinter - Override the default (LLVM specific) version printer
145145 const char *const Description;
146146 void registerCategory();
147147 public:
148 OptionCategory(const char *const Name, const char *const Description = 0)
148 OptionCategory(const char *const Name, const char *const Description = nullptr)
149149 : Name(Name), Description(Description) { registerCategory(); }
150150 const char *getName() const { return Name; }
151151 const char *getDescription() const { return Description; }
237237 enum OptionHidden Hidden)
238238 : NumOccurrences(0), Occurrences(OccurrencesFlag), Value(0),
239239 HiddenFlag(Hidden), Formatting(NormalFormatting), Misc(0),
240 Position(0), AdditionalVals(0), NextRegistered(0),
240 Position(0), AdditionalVals(0), NextRegistered(nullptr),
241241 ArgStr(""), HelpStr(""), ValueStr(""), Category(&GeneralCategory) {
242242 }
243243
762762 }
763763
764764 // getValueName - Do not print = at all.
765 const char *getValueName() const override { return 0; }
765 const char *getValueName() const override { return nullptr; }
766766
767767 void printOptionDiff(const Option &O, bool V, OptVal Default,
768768 size_t GlobalWidth) const;
786786 }
787787
788788 // getValueName - Do not print = at all.
789 const char *getValueName() const override { return 0; }
789 const char *getValueName() const override { return nullptr; }
790790
791791 void printOptionDiff(const Option &O, boolOrDefault V, OptVal Default,
792792 size_t GlobalWidth) const;
10671067 "or cl::init specified before cl::location()!!");
10681068 }
10691069 public:
1070 opt_storage() : Location(0) {}
1070 opt_storage() : Location(nullptr) {}
10711071
10721072 bool setLocation(Option &O, DataType &L) {
10731073 if (Location)
14681468 }
14691469
14701470 public:
1471 bits_storage() : Location(0) {}
1471 bits_storage() : Location(nullptr) {}
14721472
14731473 bool setLocation(Option &O, unsigned &L) {
14741474 if (Location)
16631663 void done() {
16641664 if (!hasArgStr())
16651665 error("cl::alias must have argument name specified!");
1666 if (AliasFor == 0)
1666 if (AliasFor == nullptr)
16671667 error("cl::alias must have an cl::aliasopt(option) specified!");
16681668 addArgument();
16691669 }
16761676
16771677 // One option...
16781678 template
1679 explicit alias(const M0t &M0) : Option(Optional, Hidden), AliasFor(0) {
1679 explicit alias(const M0t &M0) : Option(Optional, Hidden), AliasFor(nullptr) {
16801680 apply(M0, this);
16811681 done();
16821682 }
16831683 // Two options...
16841684 template
1685 alias(const M0t &M0, const M1t &M1) : Option(Optional, Hidden), AliasFor(0) {
1685 alias(const M0t &M0, const M1t &M1)
1686 : Option(Optional, Hidden), AliasFor(nullptr) {
16861687 apply(M0, this); apply(M1, this);
16871688 done();
16881689 }
16891690 // Three options...
16901691 template
16911692 alias(const M0t &M0, const M1t &M1, const M2t &M2)
1692 : Option(Optional, Hidden), AliasFor(0) {
1693 : Option(Optional, Hidden), AliasFor(nullptr) {
16931694 apply(M0, this); apply(M1, this); apply(M2, this);
16941695 done();
16951696 }
16961697 // Four options...
16971698 template
16981699 alias(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3)
1699 : Option(Optional, Hidden), AliasFor(0) {
1700 : Option(Optional, Hidden), AliasFor(nullptr) {
17001701 apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this);
17011702 done();
17021703 }
5757 };
5858
5959 public:
60 CrashRecoveryContext() : Impl(0), head(0) {}
60 CrashRecoveryContext() : Impl(nullptr), head(nullptr) {}
6161 ~CrashRecoveryContext();
6262
6363 void registerCleanup(CrashRecoveryContextCleanup *cleanup);
6464 /// It is safe to call this function multiple times for the same library.
6565 /// @brief Open a dynamic library permanently.
6666 static DynamicLibrary getPermanentLibrary(const char *filename,
67 std::string *errMsg = 0);
67 std::string *errMsg = nullptr);
6868
6969 /// This function permanently loads the dynamic library at the given path.
7070 /// Use this instead of getPermanentLibrary() when you won't need to get
7272 ///
7373 /// It is safe to call this function multiple times for the same library.
7474 static bool LoadLibraryPermanently(const char *Filename,
75 std::string *ErrMsg = 0) {
75 std::string *ErrMsg = nullptr) {
7676 return !getPermanentLibrary(Filename, ErrMsg).isValid();
7777 }
7878
4646 /// \param user_data - An argument which will be passed to the install error
4747 /// handler.
4848 void install_fatal_error_handler(fatal_error_handler_t handler,
49 void *user_data = 0);
49 void *user_data = nullptr);
5050
5151 /// Restores default error handling behaviour.
5252 /// This must not be called between llvm_start_multithreaded() and
5858 /// remove_fatal_error_handler in its destructor.
5959 struct ScopedFatalErrorHandler {
6060 explicit ScopedFatalErrorHandler(fatal_error_handler_t handler,
61 void *user_data = 0) {
61 void *user_data = nullptr) {
6262 install_fatal_error_handler(handler, user_data);
6363 }
6464
8585 /// This function calls abort(), and prints the optional message to stderr.
8686 /// Use the llvm_unreachable macro (that adds location info), instead of
8787 /// calling this function directly.
88 LLVM_ATTRIBUTE_NORETURN void llvm_unreachable_internal(const char *msg=0,
89 const char *file=0,
90 unsigned line=0);
88 LLVM_ATTRIBUTE_NORETURN void
89 llvm_unreachable_internal(const char *msg=nullptr, const char *file=nullptr,
90 unsigned line=0);
9191 }
9292
9393 /// Marks that the current location is not supposed to be reachable.
813813 }
814814
815815 /// Construct end iterator.
816 directory_iterator() : State(0) {}
816 directory_iterator() : State(nullptr) {}
817817
818818 // No operator++ because we need error_code.
819819 directory_iterator &increment(error_code &ec) {
827827 bool operator==(const directory_iterator &RHS) const {
828828 if (State == RHS.State)
829829 return true;
830 if (RHS.State == 0)
830 if (RHS.State == nullptr)
831831 return State->CurrentEntry == directory_entry();
832 if (State == 0)
832 if (State == nullptr)
833833 return RHS.State->CurrentEntry == directory_entry();
834834 return State->CurrentEntry == RHS.State->CurrentEntry;
835835 }
2929 int DiffFilesWithTolerance(StringRef FileA,
3030 StringRef FileB,
3131 double AbsTol, double RelTol,
32 std::string *Error = 0);
32 std::string *Error = nullptr);
3333
3434
3535 /// FileRemover - This class is a simple object meant to be stack allocated.
8484 /// underneath it.
8585 ///
8686 formatted_raw_ostream(raw_ostream &Stream, bool Delete = false)
87 : raw_ostream(), TheStream(0), DeleteStream(false), Position(0, 0) {
87 : raw_ostream(), TheStream(nullptr), DeleteStream(false), Position(0, 0) {
8888 setStream(Stream, Delete);
8989 }
9090 explicit formatted_raw_ostream()
91 : raw_ostream(), TheStream(0), DeleteStream(false), Position(0, 0) {
92 Scanned = 0;
91 : raw_ostream(), TheStream(nullptr), DeleteStream(false), Position(0, 0) {
92 Scanned = nullptr;
9393 }
9494
9595 ~formatted_raw_ostream() {
113113 SetUnbuffered();
114114 TheStream->SetUnbuffered();
115115
116 Scanned = 0;
116 Scanned = nullptr;
117117 }
118118
119119 /// PadToColumn - Align the output to some column number. If the current
258258
259259 /// emitSimpleNode - Outputs a simple (non-record) node
260260 void emitSimpleNode(const void *ID, const std::string &Attr,
261 const std::string &Label, unsigned NumEdgeSources = 0,
262 const std::vector *EdgeSourceLabels = 0) {
261 const std::string &Label, unsigned NumEdgeSources = 0,
262 const std::vector *EdgeSourceLabels = nullptr) {
263263 O << "\tNode" << ID << "[ ";
264264 if (!Attr.empty())
265265 O << Attr << ",";
7676
7777
7878 /// Utility function to decode a ULEB128 value.
79 inline uint64_t decodeULEB128(const uint8_t *p, unsigned *n = 0) {
79 inline uint64_t decodeULEB128(const uint8_t *p, unsigned *n = nullptr) {
8080 const uint8_t *orig_p = p;
8181 uint64_t Value = 0;
8282 unsigned Shift = 0;
3636
3737 public:
3838 /// \brief Default construct an "end" iterator.
39 line_iterator() : Buffer(0) {}
39 line_iterator() : Buffer(nullptr) {}
4040
4141 /// \brief Construct a new iterator around some memory buffer.
4242 explicit line_iterator(const MemoryBuffer &Buffer, char CommentMarker = '\0');
4646 void RegisterManagedStatic(void *(*creator)(), void (*deleter)(void*)) const;
4747 public:
4848 /// isConstructed - Return true if this object has not been created yet.
49 bool isConstructed() const { return Ptr != 0; }
49 bool isConstructed() const { return Ptr != nullptr; }
5050
5151 void destroy() const;
5252 };
2727 /// @brief Memory block abstraction.
2828 class MemoryBlock {
2929 public:
30 MemoryBlock() : Address(0), Size(0) { }
30 MemoryBlock() : Address(nullptr), Size(0) { }
3131 MemoryBlock(void *addr, size_t size) : Address(addr), Size(size) { }
3232 void *base() const { return Address; }
3333 size_t size() const { return Size; }
119119 /// @brief Allocate Read/Write/Execute memory.
120120 static MemoryBlock AllocateRWX(size_t NumBytes,
121121 const MemoryBlock *NearBlock,
122 std::string *ErrMsg = 0);
122 std::string *ErrMsg = nullptr);
123123
124124 /// This method releases a block of Read/Write/Execute memory that was
125125 /// allocated with the AllocateRWX method. It should not be used to
128128 /// On success, this returns false, otherwise it returns true and fills
129129 /// in *ErrMsg.
130130 /// @brief Release Read/Write/Execute memory.
131 static bool ReleaseRWX(MemoryBlock &block, std::string *ErrMsg = 0);
131 static bool ReleaseRWX(MemoryBlock &block, std::string *ErrMsg = nullptr);
132132
133133
134134 /// InvalidateInstructionCache - Before the JIT can run a block of code
139139 /// setExecutable - Before the JIT can run a block of code, it has to be
140140 /// given read and executable privilege. Return true if it is already r-x
141141 /// or the system is able to change its previlege.
142 static bool setExecutable(MemoryBlock &M, std::string *ErrMsg = 0);
142 static bool setExecutable(MemoryBlock &M, std::string *ErrMsg = nullptr);
143143
144144 /// setWritable - When adding to a block of code, the JIT may need
145145 /// to mark a block of code as RW since the protections are on page
146146 /// boundaries, and the JIT internal allocations are not page aligned.
147 static bool setWritable(MemoryBlock &M, std::string *ErrMsg = 0);
147 static bool setWritable(MemoryBlock &M, std::string *ErrMsg = nullptr);
148148
149149 /// setRangeExecutable - Mark the page containing a range of addresses
150150 /// as executable.
8686 const char **args, ///< A vector of strings that are passed to the
8787 ///< program. The first element should be the name of the program.
8888 ///< The list *must* be terminated by a null char* entry.
89 const char **env = 0, ///< An optional vector of strings to use for
89 const char **env = nullptr, ///< An optional vector of strings to use for
9090 ///< the program's environment. If not provided, the current program's
9191 ///< environment will be used.
92 const StringRef **redirects = 0, ///< An optional array of pointers to
93 ///< paths. If the array is null, no redirection is done. The array
92 const StringRef **redirects = nullptr, ///< An optional array of pointers
93 ///< to paths. If the array is null, no redirection is done. The array
9494 ///< should have a size of at least three. The inferior process's
9595 ///< stdin(0), stdout(1), and stderr(2) will be redirected to the
9696 ///< corresponding paths.
106106 ///< of memory can be allocated by process. If memory usage will be
107107 ///< higher limit, the child is killed and this call returns. If zero
108108 ///< - no memory limit.
109 std::string *ErrMsg = 0, ///< If non-zero, provides a pointer to a string
110 ///< instance in which error messages will be returned. If the string
111 ///< is non-empty upon return an error occurred while invoking the
109 std::string *ErrMsg = nullptr, ///< If non-zero, provides a pointer to a
110 ///< string instance in which error messages will be returned. If the
111 ///< string is non-empty upon return an error occurred while invoking the
112112 ///< program.
113 bool *ExecutionFailed = 0);
113 bool *ExecutionFailed = nullptr);
114114
115115 /// Similar to ExecuteAndWait, but returns immediately.
116116 /// @returns The \see ProcessInfo of the newly launced process.
118118 /// Wait until the process finished execution or win32 CloseHandle() API on
119119 /// ProcessInfo.ProcessHandle to avoid memory leaks.
120120 ProcessInfo
121 ExecuteNoWait(StringRef Program, const char **args, const char **env = 0,
122 const StringRef **redirects = 0, unsigned memoryLimit = 0,
123 std::string *ErrMsg = 0, bool *ExecutionFailed = 0);
121 ExecuteNoWait(StringRef Program, const char **args, const char **env = nullptr,
122 const StringRef **redirects = nullptr, unsigned memoryLimit = 0,
123 std::string *ErrMsg = nullptr, bool *ExecutionFailed = nullptr);
124124
125125 /// Return true if the given arguments fit within system-specific
126126 /// argument length limits.
141141 ///< will perform a non-blocking wait on the child process.
142142 bool WaitUntilTerminates, ///< If true, ignores \p SecondsToWait and waits
143143 ///< until child has terminated.
144 std::string *ErrMsg = 0 ///< If non-zero, provides a pointer to a string
145 ///< instance in which error messages will be returned. If the string
146 ///< is non-empty upon return an error occurred while invoking the
144 std::string *ErrMsg = nullptr ///< If non-zero, provides a pointer to a
145 ///< string instance in which error messages will be returned. If the
146 ///< string is non-empty upon return an error occurred while invoking the
147147 ///< program.
148148 );
149149 }
5454 Regex(Regex &®ex) {
5555 preg = regex.preg;
5656 error = regex.error;
57 regex.preg = NULL;
57 regex.preg = nullptr;
5858 }
5959 ~Regex();
6060
7474 /// the first group is always the entire pattern.
7575 ///
7676 /// This returns true on a successful match.
77 bool match(StringRef String, SmallVectorImpl *Matches = 0);
77 bool match(StringRef String, SmallVectorImpl *Matches = nullptr);
7878
7979 /// sub - Return the result of replacing the first match of the regex in
8080 /// \p String with the \p Repl string. Backreferences like "\0" in the
8686 /// \param Error If non-null, any errors in the substitution (invalid
8787 /// backreferences, trailing backslashes) will be recorded as a non-empty
8888 /// string.
89 std::string sub(StringRef Repl, StringRef String, std::string *Error = 0);
89 std::string sub(StringRef Repl, StringRef String,
90 std::string *Error = nullptr);
9091
9192 /// \brief If this function returns true, ^Str$ is an extended regular
9293 /// expression that matches Str and only Str.
2222 class SMLoc {
2323 const char *Ptr;
2424 public:
25 SMLoc() : Ptr(0) {}
25 SMLoc() : Ptr(nullptr) {}
2626
27 bool isValid() const { return Ptr != 0; }
27 bool isValid() const { return Ptr != nullptr; }
2828
2929 bool operator==(const SMLoc &RHS) const { return RHS.Ptr == Ptr; }
3030 bool operator!=(const SMLoc &RHS) const { return RHS.Ptr != Ptr; }
2727 /// This function registers signal handlers to ensure that if a signal gets
2828 /// delivered that the named file is removed.
2929 /// @brief Remove a file if a fatal signal occurs.
30 bool RemoveFileOnSignal(StringRef Filename, std::string* ErrMsg = 0);
30 bool RemoveFileOnSignal(StringRef Filename, std::string* ErrMsg = nullptr);
3131
3232 /// This function removes a file from the list of files to be removed on
3333 /// signal delivery.
7070 SourceMgr(const SourceMgr&) LLVM_DELETED_FUNCTION;
7171 void operator=(const SourceMgr&) LLVM_DELETED_FUNCTION;
7272 public:
73 SourceMgr() : LineNoCache(0), DiagHandler(0), DiagContext(0) {}
73 SourceMgr()
74 : LineNoCache(nullptr), DiagHandler(nullptr), DiagContext(nullptr) {}
7475 ~SourceMgr();
7576
7677 void setIncludeDirs(const std::vector &Dirs) {
7980
8081 /// setDiagHandler - Specify a diagnostic handler to be invoked every time
8182 /// PrintMessage is called. Ctx is passed into the handler when it is invoked.
82 void setDiagHandler(DiagHandlerTy DH, void *Ctx = 0) {
83 void setDiagHandler(DiagHandlerTy DH, void *Ctx = nullptr) {
8384 DiagHandler = DH;
8485 DiagContext = Ctx;
8586 }
221222 public:
222223 // Null diagnostic.
223224 SMDiagnostic()
224 : SM(0), LineNo(0), ColumnNo(0), Kind(SourceMgr::DK_Error) {}
225 : SM(nullptr), LineNo(0), ColumnNo(0), Kind(SourceMgr::DK_Error) {}
225226 // Diagnostic with no location (e.g. file not found, command line arg error).
226227 SMDiagnostic(StringRef filename, SourceMgr::DiagKind Knd, StringRef Msg)
227 : SM(0), Filename(filename), LineNo(-1), ColumnNo(-1), Kind(Knd),
228 : SM(nullptr), Filename(filename), LineNo(-1), ColumnNo(-1), Kind(Knd),
228229 Message(Msg) {}
229230
230231 // Diagnostic with a location.
115115 // the memory doesn't go away/get reallocated, but it's
116116 // not currently necessary. Users that need the pointer don't stream.
117117 assert(0 && "getPointer in streaming memory objects not allowed");
118 return NULL;
118 return nullptr;
119119 }
120120 bool isValidAddress(uint64_t address) const override;
121121 bool isObjectEnd(uint64_t address) const override;
4747 unsigned Refcount; ///< Number of referencing PooledStringPtrs.
4848
4949 public:
50 PooledString() : Pool(0), Refcount(0) { }
50 PooledString() : Pool(nullptr), Refcount(0) { }
5151 };
5252
5353 friend class PooledStringPtr;
8080 entry_t *S;
8181
8282 public:
83 PooledStringPtr() : S(0) {}
83 PooledStringPtr() : S(nullptr) {}
8484
8585 explicit PooledStringPtr(entry_t *E) : S(E) {
8686 if (S) ++S->getValue().Refcount;
106106 S->getValue().Pool->InternTable.remove(S);
107107 S->Destroy();
108108 }
109 S = 0;
109 S = nullptr;
110110 }
111111
112112 ~PooledStringPtr() { clear(); }
127127 }
128128
129129 inline const char *operator*() const { return begin(); }
130 inline operator bool() const { return S != 0; }
130 inline operator bool() const { return S != nullptr; }
131131
132132 inline bool operator==(const PooledStringPtr &That) { return S == That.S; }
133133 inline bool operator!=(const PooledStringPtr &That) { return S != That.S; }
232232
233233 public:
234234 Target()
235 : AsmStreamerCtorFn(0), MCRelocationInfoCtorFn(0),
236 MCSymbolizerCtorFn(0) {}
235 : AsmStreamerCtorFn(nullptr), MCRelocationInfoCtorFn(nullptr),
236 MCSymbolizerCtorFn(nullptr) {}
237237
238238 /// @name Target Information
239239 /// @{
255255 bool hasJIT() const { return HasJIT; }
256256
257257 /// hasTargetMachine - Check if this target supports code generation.
258 bool hasTargetMachine() const { return TargetMachineCtorFn != 0; }
258 bool hasTargetMachine() const { return TargetMachineCtorFn != nullptr; }
259259
260260 /// hasMCAsmBackend - Check if this target supports .o generation.
261 bool hasMCAsmBackend() const { return MCAsmBackendCtorFn != 0; }
261 bool hasMCAsmBackend() const { return MCAsmBackendCtorFn != nullptr; }
262262
263263 /// @}
264264 /// @name Feature Constructors
274274 MCAsmInfo *createMCAsmInfo(const MCRegisterInfo &MRI,
275275 StringRef Triple) const {
276276 if (!MCAsmInfoCtorFn)
277 return 0;
277 return nullptr;
278278 return MCAsmInfoCtorFn(MRI, Triple);
279279 }
280280
284284 CodeModel::Model CM,
285285 CodeGenOpt::Level OL) const {
286286 if (!MCCodeGenInfoCtorFn)
287 return 0;
287 return nullptr;
288288 return MCCodeGenInfoCtorFn(Triple, RM, CM, OL);
289289 }
290290
292292 ///
293293 MCInstrInfo *createMCInstrInfo() const {
294294 if (!MCInstrInfoCtorFn)
295 return 0;
295 return nullptr;
296296 return MCInstrInfoCtorFn();
297297 }
298298
300300 ///
301301 MCInstrAnalysis *createMCInstrAnalysis(const MCInstrInfo *Info) const {
302302 if (!MCInstrAnalysisCtorFn)
303 return 0;
303 return nullptr;
304304 return MCInstrAnalysisCtorFn(Info);
305305 }
306306
308308 ///
309309 MCRegisterInfo *createMCRegInfo(StringRef Triple) const {
310310 if (!MCRegInfoCtorFn)
311 return 0;
311 return nullptr;
312312 return MCRegInfoCtorFn(Triple);
313313 }
314314
324324 MCSubtargetInfo *createMCSubtargetInfo(StringRef Triple, StringRef CPU,
325325 StringRef Features) const {
326326 if (!MCSubtargetInfoCtorFn)
327 return 0;
327 return nullptr;
328328 return MCSubtargetInfoCtorFn(Triple, CPU, Features);
329329 }
330330
341341 CodeModel::Model CM = CodeModel::Default,
342342 CodeGenOpt::Level OL = CodeGenOpt::Default) const {
343343 if (!TargetMachineCtorFn)
344 return 0;
344 return nullptr;
345345 return TargetMachineCtorFn(*this, Triple, CPU, Features, Options,
346346 RM, CM, OL);
347347 }
352352 MCAsmBackend *createMCAsmBackend(const MCRegisterInfo &MRI,
353353 StringRef Triple, StringRef CPU) const {
354354 if (!MCAsmBackendCtorFn)
355 return 0;
355 return nullptr;
356356 return MCAsmBackendCtorFn(*this, MRI, Triple, CPU);
357357 }
358358
364364 MCAsmParser &Parser,
365365 const MCInstrInfo &MII) const {
366366 if (!MCAsmParserCtorFn)
367 return 0;
367 return nullptr;
368368 return MCAsmParserCtorFn(STI, Parser, MII);
369369 }
370370
372372 /// takes ownership of the MCStreamer object.
373373 AsmPrinter *createAsmPrinter(TargetMachine &TM, MCStreamer &Streamer) const{
374374 if (!AsmPrinterCtorFn)
375 return 0;
375 return nullptr;
376376 return AsmPrinterCtorFn(TM, Streamer);
377377 }
378378
379379 MCDisassembler *createMCDisassembler(const MCSubtargetInfo &STI) const {
380380 if (!MCDisassemblerCtorFn)
381 return 0;
381 return nullptr;
382382 return MCDisassemblerCtorFn(*this, STI);
383383 }
384384
388388 const MCRegisterInfo &MRI,
389389 const MCSubtargetInfo &STI) const {
390390 if (!MCInstPrinterCtorFn)
391 return 0;
391 return nullptr;
392392 return MCInstPrinterCtorFn(*this, SyntaxVariant, MAI, MII, MRI, STI);
393393 }
394394
399399 const MCSubtargetInfo &STI,
400400 MCContext &Ctx) const {
401401 if (!MCCodeEmitterCtorFn)
402 return 0;
402 return nullptr;
403403 return MCCodeEmitterCtorFn(II, MRI, STI, Ctx);
404404 }
405405
420420 bool RelaxAll,
421421 bool NoExecStack) const {
422422 if (!MCObjectStreamerCtorFn)
423 return 0;
423 return nullptr;
424424 return MCObjectStreamerCtorFn(*this, TT, Ctx, TAB, _OS, _Emitter, STI,
425425 RelaxAll, NoExecStack);
426426 }
485485 explicit iterator(Target *T) : Current(T) {}
486486 friend struct TargetRegistry;
487487 public:
488 iterator() : Current(0) {}
488 iterator() : Current(nullptr) {}
489489
490490 bool operator==(const iterator &x) const {
491491 return Current == x.Current;
8484
8585 Timer **Prev, *Next; // Doubly linked list of timers in the group.
8686 public:
87 explicit Timer(StringRef N) : TG(0) { init(N); }
88 Timer(StringRef N, TimerGroup &tg) : TG(0) { init(N, tg); }
89 Timer(const Timer &RHS) : TG(0) {
87 explicit Timer(StringRef N) : TG(nullptr) { init(N); }
88 Timer(StringRef N, TimerGroup &tg) : TG(nullptr) { init(N, tg); }
89 Timer(const Timer &RHS) : TG(nullptr) {
9090 assert(RHS.TG == 0 && "Can only copy uninitialized timers");
9191 }
9292 const Timer &operator=(const Timer &T) {
9696 ~Timer();
9797
9898 // Create an uninitialized timer, client must use 'init'.
99 explicit Timer() : TG(0) {}
99 explicit Timer() : TG(nullptr) {}
100100 void init(StringRef N);
101101 void init(StringRef N, TimerGroup &tg);
102102
103103 const std::string &getName() const { return Name; }
104 bool isInitialized() const { return TG != 0; }
104 bool isInitialized() const { return TG != nullptr; }
105105
106106 /// startTimer - Start the timer running. Time between calls to
107107 /// startTimer/stopTimer is counted by the Timer class. Note that these calls
234234 void anchor() override;
235235 public:
236236 KeyValueNode(std::unique_ptr &D)
237 : Node(NK_KeyValue, D, StringRef(), StringRef()), Key(0), Value(0) {}
237 : Node(NK_KeyValue, D, StringRef(), StringRef()), Key(nullptr),
238 Value(nullptr) {}
238239
239240 /// @brief Parse and return the key.
240241 ///
273274 class basic_collection_iterator
274275 : public std::iterator {
275276 public:
276 basic_collection_iterator() : Base(0) {}
277 basic_collection_iterator() : Base(nullptr) {}
277278 basic_collection_iterator(BaseT *B) : Base(B) {}
278279
279280 ValueT *operator ->() const {
303304 assert(Base && "Attempted to advance iterator past end!");
304305 Base->increment();
305306 // Create an end iterator.
306 if (Base->CurrentEntry == 0)
307 Base = 0;
307 if (Base->CurrentEntry == nullptr)
308 Base = nullptr;
308309 return *this;
309310 }
310311
351352 MappingNode(std::unique_ptr &D, StringRef Anchor, StringRef Tag,
352353 MappingType MT)
353354 : Node(NK_Mapping, D, Anchor, Tag), Type(MT), IsAtBeginning(true),
354 IsAtEnd(false), CurrentEntry(0) {}
355 IsAtEnd(false), CurrentEntry(nullptr) {}
355356
356357 friend class basic_collection_iterator;
357358 typedef basic_collection_iterator iterator;
410411 : Node(NK_Sequence, D, Anchor, Tag), SeqType(ST), IsAtBeginning(true),
411412 IsAtEnd(false),
412413 WasPreviousTokenFlowEntry(true), // Start with an imaginary ','.
413 CurrentEntry(0) {}
414 CurrentEntry(nullptr) {}
414415
415416 friend class basic_collection_iterator;
416417 typedef basic_collection_iterator iterator;
525526 /// @brief Iterator abstraction for Documents over a Stream.
526527 class document_iterator {
527528 public:
528 document_iterator() : Doc(0) {}
529 document_iterator() : Doc(nullptr) {}
529530 document_iterator(std::unique_ptr &D) : Doc(&D) {}
530531
531532 bool operator ==(const document_iterator &Other) {
541542 document_iterator operator ++() {
542543 assert(Doc != 0 && "incrementing iterator past the end.");
543544 if (!(*Doc)->skip()) {
544 Doc->reset(0);
545 Doc->reset(nullptr);
545546 } else {
546547 Stream &S = (*Doc)->stream;
547548 Doc->reset(new Document(S));
206206 static double test(...);
207207
208208 public:
209 static bool const value = (sizeof(test >(0,0)) == 1);
209 static bool const value =
210 (sizeof(test >(nullptr,nullptr)) == 1);
210211 };
211212
212213
339340 class IO {
340341 public:
341342
342 IO(void *Ctxt=NULL);
343 IO(void *Ctxt=nullptr);
343344 virtual ~IO();
344345
345346 virtual bool outputting() = 0;
764765 // user-data. The DiagHandler can be specified to provide
765766 // alternative error reporting.
766767 Input(StringRef InputContent,
767 void *Ctxt = NULL,
768 SourceMgr::DiagHandlerTy DiagHandler = NULL,
769 void *DiagHandlerCtxt = NULL);
768 void *Ctxt = nullptr,
769 SourceMgr::DiagHandlerTy DiagHandler = nullptr,
770 void *DiagHandlerCtxt = nullptr);
770771 ~Input();
771772
772773 // Check if there was an syntax or semantic error during parsing.
895896 ///
896897 class Output : public IO {
897898 public:
898 Output(llvm::raw_ostream &, void *Ctxt=NULL);
899 Output(llvm::raw_ostream &, void *Ctxt=nullptr);
899900 virtual ~Output();
900901
901902 bool outputting() override;
108108 circular_raw_ostream(raw_ostream &Stream, const char *Header,
109109 size_t BuffSize = 0, bool Owns = REFERENCE_ONLY)
110110 : raw_ostream(/*unbuffered*/true),
111 TheStream(0),
111 TheStream(nullptr),
112112 OwnsStream(Owns),
113113 BufferSize(BuffSize),
114 BufferArray(0),
114 BufferArray(nullptr),
115115 Filled(false),
116116 Banner(Header) {
117117 if (BufferSize != 0)
121121 }
122122 explicit circular_raw_ostream()
123123 : raw_ostream(/*unbuffered*/true),
124 TheStream(0),
124 TheStream(nullptr),
125125 OwnsStream(REFERENCE_ONLY),
126 BufferArray(0),
126 BufferArray(nullptr),
127127 Filled(false),
128128 Banner("") {
129129 Cur = BufferArray;
7575 explicit raw_ostream(bool unbuffered=false)
7676 : BufferMode(unbuffered ? Unbuffered : InternalBuffer) {
7777 // Start out ready to flush.
78 OutBufStart = OutBufEnd = OutBufCur = 0;
78 OutBufStart = OutBufEnd = OutBufCur = nullptr;
7979 }
8080
8181 virtual ~raw_ostream();
101101 size_t GetBufferSize() const {
102102 // If we're supposed to be buffered but haven't actually gotten around
103103 // to allocating the buffer yet, return the value that would be used.
104 if (BufferMode != Unbuffered && OutBufStart == 0)
104 if (BufferMode != Unbuffered && OutBufStart == nullptr)
105105 return preferred_buffer_size();
106106
107107 // Otherwise just return the size of the allocated buffer.
114114 /// set to unbuffered.
115115 void SetUnbuffered() {
116116 flush();
117 SetBufferAndMode(0, 0, Unbuffered);
117 SetBufferAndMode(nullptr, 0, Unbuffered);
118118 }
119119
120120 size_t GetNumBytesInBuffer() const {
705705 static void unspecified_bool_true() {}
706706
707707 operator unspecified_bool_type() const { // true if error
708 return _val_ == 0 ? 0 : unspecified_bool_true;
708 return _val_ == 0 ? nullptr : unspecified_bool_true;
709709 }
710710 };
711711
770770 static void unspecified_bool_true() {}
771771
772772 operator unspecified_bool_type() const { // true if error
773 return _val_ == 0 ? 0 : unspecified_bool_true;
773 return _val_ == 0 ? nullptr : unspecified_bool_true;
774774 }
775775 };
776776
16781678 fs = multiplySpecials(rhs);
16791679
16801680 if (isFiniteNonZero()) {
1681 lostFraction lost_fraction = multiplySignificand(rhs, 0);
1681 lostFraction lost_fraction = multiplySignificand(rhs, nullptr);
16821682 fs = normalize(rounding_mode, lost_fraction);
16831683 if (lost_fraction != lfExactlyZero)
16841684 fs = (opStatus) (fs | opInexact);
24382438
24392439 if (exp >= 0) {
24402440 /* multiplySignificand leaves the precision-th bit set to 1. */
2441 calcLostFraction = decSig.multiplySignificand(pow5, NULL);
2441 calcLostFraction = decSig.multiplySignificand(pow5, nullptr);
24422442 powHUerr = powStatus != opOK;
24432443 } else {
24442444 calcLostFraction = decSig.divideSignificand(pow5);
37943794 if (isSignaling()) {
37953795 result = opInvalidOp;
37963796 // For consistency, propagate the sign of the sNaN to the qNaN.
3797 makeNaN(false, isNegative(), 0);
3797 makeNaN(false, isNegative(), nullptr);
37983798 }
37993799 break;
38003800 case fcZero:
16821682 // Allocate space for the temporary values we need either on the stack, if
16831683 // it will fit, or on the heap if it won't.
16841684 unsigned SPACE[128];
1685 unsigned *U = 0;
1686 unsigned *V = 0;
1687 unsigned *Q = 0;
1688 unsigned *R = 0;
1685 unsigned *U = nullptr;
1686 unsigned *V = nullptr;
1687 unsigned *Q = nullptr;
1688 unsigned *R = nullptr;
16891689 if ((Remainder?4:3)*n+2*m+1 <= 128) {
16901690 U = &SPACE[0];
16911691 V = &SPACE[m+n+1];
18711871
18721872 // We have to compute it the hard way. Invoke the Knuth divide algorithm.
18731873 APInt Quotient(1,0); // to hold result.
1874 divide(*this, lhsWords, RHS, rhsWords, &Quotient, 0);
1874 divide(*this, lhsWords, RHS, rhsWords, &Quotient, nullptr);
18751875 return Quotient;
18761876 }
18771877
19191919
19201920 // We have to compute it the hard way. Invoke the Knuth divide algorithm.
19211921 APInt Remainder(1,0);
1922 divide(*this, lhsWords, RHS, rhsWords, 0, &Remainder);
1922 divide(*this, lhsWords, RHS, rhsWords, nullptr, &Remainder);
19231923 return Remainder;
19241924 }
19251925
2727 MemSlab *MallocSlabAllocator::Allocate(size_t Size) {
2828 MemSlab *Slab = (MemSlab*)Allocator.Allocate(Size, 0);
2929 Slab->Size = Size;
30 Slab->NextPtr = 0;
30 Slab->NextPtr = nullptr;
3131 return Slab;
3232 }
3333
3838 void BumpPtrAllocatorBase::PrintStats() const {
3939 unsigned NumSlabs = 0;
4040 size_t TotalMemory = 0;
41 for (MemSlab *Slab = CurSlab; Slab != 0; Slab = Slab->NextPtr) {
41 for (MemSlab *Slab = CurSlab; Slab != nullptr; Slab = Slab->NextPtr) {
4242 TotalMemory += Slab->Size;
4343 ++NumSlabs;
4444 }
5252
5353 size_t BumpPtrAllocatorBase::getTotalMemory() const {
5454 size_t TotalMemory = 0;
55 for (MemSlab *Slab = CurSlab; Slab != 0; Slab = Slab->NextPtr) {
55 for (MemSlab *Slab = CurSlab; Slab != nullptr; Slab = Slab->NextPtr) {
5656 TotalMemory += Slab->Size;
5757 }
5858 return TotalMemory;
8080 // Globals for name and overview of program. Program name is not a string to
8181 // avoid static ctor/dtor issues.
8282 static char ProgramName[80] = "";
83 static const char *ProgramOverview = 0;
83 static const char *ProgramOverview = nullptr;
8484
8585 // This collects additional help to be printed.
8686 static ManagedStatic > MoreHelp;
9999
100100 /// RegisteredOptionList - This is the list of the command line options that
101101 /// have statically constructed themselves.
102 static Option *RegisteredOptionList = 0;
102 static Option *RegisteredOptionList = nullptr;
103103
104104 void Option::addArgument() {
105105 assert(NextRegistered == 0 && "argument multiply registered!");
143143 SmallVectorImpl &SinkOpts,
144144 StringMap &OptionsMap) {
145145 SmallVector OptionNames;
146 Option *CAOpt = 0; // The ConsumeAfter option if it exists.
146 Option *CAOpt = nullptr; // The ConsumeAfter option if it exists.
147147 for (Option *O = RegisteredOptionList; O; O = O->getNextRegisteredOption()) {
148148 // If this option wants to handle multiple option names, get the full set.
149149 // This handles enum options like "-O1 -O2" etc.
188188 static Option *LookupOption(StringRef &Arg, StringRef &Value,
189189 const StringMap &OptionsMap) {
190190 // Reject all dashes.
191 if (Arg.empty()) return 0;
191 if (Arg.empty()) return nullptr;
192192
193193 size_t EqualPos = Arg.find('=');
194194
196196 if (EqualPos == StringRef::npos) {
197197 // Look up the option.
198198 StringMap::const_iterator I = OptionsMap.find(Arg);
199 return I != OptionsMap.end() ? I->second : 0;
199 return I != OptionsMap.end() ? I->second : nullptr;
200200 }
201201
202202 // If the argument before the = is a valid option name, we match. If not,
203203 // return Arg unmolested.
204204 StringMap::const_iterator I =
205205 OptionsMap.find(Arg.substr(0, EqualPos));
206 if (I == OptionsMap.end()) return 0;
206 if (I == OptionsMap.end()) return nullptr;
207207
208208 Value = Arg.substr(EqualPos+1);
209209 Arg = Arg.substr(0, EqualPos);
218218 const StringMap &OptionsMap,
219219 std::string &NearestString) {
220220 // Reject all dashes.
221 if (Arg.empty()) return 0;
221 if (Arg.empty()) return nullptr;
222222
223223 // Split on any equal sign.
224224 std::pair SplitArg = Arg.split('=');
226226 StringRef &RHS = SplitArg.second;
227227
228228 // Find the closest match.
229 Option *Best = 0;
229 Option *Best = nullptr;
230230 unsigned BestDistance = 0;
231231 for (StringMap::const_iterator it = OptionsMap.begin(),
232232 ie = OptionsMap.end(); it != ie; ++it) {
299299 // Enforce value requirements
300300 switch (Handler->getValueExpectedFlag()) {
301301 case ValueRequired:
302 if (Value.data() == 0) { // No value specified?
302 if (Value.data() == nullptr) { // No value specified?
303303 if (i+1 >= argc)
304304 return Handler->error("requires a value!");
305305 // Steal the next argument, like for '-o filename'
348348
349349 static bool ProvidePositionalOption(Option *Handler, StringRef Arg, int i) {
350350 int Dummy = i;
351 return ProvideOption(Handler, Handler->ArgStr, Arg, 0, 0, Dummy);
351 return ProvideOption(Handler, Handler->ArgStr, Arg, 0, nullptr, Dummy);
352352 }
353353
354354
384384 Length = Name.size();
385385 return OMI->second; // Found one!
386386 }
387 return 0; // No option found!
387 return nullptr; // No option found!
388388 }
389389
390390 /// HandlePrefixedOrGroupedOption - The specified argument string (which started
394394 static Option *HandlePrefixedOrGroupedOption(StringRef &Arg, StringRef &Value,
395395 bool &ErrorParsing,
396396 const StringMap &OptionsMap) {
397 if (Arg.size() == 1) return 0;
397 if (Arg.size() == 1) return nullptr;
398398
399399 // Do the lookup!
400400 size_t Length = 0;
401401 Option *PGOpt = getOptionPred(Arg, Length, isPrefixedOrGrouping, OptionsMap);
402 if (PGOpt == 0) return 0;
402 if (PGOpt == nullptr) return nullptr;
403403
404404 // If the option is a prefixed option, then the value is simply the
405405 // rest of the name... so fall through to later processing, by
426426 "Option can not be cl::Grouping AND cl::ValueRequired!");
427427 int Dummy = 0;
428428 ErrorParsing |= ProvideOption(PGOpt, OneArgName,
429 StringRef(), 0, 0, Dummy);
429 StringRef(), 0, nullptr, Dummy);
430430
431431 // Get the next grouping option.
432432 PGOpt = getOptionPred(Arg, Length, isGrouping, OptionsMap);
759759 // Determine whether or not there are an unlimited number of positionals
760760 bool HasUnlimitedPositionals = false;
761761
762 Option *ConsumeAfterOpt = 0;
762 Option *ConsumeAfterOpt = nullptr;
763763 if (!PositionalOpts.empty()) {
764764 if (PositionalOpts[0]->getNumOccurrencesFlag() == cl::ConsumeAfter) {
765765 assert(PositionalOpts.size() > 1 &&
769769
770770 // Calculate how many positional values are _required_.
771771 bool UnboundedFound = false;
772 for (size_t i = ConsumeAfterOpt != 0, e = PositionalOpts.size();
772 for (size_t i = ConsumeAfterOpt != nullptr, e = PositionalOpts.size();
773773 i != e; ++i) {
774774 Option *Opt = PositionalOpts[i];
775775 if (RequiresValue(Opt))
805805 // If the program has named positional arguments, and the name has been run
806806 // across, keep track of which positional argument was named. Otherwise put
807807 // the positional args into the PositionalVals list...
808 Option *ActivePositionalArg = 0;
808 Option *ActivePositionalArg = nullptr;
809809
810810 // Loop over all of the arguments... processing them.
811811 bool DashDashFound = false; // Have we read '--'?
812812 for (int i = 1; i < argc; ++i) {
813 Option *Handler = 0;
814 Option *NearestHandler = 0;
813 Option *Handler = nullptr;
814 Option *NearestHandler = nullptr;
815815 std::string NearestHandlerString;
816816 StringRef Value;
817817 StringRef ArgName = "";
845845 // the consume after option... if it's specified...
846846 //
847847 if (PositionalVals.size() >= NumPositionalRequired &&
848 ConsumeAfterOpt != 0) {
848 ConsumeAfterOpt != nullptr) {
849849 for (++i; i < argc; ++i)
850850 PositionalVals.push_back(std::make_pair(argv[i],i));
851851 break; // Handle outside of the argument processing loop...
883883 Handler = LookupOption(ArgName, Value, Opts);
884884
885885 // Check to see if this "option" is really a prefixed or grouped argument.
886 if (Handler == 0)
886 if (Handler == nullptr)
887887 Handler = HandlePrefixedOrGroupedOption(ArgName, Value,
888888 ErrorParsing, Opts);
889889
890890 // Otherwise, look for the closest available option to report to the user
891891 // in the upcoming error.
892 if (Handler == 0 && SinkOpts.empty())
892 if (Handler == nullptr && SinkOpts.empty())
893893 NearestHandler = LookupNearestOption(ArgName, Opts,
894894 NearestHandlerString);
895895 }
896896
897 if (Handler == 0) {
897 if (Handler == nullptr) {
898898 if (SinkOpts.empty()) {
899899 errs() << ProgramName << ": Unknown command line argument '"
900900 << argv[i] << "'. Try: '" << argv[0] << " -help'\n";
938938 << " positional arguments: See: " << argv[0] << " -help\n";
939939 ErrorParsing = true;
940940
941 } else if (ConsumeAfterOpt == 0) {
941 } else if (ConsumeAfterOpt == nullptr) {
942942 // Positional args have already been handled if ConsumeAfter is specified.
943943 unsigned ValNo = 0, NumVals = static_cast(PositionalVals.size());
944944 for (size_t i = 0, e = PositionalOpts.size(); i != e; ++i) {
10431043 //
10441044
10451045 bool Option::error(const Twine &Message, StringRef ArgName) {
1046 if (ArgName.data() == 0) ArgName = ArgStr;
1046 if (ArgName.data() == nullptr) ArgName = ArgStr;
10471047 if (ArgName.empty())
10481048 errs() << HelpStr; // Be nice for positional arguments
10491049 else
14541454 outs() << "USAGE: " << ProgramName << " [options]";
14551455
14561456 // Print out the positional options.
1457 Option *CAOpt = 0; // The cl::ConsumeAfter option, if it exists...
1457 Option *CAOpt = nullptr; // The cl::ConsumeAfter option, if it exists...
14581458 if (!PositionalOpts.empty() &&
14591459 PositionalOpts[0]->getNumOccurrencesFlag() == ConsumeAfter)
14601460 CAOpt = PositionalOpts[0];
14611461
1462 for (size_t i = CAOpt != 0, e = PositionalOpts.size(); i != e; ++i) {
1462 for (size_t i = CAOpt != nullptr, e = PositionalOpts.size(); i != e; ++i) {
14631463 if (PositionalOpts[i]->ArgStr[0])
14641464 outs() << " --" << PositionalOpts[i]->ArgStr;
14651465 outs() << " " << PositionalOpts[i]->HelpStr;
15541554 outs() << (*Category)->getName() << ":\n";
15551555
15561556 // Check if description is set.
1557 if ((*Category)->getDescription() != 0)
1557 if ((*Category)->getDescription() != nullptr)
15581558 outs() << (*Category)->getDescription() << "\n\n";
15591559 else
15601560 outs() << "\n";
16851685 Opts[i].second->printOptionValue(MaxArgLen, PrintAllOptions);
16861686 }
16871687
1688 static void (*OverrideVersionPrinter)() = 0;
1689
1690 static std::vector* ExtraVersionPrinters = 0;
1688 static void (*OverrideVersionPrinter)() = nullptr;
1689
1690 static std::vector* ExtraVersionPrinters = nullptr;
16911691
16921692 namespace {
16931693 class VersionPrinter {
17201720 void operator=(bool OptionWasSpecified) {
17211721 if (!OptionWasSpecified) return;
17221722
1723 if (OverrideVersionPrinter != 0) {
1723 if (OverrideVersionPrinter != nullptr) {
17241724 (*OverrideVersionPrinter)();
17251725 exit(0);
17261726 }
17281728
17291729 // Iterate over any registered extra printers and call them to add further
17301730 // information.
1731 if (ExtraVersionPrinters != 0) {
1731 if (ExtraVersionPrinters != nullptr) {
17321732 outs() << '\n';
17331733 for (std::vector::iterator I = ExtraVersionPrinters->begin(),
17341734 E = ExtraVersionPrinters->end();
17781778 }
17791779
17801780 void cl::AddExtraVersionPrinter(void (*func)()) {
1781 if (ExtraVersionPrinters == 0)
1781 if (ExtraVersionPrinters == nullptr)
17821782 ExtraVersionPrinters = new std::vector;
17831783
17841784 ExtraVersionPrinters->push_back(func);
8888 }
8989
9090 bool CrashRecoveryContext::isRecoveringFromCrash() {
91 return tlIsRecoveringFromCrash->get() != 0;
91 return tlIsRecoveringFromCrash->get() != nullptr;
9292 }
9393
9494 CrashRecoveryContext *CrashRecoveryContext::GetCurrent() {
9595 if (!gCrashRecoveryEnabled)
96 return 0;
96 return nullptr;
9797
9898 const CrashRecoveryContextImpl *CRCI = CurrentContext->get();
9999 if (!CRCI)
100 return 0;
100 return nullptr;
101101
102102 return CRCI->CRC;
103103 }
119119 if (cleanup == head) {
120120 head = cleanup->next;
121121 if (head)
122 head->prev = 0;
122 head->prev = nullptr;
123123 }
124124 else {
125125 cleanup->prev->next = cleanup->next;
260260 sigset_t SigMask;
261261 sigemptyset(&SigMask);
262262 sigaddset(&SigMask, Signal);
263 sigprocmask(SIG_UNBLOCK, &SigMask, 0);
263 sigprocmask(SIG_UNBLOCK, &SigMask, nullptr);
264264
265265 if (CRCI)
266266 const_cast(CRCI)->HandleCrash();
295295
296296 // Restore the previous signal handlers.
297297 for (unsigned i = 0; i != NumSignals; ++i)
298 sigaction(Signals[i], &PrevActions[i], 0);
298 sigaction(Signals[i], &PrevActions[i], nullptr);
299299 }
300300
301301 #endif
4343 // success
4444 return dst;
4545 }
46 return NULL;
46 return nullptr;
4747 }
4848
4949 uint8_t DataExtractor::getU8(uint32_t *offset_ptr) const {
124124 *offset_ptr = pos + 1;
125125 return Data.data() + offset;
126126 }
127 return NULL;
127 return nullptr;
128128 }
129129
130130 uint64_t DataExtractor::getULEB128(uint32_t *offset_ptr) const {
8282 if (error_code e = s->OpenFile(Filename)) {
8383 *StrError = std::string("Could not open ") + Filename + ": " +
8484 e.message() + "\n";
85 return NULL;
85 return nullptr;
8686 }
8787 return s;
8888 }
9999 return "DW_TAG_GNU_formal_parameter_pack";
100100 case DW_TAG_APPLE_property: return "DW_TAG_APPLE_property";
101101 }
102 return 0;
102 return nullptr;
103103 }
104104
105105 /// ChildrenString - Return the string for the specified children flag.
109109 case DW_CHILDREN_no: return "DW_CHILDREN_no";
110110 case DW_CHILDREN_yes: return "DW_CHILDREN_yes";
111111 }
112 return 0;
112 return nullptr;
113113 }
114114
115115 /// AttributeString - Return the string for the specified attribute.
270270 case DW_AT_GNU_pubnames: return "DW_AT_GNU_pubnames";
271271 case DW_AT_GNU_pubtypes: return "DW_AT_GNU_pubtypes";
272272 }
273 return 0;
273 return nullptr;
274274 }
275275
276276 /// FormEncodingString - Return the string for the specified form encoding.
307307 case DW_FORM_GNU_addr_index: return "DW_FORM_GNU_addr_index";
308308 case DW_FORM_GNU_str_index: return "DW_FORM_GNU_str_index";
309309 }
310 return 0;
310 return nullptr;
311311 }
312312
313313 /// OperationEncodingString - Return the string for the specified operation
476476 case DW_OP_GNU_addr_index: return "DW_OP_GNU_addr_index";
477477 case DW_OP_GNU_const_index: return "DW_OP_GNU_const_index";
478478 }
479 return 0;
479 return nullptr;
480480 }
481481
482482 /// AttributeEncodingString - Return the string for the specified attribute
502502 case DW_ATE_lo_user: return "DW_ATE_lo_user";
503503 case DW_ATE_hi_user: return "DW_ATE_hi_user";
504504 }
505 return 0;
505 return nullptr;
506506 }
507507
508508 /// DecimalSignString - Return the string for the specified decimal sign
515515 case DW_DS_leading_separate: return "DW_DS_leading_separate";
516516 case DW_DS_trailing_separate: return "DW_DS_trailing_separate";
517517 }
518 return 0;
518 return nullptr;
519519 }
520520
521521 /// EndianityString - Return the string for the specified endianity.
528528 case DW_END_lo_user: return "DW_END_lo_user";
529529 case DW_END_hi_user: return "DW_END_hi_user";
530530 }
531 return 0;
531 return nullptr;
532532 }
533533
534534 /// AccessibilityString - Return the string for the specified accessibility.
540540 case DW_ACCESS_protected: return "DW_ACCESS_protected";
541541 case DW_ACCESS_private: return "DW_ACCESS_private";
542542 }
543 return 0;
543 return nullptr;
544544 }
545545
546546 /// VisibilityString - Return the string for the specified visibility.
551551 case DW_VIS_exported: return "DW_VIS_exported";
552552 case DW_VIS_qualified: return "DW_VIS_qualified";
553553 }
554 return 0;
554 return nullptr;
555555 }
556556
557557 /// VirtualityString - Return the string for the specified virtuality.
562562 case DW_VIRTUALITY_virtual: return "DW_VIRTUALITY_virtual";
563563 case DW_VIRTUALITY_pure_virtual: return "DW_VIRTUALITY_pure_virtual";
564564 }
565 return 0;
565 return nullptr;
566566 }
567567
568568 /// LanguageString - Return the string for the specified language.
599599 case DW_LANG_lo_user: return "DW_LANG_lo_user";
600600 case DW_LANG_hi_user: return "DW_LANG_hi_user";
601601 }
602 return 0;
602 return nullptr;
603603 }
604604
605605 /// CaseString - Return the string for the specified identifier case.
611611 case DW_ID_down_case: return "DW_ID_down_case";
612612 case DW_ID_case_insensitive: return "DW_ID_case_insensitive";
613613 }
614 return 0;
614 return nullptr;
615615 }
616616
617617 /// ConventionString - Return the string for the specified calling convention.
624624 case DW_CC_lo_user: return "DW_CC_lo_user";
625625 case DW_CC_hi_user: return "DW_CC_hi_user";
626626 }
627 return 0;
627 return nullptr;
628628 }
629629
630630 /// InlineCodeString - Return the string for the specified inline code.
636636 case DW_INL_declared_not_inlined: return "DW_INL_declared_not_inlined";
637637 case DW_INL_declared_inlined: return "DW_INL_declared_inlined";
638638 }
639 return 0;
639 return nullptr;
640640 }
641641
642642 /// ArrayOrderString - Return the string for the specified array order.
646646 case DW_ORD_row_major: return "DW_ORD_row_major";
647647 case DW_ORD_col_major: return "DW_ORD_col_major";
648648 }
649 return 0;
649 return nullptr;
650650 }
651651
652652 /// DiscriminantString - Return the string for the specified discriminant
656656 case DW_DSC_label: return "DW_DSC_label";
657657 case DW_DSC_range: return "DW_DSC_range";
658658 }
659 return 0;
659 return nullptr;
660660 }
661661
662662 /// LNStandardString - Return the string for the specified line number standard.
676676 case DW_LNS_set_epilogue_begin: return "DW_LNS_set_epilogue_begin";
677677 case DW_LNS_set_isa: return "DW_LNS_set_isa";
678678 }
679 return 0;
679 return nullptr;
680680 }
681681
682682 /// LNExtendedString - Return the string for the specified line number extended
691691 case DW_LNE_lo_user: return "DW_LNE_lo_user";
692692 case DW_LNE_hi_user: return "DW_LNE_hi_user";
693693 }
694 return 0;
694 return nullptr;
695695 }
696696
697697 /// MacinfoString - Return the string for the specified macinfo type encodings.
705705 case DW_MACINFO_end_file: return "DW_MACINFO_end_file";
706706 case DW_MACINFO_vendor_ext: return "DW_MACINFO_vendor_ext";
707707 }
708 return 0;
708 return nullptr;
709709 }
710710
711711 /// CallFrameString - Return the string for the specified call frame instruction
744744 case DW_CFA_lo_user: return "DW_CFA_lo_user";
745745 case DW_CFA_hi_user: return "DW_CFA_hi_user";
746746 }
747 return 0;
747 return nullptr;
748748 }
749749
750750 const char *llvm::dwarf::AtomTypeString(unsigned AT) {
760760 case DW_ATOM_type_flags:
761761 return "DW_ATOM_type_flags";
762762 }
763 return 0;
763 return nullptr;
764764 }
765765
766766 const char *llvm::dwarf::GDBIndexEntryKindString(GDBIndexEntryKind Kind) {
5050 //=== independent code.
5151 //===----------------------------------------------------------------------===//
5252
53 static DenseSet *OpenedHandles = 0;
53 static DenseSet *OpenedHandles = nullptr;
5454
5555 DynamicLibrary DynamicLibrary::getPermanentLibrary(const char *filename,
5656 std::string *errMsg) {
5757 SmartScopedLock lock(*SymbolsMutex);
5858
5959 void *handle = dlopen(filename, RTLD_LAZY|RTLD_GLOBAL);
60 if (handle == 0) {
60 if (handle == nullptr) {
6161 if (errMsg) *errMsg = dlerror();
6262 return DynamicLibrary();
6363 }
6969 handle = RTLD_DEFAULT;
7070 #endif
7171
72 if (OpenedHandles == 0)
72 if (OpenedHandles == nullptr)
7373 OpenedHandles = new DenseSet();
7474
7575 // If we've already loaded this library, dlclose() the handle in order to
8282
8383 void *DynamicLibrary::getAddressOfSymbol(const char *symbolName) {
8484 if (!isValid())
85 return NULL;
85 return nullptr;
8686 return dlsym(Data, symbolName);
8787 }
8888
165165 #endif
166166 #undef EXPLICIT_SYMBOL
167167
168 return 0;
168 return nullptr;
169169 }
170170
171171 #endif // LLVM_ON_WIN32
3333
3434 using namespace llvm;
3535
36 static fatal_error_handler_t ErrorHandler = 0;
37 static void *ErrorHandlerUserData = 0;
36 static fatal_error_handler_t ErrorHandler = nullptr;
37 static void *ErrorHandlerUserData = nullptr;
3838
3939 void llvm::install_fatal_error_handler(fatal_error_handler_t handler,
4040 void *user_data) {
4646 }
4747
4848 void llvm::remove_fatal_error_handler() {
49 ErrorHandler = 0;
49 ErrorHandler = nullptr;
5050 }
5151
5252 void llvm::report_fatal_error(const char *Reason, bool GenCrashDiag) {
9696
9797 error_code FileOutputBuffer::commit(int64_t NewSmallerSize) {
9898 // Unmap buffer, letting OS flush dirty pages to file on disk.
99 Region.reset(0);
99 Region.reset(nullptr);
100100
101101 // If requested, resize file as part of commit.
102102 if ( NewSmallerSize != -1 ) {
189189 static FoldingSetImpl::Node *GetNextPtr(void *NextInBucketPtr) {
190190 // The low bit is set if this is the pointer back to the bucket.
191191 if (reinterpret_cast(NextInBucketPtr) & 1)
192 return 0;
192 return nullptr;
193193
194194 return static_cast(NextInBucketPtr);
195195 }
261261 while (Node *NodeInBucket = GetNextPtr(Probe)) {
262262 // Figure out the next link, remove NodeInBucket from the old link.
263263 Probe = NodeInBucket->getNextInBucket();
264 NodeInBucket->SetNextInBucket(0);
264 NodeInBucket->SetNextInBucket(nullptr);
265265
266266 // Insert the node into the new bucket, after recomputing the hash.
267267 InsertNode(NodeInBucket,
284284 void **Bucket = GetBucketFor(IDHash, Buckets, NumBuckets);
285285 void *Probe = *Bucket;
286286
287 InsertPos = 0;
287 InsertPos = nullptr;
288288
289289 FoldingSetNodeID TempID;
290290 while (Node *NodeInBucket = GetNextPtr(Probe)) {
297297
298298 // Didn't find the node, return null with the bucket as the InsertPos.
299299 InsertPos = Bucket;
300 return 0;
300 return nullptr;
301301 }
302302
303303 /// InsertNode - Insert the specified node into the folding set, knowing that it
322322 // If this is the first insertion into this bucket, its next pointer will be
323323 // null. Pretend as if it pointed to itself, setting the low bit to indicate
324324 // that it is a pointer to the bucket.
325 if (Next == 0)
325 if (Next == nullptr)
326326 Next = reinterpret_cast(reinterpret_cast(Bucket)|1);
327327
328328 // Set the node's next pointer, and make the bucket point to the node.
336336 // Because each bucket is a circular list, we don't need to compute N's hash
337337 // to remove it.
338338 void *Ptr = N->getNextInBucket();
339 if (Ptr == 0) return false; // Not in folding set.
339 if (Ptr == nullptr) return false; // Not in folding set.
340340
341341 --NumNodes;
342 N->SetNextInBucket(0);
342 N->SetNextInBucket(nullptr);
343343
344344 // Remember what N originally pointed to, either a bucket or another node.
345345 void *NodeNextPtr = Ptr;
389389 FoldingSetIteratorImpl::FoldingSetIteratorImpl(void **Bucket) {
390390 // Skip to the first non-null non-self-cycle bucket.
391391 while (*Bucket != reinterpret_cast(-1) &&
392 (*Bucket == 0 || GetNextPtr(*Bucket) == 0))
392 (*Bucket == nullptr || GetNextPtr(*Bucket) == nullptr))
393393 ++Bucket;
394394
395395 NodePtr = static_cast(*Bucket);
409409 do {
410410 ++Bucket;
411411 } while (*Bucket != reinterpret_cast(-1) &&
412 (*Bucket == 0 || GetNextPtr(*Bucket) == 0));
412 (*Bucket == nullptr || GetNextPtr(*Bucket) == nullptr));
413413
414414 NodePtr = static_cast(*Bucket);
415415 }
419419 // FoldingSetBucketIteratorImpl Implementation
420420
421421 FoldingSetBucketIteratorImpl::FoldingSetBucketIteratorImpl(void **Bucket) {
422 Ptr = (*Bucket == 0 || GetNextPtr(*Bucket) == 0) ? (void*) Bucket : *Bucket;
423 }
422 Ptr = (*Bucket == nullptr || GetNextPtr(*Bucket) == nullptr) ? (void*) Bucket
423 : *Bucket;
424 }
8080 TheStream->write(Ptr, Size);
8181
8282 // Reset the scanning pointer.
83 Scanned = 0;
83 Scanned = nullptr;
8484 }
8585
8686 /// fouts() - This returns a reference to a formatted_raw_ostream for
8282 ExecGraphViewer(StringRef ExecPath, std::vector &args,
8383 StringRef Filename, bool wait, std::string &ErrMsg) {
8484 if (wait) {
85 if (sys::ExecuteAndWait(ExecPath, &args[0],0,0,0,0,&ErrMsg)) {
85 if (sys::ExecuteAndWait(ExecPath, &args[0],nullptr,nullptr,0,0,&ErrMsg)) {
8686 errs() << "Error: " << ErrMsg << "\n";
8787 return false;
8888 }
9090 errs() << " done. \n";
9191 }
9292 else {
93 sys::ExecuteNoWait(ExecPath, &args[0],0,0,0,&ErrMsg);
93 sys::ExecuteNoWait(ExecPath, &args[0],nullptr,nullptr,0,&ErrMsg);
9494 errs() << "Remember to erase graph file: " << Filename.str() << "\n";
9595 }
9696 return true;
107107 std::vector args;
108108 args.push_back(Graphviz.c_str());
109109 args.push_back(Filename.c_str());
110 args.push_back(0);
110 args.push_back(nullptr);
111111
112112 errs() << "Running 'Graphviz' program... ";
113113 if (!ExecGraphViewer(Graphviz, args, Filename, wait, ErrMsg))
5757 }
5858 } else if (height() < Level)
5959 // end() may have created a height=0 path.
60 path.resize(Level + 1, Entry(0, 0, 0));
60 path.resize(Level + 1, Entry(nullptr, 0, 0));
6161
6262 // NR is the subtree containing our left sibling.
6363 --path[l].offset;
1212 using namespace llvm;
1313
1414 line_iterator::line_iterator(const MemoryBuffer &Buffer, char CommentMarker)
15 : Buffer(Buffer.getBufferSize() ? &Buffer : 0),
15 : Buffer(Buffer.getBufferSize() ? &Buffer : nullptr),
1616 CommentMarker(CommentMarker), LineNumber(1),
17 CurrentLine(Buffer.getBufferSize() ? Buffer.getBufferStart() : 0, 0) {
17 CurrentLine(Buffer.getBufferSize() ? Buffer.getBufferStart() : nullptr,
18 0) {
1819 // Ensure that if we are constructed on a non-empty memory buffer that it is
1920 // a null terminated buffer.
2021 if (Buffer.getBufferSize()) {
5253
5354 if (*Pos == '\0') {
5455 // We've hit the end of the buffer, reset ourselves to the end state.
55 Buffer = 0;
56 Buffer = nullptr;
5657 CurrentLine = StringRef();
5758 return;
5859 }
195195 #if LLVM_ON_WIN32
196196 Sleep(Interval);
197197 #else
198 nanosleep(&Interval, NULL);
198 nanosleep(&Interval, nullptr);
199199 #endif
200200 bool LockFileJustDisappeared = false;
201201
1616 #include
1717 using namespace llvm;
1818
19 static const ManagedStaticBase *StaticList = 0;
19 static const ManagedStaticBase *StaticList = nullptr;
2020
2121 void ManagedStaticBase::RegisterManagedStatic(void *(*Creator)(),
2222 void (*Deleter)(void*)) const {
2323 if (llvm_is_multithreaded()) {
2424 llvm_acquire_global_lock();
2525
26 if (Ptr == 0) {
27 void* tmp = Creator ? Creator() : 0;
26 if (Ptr == nullptr) {
27 void* tmp = Creator ? Creator() : nullptr;
2828
2929 TsanHappensBefore(this);
3030 sys::MemoryFence();
4646 } else {
4747 assert(Ptr == 0 && DeleterFn == 0 && Next == 0 &&
4848 "Partially initialized ManagedStatic!?");
49 Ptr = Creator ? Creator() : 0;
49 Ptr = Creator ? Creator() : nullptr;
5050 DeleterFn = Deleter;
5151
5252 // Add to list of managed statics.
6161 "Not destroyed in reverse order of construction?");
6262 // Unlink from list.
6363 StaticList = Next;
64 Next = 0;
64 Next = nullptr;
6565
6666 // Destroy memory.
6767 DeleterFn(Ptr);
6868
6969 // Cleanup.
70 Ptr = 0;
71 DeleterFn = 0;
70 Ptr = nullptr;
71 DeleterFn = nullptr;
7272 }
7373
7474 /// llvm_shutdown - Deallocate and destroy all ManagedStatic variables.
116116 MemoryBuffer *MemoryBuffer::getMemBufferCopy(StringRef InputData,
117117 StringRef BufferName) {
118118 MemoryBuffer *Buf = getNewUninitMemBuffer(InputData.size(), BufferName);
119 if (!Buf) return 0;
119 if (!Buf) return nullptr;
120120 memcpy(const_cast(Buf->getBufferStart()), InputData.data(),
121121 InputData.size());
122122 return Buf;
136136 RoundUpToAlignment(sizeof(MemoryBufferMem) + BufferName.size() + 1, 16);
137137 size_t RealLen = AlignedStringLen + Size + 1;
138138 char *Mem = static_cast(operator new(RealLen, std::nothrow));
139 if (!Mem) return 0;
139 if (!Mem) return nullptr;
140140
141141 // The name is stored after the class itself.
142142 CopyStringRef(Mem + sizeof(MemoryBufferMem), BufferName);
154154 /// the MemoryBuffer object.
155155 MemoryBuffer *MemoryBuffer::getNewMemBuffer(size_t Size, StringRef BufferName) {
156156 MemoryBuffer *SB = getNewUninitMemBuffer(Size, BufferName);
157 if (!SB) return 0;
157 if (!SB) return nullptr;
158158 memset(const_cast(SB->getBufferStart()), 0, Size);
159159 return SB;
160160 }
4141
4242 // Construct a Mutex using pthread calls
4343 MutexImpl::MutexImpl( bool recursive)
44 : data_(0)
44 : data_(nullptr)
4545 {
4646 // Declare the pthread_mutex data structures
4747 pthread_mutex_t* mutex =
576576 // macros defined in on darwin >= 9
577577 int ConfName = erasedOnReboot? _CS_DARWIN_USER_TEMP_DIR
578578 : _CS_DARWIN_USER_CACHE_DIR;
579 size_t ConfLen = confstr(ConfName, 0, 0);
579 size_t ConfLen = confstr(ConfName, nullptr, 0);
580580 if (ConfLen > 0) {
581581 do {
582582 result.resize(ConfLen);
4545 /// PrintCurStackTrace - Print the current stack trace to the specified stream.
4646 static void PrintCurStackTrace(raw_ostream &OS) {
4747 // Don't print an empty trace.
48 if (PrettyStackTraceHead->get() == 0) return;
48 if (PrettyStackTraceHead->get() == nullptr) return;
4949
5050 // If there are pretty stack frames registered, walk and emit them.
5151 OS << "Stack dump:\n";
135135 }
136136
137137 static bool RegisterCrashPrinter() {
138 sys::AddSignalHandler(CrashHandler, 0);
138 sys::AddSignalHandler(CrashHandler, nullptr);
139139 return false;
140140 }
141141
4343
4444 // Construct a RWMutex using pthread calls
4545 RWMutexImpl::RWMutexImpl()
46 : data_(0)
46 : data_(nullptr)
4747 {
4848 // Declare the pthread_rwlock data structures
4949 pthread_rwlock_t* rwlock =
5555 #endif
5656
5757 // Initialize the rwlock
58 int errorcode = pthread_rwlock_init(rwlock, NULL);
58 int errorcode = pthread_rwlock_init(rwlock, nullptr);
5959 (void)errorcode;
6060 assert(errorcode == 0);
6161
4242 if (!error)
4343 return true;
4444
45 size_t len = llvm_regerror(error, preg, NULL, 0);
45 size_t len = llvm_regerror(error, preg, nullptr, 0);
4646
4747 Error.resize(len - 1);
4848 llvm_regerror(error, preg, &Error[0], len);
4747 #endif
4848
4949 #undef EXPLICIT_SYMBOL
50 return 0;
50 return nullptr;
5151 }
5252
5353 namespace llvm {
102102 unsigned ArraySize = CurArraySize;
103103 unsigned ProbeAmt = 1;
104104 const void *const *Array = CurArray;
105 const void *const *Tombstone = 0;
105 const void *const *Tombstone = nullptr;
106106 while (1) {
107107 // Found Ptr's bucket?
108108 if (Array[Bucket] == Ptr)
113113 if (*Ptr == '\n') ++LineNo;
114114
115115 // Allocate the line number cache if it doesn't exist.
116 if (LineNoCache == 0)
116 if (LineNoCache == nullptr)
117117 LineNoCache = new LineNoCacheTy();
118118
119119 // Update the line # cache.
227227 PrintIncludeStack(getBufferInfo(CurBuf).IncludeLoc, OS);
228228 }
229229
230 Diagnostic.print(0, OS, ShowColors);
230 Diagnostic.print(nullptr, OS, ShowColors);
231231 }
232232
233233 void SourceMgr::PrintMessage(SMLoc Loc, SourceMgr::DiagKind Kind,
2626 }
2727
2828 // Otherwise, initialize it with zero buckets to avoid the allocation.
29 TheTable = 0;
29 TheTable = nullptr;
3030 NumBuckets = 0;
3131 NumItems = 0;
3232 NumTombstones = 0;
6969 while (1) {
7070 StringMapEntryBase *BucketItem = TheTable[BucketNo];
7171 // If we found an empty bucket, this key isn't in the table yet, return it.
72 if (LLVM_LIKELY(BucketItem == 0)) {
72 if (LLVM_LIKELY(BucketItem == nullptr)) {
7373 // If we found a tombstone, we want to reuse the tombstone instead of an
7474 // empty bucket. This reduces probing.
7575 if (FirstTombstone != -1) {
123123 while (1) {
124124 StringMapEntryBase *BucketItem = TheTable[BucketNo];
125125 // If we found an empty bucket, this key isn't in the table yet, return.
126 if (LLVM_LIKELY(BucketItem == 0))
126 if (LLVM_LIKELY(BucketItem == nullptr))
127127 return -1;
128128
129129 if (BucketItem == getTombstoneVal()) {
165165 /// table, returning it. If the key is not in the table, this returns null.
166166 StringMapEntryBase *StringMapImpl::RemoveKey(StringRef Key) {
167167 int Bucket = FindKey(Key);
168 if (Bucket == -1) return 0;
168 if (Bucket == -1) return nullptr;
169169
170170 StringMapEntryBase *Result = TheTable[Bucket];
171171 TheTable[Bucket] = getTombstoneVal();
211211 // Fast case, bucket available.
212212 unsigned FullHash = HashTable[I];
213213 unsigned NewBucket = FullHash & (NewSize-1);
214 if (NewTableArray[NewBucket] == 0) {
214 if (NewTableArray[NewBucket] == nullptr) {
215215 NewTableArray[FullHash & (NewSize-1)] = Bucket;
216216 NewHashArray[FullHash & (NewSize-1)] = FullHash;
217217 continue;
280280 // rest.data() is used to distinguish cases like "a," that splits into
281281 // "a" + "" and "a" that splits into "a" + 0.
282282 for (int splits = 0;
283 rest.data() != NULL && (MaxSplit < 0 || splits < MaxSplit);
283 rest.data() != nullptr && (MaxSplit < 0 || splits < MaxSplit);
284284 ++splits) {
285285 std::pair p = rest.split(Separators);
286286
289289 rest = p.second;
290290 }
291291 // If we have a tail left, add it.
292 if (rest.data() != NULL && (rest.size() != 0 || KeepEmpty))
292 if (rest.data() != nullptr && (rest.size() != 0 || KeepEmpty))
293293 A.push_back(rest);
294294 }
295295
1616 using namespace llvm;
1717
1818 // Clients are responsible for avoid race conditions in registration.
19 static Target *FirstTarget = 0;
19 static Target *FirstTarget = nullptr;
2020
2121 TargetRegistry::iterator TargetRegistry::begin() {
2222 return iterator(FirstTarget);
2828 // Allocate target machine. First, check whether the user has explicitly
2929 // specified an architecture to compile for. If so we have to look it up by
3030 // name, because it might be a backend that has no mapping to a target triple.
31 const Target *TheTarget = 0;
31 const Target *TheTarget = nullptr;
3232 if (!ArchName.empty()) {
3333 for (TargetRegistry::iterator it = TargetRegistry::begin(),
3434 ie = TargetRegistry::end(); it != ie; ++it) {
4040
4141 if (!TheTarget) {
4242 Error = "error: invalid target '" + ArchName + "'.\n";
43 return 0;
43 return nullptr;
4444 }
4545
4646 // Adjust the triple to match (if known), otherwise stick with the
5252 // Get the target specific parser.
5353 std::string TempError;
5454 TheTarget = TargetRegistry::lookupTarget(TheTriple.getTriple(), TempError);
55 if (TheTarget == 0) {
55 if (TheTarget == nullptr) {
5656 Error = ": error: unable to get target for '"
5757 + TheTriple.getTriple()
5858 + "', see --version and --triple.\n";
59 return 0;
59 return nullptr;
6060 }
6161 }
6262
6868 // Provide special warning when no targets are initialized.
6969 if (begin() == end()) {
7070 Error = "Unable to find target for this triple (no targets are registered)";
71 return 0;
71 return nullptr;
7272 }
73 const Target *Matching = 0;
73 const Target *Matching = nullptr;
7474 Triple::ArchType Arch = Triple(TT).getArch();
7575 for (iterator it = begin(), ie = end(); it != ie; ++it) {
7676 if (it->ArchMatchFn(Arch)) {
7777 if (Matching) {
7878 Error = std::string("Cannot choose between targets \"") +
7979 Matching->Name + "\" and \"" + it->Name + "\"";
80 return 0;
80 return nullptr;
8181 }
8282 Matching = &*it;
8383 }
8686 if (!Matching) {
8787 Error = "No available targets are compatible with this triple, "
8888 "see -version for the available targets.";
89 return 0;
89 return nullptr;
9090 }
9191
9292 return Matching;
120120
121121 if (TheTarget && !TheTarget->hasJIT()) {
122122 Error = "No JIT compatible target available for this host";
123 return 0;
123 return nullptr;
124124 }
125125
126126 return TheTarget;
5252 ThreadLocalImpl::ThreadLocalImpl() : data() {
5353 static_assert(sizeof(pthread_key_t) <= sizeof(data), "size too big");
5454 pthread_key_t* key = reinterpret_cast(&data);
55 int errorcode = pthread_key_create(key, NULL);
55 int errorcode = pthread_key_create(key, nullptr);
5656 assert(errorcode == 0);
5757 (void) errorcode;
5858 }
7777 }
7878
7979 void ThreadLocalImpl::removeInstance() {
80 setInstance(0);
80 setInstance(nullptr);
8181 }
8282
8383 }
2020
2121 static bool multithreaded_mode = false;
2222
23 static sys::Mutex* global_lock = 0;
23 static sys::Mutex* global_lock = nullptr;
2424
2525 bool llvm::llvm_start_multithreaded() {
2626 #if LLVM_ENABLE_THREADS != 0
7272 static void *ExecuteOnThread_Dispatch(void *Arg) {
7373 ThreadInfo *TI = reinterpret_cast(Arg);
7474 TI->UserFn(TI->UserData);
75 return 0;
75 return nullptr;
7676 }
7777
7878 void llvm::llvm_execute_on_thread(void (*Fn)(void*), void *UserData,
9696 goto error;
9797
9898 // Wait for the thread and clean up.
99 ::pthread_join(Thread, 0);
99 ::pthread_join(Thread, nullptr);
100100
101101 error:
102102 ::pthread_attr_destroy(&Attr);
7676 }
7777
7878
79 static TimerGroup *DefaultTimerGroup = 0;
79 static TimerGroup *DefaultTimerGroup = nullptr;
8080 static TimerGroup *getDefaultTimerGroup() {
8181 TimerGroup *tmp = DefaultTimerGroup;
8282 sys::MemoryFence();
234234
235235 NamedRegionTimer::NamedRegionTimer(StringRef Name,
236236 bool Enabled)
237 : TimeRegion(!Enabled ? 0 : &getNamedRegionTimer(Name)) {}
237 : TimeRegion(!Enabled ? nullptr : &getNamedRegionTimer(Name)) {}
238238
239239 NamedRegionTimer::NamedRegionTimer(StringRef Name, StringRef GroupName,
240240 bool Enabled)
241 : TimeRegion(!Enabled ? 0 : &NamedGroupedTimers->get(Name, GroupName)) {}
241 : TimeRegion(!Enabled ? nullptr : &NamedGroupedTimers->get(Name, GroupName)){}
242242
243243 //===----------------------------------------------------------------------===//
244244 // TimerGroup Implementation
246246
247247 /// TimerGroupList - This is the global list of TimerGroups, maintained by the
248248 /// TimerGroup ctor/dtor and is protected by the TimerLock lock.
249 static TimerGroup *TimerGroupList = 0;
249 static TimerGroup *TimerGroupList = nullptr;
250250
251251 TimerGroup::TimerGroup(StringRef name)
252 : Name(name.begin(), name.end()), FirstTimer(0) {
252 : Name(name.begin(), name.end()), FirstTimer(nullptr) {
253253
254254 // Add the group to TimerGroupList.
255255 sys::SmartScopedLock L(*TimerLock);
263263 TimerGroup::~TimerGroup() {
264264 // If the timer group is destroyed before the timers it owns, accumulate and
265265 // print the timing data.
266 while (FirstTimer != 0)
266 while (FirstTimer != nullptr)
267267 removeTimer(*FirstTimer);
268268
269269 // Remove the group from the TimerGroupList.
281281 if (T.Started)
282282 TimersToPrint.push_back(std::make_pair(T.Time, T.Name));
283283
284 T.TG = 0;
284 T.TG = nullptr;
285285
286286 // Unlink the timer from our list.
287287 *T.Prev = T.Next;
290290
291291 // Print the report when all timers in this group are destroyed if some of
292292 // them were started.
293 if (FirstTimer != 0 || TimersToPrint.empty())
293 if (FirstTimer != nullptr || TimersToPrint.empty())
294294 return;
295295
296296 raw_ostream *OutStream = CreateInfoOutputFile();
5656 const char *Triple::getArchTypePrefix(ArchType Kind) {
5757 switch (Kind) {
5858 default:
59 return 0;
59 return nullptr;
6060
6161 case aarch64:
6262 case aarch64_be: return "aarch64";
209209 // Returns architecture name that is understood by the target assembler.
210210 const char *Triple::getArchNameForAssembler() {
211211 if (!isOSDarwin() && getVendor() != Triple::Apple)
212 return NULL;
212 return nullptr;
213213
214214 return StringSwitch(getArchName())
215215 .Case("i386", "i386")
231231 .Case("amdil", "amdil")
232232 .Case("spir", "spir")
233233 .Case("spir64", "spir64")
234 .Default(NULL);
234 .Default(nullptr);
235235 }
236236
237237 static Triple::ArchType parseArch(StringRef ArchName) {
18751875 void MappingNode::increment() {
18761876 if (failed()) {
18771877 IsAtEnd = true;
1878 CurrentEntry = 0;
1878 CurrentEntry = nullptr;
18791879 return;
18801880 }
18811881 if (CurrentEntry) {
18821882 CurrentEntry->skip();
18831883 if (Type == MT_Inline) {
18841884 IsAtEnd = true;
1885 CurrentEntry = 0;
1885 CurrentEntry = nullptr;
18861886 return;
18871887 }
18881888 }
18951895 case Token::TK_BlockEnd:
18961896 getNext();
18971897 IsAtEnd = true;
1898 CurrentEntry = 0;
1898 CurrentEntry = nullptr;
18991899 break;
19001900 default:
19011901 setError("Unexpected token. Expected Key or Block End", T);
19021902 case Token::TK_Error:
19031903 IsAtEnd = true;
1904 CurrentEntry = 0;
1904 CurrentEntry = nullptr;
19051905 }
19061906 } else {
19071907 switch (T.Kind) {
19141914 case Token::TK_Error:
19151915 // Set this to end iterator.
19161916 IsAtEnd = true;
1917 CurrentEntry = 0;
1917 CurrentEntry = nullptr;
19181918 break;
19191919 default:
19201920 setError( "Unexpected token. Expected Key, Flow Entry, or Flow "
19211921 "Mapping End."
19221922 , T);
19231923 IsAtEnd = true;
1924 CurrentEntry = 0;
1924 CurrentEntry = nullptr;
19251925 }
19261926 }
19271927 }
19291929 void SequenceNode::increment() {
19301930 if (failed()) {
19311931 IsAtEnd = true;
1932 CurrentEntry = 0;
1932 CurrentEntry = nullptr;
19331933 return;
19341934 }
19351935 if (CurrentEntry)
19401940 case Token::TK_BlockEntry:
19411941 getNext();
19421942 CurrentEntry = parseBlockNode();
1943 if (CurrentEntry == 0) { // An error occurred.
1943 if (CurrentEntry == nullptr) { // An error occurred.
19441944 IsAtEnd = true;
1945 CurrentEntry = 0;
1945 CurrentEntry = nullptr;
19461946 }
19471947 break;
19481948 case Token::TK_BlockEnd:
19491949 getNext();
19501950 IsAtEnd = true;
1951 CurrentEntry = 0;
1951 CurrentEntry = nullptr;
19521952 break;
19531953 default:
19541954 setError( "Unexpected token. Expected Block Entry or Block End."
19551955 , T);
19561956 case Token::TK_Error:
19571957 IsAtEnd = true;
1958 CurrentEntry = 0;
1958 CurrentEntry = nullptr;
19591959 }
19601960 } else if (SeqType == ST_Indentless) {
19611961 switch (T.Kind) {
19621962 case Token::TK_BlockEntry:
19631963 getNext();
19641964 CurrentEntry = parseBlockNode();
1965 if (CurrentEntry == 0) { // An error occurred.
1965 if (CurrentEntry == nullptr) { // An error occurred.
19661966 IsAtEnd = true;
1967 CurrentEntry = 0;
1967 CurrentEntry = nullptr;
19681968 }
19691969 break;
19701970 default:
19711971 case Token::TK_Error:
19721972 IsAtEnd = true;
1973 CurrentEntry = 0;
1973 CurrentEntry = nullptr;
19741974 }
19751975 } else if (SeqType == ST_Flow) {
19761976 switch (T.Kind) {
19841984 case Token::TK_Error:
19851985 // Set this to end iterator.
19861986 IsAtEnd = true;
1987 CurrentEntry = 0;
1987 CurrentEntry = nullptr;
19881988 break;
19891989 case Token::TK_StreamEnd:
19901990 case Token::TK_DocumentEnd:
19921992 setError("Could not find closing ]!", T);
19931993 // Set this to end iterator.
19941994 IsAtEnd = true;
1995 CurrentEntry = 0;
1995 CurrentEntry = nullptr;
19961996 break;
19971997 default:
19981998 if (!WasPreviousTokenFlowEntry) {
19991999 setError("Expected , between entries!", T);
20002000 IsAtEnd = true;
2001 CurrentEntry = 0;
2001 CurrentEntry = nullptr;
20022002 break;
20032003 }
20042004 // Otherwise it must be a flow entry.
20122012 }
20132013 }
20142014
2015 Document::Document(Stream &S) : stream(S), Root(0) {
2015 Document::Document(Stream &S) : stream(S), Root(nullptr) {
20162016 // Tag maps starts with two default mappings.
20172017 TagMap["!"] = "!";
20182018 TagMap["!!"] = "tag:yaml.org,2002:";
20692069 case Token::TK_Anchor:
20702070 if (AnchorInfo.Kind == Token::TK_Anchor) {
20712071 setError("Already encountered an anchor for this node!", T);
2072 return 0;
2072 return nullptr;
20732073 }
20742074 AnchorInfo = getNext(); // Consume TK_Anchor.
20752075 T = peekNext();
20772077 case Token::TK_Tag:
20782078 if (TagInfo.Kind == Token::TK_Tag) {
20792079 setError("Already encountered a tag for this node!", T);
2080 return 0;
2080 return nullptr;
20812081 }
20822082 TagInfo = getNext(); // Consume TK_Tag.
20832083 T = peekNext();
21452145 // !!null null.
21462146 return new (NodeAllocator) NullNode(stream.CurrentDoc);
21472147 case Token::TK_Error:
2148 return 0;
2148 return nullptr;
21492149 }
21502150 llvm_unreachable("Control flow shouldn't reach here.");
2151 return 0;
2151 return nullptr;
21522152 }
21532153
21542154 bool Document::parseDirectives() {
4646 void *DiagHandlerCtxt)
4747 : IO(Ctxt),
4848 Strm(new Stream(InputContent, SrcMgr)),
49 CurrentNode(NULL) {
49 CurrentNode(nullptr) {
5050 if (DiagHandler)
5151 SrcMgr.setDiagHandler(DiagHandler, DiagHandlerCtxt);
5252 DocIterator = Strm->begin();
350350 return new EmptyHNode(N);
351351 } else {
352352 setError(N, "unknown node kind");
353 return NULL;
353 return nullptr;
354354 }
355355 }
356356