diff options
author | Craig Topper <craig.topper@gmail.com> | 2014-05-26 06:22:03 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2014-05-26 06:22:03 +0000 |
commit | c3ec149bb238ce4640ebaa8b499807264c15276f (patch) | |
tree | 7ccc6685888fe48e68fbc723df92c37048e13273 /clang/lib/Sema/SemaInit.cpp | |
parent | 236bde3d6f589dd7011d052aea4d98f610efb419 (diff) | |
download | bcm5719-llvm-c3ec149bb238ce4640ebaa8b499807264c15276f.tar.gz bcm5719-llvm-c3ec149bb238ce4640ebaa8b499807264c15276f.zip |
[C++11] Use 'nullptr'. Sema edition.
llvm-svn: 209613
Diffstat (limited to 'clang/lib/Sema/SemaInit.cpp')
-rw-r--r-- | clang/lib/Sema/SemaInit.cpp | 103 |
1 files changed, 53 insertions, 50 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index fe1f7c8e746..a16960213eb 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -69,7 +69,7 @@ static StringInitFailureKind IsStringInit(Expr *Init, const ArrayType *AT, // Otherwise we can only handle string literals. StringLiteral *SL = dyn_cast<StringLiteral>(Init); - if (SL == 0) + if (!SL) return SIF_Other; const QualType ElemTy = @@ -498,7 +498,7 @@ InitListChecker::FillInValueInitializations(const InitializedEntity &Entity, ElementEntity.getKind() == InitializedEntity::EK_VectorElement) ElementEntity.setElementIndex(Init); - Expr *InitExpr = (Init < NumInits ? ILE->getInit(Init) : 0); + Expr *InitExpr = (Init < NumInits ? ILE->getInit(Init) : nullptr); if (!InitExpr && !ILE->hasArrayFiller()) { InitializationKind Kind = InitializationKind::CreateValue(Loc, Loc, Loc, true); @@ -556,7 +556,7 @@ InitListChecker::InitListChecker(Sema &S, const InitializedEntity &Entity, hadError = false; FullyStructuredList = - getStructuredSubobjectInit(IL, 0, T, 0, 0, IL->getSourceRange()); + getStructuredSubobjectInit(IL, 0, T, nullptr, 0, IL->getSourceRange()); CheckExplicitInitList(Entity, IL, T, FullyStructuredList, /*TopLevelObject=*/true); @@ -1030,7 +1030,7 @@ void InitListChecker::CheckScalarType(const InitializedEntity &Entity, SemaRef.Owned(expr), /*TopLevelOfInitList=*/true); - Expr *ResultExpr = 0; + Expr *ResultExpr = nullptr; if (Result.isInvalid()) hadError = true; // types weren't compatible. @@ -1141,7 +1141,7 @@ void InitListChecker::CheckVectorType(const InitializedEntity &Entity, SemaRef.Owned(Init), /*TopLevelOfInitList=*/true); - Expr *ResultExpr = 0; + Expr *ResultExpr = nullptr; if (Result.isInvalid()) hadError = true; // types weren't compatible. else { @@ -1287,7 +1287,7 @@ void InitListChecker::CheckArrayType(const InitializedEntity &Entity, // Handle this designated initializer. elementIndex will be // updated to be the next array element we'll initialize. if (CheckDesignatedInitializer(Entity, IList, DIE, 0, - DeclType, 0, &elementIndex, Index, + DeclType, nullptr, &elementIndex, Index, StructuredList, StructuredIndex, true, false)) { hadError = true; @@ -1462,7 +1462,7 @@ void InitListChecker::CheckStructUnionTypes(const InitializedEntity &Entity, // Handle this designated initializer. Field will be updated to // the next field that we'll be initializing. if (CheckDesignatedInitializer(Entity, IList, DIE, 0, - DeclType, &Field, 0, Index, + DeclType, &Field, nullptr, Index, StructuredList, StructuredIndex, true, TopLevelObject)) hadError = true; @@ -1586,12 +1586,12 @@ static void ExpandAnonymousFieldDesignator(Sema &SemaRef, for (IndirectFieldDecl::chain_iterator PI = IndirectField->chain_begin(), PE = IndirectField->chain_end(); PI != PE; ++PI) { if (PI + 1 == PE) - Replacements.push_back(Designator((IdentifierInfo *)0, + Replacements.push_back(Designator((IdentifierInfo *)nullptr, DIE->getDesignator(DesigIdx)->getDotLoc(), DIE->getDesignator(DesigIdx)->getFieldLoc())); else - Replacements.push_back(Designator((IdentifierInfo *)0, SourceLocation(), - SourceLocation())); + Replacements.push_back(Designator((IdentifierInfo *)nullptr, + SourceLocation(), SourceLocation())); assert(isa<FieldDecl>(*PI)); Replacements.back().setField(cast<FieldDecl>(*PI)); } @@ -1608,7 +1608,7 @@ static void ExpandAnonymousFieldDesignator(Sema &SemaRef, static IndirectFieldDecl *FindIndirectFieldDesignator(FieldDecl *AnonField, IdentifierInfo *FieldName) { if (!FieldName) - return 0; + return nullptr; assert(AnonField->isAnonymousStructOrUnion()); Decl *NextDecl = AnonField->getNextDeclInContext(); @@ -1618,7 +1618,7 @@ static IndirectFieldDecl *FindIndirectFieldDesignator(FieldDecl *AnonField, return IF; NextDecl = NextDecl->getNextDeclInContext(); } - return 0; + return nullptr; } static DesignatedInitExpr *CloneDesignatedInitExpr(Sema &SemaRef, @@ -1807,15 +1807,15 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity, // may find nothing, or may find a member of an anonymous // struct/union. DeclContext::lookup_result Lookup = RT->getDecl()->lookup(FieldName); - FieldDecl *ReplacementField = 0; + FieldDecl *ReplacementField = nullptr; if (Lookup.empty()) { // Name lookup didn't find anything. Determine whether this // was a typo for another field name. FieldInitializerValidatorCCC Validator(RT->getDecl()); if (TypoCorrection Corrected = SemaRef.CorrectTypo( DeclarationNameInfo(FieldName, D->getFieldLoc()), - Sema::LookupMemberName, /*Scope=*/ 0, /*SS=*/ 0, Validator, - Sema::CTK_ErrorRecovery, RT->getDecl())) { + Sema::LookupMemberName, /*Scope=*/ nullptr, /*SS=*/ nullptr, + Validator, Sema::CTK_ErrorRecovery, RT->getDecl())) { SemaRef.diagnoseTypo( Corrected, SemaRef.PDiag(diag::err_field_designator_unknown_suggest) @@ -1880,7 +1880,7 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity, // remove existing initializer StructuredList->resizeInits(SemaRef.Context, 0); - StructuredList->setInitializedFieldInUnion(0); + StructuredList->setInitializedFieldInUnion(nullptr); } StructuredList->setInitializedFieldInUnion(*Field); @@ -1978,7 +1978,7 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity, InitializedEntity MemberEntity = InitializedEntity::InitializeMember(*Field, &Entity); if (CheckDesignatedInitializer(MemberEntity, IList, DIE, DesigIdx + 1, - FieldType, 0, 0, Index, + FieldType, nullptr, nullptr, Index, StructuredList, newStructuredIndex, true, false)) return true; @@ -2037,7 +2037,7 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity, return true; } - Expr *IndexExpr = 0; + Expr *IndexExpr = nullptr; llvm::APSInt DesignatedStartIndex, DesignatedEndIndex; if (D->isArrayDesignator()) { IndexExpr = DIE->getArrayIndex(*D); @@ -2122,7 +2122,7 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity, Context, CodeUnit, PromotedCharTy, SubExpr->getExprLoc()); if (CharTy != PromotedCharTy) Init = ImplicitCastExpr::Create(Context, CharTy, CK_IntegralCast, - Init, 0, VK_RValue); + Init, nullptr, VK_RValue); StructuredList->updateInit(Context, i, Init); } } else { @@ -2144,7 +2144,7 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity, Context, CodeUnit, PromotedCharTy, SubExpr->getExprLoc()); if (CharTy != PromotedCharTy) Init = ImplicitCastExpr::Create(Context, CharTy, CK_IntegralCast, - Init, 0, VK_RValue); + Init, nullptr, VK_RValue); StructuredList->updateInit(Context, i, Init); } } @@ -2174,7 +2174,7 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity, ElementEntity.setElementIndex(ElementIndex); if (CheckDesignatedInitializer(ElementEntity, IList, DIE, DesigIdx + 1, - ElementType, 0, 0, Index, + ElementType, nullptr, nullptr, Index, StructuredList, ElementIndex, (DesignatedStartIndex == DesignatedEndIndex), false)) @@ -2214,8 +2214,8 @@ InitListChecker::getStructuredSubobjectInit(InitListExpr *IList, unsigned Index, unsigned StructuredIndex, SourceRange InitRange) { if (VerifyOnly) - return 0; // No structured list in verification-only mode. - Expr *ExistingInit = 0; + return nullptr; // No structured list in verification-only mode. + Expr *ExistingInit = nullptr; if (!StructuredList) ExistingInit = SyntacticToSemantic.lookup(IList); else if (StructuredIndex < StructuredList->getNumInits()) @@ -2477,7 +2477,7 @@ InitializedEntity::InitializeBase(ASTContext &Context, bool IsInheritedVirtualBase) { InitializedEntity Result; Result.Kind = EK_Base; - Result.Parent = 0; + Result.Parent = nullptr; Result.Base = reinterpret_cast<uintptr_t>(Base); if (IsInheritedVirtualBase) Result.Base |= 0x01; @@ -2542,7 +2542,7 @@ DeclaratorDecl *InitializedEntity::getDecl() const { case EK_LambdaCapture: case EK_CompoundLiteralInit: case EK_RelatedResult: - return 0; + return nullptr; } llvm_unreachable("Invalid EntityKind!"); @@ -3019,7 +3019,7 @@ ResolveConstructorOverload(Sema &S, SourceLocation DeclLoc, bool SuppressUserConversions = false; // Find the constructor (which may be a template). - CXXConstructorDecl *Constructor = 0; + CXXConstructorDecl *Constructor = nullptr; FunctionTemplateDecl *ConstructorTmpl = dyn_cast<FunctionTemplateDecl>(D); if (ConstructorTmpl) Constructor = cast<CXXConstructorDecl>( @@ -3050,7 +3050,7 @@ ResolveConstructorOverload(Sema &S, SourceLocation DeclLoc, (!OnlyListConstructors || S.isInitListConstructor(Constructor))) { if (ConstructorTmpl) S.AddTemplateOverloadCandidate(ConstructorTmpl, FoundDecl, - /*ExplicitArgs*/ 0, Args, + /*ExplicitArgs*/ nullptr, Args, CandidateSet, SuppressUserConversions); else { // C++ [over.match.copy]p1: @@ -3236,7 +3236,7 @@ static void TryValueInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, InitializationSequence &Sequence, - InitListExpr *InitList = 0); + InitListExpr *InitList = nullptr); /// \brief Attempt list initialization of a reference. static void TryReferenceListInitialization(Sema &S, @@ -3435,7 +3435,7 @@ static OverloadingResult TryRefInitWithConversionFunction(Sema &S, bool AllowExplicit = Kind.AllowExplicit(); bool AllowExplicitConvs = Kind.allowExplicitConversionFunctionsInRefBinding(); - const RecordType *T1RecordType = 0; + const RecordType *T1RecordType = nullptr; if (AllowRValues && (T1RecordType = T1->getAs<RecordType>()) && !S.RequireCompleteType(Kind.getLocation(), T1, 0)) { // The type we're converting to is a class type. Enumerate its constructors @@ -3453,7 +3453,7 @@ static OverloadingResult TryRefInitWithConversionFunction(Sema &S, DeclAccessPair FoundDecl = DeclAccessPair::make(D, D->getAccess()); // Find the constructor (which may be a template). - CXXConstructorDecl *Constructor = 0; + CXXConstructorDecl *Constructor = nullptr; FunctionTemplateDecl *ConstructorTmpl = dyn_cast<FunctionTemplateDecl>(D); if (ConstructorTmpl) Constructor = cast<CXXConstructorDecl>( @@ -3465,7 +3465,7 @@ static OverloadingResult TryRefInitWithConversionFunction(Sema &S, Constructor->isConvertingConstructor(AllowExplicit)) { if (ConstructorTmpl) S.AddTemplateOverloadCandidate(ConstructorTmpl, FoundDecl, - /*ExplicitArgs*/ 0, + /*ExplicitArgs*/ nullptr, Initializer, CandidateSet, /*SuppressUserConversions=*/true); else @@ -3478,7 +3478,7 @@ static OverloadingResult TryRefInitWithConversionFunction(Sema &S, if (T1RecordType && T1RecordType->getDecl()->isInvalidDecl()) return OR_No_Viable_Function; - const RecordType *T2RecordType = 0; + const RecordType *T2RecordType = nullptr; if ((T2RecordType = T2->getAs<RecordType>()) && !S.RequireCompleteType(Kind.getLocation(), T2, 0)) { // The type we're converting from is a class type, enumerate its conversion @@ -4081,7 +4081,7 @@ static void TryUserDefinedConversion(Sema &S, DeclAccessPair FoundDecl = DeclAccessPair::make(D, D->getAccess()); // Find the constructor (which may be a template). - CXXConstructorDecl *Constructor = 0; + CXXConstructorDecl *Constructor = nullptr; FunctionTemplateDecl *ConstructorTmpl = dyn_cast<FunctionTemplateDecl>(D); if (ConstructorTmpl) @@ -4094,7 +4094,7 @@ static void TryUserDefinedConversion(Sema &S, Constructor->isConvertingConstructor(AllowExplicit)) { if (ConstructorTmpl) S.AddTemplateOverloadCandidate(ConstructorTmpl, FoundDecl, - /*ExplicitArgs*/ 0, + /*ExplicitArgs*/ nullptr, Initializer, CandidateSet, /*SuppressUserConversions=*/true); else @@ -4454,7 +4454,7 @@ void InitializationSequence::InitializeFrom(Sema &S, setSequenceKind(NormalSequence); QualType SourceType; - Expr *Initializer = 0; + Expr *Initializer = nullptr; if (Args.size() == 1) { Initializer = Args[0]; if (S.getLangOpts().ObjC1) { @@ -4816,7 +4816,7 @@ static void LookupCopyAndMoveConstructors(Sema &S, for (SmallVectorImpl<NamedDecl *>::iterator CI = Ctors.begin(), CE = Ctors.end(); CI != CE; ++CI) { NamedDecl *D = *CI; - CXXConstructorDecl *Constructor = 0; + CXXConstructorDecl *Constructor = nullptr; if ((Constructor = dyn_cast<CXXConstructorDecl>(D))) { // Handle copy/moveconstructors, only. @@ -4846,7 +4846,7 @@ static void LookupCopyAndMoveConstructors(Sema &S, // candidates? DeclAccessPair FoundDecl = DeclAccessPair::make(ConstructorTmpl, ConstructorTmpl->getAccess()); - S.AddTemplateOverloadCandidate(ConstructorTmpl, FoundDecl, 0, + S.AddTemplateOverloadCandidate(ConstructorTmpl, FoundDecl, nullptr, CurInitExpr, CandidateSet, true); } } @@ -4912,7 +4912,7 @@ static ExprResult CopyObject(Sema &S, bool IsExtraneousCopy) { // Determine which class type we're copying to. Expr *CurInitExpr = (Expr *)CurInit.get(); - CXXRecordDecl *Class = 0; + CXXRecordDecl *Class = nullptr; if (const RecordType *Record = T->getAs<RecordType>()) Class = cast<CXXRecordDecl>(Record->getDecl()); if (!Class) @@ -5169,7 +5169,7 @@ PerformConstructorInitialization(Sema &S, S.DefineImplicitDefaultConstructor(Loc, Constructor); } - ExprResult CurInit = S.Owned((Expr *)0); + ExprResult CurInit = S.Owned((Expr *)nullptr); // C++ [over.match.copy]p1: // - When initializing a temporary to be bound to the first parameter @@ -5312,7 +5312,7 @@ InitializedEntityOutlivesFullExpression(const InitializedEntity &Entity) { /// the initialization of \p Entity. static const InitializedEntity *getEntityForTemporaryLifetimeExtension( const InitializedEntity *Entity, - const InitializedEntity *FallbackDecl = 0) { + const InitializedEntity *FallbackDecl = nullptr) { // C++11 [class.temporary]p5: switch (Entity->getKind()) { case InitializedEntity::EK_Variable: @@ -5566,7 +5566,7 @@ InitializationSequence::Perform(Sema &S, *ResultType = S.Context.getDependentSizedArrayType(ArrayT->getElementType(), - /*NumElts=*/0, + /*NumElts=*/nullptr, ArrayT->getSizeModifier(), ArrayT->getIndexTypeCVRQualifiers(), Brackets); @@ -5589,7 +5589,7 @@ InitializationSequence::Perform(Sema &S, // No steps means no initialization. if (Steps.empty()) - return S.Owned((Expr *)0); + return S.Owned((Expr *)nullptr); if (S.getLangOpts().CPlusPlus11 && Entity.getType()->isReferenceType() && Args.size() == 1 && isa<InitListExpr>(Args[0]) && @@ -5622,7 +5622,7 @@ InitializationSequence::Perform(Sema &S, *ResultType = Entity.getDecl() ? Entity.getDecl()->getType() : Entity.getType(); - ExprResult CurInit = S.Owned((Expr *)0); + ExprResult CurInit = S.Owned((Expr *)nullptr); // For initialization steps that start with a single initializer, // grab the only argument out the Args and place it into the "current" @@ -5737,7 +5737,7 @@ InitializationSequence::Perform(Sema &S, S.Diag(Kind.getLocation(), diag::err_reference_bind_to_bitfield) << Entity.getType().isVolatileQualified() << (BitField ? BitField->getDeclName() : DeclarationName()) - << (BitField != NULL) + << (BitField != nullptr) << CurInit.get()->getSourceRange(); if (BitField) S.Diag(BitField->getLocation(), diag::note_bitfield_decl); @@ -5861,7 +5861,7 @@ InitializationSequence::Perform(Sema &S, } else { // Build a call to the conversion function. CXXConversionDecl *Conversion = cast<CXXConversionDecl>(Fn); - S.CheckMemberOperatorAccess(Kind.getLocation(), CurInit.get(), 0, + S.CheckMemberOperatorAccess(Kind.getLocation(), CurInit.get(), nullptr, FoundFn); if (S.DiagnoseUseOfDecl(FoundFn, Kind.getLocation())) return ExprError(); @@ -5870,7 +5870,8 @@ InitializationSequence::Perform(Sema &S, // derived-to-base conversion? I believe the answer is "no", because // we don't want to turn off access control here for c-style casts. ExprResult CurInitExprRes = - S.PerformObjectArgumentInitialization(CurInit.take(), /*Qualifier=*/0, + S.PerformObjectArgumentInitialization(CurInit.take(), + /*Qualifier=*/nullptr, FoundFn, Conversion); if(CurInitExprRes.isInvalid()) return ExprError(); @@ -5905,7 +5906,8 @@ InitializationSequence::Perform(Sema &S, CurInit = S.Owned(ImplicitCastExpr::Create(S.Context, CurInit.get()->getType(), - CastKind, CurInit.get(), 0, + CastKind, CurInit.get(), + nullptr, CurInit.get()->getValueKind())); if (MaybeBindToTemp) CurInit = S.MaybeBindToTemporary(CurInit.takeAs<Expr>()); @@ -5934,7 +5936,7 @@ InitializationSequence::Perform(Sema &S, CurInit = S.Owned(ImplicitCastExpr::Create(S.Context, Step->Type, CK_LValueToRValue, CurInit.take(), - /*BasePath=*/0, + /*BasePath=*/nullptr, VK_RValue)); break; } @@ -6171,7 +6173,8 @@ InitializationSequence::Perform(Sema &S, case SK_ProduceObjCObject: CurInit = S.Owned(ImplicitCastExpr::Create(S.Context, Step->Type, CK_ARCProduceObject, - CurInit.take(), 0, VK_RValue)); + CurInit.take(), nullptr, + VK_RValue)); break; case SK_StdInitializerList: { @@ -6977,7 +6980,7 @@ static void DiagnoseNarrowingInInitList(Sema &S, QualType PreNarrowingType, QualType EntityType, const Expr *PostInit) { - const StandardConversionSequence *SCS = 0; + const StandardConversionSequence *SCS = nullptr; switch (ICS.getKind()) { case ImplicitConversionSequence::StandardConversion: SCS = &ICS.Standard; |