diff options
author | Craig Topper <craig.topper@gmail.com> | 2014-04-09 06:08:46 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2014-04-09 06:08:46 +0000 |
commit | ec0f0bc6afa8d2c1f427ec55264fc78738b83ef6 (patch) | |
tree | 9fd922368890f4c0e51831dc17d85d7f793a15c3 /lib/IR/Metadata.cpp | |
parent | 8a0d1c8f06391add493d0ff4b7344fce3420d2d5 (diff) | |
download | llvm-ec0f0bc6afa8d2c1f427ec55264fc78738b83ef6.tar.gz llvm-ec0f0bc6afa8d2c1f427ec55264fc78738b83ef6.tar.bz2 llvm-ec0f0bc6afa8d2c1f427ec55264fc78738b83ef6.tar.xz |
[C++11] More 'nullptr' conversion or in some cases just using a boolean check instead of comparing to nullptr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205831 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR/Metadata.cpp')
-rw-r--r-- | lib/IR/Metadata.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/lib/IR/Metadata.cpp b/lib/IR/Metadata.cpp index ba393345db..39acbd8106 100644 --- a/lib/IR/Metadata.cpp +++ b/lib/IR/Metadata.cpp @@ -87,7 +87,7 @@ public: MDNodeOperand::~MDNodeOperand() {} void MDNodeOperand::deleted() { - getParent()->replaceOperand(this, 0); + getParent()->replaceOperand(this, nullptr); } void MDNodeOperand::allUsesReplacedWith(Value *NV) { @@ -148,10 +148,10 @@ MDNode::~MDNode() { } static const Function *getFunctionForValue(Value *V) { - if (!V) return NULL; + if (!V) return nullptr; if (Instruction *I = dyn_cast<Instruction>(V)) { BasicBlock *BB = I->getParent(); - return BB ? BB->getParent() : 0; + return BB ? BB->getParent() : nullptr; } if (Argument *A = dyn_cast<Argument>(V)) return A->getParent(); @@ -159,7 +159,7 @@ static const Function *getFunctionForValue(Value *V) { return BB->getParent(); if (MDNode *MD = dyn_cast<MDNode>(V)) return MD->getFunction(); - return NULL; + return nullptr; } #ifndef NDEBUG @@ -192,11 +192,11 @@ const Function *MDNode::getFunction() const { #ifndef NDEBUG return assertLocalFunction(this); #else - if (!isFunctionLocal()) return NULL; + if (!isFunctionLocal()) return nullptr; for (unsigned i = 0, e = getNumOperands(); i != e; ++i) if (const Function *F = getFunctionForValue(getOperand(i))) return F; - return NULL; + return nullptr; #endif } @@ -335,14 +335,14 @@ void MDNode::replaceOperand(MDNodeOperand *Op, Value *To) { // Likewise if the MDNode is function-local but for a different function. if (To && isFunctionLocalValue(To)) { if (!isFunctionLocal()) - To = 0; + To = nullptr; else { const Function *F = getFunction(); const Function *FV = getFunctionForValue(To); // Metadata can be function-local without having an associated function. // So only consider functions to have changed if non-null. if (F && FV && F != FV) - To = 0; + To = nullptr; } } @@ -366,7 +366,7 @@ void MDNode::replaceOperand(MDNodeOperand *Op, Value *To) { // anymore. This commonly occurs during destruction, and uniquing these // brings little reuse. Also, this means we don't need to include // isFunctionLocal bits in FoldingSetNodeIDs for MDNodes. - if (To == 0) { + if (!To) { setIsNotUniqued(); return; } @@ -407,7 +407,7 @@ void MDNode::replaceOperand(MDNodeOperand *Op, Value *To) { MDNode *MDNode::getMostGenericFPMath(MDNode *A, MDNode *B) { if (!A || !B) - return NULL; + return nullptr; APFloat AVal = cast<ConstantFP>(A->getOperand(0))->getValueAPF(); APFloat BVal = cast<ConstantFP>(B->getOperand(0))->getValueAPF(); @@ -457,7 +457,7 @@ MDNode *MDNode::getMostGenericRange(MDNode *A, MDNode *B) { // the ones that overlap. if (!A || !B) - return NULL; + return nullptr; if (A == B) return A; @@ -512,7 +512,7 @@ MDNode *MDNode::getMostGenericRange(MDNode *A, MDNode *B) { ConstantRange Range(cast<ConstantInt>(EndPoints[0])->getValue(), cast<ConstantInt>(EndPoints[1])->getValue()); if (Range.isFullSet()) - return NULL; + return nullptr; } return MDNode::get(A->getContext(), EndPoints); @@ -527,7 +527,7 @@ static SmallVector<TrackingVH<MDNode>, 4> &getNMDOps(void *Operands) { } NamedMDNode::NamedMDNode(const Twine &N) - : Name(N.str()), Parent(0), + : Name(N.str()), Parent(nullptr), Operands(new SmallVector<TrackingVH<MDNode>, 4>()) { } @@ -575,7 +575,7 @@ StringRef NamedMDNode::getName() const { // void Instruction::setMetadata(StringRef Kind, MDNode *Node) { - if (Node == 0 && !hasMetadata()) return; + if (!Node && !hasMetadata()) return; setMetadata(getContext().getMDKindID(Kind), Node); } @@ -631,7 +631,7 @@ void Instruction::dropUnknownMetadata(ArrayRef<unsigned> KnownIDs) { /// node. This updates/replaces metadata if already present, or removes it if /// Node is null. void Instruction::setMetadata(unsigned KindID, MDNode *Node) { - if (Node == 0 && !hasMetadata()) return; + if (!Node && !hasMetadata()) return; // Handle 'dbg' as a special case since it is not stored in the hash table. if (KindID == LLVMContext::MD_dbg) { @@ -691,7 +691,7 @@ MDNode *Instruction::getMetadataImpl(unsigned KindID) const { if (KindID == LLVMContext::MD_dbg) return DbgLoc.getAsMDNode(getContext()); - if (!hasMetadataHashEntry()) return 0; + if (!hasMetadataHashEntry()) return nullptr; LLVMContextImpl::MDMapTy &Info = getContext().pImpl->MetadataStore[this]; assert(!Info.empty() && "bit out of sync with hash table"); @@ -699,7 +699,7 @@ MDNode *Instruction::getMetadataImpl(unsigned KindID) const { for (const auto &I : Info) if (I.first == KindID) return I.second; - return 0; + return nullptr; } void Instruction::getAllMetadataImpl(SmallVectorImpl<std::pair<unsigned, |