From: Craig Topper Date: Wed, 21 May 2014 05:09:00 +0000 (+0000) Subject: [C++11] Use 'nullptr'. CodeGen edition. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d1008e5c93536222903523b70245ec66876bbad5;p=clang [C++11] Use 'nullptr'. CodeGen edition. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209272 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/BackendUtil.cpp b/lib/CodeGen/BackendUtil.cpp index 4e08780ad9..fc6c5949d5 100644 --- a/lib/CodeGen/BackendUtil.cpp +++ b/lib/CodeGen/BackendUtil.cpp @@ -113,7 +113,8 @@ public: Module *M) : Diags(_Diags), CodeGenOpts(CGOpts), TargetOpts(TOpts), LangOpts(LOpts), TheModule(M), CodeGenerationTime("Code Generation Time"), - CodeGenPasses(0), PerModulePasses(0), PerFunctionPasses(0) {} + CodeGenPasses(nullptr), PerModulePasses(nullptr), + PerFunctionPasses(nullptr) {} ~EmitAssemblyHelper() { delete CodeGenPasses; @@ -367,7 +368,7 @@ TargetMachine *EmitAssemblyHelper::CreateTargetMachine(bool MustCreateTM) { if (!TheTarget) { if (MustCreateTM) Diags.Report(diag::err_fe_unable_to_create_target) << Error; - return 0; + return nullptr; } unsigned CodeModel = @@ -397,7 +398,7 @@ TargetMachine *EmitAssemblyHelper::CreateTargetMachine(bool MustCreateTM) { BackendArgs.push_back(CodeGenOpts.BackendOptions[i].c_str()); if (CodeGenOpts.NoGlobalMerge) BackendArgs.push_back("-global-merge=false"); - BackendArgs.push_back(0); + BackendArgs.push_back(nullptr); llvm::cl::ParseCommandLineOptions(BackendArgs.size() - 1, BackendArgs.data()); @@ -541,7 +542,7 @@ bool EmitAssemblyHelper::AddEmitPasses(BackendAction Action, } void EmitAssemblyHelper::EmitAssembly(BackendAction Action, raw_ostream *OS) { - TimeRegion Region(llvm::TimePassesIsEnabled ? &CodeGenerationTime : 0); + TimeRegion Region(llvm::TimePassesIsEnabled ? &CodeGenerationTime : nullptr); llvm::formatted_raw_ostream FormattedOS; bool UsesCodeGen = (Action != Backend_EmitNothing && diff --git a/lib/CodeGen/CGAtomic.cpp b/lib/CodeGen/CGAtomic.cpp index 7c7c80c570..18eb065226 100644 --- a/lib/CodeGen/CGAtomic.cpp +++ b/lib/CodeGen/CGAtomic.cpp @@ -255,7 +255,8 @@ static void emitAtomicCmpXchgFailureSet(CodeGenFunction &CGF, AtomicExpr *E, } // Create all the relevant BB's - llvm::BasicBlock *MonotonicBB = 0, *AcquireBB = 0, *SeqCstBB = 0; + llvm::BasicBlock *MonotonicBB = nullptr, *AcquireBB = nullptr, + *SeqCstBB = nullptr; MonotonicBB = CGF.createBasicBlock("monotonic_fail", CGF.CurFn); if (SuccessOrder != llvm::Monotonic && SuccessOrder != llvm::Release) AcquireBB = CGF.createBasicBlock("acquire_fail", CGF.CurFn); @@ -452,17 +453,17 @@ RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E, llvm::Value *Dest) { bool UseLibcall = (Size != Align || getContext().toBits(sizeChars) > MaxInlineWidthInBits); - llvm::Value *Ptr, *Order, *OrderFail = 0, *Val1 = 0, *Val2 = 0; - Ptr = EmitScalarExpr(E->getPtr()); + llvm::Value *OrderFail = nullptr, *Val1 = nullptr, *Val2 = nullptr; + llvm::Value *Ptr = EmitScalarExpr(E->getPtr()); if (E->getOp() == AtomicExpr::AO__c11_atomic_init) { assert(!Dest && "Init does not return a value"); LValue lvalue = LValue::MakeAddr(Ptr, AtomicTy, alignChars, getContext()); EmitAtomicInit(E->getVal1(), lvalue); - return RValue::get(0); + return RValue::get(nullptr); } - Order = EmitScalarExpr(E->getOrder()); + llvm::Value *Order = EmitScalarExpr(E->getOrder()); switch (E->getOp()) { case AtomicExpr::AO__c11_atomic_init: @@ -696,7 +697,7 @@ RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E, llvm::Value *Dest) { if (!RetTy->isVoidType()) return Res; if (E->getType()->isVoidType()) - return RValue::get(0); + return RValue::get(nullptr); return convertTempToRValue(Dest, E->getType(), E->getExprLoc()); } @@ -751,15 +752,16 @@ RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E, llvm::Value *Dest) { break; } if (E->getType()->isVoidType()) - return RValue::get(0); + return RValue::get(nullptr); return convertTempToRValue(OrigDest, E->getType(), E->getExprLoc()); } // Long case, when Order isn't obviously constant. // Create all the relevant BB's - llvm::BasicBlock *MonotonicBB = 0, *AcquireBB = 0, *ReleaseBB = 0, - *AcqRelBB = 0, *SeqCstBB = 0; + llvm::BasicBlock *MonotonicBB = nullptr, *AcquireBB = nullptr, + *ReleaseBB = nullptr, *AcqRelBB = nullptr, + *SeqCstBB = nullptr; MonotonicBB = createBasicBlock("monotonic", CurFn); if (!IsStore) AcquireBB = createBasicBlock("acquire", CurFn); @@ -818,7 +820,7 @@ RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E, llvm::Value *Dest) { // Cleanup and return Builder.SetInsertPoint(ContBB); if (E->getType()->isVoidType()) - return RValue::get(0); + return RValue::get(nullptr); return convertTempToRValue(OrigDest, E->getType(), E->getExprLoc()); } @@ -896,7 +898,7 @@ RValue CodeGenFunction::EmitAtomicLoad(LValue src, SourceLocation loc, // If we're ignoring an aggregate return, don't do anything. if (atomics.getEvaluationKind() == TEK_Aggregate && resultSlot.isIgnored()) - return RValue::getAggregate(0, false); + return RValue::getAggregate(nullptr, false); // The easiest way to do this this is to go through memory, but we // try not to in some easy cases. diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp index 56c8a07140..21896da349 100644 --- a/lib/CodeGen/CGBlocks.cpp +++ b/lib/CodeGen/CGBlocks.cpp @@ -30,9 +30,9 @@ using namespace CodeGen; CGBlockInfo::CGBlockInfo(const BlockDecl *block, StringRef name) : Name(name), CXXThisIndex(0), CanBeGlobal(false), NeedsCopyDispose(false), HasCXXObject(false), UsesStret(false), HasCapturedVariableLayout(false), - StructureType(0), Block(block), - DominatingIP(0) { - + StructureType(nullptr), Block(block), + DominatingIP(nullptr) { + // Skip asm prefix, if any. 'name' is usually taken directly from // the mangled name of the enclosing function. if (!name.empty() && name[0] == '\01') @@ -269,7 +269,7 @@ static llvm::Constant *tryCaptureAsConstant(CodeGenModule &CGM, QualType type = var->getType(); // We can only do this if the variable is const. - if (!type.isConstQualified()) return 0; + if (!type.isConstQualified()) return nullptr; // Furthermore, in C++ we have to worry about mutable fields: // C++ [dcl.type.cv]p4: @@ -277,13 +277,13 @@ static llvm::Constant *tryCaptureAsConstant(CodeGenModule &CGM, // modified, any attempt to modify a const object during its // lifetime results in undefined behavior. if (CGM.getLangOpts().CPlusPlus && !isSafeForCXXConstantCapture(type)) - return 0; + return nullptr; // If the variable doesn't have any initializer (shouldn't this be // invalid?), it's not clear what we should do. Maybe capture as // zero? const Expr *init = var->getInit(); - if (!init) return 0; + if (!init) return nullptr; return CGM.EmitConstantInit(*var, CGF); } @@ -366,7 +366,7 @@ static void computeBlockInfo(CodeGenModule &CGM, CodeGenFunction *CGF, layout.push_back(BlockLayoutChunk(tinfo.second, tinfo.first, Qualifiers::OCL_None, - 0, llvmType)); + nullptr, llvmType)); } // Next, all the block captures. @@ -661,7 +661,7 @@ void CodeGenFunction::destroyBlockInfos(CGBlockInfo *head) { CGBlockInfo *cur = head; head = cur->NextBlockInfo; delete cur; - } while (head != 0); + } while (head != nullptr); } /// Emit a block literal expression in the current function. @@ -769,7 +769,7 @@ llvm::Value *CodeGenFunction::EmitBlockLiteral(const CGBlockInfo &blockInfo) { } else if (blockDecl->isConversionFromLambda()) { // The lambda capture in a lambda's conversion-to-block-pointer is // special; we'll simply emit it directly. - src = 0; + src = nullptr; } else { // Just look it up in the locals map, which will give us back a // [[type]]*. If that doesn't work, do the more elaborate DRE @@ -841,8 +841,9 @@ llvm::Value *CodeGenFunction::EmitBlockLiteral(const CGBlockInfo &blockInfo) { } else { // Fake up a new variable so that EmitScalarInit doesn't think // we're referring to the variable in its own initializer. - ImplicitParamDecl blockFieldPseudoVar(getContext(), /*DC*/ 0, - SourceLocation(), /*name*/ 0, type); + ImplicitParamDecl blockFieldPseudoVar(getContext(), /*DC*/ nullptr, + SourceLocation(), /*name*/ nullptr, + type); // We use one of these or the other depending on whether the // reference is nested. @@ -1019,7 +1020,7 @@ CodeGenModule::GetAddrOfGlobalBlock(const BlockExpr *blockExpr, blockInfo.BlockExpression = blockExpr; // Compute information about the layout, etc., of this block. - computeBlockInfo(*this, 0, blockInfo); + computeBlockInfo(*this, nullptr, blockInfo); // Using that metadata, generate the actual block function. llvm::Constant *blockFn; @@ -1237,7 +1238,7 @@ CodeGenFunction::GenerateBlockFunction(GlobalDecl GD, } // And resume where we left off. - if (resume == 0) + if (resume == nullptr) Builder.ClearInsertionPoint(); else Builder.SetInsertPoint(resume); @@ -1279,9 +1280,11 @@ CodeGenFunction::GenerateCopyHelperFunction(const CGBlockInfo &blockInfo) { ASTContext &C = getContext(); FunctionArgList args; - ImplicitParamDecl dstDecl(getContext(), 0, SourceLocation(), 0, C.VoidPtrTy); + ImplicitParamDecl dstDecl(getContext(), nullptr, SourceLocation(), nullptr, + C.VoidPtrTy); args.push_back(&dstDecl); - ImplicitParamDecl srcDecl(getContext(), 0, SourceLocation(), 0, C.VoidPtrTy); + ImplicitParamDecl srcDecl(getContext(), nullptr, SourceLocation(), nullptr, + C.VoidPtrTy); args.push_back(&srcDecl); const CGFunctionInfo &FI = CGM.getTypes().arrangeFreeFunctionDeclaration( @@ -1301,8 +1304,8 @@ CodeGenFunction::GenerateCopyHelperFunction(const CGBlockInfo &blockInfo) { FunctionDecl *FD = FunctionDecl::Create(C, C.getTranslationUnitDecl(), SourceLocation(), - SourceLocation(), II, C.VoidTy, 0, - SC_Static, + SourceLocation(), II, C.VoidTy, + nullptr, SC_Static, false, false); // Create a scope with an artificial location for the body of this function. @@ -1453,7 +1456,8 @@ CodeGenFunction::GenerateDestroyHelperFunction(const CGBlockInfo &blockInfo) { ASTContext &C = getContext(); FunctionArgList args; - ImplicitParamDecl srcDecl(getContext(), 0, SourceLocation(), 0, C.VoidPtrTy); + ImplicitParamDecl srcDecl(getContext(), nullptr, SourceLocation(), nullptr, + C.VoidPtrTy); args.push_back(&srcDecl); const CGFunctionInfo &FI = CGM.getTypes().arrangeFreeFunctionDeclaration( @@ -1472,8 +1476,8 @@ CodeGenFunction::GenerateDestroyHelperFunction(const CGBlockInfo &blockInfo) { FunctionDecl *FD = FunctionDecl::Create(C, C.getTranslationUnitDecl(), SourceLocation(), - SourceLocation(), II, C.VoidTy, 0, - SC_Static, + SourceLocation(), II, C.VoidTy, + nullptr, SC_Static, false, false); // Create a scope with an artificial location for the body of this function. ArtificialLocation AL(*this, Builder); @@ -1498,7 +1502,7 @@ CodeGenFunction::GenerateDestroyHelperFunction(const CGBlockInfo &blockInfo) { if (capture.isConstant()) continue; BlockFieldFlags flags; - const CXXDestructorDecl *dtor = 0; + const CXXDestructorDecl *dtor = nullptr; bool useARCWeakDestroy = false; bool useARCStrongDestroy = false; @@ -1709,7 +1713,7 @@ public: const Expr *copyExpr) : ByrefHelpers(alignment), VarType(type), CopyExpr(copyExpr) {} - bool needsCopy() const override { return CopyExpr != 0; } + bool needsCopy() const override { return CopyExpr != nullptr; } void emitCopy(CodeGenFunction &CGF, llvm::Value *destField, llvm::Value *srcField) override { if (!CopyExpr) return; @@ -1738,11 +1742,11 @@ generateByrefCopyHelper(CodeGenFunction &CGF, QualType R = Context.VoidTy; FunctionArgList args; - ImplicitParamDecl dst(CGF.getContext(), 0, SourceLocation(), 0, + ImplicitParamDecl dst(CGF.getContext(), nullptr, SourceLocation(), nullptr, Context.VoidPtrTy); args.push_back(&dst); - ImplicitParamDecl src(CGF.getContext(), 0, SourceLocation(), 0, + ImplicitParamDecl src(CGF.getContext(), nullptr, SourceLocation(), nullptr, Context.VoidPtrTy); args.push_back(&src); @@ -1764,7 +1768,7 @@ generateByrefCopyHelper(CodeGenFunction &CGF, FunctionDecl *FD = FunctionDecl::Create(Context, Context.getTranslationUnitDecl(), SourceLocation(), - SourceLocation(), II, R, 0, + SourceLocation(), II, R, nullptr, SC_Static, false, false); @@ -1812,7 +1816,7 @@ generateByrefDisposeHelper(CodeGenFunction &CGF, QualType R = Context.VoidTy; FunctionArgList args; - ImplicitParamDecl src(CGF.getContext(), 0, SourceLocation(), 0, + ImplicitParamDecl src(CGF.getContext(), nullptr, SourceLocation(), nullptr, Context.VoidPtrTy); args.push_back(&src); @@ -1835,7 +1839,7 @@ generateByrefDisposeHelper(CodeGenFunction &CGF, FunctionDecl *FD = FunctionDecl::Create(Context, Context.getTranslationUnitDecl(), SourceLocation(), - SourceLocation(), II, R, 0, + SourceLocation(), II, R, nullptr, SC_Static, false, false); CGF.StartFunction(FD, R, Fn, FI, args); @@ -1905,7 +1909,7 @@ CodeGenFunction::buildByrefHelpers(llvm::StructType &byrefType, if (const CXXRecordDecl *record = type->getAsCXXRecordDecl()) { const Expr *copyExpr = CGM.getContext().getBlockVarCopyInits(&var); - if (!copyExpr && record->hasTrivialDestructor()) return 0; + if (!copyExpr && record->hasTrivialDestructor()) return nullptr; CXXByrefHelpers byrefInfo(emission.Alignment, type, copyExpr); return ::buildByrefHelpers(CGM, byrefType, byrefValueIndex, byrefInfo); @@ -1913,7 +1917,7 @@ CodeGenFunction::buildByrefHelpers(llvm::StructType &byrefType, // Otherwise, if we don't have a retainable type, there's nothing to do. // that the runtime does extra copies. - if (!type->isObjCRetainableType()) return 0; + if (!type->isObjCRetainableType()) return nullptr; Qualifiers qs = type.getQualifiers(); @@ -1927,7 +1931,7 @@ CodeGenFunction::buildByrefHelpers(llvm::StructType &byrefType, // These are just bits as far as the runtime is concerned. case Qualifiers::OCL_ExplicitNone: case Qualifiers::OCL_Autoreleasing: - return 0; + return nullptr; // Tell the runtime that this is ARC __weak, called by the // byref routines. @@ -1961,7 +1965,7 @@ CodeGenFunction::buildByrefHelpers(llvm::StructType &byrefType, type->isObjCObjectPointerType()) { flags |= BLOCK_FIELD_IS_OBJECT; } else { - return 0; + return nullptr; } if (type.isObjCGCWeak()) @@ -2268,7 +2272,8 @@ llvm::Constant *CodeGenModule::getNSConcreteGlobalBlock() { return NSConcreteGlobalBlock; NSConcreteGlobalBlock = GetOrCreateLLVMGlobal("_NSConcreteGlobalBlock", - Int8PtrTy->getPointerTo(), 0); + Int8PtrTy->getPointerTo(), + nullptr); configureBlocksRuntimeObject(*this, NSConcreteGlobalBlock); return NSConcreteGlobalBlock; } @@ -2278,7 +2283,8 @@ llvm::Constant *CodeGenModule::getNSConcreteStackBlock() { return NSConcreteStackBlock; NSConcreteStackBlock = GetOrCreateLLVMGlobal("_NSConcreteStackBlock", - Int8PtrTy->getPointerTo(), 0); + Int8PtrTy->getPointerTo(), + nullptr); configureBlocksRuntimeObject(*this, NSConcreteStackBlock); return NSConcreteStackBlock; } diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp index f77aeecd29..9d692d8e1e 100644 --- a/lib/CodeGen/CGBuiltin.cpp +++ b/lib/CodeGen/CGBuiltin.cpp @@ -212,7 +212,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, default: break; // Handle intrinsics and libm functions below. case Builtin::BI__builtin___CFStringMakeConstantString: case Builtin::BI__builtin___NSStringMakeConstantString: - return RValue::get(CGM.EmitConstantExpr(E, E->getType(), 0)); + return RValue::get(CGM.EmitConstantExpr(E, E->getType(), nullptr)); case Builtin::BI__builtin_stdarg_start: case Builtin::BI__builtin_va_start: case Builtin::BI__va_start: @@ -457,7 +457,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, // We do need to preserve an insertion point. EmitBlock(createBasicBlock("unreachable.cont")); - return RValue::get(0); + return RValue::get(nullptr); } case Builtin::BI__builtin_powi: @@ -790,7 +790,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, // We do need to preserve an insertion point. EmitBlock(createBasicBlock("builtin_eh_return.cont")); - return RValue::get(0); + return RValue::get(nullptr); } case Builtin::BI__builtin_unwind_init: { Value *F = CGM.getIntrinsic(Intrinsic::eh_unwind_init); @@ -856,7 +856,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, // We do need to preserve an insertion point. EmitBlock(createBasicBlock("longjmp.cont")); - return RValue::get(0); + return RValue::get(nullptr); } case Builtin::BI__sync_fetch_and_add: case Builtin::BI__sync_fetch_and_sub: @@ -1037,7 +1037,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, Builder.CreateStore(llvm::Constant::getNullValue(ITy), Ptr); Store->setAlignment(StoreSize.getQuantity()); Store->setAtomic(llvm::Release); - return RValue::get(0); + return RValue::get(nullptr); } case Builtin::BI__sync_synchronize: { @@ -1049,7 +1049,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, // to use it with non-atomic loads and stores to get acquire/release // semantics. Builder.CreateFence(llvm::SequentiallyConsistent); - return RValue::get(0); + return RValue::get(nullptr); } case Builtin::BI__c11_atomic_is_lock_free: @@ -1090,7 +1090,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, Value *Order = EmitScalarExpr(E->getArg(1)); if (isa(Order)) { int ord = cast(Order)->getZExtValue(); - AtomicRMWInst *Result = 0; + AtomicRMWInst *Result = nullptr; switch (ord) { case 0: // memory_order_relaxed default: // invalid order @@ -1190,7 +1190,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, Store->setOrdering(llvm::SequentiallyConsistent); break; } - return RValue::get(0); + return RValue::get(nullptr); } llvm::BasicBlock *ContBB = createBasicBlock("atomic.continue", CurFn); @@ -1220,7 +1220,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, SI->addCase(Builder.getInt32(5), BBs[2]); Builder.SetInsertPoint(ContBB); - return RValue::get(0); + return RValue::get(nullptr); } case Builtin::BI__atomic_thread_fence: @@ -1254,7 +1254,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, Builder.CreateFence(llvm::SequentiallyConsistent, Scope); break; } - return RValue::get(0); + return RValue::get(nullptr); } llvm::BasicBlock *AcquireBB, *ReleaseBB, *AcqRelBB, *SeqCstBB; @@ -1289,7 +1289,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, SI->addCase(Builder.getInt32(5), SeqCstBB); Builder.SetInsertPoint(ContBB); - return RValue::get(0); + return RValue::get(nullptr); } // Library functions with special handling. @@ -1509,7 +1509,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, case Builtin::BI__builtin_addressof: return RValue::get(EmitLValue(E->getArg(0)).getAddress()); case Builtin::BI__noop: - return RValue::get(0); + return RValue::get(nullptr); case Builtin::BI_InterlockedCompareExchange: { AtomicCmpXchgInst *CXI = Builder.CreateAtomicCmpXchg( EmitScalarExpr(E->getArg(0)), @@ -1656,7 +1656,7 @@ Value *CodeGenFunction::EmitTargetBuiltinExpr(unsigned BuiltinID, case llvm::Triple::ppc64le: return EmitPPCBuiltinExpr(BuiltinID, E); default: - return 0; + return nullptr; } } @@ -2764,7 +2764,7 @@ findNeonIntrinsicInMap(llvm::ArrayRef IntrinsicMap, if (Builtin != IntrinsicMap.end() && Builtin->BuiltinID == BuiltinID) return Builtin; - return 0; + return nullptr; } Function *CodeGenFunction::LookupNeonLLVMIntrinsic(unsigned IntrinsicID, @@ -3040,7 +3040,7 @@ Value *CodeGenFunction::EmitCommonNeonBuiltinExpr( llvm::APSInt NeonTypeConst; const Expr *Arg = E->getArg(E->getNumArgs() - 1); if (!Arg->isIntegerConstantExpr(NeonTypeConst, getContext())) - return 0; + return nullptr; // Determine the type of this overloaded NEON intrinsic. NeonTypeFlags Type(NeonTypeConst.getZExtValue()); @@ -3050,7 +3050,7 @@ Value *CodeGenFunction::EmitCommonNeonBuiltinExpr( llvm::VectorType *VTy = GetNeonType(this, Type); llvm::Type *Ty = VTy; if (!Ty) - return 0; + return nullptr; unsigned Int = LLVMIntrinsic; if ((Modifier & UnsignedAlts) && !Usgn) @@ -3397,7 +3397,7 @@ Value *CodeGenFunction::EmitCommonNeonBuiltinExpr( Ops[0] = Builder.CreateBitCast(Ops[0], llvm::PointerType::getUnqual(Ty)); Ops[1] = Builder.CreateBitCast(Ops[1], Ty); Ops[2] = Builder.CreateBitCast(Ops[2], Ty); - Value *SV = 0; + Value *SV = nullptr; for (unsigned vi = 0; vi != 2; ++vi) { SmallVector Indices; @@ -3426,7 +3426,7 @@ Value *CodeGenFunction::EmitCommonNeonBuiltinExpr( Ops[0] = Builder.CreateBitCast(Ops[0], llvm::PointerType::getUnqual(Ty)); Ops[1] = Builder.CreateBitCast(Ops[1], Ty); Ops[2] = Builder.CreateBitCast(Ops[2], Ty); - Value *SV = 0; + Value *SV = nullptr; for (unsigned vi = 0; vi != 2; ++vi) { SmallVector Indices; @@ -3445,7 +3445,7 @@ Value *CodeGenFunction::EmitCommonNeonBuiltinExpr( Ops[0] = Builder.CreateBitCast(Ops[0], llvm::PointerType::getUnqual(Ty)); Ops[1] = Builder.CreateBitCast(Ops[1], Ty); Ops[2] = Builder.CreateBitCast(Ops[2], Ty); - Value *SV = 0; + Value *SV = nullptr; for (unsigned vi = 0; vi != 2; ++vi) { SmallVector Indices; @@ -3538,11 +3538,11 @@ static Value *EmitAArch64TblBuiltinExpr(CodeGenFunction &CGF, unsigned BuiltinID, const CallExpr *E) { unsigned int Int = 0; - const char *s = NULL; + const char *s = nullptr; switch (BuiltinID) { default: - return 0; + return nullptr; case NEON::BI__builtin_neon_vtbl1_v: case NEON::BI__builtin_neon_vqtbl1_v: case NEON::BI__builtin_neon_vqtbl1q_v: @@ -3576,14 +3576,14 @@ static Value *EmitAArch64TblBuiltinExpr(CodeGenFunction &CGF, llvm::APSInt Result; const Expr *Arg = E->getArg(E->getNumArgs() - 1); if (!Arg->isIntegerConstantExpr(Result, CGF.getContext())) - return 0; + return nullptr; // Determine the type of this overloaded NEON intrinsic. NeonTypeFlags Type(Result.getZExtValue()); llvm::VectorType *VTy = GetNeonType(&CGF, Type); llvm::Type *Ty = VTy; if (!Ty) - return 0; + return nullptr; SmallVector Ops; for (unsigned i = 0, e = E->getNumArgs() - 1; i != e; i++) { @@ -3598,20 +3598,20 @@ static Value *EmitAArch64TblBuiltinExpr(CodeGenFunction &CGF, switch (BuiltinID) { case NEON::BI__builtin_neon_vtbl1_v: { TblOps.push_back(Ops[0]); - return packTBLDVectorList(CGF, TblOps, 0, Ops[1], Ty, + return packTBLDVectorList(CGF, TblOps, nullptr, Ops[1], Ty, Intrinsic::aarch64_neon_vtbl1, "vtbl1"); } case NEON::BI__builtin_neon_vtbl2_v: { TblOps.push_back(Ops[0]); TblOps.push_back(Ops[1]); - return packTBLDVectorList(CGF, TblOps, 0, Ops[2], Ty, + return packTBLDVectorList(CGF, TblOps, nullptr, Ops[2], Ty, Intrinsic::aarch64_neon_vtbl1, "vtbl1"); } case NEON::BI__builtin_neon_vtbl3_v: { TblOps.push_back(Ops[0]); TblOps.push_back(Ops[1]); TblOps.push_back(Ops[2]); - return packTBLDVectorList(CGF, TblOps, 0, Ops[3], Ty, + return packTBLDVectorList(CGF, TblOps, nullptr, Ops[3], Ty, Intrinsic::aarch64_neon_vtbl2, "vtbl2"); } case NEON::BI__builtin_neon_vtbl4_v: { @@ -3619,13 +3619,13 @@ static Value *EmitAArch64TblBuiltinExpr(CodeGenFunction &CGF, TblOps.push_back(Ops[1]); TblOps.push_back(Ops[2]); TblOps.push_back(Ops[3]); - return packTBLDVectorList(CGF, TblOps, 0, Ops[4], Ty, + return packTBLDVectorList(CGF, TblOps, nullptr, Ops[4], Ty, Intrinsic::aarch64_neon_vtbl2, "vtbl2"); } case NEON::BI__builtin_neon_vtbx1_v: { TblOps.push_back(Ops[1]); - Value *TblRes = packTBLDVectorList(CGF, TblOps, 0, Ops[2], Ty, - Intrinsic::aarch64_neon_vtbl1, "vtbl1"); + Value *TblRes = packTBLDVectorList(CGF, TblOps, nullptr, Ops[2], Ty, + Intrinsic::aarch64_neon_vtbl1, "vtbl1"); llvm::Constant *Eight = ConstantInt::get(VTy->getElementType(), 8); Value* EightV = llvm::ConstantVector::getSplat(nElts, Eight); @@ -3649,7 +3649,7 @@ static Value *EmitAArch64TblBuiltinExpr(CodeGenFunction &CGF, TblOps.push_back(Ops[1]); TblOps.push_back(Ops[2]); TblOps.push_back(Ops[3]); - Value *TblRes = packTBLDVectorList(CGF, TblOps, 0, Ops[4], Ty, + Value *TblRes = packTBLDVectorList(CGF, TblOps, nullptr, Ops[4], Ty, Intrinsic::aarch64_neon_vtbl2, "vtbl2"); llvm::Constant *TwentyFour = ConstantInt::get(VTy->getElementType(), 24); @@ -3701,7 +3701,7 @@ static Value *EmitAArch64TblBuiltinExpr(CodeGenFunction &CGF, } if (!Int) - return 0; + return nullptr; Function *F = CGF.CGM.getIntrinsic(Int, Ty); return CGF.EmitNeonCall(F, Ops, s); @@ -3740,7 +3740,7 @@ Value *CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID, } SmallVector Ops; - llvm::Value *Align = 0; // Alignment for load/store + llvm::Value *Align = nullptr; // Alignment for load/store if (BuiltinID == NEON::BI__builtin_neon_vldrq_p128) { Value *Op = EmitScalarExpr(E->getArg(0)); @@ -3847,7 +3847,7 @@ Value *CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID, llvm::APSInt Result; const Expr *Arg = E->getArg(E->getNumArgs() - 1); if (!Arg->isIntegerConstantExpr(Result, getContext())) - return 0; + return nullptr; // Determine the type of this overloaded NEON intrinsic. NeonTypeFlags Type(Result.getZExtValue()); @@ -3857,8 +3857,7 @@ Value *CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID, llvm::VectorType *VTy = GetNeonType(this, Type); llvm::Type *Ty = VTy; if (!Ty) - return 0; - + return nullptr; // Many NEON builtins have identical semantics and uses in ARM and // AArch64. Emit these in a single function. @@ -3873,7 +3872,7 @@ Value *CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID, unsigned Int; switch (BuiltinID) { default: - return 0; + return nullptr; // AArch64 builtins mapping to legacy ARM v7 builtins. // FIXME: the mapped builtins listed correspond to what has been tested @@ -4492,7 +4491,7 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID, } SmallVector Ops; - llvm::Value *Align = 0; + llvm::Value *Align = nullptr; for (unsigned i = 0, e = E->getNumArgs() - 1; i != e; i++) { if (i == 0) { switch (BuiltinID) { @@ -4608,7 +4607,7 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID, llvm::APSInt Result; const Expr *Arg = E->getArg(E->getNumArgs()-1); if (!Arg->isIntegerConstantExpr(Result, getContext())) - return 0; + return nullptr; if (BuiltinID == ARM::BI__builtin_arm_vcvtr_f || BuiltinID == ARM::BI__builtin_arm_vcvtr_d) { @@ -4636,7 +4635,7 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID, llvm::VectorType *VTy = GetNeonType(this, Type); llvm::Type *Ty = VTy; if (!Ty) - return 0; + return nullptr; // Many NEON builtins have identical semantics and uses in ARM and // AArch64. Emit these in a single function. @@ -4650,7 +4649,7 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID, unsigned Int; switch (BuiltinID) { - default: return 0; + default: return nullptr; case NEON::BI__builtin_neon_vld1q_lane_v: // Handle 64-bit integer elements as a special case. Use shuffles of // one-element vectors to avoid poor code for i64 in the backend. @@ -4842,11 +4841,11 @@ static Value *EmitARM64TblBuiltinExpr(CodeGenFunction &CGF, unsigned BuiltinID, const CallExpr *E, SmallVectorImpl &Ops) { unsigned int Int = 0; - const char *s = NULL; + const char *s = nullptr; switch (BuiltinID) { default: - return 0; + return nullptr; case NEON::BI__builtin_neon_vtbl1_v: case NEON::BI__builtin_neon_vqtbl1_v: case NEON::BI__builtin_neon_vqtbl1q_v: @@ -4881,14 +4880,14 @@ static Value *EmitARM64TblBuiltinExpr(CodeGenFunction &CGF, unsigned BuiltinID, llvm::APSInt Result; const Expr *Arg = E->getArg(E->getNumArgs() - 1); if (!Arg->isIntegerConstantExpr(Result, CGF.getContext())) - return 0; + return nullptr; // Determine the type of this overloaded NEON intrinsic. NeonTypeFlags Type(Result.getZExtValue()); llvm::VectorType *VTy = GetNeonType(&CGF, Type); llvm::Type *Ty = VTy; if (!Ty) - return 0; + return nullptr; unsigned nElts = VTy->getNumElements(); @@ -4900,20 +4899,20 @@ static Value *EmitARM64TblBuiltinExpr(CodeGenFunction &CGF, unsigned BuiltinID, switch (BuiltinID) { case NEON::BI__builtin_neon_vtbl1_v: { TblOps.push_back(Ops[0]); - return packTBLDVectorList(CGF, TblOps, 0, Ops[1], Ty, + return packTBLDVectorList(CGF, TblOps, nullptr, Ops[1], Ty, Intrinsic::arm64_neon_tbl1, "vtbl1"); } case NEON::BI__builtin_neon_vtbl2_v: { TblOps.push_back(Ops[0]); TblOps.push_back(Ops[1]); - return packTBLDVectorList(CGF, TblOps, 0, Ops[2], Ty, + return packTBLDVectorList(CGF, TblOps, nullptr, Ops[2], Ty, Intrinsic::arm64_neon_tbl1, "vtbl1"); } case NEON::BI__builtin_neon_vtbl3_v: { TblOps.push_back(Ops[0]); TblOps.push_back(Ops[1]); TblOps.push_back(Ops[2]); - return packTBLDVectorList(CGF, TblOps, 0, Ops[3], Ty, + return packTBLDVectorList(CGF, TblOps, nullptr, Ops[3], Ty, Intrinsic::arm64_neon_tbl2, "vtbl2"); } case NEON::BI__builtin_neon_vtbl4_v: { @@ -4921,13 +4920,13 @@ static Value *EmitARM64TblBuiltinExpr(CodeGenFunction &CGF, unsigned BuiltinID, TblOps.push_back(Ops[1]); TblOps.push_back(Ops[2]); TblOps.push_back(Ops[3]); - return packTBLDVectorList(CGF, TblOps, 0, Ops[4], Ty, + return packTBLDVectorList(CGF, TblOps, nullptr, Ops[4], Ty, Intrinsic::arm64_neon_tbl2, "vtbl2"); } case NEON::BI__builtin_neon_vtbx1_v: { TblOps.push_back(Ops[1]); - Value *TblRes = packTBLDVectorList(CGF, TblOps, 0, Ops[2], Ty, - Intrinsic::arm64_neon_tbl1, "vtbl1"); + Value *TblRes = packTBLDVectorList(CGF, TblOps, nullptr, Ops[2], Ty, + Intrinsic::arm64_neon_tbl1, "vtbl1"); llvm::Constant *Eight = ConstantInt::get(VTy->getElementType(), 8); Value* EightV = llvm::ConstantVector::getSplat(nElts, Eight); @@ -4948,7 +4947,7 @@ static Value *EmitARM64TblBuiltinExpr(CodeGenFunction &CGF, unsigned BuiltinID, TblOps.push_back(Ops[1]); TblOps.push_back(Ops[2]); TblOps.push_back(Ops[3]); - Value *TblRes = packTBLDVectorList(CGF, TblOps, 0, Ops[4], Ty, + Value *TblRes = packTBLDVectorList(CGF, TblOps, nullptr, Ops[4], Ty, Intrinsic::arm64_neon_tbl2, "vtbl2"); llvm::Constant *TwentyFour = ConstantInt::get(VTy->getElementType(), 24); @@ -4997,7 +4996,7 @@ static Value *EmitARM64TblBuiltinExpr(CodeGenFunction &CGF, unsigned BuiltinID, } if (!Int) - return 0; + return nullptr; Function *F = CGF.CGM.getIntrinsic(Int, Ty); return CGF.EmitNeonCall(F, Ops, s); @@ -5678,7 +5677,7 @@ Value *CodeGenFunction::EmitARM64BuiltinExpr(unsigned BuiltinID, llvm::VectorType *VTy = GetNeonType(this, Type); llvm::Type *Ty = VTy; if (!Ty) - return 0; + return nullptr; // Not all intrinsics handled by the common case work for ARM64 yet, so only // defer to common code if it's been added to our special map. @@ -5688,14 +5687,14 @@ Value *CodeGenFunction::EmitARM64BuiltinExpr(unsigned BuiltinID, if (Builtin) return EmitCommonNeonBuiltinExpr( Builtin->BuiltinID, Builtin->LLVMIntrinsic, Builtin->AltLLVMIntrinsic, - Builtin->NameHint, Builtin->TypeModifier, E, Ops, 0); + Builtin->NameHint, Builtin->TypeModifier, E, Ops, nullptr); if (Value *V = EmitARM64TblBuiltinExpr(*this, BuiltinID, E, Ops)) return V; unsigned Int; switch (BuiltinID) { - default: return 0; + default: return nullptr; case NEON::BI__builtin_neon_vbsl_v: case NEON::BI__builtin_neon_vbslq_v: { llvm::Type *BitTy = llvm::VectorType::getInteger(VTy); @@ -6725,7 +6724,7 @@ Value *CodeGenFunction::EmitARM64BuiltinExpr(unsigned BuiltinID, Ops[0] = Builder.CreateBitCast(Ops[0], llvm::PointerType::getUnqual(Ty)); Ops[1] = Builder.CreateBitCast(Ops[1], Ty); Ops[2] = Builder.CreateBitCast(Ops[2], Ty); - Value *SV = 0; + Value *SV = nullptr; for (unsigned vi = 0; vi != 2; ++vi) { SmallVector Indices; @@ -6745,7 +6744,7 @@ Value *CodeGenFunction::EmitARM64BuiltinExpr(unsigned BuiltinID, Ops[0] = Builder.CreateBitCast(Ops[0], llvm::PointerType::getUnqual(Ty)); Ops[1] = Builder.CreateBitCast(Ops[1], Ty); Ops[2] = Builder.CreateBitCast(Ops[2], Ty); - Value *SV = 0; + Value *SV = nullptr; for (unsigned vi = 0; vi != 2; ++vi) { SmallVector Indices; @@ -6764,7 +6763,7 @@ Value *CodeGenFunction::EmitARM64BuiltinExpr(unsigned BuiltinID, Ops[0] = Builder.CreateBitCast(Ops[0], llvm::PointerType::getUnqual(Ty)); Ops[1] = Builder.CreateBitCast(Ops[1], Ty); Ops[2] = Builder.CreateBitCast(Ops[2], Ty); - Value *SV = 0; + Value *SV = nullptr; for (unsigned vi = 0; vi != 2; ++vi) { SmallVector Indices; @@ -6876,7 +6875,7 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID, } switch (BuiltinID) { - default: return 0; + default: return nullptr; case X86::BI_mm_prefetch: { Value *Address = EmitScalarExpr(E->getArg(0)); Value *RW = ConstantInt::get(Int32Ty, 0); @@ -7053,7 +7052,7 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID, // 3DNow! case X86::BI__builtin_ia32_pswapdsf: case X86::BI__builtin_ia32_pswapdsi: { - const char *name = 0; + const char *name = nullptr; Intrinsic::ID ID = Intrinsic::not_intrinsic; switch(BuiltinID) { default: llvm_unreachable("Unsupported intrinsic!"); @@ -7122,7 +7121,7 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned BuiltinID, Intrinsic::ID ID = Intrinsic::not_intrinsic; switch (BuiltinID) { - default: return 0; + default: return nullptr; // vec_ld, vec_lvsl, vec_lvsr case PPC::BI__builtin_altivec_lvx: diff --git a/lib/CodeGen/CGCUDARuntime.cpp b/lib/CodeGen/CGCUDARuntime.cpp index 54a28f51bd..29e0a91a63 100644 --- a/lib/CodeGen/CGCUDARuntime.cpp +++ b/lib/CodeGen/CGCUDARuntime.cpp @@ -37,7 +37,7 @@ RValue CGCUDARuntime::EmitCUDAKernelCallExpr(CodeGenFunction &CGF, eval.begin(CGF); CGF.EmitBlock(ConfigOKBlock); - const Decl *TargetDecl = 0; + const Decl *TargetDecl = nullptr; if (const ImplicitCastExpr *CE = dyn_cast(E->getCallee())) { if (const DeclRefExpr *DRE = dyn_cast(CE->getSubExpr())) { TargetDecl = DRE->getDecl(); @@ -52,5 +52,5 @@ RValue CGCUDARuntime::EmitCUDAKernelCallExpr(CodeGenFunction &CGF, CGF.EmitBlock(ContBlock); eval.end(CGF); - return RValue::get(0); + return RValue::get(nullptr); } diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp index 571acf6ccb..55c06f6786 100644 --- a/lib/CodeGen/CGCXX.cpp +++ b/lib/CodeGen/CGCXX.cpp @@ -61,7 +61,7 @@ bool CodeGenModule::TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D) { return true; // Try to find a unique base class with a non-trivial destructor. - const CXXRecordDecl *UniqueBase = 0; + const CXXRecordDecl *UniqueBase = nullptr; for (const auto &I : Class->bases()) { // We're in the base destructor, so skip virtual bases. @@ -272,7 +272,7 @@ void CodeGenModule::EmitCXXDestructor(const CXXDestructorDecl *dtor, getTypes().arrangeCXXDestructor(dtor, dtorType); auto *fn = cast( - GetAddrOfCXXDestructor(dtor, dtorType, &fnInfo, 0, true)); + GetAddrOfCXXDestructor(dtor, dtorType, &fnInfo, nullptr, true)); setFunctionLinkage(GlobalDecl(dtor, dtorType), fn); CodeGenFunction(*this).GenerateCode(GlobalDecl(dtor, dtorType), fn, fnInfo); @@ -364,5 +364,5 @@ CodeGenFunction::BuildAppleKextVirtualDestructorCall( llvm::Type *Ty = CGM.getTypes().GetFunctionType(FInfo); return ::BuildAppleKextVirtualCall(*this, GlobalDecl(DD, Type), Ty, RD); } - return 0; + return nullptr; } diff --git a/lib/CodeGen/CGCXXABI.cpp b/lib/CodeGen/CGCXXABI.cpp index d1904ec7c4..1f0de31364 100644 --- a/lib/CodeGen/CGCXXABI.cpp +++ b/lib/CodeGen/CGCXXABI.cpp @@ -156,7 +156,7 @@ void CGCXXABI::buildThisParam(CodeGenFunction &CGF, FunctionArgList ¶ms) { // FIXME: I'm not entirely sure I like using a fake decl just for code // generation. Maybe we can come up with a better way? ImplicitParamDecl *ThisDecl - = ImplicitParamDecl::Create(CGM.getContext(), 0, MD->getLocation(), + = ImplicitParamDecl::Create(CGM.getContext(), nullptr, MD->getLocation(), &CGM.getContext().Idents.get("this"), MD->getThisType(CGM.getContext())); params.push_back(ThisDecl); @@ -194,7 +194,7 @@ llvm::Value *CGCXXABI::InitializeArrayCookie(CodeGenFunction &CGF, QualType ElementType) { // Should never be called. ErrorUnsupportedABI(CGF, "array cookie initialization"); - return 0; + return nullptr; } bool CGCXXABI::requiresArrayCookie(const CXXDeleteExpr *expr, @@ -228,7 +228,7 @@ void CGCXXABI::ReadArrayCookie(CodeGenFunction &CGF, llvm::Value *ptr, // If we don't need an array cookie, bail out early. if (!requiresArrayCookie(expr, eltTy)) { allocPtr = ptr; - numElements = 0; + numElements = nullptr; cookieSize = CharUnits::Zero(); return; } @@ -307,7 +307,7 @@ CGCXXABI::EmitCtorCompleteObjectHandler(CodeGenFunction &CGF, llvm_unreachable("shouldn't be called in this ABI"); ErrorUnsupportedABI(CGF, "complete object detection in ctor"); - return 0; + return nullptr; } void CGCXXABI::EmitThreadLocalInitFuncs( diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp index 31665f8851..d0849d3263 100644 --- a/lib/CodeGen/CGCall.cpp +++ b/lib/CodeGen/CGCall.cpp @@ -491,7 +491,7 @@ CodeGenTypes::arrangeLLVMFunctionInfo(CanQualType resultType, CGFunctionInfo::Profile(ID, IsInstanceMethod, info, required, resultType, argTypes); - void *insertPos = 0; + void *insertPos = nullptr; CGFunctionInfo *FI = FunctionInfos.FindNodeOrInsertPos(ID, insertPos); if (FI) return *FI; @@ -511,11 +511,11 @@ CodeGenTypes::arrangeLLVMFunctionInfo(CanQualType resultType, // them are direct or extend without a specified coerce type, specify the // default now. ABIArgInfo &retInfo = FI->getReturnInfo(); - if (retInfo.canHaveCoerceToType() && retInfo.getCoerceToType() == 0) + if (retInfo.canHaveCoerceToType() && retInfo.getCoerceToType() == nullptr) retInfo.setCoerceToType(ConvertType(FI->getReturnType())); for (auto &I : FI->arguments()) - if (I.info.canHaveCoerceToType() && I.info.getCoerceToType() == 0) + if (I.info.canHaveCoerceToType() && I.info.getCoerceToType() == nullptr) I.info.setCoerceToType(ConvertType(I.type)); bool erased = FunctionsBeingProcessed.erase(FI); (void)erased; @@ -542,7 +542,7 @@ CGFunctionInfo *CGFunctionInfo::create(unsigned llvmCC, FI->Required = required; FI->HasRegParm = info.getHasRegParm(); FI->RegParm = info.getRegParm(); - FI->ArgStruct = 0; + FI->ArgStruct = nullptr; FI->NumArgs = argTypes.size(); FI->getArgsBuffer()[0].type = resultType; for (unsigned i = 0, e = argTypes.size(); i != e; ++i) @@ -565,7 +565,7 @@ void CodeGenTypes::GetExpandedTypes(QualType type, if (RD->isUnion()) { // Unions can be here only in degenerative cases - all the fields are same // after flattening. Thus we have to use the "largest" field. - const FieldDecl *LargestFD = 0; + const FieldDecl *LargestFD = nullptr; CharUnits UnionSize = CharUnits::Zero(); for (const auto *FD : RD->fields()) { @@ -613,7 +613,7 @@ CodeGenFunction::ExpandTypeFromArgs(QualType Ty, LValue LV, if (RD->isUnion()) { // Unions can be here only in degenerative cases - all the fields are same // after flattening. Thus we have to use the "largest" field. - const FieldDecl *LargestFD = 0; + const FieldDecl *LargestFD = nullptr; CharUnits UnionSize = CharUnits::Zero(); for (const auto *FD : RD->fields()) { @@ -942,7 +942,7 @@ CodeGenTypes::GetFunctionType(const CGFunctionInfo &FI) { bool SwapThisWithSRet = false; SmallVector argTypes; - llvm::Type *resultType = 0; + llvm::Type *resultType = nullptr; const ABIArgInfo &retAI = FI.getReturnInfo(); switch (retAI.getKind()) { @@ -1351,7 +1351,7 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI, // If we're using inalloca, all the memory arguments are GEPs off of the last // parameter, which is a pointer to the complete memory area. - llvm::Value *ArgStruct = 0; + llvm::Value *ArgStruct = nullptr; if (FI.usesInAlloca()) { llvm::Function::arg_iterator EI = Fn->arg_end(); --EI; @@ -1638,8 +1638,8 @@ static llvm::Value *tryEmitFusedAutoreleaseOfResult(CodeGenFunction &CGF, llvm::Value *result) { // We must be immediately followed the cast. llvm::BasicBlock *BB = CGF.Builder.GetInsertBlock(); - if (BB->empty()) return 0; - if (&BB->back() != result) return 0; + if (BB->empty()) return nullptr; + if (&BB->back() != result) return nullptr; llvm::Type *resultType = result->getType(); @@ -1657,7 +1657,7 @@ static llvm::Value *tryEmitFusedAutoreleaseOfResult(CodeGenFunction &CGF, // Require the generator to be immediately followed by the cast. if (generator->getNextNode() != bitcast) - return 0; + return nullptr; insnsToKill.push_back(bitcast); } @@ -1667,7 +1667,7 @@ static llvm::Value *tryEmitFusedAutoreleaseOfResult(CodeGenFunction &CGF, // or // %generator = call i8* @objc_retainAutoreleasedReturnValue(i8* %originalResult) llvm::CallInst *call = dyn_cast(generator); - if (!call) return 0; + if (!call) return nullptr; bool doRetainAutorelease; @@ -1695,7 +1695,7 @@ static llvm::Value *tryEmitFusedAutoreleaseOfResult(CodeGenFunction &CGF, insnsToKill.push_back(prev); } } else { - return 0; + return nullptr; } result = call->getArgOperand(0); @@ -1728,16 +1728,16 @@ static llvm::Value *tryRemoveRetainOfSelf(CodeGenFunction &CGF, // This is only applicable to a method with an immutable 'self'. const ObjCMethodDecl *method = dyn_cast_or_null(CGF.CurCodeDecl); - if (!method) return 0; + if (!method) return nullptr; const VarDecl *self = method->getSelfDecl(); - if (!self->getType().isConstQualified()) return 0; + if (!self->getType().isConstQualified()) return nullptr; // Look for a retain call. llvm::CallInst *retainCall = dyn_cast(result->stripPointerCasts()); if (!retainCall || retainCall->getCalledValue() != CGF.CGM.getARCEntrypoints().objc_retain) - return 0; + return nullptr; // Look for an ordinary load of 'self'. llvm::Value *retainedValue = retainCall->getArgOperand(0); @@ -1745,7 +1745,7 @@ static llvm::Value *tryRemoveRetainOfSelf(CodeGenFunction &CGF, dyn_cast(retainedValue->stripPointerCasts()); if (!load || load->isAtomic() || load->isVolatile() || load->getPointerOperand() != CGF.GetAddrOfLocalVar(self)) - return 0; + return nullptr; // Okay! Burn it all down. This relies for correctness on the // assumption that the retain is emitted as part of the return and @@ -1787,17 +1787,17 @@ static llvm::StoreInst *findDominatingStoreToReturnValue(CodeGenFunction &CGF) { // with noreturn cleanups. if (!CGF.ReturnValue->hasOneUse()) { llvm::BasicBlock *IP = CGF.Builder.GetInsertBlock(); - if (IP->empty()) return 0; + if (IP->empty()) return nullptr; llvm::StoreInst *store = dyn_cast(&IP->back()); - if (!store) return 0; - if (store->getPointerOperand() != CGF.ReturnValue) return 0; + if (!store) return nullptr; + if (store->getPointerOperand() != CGF.ReturnValue) return nullptr; assert(!store->isAtomic() && !store->isVolatile()); // see below return store; } llvm::StoreInst *store = dyn_cast(CGF.ReturnValue->user_back()); - if (!store) return 0; + if (!store) return nullptr; // These aren't actually possible for non-coerced returns, and we // only care about non-coerced returns on this code path. @@ -1809,7 +1809,7 @@ static llvm::StoreInst *findDominatingStoreToReturnValue(CodeGenFunction &CGF) { llvm::BasicBlock *IP = CGF.Builder.GetInsertBlock(); while (IP != StoreBB) { if (!(IP = IP->getSinglePredecessor())) - return 0; + return nullptr; } // Okay, the store's basic block dominates the insertion point; we @@ -1821,13 +1821,13 @@ void CodeGenFunction::EmitFunctionEpilog(const CGFunctionInfo &FI, bool EmitRetDbgLoc, SourceLocation EndLoc) { // Functions with no result always return void. - if (ReturnValue == 0) { + if (!ReturnValue) { Builder.CreateRetVoid(); return; } llvm::DebugLoc RetDbgLoc; - llvm::Value *RV = 0; + llvm::Value *RV = nullptr; QualType RetTy = FI.getReturnType(); const ABIArgInfo &RetAI = FI.getReturnInfo(); @@ -1893,7 +1893,7 @@ void CodeGenFunction::EmitFunctionEpilog(const CGFunctionInfo &FI, // If that was the only use of the return value, nuke it as well now. if (ReturnValue->use_empty() && isa(ReturnValue)) { cast(ReturnValue)->eraseFromParent(); - ReturnValue = 0; + ReturnValue = nullptr; } // Otherwise, we have to do a simple load. @@ -2011,7 +2011,7 @@ static void emitWriteback(CodeGenFunction &CGF, assert(!isProvablyNull(srcAddr) && "shouldn't have writeback for provably null argument"); - llvm::BasicBlock *contBB = 0; + llvm::BasicBlock *contBB = nullptr; // If the argument wasn't provably non-null, we need to null check // before doing the store. @@ -2092,7 +2092,7 @@ static const Expr *maybeGetUnaryAddrOfOperand(const Expr *E) { if (const UnaryOperator *uop = dyn_cast(E->IgnoreParens())) if (uop->getOpcode() == UO_AddrOf) return uop->getSubExpr(); - return 0; + return nullptr; } /// Emit an argument that's being passed call-by-writeback. That is, @@ -2146,9 +2146,9 @@ static void emitWritebackArg(CodeGenFunction &CGF, CallArgList &args, cast(destType->getElementType())); CGF.Builder.CreateStore(null, temp); } - - llvm::BasicBlock *contBB = 0; - llvm::BasicBlock *originBB = 0; + + llvm::BasicBlock *contBB = nullptr; + llvm::BasicBlock *originBB = nullptr; // If the address is *not* known to be non-null, we need to switch. llvm::Value *finalArgument; @@ -2175,7 +2175,7 @@ static void emitWritebackArg(CodeGenFunction &CGF, CallArgList &args, } } - llvm::Value *valueToUse = 0; + llvm::Value *valueToUse = nullptr; // Perform a copy if necessary. if (shouldCopy) { @@ -2532,7 +2532,7 @@ void CodeGenFunction::ExpandTypeToArgs(QualType Ty, RValue RV, LValue LV = MakeAddrLValue(RV.getAggregateAddr(), Ty); if (RD->isUnion()) { - const FieldDecl *LargestFD = 0; + const FieldDecl *LargestFD = nullptr; CharUnits UnionSize = CharUnits::Zero(); for (const auto *FD : RD->fields()) { @@ -2609,7 +2609,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo, // If we're using inalloca, insert the allocation after the stack save. // FIXME: Do this earlier rather than hacking it in here! - llvm::Value *ArgMemory = 0; + llvm::Value *ArgMemory = nullptr; if (llvm::StructType *ArgStruct = CallInfo.getArgStruct()) { llvm::Instruction *IP = CallArgs.getStackBase(); llvm::AllocaInst *AI; @@ -2626,7 +2626,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo, // If the call returns a temporary with struct return, create a temporary // alloca to hold the result, unless one is given to us. - llvm::Value *SRetPtr = 0; + llvm::Value *SRetPtr = nullptr; bool SwapThisWithSRet = false; if (RetAI.isIndirect() || RetAI.isInAlloca()) { SRetPtr = ReturnValue.getValue(); @@ -2919,7 +2919,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo, llvm::AttributeSet Attrs = llvm::AttributeSet::get(getLLVMContext(), AttributeList); - llvm::BasicBlock *InvokeDest = 0; + llvm::BasicBlock *InvokeDest = nullptr; if (!Attrs.hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::NoUnwind)) InvokeDest = getInvokeDest(); diff --git a/lib/CodeGen/CGCall.h b/lib/CodeGen/CGCall.h index 2e43d1d67f..9510a1cd54 100644 --- a/lib/CodeGen/CGCall.h +++ b/lib/CodeGen/CGCall.h @@ -56,7 +56,7 @@ namespace CodeGen { class CallArgList : public SmallVector { public: - CallArgList() : StackBase(0), StackBaseMem(0) {} + CallArgList() : StackBase(nullptr), StackBaseMem(nullptr) {} struct Writeback { /// The original argument. Note that the argument l-value diff --git a/lib/CodeGen/CGClass.cpp b/lib/CodeGen/CGClass.cpp index 071f8b3237..97bea97734 100644 --- a/lib/CodeGen/CGClass.cpp +++ b/lib/CodeGen/CGClass.cpp @@ -66,8 +66,8 @@ CodeGenModule::GetNonVirtualBaseClassOffset(const CXXRecordDecl *ClassDecl, ComputeNonVirtualBaseClassOffset(getContext(), ClassDecl, PathBegin, PathEnd); if (Offset.isZero()) - return 0; - + return nullptr; + llvm::Type *PtrDiffTy = Types.ConvertType(getContext().getPointerDiffType()); @@ -114,7 +114,7 @@ ApplyNonVirtualAndVirtualOffset(CodeGenFunction &CGF, llvm::Value *ptr, CharUnits nonVirtualOffset, llvm::Value *virtualOffset) { // Assert that we have something to do. - assert(!nonVirtualOffset.isZero() || virtualOffset != 0); + assert(!nonVirtualOffset.isZero() || virtualOffset != nullptr); // Compute the offset from the static and dynamic components. llvm::Value *baseOffset; @@ -143,8 +143,8 @@ CodeGenFunction::GetAddressOfBaseClass(llvm::Value *Value, assert(PathBegin != PathEnd && "Base path should not be empty!"); CastExpr::path_const_iterator Start = PathBegin; - const CXXRecordDecl *VBase = 0; - + const CXXRecordDecl *VBase = nullptr; + // Sema has done some convenient canonicalization here: if the // access path involved any virtual steps, the conversion path will // *start* with a step down to the correct virtual base subobject, @@ -169,7 +169,7 @@ CodeGenFunction::GetAddressOfBaseClass(llvm::Value *Value, const ASTRecordLayout &layout = getContext().getASTRecordLayout(Derived); CharUnits vBaseOffset = layout.getVBaseClassOffset(VBase); NonVirtualOffset += vBaseOffset; - VBase = 0; // we no longer have a virtual step + VBase = nullptr; // we no longer have a virtual step } // Get the base pointer type. @@ -180,11 +180,11 @@ CodeGenFunction::GetAddressOfBaseClass(llvm::Value *Value, // just do a bitcast; null checks are unnecessary. if (NonVirtualOffset.isZero() && !VBase) { return Builder.CreateBitCast(Value, BasePtrTy); - } + } + + llvm::BasicBlock *origBB = nullptr; + llvm::BasicBlock *endBB = nullptr; - llvm::BasicBlock *origBB = 0; - llvm::BasicBlock *endBB = 0; - // Skip over the offset (and the vtable load) if we're supposed to // null-check the pointer. if (NullCheckValue) { @@ -198,7 +198,7 @@ CodeGenFunction::GetAddressOfBaseClass(llvm::Value *Value, } // Compute the virtual offset. - llvm::Value *VirtualOffset = 0; + llvm::Value *VirtualOffset = nullptr; if (VBase) { VirtualOffset = CGM.getCXXABI().GetVirtualBaseClassOffset(*this, Value, Derived, VBase); @@ -246,11 +246,11 @@ CodeGenFunction::GetAddressOfDerivedClass(llvm::Value *Value, // No offset, we can just cast back. return Builder.CreateBitCast(Value, DerivedPtrTy); } - - llvm::BasicBlock *CastNull = 0; - llvm::BasicBlock *CastNotNull = 0; - llvm::BasicBlock *CastEnd = 0; - + + llvm::BasicBlock *CastNull = nullptr; + llvm::BasicBlock *CastNotNull = nullptr; + llvm::BasicBlock *CastEnd = nullptr; + if (NullCheckValue) { CastNull = createBasicBlock("cast.null"); CastNotNull = createBasicBlock("cast.notnull"); @@ -290,7 +290,7 @@ llvm::Value *CodeGenFunction::GetVTTParameter(GlobalDecl GD, bool Delegating) { if (!CGM.getCXXABI().NeedsVTTParameter(GD)) { // This constructor/destructor does not need a VTT parameter. - return 0; + return nullptr; } const CXXRecordDecl *RD = cast(CurCodeDecl)->getParent(); @@ -454,7 +454,7 @@ static void EmitAggMemberInitializer(CodeGenFunction &CGF, switch (CGF.getEvaluationKind(T)) { case TEK_Scalar: - CGF.EmitScalarInit(Init, /*decl*/ 0, LV, false); + CGF.EmitScalarInit(Init, /*decl*/ nullptr, LV, false); break; case TEK_Complex: CGF.EmitComplexExprIntoLValue(Init, LV, /*isInit*/ true); @@ -607,7 +607,7 @@ void CodeGenFunction::EmitInitializerForField(FieldDecl *Field, EmitComplexExprIntoLValue(Init, LHS, /*isInit*/ true); break; case TEK_Aggregate: { - llvm::Value *ArrayIndexVar = 0; + llvm::Value *ArrayIndexVar = nullptr; if (ArrayIndexes.size()) { llvm::Type *SizeTy = ConvertType(getContext().getSizeType()); @@ -777,8 +777,8 @@ namespace { const VarDecl *SrcRec) : CGF(CGF), ClassDecl(ClassDecl), SrcRec(SrcRec), RecLayout(CGF.getContext().getASTRecordLayout(ClassDecl)), - FirstField(0), LastField(0), FirstFieldOffset(0), LastFieldOffset(0), - LastAddedFieldIndex(0) { } + FirstField(nullptr), LastField(nullptr), FirstFieldOffset(0), + LastFieldOffset(0), LastAddedFieldIndex(0) {} static bool isMemcpyableField(FieldDecl *F) { Qualifiers Qual = F->getType().getQualifiers(); @@ -788,7 +788,7 @@ namespace { } void addMemcpyableField(FieldDecl *F) { - if (FirstField == 0) + if (!FirstField) addInitialField(F); else addNextField(F); @@ -810,7 +810,7 @@ namespace { void emitMemcpy() { // Give the subclass a chance to bail out if it feels the memcpy isn't // worth it (e.g. Hasn't aggregated enough data). - if (FirstField == 0) { + if (!FirstField) { return; } @@ -844,7 +844,7 @@ namespace { } void reset() { - FirstField = 0; + FirstField = nullptr; } protected: @@ -917,7 +917,7 @@ namespace { FunctionArgList &Args) { if (CD->isCopyOrMoveConstructor() && CD->isDefaulted()) return Args[Args.size() - 1]; - return 0; + return nullptr; } // Returns true if a CXXCtorInitializer represents a member initialization @@ -926,7 +926,7 @@ namespace { if (!MemcpyableCtor) return false; FieldDecl *Field = MemberInit->getMember(); - assert(Field != 0 && "No field for member init."); + assert(Field && "No field for member init."); QualType FieldType = Field->getType(); CXXConstructExpr *CE = dyn_cast(MemberInit->getInit()); @@ -1014,71 +1014,71 @@ namespace { // exists. Otherwise returns null. FieldDecl *getMemcpyableField(Stmt *S) { if (!AssignmentsMemcpyable) - return 0; + return nullptr; if (BinaryOperator *BO = dyn_cast(S)) { // Recognise trivial assignments. if (BO->getOpcode() != BO_Assign) - return 0; + return nullptr; MemberExpr *ME = dyn_cast(BO->getLHS()); if (!ME) - return 0; + return nullptr; FieldDecl *Field = dyn_cast(ME->getMemberDecl()); if (!Field || !isMemcpyableField(Field)) - return 0; + return nullptr; Stmt *RHS = BO->getRHS(); if (ImplicitCastExpr *EC = dyn_cast(RHS)) RHS = EC->getSubExpr(); if (!RHS) - return 0; + return nullptr; MemberExpr *ME2 = dyn_cast(RHS); if (dyn_cast(ME2->getMemberDecl()) != Field) - return 0; + return nullptr; return Field; } else if (CXXMemberCallExpr *MCE = dyn_cast(S)) { CXXMethodDecl *MD = dyn_cast(MCE->getCalleeDecl()); if (!(MD && (MD->isCopyAssignmentOperator() || MD->isMoveAssignmentOperator()) && MD->isTrivial())) - return 0; + return nullptr; MemberExpr *IOA = dyn_cast(MCE->getImplicitObjectArgument()); if (!IOA) - return 0; + return nullptr; FieldDecl *Field = dyn_cast(IOA->getMemberDecl()); if (!Field || !isMemcpyableField(Field)) - return 0; + return nullptr; MemberExpr *Arg0 = dyn_cast(MCE->getArg(0)); if (!Arg0 || Field != dyn_cast(Arg0->getMemberDecl())) - return 0; + return nullptr; return Field; } else if (CallExpr *CE = dyn_cast(S)) { FunctionDecl *FD = dyn_cast(CE->getCalleeDecl()); if (!FD || FD->getBuiltinID() != Builtin::BI__builtin_memcpy) - return 0; + return nullptr; Expr *DstPtr = CE->getArg(0); if (ImplicitCastExpr *DC = dyn_cast(DstPtr)) DstPtr = DC->getSubExpr(); UnaryOperator *DUO = dyn_cast(DstPtr); if (!DUO || DUO->getOpcode() != UO_AddrOf) - return 0; + return nullptr; MemberExpr *ME = dyn_cast(DUO->getSubExpr()); if (!ME) - return 0; + return nullptr; FieldDecl *Field = dyn_cast(ME->getMemberDecl()); if (!Field || !isMemcpyableField(Field)) - return 0; + return nullptr; Expr *SrcPtr = CE->getArg(1); if (ImplicitCastExpr *SC = dyn_cast(SrcPtr)) SrcPtr = SC->getSubExpr(); UnaryOperator *SUO = dyn_cast(SrcPtr); if (!SUO || SUO->getOpcode() != UO_AddrOf) - return 0; + return nullptr; MemberExpr *ME2 = dyn_cast(SUO->getSubExpr()); if (!ME2 || Field != dyn_cast(ME2->getMemberDecl())) - return 0; + return nullptr; return Field; } - return 0; + return nullptr; } bool AssignmentsMemcpyable; @@ -1137,7 +1137,7 @@ void CodeGenFunction::EmitCtorPrologue(const CXXConstructorDecl *CD, CXXConstructorDecl::init_const_iterator B = CD->init_begin(), E = CD->init_end(); - llvm::BasicBlock *BaseCtorContinueBB = 0; + llvm::BasicBlock *BaseCtorContinueBB = nullptr; if (ClassDecl->getNumVBases() && !CGM.getTarget().getCXXABI().hasConstructorVariants()) { // The ABIs that don't have constructor variants need to put a branch @@ -1374,7 +1374,7 @@ namespace { public: CallDtorDeleteConditional(llvm::Value *ShouldDeleteCondition) : ShouldDeleteCondition(ShouldDeleteCondition) { - assert(ShouldDeleteCondition != NULL); + assert(ShouldDeleteCondition != nullptr); } void Emit(CodeGenFunction &CGF, Flags flags) override { @@ -1552,7 +1552,7 @@ CodeGenFunction::EmitCXXAggrConstructorCall(const CXXConstructorDecl *ctor, // because of GCC extensions that permit zero-length arrays. There // are probably legitimate places where we could assume that this // doesn't happen, but it's not clear that it's worth it. - llvm::BranchInst *zeroCheckBranch = 0; + llvm::BranchInst *zeroCheckBranch = nullptr; // Optimize for a constant count. llvm::ConstantInt *constantCount @@ -1870,7 +1870,7 @@ CodeGenFunction::InitializeVTablePointer(BaseSubobject Base, return; // Compute where to store the address point. - llvm::Value *VirtualOffset = 0; + llvm::Value *VirtualOffset = nullptr; CharUnits NonVirtualOffset = CharUnits::Zero(); if (NeedsVirtualOffset) { @@ -1968,7 +1968,7 @@ void CodeGenFunction::InitializeVTablePointers(const CXXRecordDecl *RD) { // Initialize the vtable pointers for this class and all of its bases. VisitedVirtualBasesSetTy VBases; InitializeVTablePointers(BaseSubobject(RD, CharUnits::Zero()), - /*NearestVBase=*/0, + /*NearestVBase=*/nullptr, /*OffsetFromNearestVBase=*/CharUnits::Zero(), /*BaseIsNonVirtualPrimaryBase=*/false, RD, VBases); @@ -2177,7 +2177,7 @@ void CodeGenFunction::EmitLambdaDelegatingInvokeBody(const CXXMethodDecl *MD) { assert(MD->isFunctionTemplateSpecialization()); const TemplateArgumentList *TAL = MD->getTemplateSpecializationArgs(); FunctionTemplateDecl *CallOpTemplate = CallOp->getDescribedFunctionTemplate(); - void *InsertPos = 0; + void *InsertPos = nullptr; FunctionDecl *CorrespondingCallOpSpecialization = CallOpTemplate->findSpecialization(TAL->data(), TAL->size(), InsertPos); assert(CorrespondingCallOpSpecialization); diff --git a/lib/CodeGen/CGCleanup.cpp b/lib/CodeGen/CGCleanup.cpp index 8748224b3e..ed9f96df79 100644 --- a/lib/CodeGen/CGCleanup.cpp +++ b/lib/CodeGen/CGCleanup.cpp @@ -50,7 +50,7 @@ DominatingValue::saved_type::save(CodeGenFunction &CGF, RValue rv) { CodeGenFunction::ComplexPairTy V = rv.getComplexVal(); llvm::Type *ComplexTy = llvm::StructType::get(V.first->getType(), V.second->getType(), - (void*) 0); + (void*) nullptr); llvm::Value *addr = CGF.CreateTempAlloca(ComplexTy, "saved-complex"); CGF.Builder.CreateStore(V.first, CGF.Builder.CreateStructGEP(addr, 0)); CGF.Builder.CreateStore(V.second, CGF.Builder.CreateStructGEP(addr, 1)); @@ -245,7 +245,7 @@ void EHScopeStack::popNullFixups() { assert(BranchFixups.size() >= MinSize && "fixup stack out of order"); while (BranchFixups.size() > MinSize && - BranchFixups.back().Destination == 0) + BranchFixups.back().Destination == nullptr) BranchFixups.pop_back(); } @@ -263,7 +263,7 @@ void CodeGenFunction::initFullExprCleanup() { // Set that as the active flag in the cleanup. EHCleanupScope &cleanup = cast(*EHStack.begin()); - assert(cleanup.getActiveFlag() == 0 && "cleanup already has active flag?"); + assert(!cleanup.getActiveFlag() && "cleanup already has active flag?"); cleanup.setActiveFlag(active); if (cleanup.isNormalCleanup()) cleanup.setTestFlagInNormalCleanup(); @@ -283,7 +283,7 @@ static void ResolveAllBranchFixups(CodeGenFunction &CGF, for (unsigned I = 0, E = CGF.EHStack.getNumBranchFixups(); I != E; ++I) { // Skip this fixup if its destination isn't set. BranchFixup &Fixup = CGF.EHStack.getBranchFixup(I); - if (Fixup.Destination == 0) continue; + if (Fixup.Destination == nullptr) continue; // If there isn't an OptimisticBranchBlock, then InitialBranch is // still pointing directly to its destination; forward it to the @@ -293,7 +293,7 @@ static void ResolveAllBranchFixups(CodeGenFunction &CGF, // lbl: // i.e. where there's an unresolved fixup inside a single cleanup // entry which we're currently popping. - if (Fixup.OptimisticBranchBlock == 0) { + if (Fixup.OptimisticBranchBlock == nullptr) { new llvm::StoreInst(CGF.Builder.getInt32(Fixup.DestinationIndex), CGF.getNormalCleanupDestSlot(), Fixup.InitialBranch); @@ -347,7 +347,7 @@ void CodeGenFunction::ResolveBranchFixups(llvm::BasicBlock *Block) { BranchFixup &Fixup = EHStack.getBranchFixup(I); if (Fixup.Destination != Block) continue; - Fixup.Destination = 0; + Fixup.Destination = nullptr; ResolvedAny = true; // If it doesn't have an optimistic branch block, LatestBranch is @@ -473,7 +473,7 @@ static void EmitCleanup(CodeGenFunction &CGF, // If there's an active flag, load it and skip the cleanup if it's // false. - llvm::BasicBlock *ContBB = 0; + llvm::BasicBlock *ContBB = nullptr; if (ActiveFlag) { ContBB = CGF.createBasicBlock("cleanup.done"); llvm::BasicBlock *CleanupBB = CGF.createBasicBlock("cleanup.action"); @@ -568,15 +568,15 @@ void CodeGenFunction::PopCleanupBlock(bool FallthroughIsBranchThrough) { // Remember activation information. bool IsActive = Scope.isActive(); llvm::Value *NormalActiveFlag = - Scope.shouldTestFlagInNormalCleanup() ? Scope.getActiveFlag() : 0; + Scope.shouldTestFlagInNormalCleanup() ? Scope.getActiveFlag() : nullptr; llvm::Value *EHActiveFlag = - Scope.shouldTestFlagInEHCleanup() ? Scope.getActiveFlag() : 0; + Scope.shouldTestFlagInEHCleanup() ? Scope.getActiveFlag() : nullptr; // Check whether we need an EH cleanup. This is only true if we've // generated a lazy EH cleanup block. llvm::BasicBlock *EHEntry = Scope.getCachedEHDispatchBlock(); - assert(Scope.hasEHBranches() == (EHEntry != 0)); - bool RequiresEHCleanup = (EHEntry != 0); + assert(Scope.hasEHBranches() == (EHEntry != nullptr)); + bool RequiresEHCleanup = (EHEntry != nullptr); EHScopeStack::stable_iterator EHParent = Scope.getEnclosingEHScope(); // Check the three conditions which might require a normal cleanup: @@ -590,7 +590,7 @@ void CodeGenFunction::PopCleanupBlock(bool FallthroughIsBranchThrough) { // - whether there's a fallthrough llvm::BasicBlock *FallthroughSource = Builder.GetInsertBlock(); - bool HasFallthrough = (FallthroughSource != 0 && IsActive); + bool HasFallthrough = (FallthroughSource != nullptr && IsActive); // Branch-through fall-throughs leave the insertion point set to the // end of the last cleanup, which points to the current scope. The @@ -720,7 +720,7 @@ void CodeGenFunction::PopCleanupBlock(bool FallthroughIsBranchThrough) { // - if fall-through is a branch-through // - if there are fixups that will be optimistically forwarded // to the enclosing cleanup - llvm::BasicBlock *BranchThroughDest = 0; + llvm::BasicBlock *BranchThroughDest = nullptr; if (Scope.hasBranchThroughs() || (FallthroughSource && FallthroughIsBranchThrough) || (HasFixups && HasEnclosingCleanups)) { @@ -729,7 +729,7 @@ void CodeGenFunction::PopCleanupBlock(bool FallthroughIsBranchThrough) { BranchThroughDest = CreateNormalEntry(*this, cast(S)); } - llvm::BasicBlock *FallthroughDest = 0; + llvm::BasicBlock *FallthroughDest = nullptr; SmallVector InstsToAppend; // If there's exactly one branch-after and no other threads, @@ -943,7 +943,7 @@ void CodeGenFunction::EmitBranchThroughCleanup(JumpDest Dest) { Fixup.Destination = Dest.getBlock(); Fixup.DestinationIndex = Dest.getDestIndex(); Fixup.InitialBranch = BI; - Fixup.OptimisticBranchBlock = 0; + Fixup.OptimisticBranchBlock = nullptr; Builder.ClearInsertionPoint(); return; diff --git a/lib/CodeGen/CGCleanup.h b/lib/CodeGen/CGCleanup.h index fed75bc9d8..066cdb2a07 100644 --- a/lib/CodeGen/CGCleanup.h +++ b/lib/CodeGen/CGCleanup.h @@ -96,7 +96,7 @@ public: enum Kind { Cleanup, Catch, Terminate, Filter }; EHScope(Kind kind, EHScopeStack::stable_iterator enclosingEHScope) - : CachedLandingPad(0), CachedEHDispatchBlock(0), + : CachedLandingPad(nullptr), CachedEHDispatchBlock(nullptr), EnclosingEHScope(enclosingEHScope) { CommonBits.Kind = kind; } @@ -150,7 +150,7 @@ public: /// The catch handler for this type. llvm::BasicBlock *Block; - bool isCatchAll() const { return Type == 0; } + bool isCatchAll() const { return Type == nullptr; } }; private: @@ -180,7 +180,7 @@ public: } void setCatchAllHandler(unsigned I, llvm::BasicBlock *Block) { - setHandler(I, /*catchall*/ 0, Block); + setHandler(I, /*catchall*/ nullptr, Block); } void setHandler(unsigned I, llvm::Value *Type, llvm::BasicBlock *Block) { @@ -268,7 +268,7 @@ public: EHScopeStack::stable_iterator enclosingNormal, EHScopeStack::stable_iterator enclosingEH) : EHScope(EHScope::Cleanup, enclosingEH), EnclosingNormal(enclosingNormal), - NormalBlock(0), ActiveFlag(0), ExtInfo(0) { + NormalBlock(nullptr), ActiveFlag(nullptr), ExtInfo(nullptr) { CleanupBits.IsNormalCleanup = isNormal; CleanupBits.IsEHCleanup = isEH; CleanupBits.IsActive = isActive; @@ -455,7 +455,7 @@ class EHScopeStack::iterator { explicit iterator(char *Ptr) : Ptr(Ptr) {} public: - iterator() : Ptr(0) {} + iterator() : Ptr(nullptr) {} EHScope *get() const { return reinterpret_cast(Ptr); diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index acdce84e15..e2ba70ac54 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -878,7 +878,7 @@ CGDebugInfo::CreateRecordStaticField(const VarDecl *Var, unsigned LineNumber = getLineNumber(Var->getLocation()); StringRef VName = Var->getName(); - llvm::Constant *C = NULL; + llvm::Constant *C = nullptr; if (Var->getInit()) { const APValue *Value = Var->evaluateValue(); if (Value) { @@ -1122,7 +1122,7 @@ CGDebugInfo::CreateCXXMemberFunction(const CXXMethodDecl *Method, MethodTy, /*isLocalToUnit=*/false, /* isDefinition=*/ false, Virtuality, VIndex, ContainingType, - Flags, CGM.getLangOpts().Optimize, NULL, + Flags, CGM.getLangOpts().Optimize, nullptr, TParamsArray); SPCache[Method->getCanonicalDecl()] = llvm::WeakVH(SP); @@ -1250,7 +1250,7 @@ CollectTemplateParams(const TemplateParameterList *TPList, ->getTypeForDecl()) : CGM.getContext().getPointerType(D->getType()); llvm::DIType TTy = getOrCreateType(T, Unit); - llvm::Value *V = 0; + llvm::Value *V = nullptr; // Variable pointer template parameters have a value that is the address // of the variable. if (const VarDecl *VD = dyn_cast(D)) @@ -1282,7 +1282,7 @@ CollectTemplateParams(const TemplateParameterList *TPList, case TemplateArgument::NullPtr: { QualType T = TA.getNullPtrType(); llvm::DIType TTy = getOrCreateType(T, Unit); - llvm::Value *V = 0; + llvm::Value *V = nullptr; // Special case member data pointer null values since they're actually -1 // instead of zero. if (const MemberPointerType *MPT = @@ -1312,7 +1312,7 @@ CollectTemplateParams(const TemplateParameterList *TPList, llvm::DITemplateValueParameter TVP = DBuilder.createTemplateParameterPack( TheCU, Name, llvm::DIType(), - CollectTemplateParams(NULL, TA.getPackAsArray(), Unit)); + CollectTemplateParams(nullptr, TA.getPackAsArray(), Unit)); TemplateParams.push_back(TVP); } break; case TemplateArgument::Expression: { @@ -1765,7 +1765,7 @@ llvm::DIType CGDebugInfo::CreateTypeDefinition(const ObjCInterfaceType *Ty, llvm else if (Field->getAccessControl() == ObjCIvarDecl::Private) Flags = llvm::DIDescriptor::FlagPrivate; - llvm::MDNode *PropertyNode = NULL; + llvm::MDNode *PropertyNode = nullptr; if (ObjCImplementationDecl *ImpD = ID->getImplementation()) { if (ObjCPropertyImplDecl *PImpD = ImpD->FindPropertyImplIvarDecl(Field->getIdentifier())) { @@ -2086,7 +2086,7 @@ unsigned CGDebugInfo::Checksum(const ObjCInterfaceDecl *ID) { // a checksum. unsigned Sum = 0; for (const ObjCIvarDecl *Ivar = ID->all_declared_ivar_begin(); - Ivar != 0; Ivar = Ivar->getNextIvar()) + Ivar != nullptr; Ivar = Ivar->getNextIvar()) ++Sum; return Sum; @@ -2100,7 +2100,7 @@ ObjCInterfaceDecl *CGDebugInfo::getObjCInterfaceDecl(QualType Ty) { case Type::ObjCInterface: return cast(Ty)->getDecl(); default: - return 0; + return nullptr; } } @@ -2110,7 +2110,7 @@ llvm::DIType CGDebugInfo::CreateTypeNode(QualType Ty, llvm::DIFile Unit) { if (Ty.hasLocalQualifiers()) return CreateQualifiedType(Ty, Unit); - const char *Diag = 0; + const char *Diag = nullptr; // Work out details of type. switch (Ty->getTypeClass()) { @@ -2454,7 +2454,7 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, FnBeginRegionCount.push_back(LexicalBlockStack.size()); const Decl *D = GD.getDecl(); - bool HasDecl = (D != 0); + bool HasDecl = (D != nullptr); unsigned Flags = 0; llvm::DIFile Unit = getOrCreateFile(Loc); @@ -2857,7 +2857,7 @@ void CGDebugInfo::EmitDeclareOfBlockDeclRefVariable(const VarDecl *VD, assert(DebugKind >= CodeGenOptions::LimitedDebugInfo); assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!"); - if (Builder.GetInsertBlock() == 0) + if (Builder.GetInsertBlock() == nullptr) return; bool isByRef = VD->hasAttr(); @@ -2987,7 +2987,7 @@ void CGDebugInfo::EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo &block, BlockLayoutChunk chunk; chunk.OffsetInBits = blockLayout->getElementOffsetInBits(block.CXXThisIndex); - chunk.Capture = 0; + chunk.Capture = nullptr; chunks.push_back(chunk); } @@ -3281,11 +3281,11 @@ void CGDebugInfo::EmitUsingDecl(const UsingDecl &UD) { llvm::DIImportedEntity CGDebugInfo::EmitNamespaceAlias(const NamespaceAliasDecl &NA) { if (CGM.getCodeGenOpts().getDebugInfo() < CodeGenOptions::LimitedDebugInfo) - return llvm::DIImportedEntity(0); + return llvm::DIImportedEntity(nullptr); llvm::WeakVH &VH = NamespaceAliasCache[&NA]; if (VH) return llvm::DIImportedEntity(cast(VH)); - llvm::DIImportedEntity R(0); + llvm::DIImportedEntity R(nullptr); if (const NamespaceAliasDecl *Underlying = dyn_cast(NA.getAliasedNamespace())) // This could cache & dedup here rather than relying on metadata deduping. diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index ee70c7a0b0..1869c1c27a 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/lib/CodeGen/CGDecl.cpp @@ -197,7 +197,7 @@ CodeGenFunction::CreateStaticVarDecl(const VarDecl &D, llvm::GlobalVariable *GV = new llvm::GlobalVariable(CGM.getModule(), LTy, Ty.isConstant(getContext()), Linkage, - CGM.EmitNullConstant(D.getType()), Name, 0, + CGM.EmitNullConstant(D.getType()), Name, nullptr, llvm::GlobalVariable::NotThreadLocal, AddrSpace); GV->setAlignment(getContext().getDeclAlign(&D).getQuantity()); @@ -291,7 +291,7 @@ CodeGenFunction::AddInitializerToStaticVarDecl(const VarDecl &D, void CodeGenFunction::EmitStaticVarDecl(const VarDecl &D, llvm::GlobalValue::LinkageTypes Linkage) { llvm::Value *&DMEntry = LocalDeclMap[&D]; - assert(DMEntry == 0 && "Decl already exists in localdeclmap!"); + assert(!DMEntry && "Decl already exists in localdeclmap!"); // Check to see if we already have a global variable for this // declaration. This can happen when double-emitting function @@ -388,7 +388,7 @@ namespace { // Along the exceptions path we always execute the dtor. bool NRVO = flags.isForNormalCleanup() && NRVOFlag; - llvm::BasicBlock *SkipDtorBB = 0; + llvm::BasicBlock *SkipDtorBB = nullptr; if (NRVO) { // If we exited via NRVO, we skip the destructor call. llvm::BasicBlock *RunDtorBB = CGF.createBasicBlock("nrvo.unused"); @@ -615,7 +615,7 @@ void CodeGenFunction::EmitScalarInit(const Expr *init, } // Emit the initializer. - llvm::Value *value = 0; + llvm::Value *value = nullptr; switch (lifetime) { case Qualifiers::OCL_None: @@ -868,7 +868,7 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) { CGM.isTypeConstant(Ty, true)) { EmitStaticVarDecl(D, llvm::GlobalValue::InternalLinkage); - emission.Address = 0; // signal this condition to later callbacks + emission.Address = nullptr; // signal this condition to later callbacks assert(emission.wasEmittedAsGlobal()); return emission; } @@ -963,7 +963,7 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) { } llvm::Value *&DMEntry = LocalDeclMap[&D]; - assert(DMEntry == 0 && "Decl already exists in localdeclmap!"); + assert(!DMEntry && "Decl already exists in localdeclmap!"); DMEntry = DeclPtr; emission.Address = DeclPtr; @@ -1083,7 +1083,7 @@ void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) { llvm::Value *Loc = capturedByInit ? emission.Address : emission.getObjectAddress(*this); - llvm::Constant *constant = 0; + llvm::Constant *constant = nullptr; if (emission.IsConstantAggregate || D.isConstexpr()) { assert(!capturedByInit && "constant init contains a capturing block?"); constant = CGM.EmitConstantInit(D, this); @@ -1210,7 +1210,7 @@ void CodeGenFunction::emitAutoVarTypeCleanup( QualType type = var->getType(); CleanupKind cleanupKind = NormalAndEHCleanup; - CodeGenFunction::Destroyer *destroyer = 0; + CodeGenFunction::Destroyer *destroyer = nullptr; switch (dtorKind) { case QualType::DK_none: @@ -1620,7 +1620,7 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, llvm::Value *Arg, // The only implicit argument a block has is its literal. if (BlockInfo) { LocalDeclMap[&D] = Arg; - llvm::Value *LocalAddr = 0; + llvm::Value *LocalAddr = nullptr; if (CGM.getCodeGenOpts().OptimizationLevel == 0) { // Allocate a stack slot to let the debug info survive the RA. llvm::AllocaInst *Alloc = CreateTempAlloca(ConvertTypeForMem(Ty), @@ -1734,7 +1734,7 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, llvm::Value *Arg, EmitStoreOfScalar(Arg, lv, /* isInitialization */ true); llvm::Value *&DMEntry = LocalDeclMap[&D]; - assert(DMEntry == 0 && "Decl already exists in localdeclmap!"); + assert(!DMEntry && "Decl already exists in localdeclmap!"); DMEntry = DeclPtr; // Emit debug info for param declaration. diff --git a/lib/CodeGen/CGDeclCXX.cpp b/lib/CodeGen/CGDeclCXX.cpp index 0cc9330a86..742be0b25c 100644 --- a/lib/CodeGen/CGDeclCXX.cpp +++ b/lib/CodeGen/CGDeclCXX.cpp @@ -90,7 +90,7 @@ static void EmitDeclDestroy(CodeGenFunction &CGF, const VarDecl &D, // Special-case non-array C++ destructors, where there's a function // with the right signature that we can just call. - const CXXRecordDecl *record = 0; + const CXXRecordDecl *record = nullptr; if (dtorKind == QualType::DK_cxx_destructor && (record = type->getAsCXXRecordDecl())) { assert(!record->hasTrivialDestructor()); @@ -305,7 +305,7 @@ CodeGenModule::EmitCXXGlobalVarDeclInitFunc(const VarDecl *D, if (I == DelayedCXXInitPosition.end()) { CXXGlobalInits.push_back(Fn); } else { - assert(CXXGlobalInits[I->second] == 0); + assert(CXXGlobalInits[I->second] == nullptr); CXXGlobalInits[I->second] = Fn; DelayedCXXInitPosition.erase(I); } @@ -313,7 +313,7 @@ CodeGenModule::EmitCXXGlobalVarDeclInitFunc(const VarDecl *D, } void CodeGenModule::EmitCXXThreadLocalInitFunc() { - llvm::Function *InitFn = 0; + llvm::Function *InitFn = nullptr; if (!CXXThreadLocalInits.empty()) { // Generate a guarded initialization function. llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, false); @@ -420,7 +420,7 @@ void CodeGenFunction::GenerateCXXGlobalVarDeclInitFunc(llvm::Function *Fn, bool PerformInit) { // Check if we need to emit debug info for variable initializer. if (D->hasAttr()) - DebugInfo = NULL; // disable debug info indefinitely for this function + DebugInfo = nullptr; // disable debug info indefinitely for this function StartFunction(GlobalDecl(D), getContext().VoidTy, Fn, getTypes().arrangeNullaryFunction(), @@ -451,7 +451,7 @@ CodeGenFunction::GenerateCXXGlobalInitFunc(llvm::Function *Fn, // Emit an artificial location for this function. AL.Emit(); - llvm::BasicBlock *ExitBlock = 0; + llvm::BasicBlock *ExitBlock = nullptr; if (Guard) { // If we have a guard variable, check whether we've already performed // these initializations. This happens for TLS initialization functions. @@ -522,7 +522,7 @@ llvm::Function *CodeGenFunction::generateDestroyHelper( llvm::Constant *addr, QualType type, Destroyer *destroyer, bool useEHCleanupForArray, const VarDecl *VD) { FunctionArgList args; - ImplicitParamDecl dst(getContext(), 0, SourceLocation(), 0, + ImplicitParamDecl dst(getContext(), nullptr, SourceLocation(), nullptr, getContext().VoidPtrTy); args.push_back(&dst); diff --git a/lib/CodeGen/CGException.cpp b/lib/CodeGen/CGException.cpp index ef651bccb1..9fa478ce78 100644 --- a/lib/CodeGen/CGException.cpp +++ b/lib/CodeGen/CGException.cpp @@ -164,18 +164,21 @@ namespace { }; } -const EHPersonality EHPersonality::GNU_C = { "__gcc_personality_v0", 0 }; -const EHPersonality EHPersonality::GNU_C_SJLJ = { "__gcc_personality_sj0", 0 }; -const EHPersonality EHPersonality::NeXT_ObjC = { "__objc_personality_v0", 0 }; -const EHPersonality EHPersonality::GNU_CPlusPlus = { "__gxx_personality_v0", 0}; +const EHPersonality EHPersonality::GNU_C = { "__gcc_personality_v0", nullptr }; const EHPersonality -EHPersonality::GNU_CPlusPlus_SJLJ = { "__gxx_personality_sj0", 0 }; +EHPersonality::GNU_C_SJLJ = { "__gcc_personality_sj0", nullptr }; +const EHPersonality +EHPersonality::NeXT_ObjC = { "__objc_personality_v0", nullptr }; +const EHPersonality +EHPersonality::GNU_CPlusPlus = { "__gxx_personality_v0", nullptr }; +const EHPersonality +EHPersonality::GNU_CPlusPlus_SJLJ = { "__gxx_personality_sj0", nullptr }; const EHPersonality EHPersonality::GNU_ObjC = {"__gnu_objc_personality_v0", "objc_exception_throw"}; const EHPersonality -EHPersonality::GNU_ObjCXX = { "__gnustep_objcxx_personality_v0", 0 }; +EHPersonality::GNU_ObjCXX = { "__gnustep_objcxx_personality_v0", nullptr }; const EHPersonality -EHPersonality::GNUstep_ObjC = { "__gnustep_objc_personality_v0", 0 }; +EHPersonality::GNUstep_ObjC = { "__gnustep_objc_personality_v0", nullptr }; static const EHPersonality &getCPersonality(const LangOptions &L) { if (L.SjLjExceptions) @@ -467,7 +470,7 @@ void CodeGenFunction::EmitCXXThrowExpr(const CXXThrowExpr *E, // The address of the destructor. If the exception type has a // trivial destructor (or isn't a record), we just pass null. - llvm::Constant *Dtor = 0; + llvm::Constant *Dtor = nullptr; if (const RecordType *RecordTy = ThrowType->getAs()) { CXXRecordDecl *Record = cast(RecordTy->getDecl()); if (!Record->hasTrivialDestructor()) { @@ -492,7 +495,7 @@ void CodeGenFunction::EmitStartEHSpec(const Decl *D) { return; const FunctionDecl* FD = dyn_cast_or_null(D); - if (FD == 0) { + if (!FD) { // Check if CapturedDecl is nothrow and create terminate scope for it. if (const CapturedDecl* CD = dyn_cast_or_null(D)) { if (CD->isNothrow()) @@ -501,7 +504,7 @@ void CodeGenFunction::EmitStartEHSpec(const Decl *D) { return; } const FunctionProtoType *Proto = FD->getType()->getAs(); - if (Proto == 0) + if (!Proto) return; ExceptionSpecificationType EST = Proto->getExceptionSpecType(); @@ -566,7 +569,7 @@ void CodeGenFunction::EmitEndEHSpec(const Decl *D) { return; const FunctionDecl* FD = dyn_cast_or_null(D); - if (FD == 0) { + if (!FD) { // Check if CapturedDecl is nothrow and pop terminate scope for it. if (const CapturedDecl* CD = dyn_cast_or_null(D)) { if (CD->isNothrow()) @@ -575,7 +578,7 @@ void CodeGenFunction::EmitEndEHSpec(const Decl *D) { return; } const FunctionProtoType *Proto = FD->getType()->getAs(); - if (Proto == 0) + if (!Proto) return; ExceptionSpecificationType EST = Proto->getExceptionSpecType(); @@ -619,7 +622,7 @@ void CodeGenFunction::EnterCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock) { QualType CaughtType = C->getCaughtType(); CaughtType = CaughtType.getNonReferenceType().getUnqualifiedType(); - llvm::Value *TypeInfo = 0; + llvm::Value *TypeInfo = nullptr; if (CaughtType->isObjCObjectPointerType()) TypeInfo = CGM.getObjCRuntime().GetEHType(CaughtType); else @@ -697,7 +700,7 @@ llvm::BasicBlock *CodeGenFunction::getInvokeDestImpl() { assert(!EHStack.empty()); if (!CGM.getLangOpts().Exceptions) - return 0; + return nullptr; // Check the innermost scope for a cached landing pad. If this is // a non-EH cleanup, we'll check enclosing scopes in EmitLandingPad. @@ -1444,7 +1447,7 @@ void CodeGenFunction::FinallyInfo::enter(CodeGenFunction &CGF, llvm::Constant *beginCatchFn, llvm::Constant *endCatchFn, llvm::Constant *rethrowFn) { - assert((beginCatchFn != 0) == (endCatchFn != 0) && + assert((beginCatchFn != nullptr) == (endCatchFn != nullptr) && "begin/end catch functions not paired"); assert(rethrowFn && "rethrow function is required"); @@ -1459,7 +1462,7 @@ void CodeGenFunction::FinallyInfo::enter(CodeGenFunction &CGF, llvm::FunctionType *rethrowFnTy = cast( cast(rethrowFn->getType())->getElementType()); - SavedExnVar = 0; + SavedExnVar = nullptr; if (rethrowFnTy->getNumParams()) SavedExnVar = CGF.CreateTempAlloca(CGF.Int8PtrTy, "finally.exn"); @@ -1509,7 +1512,7 @@ void CodeGenFunction::FinallyInfo::exit(CodeGenFunction &CGF) { CGBuilderTy::InsertPoint savedIP = CGF.Builder.saveAndClearIP(); CGF.EmitBlock(catchBB); - llvm::Value *exn = 0; + llvm::Value *exn = nullptr; // If there's a begin-catch function, call it. if (BeginCatchFn) { @@ -1673,7 +1676,7 @@ llvm::BasicBlock *CodeGenFunction::getEHResumeBlock(bool isCleanup) { // This can always be a call because we necessarily didn't find // anything on the EH stack which needs our help. const char *RethrowName = Personality.CatchallRethrowFn; - if (RethrowName != 0 && !isCleanup) { + if (RethrowName != nullptr && !isCleanup) { EmitRuntimeCall(getCatchallRethrowFn(CGM, RethrowName), getExceptionFromSlot()) ->setDoesNotReturn(); diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index ebd160b2e6..1f8a804bd7 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -54,8 +54,8 @@ llvm::Value *CodeGenFunction::EmitCastToVoidPtr(llvm::Value *value) { llvm::AllocaInst *CodeGenFunction::CreateTempAlloca(llvm::Type *Ty, const Twine &Name) { if (!Builder.isNamePreserving()) - return new llvm::AllocaInst(Ty, 0, "", AllocaInsertPt); - return new llvm::AllocaInst(Ty, 0, Name, AllocaInsertPt); + return new llvm::AllocaInst(Ty, nullptr, "", AllocaInsertPt); + return new llvm::AllocaInst(Ty, nullptr, Name, AllocaInsertPt); } void CodeGenFunction::InitTempAlloca(llvm::AllocaInst *Var, @@ -242,7 +242,7 @@ pushTemporaryCleanup(CodeGenFunction &CGF, const MaterializeTemporaryExpr *M, } } - CXXDestructorDecl *ReferenceTemporaryDtor = 0; + CXXDestructorDecl *ReferenceTemporaryDtor = nullptr; if (const RecordType *RT = E->getType()->getBaseElementTypeUnsafe()->getAs()) { // Get the destructor for the reference temporary. @@ -453,8 +453,8 @@ void CodeGenFunction::EmitTypeCheck(TypeCheckKind TCK, SourceLocation Loc, if (Address->getType()->getPointerAddressSpace()) return; - llvm::Value *Cond = 0; - llvm::BasicBlock *Done = 0; + llvm::Value *Cond = nullptr; + llvm::BasicBlock *Done = nullptr; if (SanOpts->Null) { // The glvalue must not be an empty glvalue. @@ -468,7 +468,7 @@ void CodeGenFunction::EmitTypeCheck(TypeCheckKind TCK, SourceLocation Loc, llvm::BasicBlock *Rest = createBasicBlock("not.null"); Builder.CreateCondBr(Cond, Rest, Done); EmitBlock(Rest); - Cond = 0; + Cond = nullptr; } } @@ -637,7 +637,7 @@ static llvm::Value *getArrayIndexingBound( } } - return 0; + return nullptr; } void CodeGenFunction::EmitBoundsCheck(const Expr *E, const Expr *Base, @@ -706,7 +706,7 @@ EmitComplexPrePostIncDec(const UnaryOperator *E, LValue LV, RValue CodeGenFunction::GetUndefRValue(QualType Ty) { if (Ty->isVoidType()) - return RValue::get(0); + return RValue::get(nullptr); switch (getEvaluationKind(Ty)) { case TEK_Complex: { @@ -1048,7 +1048,7 @@ llvm::MDNode *CodeGenFunction::getRangeForLoadFromType(QualType Ty) { llvm::APInt Min, End; if (!getRangeForType(*this, Ty, Min, End, CGM.getCodeGenOpts().StrictEnums)) - return 0; + return nullptr; llvm::MDBuilder MDHelper(getLLVMContext()); return MDHelper.createRange(Min, End); @@ -2035,7 +2035,7 @@ LValue CodeGenFunction::EmitPredefinedLValue(const PredefinedExpr *E) { // If this is outside of a function use the top level decl. const Decl *CurDecl = CurCodeDecl; - if (CurDecl == 0 || isa(CurDecl)) + if (!CurDecl || isa(CurDecl)) CurDecl = getContext().getTranslationUnitDecl(); const Type *ElemType = E->getType()->getArrayElementTypeNoTypeQual(); @@ -2106,7 +2106,7 @@ llvm::Constant *CodeGenFunction::EmitCheckTypeDescriptor(QualType T) { SmallString<32> Buffer; CGM.getDiags().ConvertArgToString(DiagnosticsEngine::ak_qualtype, (intptr_t)T.getAsOpaquePtr(), - 0, 0, 0, 0, 0, 0, Buffer, + nullptr, 0, nullptr, 0, nullptr, 0, Buffer, ArrayRef()); llvm::Constant *Components[] = { @@ -2281,13 +2281,13 @@ void CodeGenFunction::EmitTrapCheck(llvm::Value *Checked) { static const Expr *isSimpleArrayDecayOperand(const Expr *E) { // If this isn't just an array->pointer decay, bail out. const auto *CE = dyn_cast(E); - if (CE == 0 || CE->getCastKind() != CK_ArrayToPointerDecay) + if (!CE || CE->getCastKind() != CK_ArrayToPointerDecay) return 0; // If this is a decay from variable width array, bail out. const Expr *SubExpr = CE->getSubExpr(); if (SubExpr->getType()->isVariableArrayType()) - return 0; + return nullptr; return SubExpr; } @@ -2319,7 +2319,7 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E, // We know that the pointer points to a type of the correct size, unless the // size is a VLA or Objective-C interface. - llvm::Value *Address = 0; + llvm::Value *Address = nullptr; CharUnits ArrayAlignment; if (const VariableArrayType *vla = getContext().getAsVariableArrayType(E->getType())) { @@ -2962,7 +2962,7 @@ RValue CodeGenFunction::EmitCallExpr(const CallExpr *E, // If the pseudo-expression names a retainable object with weak or // strong lifetime, the object shall be released. Expr *BaseExpr = PseudoDtor->getBase(); - llvm::Value *BaseValue = NULL; + llvm::Value *BaseValue = nullptr; Qualifiers BaseQuals; // If this is s.x, emit s as an lvalue. If it is s->x, emit s as a scalar. @@ -3002,7 +3002,7 @@ RValue CodeGenFunction::EmitCallExpr(const CallExpr *E, EmitScalarExpr(E->getCallee()); } - return RValue::get(0); + return RValue::get(nullptr); } llvm::Value *Callee = EmitScalarExpr(E->getCallee()); @@ -3148,7 +3148,7 @@ LValue CodeGenFunction::EmitLValueForIvar(QualType ObjectTy, LValue CodeGenFunction::EmitObjCIvarRefLValue(const ObjCIvarRefExpr *E) { // FIXME: A lot of the code below could be shared with EmitMemberExpr. - llvm::Value *BaseValue = 0; + llvm::Value *BaseValue = nullptr; const Expr *BaseExpr = E->getBase(); Qualifiers BaseQuals; QualType ObjectTy; diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp index 6c505210b9..760e6f15fa 100644 --- a/lib/CodeGen/CGExprAgg.cpp +++ b/lib/CodeGen/CGExprAgg.cpp @@ -389,9 +389,9 @@ void AggExprEmitter::EmitArrayInit(llvm::Value *DestPtr, llvm::ArrayType *AType, // already-constructed members if an initializer throws. // For that, we'll need an EH cleanup. QualType::DestructionKind dtorKind = elementType.isDestructedType(); - llvm::AllocaInst *endOfInit = 0; + llvm::AllocaInst *endOfInit = nullptr; EHScopeStack::stable_iterator cleanup; - llvm::Instruction *cleanupDominator = 0; + llvm::Instruction *cleanupDominator = nullptr; if (CGF.needsEHCleanup(dtorKind)) { // In principle we could tell the cleanup where we are more // directly, but the control flow can get so varied here that it @@ -539,7 +539,7 @@ static Expr *findPeephole(Expr *op, CastKind kind) { if (castE->getCastKind() == CK_NoOp) continue; } - return 0; + return nullptr; } } @@ -1044,7 +1044,7 @@ AggExprEmitter::EmitInitializationToLValue(Expr *E, LValue LV) { return; case TEK_Scalar: if (LV.isSimple()) { - CGF.EmitScalarInit(E, /*D=*/0, LV, /*Captured=*/false); + CGF.EmitScalarInit(E, /*D=*/nullptr, LV, /*Captured=*/false); } else { CGF.EmitStoreThroughLValue(RValue::get(CGF.EmitScalarExpr(E)), LV); } @@ -1165,7 +1165,7 @@ void AggExprEmitter::VisitInitListExpr(InitListExpr *E) { // We'll need to enter cleanup scopes in case any of the member // initializers throw an exception. SmallVector cleanups; - llvm::Instruction *cleanupDominator = 0; + llvm::Instruction *cleanupDominator = nullptr; // Here we iterate over the fields; this makes it simpler to both // default-initialize fields and skip over unnamed fields. @@ -1252,7 +1252,7 @@ static CharUnits GetNumNonZeroBytesInInit(const Expr *E, CodeGenFunction &CGF) { // If this is an initlist expr, sum up the size of sizes of the (present) // elements. If this is something weird, assume the whole thing is non-zero. const InitListExpr *ILE = dyn_cast(E); - if (ILE == 0 || !CGF.getTypes().isZeroInitializable(ILE->getType())) + if (!ILE || !CGF.getTypes().isZeroInitializable(ILE->getType())) return CGF.getContext().getTypeSizeInChars(E->getType()); // InitListExprs for structs have to be handled carefully. If there are @@ -1301,7 +1301,8 @@ static void CheckAggExprForMemSetUse(AggValueSlot &Slot, const Expr *E, CodeGenFunction &CGF) { // If the slot is already known to be zeroed, nothing to do. Don't mess with // volatile stores. - if (Slot.isZeroed() || Slot.isVolatile() || Slot.getAddr() == 0) return; + if (Slot.isZeroed() || Slot.isVolatile() || Slot.getAddr() == nullptr) + return; // C++ objects with a user-declared constructor don't need zero'ing. if (CGF.getLangOpts().CPlusPlus) @@ -1348,7 +1349,7 @@ static void CheckAggExprForMemSetUse(AggValueSlot &Slot, const Expr *E, void CodeGenFunction::EmitAggExpr(const Expr *E, AggValueSlot Slot) { assert(E && hasAggregateEvaluationKind(E->getType()) && "Invalid aggregate expression to emit"); - assert((Slot.getAddr() != 0 || Slot.isIgnored()) && + assert((Slot.getAddr() != nullptr || Slot.isIgnored()) && "slot has bits but no address"); // Optimize the slot if possible. @@ -1468,10 +1469,10 @@ void CodeGenFunction::EmitAggregateCopy(llvm::Value *DestPtr, // memcpy, as well as the TBAA tags for the members of the struct, in case // the optimizer wishes to expand it in to scalar memory operations. llvm::MDNode *TBAAStructTag = CGM.getTBAAStructInfo(Ty); - + Builder.CreateMemCpy(DestPtr, SrcPtr, llvm::ConstantInt::get(IntPtrTy, TypeInfo.first.getQuantity()), alignment.getQuantity(), isVolatile, - /*TBAATag=*/0, TBAAStructTag); + /*TBAATag=*/nullptr, TBAAStructTag); } diff --git a/lib/CodeGen/CGExprCXX.cpp b/lib/CodeGen/CGExprCXX.cpp index 3a116062b8..548cd48890 100644 --- a/lib/CodeGen/CGExprCXX.cpp +++ b/lib/CodeGen/CGExprCXX.cpp @@ -95,7 +95,7 @@ RValue CodeGenFunction::EmitCXXMemberCallExpr(const CXXMemberCallExpr *CE, const Expr *Base = ME->getBase(); bool CanUseVirtualCall = MD->isVirtual() && !ME->hasQualifier(); - const CXXMethodDecl *DevirtualizedMethod = NULL; + const CXXMethodDecl *DevirtualizedMethod = nullptr; if (CanUseVirtualCall && CanDevirtualizeMemberFunctionCall(Base, MD)) { const CXXRecordDecl *BestDynamicDecl = Base->getBestDynamicClassType(); DevirtualizedMethod = MD->getCorrespondingMethodInClass(BestDynamicDecl); @@ -111,7 +111,7 @@ RValue CodeGenFunction::EmitCXXMemberCallExpr(const CXXMemberCallExpr *CE, // one or the one of the full expression, we would have to build // a derived-to-base cast to compute the correct this pointer, but // we don't have support for that yet, so do a virtual call. - DevirtualizedMethod = NULL; + DevirtualizedMethod = nullptr; } // If the return types are not the same, this might be a case where more // code needs to run to compensate for it. For example, the derived @@ -121,7 +121,7 @@ RValue CodeGenFunction::EmitCXXMemberCallExpr(const CXXMemberCallExpr *CE, if (DevirtualizedMethod && DevirtualizedMethod->getReturnType().getCanonicalType() != MD->getReturnType().getCanonicalType()) - DevirtualizedMethod = NULL; + DevirtualizedMethod = nullptr; } llvm::Value *This; @@ -132,10 +132,10 @@ RValue CodeGenFunction::EmitCXXMemberCallExpr(const CXXMemberCallExpr *CE, if (MD->isTrivial()) { - if (isa(MD)) return RValue::get(0); + if (isa(MD)) return RValue::get(nullptr); if (isa(MD) && cast(MD)->isDefaultConstructor()) - return RValue::get(0); + return RValue::get(nullptr); if (MD->isCopyAssignmentOperator() || MD->isMoveAssignmentOperator()) { // We don't like to generate the trivial copy/move assignment operator @@ -158,7 +158,7 @@ RValue CodeGenFunction::EmitCXXMemberCallExpr(const CXXMemberCallExpr *CE, // Compute the function type we're calling. const CXXMethodDecl *CalleeDecl = DevirtualizedMethod ? DevirtualizedMethod : MD; - const CGFunctionInfo *FInfo = 0; + const CGFunctionInfo *FInfo = nullptr; if (const CXXDestructorDecl *Dtor = dyn_cast(CalleeDecl)) FInfo = &CGM.getTypes().arrangeCXXDestructor(Dtor, Dtor_Complete); @@ -199,9 +199,9 @@ RValue CodeGenFunction::EmitCXXMemberCallExpr(const CXXMemberCallExpr *CE, Callee = CGM.GetAddrOfFunction(GlobalDecl(DDtor, Dtor_Complete), Ty); } EmitCXXMemberCall(MD, CE->getExprLoc(), Callee, ReturnValue, This, - /*ImplicitParam=*/0, QualType(), 0, 0); + /*ImplicitParam=*/nullptr, QualType(), nullptr,nullptr); } - return RValue::get(0); + return RValue::get(nullptr); } if (const CXXConstructorDecl *Ctor = dyn_cast(MD)) { @@ -226,7 +226,7 @@ RValue CodeGenFunction::EmitCXXMemberCallExpr(const CXXMemberCallExpr *CE, } return EmitCXXMemberCall(MD, CE->getExprLoc(), Callee, ReturnValue, This, - /*ImplicitParam=*/0, QualType(), + /*ImplicitParam=*/nullptr, QualType(), CE->arg_begin(), CE->arg_end()); } @@ -299,7 +299,7 @@ CodeGenFunction::EmitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *E, llvm::Value *Callee = EmitCXXOperatorMemberCallee(E, MD, This); return EmitCXXMemberCall(MD, E->getExprLoc(), Callee, ReturnValue, This, - /*ImplicitParam=*/0, QualType(), + /*ImplicitParam=*/nullptr, QualType(), E->arg_begin() + 1, E->arg_end()); } @@ -586,7 +586,7 @@ static llvm::Value *EmitCXXNewAllocSize(CodeGenFunction &CGF, // size := sizeWithoutCookie + cookieSize // and check whether it overflows. - llvm::Value *hasOverflow = 0; + llvm::Value *hasOverflow = nullptr; // If numElementsWidth > sizeWidth, then one way or another, we're // going to have to do a comparison for (2), and this happens to @@ -726,8 +726,8 @@ static void StoreAnyExprIntoOneUnit(CodeGenFunction &CGF, const Expr *Init, CharUnits Alignment = CGF.getContext().getTypeAlignInChars(AllocType); switch (CGF.getEvaluationKind(AllocType)) { case TEK_Scalar: - CGF.EmitScalarInit(Init, 0, CGF.MakeAddrLValue(NewPtr, AllocType, - Alignment), + CGF.EmitScalarInit(Init, nullptr, CGF.MakeAddrLValue(NewPtr, AllocType, + Alignment), false); return; case TEK_Complex: @@ -764,10 +764,10 @@ CodeGenFunction::EmitNewArrayInitializer(const CXXNewExpr *E, unsigned initializerElements = 0; const Expr *Init = E->getInitializer(); - llvm::AllocaInst *endOfInit = 0; + llvm::AllocaInst *endOfInit = nullptr; QualType::DestructionKind dtorKind = elementType.isDestructedType(); EHScopeStack::stable_iterator cleanup; - llvm::Instruction *cleanupDominator = 0; + llvm::Instruction *cleanupDominator = nullptr; // If the initializer is an initializer list, first do the explicit elements. if (const InitListExpr *ILE = dyn_cast(Init)) { @@ -1161,8 +1161,8 @@ llvm::Value *CodeGenFunction::EmitCXXNewExpr(const CXXNewExpr *E) { minElements = ILE->getNumInits(); } - llvm::Value *numElements = 0; - llvm::Value *allocSizeWithoutCookie = 0; + llvm::Value *numElements = nullptr; + llvm::Value *allocSizeWithoutCookie = nullptr; llvm::Value *allocSize = EmitCXXNewAllocSize(*this, E, minElements, numElements, allocSizeWithoutCookie); @@ -1196,8 +1196,8 @@ llvm::Value *CodeGenFunction::EmitCXXNewExpr(const CXXNewExpr *E) { bool nullCheck = allocatorType->isNothrow(getContext()) && (!allocType.isPODType(getContext()) || E->hasInitializer()); - llvm::BasicBlock *nullCheckBB = 0; - llvm::BasicBlock *contBB = 0; + llvm::BasicBlock *nullCheckBB = nullptr; + llvm::BasicBlock *contBB = nullptr; llvm::Value *allocation = RV.getScalarVal(); unsigned AS = allocation->getType()->getPointerAddressSpace(); @@ -1221,7 +1221,7 @@ llvm::Value *CodeGenFunction::EmitCXXNewExpr(const CXXNewExpr *E) { // If there's an operator delete, enter a cleanup to call it if an // exception is thrown. EHScopeStack::stable_iterator operatorDeleteCleanup; - llvm::Instruction *cleanupDominator = 0; + llvm::Instruction *cleanupDominator = nullptr; if (E->getOperatorDelete() && !E->getOperatorDelete()->isReservedGlobalPlacementOperator()) { EnterNewDeleteCleanup(*this, E, allocation, allocSize, allocatorArgs); @@ -1288,7 +1288,7 @@ void CodeGenFunction::EmitDeleteCall(const FunctionDecl *DeleteFD, CallArgList DeleteArgs; // Check if we need to pass the size to the delete operator. - llvm::Value *Size = 0; + llvm::Value *Size = nullptr; QualType SizeTy; if (DeleteFTy->getNumParams() == 2) { SizeTy = DeleteFTy->getParamType(1); @@ -1334,7 +1334,7 @@ static void EmitObjectDelete(CodeGenFunction &CGF, bool UseGlobalDelete) { // Find the destructor for the type, if applicable. If the // destructor is virtual, we'll just emit the vcall and return. - const CXXDestructorDecl *Dtor = 0; + const CXXDestructorDecl *Dtor = nullptr; if (const RecordType *RT = ElementType->getAs()) { CXXRecordDecl *RD = cast(RT->getDecl()); if (RD->hasDefinition() && !RD->hasTrivialDestructor()) { @@ -1471,8 +1471,8 @@ static void EmitArrayDelete(CodeGenFunction &CGF, const CXXDeleteExpr *E, llvm::Value *deletedPtr, QualType elementType) { - llvm::Value *numElements = 0; - llvm::Value *allocatedPtr = 0; + llvm::Value *numElements = nullptr; + llvm::Value *allocatedPtr = nullptr; CharUnits cookieSize; CGF.CGM.getCXXABI().ReadArrayCookie(CGF, deletedPtr, E, elementType, numElements, allocatedPtr, cookieSize); @@ -1820,9 +1820,9 @@ llvm::Value *CodeGenFunction::EmitDynamicCast(llvm::Value *Value, // If the value of v is a null pointer value in the pointer case, the result // is the null pointer value of type T. bool ShouldNullCheckSrcValue = SrcTy->isPointerType(); - - llvm::BasicBlock *CastNull = 0; - llvm::BasicBlock *CastNotNull = 0; + + llvm::BasicBlock *CastNull = nullptr; + llvm::BasicBlock *CastNotNull = nullptr; llvm::BasicBlock *CastEnd = createBasicBlock("dynamic_cast.end"); if (ShouldNullCheckSrcValue) { diff --git a/lib/CodeGen/CGExprComplex.cpp b/lib/CodeGen/CGExprComplex.cpp index 1f84c86ad6..7244b9e4d1 100644 --- a/lib/CodeGen/CGExprComplex.cpp +++ b/lib/CodeGen/CGExprComplex.cpp @@ -306,7 +306,7 @@ ComplexPairTy ComplexExprEmitter::EmitLoadOfLValue(LValue lvalue, unsigned ComplexAlign = C.getTypeAlignInChars(ComplexTy).getQuantity(); unsigned AlignI = std::min(AlignR, ComplexAlign); - llvm::Value *Real=0, *Imag=0; + llvm::Value *Real=nullptr, *Imag=nullptr; if (!IgnoreReal || isVolatile) { llvm::Value *RealP = Builder.CreateStructGEP(SrcPtr, 0, diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp index 4e615922fe..b2f08c32d9 100644 --- a/lib/CodeGen/CGExprConstant.cpp +++ b/lib/CodeGen/CGExprConstant.cpp @@ -530,7 +530,7 @@ llvm::Constant *ConstStructBuilder::BuildStruct(CodeGenModule &CGM, ConstStructBuilder Builder(CGM, CGF); if (!Builder.Build(ILE)) - return 0; + return nullptr; return Builder.Finalize(ILE->getType()); } @@ -572,7 +572,7 @@ public: //===--------------------------------------------------------------------===// llvm::Constant *VisitStmt(Stmt *S) { - return 0; + return nullptr; } llvm::Constant *VisitParenExpr(ParenExpr *PE) { @@ -599,7 +599,7 @@ public: llvm::Constant *VisitCastExpr(CastExpr* E) { Expr *subExpr = E->getSubExpr(); llvm::Constant *C = CGM.EmitConstantExpr(subExpr, subExpr->getType(), CGF); - if (!C) return 0; + if (!C) return nullptr; llvm::Type *destType = ConvertType(E->getType()); @@ -660,7 +660,7 @@ public: case CK_ARCReclaimReturnedObject: case CK_ARCExtendBlockObject: case CK_CopyAndAutoreleaseBlockObject: - return 0; + return nullptr; // These don't need to be handled here because Evaluate knows how to // evaluate them in the cases where they can be folded. @@ -701,7 +701,7 @@ public: case CK_FloatingToBoolean: case CK_FloatingCast: case CK_ZeroToOCLEvent: - return 0; + return nullptr; } llvm_unreachable("Invalid CastKind"); } @@ -743,7 +743,7 @@ public: Expr *Init = ILE->getInit(i); llvm::Constant *C = CGM.EmitConstantExpr(Init, Init->getType(), CGF); if (!C) - return 0; + return nullptr; RewriteType |= (C->getType() != ElemTy); Elts.push_back(C); } @@ -756,7 +756,7 @@ public: else fillC = llvm::Constant::getNullValue(ElemTy); if (!fillC) - return 0; + return nullptr; RewriteType |= (fillC->getType() != ElemTy); Elts.resize(NumElements, fillC); @@ -789,12 +789,12 @@ public: if (ILE->getType()->isRecordType()) return EmitRecordInitialization(ILE); - return 0; + return nullptr; } llvm::Constant *VisitCXXConstructExpr(CXXConstructExpr *E) { if (!E->getConstructor()->isTrivial()) - return 0; + return nullptr; QualType Ty = E->getType(); @@ -806,8 +806,8 @@ public: // If the class doesn't have a trivial destructor, we can't emit it as a // constant expr. if (!RD->hasTrivialDestructor()) - return 0; - + return nullptr; + // Only copy and default constructors can be trivial. @@ -872,7 +872,7 @@ public: return CGM.getStaticLocalDeclAddress(VD); } } - return 0; + return nullptr; } Expr *E = const_cast(LVBase.get()); @@ -889,7 +889,7 @@ public: C = new llvm::GlobalVariable(CGM.getModule(), C->getType(), E->getType().isConstant(CGM.getContext()), llvm::GlobalValue::InternalLinkage, - C, ".compoundliteral", 0, + C, ".compoundliteral", nullptr, llvm::GlobalVariable::NotThreadLocal, CGM.getContext().getTargetAddressSpace(E->getType())); return C; @@ -970,7 +970,7 @@ public: } } - return 0; + return nullptr; } }; @@ -1004,7 +1004,7 @@ llvm::Constant *CodeGenModule::EmitConstantInit(const VarDecl &D, // interprets that as the (pointer) value of the reference, rather than the // desired value of the referee. if (D.getType()->isReferenceType()) - return 0; + return nullptr; const Expr *E = D.getInit(); assert(E && "No initializer to emit"); @@ -1029,7 +1029,7 @@ llvm::Constant *CodeGenModule::EmitConstantExpr(const Expr *E, else Success = E->EvaluateAsRValue(Result, Context); - llvm::Constant *C = 0; + llvm::Constant *C = nullptr; if (Success && !Result.HasSideEffects) C = EmitConstantValue(Result.Val, DestType, CGF); else @@ -1174,13 +1174,13 @@ llvm::Constant *CodeGenModule::EmitConstantValue(const APValue &Value, Elts.reserve(NumElements); // Emit array filler, if there is one. - llvm::Constant *Filler = 0; + llvm::Constant *Filler = nullptr; if (Value.hasArrayFiller()) Filler = EmitConstantValueForMemory(Value.getArrayFiller(), CAT->getElementType(), CGF); // Emit initializer elements. - llvm::Type *CommonElementType = 0; + llvm::Type *CommonElementType = nullptr; for (unsigned I = 0; I < NumElements; ++I) { llvm::Constant *C = Filler; if (I < NumInitElts) @@ -1191,7 +1191,7 @@ llvm::Constant *CodeGenModule::EmitConstantValue(const APValue &Value, if (I == 0) CommonElementType = C->getType(); else if (C->getType() != CommonElementType) - CommonElementType = 0; + CommonElementType = nullptr; Elts.push_back(C); } @@ -1230,7 +1230,7 @@ CodeGenModule::EmitConstantValueForMemory(const APValue &Value, llvm::Constant * CodeGenModule::GetAddrOfConstantCompoundLiteral(const CompoundLiteralExpr *E) { assert(E->isFileScope() && "not a file-scope compound literal expr"); - return ConstExprEmitter(*this, 0).EmitLValue(E); + return ConstExprEmitter(*this, nullptr).EmitLValue(E); } llvm::Constant * diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp index 522a0e2d23..1ee3ce84ce 100644 --- a/lib/CodeGen/CGExprScalar.cpp +++ b/lib/CodeGen/CGExprScalar.cpp @@ -365,7 +365,7 @@ public: } Value *VisitCXXDeleteExpr(const CXXDeleteExpr *E) { CGF.EmitCXXDeleteExpr(E); - return 0; + return nullptr; } Value *VisitTypeTraitExpr(const TypeTraitExpr *E) { @@ -387,7 +387,7 @@ public: // effect is the evaluation of the postfix-expression before the dot or // arrow. CGF.EmitScalarExpr(E->getBase()); - return 0; + return nullptr; } Value *VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *E) { @@ -396,7 +396,7 @@ public: Value *VisitCXXThrowExpr(const CXXThrowExpr *E) { CGF.EmitCXXThrowExpr(E); - return 0; + return nullptr; } Value *VisitCXXNoexceptExpr(const CXXNoexceptExpr *E) { @@ -559,7 +559,7 @@ void ScalarExprEmitter::EmitFloatConversionCheck(Value *OrigSrc, llvm::Type *SrcTy = Src->getType(); - llvm::Value *Check = 0; + llvm::Value *Check = nullptr; if (llvm::IntegerType *IntTy = dyn_cast(SrcTy)) { // Integer to floating-point. This can fail for unsigned short -> __half // or unsigned __int128 -> float. @@ -693,7 +693,7 @@ Value *ScalarExprEmitter::EmitScalarConversion(Value *Src, QualType SrcType, DstType = CGF.getContext().getCanonicalType(DstType); if (SrcType == DstType) return Src; - if (DstType->isVoidType()) return 0; + if (DstType->isVoidType()) return nullptr; llvm::Value *OrigSrc = Src; QualType OrigSrcType = SrcType; @@ -758,7 +758,7 @@ Value *ScalarExprEmitter::EmitScalarConversion(Value *Src, QualType SrcType, return Builder.CreateBitCast(Src, DstTy, "conv"); // Finally, we have the arithmetic types: real int/float. - Value *Res = NULL; + Value *Res = nullptr; llvm::Type *ResTy = DstTy; // An overflowing conversion has undefined behavior if either the source type @@ -887,7 +887,7 @@ void ScalarExprEmitter::EmitBinOpCheck(Value *Check, const BinOpInfo &Info) { Value *ScalarExprEmitter::VisitExpr(Expr *E) { CGF.ErrorUnsupported(E, "scalar expression"); if (E->getType()->isVoidType()) - return 0; + return nullptr; return llvm::UndefValue::get(CGF.ConvertType(E->getType())); } @@ -1013,7 +1013,7 @@ Value *ScalarExprEmitter::VisitConvertVectorExpr(ConvertVectorExpr *E) { } // We have the arithmetic types: real int/float. - Value *Res = NULL; + Value *Res = nullptr; if (isa(SrcEltTy)) { bool InputSigned = SrcEltType->isSignedIntegerOrEnumerationType(); @@ -1133,7 +1133,7 @@ Value *ScalarExprEmitter::VisitInitListExpr(InitListExpr *E) { if (EI->getVectorOperandType()->getNumElements() == ResElts) { llvm::ConstantInt *C = cast(EI->getIndexOperand()); - Value *LHS = 0, *RHS = 0; + Value *LHS = nullptr, *RHS = nullptr; if (CurIdx == 0) { // insert into undef -> shuffle (src, undef) Args.push_back(C); @@ -1450,7 +1450,7 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) { case CK_ToVoid: { CGF.EmitIgnoredExpr(E); - return 0; + return nullptr; } case CK_VectorSplat: { llvm::Type *DstTy = ConvertType(DestTy); @@ -1507,7 +1507,7 @@ Value *ScalarExprEmitter::VisitStmtExpr(const StmtExpr *E) { llvm::Value *RetAlloca = CGF.EmitCompoundStmt(*E->getSubStmt(), !E->getType()->isVoidType()); if (!RetAlloca) - return 0; + return nullptr; return CGF.EmitLoadOfScalar(CGF.MakeAddrLValue(RetAlloca, E->getType()), E->getExprLoc()); } @@ -1545,7 +1545,7 @@ ScalarExprEmitter::EmitScalarPrePostIncDec(const UnaryOperator *E, LValue LV, bool isInc, bool isPre) { QualType type = E->getSubExpr()->getType(); - llvm::PHINode *atomicPHI = 0; + llvm::PHINode *atomicPHI = nullptr; llvm::Value *value; llvm::Value *input; @@ -1819,7 +1819,7 @@ Value *ScalarExprEmitter::VisitOffsetOfExpr(OffsetOfExpr *E) { QualType CurrentType = E->getTypeSourceInfo()->getType(); for (unsigned i = 0; i != n; ++i) { OffsetOfExpr::OffsetOfNode ON = E->getComponent(i); - llvm::Value *Offset = 0; + llvm::Value *Offset = nullptr; switch (ON.getKind()) { case OffsetOfExpr::OffsetOfNode::Array: { // Compute the index @@ -2009,7 +2009,7 @@ LValue ScalarExprEmitter::EmitCompoundAssignLValue( // Load/convert the LHS. LValue LHSLV = EmitCheckedLValue(E->getLHS(), CodeGenFunction::TCK_Store); - llvm::PHINode *atomicPHI = 0; + llvm::PHINode *atomicPHI = nullptr; if (const AtomicType *atomicTy = LHSTy->getAs()) { QualType type = atomicTy->getValueType(); if (!type->isBooleanType() && type->isIntegerType() && @@ -2108,7 +2108,7 @@ Value *ScalarExprEmitter::EmitCompoundAssign(const CompoundAssignOperator *E, // If the result is clearly ignored, return now. if (Ignore) - return 0; + return nullptr; // The result of an assignment in C is the assigned r-value. if (!CGF.getLangOpts().CPlusPlus) @@ -2124,7 +2124,7 @@ Value *ScalarExprEmitter::EmitCompoundAssign(const CompoundAssignOperator *E, void ScalarExprEmitter::EmitUndefinedBehaviorIntegerDivAndRemCheck( const BinOpInfo &Ops, llvm::Value *Zero, bool isDiv) { - llvm::Value *Cond = 0; + llvm::Value *Cond = nullptr; if (CGF.SanOpts->IntegerDivideByZero) Cond = Builder.CreateICmpNE(Ops.RHS, Zero); @@ -2428,12 +2428,12 @@ static Value* tryEmitFMulAdd(const BinOpInfo &op, // Check whether this op is marked as fusable. if (!op.FPContractable) - return 0; + return nullptr; // Check whether -ffp-contract=on. (If -ffp-contract=off/fast, fusing is // either disabled, or handled entirely by the LLVM backend). if (CGF.CGM.getCodeGenOpts().getFPContractMode() != CodeGenOptions::FPC_On) - return 0; + return nullptr; // We have a potentially fusable op. Look for a mul on one of the operands. if (llvm::BinaryOperator* LHSBinOp = dyn_cast(op.LHS)) { @@ -2451,7 +2451,7 @@ static Value* tryEmitFMulAdd(const BinOpInfo &op, } } - return 0; + return nullptr; } Value *ScalarExprEmitter::EmitAdd(const BinOpInfo &op) { @@ -2533,7 +2533,7 @@ Value *ScalarExprEmitter::EmitSub(const BinOpInfo &op) { const BinaryOperator *expr = cast(op.E); QualType elementType = expr->getLHS()->getType()->getPointeeType(); - llvm::Value *divisor = 0; + llvm::Value *divisor = nullptr; // For a variable-length array, this is going to be non-constant. if (const VariableArrayType *vla @@ -2861,7 +2861,7 @@ Value *ScalarExprEmitter::VisitBinAssign(const BinaryOperator *E) { // If the result is clearly ignored, return now. if (Ignore) - return 0; + return nullptr; // The result of an assignment in C is the assigned r-value. if (!CGF.getLangOpts().CPlusPlus) @@ -3152,7 +3152,7 @@ VisitAbstractConditionalOperator(const AbstractConditionalOperator *E) { if (!LHS) { // If the conditional has void type, make sure we return a null Value*. assert(!RHS && "LHS and RHS types must match"); - return 0; + return nullptr; } return Builder.CreateSelect(CondV, LHS, RHS, "cond"); } @@ -3349,7 +3349,7 @@ LValue CodeGenFunction::EmitObjCIsaExpr(const ObjCIsaExpr *E) { LValue CodeGenFunction::EmitCompoundAssignmentLValue( const CompoundAssignOperator *E) { ScalarExprEmitter Scalar(*this); - Value *Result = 0; + Value *Result = nullptr; switch (E->getOpcode()) { #define COMPOUND_OP(Op) \ case BO_##Op##Assign: \ diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp index d1cfddce9f..8c54bba4c7 100644 --- a/lib/CodeGen/CGObjC.cpp +++ b/lib/CodeGen/CGObjC.cpp @@ -90,7 +90,7 @@ CodeGenFunction::EmitObjCBoxedExpr(const ObjCBoxedExpr *E) { llvm::Value *CodeGenFunction::EmitObjCCollectionLiteral(const Expr *E, const ObjCMethodDecl *MethodWithObjects) { ASTContext &Context = CGM.getContext(); - const ObjCDictionaryLiteral *DLE = 0; + const ObjCDictionaryLiteral *DLE = nullptr; const ObjCArrayLiteral *ALE = dyn_cast(E); if (!ALE) DLE = cast(E); @@ -106,8 +106,8 @@ llvm::Value *CodeGenFunction::EmitObjCCollectionLiteral(const Expr *E, ArrayType::Normal, /*IndexTypeQuals=*/0); // Allocate the temporary array(s). - llvm::Value *Objects = CreateMemTemp(ElementArrayType, "objects"); - llvm::Value *Keys = 0; + llvm::Value *Objects = CreateMemTemp(ElementArrayType, "objects"); + llvm::Value *Keys = nullptr; if (DLE) Keys = CreateMemTemp(ElementArrayType, "keys"); @@ -314,10 +314,10 @@ RValue CodeGenFunction::EmitObjCMessageExpr(const ObjCMessageExpr *E, CGObjCRuntime &Runtime = CGM.getObjCRuntime(); bool isSuperMessage = false; bool isClassMessage = false; - ObjCInterfaceDecl *OID = 0; + ObjCInterfaceDecl *OID = nullptr; // Find the receiver QualType ReceiverType; - llvm::Value *Receiver = 0; + llvm::Value *Receiver = nullptr; switch (E->getReceiverKind()) { case ObjCMessageExpr::Instance: ReceiverType = E->getInstanceReceiver()->getType(); @@ -466,7 +466,7 @@ void CodeGenFunction::StartObjCMethod(const ObjCMethodDecl *OMD, FunctionArgList args; // Check if we should generate debug info for this method. if (OMD->hasAttr()) - DebugInfo = NULL; // disable debug info indefinitely for this function + DebugInfo = nullptr; // disable debug info indefinitely for this function llvm::Function *Fn = CGM.getObjCRuntime().GenerateMethod(OMD, CD); @@ -820,7 +820,7 @@ CodeGenFunction::generateObjCGetterBody(const ObjCImplementationDecl *classImpl, if (!hasTrivialGetExpr(propImpl)) { if (!AtomicHelperFn) { ReturnStmt ret(SourceLocation(), propImpl->getGetterCXXConstructor(), - /*nrvo*/ 0); + /*nrvo*/ nullptr); EmitReturnStmt(ret); } else { @@ -901,7 +901,7 @@ CodeGenFunction::generateObjCGetterBody(const ObjCImplementationDecl *classImpl, RValue RV = EmitCall(getTypes().arrangeFreeFunctionCall(propType, args, FunctionType::ExtInfo(), RequiredArgs::All), - getPropertyFn, ReturnValueSlot(), args, 0, + getPropertyFn, ReturnValueSlot(), args, nullptr, &CallInstruction); if (llvm::CallInst *call = dyn_cast(CallInstruction)) call->setTailCall(); @@ -1146,9 +1146,9 @@ CodeGenFunction::generateObjCSetterBody(const ObjCImplementationDecl *classImpl, case PropertyImplStrategy::GetSetProperty: case PropertyImplStrategy::SetPropertyAndExpressionGet: { - - llvm::Value *setOptimizedPropertyFn = 0; - llvm::Value *setPropertyFn = 0; + + llvm::Value *setOptimizedPropertyFn = nullptr; + llvm::Value *setPropertyFn = nullptr; if (UseOptimizedSetter(CGM)) { // 10.8 and iOS 6.0 code and GC is off setOptimizedPropertyFn = @@ -1331,7 +1331,7 @@ static void emitCXXDestructMethod(CodeGenFunction &CGF, QualType::DestructionKind dtorKind = type.isDestructedType(); if (!dtorKind) continue; - CodeGenFunction::Destroyer *destroyer = 0; + CodeGenFunction::Destroyer *destroyer = nullptr; // Use a call to objc_storeStrong to destroy strong ivars, for the // general benefit of the tools. @@ -1871,7 +1871,7 @@ static llvm::Value *emitARCStoreOperation(CodeGenFunction &CGF, }; llvm::CallInst *result = CGF.EmitNounwindRuntimeCall(fn, args); - if (ignored) return 0; + if (ignored) return nullptr; return CGF.Builder.CreateBitCast(result, origType); } @@ -2069,7 +2069,7 @@ llvm::Value *CodeGenFunction::EmitARCStoreStrongCall(llvm::Value *addr, }; EmitNounwindRuntimeCall(fn, args); - if (ignored) return 0; + if (ignored) return nullptr; return value; } @@ -2564,7 +2564,7 @@ tryEmitARCRetainScalarExpr(CodeGenFunction &CGF, const Expr *e) { // The desired result type, if it differs from the type of the // ultimate opaque expression. - llvm::Type *resultType = 0; + llvm::Type *resultType = nullptr; while (true) { e = e->IgnoreParens(); @@ -2870,16 +2870,16 @@ CodeGenFunction::GenerateObjCAtomicSetterCopyHelperFunction( const ObjCPropertyImplDecl *PID) { if (!getLangOpts().CPlusPlus || !getLangOpts().ObjCRuntime.hasAtomicCopyHelper()) - return 0; + return nullptr; QualType Ty = PID->getPropertyIvarDecl()->getType(); if (!Ty->isRecordType()) - return 0; + return nullptr; const ObjCPropertyDecl *PD = PID->getPropertyDecl(); if ((!(PD->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_atomic))) - return 0; - llvm::Constant * HelperFn = 0; + return nullptr; + llvm::Constant *HelperFn = nullptr; if (hasTrivialSetExpr(PID)) - return 0; + return nullptr; assert(PID->getSetterCXXAssignment() && "SetterCXXAssignment - null"); if ((HelperFn = CGM.getAtomicSetterHelperFnMap(Ty))) return HelperFn; @@ -2890,20 +2890,20 @@ CodeGenFunction::GenerateObjCAtomicSetterCopyHelperFunction( FunctionDecl *FD = FunctionDecl::Create(C, C.getTranslationUnitDecl(), SourceLocation(), - SourceLocation(), II, C.VoidTy, 0, - SC_Static, + SourceLocation(), II, C.VoidTy, + nullptr, SC_Static, false, false); - + QualType DestTy = C.getPointerType(Ty); QualType SrcTy = Ty; SrcTy.addConst(); SrcTy = C.getPointerType(SrcTy); FunctionArgList args; - ImplicitParamDecl dstDecl(getContext(), FD, SourceLocation(), 0, DestTy); + ImplicitParamDecl dstDecl(getContext(), FD, SourceLocation(), nullptr,DestTy); args.push_back(&dstDecl); - ImplicitParamDecl srcDecl(getContext(), FD, SourceLocation(), 0, SrcTy); + ImplicitParamDecl srcDecl(getContext(), FD, SourceLocation(), nullptr, SrcTy); args.push_back(&srcDecl); const CGFunctionInfo &FI = CGM.getTypes().arrangeFreeFunctionDeclaration( @@ -2947,17 +2947,17 @@ CodeGenFunction::GenerateObjCAtomicGetterCopyHelperFunction( const ObjCPropertyImplDecl *PID) { if (!getLangOpts().CPlusPlus || !getLangOpts().ObjCRuntime.hasAtomicCopyHelper()) - return 0; + return nullptr; const ObjCPropertyDecl *PD = PID->getPropertyDecl(); QualType Ty = PD->getType(); if (!Ty->isRecordType()) - return 0; + return nullptr; if ((!(PD->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_atomic))) - return 0; - llvm::Constant * HelperFn = 0; - + return nullptr; + llvm::Constant *HelperFn = nullptr; + if (hasTrivialGetExpr(PID)) - return 0; + return nullptr; assert(PID->getGetterCXXConstructor() && "getGetterCXXConstructor - null"); if ((HelperFn = CGM.getAtomicGetterHelperFnMap(Ty))) return HelperFn; @@ -2969,20 +2969,20 @@ CodeGenFunction::GenerateObjCAtomicGetterCopyHelperFunction( FunctionDecl *FD = FunctionDecl::Create(C, C.getTranslationUnitDecl(), SourceLocation(), - SourceLocation(), II, C.VoidTy, 0, - SC_Static, + SourceLocation(), II, C.VoidTy, + nullptr, SC_Static, false, false); - + QualType DestTy = C.getPointerType(Ty); QualType SrcTy = Ty; SrcTy.addConst(); SrcTy = C.getPointerType(SrcTy); FunctionArgList args; - ImplicitParamDecl dstDecl(getContext(), FD, SourceLocation(), 0, DestTy); + ImplicitParamDecl dstDecl(getContext(), FD, SourceLocation(), nullptr,DestTy); args.push_back(&dstDecl); - ImplicitParamDecl srcDecl(getContext(), FD, SourceLocation(), 0, SrcTy); + ImplicitParamDecl srcDecl(getContext(), FD, SourceLocation(), nullptr, SrcTy); args.push_back(&srcDecl); const CGFunctionInfo &FI = CGM.getTypes().arrangeFreeFunctionDeclaration( @@ -3059,11 +3059,11 @@ CodeGenFunction::EmitBlockCopyAndAutorelease(llvm::Value *Block, QualType Ty) { RValue Result; Result = Runtime.GenerateMessageSend(*this, ReturnValueSlot(), Ty, CopySelector, - Val, CallArgList(), 0, 0); + Val, CallArgList(), nullptr, nullptr); Val = Result.getScalarVal(); Result = Runtime.GenerateMessageSend(*this, ReturnValueSlot(), Ty, AutoreleaseSelector, - Val, CallArgList(), 0, 0); + Val, CallArgList(), nullptr, nullptr); Val = Result.getScalarVal(); return Val; } diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp index 029d822afc..3ca03780a3 100644 --- a/lib/CodeGen/CGObjCGNU.cpp +++ b/lib/CodeGen/CGObjCGNU.cpp @@ -53,7 +53,8 @@ class LazyRuntimeFunction { /// Constructor leaves this class uninitialized, because it is intended to /// be used as a field in another class and not all of the types that are /// used as arguments will necessarily be available at construction time. - LazyRuntimeFunction() : CGM(0), FunctionName(0), Function(0) {} + LazyRuntimeFunction() + : CGM(nullptr), FunctionName(nullptr), Function(nullptr) {} /// Initialises the lazy function with the name, return type, and the types /// of the arguments. @@ -62,7 +63,7 @@ class LazyRuntimeFunction { llvm::Type *RetTy, ...) { CGM =Mod; FunctionName = name; - Function = 0; + Function = nullptr; ArgTys.clear(); va_list Args; va_start(Args, RetTy); @@ -76,7 +77,7 @@ class LazyRuntimeFunction { /// LLVM constant. operator llvm::Constant*() { if (!Function) { - if (0 == FunctionName) return 0; + if (!FunctionName) return nullptr; // We put the return type on the end of the vector, so pop it back off llvm::Type *RetTy = ArgTys.back(); ArgTys.pop_back(); @@ -564,7 +565,7 @@ public: llvm::GlobalVariable *GetClassGlobal(const std::string &Name, bool Weak = false) override { - return 0; + return nullptr; } }; /// Class representing the legacy GCC Objective-C ABI. This is the default when @@ -605,10 +606,11 @@ protected: public: CGObjCGCC(CodeGenModule &Mod) : CGObjCGNU(Mod, 8, 2) { // IMP objc_msg_lookup(id, SEL); - MsgLookupFn.init(&CGM, "objc_msg_lookup", IMPTy, IdTy, SelectorTy, NULL); + MsgLookupFn.init(&CGM, "objc_msg_lookup", IMPTy, IdTy, SelectorTy, + nullptr); // IMP objc_msg_lookup_super(struct objc_super*, SEL); MsgLookupSuperFn.init(&CGM, "objc_msg_lookup_super", IMPTy, - PtrToObjCSuperTy, SelectorTy, NULL); + PtrToObjCSuperTy, SelectorTy, nullptr); } }; /// Class used when targeting the new GNUstep runtime ABI. @@ -696,51 +698,51 @@ class CGObjCGNUstep : public CGObjCGNU { const ObjCRuntime &R = CGM.getLangOpts().ObjCRuntime; llvm::StructType *SlotStructTy = llvm::StructType::get(PtrTy, - PtrTy, PtrTy, IntTy, IMPTy, NULL); + PtrTy, PtrTy, IntTy, IMPTy, nullptr); SlotTy = llvm::PointerType::getUnqual(SlotStructTy); // Slot_t objc_msg_lookup_sender(id *receiver, SEL selector, id sender); SlotLookupFn.init(&CGM, "objc_msg_lookup_sender", SlotTy, PtrToIdTy, - SelectorTy, IdTy, NULL); + SelectorTy, IdTy, nullptr); // Slot_t objc_msg_lookup_super(struct objc_super*, SEL); SlotLookupSuperFn.init(&CGM, "objc_slot_lookup_super", SlotTy, - PtrToObjCSuperTy, SelectorTy, NULL); + PtrToObjCSuperTy, SelectorTy, nullptr); // If we're in ObjC++ mode, then we want to make if (CGM.getLangOpts().CPlusPlus) { llvm::Type *VoidTy = llvm::Type::getVoidTy(VMContext); // void *__cxa_begin_catch(void *e) - EnterCatchFn.init(&CGM, "__cxa_begin_catch", PtrTy, PtrTy, NULL); + EnterCatchFn.init(&CGM, "__cxa_begin_catch", PtrTy, PtrTy, nullptr); // void __cxa_end_catch(void) - ExitCatchFn.init(&CGM, "__cxa_end_catch", VoidTy, NULL); + ExitCatchFn.init(&CGM, "__cxa_end_catch", VoidTy, nullptr); // void _Unwind_Resume_or_Rethrow(void*) ExceptionReThrowFn.init(&CGM, "_Unwind_Resume_or_Rethrow", VoidTy, - PtrTy, NULL); + PtrTy, nullptr); } else if (R.getVersion() >= VersionTuple(1, 7)) { llvm::Type *VoidTy = llvm::Type::getVoidTy(VMContext); // id objc_begin_catch(void *e) - EnterCatchFn.init(&CGM, "objc_begin_catch", IdTy, PtrTy, NULL); + EnterCatchFn.init(&CGM, "objc_begin_catch", IdTy, PtrTy, nullptr); // void objc_end_catch(void) - ExitCatchFn.init(&CGM, "objc_end_catch", VoidTy, NULL); + ExitCatchFn.init(&CGM, "objc_end_catch", VoidTy, nullptr); // void _Unwind_Resume_or_Rethrow(void*) ExceptionReThrowFn.init(&CGM, "objc_exception_rethrow", VoidTy, - PtrTy, NULL); + PtrTy, nullptr); } llvm::Type *VoidTy = llvm::Type::getVoidTy(VMContext); SetPropertyAtomic.init(&CGM, "objc_setProperty_atomic", VoidTy, IdTy, - SelectorTy, IdTy, PtrDiffTy, NULL); + SelectorTy, IdTy, PtrDiffTy, nullptr); SetPropertyAtomicCopy.init(&CGM, "objc_setProperty_atomic_copy", VoidTy, - IdTy, SelectorTy, IdTy, PtrDiffTy, NULL); + IdTy, SelectorTy, IdTy, PtrDiffTy, nullptr); SetPropertyNonAtomic.init(&CGM, "objc_setProperty_nonatomic", VoidTy, - IdTy, SelectorTy, IdTy, PtrDiffTy, NULL); + IdTy, SelectorTy, IdTy, PtrDiffTy, nullptr); SetPropertyNonAtomicCopy.init(&CGM, "objc_setProperty_nonatomic_copy", - VoidTy, IdTy, SelectorTy, IdTy, PtrDiffTy, NULL); + VoidTy, IdTy, SelectorTy, IdTy, PtrDiffTy, nullptr); // void objc_setCppObjectAtomic(void *dest, const void *src, void // *helper); CxxAtomicObjectSetFn.init(&CGM, "objc_setCppObjectAtomic", VoidTy, PtrTy, - PtrTy, PtrTy, NULL); + PtrTy, PtrTy, nullptr); // void objc_getCppObjectAtomic(void *dest, const void *src, void // *helper); CxxAtomicObjectGetFn.init(&CGM, "objc_getCppObjectAtomic", VoidTy, PtrTy, - PtrTy, PtrTy, NULL); + PtrTy, PtrTy, nullptr); } llvm::Constant *GetCppAtomicObjectGetFunction() override { // The optimised functions were added in version 1.7 of the GNUstep @@ -834,7 +836,7 @@ protected: if (!ClassSymbol) ClassSymbol = new llvm::GlobalVariable(TheModule, LongTy, false, llvm::GlobalValue::ExternalLinkage, - 0, SymbolName); + nullptr, SymbolName); return ClassSymbol; } @@ -842,14 +844,14 @@ protected: public: CGObjCObjFW(CodeGenModule &Mod): CGObjCGNU(Mod, 9, 3) { // IMP objc_msg_lookup(id, SEL); - MsgLookupFn.init(&CGM, "objc_msg_lookup", IMPTy, IdTy, SelectorTy, NULL); + MsgLookupFn.init(&CGM, "objc_msg_lookup", IMPTy, IdTy, SelectorTy, nullptr); MsgLookupFnSRet.init(&CGM, "objc_msg_lookup_stret", IMPTy, IdTy, - SelectorTy, NULL); + SelectorTy, nullptr); // IMP objc_msg_lookup_super(struct objc_super*, SEL); MsgLookupSuperFn.init(&CGM, "objc_msg_lookup_super", IMPTy, - PtrToObjCSuperTy, SelectorTy, NULL); + PtrToObjCSuperTy, SelectorTy, nullptr); MsgLookupSuperFnSRet.init(&CGM, "objc_msg_lookup_super_stret", IMPTy, - PtrToObjCSuperTy, SelectorTy, NULL); + PtrToObjCSuperTy, SelectorTy, nullptr); } }; } // end anonymous namespace @@ -867,7 +869,8 @@ void CGObjCGNU::EmitClassRef(const std::string &className) { llvm::GlobalVariable *ClassSymbol = TheModule.getGlobalVariable(symbolName); if (!ClassSymbol) { ClassSymbol = new llvm::GlobalVariable(TheModule, LongTy, false, - llvm::GlobalValue::ExternalLinkage, 0, symbolName); + llvm::GlobalValue::ExternalLinkage, + nullptr, symbolName); } new llvm::GlobalVariable(TheModule, ClassSymbol->getType(), true, llvm::GlobalValue::WeakAnyLinkage, ClassSymbol, symbolRef); @@ -884,10 +887,11 @@ static std::string SymbolNameForMethod(const StringRef &ClassName, } CGObjCGNU::CGObjCGNU(CodeGenModule &cgm, unsigned runtimeABIVersion, - unsigned protocolClassVersion) + unsigned protocolClassVersion) : CGObjCRuntime(cgm), TheModule(CGM.getModule()), - VMContext(cgm.getLLVMContext()), ClassPtrAlias(0), MetaClassPtrAlias(0), - RuntimeVersion(runtimeABIVersion), ProtocolVersion(protocolClassVersion) { + VMContext(cgm.getLLVMContext()), ClassPtrAlias(nullptr), + MetaClassPtrAlias(nullptr), RuntimeVersion(runtimeABIVersion), + ProtocolVersion(protocolClassVersion) { msgSendMDKind = VMContext.getMDKindID("GNUObjCMessageSend"); @@ -937,35 +941,35 @@ CGObjCGNU::CGObjCGNU(CodeGenModule &cgm, unsigned runtimeABIVersion, } PtrToIdTy = llvm::PointerType::getUnqual(IdTy); - ObjCSuperTy = llvm::StructType::get(IdTy, IdTy, NULL); + ObjCSuperTy = llvm::StructType::get(IdTy, IdTy, nullptr); PtrToObjCSuperTy = llvm::PointerType::getUnqual(ObjCSuperTy); llvm::Type *VoidTy = llvm::Type::getVoidTy(VMContext); // void objc_exception_throw(id); - ExceptionThrowFn.init(&CGM, "objc_exception_throw", VoidTy, IdTy, NULL); - ExceptionReThrowFn.init(&CGM, "objc_exception_throw", VoidTy, IdTy, NULL); + ExceptionThrowFn.init(&CGM, "objc_exception_throw", VoidTy, IdTy, nullptr); + ExceptionReThrowFn.init(&CGM, "objc_exception_throw", VoidTy, IdTy, nullptr); // int objc_sync_enter(id); - SyncEnterFn.init(&CGM, "objc_sync_enter", IntTy, IdTy, NULL); + SyncEnterFn.init(&CGM, "objc_sync_enter", IntTy, IdTy, nullptr); // int objc_sync_exit(id); - SyncExitFn.init(&CGM, "objc_sync_exit", IntTy, IdTy, NULL); + SyncExitFn.init(&CGM, "objc_sync_exit", IntTy, IdTy, nullptr); // void objc_enumerationMutation (id) EnumerationMutationFn.init(&CGM, "objc_enumerationMutation", VoidTy, - IdTy, NULL); + IdTy, nullptr); // id objc_getProperty(id, SEL, ptrdiff_t, BOOL) GetPropertyFn.init(&CGM, "objc_getProperty", IdTy, IdTy, SelectorTy, - PtrDiffTy, BoolTy, NULL); + PtrDiffTy, BoolTy, nullptr); // void objc_setProperty(id, SEL, ptrdiff_t, id, BOOL, BOOL) SetPropertyFn.init(&CGM, "objc_setProperty", VoidTy, IdTy, SelectorTy, - PtrDiffTy, IdTy, BoolTy, BoolTy, NULL); + PtrDiffTy, IdTy, BoolTy, BoolTy, nullptr); // void objc_setPropertyStruct(void*, void*, ptrdiff_t, BOOL, BOOL) GetStructPropertyFn.init(&CGM, "objc_getPropertyStruct", VoidTy, PtrTy, PtrTy, - PtrDiffTy, BoolTy, BoolTy, NULL); + PtrDiffTy, BoolTy, BoolTy, nullptr); // void objc_setPropertyStruct(void*, void*, ptrdiff_t, BOOL, BOOL) SetStructPropertyFn.init(&CGM, "objc_setPropertyStruct", VoidTy, PtrTy, PtrTy, - PtrDiffTy, BoolTy, BoolTy, NULL); + PtrDiffTy, BoolTy, BoolTy, nullptr); // IMP type llvm::Type *IMPArgs[] = { IdTy, SelectorTy }; @@ -990,20 +994,20 @@ CGObjCGNU::CGObjCGNU(CodeGenModule &cgm, unsigned runtimeABIVersion, // id objc_assign_ivar(id, id, ptrdiff_t); IvarAssignFn.init(&CGM, "objc_assign_ivar", IdTy, IdTy, IdTy, PtrDiffTy, - NULL); + nullptr); // id objc_assign_strongCast (id, id*) StrongCastAssignFn.init(&CGM, "objc_assign_strongCast", IdTy, IdTy, - PtrToIdTy, NULL); + PtrToIdTy, nullptr); // id objc_assign_global(id, id*); GlobalAssignFn.init(&CGM, "objc_assign_global", IdTy, IdTy, PtrToIdTy, - NULL); + nullptr); // id objc_assign_weak(id, id*); - WeakAssignFn.init(&CGM, "objc_assign_weak", IdTy, IdTy, PtrToIdTy, NULL); + WeakAssignFn.init(&CGM, "objc_assign_weak", IdTy, IdTy, PtrToIdTy, nullptr); // id objc_read_weak(id*); - WeakReadFn.init(&CGM, "objc_read_weak", IdTy, PtrToIdTy, NULL); + WeakReadFn.init(&CGM, "objc_read_weak", IdTy, PtrToIdTy, nullptr); // void *objc_memmove_collectable(void*, void *, size_t); MemMoveFn.init(&CGM, "objc_memmove_collectable", PtrTy, PtrTy, PtrTy, - SizeTy, NULL); + SizeTy, nullptr); } } @@ -1042,8 +1046,7 @@ llvm::Value *CGObjCGNU::GetSelector(CodeGenFunction &CGF, Selector Sel, const std::string &TypeEncoding, bool lval) { SmallVectorImpl &Types = SelectorTable[Sel]; - llvm::GlobalAlias *SelValue = 0; - + llvm::GlobalAlias *SelValue = nullptr; for (SmallVectorImpl::iterator i = Types.begin(), e = Types.end() ; i!=e ; i++) { @@ -1052,7 +1055,7 @@ llvm::Value *CGObjCGNU::GetSelector(CodeGenFunction &CGF, Selector Sel, break; } } - if (0 == SelValue) { + if (!SelValue) { SelValue = llvm::GlobalAlias::create( SelectorTy->getElementType(), 0, llvm::GlobalValue::PrivateLinkage, ".objc_selector_" + Sel.getAsString(), &TheModule); @@ -1088,7 +1091,7 @@ llvm::Constant *CGObjCGNU::GetEHType(QualType T) { if (CGM.getLangOpts().ObjCRuntime.isNonFragile()) { return MakeConstantString("@id"); } else { - return 0; + return nullptr; } } @@ -1117,7 +1120,7 @@ llvm::Constant *CGObjCGNUstep::GetEHType(QualType T) { new llvm::GlobalVariable(CGM.getModule(), PtrToInt8Ty, false, llvm::GlobalValue::ExternalLinkage, - 0, "__objc_id_type_info"); + nullptr, "__objc_id_type_info"); return llvm::ConstantExpr::getBitCast(IDEHType, PtrToInt8Ty); } @@ -1144,7 +1147,8 @@ llvm::Constant *CGObjCGNUstep::GetEHType(QualType T) { llvm::Constant *Vtable = TheModule.getGlobalVariable(vtableName); if (!Vtable) { Vtable = new llvm::GlobalVariable(TheModule, PtrToInt8Ty, true, - llvm::GlobalValue::ExternalLinkage, 0, vtableName); + llvm::GlobalValue::ExternalLinkage, + nullptr, vtableName); } llvm::Constant *Two = llvm::ConstantInt::get(IntTy, 2); Vtable = llvm::ConstantExpr::getGetElementPtr(Vtable, Two); @@ -1158,7 +1162,7 @@ llvm::Constant *CGObjCGNUstep::GetEHType(QualType T) { fields.push_back(typeName); llvm::Constant *TI = MakeGlobal(llvm::StructType::get(PtrToInt8Ty, PtrToInt8Ty, - NULL), fields, "__objc_eh_typeinfo_" + className, + nullptr), fields, "__objc_eh_typeinfo_" + className, llvm::GlobalValue::LinkOnceODRLinkage); return llvm::ConstantExpr::getBitCast(TI, PtrToInt8Ty); } @@ -1184,7 +1188,7 @@ llvm::Constant *CGObjCGNU::GenerateConstantString(const StringLiteral *SL) { if (!isa) isa = new llvm::GlobalVariable(TheModule, IdTy, /* isConstant */false, - llvm::GlobalValue::ExternalWeakLinkage, 0, Sym); + llvm::GlobalValue::ExternalWeakLinkage, nullptr, Sym); else if (isa->getType() != PtrToIdTy) isa = llvm::ConstantExpr::getBitCast(isa, PtrToIdTy); @@ -1193,7 +1197,7 @@ llvm::Constant *CGObjCGNU::GenerateConstantString(const StringLiteral *SL) { Ivars.push_back(MakeConstantString(Str)); Ivars.push_back(llvm::ConstantInt::get(IntTy, Str.size())); llvm::Constant *ObjCStr = MakeGlobal( - llvm::StructType::get(PtrToIdTy, PtrToInt8Ty, IntTy, NULL), + llvm::StructType::get(PtrToIdTy, PtrToInt8Ty, IntTy, nullptr), Ivars, ".objc_str"); ObjCStr = llvm::ConstantExpr::getBitCast(ObjCStr, PtrToInt8Ty); ObjCStrings[Str] = ObjCStr; @@ -1222,7 +1226,7 @@ CGObjCGNU::GenerateMessageSendSuper(CodeGenFunction &CGF, CGM.getTypes().ConvertType(ResultType))); } if (Sel == ReleaseSel) { - return RValue::get(0); + return RValue::get(nullptr); } } @@ -1237,9 +1241,9 @@ CGObjCGNU::GenerateMessageSendSuper(CodeGenFunction &CGF, MessageSendInfo MSI = getMessageSendInfo(Method, ResultType, ActualArgs); - llvm::Value *ReceiverClass = 0; + llvm::Value *ReceiverClass = nullptr; if (isCategoryImpl) { - llvm::Constant *classLookupFunction = 0; + llvm::Constant *classLookupFunction = nullptr; if (IsClassMessage) { classLookupFunction = CGM.CreateRuntimeFunction(llvm::FunctionType::get( IdTy, PtrTy, true), "objc_get_meta_class"); @@ -1274,14 +1278,14 @@ CGObjCGNU::GenerateMessageSendSuper(CodeGenFunction &CGF, // Cast the pointer to a simplified version of the class structure ReceiverClass = Builder.CreateBitCast(ReceiverClass, llvm::PointerType::getUnqual( - llvm::StructType::get(IdTy, IdTy, NULL))); + llvm::StructType::get(IdTy, IdTy, nullptr))); // Get the superclass pointer ReceiverClass = Builder.CreateStructGEP(ReceiverClass, 1); // Load the superclass pointer ReceiverClass = Builder.CreateLoad(ReceiverClass); // Construct the structure used to look up the IMP llvm::StructType *ObjCSuperTy = llvm::StructType::get( - Receiver->getType(), IdTy, NULL); + Receiver->getType(), IdTy, nullptr); llvm::Value *ObjCSuper = Builder.CreateAlloca(ObjCSuperTy); Builder.CreateStore(Receiver, Builder.CreateStructGEP(ObjCSuper, 0)); @@ -1301,7 +1305,8 @@ CGObjCGNU::GenerateMessageSendSuper(CodeGenFunction &CGF, llvm::MDNode *node = llvm::MDNode::get(VMContext, impMD); llvm::Instruction *call; - RValue msgRet = CGF.EmitCall(MSI.CallInfo, imp, Return, ActualArgs, 0, &call); + RValue msgRet = CGF.EmitCall(MSI.CallInfo, imp, Return, ActualArgs, nullptr, + &call); call->setMetadata(msgSendMDKind, node); return msgRet; } @@ -1325,7 +1330,7 @@ CGObjCGNU::GenerateMessageSend(CodeGenFunction &CGF, CGM.getTypes().ConvertType(ResultType))); } if (Sel == ReleaseSel) { - return RValue::get(0); + return RValue::get(nullptr); } } @@ -1343,9 +1348,9 @@ CGObjCGNU::GenerateMessageSend(CodeGenFunction &CGF, bool isPointerSizedReturn = (ResultType->isAnyPointerType() || ResultType->isIntegralOrEnumerationType() || ResultType->isVoidType()); - llvm::BasicBlock *startBB = 0; - llvm::BasicBlock *messageBB = 0; - llvm::BasicBlock *continueBB = 0; + llvm::BasicBlock *startBB = nullptr; + llvm::BasicBlock *messageBB = nullptr; + llvm::BasicBlock *continueBB = nullptr; if (!isPointerSizedReturn) { startBB = Builder.GetInsertBlock(); @@ -1370,7 +1375,8 @@ CGObjCGNU::GenerateMessageSend(CodeGenFunction &CGF, llvm::Value *impMD[] = { llvm::MDString::get(VMContext, Sel.getAsString()), llvm::MDString::get(VMContext, Class ? Class->getNameAsString() :""), - llvm::ConstantInt::get(llvm::Type::getInt1Ty(VMContext), Class!=0) + llvm::ConstantInt::get(llvm::Type::getInt1Ty(VMContext), + Class!=nullptr) }; llvm::MDNode *node = llvm::MDNode::get(VMContext, impMD); @@ -1413,7 +1419,8 @@ CGObjCGNU::GenerateMessageSend(CodeGenFunction &CGF, imp = EnforceType(Builder, imp, MSI.MessengerType); llvm::Instruction *call; - RValue msgRet = CGF.EmitCall(MSI.CallInfo, imp, Return, ActualArgs, 0, &call); + RValue msgRet = CGF.EmitCall(MSI.CallInfo, imp, Return, ActualArgs, nullptr, + &call); call->setMetadata(msgSendMDKind, node); @@ -1469,7 +1476,7 @@ GenerateMethodList(const StringRef &ClassName, PtrToInt8Ty, // Really a selector, but the runtime creates it us. PtrToInt8Ty, // Method types IMPTy, //Method pointer - NULL); + nullptr); std::vector Methods; std::vector Elements; for (unsigned int i = 0, e = MethodTypes.size(); i < e; ++i) { @@ -1501,7 +1508,7 @@ GenerateMethodList(const StringRef &ClassName, NextPtrTy, IntTy, ObjCMethodArrayTy, - NULL); + nullptr); Methods.clear(); Methods.push_back(llvm::ConstantPointerNull::get( @@ -1525,7 +1532,7 @@ GenerateIvarList(ArrayRef IvarNames, PtrToInt8Ty, PtrToInt8Ty, IntTy, - NULL); + nullptr); std::vector Ivars; std::vector Elements; for (unsigned int i = 0, e = IvarNames.size() ; i < e ; i++) { @@ -1547,7 +1554,7 @@ GenerateIvarList(ArrayRef IvarNames, // Structure containing array and array count llvm::StructType *ObjCIvarListTy = llvm::StructType::get(IntTy, ObjCIvarArrayTy, - NULL); + nullptr); // Create an instance of the structure return MakeGlobal(ObjCIvarListTy, Elements, ".objc_ivar_list"); @@ -1597,7 +1604,7 @@ llvm::Constant *CGObjCGNU::GenerateClassStructure( Properties->getType(), // properties IntPtrTy, // strong_pointers IntPtrTy, // weak_pointers - NULL); + nullptr); llvm::Constant *Zero = llvm::ConstantInt::get(LongTy, 0); // Fill in the structure std::vector Elements; @@ -1651,7 +1658,7 @@ GenerateProtocolMethodList(ArrayRef MethodNames, llvm::StructType *ObjCMethodDescTy = llvm::StructType::get( PtrToInt8Ty, // Really a selector, but the runtime does the casting for us. PtrToInt8Ty, - NULL); + nullptr); std::vector Methods; std::vector Elements; for (unsigned int i = 0, e = MethodTypes.size() ; i < e ; i++) { @@ -1665,7 +1672,7 @@ GenerateProtocolMethodList(ArrayRef MethodNames, llvm::Constant *Array = llvm::ConstantArray::get(ObjCMethodArrayTy, Methods); llvm::StructType *ObjCMethodDescListTy = llvm::StructType::get( - IntTy, ObjCMethodArrayTy, NULL); + IntTy, ObjCMethodArrayTy, nullptr); Methods.clear(); Methods.push_back(llvm::ConstantInt::get(IntTy, MethodNames.size())); Methods.push_back(Array); @@ -1680,11 +1687,11 @@ llvm::Constant *CGObjCGNU::GenerateProtocolList(ArrayRefProtocols){ PtrTy, //Should be a recurisve pointer, but it's always NULL here. SizeTy, ProtocolArrayTy, - NULL); + nullptr); std::vector Elements; for (const std::string *iter = Protocols.begin(), *endIter = Protocols.end(); iter != endIter ; iter++) { - llvm::Constant *protocol = 0; + llvm::Constant *protocol = nullptr; llvm::StringMap::iterator value = ExistingProtocols.find(*iter); if (value == ExistingProtocols.end()) { @@ -1730,7 +1737,7 @@ llvm::Constant *CGObjCGNU::GenerateEmptyProtocol( MethodList->getType(), MethodList->getType(), MethodList->getType(), - NULL); + nullptr); std::vector Elements; // The isa pointer must be set to a magic number so the runtime knows it's // the correct layout. @@ -1811,7 +1818,7 @@ void CGObjCGNU::GenerateProtocol(const ObjCProtocolDecl *PD) { // structures for protocol metadata everywhere. llvm::StructType *PropertyMetadataTy = llvm::StructType::get( PtrToInt8Ty, Int8Ty, Int8Ty, Int8Ty, Int8Ty, PtrToInt8Ty, - PtrToInt8Ty, PtrToInt8Ty, PtrToInt8Ty, NULL); + PtrToInt8Ty, PtrToInt8Ty, PtrToInt8Ty, nullptr); std::vector Properties; std::vector OptionalProperties; @@ -1820,7 +1827,7 @@ void CGObjCGNU::GenerateProtocol(const ObjCProtocolDecl *PD) { for (auto *property : PD->properties()) { std::vector Fields; - Fields.push_back(MakePropertyEncodingString(property, 0)); + Fields.push_back(MakePropertyEncodingString(property, nullptr)); PushPropertyAttributes(Fields, property); if (ObjCMethodDecl *getter = property->getGetterMethodDecl()) { @@ -1887,7 +1894,7 @@ void CGObjCGNU::GenerateProtocol(const ObjCProtocolDecl *PD) { OptionalClassMethodList->getType(), PropertyList->getType(), OptionalPropertyList->getType(), - NULL); + nullptr); std::vector Elements; // The isa pointer must be set to a magic number so the runtime knows it's // the correct layout. @@ -1928,7 +1935,7 @@ void CGObjCGNU::GenerateProtocolHolderCategory() { PtrTy, //Should be a recurisve pointer, but it's always NULL here. SizeTy, ProtocolArrayTy, - NULL); + nullptr); std::vector ProtocolElements; for (llvm::StringMapIterator iter = ExistingProtocols.begin(), endIter = ExistingProtocols.end(); @@ -1948,7 +1955,7 @@ void CGObjCGNU::GenerateProtocolHolderCategory() { ProtocolElements, ".objc_protocol_list"), PtrTy)); Categories.push_back(llvm::ConstantExpr::getBitCast( MakeGlobal(llvm::StructType::get(PtrToInt8Ty, PtrToInt8Ty, - PtrTy, PtrTy, PtrTy, NULL), Elements), PtrTy)); + PtrTy, PtrTy, PtrTy, nullptr), Elements), PtrTy)); } /// Libobjc2 uses a bitfield representation where small(ish) bitfields are @@ -1988,7 +1995,7 @@ llvm::Constant *CGObjCGNU::MakeBitField(ArrayRef bits) { llvm::ConstantInt::get(Int32Ty, values.size()), array }; llvm::Constant *GS = MakeGlobal(llvm::StructType::get(Int32Ty, arrayTy, - NULL), fields); + nullptr), fields); llvm::Constant *ptr = llvm::ConstantExpr::getPtrToInt(GS, IntPtrTy); return ptr; } @@ -2040,7 +2047,7 @@ void CGObjCGNU::GenerateCategory(const ObjCCategoryImplDecl *OCD) { GenerateProtocolList(Protocols), PtrTy)); Categories.push_back(llvm::ConstantExpr::getBitCast( MakeGlobal(llvm::StructType::get(PtrToInt8Ty, PtrToInt8Ty, - PtrTy, PtrTy, PtrTy, NULL), Elements), PtrTy)); + PtrTy, PtrTy, PtrTy, nullptr), Elements), PtrTy)); } llvm::Constant *CGObjCGNU::GeneratePropertyList(const ObjCImplementationDecl *OID, @@ -2051,7 +2058,7 @@ llvm::Constant *CGObjCGNU::GeneratePropertyList(const ObjCImplementationDecl *OI // setter name, setter types, getter name, getter types. llvm::StructType *PropertyMetadataTy = llvm::StructType::get( PtrToInt8Ty, Int8Ty, Int8Ty, Int8Ty, Int8Ty, PtrToInt8Ty, - PtrToInt8Ty, PtrToInt8Ty, PtrToInt8Ty, NULL); + PtrToInt8Ty, PtrToInt8Ty, PtrToInt8Ty, nullptr); std::vector Properties; // Add all of the property methods need adding to the method list and to the @@ -2278,7 +2285,7 @@ void CGObjCGNU::GenerateClass(const ObjCImplementationDecl *OID) { // the offset (third field in ivar structure) llvm::Type *IndexTy = Int32Ty; llvm::Constant *offsetPointerIndexes[] = {Zeros[0], - llvm::ConstantInt::get(IndexTy, 1), 0, + llvm::ConstantInt::get(IndexTy, 1), nullptr, llvm::ConstantInt::get(IndexTy, 2) }; unsigned ivarIndex = 0; @@ -2309,14 +2316,14 @@ void CGObjCGNU::GenerateClass(const ObjCImplementationDecl *OID) { llvm::Constant *ZeroPtr = llvm::ConstantInt::get(IntPtrTy, 0); //Generate metaclass for class methods llvm::Constant *MetaClassStruct = GenerateClassStructure(NULLPtr, - NULLPtr, 0x12L, ClassName.c_str(), 0, Zeros[0], GenerateIvarList( + NULLPtr, 0x12L, ClassName.c_str(), nullptr, Zeros[0], GenerateIvarList( empty, empty, empty), ClassMethodList, NULLPtr, NULLPtr, NULLPtr, ZeroPtr, ZeroPtr, true); // Generate the class structure llvm::Constant *ClassStruct = GenerateClassStructure(MetaClassStruct, SuperClass, 0x11L, - ClassName.c_str(), 0, + ClassName.c_str(), nullptr, llvm::ConstantInt::get(LongTy, instanceSize), IvarList, MethodList, GenerateProtocolList(Protocols), IvarOffsetArray, Properties, StrongIvarBitmap, WeakIvarBitmap); @@ -2326,13 +2333,13 @@ void CGObjCGNU::GenerateClass(const ObjCImplementationDecl *OID) { ClassPtrAlias->replaceAllUsesWith( llvm::ConstantExpr::getBitCast(ClassStruct, IdTy)); ClassPtrAlias->eraseFromParent(); - ClassPtrAlias = 0; + ClassPtrAlias = nullptr; } if (MetaClassPtrAlias) { MetaClassPtrAlias->replaceAllUsesWith( llvm::ConstantExpr::getBitCast(MetaClassStruct, IdTy)); MetaClassPtrAlias->eraseFromParent(); - MetaClassPtrAlias = 0; + MetaClassPtrAlias = nullptr; } // Add class structure to list to be added to the symtab later @@ -2345,7 +2352,7 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() { // Only emit an ObjC load function if no Objective-C stuff has been called if (Classes.empty() && Categories.empty() && ConstantStrings.empty() && ExistingProtocols.empty() && SelectorTable.empty()) - return NULL; + return nullptr; // Add all referenced protocols to a category. GenerateProtocolHolderCategory(); @@ -2353,8 +2360,8 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() { llvm::StructType *SelStructTy = dyn_cast( SelectorTy->getElementType()); llvm::Type *SelStructPtrTy = SelectorTy; - if (SelStructTy == 0) { - SelStructTy = llvm::StructType::get(PtrToInt8Ty, PtrToInt8Ty, NULL); + if (!SelStructTy) { + SelStructTy = llvm::StructType::get(PtrToInt8Ty, PtrToInt8Ty, nullptr); SelStructPtrTy = llvm::PointerType::getUnqual(SelStructTy); } @@ -2375,7 +2382,7 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() { Elements.push_back(llvm::ConstantArray::get(StaticsArrayTy, ConstantStrings)); llvm::StructType *StaticsListTy = - llvm::StructType::get(PtrToInt8Ty, StaticsArrayTy, NULL); + llvm::StructType::get(PtrToInt8Ty, StaticsArrayTy, nullptr); llvm::Type *StaticsListPtrTy = llvm::PointerType::getUnqual(StaticsListTy); Statics = MakeGlobal(StaticsListTy, Elements, ".objc_statics"); @@ -2393,7 +2400,7 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() { llvm::StructType *SymTabTy = llvm::StructType::get(LongTy, SelStructPtrTy, llvm::Type::getInt16Ty(VMContext), llvm::Type::getInt16Ty(VMContext), - ClassListTy, NULL); + ClassListTy, nullptr); Elements.clear(); // Pointer to an array of selectors used in this module. @@ -2474,7 +2481,7 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() { // constants llvm::StructType * ModuleTy = llvm::StructType::get(LongTy, LongTy, PtrToInt8Ty, llvm::PointerType::getUnqual(SymTabTy), - (RuntimeVersion >= 10) ? IntTy : NULL, NULL); + (RuntimeVersion >= 10) ? IntTy : nullptr, nullptr); Elements.clear(); // Runtime version, used for ABI compatibility checking. Elements.push_back(llvm::ConstantInt::get(LongTy, RuntimeVersion)); @@ -2555,7 +2562,7 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() { llvm::Constant *TheClass = TheModule.getGlobalVariable(("_OBJC_CLASS_" + iter->first).c_str(), true); - if (0 != TheClass) { + if (TheClass) { TheClass = llvm::ConstantExpr::getBitCast(TheClass, PtrTy); Builder.CreateCall2(RegisterAlias, TheClass, MakeConstantString(iter->second)); @@ -2605,7 +2612,7 @@ llvm::Constant *CGObjCGNU::GetPropertySetFunction() { llvm::Constant *CGObjCGNU::GetOptimizedPropertySetFunction(bool atomic, bool copy) { - return 0; + return nullptr; } llvm::Constant *CGObjCGNU::GetGetStructFunction() { @@ -2615,10 +2622,10 @@ llvm::Constant *CGObjCGNU::GetSetStructFunction() { return SetStructPropertyFn; } llvm::Constant *CGObjCGNU::GetCppAtomicObjectGetFunction() { - return 0; + return nullptr; } llvm::Constant *CGObjCGNU::GetCppAtomicObjectSetFunction() { - return 0; + return nullptr; } llvm::Constant *CGObjCGNU::EnumerationMutationFunction() { @@ -2766,7 +2773,7 @@ llvm::GlobalVariable *CGObjCGNU::ObjCIvarOffsetVariable( } else { IvarOffsetPointer = new llvm::GlobalVariable(TheModule, llvm::Type::getInt32PtrTy(VMContext), false, - llvm::GlobalValue::ExternalLinkage, 0, Name); + llvm::GlobalValue::ExternalLinkage, nullptr, Name); } } return IvarOffsetPointer; @@ -2796,7 +2803,7 @@ static const ObjCInterfaceDecl *FindIvarInterface(ASTContext &Context, if (const ObjCInterfaceDecl *Super = OID->getSuperClass()) return FindIvarInterface(Context, Super, OIVD); - return 0; + return nullptr; } llvm::Value *CGObjCGNU::EmitIvarOffset(CodeGenFunction &CGF, diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index 575884b661..7259d45594 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -1050,7 +1050,7 @@ public: llvm::Constant *GenerateConstantString(const StringLiteral *SL) override; llvm::Function *GenerateMethod(const ObjCMethodDecl *OMD, - const ObjCContainerDecl *CD=0) override; + const ObjCContainerDecl *CD=nullptr) override; void GenerateProtocol(const ObjCProtocolDecl *PD) override; @@ -1564,7 +1564,7 @@ public: /// value. struct NullReturnState { llvm::BasicBlock *NullBB; - NullReturnState() : NullBB(0) {} + NullReturnState() : NullBB(nullptr) {} /// Perform a null-check of the given receiver. void init(CodeGenFunction &CGF, llvm::Value *receiver) { @@ -1593,8 +1593,8 @@ struct NullReturnState { // The continuation block. This will be left null if we don't have an // IP, which can happen if the method we're calling is marked noreturn. - llvm::BasicBlock *contBB = 0; - + llvm::BasicBlock *contBB = nullptr; + // Finish the call path. llvm::BasicBlock *callBB = CGF.Builder.GetInsertBlock(); if (callBB) { @@ -1881,7 +1881,7 @@ CGObjCCommonMac::EmitMessageSend(CodeGen::CodeGenFunction &CGF, NullReturnState nullReturn; - llvm::Constant *Fn = NULL; + llvm::Constant *Fn = nullptr; if (CGM.ReturnSlotInterferesWithArgs(MSI.CallInfo)) { if (!IsSuper) nullReturn.init(CGF, Arg0); Fn = (ObjCABI == 2) ? ObjCTypes.getSendStretFn2(IsSuper) @@ -1915,7 +1915,7 @@ CGObjCCommonMac::EmitMessageSend(CodeGen::CodeGenFunction &CGF, Fn = llvm::ConstantExpr::getBitCast(Fn, MSI.MessengerType); RValue rvalue = CGF.EmitCall(MSI.CallInfo, Fn, Return, ActualArgs); return nullReturn.complete(CGF, rvalue, ResultType, CallArgs, - requiresnullCheck ? Method : 0); + requiresnullCheck ? Method : nullptr); } static Qualifiers::GC GetGCAttrTypeForType(ASTContext &Ctx, QualType FQT) { @@ -2069,8 +2069,8 @@ void CGObjCCommonMac::BuildRCRecordLayout(const llvm::StructLayout *RecLayout, bool ByrefLayout) { bool IsUnion = (RD && RD->isUnion()); CharUnits MaxUnionSize = CharUnits::Zero(); - const FieldDecl *MaxField = 0; - const FieldDecl *LastFieldBitfieldOrUnnamed = 0; + const FieldDecl *MaxField = nullptr; + const FieldDecl *LastFieldBitfieldOrUnnamed = nullptr; CharUnits MaxFieldOffset = CharUnits::Zero(); CharUnits LastBitfieldOrUnnamedOffset = CharUnits::Zero(); @@ -2092,8 +2092,8 @@ void CGObjCCommonMac::BuildRCRecordLayout(const llvm::StructLayout *RecLayout, LastBitfieldOrUnnamedOffset = FieldOffset; continue; } - - LastFieldBitfieldOrUnnamed = 0; + + LastFieldBitfieldOrUnnamed = nullptr; QualType FQT = Field->getType(); if (FQT->isRecordType() || FQT->isUnionType()) { if (FQT->isUnionType()) @@ -2672,7 +2672,7 @@ llvm::Constant *CGObjCMac::GetOrEmitProtocolRef(const ObjCProtocolDecl *PD) { Entry = new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ProtocolTy, false, llvm::GlobalValue::PrivateLinkage, - 0, + nullptr, "\01L_OBJC_PROTOCOL_" + PD->getName()); Entry->setSection("__OBJC,__protocol,regular,no_dead_strip"); // FIXME: Is this necessary? Why only for protocol? @@ -2708,8 +2708,8 @@ CGObjCMac::EmitProtocolExtension(const ObjCProtocolDecl *PD, EmitMethodDescList("\01L_OBJC_PROTOCOL_CLASS_METHODS_OPT_" + PD->getName(), "__OBJC,__cat_cls_meth,regular,no_dead_strip", OptClassMethods), - EmitPropertyList("\01L_OBJC_$_PROP_PROTO_LIST_" + PD->getName(), 0, PD, - ObjCTypes), + EmitPropertyList("\01L_OBJC_$_PROP_PROTO_LIST_" + PD->getName(), nullptr, + PD, ObjCTypes), EmitProtocolMethodTypes("\01L_OBJC_PROTOCOL_METHOD_TYPES_" + PD->getName(), MethodTypesExt, ObjCTypes) }; @@ -2725,7 +2725,7 @@ CGObjCMac::EmitProtocolExtension(const ObjCProtocolDecl *PD, // No special section, but goes in llvm.used return CreateMetadataVar("\01l_OBJC_PROTOCOLEXT_" + PD->getName(), Init, - 0, 0, true); + nullptr, 0, true); } /* @@ -2860,7 +2860,7 @@ CGObjCCommonMac::EmitProtocolMethodTypes(Twine Name, llvm::GlobalVariable *GV = CreateMetadataVar(Name, Init, - (ObjCABI == 2) ? "__DATA, __objc_const" : 0, + (ObjCABI == 2) ? "__DATA, __objc_const" : nullptr, (ObjCABI == 2) ? 8 : 4, true); return llvm::ConstantExpr::getBitCast(GV, ObjCTypes.Int8PtrPtrTy); @@ -2880,8 +2880,8 @@ CGObjCMac::GetMethodDescriptionConstant(const ObjCMethodDecl *MD) { GetMethodVarType(MD) }; if (!Desc[1]) - return 0; - + return nullptr; + return llvm::ConstantStruct::get(ObjCTypes.MethodDescriptionTy, Desc); } @@ -3211,7 +3211,8 @@ llvm::Constant *CGObjCMac::EmitMetaClassRef(const ObjCInterfaceDecl *ID) { llvm::GlobalVariable *GV = CGM.getModule().getGlobalVariable(Name, true); if (!GV) GV = new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ClassTy, false, - llvm::GlobalValue::PrivateLinkage, 0, Name); + llvm::GlobalValue::PrivateLinkage, nullptr, + Name); assert(GV->getType()->getElementType() == ObjCTypes.ClassTy && "Forward metaclass reference has incorrect type."); @@ -3225,7 +3226,8 @@ llvm::Value *CGObjCMac::EmitSuperClassRef(const ObjCInterfaceDecl *ID) { if (!GV) GV = new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ClassTy, false, - llvm::GlobalValue::PrivateLinkage, 0, Name); + llvm::GlobalValue::PrivateLinkage, nullptr, + Name); assert(GV->getType()->getElementType() == ObjCTypes.ClassTy && "Forward class metadata reference has incorrect type."); @@ -3345,7 +3347,7 @@ llvm::Constant *CGObjCMac::EmitIvarList(const ObjCImplementationDecl *ID, llvm::Constant *CGObjCMac::GetMethodConstant(const ObjCMethodDecl *MD) { llvm::Function *Fn = GetMethodDefinition(MD); if (!Fn) - return 0; + return nullptr; llvm::Constant *Method[] = { llvm::ConstantExpr::getBitCast(GetMethodVarName(MD->getSelector()), @@ -3416,7 +3418,7 @@ CGObjCCommonMac::CreateMetadataVar(Twine Name, llvm::Function *CGObjCMac::ModuleInitFunction() { // Abuse this interface function as a place to finalize. FinishModule(); - return NULL; + return nullptr; } llvm::Constant *CGObjCMac::GetPropertyGetFunction() { @@ -3799,7 +3801,7 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, // @synchronized. We can't avoid a temp here because we need the // value to be preserved. If the backend ever does liveness // correctly after setjmp, this will be unnecessary. - llvm::Value *SyncArgSlot = 0; + llvm::Value *SyncArgSlot = nullptr; if (!isTry) { llvm::Value *SyncArg = CGF.EmitScalarExpr(cast(S).getSynchExpr()); @@ -3834,7 +3836,7 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, // A slot containing the exception to rethrow. Only needed when we // have both a @catch and a @finally. - llvm::Value *PropagatingExnVar = 0; + llvm::Value *PropagatingExnVar = nullptr; // Push a normal cleanup to leave the try scope. CGF.EHStack.pushCleanup(NormalAndEHCleanup, &S, @@ -3900,10 +3902,10 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, const ObjCAtTryStmt* AtTryStmt = cast(&S); - bool HasFinally = (AtTryStmt->getFinallyStmt() != 0); + bool HasFinally = (AtTryStmt->getFinallyStmt() != nullptr); - llvm::BasicBlock *CatchBlock = 0; - llvm::BasicBlock *CatchHandler = 0; + llvm::BasicBlock *CatchBlock = nullptr; + llvm::BasicBlock *CatchHandler = nullptr; if (HasFinally) { // Save the currently-propagating exception before // objc_exception_try_enter clears the exception slot. @@ -3941,7 +3943,7 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, const ObjCAtCatchStmt *CatchStmt = AtTryStmt->getCatchStmt(I); const VarDecl *CatchParam = CatchStmt->getCatchParamDecl(); - const ObjCObjectPointerType *OPT = 0; + const ObjCObjectPointerType *OPT = nullptr; // catch(...) always matches. if (!CatchParam) { @@ -4472,7 +4474,7 @@ llvm::Function *CGObjCCommonMac::GetMethodDefinition(const ObjCMethodDecl *MD) { if (I != MethodDefinitions.end()) return I->second; - return NULL; + return nullptr; } /// GetIvarLayoutName - Returns a unique constant for the given @@ -4493,8 +4495,8 @@ void CGObjCCommonMac::BuildAggrIvarRecordLayout(const RecordType *RT, const llvm::StructLayout *RecLayout = CGM.getDataLayout().getStructLayout(cast(Ty)); - BuildAggrIvarLayout(0, RecLayout, RD, Fields, BytePos, - ForStrongLayout, HasUnion); + BuildAggrIvarLayout(nullptr, RecLayout, RD, Fields, BytePos, ForStrongLayout, + HasUnion); } void CGObjCCommonMac::BuildAggrIvarLayout(const ObjCImplementationDecl *OI, @@ -4506,9 +4508,9 @@ void CGObjCCommonMac::BuildAggrIvarLayout(const ObjCImplementationDecl *OI, bool IsUnion = (RD && RD->isUnion()); uint64_t MaxUnionIvarSize = 0; uint64_t MaxSkippedUnionIvarSize = 0; - const FieldDecl *MaxField = 0; - const FieldDecl *MaxSkippedField = 0; - const FieldDecl *LastFieldBitfieldOrUnnamed = 0; + const FieldDecl *MaxField = nullptr; + const FieldDecl *MaxSkippedField = nullptr; + const FieldDecl *LastFieldBitfieldOrUnnamed = nullptr; uint64_t MaxFieldOffset = 0; uint64_t MaxSkippedFieldOffset = 0; uint64_t LastBitfieldOrUnnamedOffset = 0; @@ -4543,7 +4545,7 @@ void CGObjCCommonMac::BuildAggrIvarLayout(const ObjCImplementationDecl *OI, continue; } - LastFieldBitfieldOrUnnamed = 0; + LastFieldBitfieldOrUnnamed = nullptr; QualType FQT = Field->getType(); if (FQT->isRecordType() || FQT->isUnionType()) { if (FQT->isUnionType()) @@ -4834,7 +4836,8 @@ llvm::Constant *CGObjCCommonMac::BuildIvarLayout( SkipIvars.clear(); IvarsInfo.clear(); - BuildAggrIvarLayout(OMD, 0, 0, RecFields, 0, ForStrongLayout, hasUnion); + BuildAggrIvarLayout(OMD, nullptr, nullptr, RecFields, 0, ForStrongLayout, + hasUnion); if (IvarsInfo.empty()) return llvm::Constant::getNullValue(PtrTy); // Sort on byte position in case we encounterred a union nested in @@ -4903,7 +4906,7 @@ llvm::Constant *CGObjCCommonMac::GetMethodVarType(const ObjCMethodDecl *D, bool Extended) { std::string TypeStr; if (CGM.getContext().getObjCEncodingForMethodDecl(D, TypeStr, Extended)) - return 0; + return nullptr; llvm::GlobalVariable *&Entry = MethodVarTypes[TypeStr]; @@ -5010,14 +5013,14 @@ void CGObjCMac::FinishModule() { CGObjCNonFragileABIMac::CGObjCNonFragileABIMac(CodeGen::CodeGenModule &cgm) : CGObjCCommonMac(cgm), ObjCTypes(cgm) { - ObjCEmptyCacheVar = ObjCEmptyVtableVar = NULL; + ObjCEmptyCacheVar = ObjCEmptyVtableVar = nullptr; ObjCABI = 2; } /* *** */ ObjCCommonTypesHelper::ObjCCommonTypesHelper(CodeGen::CodeGenModule &cgm) - : VMContext(cgm.getLLVMContext()), CGM(cgm), ExternalProtocolPtrTy(0) + : VMContext(cgm.getLLVMContext()), CGM(cgm), ExternalProtocolPtrTy(nullptr) { CodeGen::CodeGenTypes &Types = CGM.getTypes(); ASTContext &Ctx = CGM.getContext(); @@ -5056,11 +5059,12 @@ ObjCCommonTypesHelper::ObjCCommonTypesHelper(CodeGen::CodeGenModule &cgm) Ctx.getTranslationUnitDecl(), SourceLocation(), SourceLocation(), &Ctx.Idents.get("_objc_super")); - RD->addDecl(FieldDecl::Create(Ctx, RD, SourceLocation(), SourceLocation(), 0, - Ctx.getObjCIdType(), 0, 0, false, ICIS_NoInit)); - RD->addDecl(FieldDecl::Create(Ctx, RD, SourceLocation(), SourceLocation(), 0, - Ctx.getObjCClassType(), 0, 0, false, - ICIS_NoInit)); + RD->addDecl(FieldDecl::Create(Ctx, RD, SourceLocation(), SourceLocation(), + nullptr, Ctx.getObjCIdType(), nullptr, nullptr, + false, ICIS_NoInit)); + RD->addDecl(FieldDecl::Create(Ctx, RD, SourceLocation(), SourceLocation(), + nullptr, Ctx.getObjCClassType(), nullptr, + nullptr, false, ICIS_NoInit)); RD->completeDefinition(); SuperCTy = Ctx.getTagDeclType(RD); @@ -5437,11 +5441,12 @@ ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModul Ctx.getTranslationUnitDecl(), SourceLocation(), SourceLocation(), &Ctx.Idents.get("_message_ref_t")); - RD->addDecl(FieldDecl::Create(Ctx, RD, SourceLocation(), SourceLocation(), 0, - Ctx.VoidPtrTy, 0, 0, false, ICIS_NoInit)); - RD->addDecl(FieldDecl::Create(Ctx, RD, SourceLocation(), SourceLocation(), 0, - Ctx.getObjCSelType(), 0, 0, false, + RD->addDecl(FieldDecl::Create(Ctx, RD, SourceLocation(), SourceLocation(), + nullptr, Ctx.VoidPtrTy, nullptr, nullptr, false, ICIS_NoInit)); + RD->addDecl(FieldDecl::Create(Ctx, RD, SourceLocation(), SourceLocation(), + nullptr, Ctx.getObjCSelType(), nullptr, nullptr, + false, ICIS_NoInit)); RD->completeDefinition(); MessageRefCTy = Ctx.getTagDeclType(RD); @@ -5479,7 +5484,7 @@ ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModul llvm::Function *CGObjCNonFragileABIMac::ModuleInitFunction() { FinishNonFragileABIModule(); - return NULL; + return nullptr; } void CGObjCNonFragileABIMac:: @@ -5639,7 +5644,7 @@ llvm::GlobalVariable * CGObjCNonFragileABIMac::BuildClassRoTInitializer( Values[ 2] = llvm::ConstantInt::get(ObjCTypes.IntTy, InstanceSize); // FIXME. For 64bit targets add 0 here. Values[ 3] = (flags & NonFragileABI_Class_Meta) - ? GetIvarLayoutName(0, ObjCTypes) + ? GetIvarLayoutName(nullptr, ObjCTypes) : BuildIvarLayout(ID, true); Values[ 4] = GetClassName(ID->getIdentifier()); // const struct _method_list_t * const baseMethods; @@ -5681,7 +5686,7 @@ llvm::GlobalVariable * CGObjCNonFragileABIMac::BuildClassRoTInitializer( if (flags & NonFragileABI_Class_Meta) { Values[ 7] = llvm::Constant::getNullValue(ObjCTypes.IvarListnfABIPtrTy); - Values[ 8] = GetIvarLayoutName(0, ObjCTypes); + Values[ 8] = GetIvarLayoutName(nullptr, ObjCTypes); Values[ 9] = llvm::Constant::getNullValue(ObjCTypes.PropertyListPtrTy); } else { Values[ 7] = EmitIvarList(ID); @@ -5745,7 +5750,7 @@ llvm::GlobalVariable *CGObjCNonFragileABIMac::BuildClassMetaData( bool CGObjCNonFragileABIMac::ImplementationIsNonLazy(const ObjCImplDecl *OD) const { - return OD->getClassMethod(GetNullarySelector("load")) != 0; + return OD->getClassMethod(GetNullarySelector("load")) != nullptr; } void CGObjCNonFragileABIMac::GetClassSizeInfo(const ObjCImplementationDecl *OID, @@ -5772,22 +5777,22 @@ void CGObjCNonFragileABIMac::GenerateClass(const ObjCImplementationDecl *ID) { ObjCTypes.CacheTy, false, llvm::GlobalValue::ExternalLinkage, - 0, + nullptr, "_objc_empty_cache"); - + // Make this entry NULL for any iOS device target, any iOS simulator target, // OS X with deployment target 10.9 or later. const llvm::Triple &Triple = CGM.getTarget().getTriple(); if (Triple.isiOS() || (Triple.isMacOSX() && !Triple.isMacOSXVersionLT(10, 9))) // This entry will be null. - ObjCEmptyVtableVar = 0; + ObjCEmptyVtableVar = nullptr; else ObjCEmptyVtableVar = new llvm::GlobalVariable( CGM.getModule(), ObjCTypes.ImpnfABITy, false, llvm::GlobalValue::ExternalLinkage, - 0, + nullptr, "_objc_empty_vtable"); } assert(ID->getClassInterface() && @@ -5875,7 +5880,7 @@ void CGObjCNonFragileABIMac::GenerateClass(const ObjCImplementationDecl *ID) { if (!ID->getClassInterface()->getSuperClass()) { flags |= NonFragileABI_Class_Root; - SuperClassGV = 0; + SuperClassGV = nullptr; } else { // Has a root. Current class is not a root. std::string RootClassName = @@ -6042,7 +6047,7 @@ llvm::Constant *CGObjCNonFragileABIMac::GetMethodConstant( const ObjCMethodDecl *MD) { llvm::Function *Fn = GetMethodDefinition(MD); if (!Fn) - return 0; + return nullptr; llvm::Constant *Method[] = { llvm::ConstantExpr::getBitCast(GetMethodVarName(MD->getSelector()), @@ -6102,7 +6107,7 @@ CGObjCNonFragileABIMac::ObjCIvarOffsetVariable(const ObjCInterfaceDecl *ID, if (!IvarOffsetGV) IvarOffsetGV = new llvm::GlobalVariable( CGM.getModule(), ObjCTypes.IvarOffsetVarTy, false, - llvm::GlobalValue::ExternalLinkage, 0, Name); + llvm::GlobalValue::ExternalLinkage, nullptr, Name); return IvarOffsetGV; } @@ -6217,7 +6222,8 @@ llvm::Constant *CGObjCNonFragileABIMac::GetOrEmitProtocolRef( // contents for protocols which were referenced but never defined. Entry = new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ProtocolnfABITy, - false, llvm::GlobalValue::WeakAnyLinkage, 0, + false, llvm::GlobalValue::WeakAnyLinkage, + nullptr, "\01l_OBJC_PROTOCOL_$_" + PD->getName()); Entry->setSection("__DATA,__datacoal_nt,coalesced"); } @@ -6315,7 +6321,7 @@ llvm::Constant *CGObjCNonFragileABIMac::GetOrEmitProtocol( "__DATA, __objc_const", OptClassMethods); Values[7] = EmitPropertyList("\01l_OBJC_$_PROP_LIST_" + PD->getName(), - 0, PD, ObjCTypes); + nullptr, PD, ObjCTypes); uint32_t Size = CGM.getDataLayout().getTypeAllocSize(ObjCTypes.ProtocolnfABITy); Values[8] = llvm::ConstantInt::get(ObjCTypes.IntTy, Size); @@ -6427,8 +6433,8 @@ CGObjCNonFragileABIMac::GetMethodDescriptionConstant(const ObjCMethodDecl *MD) { ObjCTypes.SelectorPtrTy); Desc[1] = GetMethodVarType(MD); if (!Desc[1]) - return 0; - + return nullptr; + // Protocol methods have no implementation. So, this entry is always NULL. Desc[2] = llvm::Constant::getNullValue(ObjCTypes.Int8PtrTy); return llvm::ConstantStruct::get(ObjCTypes.MethodTy, Desc); @@ -6515,7 +6521,7 @@ CGObjCNonFragileABIMac::EmitVTableMessageSend(CodeGenFunction &CGF, // Second argument: a pointer to the message ref structure. Leave // the actual argument value blank for now. - args.add(RValue::get(0), ObjCTypes.MessageRefCPtrTy); + args.add(RValue::get(nullptr), ObjCTypes.MessageRefCPtrTy); args.insert(args.end(), formalArgs.begin(), formalArgs.end()); @@ -6530,7 +6536,7 @@ CGObjCNonFragileABIMac::EmitVTableMessageSend(CodeGenFunction &CGF, // The runtime currently never uses vtable dispatch for anything // except normal, non-super message-sends. // FIXME: don't use this for that. - llvm::Constant *fn = 0; + llvm::Constant *fn = nullptr; std::string messageRefName("\01l_"); if (CGM.ReturnSlotInterferesWithArgs(MSI.CallInfo)) { if (isSuper) { @@ -6601,8 +6607,8 @@ CGObjCNonFragileABIMac::EmitVTableMessageSend(CodeGenFunction &CGF, callee = CGF.Builder.CreateBitCast(callee, MSI.MessengerType); RValue result = CGF.EmitCall(MSI.CallInfo, callee, returnSlot, args); - return nullReturn.complete(CGF, result, resultType, formalArgs, - requiresnullCheck ? method : 0); + return nullReturn.complete(CGF, result, resultType, formalArgs, + requiresnullCheck ? method : nullptr); } /// Generate code for a message send expression in the nonfragile abi. @@ -6635,7 +6641,7 @@ CGObjCNonFragileABIMac::GetClassGlobal(const std::string &Name, bool Weak) { if (!GV) GV = new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ClassnfABITy, - false, L, 0, Name); + false, L, nullptr, Name); assert(GV->getLinkage() == L); return GV; @@ -6950,7 +6956,7 @@ CGObjCNonFragileABIMac::GetEHType(QualType T) { new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.EHTypeTy, false, llvm::GlobalValue::ExternalLinkage, - 0, "OBJC_EHTYPE_id"); + nullptr, "OBJC_EHTYPE_id"); return IDEHType; } @@ -7007,7 +7013,7 @@ CGObjCNonFragileABIMac::GetInterfaceEHType(const ObjCInterfaceDecl *ID, return Entry = new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.EHTypeTy, false, llvm::GlobalValue::ExternalLinkage, - 0, + nullptr, ("OBJC_EHTYPE_$_" + ID->getIdentifier()->getName())); } @@ -7023,7 +7029,7 @@ CGObjCNonFragileABIMac::GetInterfaceEHType(const ObjCInterfaceDecl *ID, VTableGV = new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.Int8PtrTy, false, llvm::GlobalValue::ExternalLinkage, - 0, VTableName); + nullptr, VTableName); llvm::Value *VTableIdx = llvm::ConstantInt::get(CGM.Int32Ty, 2); diff --git a/lib/CodeGen/CGObjCRuntime.cpp b/lib/CodeGen/CGObjCRuntime.cpp index 8d6c653015..1a5db9b141 100644 --- a/lib/CodeGen/CGObjCRuntime.cpp +++ b/lib/CodeGen/CGObjCRuntime.cpp @@ -65,7 +65,7 @@ static uint64_t LookupFieldBitOffset(CodeGen::CodeGenModule &CGM, uint64_t CGObjCRuntime::ComputeIvarBaseOffset(CodeGen::CodeGenModule &CGM, const ObjCInterfaceDecl *OID, const ObjCIvarDecl *Ivar) { - return LookupFieldBitOffset(CGM, OID, 0, Ivar) / + return LookupFieldBitOffset(CGM, OID, nullptr, Ivar) / CGM.getContext().getCharWidth(); } @@ -116,7 +116,7 @@ LValue CGObjCRuntime::EmitValueForIvarAtOffset(CodeGen::CodeGenFunction &CGF, // Note, there is a subtle invariant here: we can only call this routine on // non-synthesized ivars but we may be called for synthesized ivars. However, // a synthesized ivar can never be a bit-field, so this is safe. - uint64_t FieldBitOffset = LookupFieldBitOffset(CGF.CGM, OID, 0, Ivar); + uint64_t FieldBitOffset = LookupFieldBitOffset(CGF.CGM, OID, nullptr, Ivar); uint64_t BitOffset = FieldBitOffset % CGF.CGM.getContext().getCharWidth(); uint64_t AlignmentBits = CGF.CGM.getTarget().getCharAlign(); uint64_t BitFieldSize = Ivar->getBitWidthValue(CGF.getContext()); @@ -201,7 +201,7 @@ void CGObjCRuntime::EmitTryCatchStmt(CodeGenFunction &CGF, // @catch(...) always matches. if (!CatchDecl) { - Handler.TypeInfo = 0; // catch-all + Handler.TypeInfo = nullptr; // catch-all // Don't consider any other catches. break; } @@ -242,7 +242,7 @@ void CGObjCRuntime::EmitTryCatchStmt(CodeGenFunction &CGF, if (endCatchFn) { // Add a cleanup to leave the catch. - bool EndCatchMightThrow = (Handler.Variable == 0); + bool EndCatchMightThrow = (Handler.Variable == nullptr); CGF.EHStack.pushCleanup(NormalAndEHCleanup, EndCatchMightThrow, diff --git a/lib/CodeGen/CGObjCRuntime.h b/lib/CodeGen/CGObjCRuntime.h index 2a8ae90265..fc6bee3fab 100644 --- a/lib/CodeGen/CGObjCRuntime.h +++ b/lib/CodeGen/CGObjCRuntime.h @@ -156,8 +156,8 @@ public: Selector Sel, llvm::Value *Receiver, const CallArgList &CallArgs, - const ObjCInterfaceDecl *Class = 0, - const ObjCMethodDecl *Method = 0) = 0; + const ObjCInterfaceDecl *Class = nullptr, + const ObjCMethodDecl *Method = nullptr) = 0; /// Generate an Objective-C message send operation to the super /// class initiated in a method for Class and with the given Self @@ -175,7 +175,7 @@ public: llvm::Value *Self, bool IsClassMessage, const CallArgList &CallArgs, - const ObjCMethodDecl *Method = 0) = 0; + const ObjCMethodDecl *Method = nullptr) = 0; /// Emit the code to return the named protocol as an object, as in a /// \@protocol expression. diff --git a/lib/CodeGen/CGOpenCLRuntime.cpp b/lib/CodeGen/CGOpenCLRuntime.cpp index 6e1a3c975d..079ef7234d 100644 --- a/lib/CodeGen/CGOpenCLRuntime.cpp +++ b/lib/CodeGen/CGOpenCLRuntime.cpp @@ -39,7 +39,7 @@ llvm::Type *CGOpenCLRuntime::convertOpenCLSpecificType(const Type *T) { switch (cast(T)->getKind()) { default: llvm_unreachable("Unexpected opencl builtin type!"); - return 0; + return nullptr; case BuiltinType::OCLImage1d: return llvm::PointerType::get(llvm::StructType::create( Ctx, "opencl.image1d_t"), ImgAddrSpc); diff --git a/lib/CodeGen/CGRTTI.cpp b/lib/CodeGen/CGRTTI.cpp index 1642548ca9..e6f9a57a09 100644 --- a/lib/CodeGen/CGRTTI.cpp +++ b/lib/CodeGen/CGRTTI.cpp @@ -147,7 +147,8 @@ llvm::Constant *RTTIBuilder::GetAddrOfExternalRTTIDescriptor(QualType Ty) { // Create a new global variable. GV = new llvm::GlobalVariable(CGM.getModule(), CGM.Int8PtrTy, /*Constant=*/true, - llvm::GlobalValue::ExternalLinkage, 0, Name); + llvm::GlobalValue::ExternalLinkage, nullptr, + Name); } return llvm::ConstantExpr::getBitCast(GV, CGM.Int8PtrTy); @@ -398,7 +399,7 @@ void RTTIBuilder::BuildVTablePointer(const Type *Ty) { static const char * const VMIClassTypeInfo = "_ZTVN10__cxxabiv121__vmi_class_type_infoE"; - const char *VTableName = 0; + const char *VTableName = nullptr; switch (Ty->getTypeClass()) { #define TYPE(Class, Base) diff --git a/lib/CodeGen/CGRecordLayoutBuilder.cpp b/lib/CodeGen/CGRecordLayoutBuilder.cpp index eb2d524ef7..a10d8e791b 100644 --- a/lib/CodeGen/CGRecordLayoutBuilder.cpp +++ b/lib/CodeGen/CGRecordLayoutBuilder.cpp @@ -84,7 +84,7 @@ struct CGRecordLowering { const CXXRecordDecl *RD; }; MemberInfo(CharUnits Offset, InfoKind Kind, llvm::Type *Data, - const FieldDecl *FD = 0) + const FieldDecl *FD = nullptr) : Offset(Offset), Kind(Kind), Data(Data), FD(FD) {} MemberInfo(CharUnits Offset, InfoKind Kind, llvm::Type *Data, const CXXRecordDecl *RD) @@ -278,7 +278,7 @@ void CGRecordLowering::lower(bool NVBaseType) { void CGRecordLowering::lowerUnion() { CharUnits LayoutSize = Layout.getSize(); - llvm::Type *StorageType = 0; + llvm::Type *StorageType = nullptr; // Compute zero-initializable status. if (!D->field_empty() && !isZeroInitializable(*D->field_begin())) IsZeroInitializable = IsZeroInitializableAsBase = false; @@ -373,7 +373,7 @@ CGRecordLowering::accumulateBitFields(RecordDecl::field_iterator Field, // Bitfields get the offset of their storage but come afterward and remain // there after a stable sort. Members.push_back(MemberInfo(bitsToCharUnits(StartBitOffset), - MemberInfo::Field, 0, *Field)); + MemberInfo::Field, nullptr, *Field)); } return; } @@ -407,7 +407,7 @@ CGRecordLowering::accumulateBitFields(RecordDecl::field_iterator Field, Members.push_back(StorageInfo(bitsToCharUnits(StartBitOffset), Type)); for (; Run != Field; ++Run) Members.push_back(MemberInfo(bitsToCharUnits(StartBitOffset), - MemberInfo::Field, 0, *Run)); + MemberInfo::Field, nullptr, *Run)); Run = FieldEnd; } } @@ -458,7 +458,8 @@ void CGRecordLowering::accumulateVBases() { ScissorOffset = std::min(ScissorOffset, Layout.getVBaseClassOffset(BaseDecl)); } - Members.push_back(MemberInfo(ScissorOffset, MemberInfo::Scissor, 0, RD)); + Members.push_back(MemberInfo(ScissorOffset, MemberInfo::Scissor, nullptr, + RD)); for (const auto &Base : RD->vbases()) { const CXXRecordDecl *BaseDecl = Base.getType()->getAsCXXRecordDecl(); if (BaseDecl->isEmpty()) @@ -468,7 +469,8 @@ void CGRecordLowering::accumulateVBases() { // get its own storage location but instead lives inside of that base. if (!useMSABI() && Context.isNearlyEmpty(BaseDecl) && !hasOwnStorage(RD, BaseDecl)) { - Members.push_back(MemberInfo(Offset, MemberInfo::VBase, 0, BaseDecl)); + Members.push_back(MemberInfo(Offset, MemberInfo::VBase, nullptr, + BaseDecl)); continue; } // If we've got a vtordisp, add it as a storage type. @@ -644,7 +646,7 @@ CGRecordLayout *CodeGenTypes::ComputeRecordLayout(const RecordDecl *D, Builder.lower(false); // If we're in C++, compute the base subobject type. - llvm::StructType *BaseTy = 0; + llvm::StructType *BaseTy = nullptr; if (isa(D) && !D->isUnion() && !D->hasAttr()) { BaseTy = Ty; if (Builder.Layout.getNonVirtualSize() != Builder.Layout.getSize()) { diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp index 4414230016..d30781f22f 100644 --- a/lib/CodeGen/CGStmt.cpp +++ b/lib/CodeGen/CGStmt.cpp @@ -221,7 +221,7 @@ CodeGenFunction::EmitCompoundStmtWithoutScope(const CompoundStmt &S, E = S.body_end()-GetLast; I != E; ++I) EmitStmt(*I); - llvm::Value *RetAlloca = 0; + llvm::Value *RetAlloca = nullptr; if (GetLast) { // We have to special case labels here. They are statements, but when put // at the end of a statement expression, they yield the value of their @@ -850,7 +850,7 @@ void CodeGenFunction::EmitReturnStmt(const ReturnStmt &S) { // for side effects. if (RV) EmitAnyExpr(RV); - } else if (RV == 0) { + } else if (!RV) { // Do nothing (return value is left uninitialized) } else if (FnRetTy->isReferenceType()) { // If this function returns a reference, take the address of the expression @@ -880,7 +880,7 @@ void CodeGenFunction::EmitReturnStmt(const ReturnStmt &S) { } ++NumReturnExprs; - if (RV == 0 || RV->isEvaluatable(getContext())) + if (!RV || RV->isEvaluatable(getContext())) ++NumSimpleReturnExprs; cleanupScope.ForceCleanup(); @@ -984,7 +984,7 @@ void CodeGenFunction::EmitCaseStmtRange(const CaseStmt &S) { llvm::Value *Cond = Builder.CreateICmpULE(Diff, Builder.getInt(Range), "inbounds"); - llvm::MDNode *Weights = 0; + llvm::MDNode *Weights = nullptr; if (SwitchWeights) { uint64_t ThisCount = CaseCnt.getCount(); uint64_t DefaultCount = (*SwitchWeights)[0]; @@ -1068,7 +1068,7 @@ void CodeGenFunction::EmitCaseStmt(const CaseStmt &S) { const CaseStmt *NextCase = dyn_cast(S.getSubStmt()); // Otherwise, iteratively add consecutive cases to this switch stmt. - while (NextCase && NextCase->getRHS() == 0) { + while (NextCase && NextCase->getRHS() == nullptr) { CurCase = NextCase; llvm::ConstantInt *CaseVal = Builder.getInt(CurCase->getLHS()->EvaluateKnownConstInt(getContext())); @@ -1129,7 +1129,7 @@ static CSFC_Result CollectStatementsForCase(const Stmt *S, bool &FoundCase, SmallVectorImpl &ResultStmts) { // If this is a null statement, just succeed. - if (S == 0) + if (!S) return Case ? CSFC_Success : CSFC_FallThrough; // If this is the switchcase (case 4: or default) that we're looking for, then @@ -1137,7 +1137,7 @@ static CSFC_Result CollectStatementsForCase(const Stmt *S, if (const SwitchCase *SC = dyn_cast(S)) { if (S == Case) { FoundCase = true; - return CollectStatementsForCase(SC->getSubStmt(), 0, FoundCase, + return CollectStatementsForCase(SC->getSubStmt(), nullptr, FoundCase, ResultStmts); } @@ -1148,7 +1148,7 @@ static CSFC_Result CollectStatementsForCase(const Stmt *S, // If we are in the live part of the code and we found our break statement, // return a success! - if (Case == 0 && isa(S)) + if (!Case && isa(S)) return CSFC_Success; // If this is a switch statement, then it might contain the SwitchCase, the @@ -1193,7 +1193,7 @@ static CSFC_Result CollectStatementsForCase(const Stmt *S, // statements in the compound statement as candidates for inclusion. assert(FoundCase && "Didn't find case but returned fallthrough?"); // We recursively found Case, so we're not looking for it anymore. - Case = 0; + Case = nullptr; // If we found the case and skipped declarations, we can't do the // optimization. @@ -1207,7 +1207,7 @@ static CSFC_Result CollectStatementsForCase(const Stmt *S, // If we have statements in our range, then we know that the statements are // live and need to be added to the set of statements we're tracking. for (; I != E; ++I) { - switch (CollectStatementsForCase(*I, 0, FoundCase, ResultStmts)) { + switch (CollectStatementsForCase(*I, nullptr, FoundCase, ResultStmts)) { case CSFC_Failure: return CSFC_Failure; case CSFC_FallThrough: // A fallthrough result means that the statement was simple and just @@ -1258,7 +1258,7 @@ static bool FindCaseStatementsForValue(const SwitchStmt &S, // First step, find the switch case that is being branched to. We can do this // efficiently by scanning the SwitchCase list. const SwitchCase *Case = S.getSwitchCaseList(); - const DefaultStmt *DefaultCase = 0; + const DefaultStmt *DefaultCase = nullptr; for (; Case; Case = Case->getNextSwitchCase()) { // It's either a default or case. Just remember the default statement in @@ -1280,10 +1280,10 @@ static bool FindCaseStatementsForValue(const SwitchStmt &S, // If we didn't find a matching case, we use a default if it exists, or we // elide the whole switch body! - if (Case == 0) { + if (!Case) { // It is safe to elide the body of the switch if it doesn't contain labels // etc. If it is safe, return successfully with an empty ResultStmts list. - if (DefaultCase == 0) + if (!DefaultCase) return !CodeGenFunction::ContainsLabel(&S); Case = DefaultCase; } @@ -1314,7 +1314,7 @@ void CodeGenFunction::EmitSwitchStmt(const SwitchStmt &S) { llvm::APSInt ConstantCondValue; if (ConstantFoldsToSimpleInteger(S.getCond(), ConstantCondValue)) { SmallVector CaseStmts; - const SwitchCase *Case = 0; + const SwitchCase *Case = nullptr; if (FindCaseStatementsForValue(S, ConstantCondValue, CaseStmts, getContext(), Case)) { if (Case) { @@ -1331,7 +1331,7 @@ void CodeGenFunction::EmitSwitchStmt(const SwitchStmt &S) { // At this point, we are no longer "within" a switch instance, so // we can temporarily enforce this to ensure that any embedded case // statements are not emitted. - SwitchInsn = 0; + SwitchInsn = nullptr; // Okay, we can dead code eliminate everything except this case. Emit the // specified series of statements and we're good. @@ -1437,7 +1437,7 @@ void CodeGenFunction::EmitSwitchStmt(const SwitchStmt &S) { static std::string SimplifyConstraint(const char *Constraint, const TargetInfo &Target, - SmallVectorImpl *OutCons=0) { + SmallVectorImpl *OutCons=nullptr) { std::string Result; while (*Constraint) { diff --git a/lib/CodeGen/CGVTables.cpp b/lib/CodeGen/CGVTables.cpp index 14cad8bc11..d10db5a683 100644 --- a/lib/CodeGen/CGVTables.cpp +++ b/lib/CodeGen/CGVTables.cpp @@ -71,11 +71,11 @@ static RValue PerformReturnAdjustment(CodeGenFunction &CGF, const ThunkInfo &Thunk) { // Emit the return adjustment. bool NullCheckValue = !ResultType->isReferenceType(); - - llvm::BasicBlock *AdjustNull = 0; - llvm::BasicBlock *AdjustNotNull = 0; - llvm::BasicBlock *AdjustEnd = 0; - + + llvm::BasicBlock *AdjustNull = nullptr; + llvm::BasicBlock *AdjustNotNull = nullptr; + llvm::BasicBlock *AdjustEnd = nullptr; + llvm::Value *ReturnValue = RV.getScalarVal(); if (NullCheckValue) { @@ -159,7 +159,7 @@ void CodeGenFunction::GenerateVarArgsThunk( // with "this". llvm::Value *ThisPtr = &*AI; llvm::BasicBlock *EntryBB = Fn->begin(); - llvm::Instruction *ThisStore = 0; + llvm::Instruction *ThisStore = nullptr; for (llvm::BasicBlock::iterator I = EntryBB->begin(), E = EntryBB->end(); I != E; I++) { if (isa(I) && I->getOperand(0) == ThisPtr) { @@ -446,13 +446,13 @@ CodeGenVTables::CreateVTableInitializer(const CXXRecordDecl *RD, llvm::Constant *RTTI = CGM.GetAddrOfRTTIDescriptor(ClassType); unsigned NextVTableThunkIndex = 0; - - llvm::Constant *PureVirtualFn = 0, *DeletedVirtualFn = 0; + + llvm::Constant *PureVirtualFn = nullptr, *DeletedVirtualFn = nullptr; for (unsigned I = 0; I != NumComponents; ++I) { VTableComponent Component = Components[I]; - llvm::Constant *Init = 0; + llvm::Constant *Init = nullptr; switch (Component.getKind()) { case VTableComponent::CK_VCallOffset: @@ -617,7 +617,7 @@ CodeGenModule::getVTableLinkage(const CXXRecordDecl *RD) { if (const CXXMethodDecl *keyFunction = Context.getCurrentKeyFunction(RD)) { // If this class has a key function, use that to determine the // linkage of the vtable. - const FunctionDecl *def = 0; + const FunctionDecl *def = nullptr; if (keyFunction->hasBody(def)) keyFunction = cast(def); diff --git a/lib/CodeGen/CGValue.h b/lib/CodeGen/CGValue.h index 3739ae9550..956f3247bd 100644 --- a/lib/CodeGen/CGValue.h +++ b/lib/CodeGen/CGValue.h @@ -169,7 +169,7 @@ class LValue { private: void Initialize(QualType Type, Qualifiers Quals, CharUnits Alignment, - llvm::MDNode *TBAAInfo = 0) { + llvm::MDNode *TBAAInfo = nullptr) { this->Type = Type; this->Quals = Quals; this->Alignment = Alignment.getQuantity(); @@ -180,7 +180,7 @@ private: this->Ivar = this->ObjIsArray = this->NonGC = this->GlobalObjCRef = false; this->ImpreciseLifetime = false; this->ThreadLocalRef = false; - this->BaseIvarExp = 0; + this->BaseIvarExp = nullptr; // Initialize fields for TBAA. this->TBAABaseType = Type; @@ -293,7 +293,7 @@ public: static LValue MakeAddr(llvm::Value *address, QualType type, CharUnits alignment, ASTContext &Context, - llvm::MDNode *TBAAInfo = 0) { + llvm::MDNode *TBAAInfo = nullptr) { Qualifiers qs = type.getQualifiers(); qs.setObjCGCAttr(Context.getObjCGCAttrKind(type)); @@ -405,7 +405,7 @@ public: /// ignored - Returns an aggregate value slot indicating that the /// aggregate value is being ignored. static AggValueSlot ignored() { - return forAddr(0, CharUnits(), Qualifiers(), IsNotDestructed, + return forAddr(nullptr, CharUnits(), Qualifiers(), IsNotDestructed, DoesNotNeedGCBarriers, IsNotAliased); } @@ -475,7 +475,7 @@ public: } bool isIgnored() const { - return Addr == 0; + return Addr == nullptr; } CharUnits getAlignment() const { diff --git a/lib/CodeGen/CodeGenAction.cpp b/lib/CodeGen/CodeGenAction.cpp index 9b5b9f59ab..2d08c22c51 100644 --- a/lib/CodeGen/CodeGenAction.cpp +++ b/lib/CodeGen/CodeGenAction.cpp @@ -466,7 +466,7 @@ void BackendConsumer::DiagnosticHandlerImpl(const DiagnosticInfo &DI) { #undef ComputeDiagID CodeGenAction::CodeGenAction(unsigned _Act, LLVMContext *_VMContext) - : Act(_Act), LinkModule(0), + : Act(_Act), LinkModule(nullptr), VMContext(_VMContext ? _VMContext : new LLVMContext), OwnsVMContext(!_VMContext) {} @@ -509,7 +509,7 @@ static raw_ostream *GetOutputStream(CompilerInstance &CI, case Backend_EmitBC: return CI.createDefaultOutputFile(true, InFile, "bc"); case Backend_EmitNothing: - return 0; + return nullptr; case Backend_EmitMCNull: case Backend_EmitObj: return CI.createDefaultOutputFile(true, InFile, "o"); @@ -523,7 +523,7 @@ ASTConsumer *CodeGenAction::CreateASTConsumer(CompilerInstance &CI, BackendAction BA = static_cast(Act); std::unique_ptr OS(GetOutputStream(CI, InFile, BA)); if (BA != Backend_EmitNothing && !OS) - return 0; + return nullptr; llvm::Module *LinkModuleToUse = LinkModule; @@ -538,7 +538,7 @@ ASTConsumer *CodeGenAction::CreateASTConsumer(CompilerInstance &CI, if (!BCBuf) { CI.getDiagnostics().Report(diag::err_cannot_open_file) << LinkBCFile << ErrorStr; - return 0; + return nullptr; } ErrorOr ModuleOrErr = @@ -546,7 +546,7 @@ ASTConsumer *CodeGenAction::CreateASTConsumer(CompilerInstance &CI, if (error_code EC = ModuleOrErr.getError()) { CI.getDiagnostics().Report(diag::err_cannot_open_file) << LinkBCFile << EC.message(); - return 0; + return nullptr; } LinkModuleToUse = ModuleOrErr.get(); } diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index 178cf9f2b3..1369c5786a 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -35,23 +35,25 @@ using namespace CodeGen; CodeGenFunction::CodeGenFunction(CodeGenModule &cgm, bool suppressNewContext) : CodeGenTypeCache(cgm), CGM(cgm), Target(cgm.getTarget()), - Builder(cgm.getModule().getContext()), CapturedStmtInfo(0), + Builder(cgm.getModule().getContext()), CapturedStmtInfo(nullptr), SanitizePerformTypeCheck(CGM.getSanOpts().Null | CGM.getSanOpts().Alignment | CGM.getSanOpts().ObjectSize | CGM.getSanOpts().Vptr), - SanOpts(&CGM.getSanOpts()), AutoreleaseResult(false), BlockInfo(0), - BlockPointer(0), LambdaThisCaptureField(0), NormalCleanupDest(0), - NextCleanupDestIndex(1), FirstBlockInfo(0), EHResumeBlock(0), - ExceptionSlot(0), EHSelectorSlot(0), DebugInfo(CGM.getModuleDebugInfo()), - DisableDebugInfo(false), DidCallStackSave(false), IndirectBranch(0), - PGO(cgm), SwitchInsn(0), SwitchWeights(0), - CaseRangeBlock(0), UnreachableBlock(0), NumReturnExprs(0), - NumSimpleReturnExprs(0), CXXABIThisDecl(0), CXXABIThisValue(0), - CXXThisValue(0), CXXDefaultInitExprThis(0), - CXXStructorImplicitParamDecl(0), CXXStructorImplicitParamValue(0), - OutermostConditional(0), CurLexicalScope(0), TerminateLandingPad(0), - TerminateHandler(0), TrapBB(0) { + SanOpts(&CGM.getSanOpts()), AutoreleaseResult(false), BlockInfo(nullptr), + BlockPointer(nullptr), LambdaThisCaptureField(nullptr), + NormalCleanupDest(nullptr), NextCleanupDestIndex(1), + FirstBlockInfo(nullptr), EHResumeBlock(nullptr), ExceptionSlot(nullptr), + EHSelectorSlot(nullptr), DebugInfo(CGM.getModuleDebugInfo()), + DisableDebugInfo(false), DidCallStackSave(false), IndirectBranch(nullptr), + PGO(cgm), SwitchInsn(nullptr), SwitchWeights(nullptr), + CaseRangeBlock(nullptr), UnreachableBlock(nullptr), NumReturnExprs(0), + NumSimpleReturnExprs(0), CXXABIThisDecl(nullptr), + CXXABIThisValue(nullptr), CXXThisValue(nullptr), + CXXDefaultInitExprThis(nullptr), CXXStructorImplicitParamDecl(nullptr), + CXXStructorImplicitParamValue(nullptr), OutermostConditional(nullptr), + CurLexicalScope(nullptr), TerminateLandingPad(nullptr), + TerminateHandler(nullptr), TrapBB(nullptr) { if (!suppressNewContext) CGM.getCXXABI().getMangleContext().startNewFunction(); @@ -261,7 +263,7 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) { // Remove the AllocaInsertPt instruction, which is just a convenience for us. llvm::Instruction *Ptr = AllocaInsertPt; - AllocaInsertPt = 0; + AllocaInsertPt = nullptr; Ptr->eraseFromParent(); // If someone took the address of a label but never did an indirect goto, we @@ -530,7 +532,7 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, DidCallStackSave = false; CurCodeDecl = D; - CurFuncDecl = (D ? D->getNonClosureContext() : 0); + CurFuncDecl = (D ? D->getNonClosureContext() : nullptr); FnRetTy = RetTy; CurFn = Fn; CurFnInfo = &FnInfo; @@ -613,7 +615,7 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, if (RetTy->isVoidType()) { // Void type; nothing to return. - ReturnValue = 0; + ReturnValue = nullptr; // Count the implicit return. if (!endsWithReturn(D)) @@ -712,7 +714,7 @@ void CodeGenFunction::EmitFunctionBody(FunctionArgList &Args, /// this just calls EmitBlock(). void CodeGenFunction::EmitBlockWithFallThrough(llvm::BasicBlock *BB, RegionCounter &Cnt) { - llvm::BasicBlock *SkipCountBB = 0; + llvm::BasicBlock *SkipCountBB = nullptr; if (HaveInsertPoint() && CGM.getCodeGenOpts().ProfileInstrGenerate) { // When instrumenting for profiling, the fallthrough to certain // statements needs to skip over the instrumentation code so that we @@ -763,7 +765,7 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn, // Check if we should generate debug info for this function. if (FD->hasAttr()) - DebugInfo = NULL; // disable debug info indefinitely for this function + DebugInfo = nullptr; // disable debug info indefinitely for this function FunctionArgList Args; QualType ResTy = FD->getReturnType(); @@ -876,7 +878,7 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn, /// that we can just remove the code. bool CodeGenFunction::ContainsLabel(const Stmt *S, bool IgnoreCaseStmts) { // Null statement, not a label! - if (S == 0) return false; + if (!S) return false; // If this is a label, we have to emit the code, consider something like: // if (0) { ... foo: bar(); } goto foo; @@ -908,7 +910,7 @@ bool CodeGenFunction::ContainsLabel(const Stmt *S, bool IgnoreCaseStmts) { /// inside of it, this is fine. bool CodeGenFunction::containsBreak(const Stmt *S) { // Null statement, not a label! - if (S == 0) return false; + if (!S) return false; // If this is a switch or loop that defines its own break scope, then we can // include it and anything inside of it. @@ -1234,7 +1236,7 @@ CodeGenFunction::EmitNullInitialization(llvm::Value *DestPtr, QualType Ty) { } } else { SizeVal = CGM.getSize(Size); - vla = 0; + vla = nullptr; } // If the type contains a pointer to data member we can't memset it to zero. @@ -1271,7 +1273,7 @@ CodeGenFunction::EmitNullInitialization(llvm::Value *DestPtr, QualType Ty) { llvm::BlockAddress *CodeGenFunction::GetAddrOfLabel(const LabelDecl *L) { // Make sure that there is a block for the indirect goto. - if (IndirectBranch == 0) + if (!IndirectBranch) GetIndirectGotoBlock(); llvm::BasicBlock *BB = getJumpDestForLabel(L).getBlock(); @@ -1305,7 +1307,7 @@ llvm::Value *CodeGenFunction::emitArrayLength(const ArrayType *origArrayType, // If it's a VLA, we have to load the stored size. Note that // this is the size of the VLA in bytes, not its size in elements. - llvm::Value *numVLAElements = 0; + llvm::Value *numVLAElements = nullptr; if (isa(arrayType)) { numVLAElements = getVLASize(cast(arrayType)).first; @@ -1398,7 +1400,7 @@ CodeGenFunction::getVLASize(QualType type) { std::pair CodeGenFunction::getVLASize(const VariableArrayType *type) { // The number of elements so far; always size_t. - llvm::Value *numElements = 0; + llvm::Value *numElements = nullptr; QualType elementType; do { diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index c859ddab77..8c4029afa0 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -103,13 +103,13 @@ public: /// A jump destination is an abstract label, branching to which may /// require a jump out through normal cleanups. struct JumpDest { - JumpDest() : Block(0), ScopeDepth(), Index(0) {} + JumpDest() : Block(nullptr), ScopeDepth(), Index(0) {} JumpDest(llvm::BasicBlock *Block, EHScopeStack::stable_iterator Depth, unsigned Index) : Block(Block), ScopeDepth(Depth), Index(Index) {} - bool isValid() const { return Block != 0; } + bool isValid() const { return Block != nullptr; } llvm::BasicBlock *getBlock() const { return Block; } EHScopeStack::stable_iterator getScopeDepth() const { return ScopeDepth; } unsigned getDestIndex() const { return Index; } @@ -163,7 +163,7 @@ public: public: explicit CGCapturedStmtInfo(const CapturedStmt &S, CapturedRegionKind K = CR_Default) - : Kind(K), ThisValue(0), CXXThisFieldDecl(0) { + : Kind(K), ThisValue(nullptr), CXXThisFieldDecl(nullptr) { RecordDecl::field_iterator Field = S.getCapturedRecordDecl()->field_begin(); @@ -190,7 +190,7 @@ public: return CaptureFields.lookup(VD); } - bool isCXXThisExprCaptured() const { return CXXThisFieldDecl != 0; } + bool isCXXThisExprCaptured() const { return CXXThisFieldDecl != nullptr; } FieldDecl *getThisFieldDecl() const { return CXXThisFieldDecl; } /// \brief Emit the captured statement body. @@ -611,9 +611,9 @@ public: } void end(CodeGenFunction &CGF) { - assert(CGF.OutermostConditional != 0); + assert(CGF.OutermostConditional != nullptr); if (CGF.OutermostConditional == this) - CGF.OutermostConditional = 0; + CGF.OutermostConditional = nullptr; } /// Returns a block which will be executed prior to each @@ -625,7 +625,7 @@ public: /// isInConditionalBranch - Return true if we're currently emitting /// one branch or the other of a conditional expression. - bool isInConditionalBranch() const { return OutermostConditional != 0; } + bool isInConditionalBranch() const { return OutermostConditional != nullptr; } void setBeforeOutermostConditional(llvm::Value *value, llvm::Value *addr) { assert(isInConditionalBranch()); @@ -646,7 +646,7 @@ public: public: StmtExprEvaluation(CodeGenFunction &CGF) : CGF(CGF), SavedOutermostConditional(CGF.OutermostConditional) { - CGF.OutermostConditional = 0; + CGF.OutermostConditional = nullptr; } ~StmtExprEvaluation() { @@ -663,7 +663,7 @@ public: friend class CodeGenFunction; public: - PeepholeProtection() : Inst(0) {} + PeepholeProtection() : Inst(nullptr) {} }; /// A non-RAII class containing all the information about a bound @@ -681,7 +681,7 @@ public: bool boundLValue) : OpaqueValue(ov), BoundLValue(boundLValue) {} public: - OpaqueValueMappingData() : OpaqueValue(0) {} + OpaqueValueMappingData() : OpaqueValue(nullptr) {} static bool shouldBindAsLValue(const Expr *expr) { // gl-values should be bound as l-values for obvious reasons. @@ -726,8 +726,8 @@ public: return data; } - bool isValid() const { return OpaqueValue != 0; } - void clear() { OpaqueValue = 0; } + bool isValid() const { return OpaqueValue != nullptr; } + void clear() { OpaqueValue = nullptr; } void unbind(CodeGenFunction &CGF) { assert(OpaqueValue && "no data to unbind!"); @@ -970,7 +970,7 @@ public: ASTContext &getContext() const { return CGM.getContext(); } CGDebugInfo *getDebugInfo() { if (DisableDebugInfo) - return NULL; + return nullptr; return DebugInfo; } void disableDebugInfo() { DisableDebugInfo = true; } @@ -1003,7 +1003,7 @@ public: } llvm::BasicBlock *getInvokeDest() { - if (!EHStack.requiresLandingPad()) return 0; + if (!EHStack.requiresLandingPad()) return nullptr; return getInvokeDestImpl(); } @@ -1291,8 +1291,8 @@ public: /// createBasicBlock - Create an LLVM basic block. llvm::BasicBlock *createBasicBlock(const Twine &name = "", - llvm::Function *parent = 0, - llvm::BasicBlock *before = 0) { + llvm::Function *parent = nullptr, + llvm::BasicBlock *before = nullptr) { #ifdef NDEBUG return llvm::BasicBlock::Create(getLLVMContext(), "", parent, before); #else @@ -1336,7 +1336,7 @@ public: /// HaveInsertPoint - True if an insertion point is defined. If not, this /// indicates that the current code being emitted is unreachable. bool HaveInsertPoint() const { - return Builder.GetInsertBlock() != 0; + return Builder.GetInsertBlock() != nullptr; } /// EnsureInsertPoint - Ensure that an insertion point is defined so that @@ -1747,19 +1747,21 @@ public: llvm::Value *SizeForLifetimeMarkers; struct Invalid {}; - AutoVarEmission(Invalid) : Variable(0) {} + AutoVarEmission(Invalid) : Variable(nullptr) {} AutoVarEmission(const VarDecl &variable) - : Variable(&variable), Address(0), NRVOFlag(0), + : Variable(&variable), Address(nullptr), NRVOFlag(nullptr), IsByRef(false), IsConstantAggregate(false), - SizeForLifetimeMarkers(0) {} + SizeForLifetimeMarkers(nullptr) {} - bool wasEmittedAsGlobal() const { return Address == 0; } + bool wasEmittedAsGlobal() const { return Address == nullptr; } public: static AutoVarEmission invalid() { return AutoVarEmission(Invalid()); } - bool useLifetimeMarkers() const { return SizeForLifetimeMarkers != 0; } + bool useLifetimeMarkers() const { + return SizeForLifetimeMarkers != nullptr; + } llvm::Value *getSizeForLifetimeMarkers() const { assert(useLifetimeMarkers()); return SizeForLifetimeMarkers; @@ -1947,7 +1949,7 @@ public: llvm::Value *EmitLoadOfScalar(llvm::Value *Addr, bool Volatile, unsigned Alignment, QualType Ty, SourceLocation Loc, - llvm::MDNode *TBAAInfo = 0, + llvm::MDNode *TBAAInfo = nullptr, QualType TBAABaseTy = QualType(), uint64_t TBAAOffset = 0); @@ -1962,7 +1964,7 @@ public: /// the LLVM value representation. void EmitStoreOfScalar(llvm::Value *Value, llvm::Value *Addr, bool Volatile, unsigned Alignment, QualType Ty, - llvm::MDNode *TBAAInfo = 0, bool isInit = false, + llvm::MDNode *TBAAInfo = nullptr, bool isInit = false, QualType TBAABaseTy = QualType(), uint64_t TBAAOffset = 0); @@ -1995,7 +1997,7 @@ public: /// bit-field contents after the store, appropriate for use as the result of /// an assignment to the bit-field. void EmitStoreThroughBitfieldLValue(RValue Src, LValue Dst, - llvm::Value **Result=0); + llvm::Value **Result=nullptr); /// Emit an l-value for an assignment (simple or compound) of complex type. LValue EmitComplexAssignmentLValue(const BinaryOperator *E); @@ -2043,7 +2045,9 @@ public: return ConstantEmission(C, false); } - LLVM_EXPLICIT operator bool() const { return ValueAndIsReference.getOpaqueValue() != 0; } + LLVM_EXPLICIT operator bool() const { + return ValueAndIsReference.getOpaqueValue() != nullptr; + } bool isReference() const { return ValueAndIsReference.getInt(); } LValue getReferenceLValue(CodeGenFunction &CGF, Expr *refExpr) const { @@ -2106,15 +2110,15 @@ public: llvm::Value *Callee, ReturnValueSlot ReturnValue, const CallArgList &Args, - const Decl *TargetDecl = 0, - llvm::Instruction **callOrInvoke = 0); + const Decl *TargetDecl = nullptr, + llvm::Instruction **callOrInvoke = nullptr); RValue EmitCall(QualType FnType, llvm::Value *Callee, SourceLocation CallLoc, ReturnValueSlot ReturnValue, CallExpr::const_arg_iterator ArgBeg, CallExpr::const_arg_iterator ArgEnd, - const Decl *TargetDecl = 0); + const Decl *TargetDecl = nullptr); RValue EmitCallExpr(const CallExpr *E, ReturnValueSlot ReturnValue = ReturnValueSlot()); @@ -2199,7 +2203,7 @@ public: unsigned Modifier, const CallExpr *E, SmallVectorImpl &Ops, - llvm::Value *Align = 0); + llvm::Value *Align = nullptr); llvm::Function *LookupNeonLLVMIntrinsic(unsigned IntrinsicID, unsigned Modifier, llvm::Type *ArgTy, const CallExpr *E); @@ -2397,7 +2401,7 @@ public: /// variables. void GenerateCXXGlobalInitFunc(llvm::Function *Fn, ArrayRef Decls, - llvm::GlobalVariable *Guard = 0); + llvm::GlobalVariable *Guard = nullptr); /// GenerateCXXGlobalDtorsFunc - Generates code for destroying global /// variables. @@ -2425,7 +2429,7 @@ public: void EmitLambdaExpr(const LambdaExpr *E, AggValueSlot Dest); - RValue EmitAtomicExpr(AtomicExpr *E, llvm::Value *Dest = 0); + RValue EmitAtomicExpr(AtomicExpr *E, llvm::Value *Dest = nullptr); //===--------------------------------------------------------------------===// // Annotations Emission @@ -2571,7 +2575,7 @@ public: ForceColumnInfo); } else { // T::param_type_iterator might not have a default ctor. - const QualType *NoIter = 0; + const QualType *NoIter = nullptr; EmitCallArgs(Args, /*AllowExtraArguments=*/true, NoIter, NoIter, ArgBeg, ArgEnd, ForceColumnInfo); } diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index af257c5466..fe6e75dd41 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -77,15 +77,17 @@ CodeGenModule::CodeGenModule(ASTContext &C, const CodeGenOptions &CGO, DiagnosticsEngine &diags) : Context(C), LangOpts(C.getLangOpts()), CodeGenOpts(CGO), TheModule(M), Diags(diags), TheDataLayout(TD), Target(C.getTargetInfo()), - ABI(createCXXABI(*this)), VMContext(M.getContext()), TBAA(0), - TheTargetCodeGenInfo(0), Types(*this), VTables(*this), ObjCRuntime(0), - OpenCLRuntime(0), OpenMPRuntime(nullptr), CUDARuntime(0), DebugInfo(0), - ARCData(0), NoObjCARCExceptionsMetadata(0), RRData(0), PGOReader(nullptr), - CFConstantStringClassRef(0), - ConstantStringClassRef(0), NSConstantStringType(0), - NSConcreteGlobalBlock(0), NSConcreteStackBlock(0), BlockObjectAssign(0), - BlockObjectDispose(0), BlockDescriptorType(0), GenericBlockLiteralType(0), - LifetimeStartFn(0), LifetimeEndFn(0), + ABI(createCXXABI(*this)), VMContext(M.getContext()), TBAA(nullptr), + TheTargetCodeGenInfo(nullptr), Types(*this), VTables(*this), + ObjCRuntime(nullptr), OpenCLRuntime(nullptr), OpenMPRuntime(nullptr), + CUDARuntime(nullptr), DebugInfo(nullptr), ARCData(nullptr), + NoObjCARCExceptionsMetadata(nullptr), RRData(nullptr), PGOReader(nullptr), + CFConstantStringClassRef(nullptr), ConstantStringClassRef(nullptr), + NSConstantStringType(nullptr), NSConcreteGlobalBlock(nullptr), + NSConcreteStackBlock(nullptr), BlockObjectAssign(nullptr), + BlockObjectDispose(nullptr), BlockDescriptorType(nullptr), + GenericBlockLiteralType(nullptr), LifetimeStartFn(nullptr), + LifetimeEndFn(nullptr), SanitizerBlacklist( llvm::SpecialCaseList::createOrDie(CGO.SanitizerBlacklistFile)), SanOpts(SanitizerBlacklist->isIn(M) ? SanitizerOptions::Disabled @@ -328,25 +330,25 @@ void CodeGenModule::UpdateCompletedType(const TagDecl *TD) { llvm::MDNode *CodeGenModule::getTBAAInfo(QualType QTy) { if (!TBAA) - return 0; + return nullptr; return TBAA->getTBAAInfo(QTy); } llvm::MDNode *CodeGenModule::getTBAAInfoForVTablePtr() { if (!TBAA) - return 0; + return nullptr; return TBAA->getTBAAInfoForVTablePtr(); } llvm::MDNode *CodeGenModule::getTBAAStructInfo(QualType QTy) { if (!TBAA) - return 0; + return nullptr; return TBAA->getTBAAStructInfo(QTy); } llvm::MDNode *CodeGenModule::getTBAAStructTypeInfo(QualType QTy) { if (!TBAA) - return 0; + return nullptr; return TBAA->getTBAAStructTypeInfo(QTy); } @@ -354,7 +356,7 @@ llvm::MDNode *CodeGenModule::getTBAAStructTagInfo(QualType BaseTy, llvm::MDNode *AccessN, uint64_t O) { if (!TBAA) - return 0; + return nullptr; return TBAA->getTBAAStructTagInfo(BaseTy, AccessN, O); } @@ -492,7 +494,7 @@ void CodeGenModule::getBlockMangledName(GlobalDecl GD, MangleBuffer &Buffer, MangleContext &MangleCtx = getCXXABI().getMangleContext(); const Decl *D = GD.getDecl(); llvm::raw_svector_ostream Out(Buffer.getBuffer()); - if (D == 0) + if (!D) MangleCtx.mangleGlobalBlock(BD, dyn_cast_or_null(initializedGlobalDecl.getDecl()), Out); else if (const auto *CD = dyn_cast(D)) @@ -1111,7 +1113,8 @@ llvm::Constant *CodeGenModule::GetWeakRefReference(const ValueDecl *VD) { /*ForVTable=*/false); else Aliasee = GetOrCreateLLVMGlobal(AA->getAliasee(), - llvm::PointerType::getUnqual(DeclTy), 0); + llvm::PointerType::getUnqual(DeclTy), + nullptr); auto *F = cast(Aliasee); F->setLinkage(llvm::Function::ExternalWeakLinkage); @@ -1187,7 +1190,7 @@ void CodeGenModule::EmitGlobal(GlobalDecl GD) { if (getLangOpts().CPlusPlus && isa(Global) && cast(Global)->hasInit()) { DelayedCXXInitPosition[Global] = CXXGlobalInits.size(); - CXXGlobalInits.push_back(0); + CXXGlobalInits.push_back(nullptr); } // If the value has already been used, add it directly to the @@ -1556,7 +1559,7 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName, unsigned AddrSpace = GetGlobalVarAddressSpace(D, Ty->getAddressSpace()); auto *GV = new llvm::GlobalVariable( getModule(), Ty->getElementType(), false, - llvm::GlobalValue::ExternalLinkage, 0, MangledName, 0, + llvm::GlobalValue::ExternalLinkage, nullptr, MangledName, nullptr, llvm::GlobalVariable::NotThreadLocal, AddrSpace); // This is the first use or definition of a mangled name. If there is a @@ -1612,9 +1615,8 @@ CodeGenModule::CreateOrReplaceCXXRuntimeVariable(StringRef Name, llvm::Type *Ty, llvm::GlobalValue::LinkageTypes Linkage) { llvm::GlobalVariable *GV = getModule().getNamedGlobal(Name); - llvm::GlobalVariable *OldGV = 0; + llvm::GlobalVariable *OldGV = nullptr; - if (GV) { // Check if the variable has the right type. if (GV->getType()->getElementType() == Ty) @@ -1628,8 +1630,8 @@ CodeGenModule::CreateOrReplaceCXXRuntimeVariable(StringRef Name, // Create a new variable. GV = new llvm::GlobalVariable(getModule(), Ty, /*isConstant=*/true, - Linkage, 0, Name); - + Linkage, nullptr, Name); + if (OldGV) { // Replace occurrences of the old variable if needed. GV->takeName(OldGV); @@ -1654,7 +1656,7 @@ llvm::Constant *CodeGenModule::GetAddrOfGlobalVar(const VarDecl *D, llvm::Type *Ty) { assert(D->hasGlobalStorage() && "Not a global variable"); QualType ASTTy = D->getType(); - if (Ty == 0) + if (!Ty) Ty = getTypes().ConvertTypeForMem(ASTTy); llvm::PointerType *PTy = @@ -1669,7 +1671,7 @@ llvm::Constant *CodeGenModule::GetAddrOfGlobalVar(const VarDecl *D, llvm::Constant * CodeGenModule::CreateRuntimeVariable(llvm::Type *Ty, StringRef Name) { - return GetOrCreateLLVMGlobal(Name, llvm::PointerType::getUnqual(Ty), 0, + return GetOrCreateLLVMGlobal(Name, llvm::PointerType::getUnqual(Ty), nullptr, true); } @@ -1740,11 +1742,11 @@ void CodeGenModule::MaybeHandleStaticInExternC(const SomeDecl *D, // If we have multiple internal linkage entities with the same name // in extern "C" regions, none of them gets that name. if (!R.second) - R.first->second = 0; + R.first->second = nullptr; } void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) { - llvm::Constant *Init = 0; + llvm::Constant *Init = nullptr; QualType ASTTy = D->getType(); CXXRecordDecl *RD = ASTTy->getBaseElementTypeUnsafe()->getAsCXXRecordDecl(); bool NeedsGlobalCtor = false; @@ -1814,7 +1816,7 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) { // "extern int x[];") and then a definition of a different type (e.g. // "int x[10];"). This also happens when an initializer has a different type // from the type of the global (this happens with unions). - if (GV == 0 || + if (!GV || GV->getType()->getElementType() != InitType || GV->getType()->getAddressSpace() != GetGlobalVarAddressSpace(D, getContext().getTargetAddressSpace(ASTTy))) { @@ -2264,7 +2266,8 @@ void CodeGenModule::EmitAliasDefinition(GlobalDecl GD) { /*ForVTable=*/false); else Aliasee = GetOrCreateLLVMGlobal(AA->getAliasee(), - llvm::PointerType::getUnqual(DeclTy), 0); + llvm::PointerType::getUnqual(DeclTy), + nullptr); // Create the new alias itself, but don't set a name yet. auto *GA = llvm::GlobalAlias::create( @@ -2411,7 +2414,7 @@ CodeGenModule::GetAddrOfConstantCFString(const StringLiteral *Literal) { llvm::ConstantInt::get(Ty, 0x07C8); // String pointer. - llvm::Constant *C = 0; + llvm::Constant *C = nullptr; if (isUTF16) { ArrayRef Arr = llvm::makeArrayRef(reinterpret_cast( @@ -2523,9 +2526,9 @@ CodeGenModule::GetAddrOfConstantString(const StringLiteral *Literal) { for (unsigned i = 0; i < 3; ++i) { FieldDecl *Field = FieldDecl::Create(Context, D, SourceLocation(), - SourceLocation(), 0, - FieldTypes[i], /*TInfo=*/0, - /*BitWidth=*/0, + SourceLocation(), nullptr, + FieldTypes[i], /*TInfo=*/nullptr, + /*BitWidth=*/nullptr, /*Mutable=*/false, ICIS_NoInit); Field->setAccess(AS_public); @@ -2598,9 +2601,9 @@ QualType CodeGenModule::getObjCFastEnumerationStateType() { FieldDecl *Field = FieldDecl::Create(Context, D, SourceLocation(), - SourceLocation(), 0, - FieldTypes[i], /*TInfo=*/0, - /*BitWidth=*/0, + SourceLocation(), nullptr, + FieldTypes[i], /*TInfo=*/nullptr, + /*BitWidth=*/nullptr, /*Mutable=*/false, ICIS_NoInit); Field->setAccess(AS_public); @@ -2752,7 +2755,7 @@ static llvm::GlobalVariable *GenerateStringLiteral(StringRef str, // Create a global variable for this string auto *GV = new llvm::GlobalVariable( CGM.getModule(), C->getType(), constant, - llvm::GlobalValue::PrivateLinkage, C, GlobalName, 0, + llvm::GlobalValue::PrivateLinkage, C, GlobalName, nullptr, llvm::GlobalVariable::NotThreadLocal, AddrSpace); GV->setAlignment(Alignment); GV->setUnnamedAddr(true); @@ -2834,7 +2837,7 @@ llvm::Constant *CodeGenModule::GetAddrOfGlobalTemporary( VD, E->getManglingNumber(), Out); Out.flush(); - APValue *Value = 0; + APValue *Value = nullptr; if (E->getStorageDuration() == SD_Static) { // We might have a cached constant initializer for this temporary. Note // that this might have a different value from the value computed by @@ -2842,7 +2845,7 @@ llvm::Constant *CodeGenModule::GetAddrOfGlobalTemporary( // modifies the temporary. Value = getContext().getMaterializedTemporaryValue(E, false); if (Value && Value->isUninit()) - Value = 0; + Value = nullptr; } // Try evaluating it now, it might have a constant initializer. @@ -2851,12 +2854,12 @@ llvm::Constant *CodeGenModule::GetAddrOfGlobalTemporary( !EvalResult.hasSideEffects()) Value = &EvalResult.Val; - llvm::Constant *InitialValue = 0; + llvm::Constant *InitialValue = nullptr; bool Constant = false; llvm::Type *Type; if (Value) { // The temporary has a constant initializer, use it. - InitialValue = EmitConstantValue(*Value, MaterializedType, 0); + InitialValue = EmitConstantValue(*Value, MaterializedType, nullptr); Constant = isTypeConstant(MaterializedType, /*ExcludeCtor*/Value); Type = InitialValue->getType(); } else { @@ -2931,7 +2934,7 @@ void CodeGenModule::EmitObjCIvarInitializations(ObjCImplementationDecl *D) { Selector cxxSelector = getContext().Selectors.getSelector(0, &II); ObjCMethodDecl *DTORMethod = ObjCMethodDecl::Create(getContext(), D->getLocation(), D->getLocation(), - cxxSelector, getContext().VoidTy, 0, D, + cxxSelector, getContext().VoidTy, nullptr, D, /*isInstance=*/true, /*isVariadic=*/false, /*isPropertyAccessor=*/true, /*isImplicitlyDeclared=*/true, /*isDefined=*/false, ObjCMethodDecl::Required); @@ -2952,8 +2955,8 @@ void CodeGenModule::EmitObjCIvarInitializations(ObjCImplementationDecl *D) { D->getLocation(), D->getLocation(), cxxSelector, - getContext().getObjCIdType(), 0, - D, /*isInstance=*/true, + getContext().getObjCIdType(), + nullptr, D, /*isInstance=*/true, /*isVariadic=*/false, /*isPropertyAccessor=*/true, /*isImplicitlyDeclared=*/true, @@ -3208,7 +3211,7 @@ void CodeGenModule::EmitStaticExternCAliases() { /// with an llvm::GlobalValue, we create a global named metadata /// with the name 'clang.global.decl.ptrs'. void CodeGenModule::EmitDeclMetadata() { - llvm::NamedMDNode *GlobalMetadata = 0; + llvm::NamedMDNode *GlobalMetadata = nullptr; // StaticLocalDeclMap for (llvm::DenseMap::iterator @@ -3229,7 +3232,7 @@ void CodeGenFunction::EmitDeclMetadata() { // Find the unique metadata ID for this name. unsigned DeclPtrKind = Context.getMDKindID("clang.decl.ptr"); - llvm::NamedMDNode *GlobalMetadata = 0; + llvm::NamedMDNode *GlobalMetadata = nullptr; for (llvm::DenseMap::iterator I = LocalDeclMap.begin(), E = LocalDeclMap.end(); I != E; ++I) { diff --git a/lib/CodeGen/CodeGenModule.h b/lib/CodeGen/CodeGenModule.h index 8d5627ab38..bb7f1899d5 100644 --- a/lib/CodeGen/CodeGenModule.h +++ b/lib/CodeGen/CodeGenModule.h @@ -467,7 +467,7 @@ public: /// Return a reference to the configured OpenCL runtime. CGOpenCLRuntime &getOpenCLRuntime() { - assert(OpenCLRuntime != 0); + assert(OpenCLRuntime != nullptr); return *OpenCLRuntime; } @@ -479,17 +479,17 @@ public: /// Return a reference to the configured CUDA runtime. CGCUDARuntime &getCUDARuntime() { - assert(CUDARuntime != 0); + assert(CUDARuntime != nullptr); return *CUDARuntime; } ARCEntrypoints &getARCEntrypoints() const { - assert(getLangOpts().ObjCAutoRefCount && ARCData != 0); + assert(getLangOpts().ObjCAutoRefCount && ARCData != nullptr); return *ARCData; } RREntrypoints &getRREntrypoints() const { - assert(RRData != 0); + assert(RRData != nullptr); return *RRData; } @@ -554,8 +554,8 @@ public: const TargetInfo &getTarget() const { return Target; } CGCXXABI &getCXXABI() const { return *ABI; } llvm::LLVMContext &getLLVMContext() { return VMContext; } - - bool shouldUseTBAA() const { return TBAA != 0; } + + bool shouldUseTBAA() const { return TBAA != nullptr; } const TargetCodeGenInfo &getTargetCodeGenInfo(); @@ -644,7 +644,7 @@ public: /// with the specified type instead of whatever the normal requested type /// would be. llvm::Constant *GetAddrOfGlobalVar(const VarDecl *D, - llvm::Type *Ty = 0); + llvm::Type *Ty = nullptr); /// Return the address of the given function. If Ty is non-null, then this /// function will use the specified type if it has to create it. @@ -741,7 +741,7 @@ public: /// \param GlobalName If provided, the name to use for the global /// (if one is created). llvm::Constant *GetAddrOfConstantString(StringRef Str, - const char *GlobalName=0, + const char *GlobalName=nullptr, unsigned Alignment=0); /// Returns a pointer to a character array containing the literal and a @@ -750,7 +750,7 @@ public: /// \param GlobalName If provided, the name to use for the global (if one is /// created). llvm::Constant *GetAddrOfConstantCString(const std::string &str, - const char *GlobalName=0, + const char *GlobalName=nullptr, unsigned Alignment=0); /// Returns a pointer to a constant global variable for the given file-scope @@ -767,17 +767,18 @@ public: QualType getObjCFastEnumerationStateType(); /// Return the address of the constructor of the given type. - llvm::GlobalValue *GetAddrOfCXXConstructor(const CXXConstructorDecl *ctor, - CXXCtorType ctorType, - const CGFunctionInfo *fnInfo = 0, - bool DontDefer = false); + llvm::GlobalValue * + GetAddrOfCXXConstructor(const CXXConstructorDecl *ctor, CXXCtorType ctorType, + const CGFunctionInfo *fnInfo = nullptr, + bool DontDefer = false); /// Return the address of the constructor of the given type. - llvm::GlobalValue *GetAddrOfCXXDestructor(const CXXDestructorDecl *dtor, - CXXDtorType dtorType, - const CGFunctionInfo *fnInfo = 0, - llvm::FunctionType *fnType = 0, - bool DontDefer = false); + llvm::GlobalValue * + GetAddrOfCXXDestructor(const CXXDestructorDecl *dtor, + CXXDtorType dtorType, + const CGFunctionInfo *fnInfo = nullptr, + llvm::FunctionType *fnType = nullptr, + bool DontDefer = false); /// Given a builtin id for a function like "__builtin_fabsf", return a /// Function* for "fabsf". @@ -838,23 +839,24 @@ public: /// Try to emit the initializer for the given declaration as a constant; /// returns 0 if the expression cannot be emitted as a constant. - llvm::Constant *EmitConstantInit(const VarDecl &D, CodeGenFunction *CGF = 0); + llvm::Constant *EmitConstantInit(const VarDecl &D, + CodeGenFunction *CGF = nullptr); /// Try to emit the given expression as a constant; returns 0 if the /// expression cannot be emitted as a constant. llvm::Constant *EmitConstantExpr(const Expr *E, QualType DestType, - CodeGenFunction *CGF = 0); + CodeGenFunction *CGF = nullptr); /// Emit the given constant value as a constant, in the type's scalar /// representation. llvm::Constant *EmitConstantValue(const APValue &Value, QualType DestType, - CodeGenFunction *CGF = 0); + CodeGenFunction *CGF = nullptr); /// Emit the given constant value as a constant, in the type's memory /// representation. llvm::Constant *EmitConstantValueForMemory(const APValue &Value, QualType DestType, - CodeGenFunction *CGF = 0); + CodeGenFunction *CGF = nullptr); /// Return the result of value-initializing the given type, i.e. a null /// expression of the given type. This is usually, but not always, an LLVM @@ -1031,7 +1033,7 @@ private: llvm::Function *F, bool IsIncompleteFunction); - void EmitGlobalDefinition(GlobalDecl D, llvm::GlobalValue *GV = 0); + void EmitGlobalDefinition(GlobalDecl D, llvm::GlobalValue *GV = nullptr); void EmitGlobalFunctionDefinition(GlobalDecl GD, llvm::GlobalValue *GV); void EmitGlobalVarDefinition(const VarDecl *D); diff --git a/lib/CodeGen/CodeGenPGO.h b/lib/CodeGen/CodeGenPGO.h index 98e5b1fd1a..c434808588 100644 --- a/lib/CodeGen/CodeGenPGO.h +++ b/lib/CodeGen/CodeGenPGO.h @@ -45,13 +45,13 @@ private: public: CodeGenPGO(CodeGenModule &CGM) - : CGM(CGM), NumRegionCounters(0), FunctionHash(0), RegionCounters(0), - CurrentRegionCount(0) {} + : CGM(CGM), NumRegionCounters(0), FunctionHash(0), + RegionCounters(nullptr), CurrentRegionCount(0) {} /// Whether or not we have PGO region data for the current function. This is /// false both when we have no data at all and when our data has been /// discarded. - bool haveRegionCounts() const { return RegionCounts != 0; } + bool haveRegionCounts() const { return RegionCounts != nullptr; } /// Get the string used to identify this function in the profile data. /// For functions with local linkage, this includes the main file name. @@ -128,7 +128,7 @@ private: /// Return the region counter for the given statement. This should only be /// called on statements that have a dedicated counter. unsigned getRegionCounter(const Stmt *S) { - if (RegionCounterMap == 0) + if (!RegionCounterMap) return 0; return (*RegionCounterMap)[S]; } diff --git a/lib/CodeGen/CodeGenTBAA.cpp b/lib/CodeGen/CodeGenTBAA.cpp index 699cc2eabe..53ba02a813 100644 --- a/lib/CodeGen/CodeGenTBAA.cpp +++ b/lib/CodeGen/CodeGenTBAA.cpp @@ -33,7 +33,7 @@ CodeGenTBAA::CodeGenTBAA(ASTContext &Ctx, llvm::LLVMContext& VMContext, const CodeGenOptions &CGO, const LangOptions &Features, MangleContext &MContext) : Context(Ctx), CodeGenOpts(CGO), Features(Features), MContext(MContext), - MDHelper(VMContext), Root(0), Char(0) { + MDHelper(VMContext), Root(nullptr), Char(nullptr) { } CodeGenTBAA::~CodeGenTBAA() { @@ -88,7 +88,7 @@ llvm::MDNode * CodeGenTBAA::getTBAAInfo(QualType QTy) { // At -O0 or relaxed aliasing, TBAA is not emitted for regular types. if (CodeGenOpts.OptimizationLevel == 0 || CodeGenOpts.RelaxedAliasing) - return NULL; + return nullptr; // If the type has the may_alias attribute (even on a typedef), it is // effectively in the general char alias class. @@ -221,7 +221,7 @@ CodeGenTBAA::getTBAAStructInfo(QualType QTy) { return MDHelper.createTBAAStructNode(Fields); // For now, handle any other kind of type conservatively. - return StructMetadataCache[Ty] = NULL; + return StructMetadataCache[Ty] = nullptr; } /// Check if the given type can be handled by path-aware TBAA. @@ -261,7 +261,7 @@ CodeGenTBAA::getTBAAStructTypeInfo(QualType QTy) { else FieldNode = getTBAAInfo(FieldQTy); if (!FieldNode) - return StructTypeMetadataCache[Ty] = NULL; + return StructTypeMetadataCache[Ty] = nullptr; Fields.push_back(std::make_pair( FieldNode, Layout.getFieldOffset(idx) / Context.getCharWidth())); } @@ -280,7 +280,7 @@ CodeGenTBAA::getTBAAStructTypeInfo(QualType QTy) { MDHelper.createTBAAStructTypeNode(OutName, Fields); } - return StructMetadataCache[Ty] = NULL; + return StructMetadataCache[Ty] = nullptr; } /// Return a TBAA tag node for both scalar TBAA and struct-path aware TBAA. @@ -288,7 +288,7 @@ llvm::MDNode * CodeGenTBAA::getTBAAStructTagInfo(QualType BaseQTy, llvm::MDNode *AccessNode, uint64_t Offset) { if (!AccessNode) - return NULL; + return nullptr; if (!CodeGenOpts.StructPathTBAA) return getTBAAScalarTagInfo(AccessNode); @@ -298,7 +298,7 @@ CodeGenTBAA::getTBAAStructTagInfo(QualType BaseQTy, llvm::MDNode *AccessNode, if (llvm::MDNode *N = StructTagMetadataCache[PathTag]) return N; - llvm::MDNode *BNode = 0; + llvm::MDNode *BNode = nullptr; if (isTBAAPathStruct(BaseQTy)) BNode = getTBAAStructTypeInfo(BaseQTy); if (!BNode) @@ -312,7 +312,7 @@ CodeGenTBAA::getTBAAStructTagInfo(QualType BaseQTy, llvm::MDNode *AccessNode, llvm::MDNode * CodeGenTBAA::getTBAAScalarTagInfo(llvm::MDNode *AccessNode) { if (!AccessNode) - return NULL; + return nullptr; if (llvm::MDNode *N = ScalarTagMetadataCache[AccessNode]) return N; diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp index 9be633c1c9..d4e22623e0 100644 --- a/lib/CodeGen/CodeGenTypes.cpp +++ b/lib/CodeGen/CodeGenTypes.cpp @@ -189,15 +189,15 @@ static bool isSafeToConvert(const RecordDecl *RD, CodeGenTypes &CGT) { bool CodeGenTypes::isFuncParamTypeConvertible(QualType Ty) { // If this isn't a tagged type, we can convert it! const TagType *TT = Ty->getAs(); - if (TT == 0) return true; - + if (!TT) return true; + // Incomplete types cannot be converted. if (TT->isIncompleteType()) return false; // If this is an enum, then it is always safe to convert. const RecordType *RT = dyn_cast(TT); - if (RT == 0) return true; + if (!RT) return true; // Otherwise, we have to be careful. If it is a struct that we're in the // process of expanding, then we can't convert the function type. That's ok @@ -304,7 +304,7 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) { return TCI->second; // If we don't have it in the cache, convert it now. - llvm::Type *ResultType = 0; + llvm::Type *ResultType = nullptr; switch (Ty->getTypeClass()) { case Type::Record: // Handled above. #define TYPE(Class, Base) @@ -629,7 +629,7 @@ llvm::StructType *CodeGenTypes::ConvertRecordDeclType(const RecordDecl *RD) { llvm::StructType *&Entry = RecordDeclTypes[Key]; // If we don't have a StructType at all yet, create the forward declaration. - if (Entry == 0) { + if (!Entry) { Entry = llvm::StructType::create(getLLVMContext()); addRecordTypeName(RD, Entry, ""); } @@ -638,7 +638,7 @@ llvm::StructType *CodeGenTypes::ConvertRecordDeclType(const RecordDecl *RD) { // If this is still a forward declaration, or the LLVM type is already // complete, there's nothing more to do. RD = RD->getDefinition(); - if (RD == 0 || !RD->isCompleteDefinition() || !Ty->isOpaque()) + if (!RD || !RD->isCompleteDefinition() || !Ty->isOpaque()) return Ty; // If converting this type would cause us to infinitely loop, don't do it! diff --git a/lib/CodeGen/EHScopeStack.h b/lib/CodeGen/EHScopeStack.h index 166d420d57..b9ccfb63d7 100644 --- a/lib/CodeGen/EHScopeStack.h +++ b/lib/CodeGen/EHScopeStack.h @@ -301,8 +301,8 @@ private: void *pushCleanup(CleanupKind K, size_t DataSize); public: - EHScopeStack() : StartOfBuffer(0), EndOfBuffer(0), StartOfData(0), - InnermostNormalCleanup(stable_end()), + EHScopeStack() : StartOfBuffer(nullptr), EndOfBuffer(nullptr), + StartOfData(nullptr), InnermostNormalCleanup(stable_end()), InnermostEHScope(stable_end()) {} ~EHScopeStack() { delete[] StartOfBuffer; } diff --git a/lib/CodeGen/ItaniumCXXABI.cpp b/lib/CodeGen/ItaniumCXXABI.cpp index 0df8cad5cc..f5d23726a9 100644 --- a/lib/CodeGen/ItaniumCXXABI.cpp +++ b/lib/CodeGen/ItaniumCXXABI.cpp @@ -899,7 +899,7 @@ void ItaniumCXXABI::addImplicitStructorParams(CodeGenFunction &CGF, // FIXME: avoid the fake decl QualType T = Context.getPointerType(Context.VoidPtrTy); ImplicitParamDecl *VTTDecl - = ImplicitParamDecl::Create(Context, 0, MD->getLocation(), + = ImplicitParamDecl::Create(Context, nullptr, MD->getLocation(), &Context.Idents.get("vtt"), T); Params.insert(Params.begin() + 1, VTTDecl); getStructorImplicitParamDecl(CGF) = VTTDecl; @@ -951,7 +951,7 @@ void ItaniumCXXABI::EmitDestructorCall(CodeGenFunction &CGF, llvm::Value *VTT = CGF.GetVTTParameter(GD, ForVirtualBase, Delegating); QualType VTTTy = getContext().getPointerType(getContext().VoidPtrTy); - llvm::Value *Callee = 0; + llvm::Value *Callee = nullptr; if (getContext().getLangOpts().AppleKext) Callee = CGF.BuildAppleKextVirtualDestructorCall(DD, Type, DD->getParent()); @@ -960,7 +960,7 @@ void ItaniumCXXABI::EmitDestructorCall(CodeGenFunction &CGF, // FIXME: Provide a source location here. CGF.EmitCXXMemberCall(DD, SourceLocation(), Callee, ReturnValueSlot(), This, - VTT, VTTTy, 0, 0); + VTT, VTTTy, nullptr, nullptr); } void ItaniumCXXABI::emitVTableDefinitions(CodeGenVTables &CGVT, @@ -1100,7 +1100,8 @@ void ItaniumCXXABI::EmitVirtualDestructorCall(CodeGenFunction &CGF, getVirtualFunctionPointer(CGF, GlobalDecl(Dtor, DtorType), This, Ty); CGF.EmitCXXMemberCall(Dtor, CallLoc, Callee, ReturnValueSlot(), This, - /*ImplicitParam=*/0, QualType(), 0, 0); + /*ImplicitParam=*/nullptr, QualType(), nullptr, + nullptr); } void ItaniumCXXABI::emitVirtualInheritanceTables(const CXXRecordDecl *RD) { @@ -1622,7 +1623,7 @@ void ItaniumCXXABI::EmitThreadLocalInitFuncs( // If we have a definition for the variable, emit the initialization // function as an alias to the global Init function (if any). Otherwise, // produce a declaration of the initialization function. - llvm::GlobalValue *Init = 0; + llvm::GlobalValue *Init = nullptr; bool InitIsInitFunc = false; if (VD->hasDefinition()) { InitIsInitFunc = true; diff --git a/lib/CodeGen/MicrosoftCXXABI.cpp b/lib/CodeGen/MicrosoftCXXABI.cpp index 4b8027e838..65b98d2bd0 100644 --- a/lib/CodeGen/MicrosoftCXXABI.cpp +++ b/lib/CodeGen/MicrosoftCXXABI.cpp @@ -132,7 +132,7 @@ public: // FIXME: might want to have a more precise type in the non-virtual // multiple inheritance case. if (ML.VBase || !ML.VFPtrOffset.isZero()) - return 0; + return nullptr; } return MD->getParent(); } @@ -285,13 +285,13 @@ private: llvm::Value *Base, llvm::Value *VBPtrOffset, llvm::Value *VBTableOffset, - llvm::Value **VBPtr = 0); + llvm::Value **VBPtr = nullptr); llvm::Value *GetVBaseOffsetFromVBPtr(CodeGenFunction &CGF, llvm::Value *Base, int32_t VBPtrOffset, int32_t VBTableOffset, - llvm::Value **VBPtr = 0) { + llvm::Value **VBPtr = nullptr) { llvm::Value *VBPOffset = llvm::ConstantInt::get(CGM.IntTy, VBPtrOffset), *VBTOffset = llvm::ConstantInt::get(CGM.IntTy, VBTableOffset); return GetVBaseOffsetFromVBPtr(CGF, Base, VBPOffset, VBTOffset, VBPtr); @@ -384,7 +384,7 @@ private: /// Info on the global variable used to guard initialization of static locals. /// The BitIndex field is only used for externally invisible declarations. struct GuardInfo { - GuardInfo() : Guard(0), BitIndex(0) {} + GuardInfo() : Guard(nullptr), BitIndex(0) {} llvm::GlobalVariable *Guard; unsigned BitIndex; }; @@ -567,7 +567,7 @@ void MicrosoftCXXABI::initializeHiddenVirtualInheritanceMembers( unsigned AS = cast(getThisValue(CGF)->getType())->getAddressSpace(); - llvm::Value *Int8This = 0; // Initialize lazily. + llvm::Value *Int8This = nullptr; // Initialize lazily. for (VBOffsets::const_iterator I = VBaseMap.begin(), E = VBaseMap.end(); I != E; ++I) { @@ -768,7 +768,7 @@ void MicrosoftCXXABI::addImplicitStructorParams(CodeGenFunction &CGF, assert(isa(MD) || isa(MD)); if (isa(MD) && MD->getParent()->getNumVBases()) { ImplicitParamDecl *IsMostDerived - = ImplicitParamDecl::Create(Context, 0, + = ImplicitParamDecl::Create(Context, nullptr, CGF.CurGD.getDecl()->getLocation(), &Context.Idents.get("is_most_derived"), Context.IntTy); @@ -782,7 +782,7 @@ void MicrosoftCXXABI::addImplicitStructorParams(CodeGenFunction &CGF, getStructorImplicitParamDecl(CGF) = IsMostDerived; } else if (IsDeletingDtor(CGF.CurGD)) { ImplicitParamDecl *ShouldDelete - = ImplicitParamDecl::Create(Context, 0, + = ImplicitParamDecl::Create(Context, nullptr, CGF.CurGD.getDecl()->getLocation(), &Context.Idents.get("should_call_delete"), Context.IntTy); @@ -887,7 +887,8 @@ void MicrosoftCXXABI::EmitDestructorCall(CodeGenFunction &CGF, // FIXME: Provide a source location here. CGF.EmitCXXMemberCall(DD, SourceLocation(), Callee, ReturnValueSlot(), This, - /*ImplicitParam=*/0, /*ImplicitParamTy=*/QualType(), 0, 0); + /*ImplicitParam=*/nullptr, + /*ImplicitParamTy=*/QualType(), nullptr, nullptr); } void MicrosoftCXXABI::emitVTableDefinitions(CodeGenVTables &CGVT, @@ -918,7 +919,7 @@ void MicrosoftCXXABI::emitVTableDefinitions(CodeGenVTables &CGVT, llvm::Value *MicrosoftCXXABI::getVTableAddressPointInStructor( CodeGenFunction &CGF, const CXXRecordDecl *VTableClass, BaseSubobject Base, const CXXRecordDecl *NearestVBase, bool &NeedsVirtualOffset) { - NeedsVirtualOffset = (NearestVBase != 0); + NeedsVirtualOffset = (NearestVBase != nullptr); llvm::Value *VTableAddressPoint = getAddrOfVTable(VTableClass, Base.getBaseOffset()); @@ -951,8 +952,7 @@ llvm::GlobalVariable *MicrosoftCXXABI::getAddrOfVTable(const CXXRecordDecl *RD, VFTableIdTy ID(RD, VPtrOffset); VFTablesMapTy::iterator I; bool Inserted; - std::tie(I, Inserted) = VFTablesMap.insert( - std::make_pair(ID, static_cast(0))); + std::tie(I, Inserted) = VFTablesMap.insert(std::make_pair(ID, nullptr)); if (!Inserted) return I->second; @@ -1040,7 +1040,7 @@ void MicrosoftCXXABI::EmitVirtualDestructorCall(CodeGenFunction &CGF, This = adjustThisArgumentForVirtualFunctionCall(CGF, GD, This, true); CGF.EmitCXXMemberCall(Dtor, CallLoc, Callee, ReturnValueSlot(), This, - ImplicitParam, Context.IntTy, 0, 0); + ImplicitParam, Context.IntTy, nullptr, nullptr); } const VBTableGlobals & @@ -1184,7 +1184,8 @@ void MicrosoftCXXABI::emitVBTableDefinition(const VPtrInfo &VBT, const ASTRecordLayout &DerivedLayout = CGM.getContext().getASTRecordLayout(RD); - SmallVector Offsets(1 + ReusingBase->getNumVBases(), 0); + SmallVector Offsets(1 + ReusingBase->getNumVBases(), + nullptr); // The offset from ReusingBase's vbptr to itself always leads. CharUnits VBPtrOffset = BaseLayout.getVBPtrOffset(); @@ -1204,7 +1205,7 @@ void MicrosoftCXXABI::emitVBTableDefinition(const VPtrInfo &VBT, Offset -= CompleteVBPtrOffset; unsigned VBIndex = Context.getVBTableIndex(ReusingBase, VBase); - assert(Offsets[VBIndex] == 0 && "The same vbindex seen twice?"); + assert(Offsets[VBIndex] == nullptr && "The same vbindex seen twice?"); Offsets[VBIndex] = llvm::ConstantInt::get(CGM.IntTy, Offset.getQuantity()); } @@ -1382,7 +1383,7 @@ void MicrosoftCXXABI::EmitGuardedInit(CodeGenFunction &CGF, const VarDecl &D, if (D.isExternallyVisible()) ErrorUnsupportedABI(CGF, "more than 32 guarded initializations"); BitIndex %= 32; - GI->Guard = 0; + GI->Guard = nullptr; } // Lazily create the i32 bitfield for this function. @@ -1664,7 +1665,7 @@ MicrosoftCXXABI::EmitMemberPointerComparison(CodeGenFunction &CGF, llvm::Value *Cmp0 = Builder.CreateICmp(Eq, L0, R0, "memptr.cmp.first"); // Compare everything other than the first field. - llvm::Value *Res = 0; + llvm::Value *Res = nullptr; llvm::StructType *LType = cast(L->getType()); for (unsigned I = 1, E = LType->getNumElements(); I != E; ++I) { llvm::Value *LF = Builder.CreateExtractValue(L, I); @@ -1779,9 +1780,9 @@ llvm::Value *MicrosoftCXXABI::AdjustVirtualBase( llvm::Value *Base, llvm::Value *VBTableOffset, llvm::Value *VBPtrOffset) { CGBuilderTy &Builder = CGF.Builder; Base = Builder.CreateBitCast(Base, CGM.Int8PtrTy); - llvm::BasicBlock *OriginalBB = 0; - llvm::BasicBlock *SkipAdjustBB = 0; - llvm::BasicBlock *VBaseAdjustBB = 0; + llvm::BasicBlock *OriginalBB = nullptr; + llvm::BasicBlock *SkipAdjustBB = nullptr; + llvm::BasicBlock *VBaseAdjustBB = nullptr; // In the unspecified inheritance model, there might not be a vbtable at all, // in which case we need to skip the virtual base lookup. If there is a @@ -1813,7 +1814,7 @@ llvm::Value *MicrosoftCXXABI::AdjustVirtualBase( offs = getContext().getASTRecordLayout(RD).getVBPtrOffset(); VBPtrOffset = llvm::ConstantInt::get(CGM.IntTy, offs.getQuantity()); } - llvm::Value *VBPtr = 0; + llvm::Value *VBPtr = nullptr; llvm::Value *VBaseOffs = GetVBaseOffsetFromVBPtr(CGF, Base, VBPtrOffset, VBTableOffset, &VBPtr); llvm::Value *AdjustedBase = Builder.CreateInBoundsGEP(VBPtr, VBaseOffs); @@ -1844,8 +1845,8 @@ llvm::Value *MicrosoftCXXABI::EmitMemberDataPointerAddress( // Extract the fields we need, regardless of model. We'll apply them if we // have them. llvm::Value *FieldOffset = MemPtr; - llvm::Value *VirtualBaseAdjustmentOffset = 0; - llvm::Value *VBPtrOffset = 0; + llvm::Value *VirtualBaseAdjustmentOffset = nullptr; + llvm::Value *VBPtrOffset = nullptr; if (MemPtr->getType()->isStructTy()) { // We need to extract values. unsigned I = 0; @@ -1931,9 +1932,9 @@ MicrosoftCXXABI::EmitMemberPointerConversion(CodeGenFunction &CGF, // Decompose src. llvm::Value *FirstField = Src; - llvm::Value *NonVirtualBaseAdjustment = 0; - llvm::Value *VirtualBaseAdjustmentOffset = 0; - llvm::Value *VBPtrOffset = 0; + llvm::Value *NonVirtualBaseAdjustment = nullptr; + llvm::Value *VirtualBaseAdjustmentOffset = nullptr; + llvm::Value *VBPtrOffset = nullptr; MSInheritanceAttr::Spelling SrcInheritance = SrcRD->getMSInheritanceModel(); if (!MSInheritanceAttr::hasOnlyOneField(IsFunc, SrcInheritance)) { // We need to extract values. @@ -2016,9 +2017,9 @@ MicrosoftCXXABI::EmitMemberPointerConversion(const CastExpr *E, // Decompose src. llvm::Constant *FirstField = Src; - llvm::Constant *NonVirtualBaseAdjustment = 0; - llvm::Constant *VirtualBaseAdjustmentOffset = 0; - llvm::Constant *VBPtrOffset = 0; + llvm::Constant *NonVirtualBaseAdjustment = nullptr; + llvm::Constant *VirtualBaseAdjustmentOffset = nullptr; + llvm::Constant *VBPtrOffset = nullptr; bool IsFunc = SrcTy->isMemberFunctionPointer(); if (!MSInheritanceAttr::hasOnlyOneField(IsFunc, SrcInheritance)) { // We need to extract values. @@ -2082,9 +2083,9 @@ llvm::Value *MicrosoftCXXABI::EmitLoadOfMemberFunctionPointer( // Extract the fields we need, regardless of model. We'll apply them if we // have them. llvm::Value *FunctionPointer = MemPtr; - llvm::Value *NonVirtualBaseAdjustment = NULL; - llvm::Value *VirtualBaseAdjustmentOffset = NULL; - llvm::Value *VBPtrOffset = NULL; + llvm::Value *NonVirtualBaseAdjustment = nullptr; + llvm::Value *VirtualBaseAdjustmentOffset = nullptr; + llvm::Value *VBPtrOffset = nullptr; if (MemPtr->getType()->isStructTy()) { // We need to extract values. unsigned I = 0; diff --git a/lib/CodeGen/TargetInfo.cpp b/lib/CodeGen/TargetInfo.cpp index 070896c70c..52e41322de 100644 --- a/lib/CodeGen/TargetInfo.cpp +++ b/lib/CodeGen/TargetInfo.cpp @@ -217,13 +217,13 @@ static bool isEmptyRecord(ASTContext &Context, QualType T, bool AllowArrays) { static const Type *isSingleElementStruct(QualType T, ASTContext &Context) { const RecordType *RT = T->getAsStructureType(); if (!RT) - return 0; + return nullptr; const RecordDecl *RD = RT->getDecl(); if (RD->hasFlexibleArrayMember()) - return 0; + return nullptr; - const Type *Found = 0; + const Type *Found = nullptr; // If this is a C++ record, check the bases first. if (const CXXRecordDecl *CXXRD = dyn_cast(RD)) { @@ -234,13 +234,13 @@ static const Type *isSingleElementStruct(QualType T, ASTContext &Context) { // If we already found an element then this isn't a single-element struct. if (Found) - return 0; + return nullptr; // If this is non-empty and not a single element struct, the composite // cannot be a single element struct. Found = isSingleElementStruct(I.getType(), Context); if (!Found) - return 0; + return nullptr; } } @@ -255,7 +255,7 @@ static const Type *isSingleElementStruct(QualType T, ASTContext &Context) { // If we already found an element then this isn't a single-element // struct. if (Found) - return 0; + return nullptr; // Treat single element arrays as the element. while (const ConstantArrayType *AT = Context.getAsConstantArrayType(FT)) { @@ -269,14 +269,14 @@ static const Type *isSingleElementStruct(QualType T, ASTContext &Context) { } else { Found = isSingleElementStruct(FT, Context); if (!Found) - return 0; + return nullptr; } } // We don't consider a struct a single-element struct if it has // padding beyond the element type. if (Found && Context.getTypeSize(Found) != Context.getTypeSize(T)) - return 0; + return nullptr; return Found; } @@ -372,7 +372,7 @@ public: llvm::Value *DefaultABIInfo::EmitVAArg(llvm::Value *VAListAddr, QualType Ty, CodeGenFunction &CGF) const { - return 0; + return nullptr; } ABIArgInfo DefaultABIInfo::classifyArgumentType(QualType Ty) const { @@ -437,7 +437,7 @@ void PNaClABIInfo::computeInfo(CGFunctionInfo &FI) const { llvm::Value *PNaClABIInfo::EmitVAArg(llvm::Value *VAListAddr, QualType Ty, CodeGenFunction &CGF) const { - return 0; + return nullptr; } /// \brief Classify argument of given type \p Ty. @@ -488,7 +488,7 @@ static llvm::Type* X86AdjustInlineAsmType(CodeGen::CodeGenFunction &CGF, if ((Constraint == "y" || Constraint == "&y") && Ty->isVectorTy()) { if (cast(Ty)->getBitWidth() != 64) { // Invalid MMX constraint - return 0; + return nullptr; } return llvm::Type::getX86_MMXTy(CGF.getLLVMContext()); @@ -900,7 +900,7 @@ ABIArgInfo X86_32ABIInfo::classifyArgumentType(QualType Ty, llvm::Type *Result = llvm::StructType::get(LLVMContext, Elements); return ABIArgInfo::getDirectInReg(Result); } - llvm::IntegerType *PaddingType = NeedsPadding ? Int32 : 0; + llvm::IntegerType *PaddingType = NeedsPadding ? Int32 : nullptr; // Expand small (<= 128-bit) record types when we know that the stack layout // of those arguments will match the struct. This is important because the @@ -2164,7 +2164,7 @@ classifyReturnType(QualType RetTy) const { assert((Hi != Memory || Lo == Memory) && "Invalid memory classification."); assert((Hi != SSEUp || Lo == SSE) && "Invalid SSEUp classification."); - llvm::Type *ResType = 0; + llvm::Type *ResType = nullptr; switch (Lo) { case NoClass: if (Hi == NoClass) @@ -2225,7 +2225,7 @@ classifyReturnType(QualType RetTy) const { break; } - llvm::Type *HighPart = 0; + llvm::Type *HighPart = nullptr; switch (Hi) { // Memory was handled previously and X87 should // never occur as a hi class. @@ -2297,7 +2297,7 @@ ABIArgInfo X86_64ABIInfo::classifyArgumentType( neededInt = 0; neededSSE = 0; - llvm::Type *ResType = 0; + llvm::Type *ResType = nullptr; switch (Lo) { case NoClass: if (Hi == NoClass) @@ -2358,7 +2358,7 @@ ABIArgInfo X86_64ABIInfo::classifyArgumentType( } } - llvm::Type *HighPart = 0; + llvm::Type *HighPart = nullptr; switch (Hi) { // Memory was handled previously, ComplexX87 and X87 should // never occur as hi classes, and X87Up must be preceded by X87, @@ -2533,9 +2533,9 @@ llvm::Value *X86_64ABIInfo::EmitVAArg(llvm::Value *VAListAddr, QualType Ty, // NOTE: 304 is a typo, there are (6 * 8 + 8 * 16) = 176 bytes of // register save space). - llvm::Value *InRegs = 0; - llvm::Value *gp_offset_p = 0, *gp_offset = 0; - llvm::Value *fp_offset_p = 0, *fp_offset = 0; + llvm::Value *InRegs = nullptr; + llvm::Value *gp_offset_p = nullptr, *gp_offset = nullptr; + llvm::Value *fp_offset_p = nullptr, *fp_offset = nullptr; if (neededInt) { gp_offset_p = CGF.Builder.CreateStructGEP(VAListAddr, 0, "gp_offset_p"); gp_offset = CGF.Builder.CreateLoad(gp_offset_p, "gp_offset"); @@ -3229,7 +3229,7 @@ public: static bool isHomogeneousAggregate(QualType Ty, const Type *&Base, ASTContext &Context, - uint64_t *HAMembers = 0); + uint64_t *HAMembers = nullptr); ABIArgInfo ARM64ABIInfo::classifyArgumentType(QualType Ty, unsigned &AllocatedVFP, @@ -3308,7 +3308,7 @@ ABIArgInfo ARM64ABIInfo::classifyArgumentType(QualType Ty, } // Homogeneous Floating-point Aggregates (HFAs) need to be expanded. - const Type *Base = 0; + const Type *Base = nullptr; uint64_t Members = 0; if (isHomogeneousAggregate(Ty, Base, getContext(), &Members)) { IsHA = true; @@ -3367,7 +3367,7 @@ ABIArgInfo ARM64ABIInfo::classifyReturnType(QualType RetTy) const { if (isEmptyRecord(getContext(), RetTy, true)) return ABIArgInfo::getIgnore(); - const Type *Base = 0; + const Type *Base = nullptr; if (isHomogeneousAggregate(RetTy, Base, getContext())) // Homogeneous Floating-point Aggregates (HFAs) are returned directly. return ABIArgInfo::getDirect(); @@ -3416,7 +3416,7 @@ static llvm::Value *EmitAArch64VAArg(llvm::Value *VAListAddr, QualType Ty, llvm::BasicBlock *ContBlock = CGF.createBasicBlock("vaarg.end"); auto &Ctx = CGF.getContext(); - llvm::Value *reg_offs_p = 0, *reg_offs = 0; + llvm::Value *reg_offs_p = nullptr, *reg_offs = nullptr; int reg_top_index; int RegSize; if (AllocatedGPR) { @@ -3443,7 +3443,7 @@ static llvm::Value *EmitAArch64VAArg(llvm::Value *VAListAddr, QualType Ty, // argument. We don't want to keep updating reg_offs (in case it overflows, // though anyone passing 2GB of arguments, each at most 16 bytes, deserves // whatever they get). - llvm::Value *UsingStack = 0; + llvm::Value *UsingStack = nullptr; UsingStack = CGF.Builder.CreateICmpSGE( reg_offs, llvm::ConstantInt::get(CGF.Int32Ty, 0)); @@ -3468,14 +3468,14 @@ static llvm::Value *EmitAArch64VAArg(llvm::Value *VAListAddr, QualType Ty, } // Update the gr_offs/vr_offs pointer for next call to va_arg on this va_list. - llvm::Value *NewOffset = 0; + llvm::Value *NewOffset = nullptr; NewOffset = CGF.Builder.CreateAdd( reg_offs, llvm::ConstantInt::get(CGF.Int32Ty, RegSize), "new_reg_offs"); CGF.Builder.CreateStore(NewOffset, reg_offs_p); // Now we're in a position to decide whether this argument really was in // registers or not. - llvm::Value *InRegs = 0; + llvm::Value *InRegs = nullptr; InRegs = CGF.Builder.CreateICmpSLE( NewOffset, llvm::ConstantInt::get(CGF.Int32Ty, 0), "inreg"); @@ -3489,12 +3489,12 @@ static llvm::Value *EmitAArch64VAArg(llvm::Value *VAListAddr, QualType Ty, // registers. First start the appropriate block: CGF.EmitBlock(InRegBlock); - llvm::Value *reg_top_p = 0, *reg_top = 0; + llvm::Value *reg_top_p = nullptr, *reg_top = nullptr; reg_top_p = CGF.Builder.CreateStructGEP(VAListAddr, reg_top_index, "reg_top_p"); reg_top = CGF.Builder.CreateLoad(reg_top_p, "reg_top"); llvm::Value *BaseAddr = CGF.Builder.CreateGEP(reg_top, reg_offs); - llvm::Value *RegAddr = 0; + llvm::Value *RegAddr = nullptr; llvm::Type *MemTy = llvm::PointerType::getUnqual(CGF.ConvertTypeForMem(Ty)); if (IsIndirect) { @@ -3503,7 +3503,7 @@ static llvm::Value *EmitAArch64VAArg(llvm::Value *VAListAddr, QualType Ty, MemTy = llvm::PointerType::getUnqual(MemTy); } - const Type *Base = 0; + const Type *Base = nullptr; uint64_t NumMembers; bool IsHFA = isHomogeneousAggregate(Ty, Base, Ctx, &NumMembers); if (IsHFA && NumMembers > 1) { @@ -3557,7 +3557,7 @@ static llvm::Value *EmitAArch64VAArg(llvm::Value *VAListAddr, QualType Ty, //======================================= CGF.EmitBlock(OnStackBlock); - llvm::Value *stack_p = 0, *OnStackAddr = 0; + llvm::Value *stack_p = nullptr, *OnStackAddr = nullptr; stack_p = CGF.Builder.CreateStructGEP(VAListAddr, 0, "stack_p"); OnStackAddr = CGF.Builder.CreateLoad(stack_p, "stack"); @@ -3642,12 +3642,12 @@ llvm::Value *ARM64ABIInfo::EmitDarwinVAArg(llvm::Value *VAListAddr, QualType Ty, // Lower VAArg here for these cases and use the LLVM va_arg instruction for // other cases. if (!isAggregateTypeForABI(Ty) && !isIllegalVectorType(Ty)) - return 0; + return nullptr; uint64_t Size = CGF.getContext().getTypeSize(Ty) / 8; uint64_t Align = CGF.getContext().getTypeAlign(Ty) / 8; - const Type *Base = 0; + const Type *Base = nullptr; bool isHA = isHomogeneousAggregate(Ty, Base, getContext()); bool isIndirect = false; @@ -4161,7 +4161,7 @@ ABIArgInfo ARMABIInfo::classifyArgumentType(QualType Ty, bool isVariadic, if (getABIKind() == ARMABIInfo::AAPCS_VFP && !isVariadic) { // Homogeneous Aggregates need to be expanded when we can fit the aggregate // into VFP registers. - const Type *Base = 0; + const Type *Base = nullptr; uint64_t Members = 0; if (isHomogeneousAggregate(Ty, Base, getContext(), &Members)) { assert(Base && "Base class should be set for homogeneous aggregate"); @@ -4360,7 +4360,7 @@ ABIArgInfo ARMABIInfo::classifyReturnType(QualType RetTy, // Check for homogeneous aggregates with AAPCS-VFP. if (getABIKind() == AAPCS_VFP && !isVariadic) { - const Type *Base = 0; + const Type *Base = nullptr; if (isHomogeneousAggregate(RetTy, Base, getContext())) { assert(Base && "Base class should be set for homogeneous aggregate"); // Homogeneous Aggregates are returned directly. @@ -4529,7 +4529,7 @@ private: int &FreeVFPRegs) const; ABIArgInfo tryUseRegs(QualType Ty, int &FreeRegs, int RegsNeeded, bool IsInt, - llvm::Type *DirectTy = 0) const; + llvm::Type *DirectTy = nullptr) const; void computeInfo(CGFunctionInfo &FI) const override; @@ -4588,7 +4588,7 @@ AArch64ABIInfo::tryUseRegs(QualType Ty, int &FreeRegs, int RegsNeeded, return ABIArgInfo::getDirect(DirectTy); } - llvm::Type *Padding = 0; + llvm::Type *Padding = nullptr; // We need padding so that later arguments don't get filled in anyway. That // wouldn't happen if only ByVal arguments followed in the same category, but @@ -4675,7 +4675,7 @@ ABIArgInfo AArch64ABIInfo::classifyGenericType(QualType Ty, } // Homogeneous vector aggregates get passed in registers or on the stack. - const Type *Base = 0; + const Type *Base = nullptr; uint64_t NumMembers = 0; if (isHomogeneousAggregate(Ty, Base, getContext(), &NumMembers)) { assert(Base && "Base class should be set for homogeneous aggregate"); @@ -5180,7 +5180,7 @@ ABIArgInfo SystemZABIInfo::classifyArgumentType(QualType Ty) const { if (isCompoundType(Ty)) return ABIArgInfo::getIndirect(0, /*ByVal=*/false); - return ABIArgInfo::getDirect(0); + return ABIArgInfo::getDirect(nullptr); } //===----------------------------------------------------------------------===// @@ -5357,7 +5357,7 @@ llvm::Type* MipsABIInfo::HandleAggregates(QualType Ty, uint64_t TySize) const { llvm::Type *MipsABIInfo::getPaddingType(uint64_t OrigOffset, uint64_t Offset) const { if (OrigOffset + MinABIStackAlignInBytes > Offset) - return 0; + return nullptr; return llvm::IntegerType::get(getVMContext(), (Offset - OrigOffset) * 8); } @@ -5398,7 +5398,7 @@ MipsABIInfo::classifyArgumentType(QualType Ty, uint64_t &Offset) const { return ABIArgInfo::getExtend(); return ABIArgInfo::getDirect( - 0, 0, IsO32 ? 0 : getPaddingType(OrigOffset, CurrOffset)); + nullptr, 0, IsO32 ? nullptr : getPaddingType(OrigOffset, CurrOffset)); } llvm::Type* diff --git a/lib/CodeGen/TargetInfo.h b/lib/CodeGen/TargetInfo.h index 6b99310861..2616820185 100644 --- a/lib/CodeGen/TargetInfo.h +++ b/lib/CodeGen/TargetInfo.h @@ -151,7 +151,7 @@ public: /// possessing type information, or 0 if the platform is unsupported. virtual llvm::Constant * getUBSanFunctionSignature(CodeGen::CodeGenModule &CGM) const { - return 0; + return nullptr; } /// Determine whether a call to an unprototyped functions under