summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2014-11-13 22:55:19 +0000
committerReid Kleckner <reid@kleckner.net>2014-11-13 22:55:19 +0000
commit971c3ea67b7ba140a5d7634111fd1063d86d2cdd (patch)
tree8848ac3f29b9828ac25ca2b3128764362f430a13 /llvm/lib/IR
parent8716b58583cf5e753f2dc2cfb214cdf24a839c43 (diff)
downloadbcm5719-llvm-971c3ea67b7ba140a5d7634111fd1063d86d2cdd.tar.gz
bcm5719-llvm-971c3ea67b7ba140a5d7634111fd1063d86d2cdd.zip
Use nullptr instead of NULL for variadic sentinels
Windows defines NULL to 0, which when used as an argument to a variadic function, is not a null pointer constant. As a result, Clang's -Wsentinel fires on this code. Using '0' would be wrong on most 64-bit platforms, but both MSVC and Clang make it work on Windows. Sidestep the issue with nullptr. llvm-svn: 221940
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r--llvm/lib/IR/Constants.cpp4
-rw-r--r--llvm/lib/IR/Instructions.cpp6
2 files changed, 5 insertions, 5 deletions
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp
index 21dbaccd609..c0012458168 100644
--- a/llvm/lib/IR/Constants.cpp
+++ b/llvm/lib/IR/Constants.cpp
@@ -1919,7 +1919,7 @@ Constant *ConstantExpr::getAlignOf(Type* Ty) {
// alignof is implemented as: (i64) gep ({i1,Ty}*)null, 0, 1
// Note that a non-inbounds gep is used, as null isn't within any object.
Type *AligningTy =
- StructType::get(Type::getInt1Ty(Ty->getContext()), Ty, NULL);
+ StructType::get(Type::getInt1Ty(Ty->getContext()), Ty, nullptr);
Constant *NullPtr = Constant::getNullValue(AligningTy->getPointerTo(0));
Constant *Zero = ConstantInt::get(Type::getInt64Ty(Ty->getContext()), 0);
Constant *One = ConstantInt::get(Type::getInt32Ty(Ty->getContext()), 1);
@@ -2712,7 +2712,7 @@ bool ConstantDataSequential::isCString() const {
}
/// getSplatValue - If this is a splat constant, meaning that all of the
-/// elements have the same value, return that value. Otherwise return NULL.
+/// elements have the same value, return that value. Otherwise return nullptr.
Constant *ConstantDataVector::getSplatValue() const {
const char *Base = getRawDataValues().data();
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 4b48d7d6eb0..57a4f0b61dd 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -364,7 +364,7 @@ bool CallInst::paramHasAttr(unsigned i, Attribute::AttrKind A) const {
/// IsConstantOne - Return true only if val is constant int 1
static bool IsConstantOne(Value *val) {
- assert(val && "IsConstantOne does not work with NULL val");
+ assert(val && "IsConstantOne does not work with nullptr val");
const ConstantInt *CVal = dyn_cast<ConstantInt>(val);
return CVal && CVal->isOne();
}
@@ -419,7 +419,7 @@ static Instruction *createMalloc(Instruction *InsertBefore,
Value *MallocFunc = MallocF;
if (!MallocFunc)
// prototype malloc as "void *malloc(size_t)"
- MallocFunc = M->getOrInsertFunction("malloc", BPTy, IntPtrTy, NULL);
+ MallocFunc = M->getOrInsertFunction("malloc", BPTy, IntPtrTy, nullptr);
PointerType *AllocPtrType = PointerType::getUnqual(AllocTy);
CallInst *MCall = nullptr;
Instruction *Result = nullptr;
@@ -492,7 +492,7 @@ static Instruction* createFree(Value* Source, Instruction *InsertBefore,
Type *VoidTy = Type::getVoidTy(M->getContext());
Type *IntPtrTy = Type::getInt8PtrTy(M->getContext());
// prototype free as "void free(void*)"
- Value *FreeFunc = M->getOrInsertFunction("free", VoidTy, IntPtrTy, NULL);
+ Value *FreeFunc = M->getOrInsertFunction("free", VoidTy, IntPtrTy, nullptr);
CallInst* Result = nullptr;
Value *PtrCast = Source;
if (InsertBefore) {
OpenPOWER on IntegriCloud