[llvm] r205829 - [C++11] Replace some comparisons with 'nullptr' with simple boolean checks to reduce verbosity.
David Blaikie
dblaikie at gmail.com
Wed Apr 9 10:11:37 PDT 2014
Cool. The assert cases seem less problematic, but probably good to
keep for consistency.
I wonder if we'll eventually be able to have a style (clang-fixit or
similar) warning for "explicitly compare pointers/ints/etc in contexts
that implicitly convert to bool, otherwise rely on the explicit
conversion" or something to that effect... maybe.
On Wed, Apr 9, 2014 at 9:35 AM, Craig Topper <craig.topper at gmail.com> wrote:
> Yeah I did see a few bool function arguments and didn't convert. Here a
> couple examples
>
> lib/IR/Verifier.cpp
> 347-void Verifier::visit(Instruction &I) {
> 348- for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i)
> 349: Assert1(I.getOperand(i) != nullptr, "Operand is null", &I);
> --
> 2022- for (Use &U : I.uses()) {
> 2023- if (Instruction *Used = dyn_cast<Instruction>(U.getUser()))
> 2024: Assert2(Used->getParent() != nullptr, "Instruction referencing"
> --
> 2031-
> 2032- for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i) {
> 2033: Assert1(I.getOperand(i) != nullptr, "Instruction has null
> operand!", &I);
>
> lib/IR/Globals.cpp
> 92- Constant *InitVal,
> 93- const Twine &Name, ThreadLocalMode TLMode,
> 94- unsigned AddressSpace,
> 95- bool isExternallyInitialized)
> 96- : GlobalValue(PointerType::get(Ty, AddressSpace),
> 97- Value::GlobalVariableVal,
> 98- OperandTraits<GlobalVariable>::op_begin(this),
> 99: InitVal != nullptr, Link, Name),
> --
> 113- const Twine &Name,
> 114- GlobalVariable *Before, ThreadLocalMode
> TLMode,
> 115- unsigned AddressSpace,
> 116- bool isExternallyInitialized)
> 117- : GlobalValue(PointerType::get(Ty, AddressSpace),
> 118- Value::GlobalVariableVal,
> 119- OperandTraits<GlobalVariable>::op_begin(this),
> 120: InitVal != nullptr, Link, Name),
>
>
> On Wed, Apr 9, 2014 at 9:24 AM, David Blaikie <dblaikie at gmail.com> wrote:
>>
>> Did you come across any cases of
>>
>> void func(bool)
>>
>> T *t;
>>
>> func(t);
>>
>> or similar? Implicit conversion in function parameters seems especially
>> subtle.
>>
>> On Wed, Apr 9, 2014 at 7:51 AM, Craig Topper <craig.topper at gmail.com>
>> wrote:
>> > There were also some cases of things like
>> >
>> > if (foo == 0 || bar == nullptr)
>> >
>> > Where i left the nullptr since it seemed better not to mix between
>> > explicit
>> > and implicit comparisons.
>> >
>> >
>> > On Wed, Apr 9, 2014 at 7:47 AM, Craig Topper <craig.topper at gmail.com>
>> > wrote:
>> >>
>> >> It wasn't discussed, but a significant portion of LLVM doesn't
>> >> explicitly
>> >> compare. I mostly only converted if statements since I know I've seen
>> >> lots
>> >> of if statements that don't explicitly compare.
>> >>
>> >> I didn't change things like
>> >>
>> >> bool bar = foo != nullptr;
>> >>
>> >> or
>> >>
>> >> bool bar() { return foo != nullptr; }
>> >>
>> >>
>> >> Since those seemed less clear without a comparison operation.
>> >>
>> >>
>> >>
>> >> On Wed, Apr 9, 2014 at 6:20 AM, Chandler Carruth <chandlerc at google.com>
>> >> wrote:
>> >>>
>> >>> FWIW, I think this is fine. The boolean test is idiomatic in C++ and I
>> >>> see no reason for LLVM to diverge.
>> >>>
>> >>> On Apr 9, 2014 1:36 PM, "Eli Bendersky" <eliben at google.com> wrote:
>> >>>>
>> >>>> Craig, was this change discussed somewhere? The LLVM coding
>> >>>> guidelines
>> >>>> are silent about this, but some C++ style guides recommend explicit
>> >>>> comparisons to nullptr.
>> >>>>
>> >>>> Eli
>> >>>>
>> >>>>
>> >>>> On Tue, Apr 8, 2014 at 9:20 PM, Craig Topper <craig.topper at gmail.com>
>> >>>> wrote:
>> >>>>>
>> >>>>> Author: ctopper
>> >>>>> Date: Tue Apr 8 23:20:00 2014
>> >>>>> New Revision: 205829
>> >>>>>
>> >>>>> URL: http://llvm.org/viewvc/llvm-project?rev=205829&view=rev
>> >>>>> Log:
>> >>>>> [C++11] Replace some comparisons with 'nullptr' with simple boolean
>> >>>>> checks to reduce verbosity.
>> >>>>>
>> >>>>> Modified:
>> >>>>> llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h
>> >>>>> llvm/trunk/include/llvm/ADT/StringRef.h
>> >>>>> llvm/trunk/include/llvm/ADT/ilist.h
>> >>>>> llvm/trunk/include/llvm/CodeGen/PBQP/Graph.h
>> >>>>> llvm/trunk/include/llvm/Support/CommandLine.h
>> >>>>> llvm/trunk/include/llvm/Support/FileSystem.h
>> >>>>> llvm/trunk/include/llvm/Support/YAMLParser.h
>> >>>>> llvm/trunk/lib/Support/Allocator.cpp
>> >>>>> llvm/trunk/lib/Support/CommandLine.cpp
>> >>>>> llvm/trunk/lib/Support/DynamicLibrary.cpp
>> >>>>> llvm/trunk/lib/Support/FoldingSet.cpp
>> >>>>> llvm/trunk/lib/Support/ManagedStatic.cpp
>> >>>>> llvm/trunk/lib/Support/PrettyStackTrace.cpp
>> >>>>> llvm/trunk/lib/Support/SourceMgr.cpp
>> >>>>> llvm/trunk/lib/Support/StringMap.cpp
>> >>>>> llvm/trunk/lib/Support/TargetRegistry.cpp
>> >>>>> llvm/trunk/lib/Support/Timer.cpp
>> >>>>> llvm/trunk/lib/Support/YAMLParser.cpp
>> >>>>> llvm/trunk/lib/Target/NVPTX/NVPTXFavorNonGenericAddrSpaces.cpp
>> >>>>>
>> >>>>> Modified: llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h
>> >>>>> URL:
>> >>>>>
>> >>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h?rev=205829&r1=205828&r2=205829&view=diff
>> >>>>>
>> >>>>>
>> >>>>> ==============================================================================
>> >>>>> --- llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h (original)
>> >>>>> +++ llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h Tue Apr 8
>> >>>>> 23:20:00 2014
>> >>>>> @@ -179,7 +179,7 @@ public:
>> >>>>>
>> >>>>> typedef T* (IntrusiveRefCntPtr::*unspecified_bool_type) ()
>> >>>>> const;
>> >>>>> operator unspecified_bool_type() const {
>> >>>>> - return Obj == nullptr ? nullptr :
>> >>>>> &IntrusiveRefCntPtr::getPtr;
>> >>>>> + return Obj ? &IntrusiveRefCntPtr::getPtr : nullptr;
>> >>>>> }
>> >>>>>
>> >>>>> void swap(IntrusiveRefCntPtr& other) {
>> >>>>>
>> >>>>> Modified: llvm/trunk/include/llvm/ADT/StringRef.h
>> >>>>> URL:
>> >>>>>
>> >>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringRef.h?rev=205829&r1=205828&r2=205829&view=diff
>> >>>>>
>> >>>>>
>> >>>>> ==============================================================================
>> >>>>> --- llvm/trunk/include/llvm/ADT/StringRef.h (original)
>> >>>>> +++ llvm/trunk/include/llvm/ADT/StringRef.h Tue Apr 8 23:20:00 2014
>> >>>>> @@ -186,7 +186,7 @@ namespace llvm {
>> >>>>>
>> >>>>> /// str - Get the contents as an std::string.
>> >>>>> std::string str() const {
>> >>>>> - if (Data == nullptr) return std::string();
>> >>>>> + if (!Data) return std::string();
>> >>>>> return std::string(Data, Length);
>> >>>>> }
>> >>>>>
>> >>>>>
>> >>>>> Modified: llvm/trunk/include/llvm/ADT/ilist.h
>> >>>>> URL:
>> >>>>>
>> >>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/ilist.h?rev=205829&r1=205828&r2=205829&view=diff
>> >>>>>
>> >>>>>
>> >>>>> ==============================================================================
>> >>>>> --- llvm/trunk/include/llvm/ADT/ilist.h (original)
>> >>>>> +++ llvm/trunk/include/llvm/ADT/ilist.h Tue Apr 8 23:20:00 2014
>> >>>>> @@ -383,7 +383,7 @@ public:
>> >>>>> // Miscellaneous inspection routines.
>> >>>>> size_type max_size() const { return size_type(-1); }
>> >>>>> bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const {
>> >>>>> - return Head == nullptr || Head == getTail();
>> >>>>> + return !Head || Head == getTail();
>> >>>>> }
>> >>>>>
>> >>>>> // Front and back accessor functions...
>> >>>>>
>> >>>>> Modified: llvm/trunk/include/llvm/CodeGen/PBQP/Graph.h
>> >>>>> URL:
>> >>>>>
>> >>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/PBQP/Graph.h?rev=205829&r1=205828&r2=205829&view=diff
>> >>>>>
>> >>>>>
>> >>>>> ==============================================================================
>> >>>>> --- llvm/trunk/include/llvm/CodeGen/PBQP/Graph.h (original)
>> >>>>> +++ llvm/trunk/include/llvm/CodeGen/PBQP/Graph.h Tue Apr 8 23:20:00
>> >>>>> 2014
>> >>>>> @@ -336,7 +336,7 @@ namespace PBQP {
>> >>>>> /// each node in the graph, and handleAddEdge for each edge, to
>> >>>>> give the
>> >>>>> /// solver an opportunity to set up any requried metadata.
>> >>>>> void setSolver(SolverT &S) {
>> >>>>> - assert(Solver == nullptr && "Solver already set. Call
>> >>>>> unsetSolver().");
>> >>>>> + assert(!Solver && "Solver already set. Call unsetSolver().");
>> >>>>> Solver = &S;
>> >>>>> for (auto NId : nodeIds())
>> >>>>> Solver->handleAddNode(NId);
>> >>>>> @@ -346,7 +346,7 @@ namespace PBQP {
>> >>>>>
>> >>>>> /// \brief Release from solver instance.
>> >>>>> void unsetSolver() {
>> >>>>> - assert(Solver != nullptr && "Solver not set.");
>> >>>>> + assert(Solver && "Solver not set.");
>> >>>>> Solver = nullptr;
>> >>>>> }
>> >>>>>
>> >>>>>
>> >>>>> Modified: llvm/trunk/include/llvm/Support/CommandLine.h
>> >>>>> URL:
>> >>>>>
>> >>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/CommandLine.h?rev=205829&r1=205828&r2=205829&view=diff
>> >>>>>
>> >>>>>
>> >>>>> ==============================================================================
>> >>>>> --- llvm/trunk/include/llvm/Support/CommandLine.h (original)
>> >>>>> +++ llvm/trunk/include/llvm/Support/CommandLine.h Tue Apr 8
>> >>>>> 23:20:00
>> >>>>> 2014
>> >>>>> @@ -1664,7 +1664,7 @@ class alias : public Option {
>> >>>>> void done() {
>> >>>>> if (!hasArgStr())
>> >>>>> error("cl::alias must have argument name specified!");
>> >>>>> - if (AliasFor == nullptr)
>> >>>>> + if (!AliasFor)
>> >>>>> error("cl::alias must have an cl::aliasopt(option)
>> >>>>> specified!");
>> >>>>> addArgument();
>> >>>>> }
>> >>>>>
>> >>>>> Modified: llvm/trunk/include/llvm/Support/FileSystem.h
>> >>>>> URL:
>> >>>>>
>> >>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/FileSystem.h?rev=205829&r1=205828&r2=205829&view=diff
>> >>>>>
>> >>>>>
>> >>>>> ==============================================================================
>> >>>>> --- llvm/trunk/include/llvm/Support/FileSystem.h (original)
>> >>>>> +++ llvm/trunk/include/llvm/Support/FileSystem.h Tue Apr 8 23:20:00
>> >>>>> 2014
>> >>>>> @@ -828,9 +828,9 @@ public:
>> >>>>> bool operator==(const directory_iterator &RHS) const {
>> >>>>> if (State == RHS.State)
>> >>>>> return true;
>> >>>>> - if (RHS.State == nullptr)
>> >>>>> + if (!RHS.State)
>> >>>>> return State->CurrentEntry == directory_entry();
>> >>>>> - if (State == nullptr)
>> >>>>> + if (!State)
>> >>>>> return RHS.State->CurrentEntry == directory_entry();
>> >>>>> return State->CurrentEntry == RHS.State->CurrentEntry;
>> >>>>> }
>> >>>>>
>> >>>>> Modified: llvm/trunk/include/llvm/Support/YAMLParser.h
>> >>>>> URL:
>> >>>>>
>> >>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/YAMLParser.h?rev=205829&r1=205828&r2=205829&view=diff
>> >>>>>
>> >>>>>
>> >>>>> ==============================================================================
>> >>>>> --- llvm/trunk/include/llvm/Support/YAMLParser.h (original)
>> >>>>> +++ llvm/trunk/include/llvm/Support/YAMLParser.h Tue Apr 8 23:20:00
>> >>>>> 2014
>> >>>>> @@ -305,7 +305,7 @@ public:
>> >>>>> assert(Base && "Attempted to advance iterator past end!");
>> >>>>> Base->increment();
>> >>>>> // Create an end iterator.
>> >>>>> - if (Base->CurrentEntry == nullptr)
>> >>>>> + if (!Base->CurrentEntry)
>> >>>>> Base = nullptr;
>> >>>>> return *this;
>> >>>>> }
>> >>>>>
>> >>>>> Modified: llvm/trunk/lib/Support/Allocator.cpp
>> >>>>> URL:
>> >>>>>
>> >>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Allocator.cpp?rev=205829&r1=205828&r2=205829&view=diff
>> >>>>>
>> >>>>>
>> >>>>> ==============================================================================
>> >>>>> --- llvm/trunk/lib/Support/Allocator.cpp (original)
>> >>>>> +++ llvm/trunk/lib/Support/Allocator.cpp Tue Apr 8 23:20:00 2014
>> >>>>> @@ -39,7 +39,7 @@ void MallocSlabAllocator::Deallocate(Mem
>> >>>>> void BumpPtrAllocatorBase::PrintStats() const {
>> >>>>> unsigned NumSlabs = 0;
>> >>>>> size_t TotalMemory = 0;
>> >>>>> - for (MemSlab *Slab = CurSlab; Slab != nullptr; Slab =
>> >>>>> Slab->NextPtr)
>> >>>>> {
>> >>>>> + for (MemSlab *Slab = CurSlab; Slab; Slab = Slab->NextPtr) {
>> >>>>> TotalMemory += Slab->Size;
>> >>>>> ++NumSlabs;
>> >>>>> }
>> >>>>> @@ -53,7 +53,7 @@ void BumpPtrAllocatorBase::PrintStats()
>> >>>>>
>> >>>>> size_t BumpPtrAllocatorBase::getTotalMemory() const {
>> >>>>> size_t TotalMemory = 0;
>> >>>>> - for (MemSlab *Slab = CurSlab; Slab != nullptr; Slab =
>> >>>>> Slab->NextPtr)
>> >>>>> {
>> >>>>> + for (MemSlab *Slab = CurSlab; Slab; Slab = Slab->NextPtr) {
>> >>>>> TotalMemory += Slab->Size;
>> >>>>> }
>> >>>>> return TotalMemory;
>> >>>>>
>> >>>>> Modified: llvm/trunk/lib/Support/CommandLine.cpp
>> >>>>> URL:
>> >>>>>
>> >>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CommandLine.cpp?rev=205829&r1=205828&r2=205829&view=diff
>> >>>>>
>> >>>>>
>> >>>>> ==============================================================================
>> >>>>> --- llvm/trunk/lib/Support/CommandLine.cpp (original)
>> >>>>> +++ llvm/trunk/lib/Support/CommandLine.cpp Tue Apr 8 23:20:00 2014
>> >>>>> @@ -300,7 +300,7 @@ static inline bool ProvideOption(Option
>> >>>>> // Enforce value requirements
>> >>>>> switch (Handler->getValueExpectedFlag()) {
>> >>>>> case ValueRequired:
>> >>>>> - if (Value.data() == nullptr) { // No value specified?
>> >>>>> + if (!Value.data()) { // No value specified?
>> >>>>> if (i+1 >= argc)
>> >>>>> return Handler->error("requires a value!");
>> >>>>> // Steal the next argument, like for '-o filename'
>> >>>>> @@ -400,7 +400,7 @@ static Option *HandlePrefixedOrGroupedOp
>> >>>>> // Do the lookup!
>> >>>>> size_t Length = 0;
>> >>>>> Option *PGOpt = getOptionPred(Arg, Length, isPrefixedOrGrouping,
>> >>>>> OptionsMap);
>> >>>>> - if (PGOpt == nullptr) return nullptr;
>> >>>>> + if (!PGOpt) return nullptr;
>> >>>>>
>> >>>>> // If the option is a prefixed option, then the value is simply
>> >>>>> the
>> >>>>> // rest of the name... so fall through to later processing, by
>> >>>>> @@ -770,7 +770,7 @@ void cl::ParseCommandLineOptions(int arg
>> >>>>>
>> >>>>> // Calculate how many positional values are _required_.
>> >>>>> bool UnboundedFound = false;
>> >>>>> - for (size_t i = ConsumeAfterOpt != nullptr, e =
>> >>>>> PositionalOpts.size();
>> >>>>> + for (size_t i = ConsumeAfterOpt ? 1 : 0, e =
>> >>>>> PositionalOpts.size();
>> >>>>> i != e; ++i) {
>> >>>>> Option *Opt = PositionalOpts[i];
>> >>>>> if (RequiresValue(Opt))
>> >>>>> @@ -845,8 +845,7 @@ void cl::ParseCommandLineOptions(int arg
>> >>>>> // All of the positional arguments have been fulfulled,
>> >>>>> give
>> >>>>> the rest to
>> >>>>> // the consume after option... if it's specified...
>> >>>>> //
>> >>>>> - if (PositionalVals.size() >= NumPositionalRequired &&
>> >>>>> - ConsumeAfterOpt != nullptr) {
>> >>>>> + if (PositionalVals.size() >= NumPositionalRequired &&
>> >>>>> ConsumeAfterOpt) {
>> >>>>> for (++i; i < argc; ++i)
>> >>>>> PositionalVals.push_back(std::make_pair(argv[i],i));
>> >>>>> break; // Handle outside of the argument processing
>> >>>>> loop...
>> >>>>> @@ -884,18 +883,18 @@ void cl::ParseCommandLineOptions(int arg
>> >>>>> Handler = LookupOption(ArgName, Value, Opts);
>> >>>>>
>> >>>>> // Check to see if this "option" is really a prefixed or
>> >>>>> grouped
>> >>>>> argument.
>> >>>>> - if (Handler == nullptr)
>> >>>>> + if (!Handler)
>> >>>>> Handler = HandlePrefixedOrGroupedOption(ArgName, Value,
>> >>>>> ErrorParsing,
>> >>>>> Opts);
>> >>>>>
>> >>>>> // Otherwise, look for the closest available option to report
>> >>>>> to
>> >>>>> the user
>> >>>>> // in the upcoming error.
>> >>>>> - if (Handler == nullptr && SinkOpts.empty())
>> >>>>> + if (!Handler && SinkOpts.empty())
>> >>>>> NearestHandler = LookupNearestOption(ArgName, Opts,
>> >>>>> NearestHandlerString);
>> >>>>> }
>> >>>>>
>> >>>>> - if (Handler == nullptr) {
>> >>>>> + if (!Handler) {
>> >>>>> if (SinkOpts.empty()) {
>> >>>>> errs() << ProgramName << ": Unknown command line argument
>> >>>>> '"
>> >>>>> << argv[i] << "'. Try: '" << argv[0] << " -help'\n";
>> >>>>> @@ -939,7 +938,7 @@ void cl::ParseCommandLineOptions(int arg
>> >>>>> << " positional arguments: See: " << argv[0] << "
>> >>>>> -help\n";
>> >>>>> ErrorParsing = true;
>> >>>>>
>> >>>>> - } else if (ConsumeAfterOpt == nullptr) {
>> >>>>> + } else if (!ConsumeAfterOpt) {
>> >>>>> // Positional args have already been handled if ConsumeAfter is
>> >>>>> specified.
>> >>>>> unsigned ValNo = 0, NumVals =
>> >>>>> static_cast<unsigned>(PositionalVals.size());
>> >>>>> for (size_t i = 0, e = PositionalOpts.size(); i != e; ++i) {
>> >>>>> @@ -1044,7 +1043,7 @@ void cl::ParseCommandLineOptions(int arg
>> >>>>> //
>> >>>>>
>> >>>>> bool Option::error(const Twine &Message, StringRef ArgName) {
>> >>>>> - if (ArgName.data() == nullptr) ArgName = ArgStr;
>> >>>>> + if (!ArgName.data()) ArgName = ArgStr;
>> >>>>> if (ArgName.empty())
>> >>>>> errs() << HelpStr; // Be nice for positional arguments
>> >>>>> else
>> >>>>> @@ -1779,7 +1778,7 @@ void cl::SetVersionPrinter(void (*func)(
>> >>>>> }
>> >>>>>
>> >>>>> void cl::AddExtraVersionPrinter(void (*func)()) {
>> >>>>> - if (ExtraVersionPrinters == nullptr)
>> >>>>> + if (!ExtraVersionPrinters)
>> >>>>> ExtraVersionPrinters = new std::vector<void (*)()>;
>> >>>>>
>> >>>>> ExtraVersionPrinters->push_back(func);
>> >>>>>
>> >>>>> Modified: llvm/trunk/lib/Support/DynamicLibrary.cpp
>> >>>>> URL:
>> >>>>>
>> >>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/DynamicLibrary.cpp?rev=205829&r1=205828&r2=205829&view=diff
>> >>>>>
>> >>>>>
>> >>>>> ==============================================================================
>> >>>>> --- llvm/trunk/lib/Support/DynamicLibrary.cpp (original)
>> >>>>> +++ llvm/trunk/lib/Support/DynamicLibrary.cpp Tue Apr 8 23:20:00
>> >>>>> 2014
>> >>>>> @@ -58,7 +58,7 @@ DynamicLibrary DynamicLibrary::getPerman
>> >>>>> SmartScopedLock<true> lock(*SymbolsMutex);
>> >>>>>
>> >>>>> void *handle = dlopen(filename, RTLD_LAZY|RTLD_GLOBAL);
>> >>>>> - if (handle == nullptr) {
>> >>>>> + if (!handle) {
>> >>>>> if (errMsg) *errMsg = dlerror();
>> >>>>> return DynamicLibrary();
>> >>>>> }
>> >>>>> @@ -66,11 +66,11 @@ DynamicLibrary DynamicLibrary::getPerman
>> >>>>> #ifdef __CYGWIN__
>> >>>>> // Cygwin searches symbols only in the main
>> >>>>> // with the handle of dlopen(NULL, RTLD_GLOBAL).
>> >>>>> - if (filename == NULL)
>> >>>>> + if (!filename)
>> >>>>> handle = RTLD_DEFAULT;
>> >>>>> #endif
>> >>>>>
>> >>>>> - if (OpenedHandles == nullptr)
>> >>>>> + if (!OpenedHandles)
>> >>>>> OpenedHandles = new DenseSet<void *>();
>> >>>>>
>> >>>>> // If we've already loaded this library, dlclose() the handle in
>> >>>>> order to
>> >>>>>
>> >>>>> Modified: llvm/trunk/lib/Support/FoldingSet.cpp
>> >>>>> URL:
>> >>>>>
>> >>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/FoldingSet.cpp?rev=205829&r1=205828&r2=205829&view=diff
>> >>>>>
>> >>>>>
>> >>>>> ==============================================================================
>> >>>>> --- llvm/trunk/lib/Support/FoldingSet.cpp (original)
>> >>>>> +++ llvm/trunk/lib/Support/FoldingSet.cpp Tue Apr 8 23:20:00 2014
>> >>>>> @@ -323,7 +323,7 @@ void FoldingSetImpl::InsertNode(Node *N,
>> >>>>> // If this is the first insertion into this bucket, its next
>> >>>>> pointer
>> >>>>> will be
>> >>>>> // null. Pretend as if it pointed to itself, setting the low bit
>> >>>>> to
>> >>>>> indicate
>> >>>>> // that it is a pointer to the bucket.
>> >>>>> - if (Next == nullptr)
>> >>>>> + if (!Next)
>> >>>>> Next =
>> >>>>> reinterpret_cast<void*>(reinterpret_cast<intptr_t>(Bucket)|1);
>> >>>>>
>> >>>>> // Set the node's next pointer, and make the bucket point to the
>> >>>>> node.
>> >>>>> @@ -337,7 +337,7 @@ bool FoldingSetImpl::RemoveNode(Node *N)
>> >>>>> // Because each bucket is a circular list, we don't need to
>> >>>>> compute
>> >>>>> N's hash
>> >>>>> // to remove it.
>> >>>>> void *Ptr = N->getNextInBucket();
>> >>>>> - if (Ptr == nullptr) return false; // Not in folding set.
>> >>>>> + if (!Ptr) return false; // Not in folding set.
>> >>>>>
>> >>>>> --NumNodes;
>> >>>>> N->SetNextInBucket(nullptr);
>> >>>>> @@ -390,7 +390,7 @@ FoldingSetImpl::Node *FoldingSetImpl::Ge
>> >>>>> FoldingSetIteratorImpl::FoldingSetIteratorImpl(void **Bucket) {
>> >>>>> // Skip to the first non-null non-self-cycle bucket.
>> >>>>> while (*Bucket != reinterpret_cast<void*>(-1) &&
>> >>>>> - (*Bucket == nullptr || GetNextPtr(*Bucket) == nullptr))
>> >>>>> + (!*Bucket || !GetNextPtr(*Bucket)))
>> >>>>> ++Bucket;
>> >>>>>
>> >>>>> NodePtr = static_cast<FoldingSetNode*>(*Bucket);
>> >>>>> @@ -410,7 +410,7 @@ void FoldingSetIteratorImpl::advance() {
>> >>>>> do {
>> >>>>> ++Bucket;
>> >>>>> } while (*Bucket != reinterpret_cast<void*>(-1) &&
>> >>>>> - (*Bucket == nullptr || GetNextPtr(*Bucket) ==
>> >>>>> nullptr));
>> >>>>> + (!*Bucket || !GetNextPtr(*Bucket)));
>> >>>>>
>> >>>>> NodePtr = static_cast<FoldingSetNode*>(*Bucket);
>> >>>>> }
>> >>>>> @@ -420,6 +420,5 @@ void FoldingSetIteratorImpl::advance() {
>> >>>>> // FoldingSetBucketIteratorImpl Implementation
>> >>>>>
>> >>>>> FoldingSetBucketIteratorImpl::FoldingSetBucketIteratorImpl(void
>> >>>>> **Bucket) {
>> >>>>> - Ptr = (*Bucket == nullptr || GetNextPtr(*Bucket) == nullptr) ?
>> >>>>> (void*) Bucket
>> >>>>> - :
>> >>>>> *Bucket;
>> >>>>> + Ptr = (!*Bucket || !GetNextPtr(*Bucket)) ? (void*) Bucket :
>> >>>>> *Bucket;
>> >>>>> }
>> >>>>>
>> >>>>> Modified: llvm/trunk/lib/Support/ManagedStatic.cpp
>> >>>>> URL:
>> >>>>>
>> >>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/ManagedStatic.cpp?rev=205829&r1=205828&r2=205829&view=diff
>> >>>>>
>> >>>>>
>> >>>>> ==============================================================================
>> >>>>> --- llvm/trunk/lib/Support/ManagedStatic.cpp (original)
>> >>>>> +++ llvm/trunk/lib/Support/ManagedStatic.cpp Tue Apr 8 23:20:00
>> >>>>> 2014
>> >>>>> @@ -24,7 +24,7 @@ void ManagedStaticBase::RegisterManagedS
>> >>>>> if (llvm_is_multithreaded()) {
>> >>>>> llvm_acquire_global_lock();
>> >>>>>
>> >>>>> - if (Ptr == nullptr) {
>> >>>>> + if (!Ptr) {
>> >>>>> void* tmp = Creator ? Creator() : nullptr;
>> >>>>>
>> >>>>> TsanHappensBefore(this);
>> >>>>>
>> >>>>> Modified: llvm/trunk/lib/Support/PrettyStackTrace.cpp
>> >>>>> URL:
>> >>>>>
>> >>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/PrettyStackTrace.cpp?rev=205829&r1=205828&r2=205829&view=diff
>> >>>>>
>> >>>>>
>> >>>>> ==============================================================================
>> >>>>> --- llvm/trunk/lib/Support/PrettyStackTrace.cpp (original)
>> >>>>> +++ llvm/trunk/lib/Support/PrettyStackTrace.cpp Tue Apr 8 23:20:00
>> >>>>> 2014
>> >>>>> @@ -46,7 +46,7 @@ static unsigned PrintStack(const PrettyS
>> >>>>> /// PrintCurStackTrace - Print the current stack trace to the
>> >>>>> specified stream.
>> >>>>> static void PrintCurStackTrace(raw_ostream &OS) {
>> >>>>> // Don't print an empty trace.
>> >>>>> - if (PrettyStackTraceHead->get() == nullptr) return;
>> >>>>> + if (!PrettyStackTraceHead->get()) return;
>> >>>>>
>> >>>>> // If there are pretty stack frames registered, walk and emit
>> >>>>> them.
>> >>>>> OS << "Stack dump:\n";
>> >>>>>
>> >>>>> Modified: llvm/trunk/lib/Support/SourceMgr.cpp
>> >>>>> URL:
>> >>>>>
>> >>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/SourceMgr.cpp?rev=205829&r1=205828&r2=205829&view=diff
>> >>>>>
>> >>>>>
>> >>>>> ==============================================================================
>> >>>>> --- llvm/trunk/lib/Support/SourceMgr.cpp (original)
>> >>>>> +++ llvm/trunk/lib/Support/SourceMgr.cpp Tue Apr 8 23:20:00 2014
>> >>>>> @@ -114,7 +114,7 @@ SourceMgr::getLineAndColumn(SMLoc Loc, i
>> >>>>> if (*Ptr == '\n') ++LineNo;
>> >>>>>
>> >>>>> // Allocate the line number cache if it doesn't exist.
>> >>>>> - if (LineNoCache == nullptr)
>> >>>>> + if (!LineNoCache)
>> >>>>> LineNoCache = new LineNoCacheTy();
>> >>>>>
>> >>>>> // Update the line # cache.
>> >>>>>
>> >>>>> Modified: llvm/trunk/lib/Support/StringMap.cpp
>> >>>>> URL:
>> >>>>>
>> >>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/StringMap.cpp?rev=205829&r1=205828&r2=205829&view=diff
>> >>>>>
>> >>>>>
>> >>>>> ==============================================================================
>> >>>>> --- llvm/trunk/lib/Support/StringMap.cpp (original)
>> >>>>> +++ llvm/trunk/lib/Support/StringMap.cpp Tue Apr 8 23:20:00 2014
>> >>>>> @@ -70,7 +70,7 @@ unsigned StringMapImpl::LookupBucketFor(
>> >>>>> while (1) {
>> >>>>> StringMapEntryBase *BucketItem = TheTable[BucketNo];
>> >>>>> // If we found an empty bucket, this key isn't in the table
>> >>>>> yet,
>> >>>>> return it.
>> >>>>> - if (LLVM_LIKELY(BucketItem == nullptr)) {
>> >>>>> + if (LLVM_LIKELY(!BucketItem)) {
>> >>>>> // If we found a tombstone, we want to reuse the tombstone
>> >>>>> instead of an
>> >>>>> // empty bucket. This reduces probing.
>> >>>>> if (FirstTombstone != -1) {
>> >>>>> @@ -124,7 +124,7 @@ int StringMapImpl::FindKey(StringRef Key
>> >>>>> while (1) {
>> >>>>> StringMapEntryBase *BucketItem = TheTable[BucketNo];
>> >>>>> // If we found an empty bucket, this key isn't in the table
>> >>>>> yet,
>> >>>>> return.
>> >>>>> - if (LLVM_LIKELY(BucketItem == nullptr))
>> >>>>> + if (LLVM_LIKELY(!BucketItem))
>> >>>>> return -1;
>> >>>>>
>> >>>>> if (BucketItem == getTombstoneVal()) {
>> >>>>> @@ -212,7 +212,7 @@ void StringMapImpl::RehashTable() {
>> >>>>> // Fast case, bucket available.
>> >>>>> unsigned FullHash = HashTable[I];
>> >>>>> unsigned NewBucket = FullHash & (NewSize-1);
>> >>>>> - if (NewTableArray[NewBucket] == nullptr) {
>> >>>>> + if (!NewTableArray[NewBucket]) {
>> >>>>> NewTableArray[FullHash & (NewSize-1)] = Bucket;
>> >>>>> NewHashArray[FullHash & (NewSize-1)] = FullHash;
>> >>>>> continue;
>> >>>>>
>> >>>>> Modified: llvm/trunk/lib/Support/TargetRegistry.cpp
>> >>>>> URL:
>> >>>>>
>> >>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/TargetRegistry.cpp?rev=205829&r1=205828&r2=205829&view=diff
>> >>>>>
>> >>>>>
>> >>>>> ==============================================================================
>> >>>>> --- llvm/trunk/lib/Support/TargetRegistry.cpp (original)
>> >>>>> +++ llvm/trunk/lib/Support/TargetRegistry.cpp Tue Apr 8 23:20:00
>> >>>>> 2014
>> >>>>> @@ -53,7 +53,7 @@ const Target *TargetRegistry::lookupTarg
>> >>>>> // Get the target specific parser.
>> >>>>> std::string TempError;
>> >>>>> TheTarget = TargetRegistry::lookupTarget(TheTriple.getTriple(),
>> >>>>> TempError);
>> >>>>> - if (TheTarget == nullptr) {
>> >>>>> + if (!TheTarget) {
>> >>>>> Error = ": error: unable to get target for '"
>> >>>>> + TheTriple.getTriple()
>> >>>>> + "', see --version and --triple.\n";
>> >>>>>
>> >>>>> Modified: llvm/trunk/lib/Support/Timer.cpp
>> >>>>> URL:
>> >>>>>
>> >>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Timer.cpp?rev=205829&r1=205828&r2=205829&view=diff
>> >>>>>
>> >>>>>
>> >>>>> ==============================================================================
>> >>>>> --- llvm/trunk/lib/Support/Timer.cpp (original)
>> >>>>> +++ llvm/trunk/lib/Support/Timer.cpp Tue Apr 8 23:20:00 2014
>> >>>>> @@ -264,7 +264,7 @@ TimerGroup::TimerGroup(StringRef name)
>> >>>>> TimerGroup::~TimerGroup() {
>> >>>>> // If the timer group is destroyed before the timers it owns,
>> >>>>> accumulate and
>> >>>>> // print the timing data.
>> >>>>> - while (FirstTimer != nullptr)
>> >>>>> + while (FirstTimer)
>> >>>>> removeTimer(*FirstTimer);
>> >>>>>
>> >>>>> // Remove the group from the TimerGroupList.
>> >>>>> @@ -291,7 +291,7 @@ void TimerGroup::removeTimer(Timer &T) {
>> >>>>>
>> >>>>> // Print the report when all timers in this group are destroyed
>> >>>>> if
>> >>>>> some of
>> >>>>> // them were started.
>> >>>>> - if (FirstTimer != nullptr || TimersToPrint.empty())
>> >>>>> + if (FirstTimer || TimersToPrint.empty())
>> >>>>> return;
>> >>>>>
>> >>>>> raw_ostream *OutStream = CreateInfoOutputFile();
>> >>>>>
>> >>>>> Modified: llvm/trunk/lib/Support/YAMLParser.cpp
>> >>>>> URL:
>> >>>>>
>> >>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/YAMLParser.cpp?rev=205829&r1=205828&r2=205829&view=diff
>> >>>>>
>> >>>>>
>> >>>>> ==============================================================================
>> >>>>> --- llvm/trunk/lib/Support/YAMLParser.cpp (original)
>> >>>>> +++ llvm/trunk/lib/Support/YAMLParser.cpp Tue Apr 8 23:20:00 2014
>> >>>>> @@ -1941,7 +1941,7 @@ void SequenceNode::increment() {
>> >>>>> case Token::TK_BlockEntry:
>> >>>>> getNext();
>> >>>>> CurrentEntry = parseBlockNode();
>> >>>>> - if (CurrentEntry == nullptr) { // An error occurred.
>> >>>>> + if (!CurrentEntry) { // An error occurred.
>> >>>>> IsAtEnd = true;
>> >>>>> CurrentEntry = nullptr;
>> >>>>> }
>> >>>>> @@ -1963,7 +1963,7 @@ void SequenceNode::increment() {
>> >>>>> case Token::TK_BlockEntry:
>> >>>>> getNext();
>> >>>>> CurrentEntry = parseBlockNode();
>> >>>>> - if (CurrentEntry == nullptr) { // An error occurred.
>> >>>>> + if (!CurrentEntry) { // An error occurred.
>> >>>>> IsAtEnd = true;
>> >>>>> CurrentEntry = nullptr;
>> >>>>> }
>> >>>>>
>> >>>>> Modified:
>> >>>>> llvm/trunk/lib/Target/NVPTX/NVPTXFavorNonGenericAddrSpaces.cpp
>> >>>>> URL:
>> >>>>>
>> >>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXFavorNonGenericAddrSpaces.cpp?rev=205829&r1=205828&r2=205829&view=diff
>> >>>>>
>> >>>>>
>> >>>>> ==============================================================================
>> >>>>> --- llvm/trunk/lib/Target/NVPTX/NVPTXFavorNonGenericAddrSpaces.cpp
>> >>>>> (original)
>> >>>>> +++ llvm/trunk/lib/Target/NVPTX/NVPTXFavorNonGenericAddrSpaces.cpp
>> >>>>> Tue
>> >>>>> Apr 8 23:20:00 2014
>> >>>>> @@ -111,7 +111,7 @@ static bool IsEliminableAddrSpaceCast(Op
>> >>>>> bool NVPTXFavorNonGenericAddrSpaces::hoistAddrSpaceCastFromGEP(
>> >>>>> GEPOperator *GEP) {
>> >>>>> Operator *Cast = dyn_cast<Operator>(GEP->getPointerOperand());
>> >>>>> - if (Cast == nullptr)
>> >>>>> + if (!Cast)
>> >>>>> return false;
>> >>>>>
>> >>>>> if (!IsEliminableAddrSpaceCast(Cast))
>> >>>>>
>> >>>>>
>> >>>>> _______________________________________________
>> >>>>> llvm-commits mailing list
>> >>>>> llvm-commits at cs.uiuc.edu
>> >>>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>> >>>>
>> >>>>
>> >>>>
>> >>>> _______________________________________________
>> >>>> llvm-commits mailing list
>> >>>> llvm-commits at cs.uiuc.edu
>> >>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>> >>>>
>> >>
>> >>
>> >>
>> >> --
>> >> ~Craig
>> >
>> >
>> >
>> >
>> > --
>> > ~Craig
>> >
>> > _______________________________________________
>> > llvm-commits mailing list
>> > llvm-commits at cs.uiuc.edu
>> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>> >
>
>
>
>
> --
> ~Craig
More information about the llvm-commits
mailing list