llvm.org GIT mirror llvm / 725011e
[C++11] Replace some comparisons with 'nullptr' with simple boolean checks to reduce verbosity. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205829 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 6 years ago
19 changed file(s) with 42 addition(s) and 44 deletion(s). Raw diff Collapse all Expand all
178178
179179 typedef T* (IntrusiveRefCntPtr::*unspecified_bool_type) () const;
180180 operator unspecified_bool_type() const {
181 return Obj == nullptr ? nullptr : &IntrusiveRefCntPtr::getPtr;
181 return Obj ? &IntrusiveRefCntPtr::getPtr : nullptr;
182182 }
183183
184184 void swap(IntrusiveRefCntPtr& other) {
185185
186186 /// str - Get the contents as an std::string.
187187 std::string str() const {
188 if (Data == nullptr) return std::string();
188 if (!Data) return std::string();
189189 return std::string(Data, Length);
190190 }
191191
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 == nullptr || Head == getTail();
385 return !Head || Head == getTail();
386386 }
387387
388388 // Front and back accessor functions...
335335 /// each node in the graph, and handleAddEdge for each edge, to give the
336336 /// solver an opportunity to set up any requried metadata.
337337 void setSolver(SolverT &S) {
338 assert(Solver == nullptr && "Solver already set. Call unsetSolver().");
338 assert(!Solver && "Solver already set. Call unsetSolver().");
339339 Solver = &S;
340340 for (auto NId : nodeIds())
341341 Solver->handleAddNode(NId);
345345
346346 /// \brief Release from solver instance.
347347 void unsetSolver() {
348 assert(Solver != nullptr && "Solver not set.");
348 assert(Solver && "Solver not set.");
349349 Solver = nullptr;
350350 }
351351
16631663 void done() {
16641664 if (!hasArgStr())
16651665 error("cl::alias must have argument name specified!");
1666 if (AliasFor == nullptr)
1666 if (!AliasFor)
16671667 error("cl::alias must have an cl::aliasopt(option) specified!");
16681668 addArgument();
16691669 }
827827 bool operator==(const directory_iterator &RHS) const {
828828 if (State == RHS.State)
829829 return true;
830 if (RHS.State == nullptr)
830 if (!RHS.State)
831831 return State->CurrentEntry == directory_entry();
832 if (State == nullptr)
832 if (!State)
833833 return RHS.State->CurrentEntry == directory_entry();
834834 return State->CurrentEntry == RHS.State->CurrentEntry;
835835 }
304304 assert(Base && "Attempted to advance iterator past end!");
305305 Base->increment();
306306 // Create an end iterator.
307 if (Base->CurrentEntry == nullptr)
307 if (!Base->CurrentEntry)
308308 Base = nullptr;
309309 return *this;
310310 }
3838 void BumpPtrAllocatorBase::PrintStats() const {
3939 unsigned NumSlabs = 0;
4040 size_t TotalMemory = 0;
41 for (MemSlab *Slab = CurSlab; Slab != nullptr; Slab = Slab->NextPtr) {
41 for (MemSlab *Slab = CurSlab; Slab; 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 != nullptr; Slab = Slab->NextPtr) {
55 for (MemSlab *Slab = CurSlab; Slab; Slab = Slab->NextPtr) {
5656 TotalMemory += Slab->Size;
5757 }
5858 return TotalMemory;
299299 // Enforce value requirements
300300 switch (Handler->getValueExpectedFlag()) {
301301 case ValueRequired:
302 if (Value.data() == nullptr) { // No value specified?
302 if (!Value.data()) { // No value specified?
303303 if (i+1 >= argc)
304304 return Handler->error("requires a value!");
305305 // Steal the next argument, like for '-o filename'
399399 // Do the lookup!
400400 size_t Length = 0;
401401 Option *PGOpt = getOptionPred(Arg, Length, isPrefixedOrGrouping, OptionsMap);
402 if (PGOpt == nullptr) return nullptr;
402 if (!PGOpt) 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
769769
770770 // Calculate how many positional values are _required_.
771771 bool UnboundedFound = false;
772 for (size_t i = ConsumeAfterOpt != nullptr, e = PositionalOpts.size();
772 for (size_t i = ConsumeAfterOpt ? 1 : 0, e = PositionalOpts.size();
773773 i != e; ++i) {
774774 Option *Opt = PositionalOpts[i];
775775 if (RequiresValue(Opt))
844844 // All of the positional arguments have been fulfulled, give the rest to
845845 // the consume after option... if it's specified...
846846 //
847 if (PositionalVals.size() >= NumPositionalRequired &&
848 ConsumeAfterOpt != nullptr) {
847 if (PositionalVals.size() >= NumPositionalRequired && ConsumeAfterOpt) {
849848 for (++i; i < argc; ++i)
850849 PositionalVals.push_back(std::make_pair(argv[i],i));
851850 break; // Handle outside of the argument processing loop...
883882 Handler = LookupOption(ArgName, Value, Opts);
884883
885884 // Check to see if this "option" is really a prefixed or grouped argument.
886 if (Handler == nullptr)
885 if (!Handler)
887886 Handler = HandlePrefixedOrGroupedOption(ArgName, Value,
888887 ErrorParsing, Opts);
889888
890889 // Otherwise, look for the closest available option to report to the user
891890 // in the upcoming error.
892 if (Handler == nullptr && SinkOpts.empty())
891 if (!Handler && SinkOpts.empty())
893892 NearestHandler = LookupNearestOption(ArgName, Opts,
894893 NearestHandlerString);
895894 }
896895
897 if (Handler == nullptr) {
896 if (!Handler) {
898897 if (SinkOpts.empty()) {
899898 errs() << ProgramName << ": Unknown command line argument '"
900899 << argv[i] << "'. Try: '" << argv[0] << " -help'\n";
938937 << " positional arguments: See: " << argv[0] << " -help\n";
939938 ErrorParsing = true;
940939
941 } else if (ConsumeAfterOpt == nullptr) {
940 } else if (!ConsumeAfterOpt) {
942941 // Positional args have already been handled if ConsumeAfter is specified.
943942 unsigned ValNo = 0, NumVals = static_cast(PositionalVals.size());
944943 for (size_t i = 0, e = PositionalOpts.size(); i != e; ++i) {
10431042 //
10441043
10451044 bool Option::error(const Twine &Message, StringRef ArgName) {
1046 if (ArgName.data() == nullptr) ArgName = ArgStr;
1045 if (!ArgName.data()) ArgName = ArgStr;
10471046 if (ArgName.empty())
10481047 errs() << HelpStr; // Be nice for positional arguments
10491048 else
17781777 }
17791778
17801779 void cl::AddExtraVersionPrinter(void (*func)()) {
1781 if (ExtraVersionPrinters == nullptr)
1780 if (!ExtraVersionPrinters)
17821781 ExtraVersionPrinters = new std::vector;
17831782
17841783 ExtraVersionPrinters->push_back(func);
5757 SmartScopedLock lock(*SymbolsMutex);
5858
5959 void *handle = dlopen(filename, RTLD_LAZY|RTLD_GLOBAL);
60 if (handle == nullptr) {
60 if (!handle) {
6161 if (errMsg) *errMsg = dlerror();
6262 return DynamicLibrary();
6363 }
6565 #ifdef __CYGWIN__
6666 // Cygwin searches symbols only in the main
6767 // with the handle of dlopen(NULL, RTLD_GLOBAL).
68 if (filename == NULL)
68 if (!filename)
6969 handle = RTLD_DEFAULT;
7070 #endif
7171
72 if (OpenedHandles == nullptr)
72 if (!OpenedHandles)
7373 OpenedHandles = new DenseSet();
7474
7575 // If we've already loaded this library, dlclose() the handle in order to
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 == nullptr)
325 if (!Next)
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 == nullptr) return false; // Not in folding set.
339 if (!Ptr) return false; // Not in folding set.
340340
341341 --NumNodes;
342342 N->SetNextInBucket(nullptr);
389389 FoldingSetIteratorImpl::FoldingSetIteratorImpl(void **Bucket) {
390390 // Skip to the first non-null non-self-cycle bucket.
391391 while (*Bucket != reinterpret_cast(-1) &&
392 (*Bucket == nullptr || GetNextPtr(*Bucket) == nullptr))
392 (!*Bucket || !GetNextPtr(*Bucket)))
393393 ++Bucket;
394394
395395 NodePtr = static_cast(*Bucket);
409409 do {
410410 ++Bucket;
411411 } while (*Bucket != reinterpret_cast(-1) &&
412 (*Bucket == nullptr || GetNextPtr(*Bucket) == nullptr));
412 (!*Bucket || !GetNextPtr(*Bucket)));
413413
414414 NodePtr = static_cast(*Bucket);
415415 }
419419 // FoldingSetBucketIteratorImpl Implementation
420420
421421 FoldingSetBucketIteratorImpl::FoldingSetBucketIteratorImpl(void **Bucket) {
422 Ptr = (*Bucket == nullptr || GetNextPtr(*Bucket) == nullptr) ? (void*) Bucket
423 : *Bucket;
424 }
422 Ptr = (!*Bucket || !GetNextPtr(*Bucket)) ? (void*) Bucket : *Bucket;
423 }
2323 if (llvm_is_multithreaded()) {
2424 llvm_acquire_global_lock();
2525
26 if (Ptr == nullptr) {
26 if (!Ptr) {
2727 void* tmp = Creator ? Creator() : nullptr;
2828
2929 TsanHappensBefore(this);
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() == nullptr) return;
48 if (!PrettyStackTraceHead->get()) return;
4949
5050 // If there are pretty stack frames registered, walk and emit them.
5151 OS << "Stack dump:\n";
113113 if (*Ptr == '\n') ++LineNo;
114114
115115 // Allocate the line number cache if it doesn't exist.
116 if (LineNoCache == nullptr)
116 if (!LineNoCache)
117117 LineNoCache = new LineNoCacheTy();
118118
119119 // Update the line # cache.
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 == nullptr)) {
72 if (LLVM_LIKELY(!BucketItem)) {
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 == nullptr))
126 if (LLVM_LIKELY(!BucketItem))
127127 return -1;
128128
129129 if (BucketItem == getTombstoneVal()) {
211211 // Fast case, bucket available.
212212 unsigned FullHash = HashTable[I];
213213 unsigned NewBucket = FullHash & (NewSize-1);
214 if (NewTableArray[NewBucket] == nullptr) {
214 if (!NewTableArray[NewBucket]) {
215215 NewTableArray[FullHash & (NewSize-1)] = Bucket;
216216 NewHashArray[FullHash & (NewSize-1)] = FullHash;
217217 continue;
5252 // Get the target specific parser.
5353 std::string TempError;
5454 TheTarget = TargetRegistry::lookupTarget(TheTriple.getTriple(), TempError);
55 if (TheTarget == nullptr) {
55 if (!TheTarget) {
5656 Error = ": error: unable to get target for '"
5757 + TheTriple.getTriple()
5858 + "', see --version and --triple.\n";
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 != nullptr)
266 while (FirstTimer)
267267 removeTimer(*FirstTimer);
268268
269269 // Remove the group from the TimerGroupList.
290290
291291 // Print the report when all timers in this group are destroyed if some of
292292 // them were started.
293 if (FirstTimer != nullptr || TimersToPrint.empty())
293 if (FirstTimer || TimersToPrint.empty())
294294 return;
295295
296296 raw_ostream *OutStream = CreateInfoOutputFile();
19401940 case Token::TK_BlockEntry:
19411941 getNext();
19421942 CurrentEntry = parseBlockNode();
1943 if (CurrentEntry == nullptr) { // An error occurred.
1943 if (!CurrentEntry) { // An error occurred.
19441944 IsAtEnd = true;
19451945 CurrentEntry = nullptr;
19461946 }
19621962 case Token::TK_BlockEntry:
19631963 getNext();
19641964 CurrentEntry = parseBlockNode();
1965 if (CurrentEntry == nullptr) { // An error occurred.
1965 if (!CurrentEntry) { // An error occurred.
19661966 IsAtEnd = true;
19671967 CurrentEntry = nullptr;
19681968 }
110110 bool NVPTXFavorNonGenericAddrSpaces::hoistAddrSpaceCastFromGEP(
111111 GEPOperator *GEP) {
112112 Operator *Cast = dyn_cast(GEP->getPointerOperand());
113 if (Cast == nullptr)
113 if (!Cast)
114114 return false;
115115
116116 if (!IsEliminableAddrSpaceCast(Cast))