[C++11] Use 'nullptr'. CodeGen edition.
llvm-svn: 209272
This commit is contained in:
@@ -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<VarDecl>(initializedGlobalDecl.getDecl()), Out);
|
||||
else if (const auto *CD = dyn_cast<CXXConstructorDecl>(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<llvm::GlobalValue>(Aliasee);
|
||||
F->setLinkage(llvm::Function::ExternalWeakLinkage);
|
||||
@@ -1187,7 +1190,7 @@ void CodeGenModule::EmitGlobal(GlobalDecl GD) {
|
||||
if (getLangOpts().CPlusPlus && isa<VarDecl>(Global) &&
|
||||
cast<VarDecl>(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<uint16_t> Arr =
|
||||
llvm::makeArrayRef<uint16_t>(reinterpret_cast<uint16_t*>(
|
||||
@@ -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<GlobalDecl,StringRef>::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<const Decl*, llvm::Value*>::iterator
|
||||
I = LocalDeclMap.begin(), E = LocalDeclMap.end(); I != E; ++I) {
|
||||
|
||||
Reference in New Issue
Block a user