diff options
| author | David Blaikie <dblaikie@gmail.com> | 2013-05-15 07:36:59 +0000 |
|---|---|---|
| committer | David Blaikie <dblaikie@gmail.com> | 2013-05-15 07:36:59 +0000 |
| commit | 453f4f01302f00651aae2fc7658f6e23a2beadb0 (patch) | |
| tree | 1454f10c61d8ed47d4f3e9f392f6c54366fca599 /lib | |
| parent | 1fe14c56f11c76aa90f27da633380548a9ee71a5 (diff) | |
| download | external_llvm-453f4f01302f00651aae2fc7658f6e23a2beadb0.zip external_llvm-453f4f01302f00651aae2fc7658f6e23a2beadb0.tar.gz external_llvm-453f4f01302f00651aae2fc7658f6e23a2beadb0.tar.bz2 | |
Use only explicit bool conversion operators
BitVector/SmallBitVector::reference::operator bool remain implicit since
they model more exactly a bool, rather than something else that can be
boolean tested.
The most common (non-buggy) case are where such objects are used as
return expressions in bool-returning functions or as boolean function
arguments. In those cases I've used (& added if necessary) a named
function to provide the equivalent (or sometimes negative, depending on
convenient wording) test.
One behavior change (YAMLParser) was made, though no test case is
included as I'm not sure how to reach that code path. Essentially any
comparison of llvm::yaml::document_iterators would be invalid if neither
iterator was at the end.
This helped uncover a couple of bugs in Clang - test cases provided for
those in a separate commit along with similar changes to `operator bool`
instances in Clang.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181868 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Analysis/MemoryDependenceAnalysis.cpp | 2 | ||||
| -rw-r--r-- | lib/CodeGen/RegAllocGreedy.cpp | 2 | ||||
| -rw-r--r-- | lib/Support/SourceMgr.cpp | 2 | ||||
| -rw-r--r-- | lib/Support/Windows/Windows.h | 2 |
4 files changed, 4 insertions, 4 deletions
diff --git a/lib/Analysis/MemoryDependenceAnalysis.cpp b/lib/Analysis/MemoryDependenceAnalysis.cpp index c0009cb..674ce3a 100644 --- a/lib/Analysis/MemoryDependenceAnalysis.cpp +++ b/lib/Analysis/MemoryDependenceAnalysis.cpp @@ -89,7 +89,7 @@ bool MemoryDependenceAnalysis::runOnFunction(Function &) { AA = &getAnalysis<AliasAnalysis>(); TD = getAnalysisIfAvailable<DataLayout>(); DT = getAnalysisIfAvailable<DominatorTree>(); - if (PredCache == 0) + if (!PredCache) PredCache.reset(new PredIteratorCache()); return false; } diff --git a/lib/CodeGen/RegAllocGreedy.cpp b/lib/CodeGen/RegAllocGreedy.cpp index 9eed1fc..4974828 100644 --- a/lib/CodeGen/RegAllocGreedy.cpp +++ b/lib/CodeGen/RegAllocGreedy.cpp @@ -713,7 +713,7 @@ bool RAGreedy::addSplitConstraints(InterferenceCache::Cursor Intf, Intf.moveToBlock(BC.Number); BC.Entry = BI.LiveIn ? SpillPlacement::PrefReg : SpillPlacement::DontCare; BC.Exit = BI.LiveOut ? SpillPlacement::PrefReg : SpillPlacement::DontCare; - BC.ChangesValue = BI.FirstDef; + BC.ChangesValue = BI.FirstDef.isValid(); if (!Intf.hasInterference()) continue; diff --git a/lib/Support/SourceMgr.cpp b/lib/Support/SourceMgr.cpp index fac3cad..4f650b4 100644 --- a/lib/Support/SourceMgr.cpp +++ b/lib/Support/SourceMgr.cpp @@ -65,7 +65,7 @@ unsigned SourceMgr::AddIncludeFile(const std::string &Filename, MemoryBuffer::getFile(IncludedFile.c_str(), NewBuf); } - if (NewBuf == 0) return ~0U; + if (!NewBuf) return ~0U; return AddNewSourceBuffer(NewBuf.take(), IncludeLoc); } diff --git a/lib/Support/Windows/Windows.h b/lib/Support/Windows/Windows.h index 5c1da0d..2ddd15e 100644 --- a/lib/Support/Windows/Windows.h +++ b/lib/Support/Windows/Windows.h @@ -75,7 +75,7 @@ public: } // True if Handle is valid. - operator bool() const { + LLVM_EXPLICIT operator bool() const { return HandleTraits::IsValid(Handle) ? true : false; } |
