From: Craig Topper Date: Mon, 26 May 2014 06:22:03 +0000 (+0000) Subject: [C++11] Use 'nullptr'. Sema edition. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c3ec149bb238ce4640ebaa8b499807264c15276f;p=platform%2Fupstream%2Fllvm.git [C++11] Use 'nullptr'. Sema edition. llvm-svn: 209613 --- diff --git a/clang/lib/Sema/AnalysisBasedWarnings.cpp b/clang/lib/Sema/AnalysisBasedWarnings.cpp index 048019f..7f2748e 100644 --- a/clang/lib/Sema/AnalysisBasedWarnings.cpp +++ b/clang/lib/Sema/AnalysisBasedWarnings.cpp @@ -241,7 +241,7 @@ static void checkRecursiveFunction(Sema &S, const FunctionDecl *FD, return; CFG *cfg = AC.getCFG(); - if (cfg == 0) return; + if (!cfg) return; // If the exit block is unreachable, skip processing the function. if (cfg->getExit().pred_empty()) @@ -282,7 +282,7 @@ enum ControlFlowKind { /// will return. static ControlFlowKind CheckFallThrough(AnalysisDeclContext &AC) { CFG *cfg = AC.getCFG(); - if (cfg == 0) return UnknownFallThrough; + if (!cfg) return UnknownFallThrough; // The CFG leaves in dead things, and we don't want the dead code paths to // confuse us, so we mark all live things first. @@ -1033,7 +1033,7 @@ namespace { if (hasSpecificAttr(AS->getAttrs())) return AS; } - return 0; + return nullptr; } static const Stmt *getLastStmt(const CFGBlock &B) { @@ -1052,7 +1052,7 @@ namespace { if (!isa(SW->getSubStmt())) return SW->getSubStmt(); - return 0; + return nullptr; } bool FoundSwitchStatements; @@ -1335,7 +1335,7 @@ class UninitValsDiagReporter : public UninitVariablesHandler { UsesMap *uses; public: - UninitValsDiagReporter(Sema &S) : S(S), uses(0) {} + UninitValsDiagReporter(Sema &S) : S(S), uses(nullptr) {} ~UninitValsDiagReporter() { flushDiagnostics(); } @@ -1783,7 +1783,7 @@ AnalysisBasedWarnings::IssueWarnings(sema::AnalysisBasedWarnings::Policy P, assert(Body); // Construct the analysis context with the specified CFG build options. - AnalysisDeclContext AC(/* AnalysisDeclContextManager */ 0, D); + AnalysisDeclContext AC(/* AnalysisDeclContextManager */ nullptr, D); // Don't generate EH edges for CallExprs as we'd like to avoid the n^2 // explosion for destructors that can result and the compile time hit. diff --git a/clang/lib/Sema/CodeCompleteConsumer.cpp b/clang/lib/Sema/CodeCompleteConsumer.cpp index 0049d4c..b2dc2d7 100644 --- a/clang/lib/Sema/CodeCompleteConsumer.cpp +++ b/clang/lib/Sema/CodeCompleteConsumer.cpp @@ -218,7 +218,7 @@ const char *CodeCompletionString::getAnnotation(unsigned AnnotationNr) const { if (AnnotationNr < NumAnnotations) return reinterpret_cast(end())[AnnotationNr]; else - return 0; + return nullptr; } @@ -247,8 +247,8 @@ const char *CodeCompletionString::getTypedText() const { for (iterator C = begin(), CEnd = end(); C != CEnd; ++C) if (C->Kind == CK_TypedText) return C->Text; - - return 0; + + return nullptr; } const char *CodeCompletionAllocator::CopyString(StringRef String) { @@ -278,7 +278,7 @@ StringRef CodeCompletionTUInfo::getParentName(const DeclContext *DC) { // If we already processed this DeclContext and assigned empty to it, the // data pointer will be non-null. - if (CachedParentName.data() != 0) + if (CachedParentName.data() != nullptr) return StringRef(); // Find the interesting names. @@ -405,7 +405,7 @@ CodeCompleteConsumer::OverloadCandidate::getFunction() const { else if (getKind() == CK_FunctionTemplate) return FunctionTemplate->getTemplatedDecl(); else - return 0; + return nullptr; } const FunctionType * diff --git a/clang/lib/Sema/DelayedDiagnostic.cpp b/clang/lib/Sema/DelayedDiagnostic.cpp index ddecfdb3..13a428c 100644 --- a/clang/lib/Sema/DelayedDiagnostic.cpp +++ b/clang/lib/Sema/DelayedDiagnostic.cpp @@ -40,7 +40,7 @@ DelayedDiagnostic::makeAvailability(Sema::AvailabilityDiagnostic AD, DD.DeprecationData.Decl = D; DD.DeprecationData.UnknownObjCClass = UnknownObjCClass; DD.DeprecationData.ObjCProperty = ObjCProperty; - char *MessageData = 0; + char *MessageData = nullptr; if (Msg.size()) { MessageData = new char [Msg.size()]; memcpy(MessageData, Msg.data(), Msg.size()); diff --git a/clang/lib/Sema/IdentifierResolver.cpp b/clang/lib/Sema/IdentifierResolver.cpp index 705fb07..2a5bacf 100644 --- a/clang/lib/Sema/IdentifierResolver.cpp +++ b/clang/lib/Sema/IdentifierResolver.cpp @@ -45,7 +45,7 @@ class IdentifierResolver::IdDeclInfoMap { unsigned int CurIndex; public: - IdDeclInfoMap() : CurPool(0), CurIndex(POOL_SIZE) {} + IdDeclInfoMap() : CurPool(nullptr), CurIndex(POOL_SIZE) {} ~IdDeclInfoMap() { IdDeclInfoPool *Cur = CurPool; @@ -151,7 +151,7 @@ void IdentifierResolver::AddDecl(NamedDecl *D) { IdDeclInfo *IDI; if (isDeclPtr(Ptr)) { - Name.setFETokenInfo(NULL); + Name.setFETokenInfo(nullptr); IDI = &(*IdDeclInfos)[Name]; NamedDecl *PrevD = static_cast(Ptr); IDI->AddDecl(PrevD); @@ -213,7 +213,7 @@ void IdentifierResolver::RemoveDecl(NamedDecl *D) { if (isDeclPtr(Ptr)) { assert(D == Ptr && "Didn't find this decl on its identifier's chain!"); - Name.setFETokenInfo(NULL); + Name.setFETokenInfo(nullptr); return; } @@ -314,8 +314,8 @@ bool IdentifierResolver::tryAddTopLevelDecl(NamedDecl *D, DeclarationName Name){ Name.setFETokenInfo(D); return true; } - - Name.setFETokenInfo(NULL); + + Name.setFETokenInfo(nullptr); IDI = &(*IdDeclInfos)[Name]; // If the existing declaration is not visible in translation unit scope, diff --git a/clang/lib/Sema/JumpDiagnostics.cpp b/clang/lib/Sema/JumpDiagnostics.cpp index 27bca15..f7d8788 100644 --- a/clang/lib/Sema/JumpDiagnostics.cpp +++ b/clang/lib/Sema/JumpDiagnostics.cpp @@ -348,7 +348,7 @@ void JumpScopeChecker::BuildScopeInformation(Stmt *S, unsigned &origParentScope) } Stmt *SubStmt = *CI; - if (SubStmt == 0) continue; + if (!SubStmt) continue; // Cases, labels, and defaults aren't "scope parents". It's also // important to handle these iteratively instead of recursively in diff --git a/clang/lib/Sema/MultiplexExternalSemaSource.cpp b/clang/lib/Sema/MultiplexExternalSemaSource.cpp index 35072a5..97237db 100644 --- a/clang/lib/Sema/MultiplexExternalSemaSource.cpp +++ b/clang/lib/Sema/MultiplexExternalSemaSource.cpp @@ -46,7 +46,7 @@ Decl *MultiplexExternalSemaSource::GetExternalDecl(uint32_t ID) { for(size_t i = 0; i < Sources.size(); ++i) if (Decl *Result = Sources[i]->GetExternalDecl(ID)) return Result; - return 0; + return nullptr; } void MultiplexExternalSemaSource::CompleteRedeclChain(const Decl *D) { @@ -75,7 +75,7 @@ Stmt *MultiplexExternalSemaSource::GetExternalDeclStmt(uint64_t Offset) { for(size_t i = 0; i < Sources.size(); ++i) if (Stmt *Result = Sources[i]->GetExternalDeclStmt(Offset)) return Result; - return 0; + return nullptr; } CXXBaseSpecifier *MultiplexExternalSemaSource::GetExternalCXXBaseSpecifiers( @@ -83,7 +83,7 @@ CXXBaseSpecifier *MultiplexExternalSemaSource::GetExternalCXXBaseSpecifiers( for(size_t i = 0; i < Sources.size(); ++i) if (CXXBaseSpecifier *R = Sources[i]->GetExternalCXXBaseSpecifiers(Offset)) return R; - return 0; + return nullptr; } bool MultiplexExternalSemaSource:: diff --git a/clang/lib/Sema/Scope.cpp b/clang/lib/Sema/Scope.cpp index 8e339d7..278b087 100644 --- a/clang/lib/Sema/Scope.cpp +++ b/clang/lib/Sema/Scope.cpp @@ -28,7 +28,7 @@ void Scope::Init(Scope *parent, unsigned flags) { } else { // Control scopes do not contain the contents of nested function scopes for // control flow purposes. - BreakParent = ContinueParent = 0; + BreakParent = ContinueParent = nullptr; } if (parent) { @@ -43,8 +43,8 @@ void Scope::Init(Scope *parent, unsigned flags) { Depth = 0; PrototypeDepth = 0; PrototypeIndex = 0; - MSLocalManglingParent = FnParent = BlockParent = 0; - TemplateParamParent = 0; + MSLocalManglingParent = FnParent = BlockParent = nullptr; + TemplateParamParent = nullptr; MSLocalManglingNumber = 1; } @@ -76,7 +76,7 @@ void Scope::Init(Scope *parent, unsigned flags) { DeclsInScope.clear(); UsingDirectives.clear(); - Entity = 0; + Entity = nullptr; ErrorTrap.reset(); NRVO.setPointerAndInt(nullptr, 0); } diff --git a/clang/lib/Sema/ScopeInfo.cpp b/clang/lib/Sema/ScopeInfo.cpp index 1e54c5a..d9b2ca3 100644 --- a/clang/lib/Sema/ScopeInfo.cpp +++ b/clang/lib/Sema/ScopeInfo.cpp @@ -51,7 +51,7 @@ FunctionScopeInfo::WeakObjectProfileTy::BaseInfoTy FunctionScopeInfo::WeakObjectProfileTy::getBaseInfo(const Expr *E) { E = E->IgnoreParenCasts(); - const NamedDecl *D = 0; + const NamedDecl *D = nullptr; bool IsExact = false; switch (E->getStmtClass()) { @@ -93,10 +93,9 @@ FunctionScopeInfo::WeakObjectProfileTy::getBaseInfo(const Expr *E) { return BaseInfoTy(D, IsExact); } - FunctionScopeInfo::WeakObjectProfileTy::WeakObjectProfileTy( const ObjCPropertyRefExpr *PropE) - : Base(0, true), Property(getBestPropertyDecl(PropE)) { + : Base(nullptr, true), Property(getBestPropertyDecl(PropE)) { if (PropE->isObjectReceiver()) { const OpaqueValueExpr *OVE = cast(PropE->getBase()); @@ -111,7 +110,7 @@ FunctionScopeInfo::WeakObjectProfileTy::WeakObjectProfileTy( FunctionScopeInfo::WeakObjectProfileTy::WeakObjectProfileTy(const Expr *BaseE, const ObjCPropertyDecl *Prop) - : Base(0, true), Property(Prop) { + : Base(nullptr, true), Property(Prop) { if (BaseE) Base = getBaseInfo(BaseE); // else, this is a message accessing a property on super. @@ -119,7 +118,7 @@ FunctionScopeInfo::WeakObjectProfileTy::WeakObjectProfileTy(const Expr *BaseE, FunctionScopeInfo::WeakObjectProfileTy::WeakObjectProfileTy( const DeclRefExpr *DRE) - : Base(0, true), Property(DRE->getDecl()) { + : Base(nullptr, true), Property(DRE->getDecl()) { assert(isa(Property)); } diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index 6a7ba5a..e8b487e 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -76,40 +76,41 @@ void Sema::ActOnTranslationUnitScope(Scope *S) { Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer, TranslationUnitKind TUKind, CodeCompleteConsumer *CodeCompleter) - : ExternalSource(0), + : ExternalSource(nullptr), isMultiplexExternalSource(false), FPFeatures(pp.getLangOpts()), LangOpts(pp.getLangOpts()), PP(pp), Context(ctxt), Consumer(consumer), Diags(PP.getDiagnostics()), SourceMgr(PP.getSourceManager()), CollectStats(false), CodeCompleter(CodeCompleter), - CurContext(0), OriginalLexicalContext(0), - PackContext(0), MSStructPragmaOn(false), + CurContext(nullptr), OriginalLexicalContext(nullptr), + PackContext(nullptr), MSStructPragmaOn(false), MSPointerToMemberRepresentationMethod( LangOpts.getMSPointerToMemberRepresentationMethod()), VtorDispModeStack(1, MSVtorDispAttr::Mode(LangOpts.VtorDispMode)), DataSegStack(nullptr), BSSSegStack(nullptr), ConstSegStack(nullptr), - CodeSegStack(nullptr), VisContext(0), + CodeSegStack(nullptr), VisContext(nullptr), IsBuildingRecoveryCallExpr(false), - ExprNeedsCleanups(false), LateTemplateParser(0), OpaqueParser(0), - IdResolver(pp), StdInitializerList(0), CXXTypeInfoDecl(0), MSVCGuidDecl(0), - NSNumberDecl(0), - NSStringDecl(0), StringWithUTF8StringMethod(0), - NSArrayDecl(0), ArrayWithObjectsMethod(0), - NSDictionaryDecl(0), DictionaryWithObjectsMethod(0), + ExprNeedsCleanups(false), LateTemplateParser(nullptr), + OpaqueParser(nullptr), IdResolver(pp), StdInitializerList(nullptr), + CXXTypeInfoDecl(nullptr), MSVCGuidDecl(nullptr), + NSNumberDecl(nullptr), + NSStringDecl(nullptr), StringWithUTF8StringMethod(nullptr), + NSArrayDecl(nullptr), ArrayWithObjectsMethod(nullptr), + NSDictionaryDecl(nullptr), DictionaryWithObjectsMethod(nullptr), GlobalNewDeleteDeclared(false), TUKind(TUKind), NumSFINAEErrors(0), AccessCheckingSFINAE(false), InNonInstantiationSFINAEContext(false), NonInstantiationEntries(0), ArgumentPackSubstitutionIndex(-1), - CurrentInstantiationScope(0), DisableTypoCorrection(false), + CurrentInstantiationScope(nullptr), DisableTypoCorrection(false), TyposCorrected(0), AnalysisWarnings(*this), - VarDataSharingAttributesStack(0), CurScope(0), - Ident_super(0), Ident___float128(0) + VarDataSharingAttributesStack(nullptr), CurScope(nullptr), + Ident_super(nullptr), Ident___float128(nullptr) { - TUScope = 0; + TUScope = nullptr; LoadedExternalKnownNamespaces = false; for (unsigned I = 0; I != NSAPI::NumNSNumberLiteralMethods; ++I) - NSNumberLiteralMethods[I] = 0; + NSNumberLiteralMethods[I] = nullptr; if (getLangOpts().ObjC1) NSAPIObj.reset(new NSAPI(Context)); @@ -123,7 +124,7 @@ Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer, ExprEvalContexts.push_back( ExpressionEvaluationContextRecord(PotentiallyEvaluated, 0, - false, 0, false)); + false, nullptr, false)); FunctionScopes.push_back(new FunctionScopeInfo(Diags)); @@ -593,7 +594,7 @@ static bool IsRecordFullyDefined(const CXXRecordDecl *RD, /// translation unit when EOF is reached and all but the top-level scope is /// popped. void Sema::ActOnEndOfTranslationUnit() { - assert(DelayedDiagnostics.getCurrentPool() == NULL + assert(DelayedDiagnostics.getCurrentPool() == nullptr && "reached end of translation unit with a pool attached?"); // If code completion is enabled, don't perform any end-of-translation-unit @@ -616,7 +617,7 @@ void Sema::ActOnEndOfTranslationUnit() { "Should not see dependent types here!"); if (const CXXMethodDecl *KeyFunction = Context.getCurrentKeyFunction(*I)) { - const FunctionDecl *Definition = 0; + const FunctionDecl *Definition = nullptr; if (KeyFunction->hasBody(Definition)) MarkVTableUsed(Definition->getLocation(), *I, true); } @@ -655,14 +656,14 @@ void Sema::ActOnEndOfTranslationUnit() { // Remove file scoped decls that turned out to be used. UnusedFileScopedDecls.erase( - std::remove_if(UnusedFileScopedDecls.begin(0, true), + std::remove_if(UnusedFileScopedDecls.begin(nullptr, true), UnusedFileScopedDecls.end(), std::bind1st(std::ptr_fun(ShouldRemoveFromUnused), this)), UnusedFileScopedDecls.end()); if (TUKind == TU_Prefix) { // Translation unit prefixes don't need any of the checking below. - TUScope = 0; + TUScope = nullptr; return; } @@ -714,7 +715,7 @@ void Sema::ActOnEndOfTranslationUnit() { } // Modules don't need any of the checking below. - TUScope = 0; + TUScope = nullptr; return; } @@ -740,7 +741,7 @@ void Sema::ActOnEndOfTranslationUnit() { // If the tentative definition was completed, getActingDefinition() returns // null. If we've already seen this variable before, insert()'s second // return value is false. - if (VD == 0 || VD->isInvalidDecl() || !Seen.insert(VD)) + if (!VD || VD->isInvalidDecl() || !Seen.insert(VD)) continue; if (const IncompleteArrayType *ArrayT @@ -845,7 +846,7 @@ void Sema::ActOnEndOfTranslationUnit() { assert(ParsingInitForAutoVars.empty() && "Didn't unmark var as having its initializer parsed"); - TUScope = 0; + TUScope = nullptr; } @@ -889,7 +890,7 @@ NamedDecl *Sema::getCurFunctionOrMethodDecl() { DeclContext *DC = getFunctionLevelDeclContext(); if (isa(DC) || isa(DC)) return cast(DC); - return 0; + return nullptr; } void Sema::EmitCurrentDiagnostic(unsigned DiagID) { @@ -1037,7 +1038,7 @@ bool Sema::findMacroSpelling(SourceLocation &locref, StringRef name) { Scope *Sema::getScopeForContext(DeclContext *Ctx) { if (!Ctx) - return 0; + return nullptr; Ctx = Ctx->getPrimaryContext(); for (Scope *S = getCurScope(); S; S = S->getParent()) { @@ -1049,7 +1050,7 @@ Scope *Sema::getScopeForContext(DeclContext *Ctx) { return S; } - return 0; + return nullptr; } /// \brief Enter a new function scope @@ -1120,7 +1121,7 @@ bool Sema::hasAnyUnrecoverableErrorsInThisFunction() const { BlockScopeInfo *Sema::getCurBlock() { if (FunctionScopes.empty()) - return 0; + return nullptr; auto CurBSI = dyn_cast(FunctionScopes.back()); if (CurBSI && CurBSI->TheDecl && @@ -1135,7 +1136,7 @@ BlockScopeInfo *Sema::getCurBlock() { LambdaScopeInfo *Sema::getCurLambda() { if (FunctionScopes.empty()) - return 0; + return nullptr; auto CurLSI = dyn_cast(FunctionScopes.back()); if (CurLSI && CurLSI->Lambda && @@ -1152,9 +1153,9 @@ LambdaScopeInfo *Sema::getCurLambda() { LambdaScopeInfo *Sema::getCurGenericLambda() { if (LambdaScopeInfo *LSI = getCurLambda()) { return (LSI->AutoTemplateParams.size() || - LSI->GLTemplateParameterList) ? LSI : 0; + LSI->GLTemplateParameterList) ? LSI : nullptr; } - return 0; + return nullptr; } @@ -1232,7 +1233,7 @@ bool Sema::tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy, ZeroArgCallReturnTy = QualType(); OverloadSet.clear(); - const OverloadExpr *Overloads = NULL; + const OverloadExpr *Overloads = nullptr; bool IsMemExpr = false; if (E.getType() == Context.OverloadTy) { OverloadExpr::FindResult FR = OverloadExpr::find(const_cast(&E)); @@ -1281,8 +1282,8 @@ bool Sema::tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy, if (IsMemExpr && !E.isTypeDependent()) { bool Suppress = getDiagnostics().getSuppressAllDiagnostics(); getDiagnostics().setSuppressAllDiagnostics(true); - ExprResult R = BuildCallToMemberFunction(NULL, &E, SourceLocation(), None, - SourceLocation()); + ExprResult R = BuildCallToMemberFunction(nullptr, &E, SourceLocation(), + None, SourceLocation()); getDiagnostics().setSuppressAllDiagnostics(Suppress); if (R.isUsable()) { ZeroArgCallReturnTy = R.get()->getType(); @@ -1302,7 +1303,7 @@ bool Sema::tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy, // We don't have an expression that's convenient to get a FunctionDecl from, // but we can at least check if the type is "function of 0 arguments". QualType ExprTy = E.getType(); - const FunctionType *FunTy = NULL; + const FunctionType *FunTy = nullptr; QualType PointeeTy = ExprTy->getPointeeType(); if (!PointeeTy.isNull()) FunTy = PointeeTy->getAs(); @@ -1407,7 +1408,7 @@ bool Sema::tryToRecoverWithCall(ExprResult &E, const PartialDiagnostic &PD, // FIXME: Try this before emitting the fixit, and suppress diagnostics // while doing so. - E = ActOnCallExpr(0, E.take(), Range.getEnd(), None, + E = ActOnCallExpr(nullptr, E.take(), Range.getEnd(), None, Range.getEnd().getLocWithOffset(1)); return true; } @@ -1442,7 +1443,7 @@ void Sema::PushCapturedRegionScope(Scope *S, CapturedDecl *CD, RecordDecl *RD, CapturedRegionScopeInfo *Sema::getCurCapturedRegion() { if (FunctionScopes.empty()) - return 0; + return nullptr; return dyn_cast(FunctionScopes.back()); } diff --git a/clang/lib/Sema/SemaAccess.cpp b/clang/lib/Sema/SemaAccess.cpp index f7806d2..dc574f1 100644 --- a/clang/lib/Sema/SemaAccess.cpp +++ b/clang/lib/Sema/SemaAccess.cpp @@ -78,7 +78,7 @@ static CXXRecordDecl *FindDeclaringClass(NamedDecl *D) { namespace { struct EffectiveContext { - EffectiveContext() : Inner(0), Dependent(false) {} + EffectiveContext() : Inner(nullptr), Dependent(false) {} explicit EffectiveContext(DeclContext *DC) : Inner(DC), @@ -209,7 +209,8 @@ struct AccessTarget : public AccessedEntity { CalculatedInstanceContext = true; DeclContext *IC = S.computeDeclContext(getBaseObjectType()); - InstanceContext = (IC ? cast(IC)->getCanonicalDecl() : 0); + InstanceContext = (IC ? cast(IC)->getCanonicalDecl() + : nullptr); return InstanceContext; } @@ -232,7 +233,7 @@ private: !getBaseObjectType().isNull() && getTargetDecl()->isCXXInstanceMember()); CalculatedInstanceContext = false; - InstanceContext = 0; + InstanceContext = nullptr; if (isMemberAccess()) DeclaringClass = FindDeclaringClass(getTargetDecl()); @@ -709,7 +710,7 @@ struct ProtectedFriendContext { static AccessResult GetProtectedFriendKind(Sema &S, const EffectiveContext &EC, const CXXRecordDecl *InstanceContext, const CXXRecordDecl *NamingClass) { - assert(InstanceContext == 0 || + assert(InstanceContext == nullptr || InstanceContext->getCanonicalDecl() == InstanceContext); assert(NamingClass->getCanonicalDecl() == NamingClass); @@ -842,7 +843,7 @@ static AccessResult HasAccess(Sema &S, // and instead rely on whether any potential P is a friend. if (Access == AS_protected && Target.isInstanceMember()) { // Compute the instance context if possible. - const CXXRecordDecl *InstanceContext = 0; + const CXXRecordDecl *InstanceContext = nullptr; if (Target.hasInstanceContext()) { InstanceContext = Target.resolveInstanceContext(S); if (!InstanceContext) return AR_dependent; @@ -937,7 +938,7 @@ static CXXBasePath *FindBestPath(Sema &S, assert(isDerived && "derived class not actually derived from base"); (void) isDerived; - CXXBasePath *BestPath = 0; + CXXBasePath *BestPath = nullptr; assert(FinalAccess != AS_none && "forbidden access after declaring class"); @@ -986,7 +987,7 @@ static CXXBasePath *FindBestPath(Sema &S, // Note that we modify the path's Access field to the // friend-modified access. - if (BestPath == 0 || PathAccess < BestPath->Access) { + if (BestPath == nullptr || PathAccess < BestPath->Access) { BestPath = &*PI; BestPath->Access = PathAccess; @@ -1004,7 +1005,7 @@ static CXXBasePath *FindBestPath(Sema &S, // We didn't find a public path, but at least one path was subject // to dependent friendship, so delay the check. if (AnyDependent) - return 0; + return nullptr; return BestPath; } @@ -1101,7 +1102,7 @@ static void diagnoseBadDirectAccess(Sema &S, // Find an original declaration. while (D->isOutOfLine()) { - NamedDecl *PrevDecl = 0; + NamedDecl *PrevDecl = nullptr; if (VarDecl *VD = dyn_cast(D)) PrevDecl = VD->getPreviousDecl(); else if (FunctionDecl *FD = dyn_cast(D)) @@ -1212,7 +1213,7 @@ static void DiagnoseAccessPath(Sema &S, case AR_accessible: accessSoFar = AS_public; entity.suppressInstanceContext(); - constrainingBase = 0; + constrainingBase = nullptr; break; case AR_dependent: llvm_unreachable("cannot diagnose dependent access"); @@ -1259,7 +1260,7 @@ static void DiagnoseBadAccess(Sema &S, SourceLocation Loc, AccessTarget &Entity) { const CXXRecordDecl *NamingClass = Entity.getNamingClass(); const CXXRecordDecl *DeclaringClass = Entity.getDeclaringClass(); - NamedDecl *D = (Entity.isMemberAccess() ? Entity.getTargetDecl() : 0); + NamedDecl *D = (Entity.isMemberAccess() ? Entity.getTargetDecl() : nullptr); S.Diag(Loc, Entity.getDiag()) << (Entity.getAccess() == AS_protected) @@ -1872,7 +1873,7 @@ bool Sema::IsSimplyAccessible(NamedDecl *Decl, DeclContext *Ctx) { // If we are inside a class or category implementation, determine the // interface we're in. - ObjCInterfaceDecl *ClassOfMethodDecl = 0; + ObjCInterfaceDecl *ClassOfMethodDecl = nullptr; if (ObjCMethodDecl *MD = getCurMethodDecl()) ClassOfMethodDecl = MD->getClassInterface(); else if (FunctionDecl *FD = getCurFunctionDecl()) { diff --git a/clang/lib/Sema/SemaAttr.cpp b/clang/lib/Sema/SemaAttr.cpp index 6397487..7c182a1 100644 --- a/clang/lib/Sema/SemaAttr.cpp +++ b/clang/lib/Sema/SemaAttr.cpp @@ -109,7 +109,7 @@ bool PragmaPackStack::pop(IdentifierInfo *Name, bool IsReset) { /// FreePackedContext - Deallocate and null out PackContext. void Sema::FreePackedContext() { delete static_cast(PackContext); - PackContext = 0; + PackContext = nullptr; } void Sema::AddAlignmentAttributesForRecord(RecordDecl *RD) { @@ -143,7 +143,7 @@ void Sema::AddMsStructLayoutForRecord(RecordDecl *RD) { void Sema::ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind, SourceLocation PragmaLoc) { - if (PackContext == 0) + if (!PackContext) PackContext = new PragmaPackStack(); PragmaPackStack *Context = static_cast(PackContext); @@ -155,14 +155,14 @@ void Sema::ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind, case POAK_Native: case POAK_Power: case POAK_Natural: - Context->push(0); + Context->push(nullptr); Context->setAlignment(0); break; // Note that '#pragma options align=packed' is not equivalent to attribute // packed, it has a different precedence relative to attribute aligned. case POAK_Packed: - Context->push(0); + Context->push(nullptr); Context->setAlignment(1); break; @@ -172,14 +172,14 @@ void Sema::ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind, Diag(PragmaLoc, diag::err_pragma_options_align_mac68k_target_unsupported); return; } - Context->push(0); + Context->push(nullptr); Context->setAlignment(PackStackEntry::kMac68kAlignmentSentinel); break; case POAK_Reset: // Reset just pops the top of the stack, or resets the current alignment to // default. - if (!Context->pop(0, /*IsReset=*/true)) { + if (!Context->pop(nullptr, /*IsReset=*/true)) { Diag(PragmaLoc, diag::warn_pragma_options_align_reset_failed) << "stack empty"; } @@ -211,7 +211,7 @@ void Sema::ActOnPragmaPack(PragmaPackKind Kind, IdentifierInfo *Name, AlignmentVal = (unsigned) Val.getZExtValue(); } - if (PackContext == 0) + if (!PackContext) PackContext = new PragmaPackStack(); PragmaPackStack *Context = static_cast(PackContext); @@ -436,7 +436,7 @@ void Sema::ActOnPragmaUnused(const Token &IdTok, Scope *curScope, IdentifierInfo *Name = IdTok.getIdentifierInfo(); LookupResult Lookup(*this, Name, IdTok.getLocation(), LookupOrdinaryName); - LookupParsedName(Lookup, curScope, NULL, true); + LookupParsedName(Lookup, curScope, nullptr, true); if (Lookup.empty()) { Diag(PragmaLoc, diag::warn_pragma_unused_undeclared_var) @@ -523,7 +523,7 @@ void Sema::AddPushedVisibilityAttribute(Decl *D) { /// FreeVisContext - Deallocate and null out VisContext. void Sema::FreeVisContext() { delete static_cast(VisContext); - VisContext = 0; + VisContext = nullptr; } static void PushPragmaVisibility(Sema &S, unsigned type, SourceLocation loc) { diff --git a/clang/lib/Sema/SemaCXXScopeSpec.cpp b/clang/lib/Sema/SemaCXXScopeSpec.cpp index 707d1b2..8c42335 100644 --- a/clang/lib/Sema/SemaCXXScopeSpec.cpp +++ b/clang/lib/Sema/SemaCXXScopeSpec.cpp @@ -29,7 +29,7 @@ using namespace clang; static CXXRecordDecl *getCurrentInstantiationOf(QualType T, DeclContext *CurContext) { if (T.isNull()) - return 0; + return nullptr; const Type *Ty = T->getCanonicalTypeInternal().getTypePtr(); if (const RecordType *RecordTy = dyn_cast(Ty)) { @@ -38,11 +38,11 @@ static CXXRecordDecl *getCurrentInstantiationOf(QualType T, Record->isCurrentInstantiation(CurContext)) return Record; - return 0; + return nullptr; } else if (isa(Ty)) return cast(Ty)->getDecl(); else - return 0; + return nullptr; } /// \brief Compute the DeclContext that is associated with the given type. @@ -76,7 +76,7 @@ DeclContext *Sema::computeDeclContext(QualType T) { DeclContext *Sema::computeDeclContext(const CXXScopeSpec &SS, bool EnteringContext) { if (!SS.isSet() || SS.isInvalid()) - return 0; + return nullptr; NestedNameSpecifier *NNS = SS.getScopeRep(); if (NNS->isDependent()) { @@ -88,7 +88,7 @@ DeclContext *Sema::computeDeclContext(const CXXScopeSpec &SS, if (EnteringContext) { const Type *NNSType = NNS->getAsType(); if (!NNSType) { - return 0; + return nullptr; } // Look through type alias templates, per C++0x [temp.dep.type]p1. @@ -126,7 +126,7 @@ DeclContext *Sema::computeDeclContext(const CXXScopeSpec &SS, } } - return 0; + return nullptr; } switch (NNS->getKind()) { @@ -170,7 +170,7 @@ CXXRecordDecl *Sema::getCurrentInstantiationOf(NestedNameSpecifier *NNS) { assert(NNS->isDependent() && "Only dependent nested-name-specifier allowed"); if (!NNS->getAsType()) - return 0; + return nullptr; QualType T = QualType(NNS->getAsType(), 0); return ::getCurrentInstantiationOf(T, CurContext); @@ -187,7 +187,7 @@ CXXRecordDecl *Sema::getCurrentInstantiationOf(NestedNameSpecifier *NNS) { /// will attempt to instantiate that class template. bool Sema::RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC) { - assert(DC != 0 && "given null context"); + assert(DC && "given null context"); TagDecl *tag = dyn_cast(DC); @@ -282,13 +282,13 @@ bool Sema::isAcceptableNestedNameSpecifier(const NamedDecl *SD) { /// name lookup. NamedDecl *Sema::FindFirstQualifierInScope(Scope *S, NestedNameSpecifier *NNS) { if (!S || !NNS) - return 0; + return nullptr; while (NNS->getPrefix()) NNS = NNS->getPrefix(); if (NNS->getKind() != NestedNameSpecifier::Identifier) - return 0; + return nullptr; LookupResult Found(*this, NNS->getAsIdentifier(), SourceLocation(), LookupNestedNameSpecifierName); @@ -296,13 +296,13 @@ NamedDecl *Sema::FindFirstQualifierInScope(Scope *S, NestedNameSpecifier *NNS) { assert(!Found.isAmbiguous() && "Cannot handle ambiguities here yet"); if (!Found.isSingleResult()) - return 0; + return nullptr; NamedDecl *Result = Found.getFoundDecl(); if (isAcceptableNestedNameSpecifier(Result)) return Result; - return 0; + return nullptr; } bool Sema::isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec &SS, @@ -313,7 +313,7 @@ bool Sema::isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec &SS, LookupResult Found(*this, &II, IdLoc, LookupNestedNameSpecifierName); // Determine where to perform name lookup - DeclContext *LookupCtx = 0; + DeclContext *LookupCtx = nullptr; bool isDependent = false; if (!ObjectType.isNull()) { // This nested-name-specifier occurs in a member access expression, e.g., @@ -423,7 +423,7 @@ bool Sema::BuildCXXNestedNameSpecifier(Scope *S, LookupNestedNameSpecifierName); // Determine where to perform name lookup - DeclContext *LookupCtx = 0; + DeclContext *LookupCtx = nullptr; bool isDependent = false; if (IsCorrectedToColon) *IsCorrectedToColon = false; @@ -746,7 +746,7 @@ bool Sema::ActOnCXXNestedNameSpecifier(Scope *S, return BuildCXXNestedNameSpecifier(S, Identifier, IdentifierLoc, CCLoc, GetTypeFromParser(ObjectType), EnteringContext, SS, - /*ScopeLookupResult=*/0, false, + /*ScopeLookupResult=*/nullptr, false, IsCorrectedToColon); } @@ -787,11 +787,11 @@ bool Sema::IsInvalidUnlessNestedName(Scope *S, CXXScopeSpec &SS, bool EnteringContext) { if (SS.isInvalid()) return false; - + return !BuildCXXNestedNameSpecifier(S, Identifier, IdentifierLoc, ColonLoc, GetTypeFromParser(ObjectType), EnteringContext, SS, - /*ScopeLookupResult=*/0, true); + /*ScopeLookupResult=*/nullptr, true); } bool Sema::ActOnCXXNestedNameSpecifier(Scope *S, @@ -894,8 +894,8 @@ namespace { void *Sema::SaveNestedNameSpecifierAnnotation(CXXScopeSpec &SS) { if (SS.isEmpty() || SS.isInvalid()) - return 0; - + return nullptr; + void *Mem = Context.Allocate((sizeof(NestedNameSpecifierAnnotation) + SS.location_size()), llvm::alignOf()); diff --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp index b842ce8..df4e823 100644 --- a/clang/lib/Sema/SemaCast.cpp +++ b/clang/lib/Sema/SemaCast.cpp @@ -90,7 +90,7 @@ namespace { if (IsARCUnbridgedCast) { castExpr = ImplicitCastExpr::Create(Self.Context, Self.Context.ARCUnbridgedCastTy, - CK_Dependent, castExpr, 0, + CK_Dependent, castExpr, nullptr, castExpr->getValueKind()); } return Self.Owned(castExpr); @@ -286,7 +286,7 @@ Sema::BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, } return Op.complete(CXXReinterpretCastExpr::Create(Context, Op.ResultType, Op.ValueKind, Op.Kind, Op.SrcExpr.take(), - 0, DestTInfo, OpLoc, + nullptr, DestTInfo, OpLoc, Parens.getEnd(), AngleBrackets)); } @@ -549,7 +549,7 @@ void CastOperation::CheckDynamicCast() { QualType DestPointee; const PointerType *DestPointer = DestType->getAs(); - const ReferenceType *DestReference = 0; + const ReferenceType *DestReference = nullptr; if (DestPointer) { DestPointee = DestPointer->getPointeeType(); } else if ((DestReference = DestType->getAs())) { @@ -1277,7 +1277,7 @@ TryStaticDowncast(Sema &Self, CanQualType SrcType, CanQualType DestType, return TC_Failed; } - if (Paths.getDetectedVirtual() != 0) { + if (Paths.getDetectedVirtual() != nullptr) { QualType VirtualBase(Paths.getDetectedVirtual(), 0); Self.Diag(OpRange.getBegin(), diag::err_static_downcast_via_virtual) << OrigSrcType << OrigDestType << VirtualBase << OpRange; @@ -1739,7 +1739,7 @@ static TryCastResult TryReinterpretCast(Sema &Self, ExprResult &SrcExpr, // same effect as the conversion *reinterpret_cast(&x) with the // built-in & and * operators. - const char *inappropriate = 0; + const char *inappropriate = nullptr; switch (SrcExpr.get()->getObjectKind()) { case OK_Ordinary: break; diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 592de52..83fb1d7 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -871,12 +871,13 @@ bool Sema::CheckPointerCall(NamedDecl *NDecl, CallExpr *TheCall, /// Checks function calls when a FunctionDecl or a NamedDecl is not available, /// such as function pointers returned from functions. bool Sema::CheckOtherCall(CallExpr *TheCall, const FunctionProtoType *Proto) { - VariadicCallType CallType = getVariadicCallType(/*FDecl=*/0, Proto, + VariadicCallType CallType = getVariadicCallType(/*FDecl=*/nullptr, Proto, TheCall->getCallee()); unsigned NumParams = Proto ? Proto->getNumParams() : 0; - checkCall(/*FDecl=*/0, llvm::makeArrayRef( - TheCall->getArgs(), TheCall->getNumArgs()), + checkCall(/*FDecl=*/nullptr, + llvm::makeArrayRef(TheCall->getArgs(), + TheCall->getNumArgs()), NumParams, /*IsMemberFunction=*/false, TheCall->getRParenLoc(), TheCall->getCallee()->getSourceRange(), CallType); @@ -1530,7 +1531,7 @@ Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) { LookupName(Res, TUScope, /*AllowBuiltinCreation=*/true); assert(Res.getFoundDecl()); NewBuiltinDecl = dyn_cast(Res.getFoundDecl()); - if (NewBuiltinDecl == 0) + if (!NewBuiltinDecl) return ExprError(); } @@ -1772,7 +1773,7 @@ bool Sema::SemaBuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs) { if (CastArg->getType()->isSpecificBuiltinType(BuiltinType::Float)) { assert(Cast->getType()->isSpecificBuiltinType(BuiltinType::Double) && "promotion from float to double is the only expected cast here"); - Cast->setSubExpr(0); + Cast->setSubExpr(nullptr); TheCall->setArg(NumArgs-1, CastArg); } } @@ -1857,7 +1858,7 @@ ExprResult Sema::SemaBuiltinShuffleVector(CallExpr *TheCall) { for (unsigned i = 0, e = TheCall->getNumArgs(); i != e; i++) { exprs.push_back(TheCall->getArg(i)); - TheCall->setArg(i, 0); + TheCall->setArg(i, nullptr); } return Owned(new (Context) ShuffleVectorExpr(Context, exprs, resType, @@ -2145,7 +2146,7 @@ checkFormatStringExpr(Sema &S, const Expr *E, ArrayRef Args, } case Stmt::ObjCStringLiteralClass: case Stmt::StringLiteralClass: { - const StringLiteral *StrE = NULL; + const StringLiteral *StrE = nullptr; if (const ObjCStringLiteral *ObjCFExpr = dyn_cast(E)) StrE = ObjCFExpr->getString(); @@ -3760,8 +3761,8 @@ static unsigned getAbsoluteValueFunctionKind(const FunctionDecl *FDecl) { static void emitReplacement(Sema &S, SourceLocation Loc, SourceRange Range, unsigned AbsKind, QualType ArgType) { bool EmitHeaderHint = true; - const char *HeaderName = 0; - const char *FunctionName = 0; + const char *HeaderName = nullptr; + const char *FunctionName = nullptr; if (S.getLangOpts().CPlusPlus && !ArgType->isAnyComplexType()) { FunctionName = "std::abs"; if (ArgType->isIntegralOrEnumerationType()) { @@ -3779,7 +3780,7 @@ static void emitReplacement(Sema &S, SourceLocation Loc, SourceRange Range, S.LookupQualifiedName(R, Std); for (const auto *I : R) { - const FunctionDecl *FDecl = 0; + const FunctionDecl *FDecl = nullptr; if (const UsingShadowDecl *UsingD = dyn_cast(I)) { FDecl = dyn_cast(UsingD->getTargetDecl()); } else { @@ -3981,7 +3982,7 @@ static const Expr *getSizeOfExprArg(const Expr* E) { if (SizeOf->getKind() == clang::UETT_SizeOf && !SizeOf->isArgumentType()) return SizeOf->getArgumentExpr()->IgnoreParenImpCasts(); - return 0; + return nullptr; } /// \brief If E is a sizeof expression, returns its argument type. @@ -4203,7 +4204,7 @@ void Sema::CheckStrlcpycatArguments(const CallExpr *Call, const Expr *SrcArg = ignoreLiteralAdditions(Call->getArg(1), Context); const Expr *SizeArg = ignoreLiteralAdditions(Call->getArg(2), Context); - const Expr *CompareWithSrc = NULL; + const Expr *CompareWithSrc = nullptr; if (CheckMemorySizeofForComparison(*this, SizeArg, FnName, Call->getLocStart(), Call->getRParenLoc())) @@ -4252,7 +4253,7 @@ void Sema::CheckStrlcpycatArguments(const CallExpr *Call, SmallString<128> sizeString; llvm::raw_svector_ostream OS(sizeString); OS << "sizeof("; - DstArg->printPretty(OS, 0, getPrintingPolicy()); + DstArg->printPretty(OS, nullptr, getPrintingPolicy()); OS << ")"; Diag(OriginalSizeArg->getLocStart(), diag::note_strlcpycat_wrong_size) @@ -4272,10 +4273,10 @@ static const Expr *getStrlenExprArg(const Expr *E) { if (const CallExpr *CE = dyn_cast(E)) { const FunctionDecl *FD = CE->getDirectCallee(); if (!FD || FD->getMemoryFunctionKind() != Builtin::BIstrlen) - return 0; + return nullptr; return CE->getArg(0)->IgnoreParenCasts(); } - return 0; + return nullptr; } // Warn on anti-patterns as the 'size' argument to strncat. @@ -4353,10 +4354,10 @@ void Sema::CheckStrncatArguments(const CallExpr *CE, SmallString<128> sizeString; llvm::raw_svector_ostream OS(sizeString); OS << "sizeof("; - DstArg->printPretty(OS, 0, getPrintingPolicy()); + DstArg->printPretty(OS, nullptr, getPrintingPolicy()); OS << ") - "; OS << "strlen("; - DstArg->printPretty(OS, 0, getPrintingPolicy()); + DstArg->printPretty(OS, nullptr, getPrintingPolicy()); OS << ") - 1"; Diag(SL, diag::note_strncat_wrong_size) @@ -4376,19 +4377,19 @@ static void CheckReturnStackAddr(Sema &S, Expr *RetValExp, QualType lhsType, SourceLocation ReturnLoc) { - Expr *stackE = 0; + Expr *stackE = nullptr; SmallVector refVars; // Perform checking for returned stack addresses, local blocks, // label addresses or references to temporaries. if (lhsType->isPointerType() || (!S.getLangOpts().ObjCAutoRefCount && lhsType->isBlockPointerType())) { - stackE = EvalAddr(RetValExp, refVars, /*ParentDecl=*/0); + stackE = EvalAddr(RetValExp, refVars, /*ParentDecl=*/nullptr); } else if (lhsType->isReferenceType()) { - stackE = EvalVal(RetValExp, refVars, /*ParentDecl=*/0); + stackE = EvalVal(RetValExp, refVars, /*ParentDecl=*/nullptr); } - if (stackE == 0) + if (!stackE) return; // Nothing suspicious was found. SourceLocation diagLoc; @@ -4462,7 +4463,7 @@ CheckReturnStackAddr(Sema &S, Expr *RetValExp, QualType lhsType, static Expr *EvalAddr(Expr *E, SmallVectorImpl &refVars, Decl *ParentDecl) { if (E->isTypeDependent()) - return NULL; + return nullptr; // We should only be called for evaluating pointer expressions. assert((E->getType()->isAnyPointerType() || @@ -4481,7 +4482,7 @@ static Expr *EvalAddr(Expr *E, SmallVectorImpl &refVars, // If we leave the immediate function, the lifetime isn't about to end. if (DR->refersToEnclosingLocal()) - return 0; + return nullptr; if (VarDecl *V = dyn_cast(DR->getDecl())) // If this is a reference variable, follow through to the expression that @@ -4493,7 +4494,7 @@ static Expr *EvalAddr(Expr *E, SmallVectorImpl &refVars, return EvalAddr(V->getInit(), refVars, ParentDecl); } - return NULL; + return nullptr; } case Stmt::UnaryOperatorClass: { @@ -4504,7 +4505,7 @@ static Expr *EvalAddr(Expr *E, SmallVectorImpl &refVars, if (U->getOpcode() == UO_AddrOf) return EvalVal(U->getSubExpr(), refVars, ParentDecl); else - return NULL; + return nullptr; } case Stmt::BinaryOperatorClass: { @@ -4514,7 +4515,7 @@ static Expr *EvalAddr(Expr *E, SmallVectorImpl &refVars, BinaryOperatorKind op = B->getOpcode(); if (op != BO_Add && op != BO_Sub) - return NULL; + return nullptr; Expr *Base = B->getLHS(); @@ -4542,7 +4543,7 @@ static Expr *EvalAddr(Expr *E, SmallVectorImpl &refVars, // In C++, we can have a throw-expression, which has 'void' type. if (C->getRHS()->getType()->isVoidType()) - return 0; + return nullptr; return EvalAddr(C->getRHS(), refVars, ParentDecl); } @@ -4550,7 +4551,7 @@ static Expr *EvalAddr(Expr *E, SmallVectorImpl &refVars, case Stmt::BlockExprClass: if (cast(E)->getBlockDecl()->hasCaptures()) return E; // local block. - return NULL; + return nullptr; case Stmt::AddrLabelExprClass: return E; // address of label. @@ -4587,7 +4588,7 @@ static Expr *EvalAddr(Expr *E, SmallVectorImpl &refVars, return EvalVal(SubExpr, refVars, ParentDecl); default: - return 0; + return nullptr; } } @@ -4601,7 +4602,7 @@ static Expr *EvalAddr(Expr *E, SmallVectorImpl &refVars, // Everything else: we simply don't reason about them. default: - return NULL; + return nullptr; } } @@ -4627,7 +4628,7 @@ do { E = IE->getSubExpr(); continue; } - return NULL; + return nullptr; } case Stmt::ExprWithCleanupsClass: @@ -4641,7 +4642,7 @@ do { // If we leave the immediate function, the lifetime isn't about to end. if (DR->refersToEnclosingLocal()) - return 0; + return nullptr; if (VarDecl *V = dyn_cast(DR->getDecl())) { // Check if it refers to itself, e.g. "int& i = i;". @@ -4662,7 +4663,7 @@ do { } } - return NULL; + return nullptr; } case Stmt::UnaryOperatorClass: { @@ -4674,7 +4675,7 @@ do { if (U->getOpcode() == UO_Deref) return EvalAddr(U->getSubExpr(), refVars, ParentDecl); - return NULL; + return nullptr; } case Stmt::ArraySubscriptExprClass: { @@ -4699,7 +4700,7 @@ do { // In C++, we can have a throw-expression, which has 'void' type. if (C->getRHS()->getType()->isVoidType()) - return 0; + return nullptr; return EvalVal(C->getRHS(), refVars, ParentDecl); } @@ -4710,12 +4711,12 @@ do { // Check for indirect access. We only want direct field accesses. if (M->isArrow()) - return NULL; + return nullptr; // Check whether the member type is itself a reference, in which case // we're not going to refer to the member, but to what the member refers to. if (M->getMemberDecl()->getType()->isReferenceType()) - return NULL; + return nullptr; return EvalVal(M->getBase(), refVars, ParentDecl); } @@ -4735,7 +4736,7 @@ do { return E; // Everything else: we simply don't reason about them. - return NULL; + return nullptr; } } while (true); } @@ -5467,7 +5468,7 @@ static void DiagnoseOutOfRangeComparison(Sema &S, BinaryOperator *E, // If this is a comparison to an enum constant, include that // constant in the diagnostic. - const EnumConstantDecl *ED = 0; + const EnumConstantDecl *ED = nullptr; if (const DeclRefExpr *DR = dyn_cast(Constant)) ED = dyn_cast(DR->getDecl()); @@ -5772,7 +5773,7 @@ void CheckImplicitArgumentConversions(Sema &S, CallExpr *TheCall, } void CheckImplicitConversion(Sema &S, Expr *E, QualType T, - SourceLocation CC, bool *ICContext = 0) { + SourceLocation CC, bool *ICContext = nullptr) { if (E->isTypeDependent() || E->isValueDependent()) return; const Type *Source = S.Context.getCanonicalType(E->getType()).getTypePtr(); @@ -6178,7 +6179,7 @@ void Sema::DiagnoseAlwaysNonNullPointer(Expr *E, } // Expect to find a single Decl. Skip anything more complicated. - ValueDecl *D = 0; + ValueDecl *D = nullptr; if (DeclRefExpr *R = dyn_cast(E)) { D = R->getDecl(); } else if (MemberExpr *M = dyn_cast(E)) { @@ -6209,7 +6210,7 @@ void Sema::DiagnoseAlwaysNonNullPointer(Expr *E, // Pretty print the expression for the diagnostic. std::string Str; llvm::raw_string_ostream S(Str); - E->printPretty(S, 0, getPrintingPolicy()); + E->printPretty(S, nullptr, getPrintingPolicy()); unsigned DiagID = IsCompare ? diag::warn_null_pointer_compare : diag::warn_impcast_pointer_to_bool; @@ -6384,7 +6385,7 @@ class SequenceChecker : public EvaluatedExprVisitor { }; struct Usage { - Usage() : Use(0), Seq() {} + Usage() : Use(nullptr), Seq() {} Expr *Use; SequenceTree::Seq Seq; }; @@ -6484,7 +6485,7 @@ class SequenceChecker : public EvaluatedExprVisitor { } else if (DeclRefExpr *DRE = dyn_cast(E)) // FIXME: If this is a reference, map through to its value. return DRE->getDecl(); - return 0; + return nullptr; } /// \brief Note that an object was modified or used by an expression. @@ -6544,8 +6545,8 @@ class SequenceChecker : public EvaluatedExprVisitor { public: SequenceChecker(Sema &S, Expr *E, SmallVectorImpl &WorkList) - : Base(S.Context), SemaRef(S), Region(Tree.root()), ModAsSideEffect(0), - WorkList(WorkList), EvalTracker(0) { + : Base(S.Context), SemaRef(S), Region(Tree.root()), + ModAsSideEffect(nullptr), WorkList(WorkList), EvalTracker(nullptr) { Visit(E); } @@ -6830,7 +6831,7 @@ bool Sema::CheckParmsForFunctionDef(ParmVarDecl *const *P, // C99 6.9.1p5: If the declarator includes a parameter type list, the // declaration of each parameter shall include an identifier. if (CheckParameterNames && - Param->getIdentifier() == 0 && + Param->getIdentifier() == nullptr && !Param->isImplicit() && !getLangOpts().CPlusPlus) Diag(Param->getLocation(), diag::err_parameter_name_omitted); @@ -6997,7 +6998,7 @@ void Sema::CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr, if (IndexNegated) index = -index; - const NamedDecl *ND = NULL; + const NamedDecl *ND = nullptr; if (const DeclRefExpr *DRE = dyn_cast(BaseExpr)) ND = dyn_cast(DRE->getDecl()); if (const MemberExpr *ME = dyn_cast(BaseExpr)) @@ -7140,7 +7141,7 @@ void Sema::CheckArrayAccess(const Expr *expr) { namespace { struct RetainCycleOwner { - RetainCycleOwner() : Variable(0), Indirect(false) {} + RetainCycleOwner() : Variable(nullptr), Indirect(false) {} VarDecl *Variable; SourceRange Range; SourceLocation Loc; @@ -7251,7 +7252,7 @@ namespace { struct FindCaptureVisitor : EvaluatedExprVisitor { FindCaptureVisitor(ASTContext &Context, VarDecl *variable) : EvaluatedExprVisitor(Context), - Variable(variable), Capturer(0) {} + Variable(variable), Capturer(nullptr) {} VarDecl *Variable; Expr *Capturer; @@ -7295,7 +7296,7 @@ static Expr *findCapturingExpr(Sema &S, Expr *e, RetainCycleOwner &owner) { if (Cmd.isUnarySelector() && Cmd.getNameForSlot(0) == "copy") { e = ME->getInstanceReceiver(); if (!e) - return 0; + return nullptr; e = e->IgnoreParenCasts(); } } else if (CallExpr *CE = dyn_cast(e)) { @@ -7312,7 +7313,7 @@ static Expr *findCapturingExpr(Sema &S, Expr *e, RetainCycleOwner &owner) { BlockExpr *block = dyn_cast(e); if (!block || !block->getBlockDecl()->capturesVariable(owner.Variable)) - return 0; + return nullptr; FindCaptureVisitor visitor(S.Context, owner.Variable); visitor.Visit(block->getBlockDecl()->getBody()); @@ -7388,7 +7389,7 @@ void Sema::checkRetainCycles(Expr *receiver, Expr *argument) { void Sema::checkRetainCycles(VarDecl *Var, Expr *Init) { RetainCycleOwner Owner; - if (!considerVariable(Var, /*DeclRefExpr=*/0, Owner)) + if (!considerVariable(Var, /*DeclRefExpr=*/nullptr, Owner)) return; // Because we don't have an expression for the variable, we have to set the @@ -7899,7 +7900,7 @@ bool GetMatchingCType( FoundWrongKind = false; // Variable declaration that has type_tag_for_datatype attribute. - const ValueDecl *VD = NULL; + const ValueDecl *VD = nullptr; uint64_t MagicValue; diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp index 7e34b64..c075c92 100644 --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -104,7 +104,7 @@ namespace { if (DeclIndexPairVector *Vec = DeclOrVector.dyn_cast()) { delete Vec; - DeclOrVector = ((NamedDecl *)0); + DeclOrVector = ((NamedDecl *)nullptr); } } @@ -172,12 +172,12 @@ namespace { explicit ResultBuilder(Sema &SemaRef, CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, const CodeCompletionContext &CompletionContext, - LookupFilter Filter = 0) + LookupFilter Filter = nullptr) : SemaRef(SemaRef), Allocator(Allocator), CCTUInfo(CCTUInfo), Filter(Filter), AllowNestedNameSpecifiers(false), HasObjectTypeQualifiers(false), CompletionContext(CompletionContext), - ObjCImplementation(0) + ObjCImplementation(nullptr) { // If this is an Objective-C instance method definition, dig out the // corresponding implementation. @@ -212,8 +212,8 @@ namespace { void setFilter(LookupFilter Filter) { this->Filter = Filter; } - - Result *data() { return Results.empty()? 0 : &Results.front(); } + + Result *data() { return Results.empty()? nullptr : &Results.front(); } unsigned size() const { return Results.size(); } bool empty() const { return Results.empty(); } @@ -289,8 +289,8 @@ namespace { /// \param R the result to add (if it is unique). /// /// \param CurContext the context in which this result will be named. - void MaybeAddResult(Result R, DeclContext *CurContext = 0); - + void MaybeAddResult(Result R, DeclContext *CurContext = nullptr); + /// \brief Add a new result to this result set, where we already know /// the hiding declation (if any). /// @@ -364,8 +364,8 @@ public: return &Value; } }; - - iterator() : DeclOrIterator((NamedDecl *)0), SingleDeclIndex(0) { } + + iterator() : DeclOrIterator((NamedDecl *)nullptr), SingleDeclIndex(0) {} iterator(const NamedDecl *SingleDecl, unsigned Index) : DeclOrIterator(SingleDecl), SingleDeclIndex(Index) { } @@ -375,7 +375,7 @@ public: iterator &operator++() { if (DeclOrIterator.is()) { - DeclOrIterator = (NamedDecl *)0; + DeclOrIterator = (NamedDecl *)nullptr; SingleDeclIndex = 0; return *this; } @@ -461,8 +461,8 @@ getRequiredQualification(ASTContext &Context, TargetParents.push_back(CommonAncestor); } - - NestedNameSpecifier *Result = 0; + + NestedNameSpecifier *Result = nullptr; while (!TargetParents.empty()) { const DeclContext *Parent = TargetParents.pop_back_val(); @@ -530,7 +530,7 @@ bool ResultBuilder::isInterestingDecl(const NamedDecl *ND, ((isa(ND) || isa(ND)) && Filter != &ResultBuilder::IsNamespace && Filter != &ResultBuilder::IsNamespaceOrAlias && - Filter != 0)) + Filter != nullptr)) AsNestedNameSpecifier = true; // Filter out any unwanted results. @@ -779,7 +779,7 @@ void ResultBuilder::MaybeAddConstructorResults(Result R) { ASTContext &Context = SemaRef.Context; const NamedDecl *D = R.Declaration; - const CXXRecordDecl *Record = 0; + const CXXRecordDecl *Record = nullptr; if (const ClassTemplateDecl *ClassTemplate = dyn_cast(D)) Record = ClassTemplate->getTemplatedDecl(); else if ((Record = dyn_cast(D))) { @@ -910,10 +910,11 @@ void ResultBuilder::MaybeAddResult(Result R, DeclContext *CurContext) { !R.StartsNestedNameSpecifier) { const DeclContext *Ctx = R.Declaration->getDeclContext(); if (const NamespaceDecl *Namespace = dyn_cast(Ctx)) - R.Qualifier = NestedNameSpecifier::Create(SemaRef.Context, 0, Namespace); + R.Qualifier = NestedNameSpecifier::Create(SemaRef.Context, nullptr, + Namespace); else if (const TagDecl *Tag = dyn_cast(Ctx)) - R.Qualifier = NestedNameSpecifier::Create(SemaRef.Context, 0, false, - SemaRef.Context.getTypeDeclType(Tag).getTypePtr()); + R.Qualifier = NestedNameSpecifier::Create(SemaRef.Context, nullptr, + false, SemaRef.Context.getTypeDeclType(Tag).getTypePtr()); else R.QualifierIsInformative = false; } @@ -975,9 +976,10 @@ void ResultBuilder::AddResult(Result R, DeclContext *CurContext, !R.StartsNestedNameSpecifier) { const DeclContext *Ctx = R.Declaration->getDeclContext(); if (const NamespaceDecl *Namespace = dyn_cast(Ctx)) - R.Qualifier = NestedNameSpecifier::Create(SemaRef.Context, 0, Namespace); + R.Qualifier = NestedNameSpecifier::Create(SemaRef.Context, nullptr, + Namespace); else if (const TagDecl *Tag = dyn_cast(Ctx)) - R.Qualifier = NestedNameSpecifier::Create(SemaRef.Context, 0, false, + R.Qualifier = NestedNameSpecifier::Create(SemaRef.Context, nullptr, false, SemaRef.Context.getTypeDeclType(Tag).getTypePtr()); else R.QualifierIsInformative = false; @@ -1259,9 +1261,9 @@ namespace { bool Accessible = true; if (Ctx) Accessible = Results.getSema().IsSimplyAccessible(ND, Ctx); - - ResultBuilder::Result Result(ND, Results.getBasePriority(ND), 0, false, - Accessible); + + ResultBuilder::Result Result(ND, Results.getBasePriority(ND), nullptr, + false, Accessible); Results.AddResult(Result, CurContext, Hiding, InBaseClass); } }; @@ -2444,7 +2446,7 @@ static void AddTypedNameChunk(ASTContext &Context, const PrintingPolicy &Policy, switch (Name.getNameKind()) { case DeclarationName::CXXOperatorName: { - const char *OperatorName = 0; + const char *OperatorName = nullptr; switch (Name.getCXXOverloadedOperator()) { case OO_None: case OO_Conditional: @@ -2483,7 +2485,7 @@ static void AddTypedNameChunk(ASTContext &Context, const PrintingPolicy &Policy, break; case DeclarationName::CXXConstructorName: { - CXXRecordDecl *Record = 0; + CXXRecordDecl *Record = nullptr; QualType Ty = Name.getCXXNameType(); if (const RecordType *RecordTy = Ty->getAs()) Record = cast(RecordTy->getDecl()); @@ -3240,7 +3242,7 @@ void Sema::CodeCompleteOrdinaryName(Scope *S, Results.setFilter(&ResultBuilder::IsOrdinaryNonTypeName); if (getLangOpts().CPlusPlus) - MaybeAddOverrideCalls(*this, /*InContext=*/0, Results); + MaybeAddOverrideCalls(*this, /*InContext=*/nullptr, Results); break; case PCC_RecoveryInFunction: @@ -3328,7 +3330,7 @@ void Sema::CodeCompleteDeclSpec(Scope *S, DeclSpec &DS, CodeCompletionDeclConsumer Consumer(Results, CurContext); LookupVisibleDecls(S, LookupNestedNameSpecifierName, Consumer, CodeCompleter->includeGlobals()); - Results.setFilter(0); + Results.setFilter(nullptr); } } Results.ExitScope(); @@ -3465,9 +3467,9 @@ static void AddObjCProperties(ObjCContainerDecl *Container, // Add properties in this container. for (const auto *P : Container->properties()) if (AddedProperties.insert(P->getIdentifier())) - Results.MaybeAddResult(Result(P, Results.getBasePriority(P), 0), + Results.MaybeAddResult(Result(P, Results.getBasePriority(P), nullptr), CurContext); - + // Add nullary methods if (AllowNullaryMethods) { ASTContext &Context = Container->getASTContext(); @@ -3615,7 +3617,7 @@ void Sema::CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base, } else if ((IsArrow && BaseType->isObjCObjectPointerType()) || (!IsArrow && BaseType->isObjCObjectType())) { // Objective-C instance variable access. - ObjCInterfaceDecl *Class = 0; + ObjCInterfaceDecl *Class = nullptr; if (const ObjCObjectPointerType *ObjCPtr = BaseType->getAs()) Class = ObjCPtr->getInterfaceDecl(); @@ -3644,8 +3646,8 @@ void Sema::CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base, void Sema::CodeCompleteTag(Scope *S, unsigned TagSpec) { if (!CodeCompleter) return; - - ResultBuilder::LookupFilter Filter = 0; + + ResultBuilder::LookupFilter Filter = nullptr; enum CodeCompletionContext::Kind ContextKind = CodeCompletionContext::CCC_Other; switch ((DeclSpec::TST)TagSpec) { @@ -3734,7 +3736,7 @@ void Sema::CodeCompleteCase(Scope *S) { // token, in case we are code-completing in the middle of the switch and not // at the end. However, we aren't able to do so at the moment. llvm::SmallPtrSet EnumeratorsSeen; - NestedNameSpecifier *Qualifier = 0; + NestedNameSpecifier *Qualifier = nullptr; for (SwitchCase *SC = Switch->getSwitchCaseList(); SC; SC = SC->getNextSwitchCase()) { CaseStmt *Case = dyn_cast(SC); @@ -3785,7 +3787,7 @@ void Sema::CodeCompleteCase(Scope *S) { continue; CodeCompletionResult R(E, CCP_EnumInCase, Qualifier); - Results.AddResult(R, CurContext, 0, false); + Results.AddResult(R, CurContext, nullptr, false); } Results.ExitScope(); @@ -4141,8 +4143,9 @@ void Sema::CodeCompleteNamespaceDecl(Scope *S) { NSEnd = OrigToLatest.end(); NS != NSEnd; ++NS) Results.AddResult(CodeCompletionResult( - NS->second, Results.getBasePriority(NS->second), 0), - CurContext, 0, false); + NS->second, Results.getBasePriority(NS->second), + nullptr), + CurContext, nullptr, false); Results.ExitScope(); } @@ -4347,7 +4350,7 @@ void Sema::CodeCompleteLambdaIntroducer(Scope *S, LambdaIntroducer &Intro, if (Known.insert(Var->getIdentifier())) Results.AddResult(CodeCompletionResult(Var, CCP_LocalDeclaration), - CurContext, 0, false); + CurContext, nullptr, false); } } @@ -4816,8 +4819,8 @@ static void AddObjCMethods(ObjCContainerDecl *Container, if (!Selectors.insert(M->getSelector())) continue; - - Result R = Result(M, Results.getBasePriority(M), 0); + + Result R = Result(M, Results.getBasePriority(M), nullptr); R.StartParameter = SelIdents.size(); R.AllParametersAreInformative = (WantKind != MK_Any); if (!InOriginalClass) @@ -5019,22 +5022,22 @@ void Sema::CodeCompleteObjCPassingType(Scope *S, ObjCDeclSpec &DS, static ObjCInterfaceDecl *GetAssumedMessageSendExprType(Expr *E) { ObjCMessageExpr *Msg = dyn_cast_or_null(E); if (!Msg) - return 0; + return nullptr; Selector Sel = Msg->getSelector(); if (Sel.isNull()) - return 0; + return nullptr; IdentifierInfo *Id = Sel.getIdentifierInfoForSlot(0); if (!Id) - return 0; + return nullptr; ObjCMethodDecl *Method = Msg->getMethodDecl(); if (!Method) - return 0; + return nullptr; // Determine the class that we're sending the message to. - ObjCInterfaceDecl *IFace = 0; + ObjCInterfaceDecl *IFace = nullptr; switch (Msg->getReceiverKind()) { case ObjCMessageExpr::Class: if (const ObjCObjectType *ObjType @@ -5055,7 +5058,7 @@ static ObjCInterfaceDecl *GetAssumedMessageSendExprType(Expr *E) { } if (!IFace) - return 0; + return nullptr; ObjCInterfaceDecl *Super = IFace->getSuperClass(); if (Method->isInstanceMethod()) @@ -5072,7 +5075,7 @@ static ObjCInterfaceDecl *GetAssumedMessageSendExprType(Expr *E) { .Case("class", IFace) .Case("classForCoder", IFace) .Case("superclass", Super) - .Default(0); + .Default(nullptr); return llvm::StringSwitch(Id->getName()) .Case("new", IFace) @@ -5080,7 +5083,7 @@ static ObjCInterfaceDecl *GetAssumedMessageSendExprType(Expr *E) { .Case("allocWithZone", IFace) .Case("class", IFace) .Case("superclass", Super) - .Default(0); + .Default(nullptr); } // Add a special completion for a message send to "super", which fills in the @@ -5105,14 +5108,14 @@ static ObjCMethodDecl *AddSuperSendCompletion( ResultBuilder &Results) { ObjCMethodDecl *CurMethod = S.getCurMethodDecl(); if (!CurMethod) - return 0; - + return nullptr; + ObjCInterfaceDecl *Class = CurMethod->getClassInterface(); if (!Class) - return 0; - + return nullptr; + // Try to find a superclass method with the same selector. - ObjCMethodDecl *SuperMethod = 0; + ObjCMethodDecl *SuperMethod = nullptr; while ((Class = Class->getSuperClass()) && !SuperMethod) { // Check in the class SuperMethod = Class->getMethod(CurMethod->getSelector(), @@ -5129,13 +5132,13 @@ static ObjCMethodDecl *AddSuperSendCompletion( } if (!SuperMethod) - return 0; - + return nullptr; + // Check whether the superclass method has the same signature. if (CurMethod->param_size() != SuperMethod->param_size() || CurMethod->isVariadic() != SuperMethod->isVariadic()) - return 0; - + return nullptr; + for (ObjCMethodDecl::param_iterator CurP = CurMethod->param_begin(), CurPEnd = CurMethod->param_end(), SuperP = SuperMethod->param_begin(); @@ -5143,11 +5146,11 @@ static ObjCMethodDecl *AddSuperSendCompletion( // Make sure the parameter types are compatible. if (!S.Context.hasSameUnqualifiedType((*CurP)->getType(), (*SuperP)->getType())) - return 0; - + return nullptr; + // Make sure we have a parameter name to forward! if (!(*CurP)->getIdentifier()) - return 0; + return nullptr; } // We have a superclass method. Now, form the send-to-super completion. @@ -5242,7 +5245,7 @@ void Sema::CodeCompleteObjCMessageReceiver(Scope *S) { void Sema::CodeCompleteObjCSuperMessage(Scope *S, SourceLocation SuperLoc, ArrayRef SelIdents, bool AtArgumentExpression) { - ObjCInterfaceDecl *CDecl = 0; + ObjCInterfaceDecl *CDecl = nullptr; if (ObjCMethodDecl *CurMethod = getCurMethodDecl()) { // Figure out which interface we're in. CDecl = CurMethod->getClassInterface(); @@ -5258,7 +5261,7 @@ void Sema::CodeCompleteObjCSuperMessage(Scope *S, SourceLocation SuperLoc, // We are inside an instance method, which means that the message // send [super ...] is actually calling an instance method on the // current object. - return CodeCompleteObjCInstanceMessage(S, 0, SelIdents, + return CodeCompleteObjCInstanceMessage(S, nullptr, SelIdents, AtArgumentExpression, CDecl); } @@ -5343,12 +5346,12 @@ static void AddClassMessageCompletions(Sema &SemaRef, Scope *S, bool IsSuper, ResultBuilder &Results) { typedef CodeCompletionResult Result; - ObjCInterfaceDecl *CDecl = 0; - + ObjCInterfaceDecl *CDecl = nullptr; + // If the given name refers to an interface type, retrieve the // corresponding declaration. if (Receiver) { - QualType T = SemaRef.GetTypeFromParser(Receiver, 0); + QualType T = SemaRef.GetTypeFromParser(Receiver, nullptr); if (!T.isNull()) if (const ObjCObjectType *Interface = T->getAs()) CDecl = Interface->getInterface(); @@ -5401,8 +5404,9 @@ static void AddClassMessageCompletions(Sema &SemaRef, Scope *S, MethList = MethList->getNext()) { if (!isAcceptableObjCMethod(MethList->Method, MK_Any, SelIdents)) continue; - - Result R(MethList->Method, Results.getBasePriority(MethList->Method),0); + + Result R(MethList->Method, Results.getBasePriority(MethList->Method), + nullptr); R.StartParameter = SelIdents.size(); R.AllParametersAreInformative = false; Results.MaybeAddResult(R, SemaRef.CurContext); @@ -5576,8 +5580,9 @@ void Sema::CodeCompleteObjCInstanceMessage(Scope *S, Expr *Receiver, if (!Selectors.insert(MethList->Method->getSelector())) continue; - - Result R(MethList->Method, Results.getBasePriority(MethList->Method),0); + + Result R(MethList->Method, Results.getBasePriority(MethList->Method), + nullptr); R.StartParameter = SelIdents.size(); R.AllParametersAreInformative = false; Results.MaybeAddResult(R, CurContext); @@ -5693,8 +5698,8 @@ static void AddProtocolResults(DeclContext *Ctx, DeclContext *CurContext, // Record any protocols we find. if (const auto *Proto = dyn_cast(D)) if (!OnlyForwardDeclarations || !Proto->hasDefinition()) - Results.AddResult(Result(Proto, Results.getBasePriority(Proto), 0), - CurContext, 0, false); + Results.AddResult(Result(Proto, Results.getBasePriority(Proto),nullptr), + CurContext, nullptr, false); } } @@ -5760,8 +5765,8 @@ static void AddInterfaceResults(DeclContext *Ctx, DeclContext *CurContext, if (const auto *Class = dyn_cast(D)) if ((!OnlyForwardDeclarations || !Class->hasDefinition()) && (!OnlyUnimplemented || !Class->getImplementation())) - Results.AddResult(Result(Class, Results.getBasePriority(Class), 0), - CurContext, 0, false); + Results.AddResult(Result(Class, Results.getBasePriority(Class),nullptr), + CurContext, nullptr, false); } } @@ -5854,8 +5859,9 @@ void Sema::CodeCompleteObjCInterfaceCategory(Scope *S, for (const auto *D : TU->decls()) if (const auto *Category = dyn_cast(D)) if (CategoryNames.insert(Category->getIdentifier())) - Results.AddResult(Result(Category, Results.getBasePriority(Category),0), - CurContext, 0, false); + Results.AddResult(Result(Category, Results.getBasePriority(Category), + nullptr), + CurContext, nullptr, false); Results.ExitScope(); HandleCodeCompleteResults(this, CodeCompleter, @@ -5891,8 +5897,8 @@ void Sema::CodeCompleteObjCImplementationCategory(Scope *S, for (const auto *Cat : Class->visible_categories()) { if ((!IgnoreImplemented || !Cat->getImplementation()) && CategoryNames.insert(Cat->getIdentifier())) - Results.AddResult(Result(Cat, Results.getBasePriority(Cat), 0), - CurContext, 0, false); + Results.AddResult(Result(Cat, Results.getBasePriority(Cat), nullptr), + CurContext, nullptr, false); } Class = Class->getSuperClass(); @@ -5959,7 +5965,7 @@ void Sema::CodeCompleteObjCPropertySynthesizeIvar(Scope *S, return; // Figure out which interface we're looking into. - ObjCInterfaceDecl *Class = 0; + ObjCInterfaceDecl *Class = nullptr; if (ObjCImplementationDecl *ClassImpl = dyn_cast(Container)) Class = ClassImpl->getClassInterface(); @@ -5991,9 +5997,9 @@ void Sema::CodeCompleteObjCPropertySynthesizeIvar(Scope *S, for(; Class; Class = Class->getSuperClass()) { for (ObjCIvarDecl *Ivar = Class->all_declared_ivar_begin(); Ivar; Ivar = Ivar->getNextIvar()) { - Results.AddResult(Result(Ivar, Results.getBasePriority(Ivar), 0), - CurContext, 0, false); - + Results.AddResult(Result(Ivar, Results.getBasePriority(Ivar), nullptr), + CurContext, nullptr, false); + // Determine whether we've seen an ivar with a name similar to the // property. if ((PropertyName == Ivar->getIdentifier() || @@ -6186,10 +6192,10 @@ static void AddObjCKeyValueCompletions(ObjCPropertyDecl *Property, CodeCompletionAllocator &Allocator; StringRef Key; const char *CopiedKey; - + KeyHolder(CodeCompletionAllocator &Allocator, StringRef Key) - : Allocator(Allocator), Key(Key), CopiedKey(0) { } - + : Allocator(Allocator), Key(Key), CopiedKey(nullptr) {} + operator const char *() { if (CopiedKey) return CopiedKey; @@ -6791,13 +6797,13 @@ void Sema::CodeCompleteObjCMethodDecl(Scope *S, // Determine the return type of the method we're declaring, if // provided. QualType ReturnType = GetTypeFromParser(ReturnTy); - Decl *IDecl = 0; + Decl *IDecl = nullptr; if (CurContext->isObjCContainer()) { ObjCContainerDecl *OCD = dyn_cast(CurContext); IDecl = cast(OCD); } // Determine where we should start searching for methods. - ObjCContainerDecl *SearchDecl = 0; + ObjCContainerDecl *SearchDecl = nullptr; bool IsInImplementation = false; if (Decl *D = IDecl) { if (ObjCImplementationDecl *Impl = dyn_cast(D)) { @@ -6819,7 +6825,7 @@ void Sema::CodeCompleteObjCMethodDecl(Scope *S, if (!SearchDecl) { HandleCodeCompleteResults(this, CodeCompleter, CodeCompletionContext::CCC_Other, - 0, 0); + nullptr, 0); return; } @@ -7000,8 +7006,9 @@ void Sema::CodeCompleteObjCMethodDeclSelector(Scope *S, continue; } - - Result R(MethList->Method, Results.getBasePriority(MethList->Method), 0); + + Result R(MethList->Method, Results.getBasePriority(MethList->Method), + nullptr); R.StartParameter = SelIdents.size(); R.AllParametersAreInformative = false; R.DeclaringEntity = true; @@ -7247,7 +7254,7 @@ void Sema::CodeCompletePreprocessorMacroArgument(Scope *S, void Sema::CodeCompleteNaturalLanguage() { HandleCodeCompleteResults(this, CodeCompleter, CodeCompletionContext::CCC_NaturalLanguage, - 0, 0); + nullptr, 0); } void Sema::GatherGlobalCodeCompletions(CodeCompletionAllocator &Allocator, diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 1501be8..3945830 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -144,7 +144,7 @@ ParsedType Sema::getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, bool WantNontrivialTypeSourceInfo, IdentifierInfo **CorrectedII) { // Determine where we will perform name lookup. - DeclContext *LookupCtx = 0; + DeclContext *LookupCtx = nullptr; if (ObjectTypePtr) { QualType ObjectType = ObjectTypePtr.get(); if (ObjectType->isRecordType()) @@ -210,8 +210,8 @@ ParsedType Sema::getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, // Perform unqualified name lookup. LookupName(Result, S); } - - NamedDecl *IIDecl = 0; + + NamedDecl *IIDecl = nullptr; switch (Result.getResultKind()) { case LookupResult::NotFound: case LookupResult::NotFoundInCurrentInstantiation: @@ -582,7 +582,7 @@ Sema::NameClassification Sema::ClassifyName(Scope *S, if (NextToken.is(tok::coloncolon)) { BuildCXXNestedNameSpecifier(S, *Name, NameLoc, NextToken.getLocation(), - QualType(), false, SS, 0, false); + QualType(), false, SS, nullptr, false); } LookupResult Result(*this, Name, NameLoc, LookupOrdinaryName); @@ -652,7 +652,7 @@ Corrected: NamedDecl *FirstDecl = Corrected.getCorrectionDecl(); NamedDecl *UnderlyingFirstDecl - = FirstDecl? FirstDecl->getUnderlyingDecl() : 0; + = FirstDecl? FirstDecl->getUnderlyingDecl() : nullptr; if (getLangOpts().CPlusPlus && NextToken.is(tok::less) && UnderlyingFirstDecl && isa(UnderlyingFirstDecl)) { UnqualifiedDiag = diag::err_no_template_suggest; @@ -725,7 +725,7 @@ Corrected: // keyword here. return ActOnDependentIdExpression(SS, /*TemplateKWLoc=*/SourceLocation(), NameInfo, IsAddressOfOperand, - /*TemplateArgs=*/0); + /*TemplateArgs=*/nullptr); } case LookupResult::Found: @@ -857,7 +857,8 @@ Corrected: } if (FirstDecl->isCXXClassMember()) - return BuildPossibleImplicitMemberExpr(SS, SourceLocation(), Result, 0); + return BuildPossibleImplicitMemberExpr(SS, SourceLocation(), Result, + nullptr); bool ADL = UseArgumentDependentLookup(SS, Result, NextToken.is(tok::l_paren)); return BuildDeclarationNameExpr(SS, Result, ADL); @@ -1096,7 +1097,7 @@ Scope *Sema::getScopeForDeclContext(Scope *S, DeclContext *DC) { return S; } while ((S = S->getParent())); - return 0; + return nullptr; } static bool isOutOfScopePreviousDeclaration(NamedDecl *, @@ -1364,7 +1365,7 @@ static void CheckPoppedLabel(LabelDecl *L, Sema &S) { // Verify that we have no forward references left. If so, there was a goto // or address of a label taken, but no definition of it. Label fwd // definitions are indicated with a null substmt. - if (L->getStmt() == 0) + if (L->getStmt() == nullptr) S.Diag(L->getLocation(), diag::err_undeclared_label_use) <getDeclName(); } @@ -1421,7 +1422,7 @@ ObjCInterfaceDecl *Sema::getObjCInterfaceDecl(IdentifierInfo *&Id, // find an Objective-C class name. DeclFilterCCC Validator; if (TypoCorrection C = CorrectTypo(DeclarationNameInfo(Id, IdLoc), - LookupOrdinaryName, TUScope, NULL, + LookupOrdinaryName, TUScope, nullptr, Validator, CTK_ErrorRecovery)) { diagnoseTypo(C, PDiag(diag::err_undef_interface_suggest) << Id); IDecl = C.getCorrectionDeclAs(); @@ -1506,19 +1507,19 @@ NamedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, unsigned bid, if (ForRedeclaration) Diag(Loc, diag::warn_implicit_decl_requires_stdio) << Context.BuiltinInfo.GetName(BID); - return 0; + return nullptr; case ASTContext::GE_Missing_setjmp: if (ForRedeclaration) Diag(Loc, diag::warn_implicit_decl_requires_setjmp) << Context.BuiltinInfo.GetName(BID); - return 0; + return nullptr; case ASTContext::GE_Missing_ucontext: if (ForRedeclaration) Diag(Loc, diag::warn_implicit_decl_requires_ucontext) << Context.BuiltinInfo.GetName(BID); - return 0; + return nullptr; } if (!ForRedeclaration && Context.BuiltinInfo.isPredefinedLibFunction(BID)) { @@ -1545,7 +1546,7 @@ NamedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, unsigned bid, FunctionDecl *New = FunctionDecl::Create(Context, Parent, - Loc, Loc, II, R, /*TInfo=*/0, + Loc, Loc, II, R, /*TInfo=*/nullptr, SC_Extern, false, /*hasPrototype=*/true); @@ -1558,7 +1559,8 @@ NamedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, unsigned bid, for (unsigned i = 0, e = FT->getNumParams(); i != e; ++i) { ParmVarDecl *parm = ParmVarDecl::Create(Context, New, SourceLocation(), SourceLocation(), - 0, FT->getParamType(i), /*TInfo=*/0, SC_None, 0); + nullptr, FT->getParamType(i), /*TInfo=*/nullptr, + SC_None, nullptr); parm->setScopeInfo(0, i); Params.push_back(parm); } @@ -1819,8 +1821,8 @@ static bool isAttributeTargetADefinition(Decl *D) { static bool mergeAlignedAttrs(Sema &S, NamedDecl *New, Decl *Old) { // Look for alignas attributes on Old, and pick out whichever attribute // specifies the strictest alignment requirement. - AlignedAttr *OldAlignasAttr = 0; - AlignedAttr *OldStrictestAlignAttr = 0; + AlignedAttr *OldAlignasAttr = nullptr; + AlignedAttr *OldStrictestAlignAttr = nullptr; unsigned OldAlign = 0; for (auto *I : Old->specific_attrs()) { // FIXME: We have no way of representing inherited dependent alignments @@ -1843,7 +1845,7 @@ static bool mergeAlignedAttrs(Sema &S, NamedDecl *New, Decl *Old) { } // Look for alignas attributes on New. - AlignedAttr *NewAlignasAttr = 0; + AlignedAttr *NewAlignasAttr = nullptr; unsigned NewAlign = 0; for (auto *I : New->specific_attrs()) { if (I->isAlignmentDependent()) @@ -1986,7 +1988,7 @@ static const Decl *getDefinition(const Decl *D) { if (FD->isDefined(Def)) return Def; } - return NULL; + return nullptr; } static bool hasAttribute(const Decl *D, attr::Kind Kind) { @@ -2278,7 +2280,7 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *&OldD, !Old->getDeclContext()->getRedeclContext()->Equals( New->getDeclContext()->getRedeclContext()) && !(Old->isExternC() && New->isExternC())) - Old = 0; + Old = nullptr; if (!Old) { Diag(New->getLocation(), diag::err_using_decl_conflict_reverse); @@ -2641,7 +2643,7 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *&OldD, Context.typesAreCompatible(OldQType, NewQType)) { const FunctionType *OldFuncType = OldQType->getAs(); const FunctionType *NewFuncType = NewQType->getAs(); - const FunctionProtoType *OldProto = 0; + const FunctionProtoType *OldProto = nullptr; if (MergeTypeWithOld && isa(NewFuncType) && (OldProto = dyn_cast(OldFuncType))) { // The old declaration provided a function prototype, but the @@ -2658,8 +2660,9 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *&OldD, SmallVector Params; for (const auto &ParamType : OldProto->param_types()) { ParmVarDecl *Param = ParmVarDecl::Create(Context, New, SourceLocation(), - SourceLocation(), 0, ParamType, - /*TInfo=*/0, SC_None, 0); + SourceLocation(), nullptr, + ParamType, /*TInfo=*/nullptr, + SC_None, nullptr); Param->setScopeInfo(0, Params.size()); Param->setImplicit(); Params.push_back(Param); @@ -2967,12 +2970,12 @@ void Sema::MergeVarDecl(VarDecl *New, LookupResult &Previous) { VarTemplateDecl *NewTemplate = New->getDescribedVarTemplate(); // Verify the old decl was also a variable or variable template. - VarDecl *Old = 0; - VarTemplateDecl *OldTemplate = 0; + VarDecl *Old = nullptr; + VarTemplateDecl *OldTemplate = nullptr; if (Previous.isSingleResult()) { if (NewTemplate) { OldTemplate = dyn_cast(Previous.getFoundDecl()); - Old = OldTemplate ? OldTemplate->getTemplatedDecl() : 0; + Old = OldTemplate ? OldTemplate->getTemplatedDecl() : nullptr; } else Old = dyn_cast(Previous.getFoundDecl()); } @@ -3169,8 +3172,8 @@ Decl *Sema::ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, DeclSpec &DS, MultiTemplateParamsArg TemplateParams, bool IsExplicitInstantiation) { - Decl *TagD = 0; - TagDecl *Tag = 0; + Decl *TagD = nullptr; + TagDecl *Tag = nullptr; if (DS.getTypeSpecType() == DeclSpec::TST_class || DS.getTypeSpecType() == DeclSpec::TST_struct || DS.getTypeSpecType() == DeclSpec::TST_interface || @@ -3179,7 +3182,7 @@ Decl *Sema::ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, TagD = DS.getRepAsDecl(); if (!TagD) // We probably had an error - return 0; + return nullptr; // Note that the above type specs guarantee that the // type rep is a Decl, whereas in many of the others @@ -3227,7 +3230,7 @@ Decl *Sema::ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, // If we're dealing with a decl but not a TagDecl, assume that // whatever routines created it handled the friendship aspect. if (TagD && !Tag) - return 0; + return nullptr; return ActOnFriendTypeDecl(S, DS, TemplateParams); } @@ -3246,7 +3249,7 @@ Decl *Sema::ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, DS.getTypeSpecType() == DeclSpec::TST_interface ? 2 : DS.getTypeSpecType() == DeclSpec::TST_union ? 3 : 4) << SS.getRange(); - return 0; + return nullptr; } // Track whether this decl-specifier declares anything. @@ -3572,7 +3575,7 @@ Decl *Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, // structs/unions. bool Invalid = false; if (getLangOpts().CPlusPlus) { - const char* PrevSpec = 0; + const char *PrevSpec = nullptr; unsigned DiagID; if (Record->isUnion()) { // C++ [class.union]p6: @@ -3728,15 +3731,15 @@ Decl *Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, assert(TInfo && "couldn't build declarator info for anonymous struct/union"); // Create a declaration for this anonymous struct/union. - NamedDecl *Anon = 0; + NamedDecl *Anon = nullptr; if (RecordDecl *OwningClass = dyn_cast(Owner)) { Anon = FieldDecl::Create(Context, OwningClass, DS.getLocStart(), Record->getLocation(), - /*IdentifierInfo=*/0, + /*IdentifierInfo=*/nullptr, Context.getTypeDeclType(Record), TInfo, - /*BitWidth=*/0, /*Mutable=*/false, + /*BitWidth=*/nullptr, /*Mutable=*/false, /*InitStyle=*/ICIS_NoInit); Anon->setAccess(AS); if (getLangOpts().CPlusPlus) @@ -3754,7 +3757,7 @@ Decl *Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, Anon = VarDecl::Create(Context, Owner, DS.getLocStart(), - Record->getLocation(), /*IdentifierInfo=*/0, + Record->getLocation(), /*IdentifierInfo=*/nullptr, Context.getTypeDeclType(Record), TInfo, SC); @@ -3828,14 +3831,14 @@ Decl *Sema::BuildMicrosoftCAnonymousStruct(Scope *S, DeclSpec &DS, assert(TInfo && "couldn't build declarator info for anonymous struct"); // Create a declaration for this anonymous struct. - NamedDecl* Anon = FieldDecl::Create(Context, + NamedDecl *Anon = FieldDecl::Create(Context, cast(CurContext), DS.getLocStart(), DS.getLocStart(), - /*IdentifierInfo=*/0, + /*IdentifierInfo=*/nullptr, Context.getTypeDeclType(Record), TInfo, - /*BitWidth=*/0, /*Mutable=*/false, + /*BitWidth=*/nullptr, /*Mutable=*/false, /*InitStyle=*/ICIS_NoInit); Anon->setImplicit(); @@ -3937,7 +3940,7 @@ Sema::GetNameFromUnqualifiedId(const UnqualifiedId &Name) { Context.getCanonicalType(CurClassType))); NameInfo.setLoc(Name.StartLocation); // FIXME: should we retrieve TypeSourceInfo? - NameInfo.setNamedTypeInfo(0); + NameInfo.setNamedTypeInfo(nullptr); return NameInfo; } @@ -4033,7 +4036,7 @@ static bool RebuildDeclaratorInCurrentInstantiation(Sema &S, Declarator &D, case DeclSpec::TST_underlyingType: case DeclSpec::TST_atomic: { // Grab the type from the parser. - TypeSourceInfo *TSI = 0; + TypeSourceInfo *TSI = nullptr; QualType T = S.GetTypeFromParser(DS.getRepAsType(), &TSI); if (T.isNull() || !T->isDependentType()) break; @@ -4225,9 +4228,9 @@ NamedDecl *Sema::HandleDeclarator(Scope *S, Declarator &D, Diag(D.getDeclSpec().getLocStart(), diag::err_declarator_need_ident) << D.getDeclSpec().getSourceRange() << D.getSourceRange(); - return 0; + return nullptr; } else if (DiagnoseUnexpandedParameterPack(NameInfo, UPPC_DeclarationType)) - return 0; + return nullptr; // The scope passed in may not be a decl scope. Zip up the scope tree until // we find one that is. @@ -4241,7 +4244,7 @@ NamedDecl *Sema::HandleDeclarator(Scope *S, Declarator &D, else if (D.getCXXScopeSpec().isSet()) { if (DiagnoseUnexpandedParameterPack(D.getCXXScopeSpec(), UPPC_DeclarationQualifier)) - return 0; + return nullptr; bool EnteringContext = !D.getDeclSpec().isFriendSpecified(); DC = computeDeclContext(D.getCXXScopeSpec(), EnteringContext); @@ -4254,13 +4257,13 @@ NamedDecl *Sema::HandleDeclarator(Scope *S, Declarator &D, diag::err_template_qualified_declarator_no_match) << D.getCXXScopeSpec().getScopeRep() << D.getCXXScopeSpec().getRange(); - return 0; + return nullptr; } bool IsDependentContext = DC->isDependentContext(); if (!IsDependentContext && RequireCompleteDeclContext(D.getCXXScopeSpec(), DC)) - return 0; + return nullptr; if (isa(DC) && !cast(DC)->hasDefinition()) { Diag(D.getIdentifierLoc(), @@ -4271,8 +4274,8 @@ NamedDecl *Sema::HandleDeclarator(Scope *S, Declarator &D, if (diagnoseQualifiedDeclaration(D.getCXXScopeSpec(), DC, Name, D.getIdentifierLoc())) { if (DC->isRecord()) - return 0; - + return nullptr; + D.setInvalidType(); } } @@ -4291,8 +4294,8 @@ NamedDecl *Sema::HandleDeclarator(Scope *S, Declarator &D, // If this is a typedef, we'll end up spewing multiple diagnostics. // Just return early; it's safer. if (D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_typedef) - return 0; - + return nullptr; + TypeSourceInfo *TInfo = GetTypeForDeclarator(D, S); QualType R = TInfo->getType(); @@ -4393,7 +4396,7 @@ NamedDecl *Sema::HandleDeclarator(Scope *S, Declarator &D, if (D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_typedef) { if (TemplateParamLists.size()) { Diag(D.getIdentifierLoc(), diag::err_template_typedef); - return 0; + return nullptr; } New = ActOnTypedefDeclarator(S, D, DC, TInfo, Previous); @@ -4406,8 +4409,8 @@ NamedDecl *Sema::HandleDeclarator(Scope *S, Declarator &D, AddToScope); } - if (New == 0) - return 0; + if (!New) + return nullptr; // If this has an identifier and is not an invalid redeclaration or // function template specialization, add it to the scope stack. @@ -4534,7 +4537,7 @@ TryToFixInvalidVariablyModifiedTypeSourceInfo(TypeSourceInfo *TInfo, = TryToFixInvalidVariablyModifiedType(TInfo->getType(), Context, SizeIsNegative, Oversized); if (FixedTy.isNull()) - return 0; + return nullptr; TypeSourceInfo *FixedTInfo = Context.getTrivialTypeSourceInfo(FixedTy); FixInvalidVariablyModifiedTypeLoc(TInfo->getTypeLoc(), FixedTInfo->getTypeLoc()); @@ -4573,7 +4576,7 @@ NamedDecl *Sema::findLocallyScopedExternCDecl(DeclarationName Name) { } NamedDecl *D = LocallyScopedExternCDecls.lookup(Name); - return D ? D->getMostRecentDecl() : 0; + return D ? D->getMostRecentDecl() : nullptr; } /// \brief Diagnose function specifiers on a declaration of an identifier that @@ -4620,11 +4623,11 @@ Sema::ActOnTypedefDeclarator(Scope* S, Declarator& D, DeclContext* DC, if (D.getName().Kind != UnqualifiedId::IK_Identifier) { Diag(D.getName().StartLocation, diag::err_typedef_not_identifier) << D.getName().getSourceRange(); - return 0; + return nullptr; } TypedefDecl *NewTD = ParseTypedefDecl(S, D, TInfo->getType(), TInfo); - if (!NewTD) return 0; + if (!NewTD) return nullptr; // Handle attributes prior to checking for duplicates in MergeVarDecl ProcessDeclAttributes(S, NewTD, D); @@ -4648,7 +4651,7 @@ Sema::CheckTypedefForVariablyModifiedType(Scope *S, TypedefNameDecl *NewTD) { if (T->isVariablyModifiedType()) { getCurFunction()->setHasBranchProtectedScope(); - if (S->getFnParent() == 0) { + if (S->getFnParent() == nullptr) { bool SizeIsNegative; llvm::APSInt Oversized; TypeSourceInfo *FixedTInfo = @@ -5109,12 +5112,12 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, if (!II) { Diag(D.getIdentifierLoc(), diag::err_bad_variable_name) << Name; - return 0; + return nullptr; } DiagnoseFunctionSpecifiers(D.getDeclSpec()); - if (!DC->isRecord() && S->getFnParent() == 0) { + if (!DC->isRecord() && S->getFnParent() == nullptr) { // C99 6.9p2: The storage-class specifiers auto and register shall not // appear in the declaration specifiers in an external declaration. // Global Register+Asm is a GNU extension we support. @@ -5144,7 +5147,7 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, // The event type cannot be used with the __local, __constant and __global // address space qualifiers. if (R->isEventT()) { - if (S->getParent() == 0) { + if (S->getParent() == nullptr) { Diag(D.getLocStart(), diag::err_event_t_global_var); D.setInvalidType(); } @@ -5160,9 +5163,9 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, bool IsVariableTemplateSpecialization = false; bool IsPartialSpecialization = false; bool IsVariableTemplate = false; - VarDecl *NewVD = 0; - VarTemplateDecl *NewTemplate = 0; - TemplateParameterList *TemplateParams = 0; + VarDecl *NewVD = nullptr; + VarTemplateDecl *NewTemplate = nullptr; + TemplateParameterList *TemplateParams = nullptr; if (!getLangOpts().CPlusPlus) { NewVD = VarDecl::Create(Context, DC, D.getLocStart(), D.getIdentifierLoc(), II, @@ -5231,7 +5234,7 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, D.getCXXScopeSpec(), D.getName().getKind() == UnqualifiedId::IK_TemplateId ? D.getName().TemplateId - : 0, + : nullptr, TemplateParamLists, /*never a friend*/ false, IsExplicitSpecialization, Invalid); @@ -5245,7 +5248,7 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, << II << SourceRange(TemplateParams->getTemplateLoc(), TemplateParams->getRAngleLoc()); - TemplateParams = 0; + TemplateParams = nullptr; } else { if (D.getName().getKind() == UnqualifiedId::IK_TemplateId) { // This is an explicit specialization or a partial specialization. @@ -5258,7 +5261,7 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, // Check that we can declare a template here. if (CheckTemplateDeclScope(S, TemplateParams)) - return 0; + return nullptr; // Only C++1y supports variable templates (N3651). Diag(D.getIdentifierLoc(), @@ -5281,7 +5284,7 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, S, D, TInfo, TemplateKWLoc, TemplateParams, SC, IsPartialSpecialization); if (Res.isInvalid()) - return 0; + return nullptr; NewVD = cast(Res.get()); AddToScope = false; } else @@ -5362,7 +5365,7 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, // that a local variable with thread storage duration still has to // be marked 'static'. Also note that it's possible to get these // semantics in C++ using __attribute__((gnu_inline)). - if (SC == SC_Static && S->getFnParent() != 0 && + if (SC == SC_Static && S->getFnParent() != nullptr && !NewVD->getType().isConstQualified()) { FunctionDecl *CurFD = getCurFunctionDecl(); if (CurFD && isFunctionDefinitionDiscarded(*this, CurFD)) { @@ -5400,7 +5403,7 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, if (getLangOpts().CUDA) { // CUDA B.2.5: "__shared__ and __constant__ variables have implied static // storage [duration]." - if (SC == SC_None && S->getFnParent() != 0 && + if (SC == SC_None && S->getFnParent() != nullptr && (NewVD->hasAttr() || NewVD->hasAttr())) { NewVD->setStorageClass(SC_Static); @@ -5424,7 +5427,7 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, // The parser guarantees this is a string. StringLiteral *SE = cast(E); StringRef Label = SE->getString(); - if (S->getFnParent() != 0) { + if (S->getFnParent() != nullptr) { switch (SC) { case SC_None: case SC_Auto: @@ -5513,7 +5516,7 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, VarTemplateDecl *PrevVarTemplate = NewVD->getPreviousDecl() ? NewVD->getPreviousDecl()->getDescribedVarTemplate() - : 0; + : nullptr; // Check the template parameter list of this declaration, possibly // merging in the template parameter list from the previous variable @@ -5521,7 +5524,7 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, if (CheckTemplateParameterList( TemplateParams, PrevVarTemplate ? PrevVarTemplate->getTemplateParameters() - : 0, + : nullptr, (D.getCXXScopeSpec().isSet() && DC && DC->isRecord() && DC->isDependentContext()) ? TPC_ClassTemplateMember @@ -5856,7 +5859,7 @@ void Sema::CheckVariableDeclarationType(VarDecl *NewVD) { TypeSourceInfo *FixedTInfo = TryToFixInvalidVariablyModifiedTypeSourceInfo(TInfo, Context, SizeIsNegative, Oversized); - if (FixedTInfo == 0 && T->isVariableArrayType()) { + if (!FixedTInfo && T->isVariableArrayType()) { const VariableArrayType *VAT = Context.getAsVariableArrayType(T); // FIXME: This won't give the correct result for // int a[10][n]; @@ -5875,7 +5878,7 @@ void Sema::CheckVariableDeclarationType(VarDecl *NewVD) { return; } - if (FixedTInfo == 0) { + if (!FixedTInfo) { if (NewVD->isFileVarDecl()) Diag(NewVD->getLocation(), diag::err_vm_decl_in_file_scope); else @@ -6078,7 +6081,7 @@ class DifferentNameValidatorCCC : public CorrectionCandidateCallback { DifferentNameValidatorCCC(ASTContext &Context, FunctionDecl *TypoFD, CXXRecordDecl *Parent) : Context(Context), OriginalFD(TypoFD), - ExpectedParent(Parent ? Parent->getCanonicalDecl() : 0) {} + ExpectedParent(Parent ? Parent->getCanonicalDecl() : nullptr) {} bool ValidateCandidate(const TypoCorrection &candidate) override { if (candidate.getEditDistance() == 0) @@ -6147,7 +6150,7 @@ static NamedDecl *DiagnoseInvalidRedeclaration( "Cannot have an ambiguity in previous-declaration lookup"); CXXMethodDecl *MD = dyn_cast(NewFD); DifferentNameValidatorCCC Validator(SemaRef.Context, NewFD, - MD ? MD->getParent() : 0); + MD ? MD->getParent() : nullptr); if (!Prev.empty()) { for (LookupResult::iterator Func = Prev.begin(), FuncEnd = Prev.end(); Func != FuncEnd; ++Func) { @@ -6165,7 +6168,7 @@ static NamedDecl *DiagnoseInvalidRedeclaration( } else if ((Correction = SemaRef.CorrectTypo( Prev.getLookupNameInfo(), Prev.getLookupKind(), S, &ExtraArgs.D.getCXXScopeSpec(), Validator, - Sema::CTK_ErrorRecovery, IsLocalFriend ? 0 : NewDC))) { + Sema::CTK_ErrorRecovery, IsLocalFriend ? nullptr : NewDC))) { // Set up everything for the call to ActOnFunctionDeclarator ExtraArgs.D.SetIdentifier(Correction.getCorrectionAsIdentifierInfo(), ExtraArgs.D.getIdentifierLoc()); @@ -6199,7 +6202,7 @@ static NamedDecl *DiagnoseInvalidRedeclaration( ExtraArgs.AddToScope); if (Trap.hasErrorOccurred()) - Result = 0; + Result = nullptr; } if (Result) { @@ -6259,7 +6262,7 @@ static NamedDecl *DiagnoseInvalidRedeclaration( IsMember ? diag::note_member_def_close_match : diag::note_local_decl_close_match); } - return 0; + return nullptr; } static FunctionDecl::StorageClass getFunctionStorageClass(Sema &SemaRef, @@ -6306,7 +6309,7 @@ static FunctionDecl* CreateNewFunctionDecl(Sema &SemaRef, Declarator &D, DeclarationNameInfo NameInfo = SemaRef.GetNameForDeclarator(D); DeclarationName Name = NameInfo.getName(); - FunctionDecl *NewFD = 0; + FunctionDecl *NewFD = nullptr; bool isInline = D.getDeclSpec().isInlineSpecified(); if (!SemaRef.getLangOpts().CPlusPlus) { @@ -6396,7 +6399,7 @@ static FunctionDecl* CreateNewFunctionDecl(Sema &SemaRef, Declarator &D, if (!DC->isRecord()) { SemaRef.Diag(D.getIdentifierLoc(), diag::err_conv_function_not_member); - return 0; + return nullptr; } SemaRef.CheckConversionDeclarator(D, R, SC); @@ -6416,7 +6419,7 @@ static FunctionDecl* CreateNewFunctionDecl(Sema &SemaRef, Declarator &D, SemaRef.Diag(D.getIdentifierLoc(), diag::err_constructor_return_type) << SourceRange(D.getDeclSpec().getTypeSpecTypeLoc()) << SourceRange(D.getIdentifierLoc()); - return 0; + return nullptr; } // This is a C++ method declaration. @@ -6535,7 +6538,7 @@ static void checkIsValidOpenCLKernelParameter( // Track where we are in the nested structs. Items will migrate from // VisitStack to HistoryStack as we do the DFS for bad field. SmallVector HistoryStack; - HistoryStack.push_back((const FieldDecl *) 0); + HistoryStack.push_back(nullptr); const RecordDecl *PD = PT->castAs()->getDecl(); VisitStack.push_back(PD); @@ -6564,7 +6567,7 @@ static void checkIsValidOpenCLKernelParameter( } // Add a null marker so we know when we've gone back up a level - VisitStack.push_back((const Decl *) 0); + VisitStack.push_back(nullptr); for (const auto *FD : RD->fields()) { QualType QT = FD->getType(); @@ -6639,7 +6642,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, adjustMemberFunctionCC(R, D.isStaticMember()); bool isFriend = false; - FunctionTemplateDecl *FunctionTemplate = 0; + FunctionTemplateDecl *FunctionTemplate = nullptr; bool isExplicitSpecialization = false; bool isFunctionTemplateSpecialization = false; @@ -6654,7 +6657,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, FunctionDecl *NewFD = CreateNewFunctionDecl(*this, D, DC, R, TInfo, SC, isVirtualOkay); - if (!NewFD) return 0; + if (!NewFD) return nullptr; if (OriginalLexicalContext && OriginalLexicalContext->isObjCContainer()) NewFD->setTopLevelDeclInObjCContainer(); @@ -6704,7 +6707,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, D.getCXXScopeSpec(), D.getName().getKind() == UnqualifiedId::IK_TemplateId ? D.getName().TemplateId - : 0, + : nullptr, TemplateParamLists, isFriend, isExplicitSpecialization, Invalid)) { if (TemplateParams->size() > 0) { @@ -6712,12 +6715,12 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, // Check that we can declare a template here. if (CheckTemplateDeclScope(S, TemplateParams)) - return 0; + return nullptr; // A destructor cannot be a template. if (Name.getNameKind() == DeclarationName::CXXDestructorName) { Diag(NewFD->getLocation(), diag::err_destructor_template); - return 0; + return nullptr; } // If we're adding a template to a dependent context, we may need to @@ -7188,7 +7191,8 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, diag::err_function_specialization_in_class) << NewFD->getDeclName(); } else if (CheckFunctionTemplateSpecialization(NewFD, - (HasExplicitTemplateArgs ? &TemplateArgs : 0), + (HasExplicitTemplateArgs ? &TemplateArgs + : nullptr), Previous)) NewFD->setInvalidDecl(); @@ -7257,7 +7261,8 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, FunctionTemplateDecl *PrevTemplate = FunctionTemplate->getPreviousDecl(); CheckTemplateParameterList(FunctionTemplate->getTemplateParameters(), - PrevTemplate ? PrevTemplate->getTemplateParameters() : 0, + PrevTemplate ? PrevTemplate->getTemplateParameters() + : nullptr, D.getDeclSpec().isFriendSpecified() ? (D.isFunctionDefinition() ? TPC_FriendFunctionTemplateDefinition @@ -7311,7 +7316,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, // whether the parameter types are references). if (NamedDecl *Result = DiagnoseInvalidRedeclaration( - *this, Previous, NewFD, ExtraArgs, false, 0)) { + *this, Previous, NewFD, ExtraArgs, false, nullptr)) { AddToScope = ExtraArgs.AddToScope; return Result; } @@ -7484,7 +7489,7 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, filterNonConflictingPreviousDecls(Context, NewFD, Previous); bool Redeclaration = false; - NamedDecl *OldDecl = 0; + NamedDecl *OldDecl = nullptr; // Merge or overload the declaration with an existing declaration of // the same name, if appropriate. @@ -7520,7 +7525,7 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, // with that name must be marked "overloadable". Diag(NewFD->getLocation(), diag::err_attribute_overloadable_missing) << Redeclaration << NewFD; - NamedDecl *OverloadedDecl = 0; + NamedDecl *OverloadedDecl = nullptr; if (Redeclaration) OverloadedDecl = OldDecl; else if (!Previous.empty()) @@ -7555,7 +7560,7 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, } if (IsOverload(NewFD, cast(OldDecl), false)) { Redeclaration = false; - OldDecl = 0; + OldDecl = nullptr; } } } @@ -7574,7 +7579,7 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, if (!getLangOpts().CPlusPlus1y && MD && MD->isConstexpr() && !MD->isStatic() && !isa(MD) && (MD->getTypeQualifiers() & Qualifiers::Const) == 0) { - CXXMethodDecl *OldMD = 0; + CXXMethodDecl *OldMD = nullptr; if (OldDecl) OldMD = dyn_cast(OldDecl->getAsFunction()); if (!OldMD || !OldMD->isStatic()) { @@ -8115,7 +8120,7 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit, bool TypeMayContainAuto) { // If there is no declaration, there was an error parsing it. Just ignore // the initializer. - if (RealDecl == 0 || RealDecl->isInvalidDecl()) + if (!RealDecl || RealDecl->isInvalidDecl()) return; if (CXXMethodDecl *Method = dyn_cast(RealDecl)) { @@ -8274,8 +8279,8 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, VDecl->setInvalidDecl(); return; } - - const VarDecl* PrevInit = 0; + + const VarDecl *PrevInit = nullptr; if (getLangOpts().CPlusPlus) { // C++ [class.static.data]p4 // If a static data member is of const integral or const @@ -8613,7 +8618,7 @@ void Sema::ActOnInitializerError(Decl *D) { void Sema::ActOnUninitializedDecl(Decl *RealDecl, bool TypeMayContainAuto) { // If there is no declaration, there was an error parsing it. Just ignore it. - if (RealDecl == 0) + if (!RealDecl) return; if (VarDecl *Var = dyn_cast(RealDecl)) { @@ -9112,7 +9117,7 @@ Sema::DeclGroupPtrTy Sema::FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS, if (DS.isTypeSpecOwned()) Decls.push_back(DS.getRepAsDecl()); - DeclaratorDecl *FirstDeclaratorInGroup = 0; + DeclaratorDecl *FirstDeclaratorInGroup = nullptr; for (unsigned i = 0, e = Group.size(); i != e; ++i) if (Decl *D = Group[i]) { if (DeclaratorDecl *DD = dyn_cast(D)) @@ -9147,7 +9152,7 @@ Sema::BuildDeclaratorGroup(llvm::MutableArrayRef Group, if (TypeMayContainAuto && Group.size() > 1) { QualType Deduced; CanQualType DeducedCanon; - VarDecl *DeducedDecl = 0; + VarDecl *DeducedDecl = nullptr; for (unsigned i = 0, e = Group.size(); i != e; ++i) { if (VarDecl *D = dyn_cast(Group[i])) { AutoType *AT = D->getType()->getContainedAutoType(); @@ -9273,7 +9278,7 @@ Decl *Sema::ActOnParamDeclarator(Scope *S, Declarator &D) { } // Ensure we have a valid name - IdentifierInfo *II = 0; + IdentifierInfo *II = nullptr; if (D.hasName()) { II = D.getIdentifier(); if (!II) { @@ -9294,14 +9299,14 @@ Decl *Sema::ActOnParamDeclarator(Scope *S, Declarator &D) { // Maybe we will complain about the shadowed template parameter. DiagnoseTemplateParameterShadow(D.getIdentifierLoc(), PrevDecl); // Just pretend that we didn't see the previous declaration. - PrevDecl = 0; + PrevDecl = nullptr; } else if (S->isDeclScope(PrevDecl)) { Diag(D.getIdentifierLoc(), diag::err_param_redefinition) << II; Diag(PrevDecl->getLocation(), diag::note_previous_declaration); // Recover by removing the name - II = 0; - D.SetIdentifier(0, D.getIdentifierLoc()); + II = nullptr; + D.SetIdentifier(nullptr, D.getIdentifierLoc()); D.setInvalidType(true); } } @@ -9351,9 +9356,9 @@ ParmVarDecl *Sema::BuildParmVarDeclForTypedef(DeclContext *DC, /* FIXME: setting StartLoc == Loc. Would it be worth to modify callers so as to provide proper source location for the unnamed parameters, embedding the parameter's type? */ - ParmVarDecl *Param = ParmVarDecl::Create(Context, DC, Loc, Loc, 0, + ParmVarDecl *Param = ParmVarDecl::Create(Context, DC, Loc, Loc, nullptr, T, Context.getTrivialTypeSourceInfo(T, Loc), - SC_None, 0); + SC_None, nullptr); Param->setImplicit(); return Param; } @@ -9433,7 +9438,7 @@ ParmVarDecl *Sema::CheckParameter(DeclContext *DC, SourceLocation StartLoc, ParmVarDecl *New = ParmVarDecl::Create(Context, DC, StartLoc, NameLoc, Name, Context.getAdjustedParameterType(T), TSInfo, - StorageClass, 0); + StorageClass, nullptr); // Parameters can not be abstract class types. // For record types, this is done by the AbstractClassUsageDiagnoser once @@ -9479,7 +9484,7 @@ void Sema::ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D, if (!FTI.hasPrototype) { for (int i = FTI.NumParams; i != 0; /* decrement in loop */) { --i; - if (FTI.Params[i].Param == 0) { + if (FTI.Params[i].Param == nullptr) { SmallString<256> Code; llvm::raw_svector_ostream(Code) << " int " << FTI.Params[i].Ident->getName() << ";\n"; @@ -9507,7 +9512,7 @@ void Sema::ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D, } Decl *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Declarator &D) { - assert(getCurFunctionDecl() == 0 && "Function parsing confused"); + assert(getCurFunctionDecl() == nullptr && "Function parsing confused"); assert(D.isFunctionDeclarator() && "Not a function declarator!"); Scope *ParentScope = FnBodyScope->getParent(); @@ -9630,11 +9635,11 @@ static void RebuildLambdaScopeInfo(CXXMethodDecl *CallOperator, /*RefersToEnclosingLocal*/true, C.getLocation(), /*EllipsisLoc*/C.isPackExpansion() ? C.getEllipsisLoc() : SourceLocation(), - CaptureType, /*Expr*/ 0); - + CaptureType, /*Expr*/ nullptr); + } else if (C.capturesThis()) { LSI->addThisCapture(/*Nested*/ false, C.getLocation(), - S.getCurrentThisType(), /*Expr*/ 0); + S.getCurrentThisType(), /*Expr*/ nullptr); } } } @@ -9645,7 +9650,7 @@ Decl *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Decl *D) { if (!D) return D; - FunctionDecl *FD = 0; + FunctionDecl *FD = nullptr; if (FunctionTemplateDecl *FunTmpl = dyn_cast(D)) FD = FunTmpl->getTemplatedDecl(); @@ -9697,7 +9702,7 @@ Decl *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Decl *D) { // prototype declaration. This warning is issued even if the // definition itself provides a prototype. The aim is to detect // global functions that fail to be declared in header files. - const FunctionDecl *PossibleZeroParamPrototype = 0; + const FunctionDecl *PossibleZeroParamPrototype = nullptr; if (ShouldWarnAboutMissingPrototype(FD, PossibleZeroParamPrototype)) { Diag(FD->getLocation(), diag::warn_missing_prototype) << FD; @@ -9854,7 +9859,7 @@ Decl *Sema::ActOnSkippedFunctionBody(Decl *Decl) { FD->setHasSkippedBody(); else if (ObjCMethodDecl *MD = dyn_cast_or_null(Decl)) MD->setHasSkippedBody(); - return ActOnFinishFunctionBody(Decl, 0); + return ActOnFinishFunctionBody(Decl, nullptr); } Decl *Sema::ActOnFinishFunctionBody(Decl *D, Stmt *BodyArg) { @@ -9863,10 +9868,10 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *D, Stmt *BodyArg) { Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body, bool IsInstantiation) { - FunctionDecl *FD = dcl ? dcl->getAsFunction() : 0; + FunctionDecl *FD = dcl ? dcl->getAsFunction() : nullptr; sema::AnalysisBasedWarnings::Policy WP = AnalysisWarnings.getDefaultPolicy(); - sema::AnalysisBasedWarnings::Policy *ActivePolicy = 0; + sema::AnalysisBasedWarnings::Policy *ActivePolicy = nullptr; if (FD) { FD->setBody(Body); @@ -9949,7 +9954,7 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body, getCurFunction()->ObjCShouldCallSuper = false; } if (getCurFunction()->ObjCWarnForNoDesignatedInitChain) { - const ObjCMethodDecl *InitMethod = 0; + const ObjCMethodDecl *InitMethod = nullptr; bool isDesignated = MD->isDesignatedInitializerForTheInterface(&InitMethod); assert(isDesignated && InitMethod); @@ -9982,7 +9987,7 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body, getCurFunction()->ObjCWarnForNoInitDelegation = false; } } else { - return 0; + return nullptr; } assert(!getCurFunction()->ObjCShouldCallSuper && @@ -10095,7 +10100,7 @@ NamedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc, TypoCorrection Corrected; DeclFilterCCC Validator; if (S && (Corrected = CorrectTypo(DeclarationNameInfo(&II, Loc), - LookupOrdinaryName, S, 0, Validator, + LookupOrdinaryName, S, nullptr, Validator, CTK_NonError))) diagnoseTypo(Corrected, PDiag(diag::note_function_suggestion), /*ErrorRecovery*/false); @@ -10115,7 +10120,7 @@ NamedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc, D.AddTypeInfo(DeclaratorChunk::getFunction(/*HasProto=*/false, /*IsAmbiguous=*/false, /*LParenLoc=*/NoLoc, - /*Params=*/0, + /*Params=*/nullptr, /*NumParams=*/0, /*EllipsisLoc=*/NoLoc, /*RParenLoc=*/NoLoc, @@ -10127,10 +10132,10 @@ NamedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc, /*MutableLoc=*/NoLoc, EST_None, /*ESpecLoc=*/NoLoc, - /*Exceptions=*/0, - /*ExceptionRanges=*/0, + /*Exceptions=*/nullptr, + /*ExceptionRanges=*/nullptr, /*NumExceptions=*/0, - /*NoexceptExpr=*/0, + /*NoexceptExpr=*/nullptr, Loc, Loc, D), DS.getAttributes(), SourceLocation()); @@ -10526,7 +10531,7 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, bool IsTypeSpecifier) { // If this is not a definition, it must have a name. IdentifierInfo *OrigName = Name; - assert((Name != 0 || TUK == TUK_Definition) && + assert((Name != nullptr || TUK == TUK_Definition) && "Nameless record must be a definition!"); assert(TemplateParameterLists.size() == 0 || TUK != TUK_Reference); @@ -10545,11 +10550,11 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, (SS.isNotEmpty() && TUK != TUK_Reference)) { if (TemplateParameterList *TemplateParams = MatchTemplateParametersToScopeSpecifier( - KWLoc, NameLoc, SS, 0, TemplateParameterLists, + KWLoc, NameLoc, SS, nullptr, TemplateParameterLists, TUK == TUK_Friend, isExplicitSpecialization, Invalid)) { if (Kind == TTK_Enum) { Diag(KWLoc, diag::err_enum_template); - return 0; + return nullptr; } if (TemplateParams->size() > 0) { @@ -10557,7 +10562,7 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, // be a member of another template). if (Invalid) - return 0; + return nullptr; OwnedDecl = false; DeclResult Result = CheckClassTemplate(S, TagSpec, TUK, KWLoc, @@ -10589,7 +10594,7 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, else if (UnderlyingType.get()) { // C++0x 7.2p2: The type-specifier-seq of an enum-base shall name an // integral type; any cv-qualification is ignored. - TypeSourceInfo *TI = 0; + TypeSourceInfo *TI = nullptr; GetTypeFromParser(UnderlyingType.get(), &TI); EnumUnderlying = TI; @@ -10621,7 +10626,7 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, // Check for invalid 'foo::'. if (SS.isInvalid()) { - Name = 0; + Name = nullptr; goto CreateNewDecl; } @@ -10631,26 +10636,26 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, DC = computeDeclContext(SS, false); if (!DC) { IsDependent = true; - return 0; + return nullptr; } } else { DC = computeDeclContext(SS, true); if (!DC) { Diag(SS.getRange().getBegin(), diag::err_dependent_nested_name_spec) << SS.getRange(); - return 0; + return nullptr; } } if (RequireCompleteDeclContext(SS, DC)) - return 0; + return nullptr; SearchDC = DC; // Look-up name inside 'foo::'. LookupQualifiedName(Previous, DC); if (Previous.isAmbiguous()) - return 0; + return nullptr; if (Previous.empty()) { // Name lookup did not find anything. However, if the @@ -10662,13 +10667,13 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, if (Previous.wasNotFoundInCurrentInstantiation() && (TUK == TUK_Reference || TUK == TUK_Friend)) { IsDependent = true; - return 0; + return nullptr; } // A tag 'foo::bar' must already exist. Diag(NameLoc, diag::err_not_tag_in_scope) << Kind << Name << DC << SS.getRange(); - Name = 0; + Name = nullptr; Invalid = true; goto CreateNewDecl; } @@ -10719,7 +10724,7 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, // Note: there used to be some attempt at recovery here. if (Previous.isAmbiguous()) - return 0; + return nullptr; if (!getLangOpts().CPlusPlus && TUK != TUK_Reference) { // FIXME: This makes sure that we ignore the contexts associated @@ -10880,7 +10885,7 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, Kind = PrevTagDecl->getTagKind(); else { // Recover by making this an anonymous redefinition. - Name = 0; + Name = nullptr; Previous.clear(); Invalid = true; } @@ -10910,7 +10915,7 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, // in which case we want the caller to bail out. if (CheckEnumRedeclaration(NameLoc.isValid() ? NameLoc : KWLoc, ScopedEnum, EnumUnderlyingTy, PrevEnum)) - return TUK == TUK_Declaration ? PrevTagDecl : 0; + return TUK == TUK_Declaration ? PrevTagDecl : nullptr; } // C++11 [class.mem]p1: @@ -10966,7 +10971,7 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, // If this is a redefinition, recover by making this // struct be anonymous, which will make any later // references get the previous definition. - Name = 0; + Name = nullptr; Previous.clear(); Invalid = true; } @@ -10979,7 +10984,7 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, Diag(NameLoc, diag::err_nested_redefinition) << Name; Diag(PrevTagDecl->getLocation(), diag::note_previous_definition); - Name = 0; + Name = nullptr; Previous.clear(); Invalid = true; } @@ -11060,7 +11065,7 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, // issue an error and recover by making this tag be anonymous. Diag(NameLoc, diag::err_redefinition_different_kind) << Name; Diag(PrevDecl->getLocation(), diag::note_previous_definition); - Name = 0; + Name = nullptr; Invalid = true; } @@ -11072,7 +11077,7 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, CreateNewDecl: - TagDecl *PrevDecl = 0; + TagDecl *PrevDecl = nullptr; if (Previous.isSingleResult()) PrevDecl = cast(Previous.getFoundDecl()); @@ -11285,7 +11290,7 @@ CreateNewDecl: OwnedDecl = true; // In C++, don't return an invalid declaration. We can't recover well from // the cases where we make the type anonymous. - return (Invalid && getLangOpts().CPlusPlus) ? 0 : New; + return (Invalid && getLangOpts().CPlusPlus) ? nullptr : New; } void Sema::ActOnTagStartDefinition(Scope *S, Decl *TagD) { @@ -11337,7 +11342,7 @@ void Sema::ActOnStartCXXMemberDeclarations(Scope *S, Decl *TagD, = CXXRecordDecl::Create(Context, Record->getTagKind(), CurContext, Record->getLocStart(), Record->getLocation(), Record->getIdentifier(), - /*PrevDecl=*/0, + /*PrevDecl=*/nullptr, /*DelayTypeCreation=*/true); Context.getTypeDeclType(InjectedClassName, Record); InjectedClassName->setImplicit(); @@ -11390,7 +11395,7 @@ void Sema::ActOnObjCTemporaryExitContainerContext(DeclContext *DC) { void Sema::ActOnObjCReenterContainerContext(DeclContext *DC) { ActOnObjCContainerStartDefinition(cast(DC)); - OriginalLexicalContext = 0; + OriginalLexicalContext = nullptr; } void Sema::ActOnTagDefinitionError(Scope *S, Decl *TagD) { @@ -11543,7 +11548,7 @@ FieldDecl *Sema::HandleField(Scope *S, RecordDecl *Record, << DeclSpec::getSpecifierName(TSCS); // Check to see if this name was declared as a member previously - NamedDecl *PrevDecl = 0; + NamedDecl *PrevDecl = nullptr; LookupResult Previous(*this, II, Loc, LookupMemberName, ForRedeclaration); LookupName(Previous, S); switch (Previous.getResultKind()) { @@ -11567,11 +11572,11 @@ FieldDecl *Sema::HandleField(Scope *S, RecordDecl *Record, // Maybe we will complain about the shadowed template parameter. DiagnoseTemplateParameterShadow(D.getIdentifierLoc(), PrevDecl); // Just pretend that we didn't see the previous declaration. - PrevDecl = 0; + PrevDecl = nullptr; } if (PrevDecl && !isDeclInScope(PrevDecl, Record, S)) - PrevDecl = 0; + PrevDecl = nullptr; bool Mutable = (D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_mutable); @@ -11687,7 +11692,7 @@ FieldDecl *Sema::CheckFieldDecl(DeclarationName Name, QualType T, &ZeroWidth).take(); if (!BitWidth) { InvalidDecl = true; - BitWidth = 0; + BitWidth = nullptr; ZeroWidth = false; } } @@ -11899,7 +11904,7 @@ Decl *Sema::ActOnIvar(Scope *S, // Must set ivar's DeclContext to its enclosing interface. ObjCContainerDecl *EnclosingDecl = cast(CurContext); if (!EnclosingDecl || EnclosingDecl->isInvalidDecl()) - return 0; + return nullptr; ObjCContainerDecl *EnclosingContext; if (ObjCImplementationDecl *IMPDecl = dyn_cast(EnclosingDecl)) { @@ -11915,7 +11920,7 @@ Decl *Sema::ActOnIvar(Scope *S, dyn_cast(EnclosingDecl)) { if (LangOpts.ObjCRuntime.isFragile() || !CDecl->IsClassExtension()) { Diag(Loc, diag::err_misplaced_ivar) << CDecl->IsClassExtension(); - return 0; + return nullptr; } } EnclosingContext = EnclosingDecl; @@ -11993,7 +11998,7 @@ void Sema::ActOnLastBitfield(SourceLocation DeclLoc, Expr * BW = IntegerLiteral::Create(Context, Zero, Context.IntTy, DeclLoc); Ivar = ObjCIvarDecl::Create(Context, cast(CurContext), - DeclLoc, DeclLoc, 0, + DeclLoc, DeclLoc, nullptr, Context.CharTy, Context.getTrivialTypeSourceInfo(Context.CharTy, DeclLoc), @@ -12470,7 +12475,7 @@ EnumConstantDecl *Sema::CheckEnumConstant(EnumDecl *Enum, QualType EltTy; if (Val && DiagnoseUnexpandedParameterPack(Val, UPPC_EnumeratorValue)) - Val = 0; + Val = nullptr; if (Val) Val = DefaultLvalueConversion(Val).take(); @@ -12490,7 +12495,7 @@ EnumConstantDecl *Sema::CheckEnumConstant(EnumDecl *Enum, CheckConvertedConstantExpression(Val, EltTy, EnumVal, CCEK_Enumerator); if (Converted.isInvalid()) - Val = 0; + Val = nullptr; else Val = Converted.take(); } else if (!Val->isValueDependent() && @@ -12652,7 +12657,7 @@ Decl *Sema::ActOnEnumConstant(Scope *S, Decl *theEnumDecl, Decl *lastEnumConst, // Maybe we will complain about the shadowed template parameter. DiagnoseTemplateParameterShadow(IdLoc, PrevDecl); // Just pretend that we didn't see the previous declaration. - PrevDecl = 0; + PrevDecl = nullptr; } if (PrevDecl) { @@ -12666,7 +12671,7 @@ Decl *Sema::ActOnEnumConstant(Scope *S, Decl *theEnumDecl, Decl *lastEnumConst, else Diag(IdLoc, diag::err_redefinition) << Id; Diag(PrevDecl->getLocation(), diag::note_previous_definition); - return 0; + return nullptr; } } @@ -13079,7 +13084,7 @@ void Sema::ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc, ECD->setInitExpr(ImplicitCastExpr::Create(Context, NewTy, CK_IntegralCast, ECD->getInitExpr(), - /*base paths*/ 0, + /*base paths*/ nullptr, VK_RValue)); if (getLangOpts().CPlusPlus) // C++ [dcl.enum]p4: Following the closing brace of an @@ -13233,7 +13238,7 @@ void Sema::ActOnPragmaWeakID(IdentifierInfo* Name, } else { (void)WeakUndeclaredIdentifiers.insert( std::pair - (Name, WeakInfo((IdentifierInfo*)0, NameLoc))); + (Name, WeakInfo((IdentifierInfo*)nullptr, NameLoc))); } } diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index e579b11..a5cdb26 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -48,7 +48,7 @@ namespace AttributeLangSupport { /// type (function or function-typed variable) or an Objective-C /// method. static bool isFunctionOrMethod(const Decl *D) { - return (D->getFunctionType() != NULL) || isa(D); + return (D->getFunctionType() != nullptr) || isa(D); } /// Return true if the given decl has a declarator that should have @@ -361,7 +361,7 @@ static const RecordType *getRecordType(QualType QT) { if (const PointerType *PT = QT->getAs()) return PT->getPointeeType()->getAs(); - return 0; + return nullptr; } static bool checkRecordTypeForCapability(Sema &S, QualType Ty) { @@ -391,7 +391,7 @@ static bool checkRecordTypeForCapability(Sema &S, QualType Ty) { void *) { return BS->getType()->getAs() ->getDecl()->hasAttr(); - }, 0, BPaths)) + }, nullptr, BPaths)) return true; } return false; @@ -558,7 +558,7 @@ static bool checkGuardedByAttrCommon(Sema &S, Decl *D, } static void handleGuardedByAttr(Sema &S, Decl *D, const AttributeList &Attr) { - Expr *Arg = 0; + Expr *Arg = nullptr; if (!checkGuardedByAttrCommon(S, D, Attr, Arg)) return; @@ -568,7 +568,7 @@ static void handleGuardedByAttr(Sema &S, Decl *D, const AttributeList &Attr) { static void handlePtGuardedByAttr(Sema &S, Decl *D, const AttributeList &Attr) { - Expr *Arg = 0; + Expr *Arg = nullptr; if (!checkGuardedByAttrCommon(S, D, Attr, Arg)) return; @@ -648,7 +648,7 @@ static void handleAssertSharedLockAttr(Sema &S, Decl *D, return; unsigned Size = Args.size(); - Expr **StartArg = Size == 0 ? 0 : &Args[0]; + Expr **StartArg = Size == 0 ? nullptr : &Args[0]; D->addAttr(::new (S.Context) AssertSharedLockAttr(Attr.getRange(), S.Context, StartArg, Size, Attr.getAttributeSpellingListIndex())); @@ -661,7 +661,7 @@ static void handleAssertExclusiveLockAttr(Sema &S, Decl *D, return; unsigned Size = Args.size(); - Expr **StartArg = Size == 0 ? 0 : &Args[0]; + Expr **StartArg = Size == 0 ? nullptr : &Args[0]; D->addAttr(::new (S.Context) AssertExclusiveLockAttr(Attr.getRange(), S.Context, StartArg, Size, @@ -1080,7 +1080,7 @@ static void handleIBOutletCollection(Sema &S, Decl *D, } } - TypeSourceInfo *QTLoc = 0; + TypeSourceInfo *QTLoc = nullptr; QualType QT = S.GetTypeFromParser(PT, &QTLoc); if (!QTLoc) QTLoc = S.Context.getTrivialTypeSourceInfo(QT, Attr.getLoc()); @@ -1192,7 +1192,7 @@ static void handleNonNullAttrParameter(Sema &S, ParmVarDecl *D, return; D->addAttr(::new (S.Context) - NonNullAttr(Attr.getRange(), S.Context, 0, 0, + NonNullAttr(Attr.getRange(), S.Context, nullptr, 0, Attr.getAttributeSpellingListIndex())); } @@ -1225,7 +1225,7 @@ static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList &AL) { // Figure out our Kind. OwnershipAttr::OwnershipKind K = - OwnershipAttr(AL.getLoc(), S.Context, 0, 0, 0, + OwnershipAttr(AL.getLoc(), S.Context, nullptr, nullptr, 0, AL.getAttributeSpellingListIndex()).getOwnKind(); // Check arguments. @@ -1480,8 +1480,8 @@ static void handleAnalyzerNoReturnAttr(Sema &S, Decl *D, // because 'analyzer_noreturn' does not impact the type. if (!isFunctionOrMethod(D) && !isa(D)) { ValueDecl *VD = dyn_cast(D); - if (VD == 0 || (!VD->getType()->isBlockPointerType() - && !VD->getType()->isFunctionPointerType())) { + if (!VD || (!VD->getType()->isBlockPointerType() && + !VD->getType()->isFunctionPointerType())) { S.Diag(Attr.getLoc(), Attr.isCXX11Attribute() ? diag::err_attribute_wrong_decl_type : diag::warn_attribute_wrong_decl_type) @@ -1820,7 +1820,7 @@ AvailabilityAttr *Sema::mergeAvailabilityAttr(NamedDecl *D, SourceRange Range, MergedIntroduced == Introduced && MergedDeprecated == Deprecated && MergedObsoleted == Obsoleted) - return NULL; + return nullptr; // Only create a new attribute if !Override, but we want to do // the checking. @@ -1832,7 +1832,7 @@ AvailabilityAttr *Sema::mergeAvailabilityAttr(NamedDecl *D, SourceRange Range, Obsoleted, IsUnavailable, Message, AttrSpellingListIndex); } - return NULL; + return nullptr; } static void handleAvailabilityAttr(Sema &S, Decl *D, @@ -1881,7 +1881,7 @@ static T *mergeVisibilityAttr(Sema &S, Decl *D, SourceRange range, if (existingAttr) { typename T::VisibilityType existingValue = existingAttr->getVisibility(); if (existingValue == value) - return NULL; + return nullptr; S.Diag(existingAttr->getLocation(), diag::err_mismatched_visibility); S.Diag(range.getBegin(), diag::note_previous_attribute); D->dropAttr(); @@ -2209,7 +2209,7 @@ static void handleVecTypeHint(Sema &S, Decl *D, const AttributeList &Attr) { return; } - TypeSourceInfo *ParmTSI = 0; + TypeSourceInfo *ParmTSI = nullptr; QualType ParmType = S.GetTypeFromParser(Attr.getTypeArg(), &ParmTSI); assert(ParmTSI && "no type source info for attribute argument"); @@ -2238,10 +2238,10 @@ SectionAttr *Sema::mergeSectionAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex) { if (SectionAttr *ExistingAttr = D->getAttr()) { if (ExistingAttr->getName() == Name) - return NULL; + return nullptr; Diag(ExistingAttr->getLocation(), diag::warn_mismatched_section); Diag(Range.getBegin(), diag::note_previous_attribute); - return NULL; + return nullptr; } return ::new (Context) SectionAttr(Range, Context, Name, AttrSpellingListIndex); @@ -2279,7 +2279,7 @@ static void handleCleanupAttr(Sema &S, Decl *D, const AttributeList &Attr) { Expr *E = Attr.getArgAsExpr(0); SourceLocation Loc = E->getExprLoc(); - FunctionDecl *FD = 0; + FunctionDecl *FD = nullptr; DeclarationNameInfo NI; // gcc only allows for simple identifiers. Since we support more than gcc, we @@ -2459,7 +2459,7 @@ FormatAttr *Sema::mergeFormatAttr(Decl *D, SourceRange Range, // location. if (F->getLocation().isInvalid()) F->setRange(Range); - return NULL; + return nullptr; } } @@ -2595,7 +2595,7 @@ static void handleFormatAttr(Sema &S, Decl *D, const AttributeList &Attr) { static void handleTransparentUnionAttr(Sema &S, Decl *D, const AttributeList &Attr) { // Try to find the underlying union declaration. - RecordDecl *RD = 0; + RecordDecl *RD = nullptr; TypedefNameDecl *TD = dyn_cast(D); if (TD && TD->getUnderlyingType()->isUnionType()) RD = TD->getUnderlyingType()->getAsUnionType()->getDecl(); @@ -2689,7 +2689,7 @@ static void handleAlignedAttr(Sema &S, Decl *D, const AttributeList &Attr) { if (Attr.getNumArgs() == 0) { D->addAttr(::new (S.Context) AlignedAttr(Attr.getRange(), S.Context, - true, 0, Attr.getAttributeSpellingListIndex())); + true, nullptr, Attr.getAttributeSpellingListIndex())); return; } @@ -2817,7 +2817,7 @@ void Sema::CheckAlignasUnderalignment(Decl *D) { // The combined effect of all alignment attributes in a declaration shall // not specify an alignment that is less strict than the alignment that // would otherwise be required for the entity being declared. - AlignedAttr *AlignasAttr = 0; + AlignedAttr *AlignasAttr = nullptr; unsigned Align = 0; for (auto *I : D->specific_attrs()) { if (I->isAlignmentDependent()) @@ -3332,7 +3332,7 @@ static void handleTypeTagForDatatypeAttr(Sema &S, Decl *D, } IdentifierInfo *PointerKind = Attr.getArgAsIdent(0)->Ident; - TypeSourceInfo *MatchingCTypeLoc = 0; + TypeSourceInfo *MatchingCTypeLoc = nullptr; S.GetTypeFromParser(Attr.getMatchingCType(), &MatchingCTypeLoc); assert(MatchingCTypeLoc && "no type source info for attribute argument"); @@ -3536,7 +3536,7 @@ static void handleCFUnknownTransferAttr(Sema &S, Decl *D, static void handleObjCBridgeAttr(Sema &S, Scope *Sc, Decl *D, const AttributeList &Attr) { - IdentifierLoc * Parm = Attr.isArgIdent(0) ? Attr.getArgAsIdent(0) : 0; + IdentifierLoc * Parm = Attr.isArgIdent(0) ? Attr.getArgAsIdent(0) : nullptr; if (!Parm) { S.Diag(D->getLocStart(), diag::err_objc_attr_not_id) << Attr.getName() << 0; @@ -3550,8 +3550,8 @@ static void handleObjCBridgeAttr(Sema &S, Scope *Sc, Decl *D, static void handleObjCBridgeMutableAttr(Sema &S, Scope *Sc, Decl *D, const AttributeList &Attr) { - IdentifierLoc * Parm = Attr.isArgIdent(0) ? Attr.getArgAsIdent(0) : 0; - + IdentifierLoc * Parm = Attr.isArgIdent(0) ? Attr.getArgAsIdent(0) : nullptr; + if (!Parm) { S.Diag(D->getLocStart(), diag::err_objc_attr_not_id) << Attr.getName() << 0; return; @@ -3565,15 +3565,15 @@ static void handleObjCBridgeMutableAttr(Sema &S, Scope *Sc, Decl *D, static void handleObjCBridgeRelatedAttr(Sema &S, Scope *Sc, Decl *D, const AttributeList &Attr) { IdentifierInfo *RelatedClass = - Attr.isArgIdent(0) ? Attr.getArgAsIdent(0)->Ident : 0; + Attr.isArgIdent(0) ? Attr.getArgAsIdent(0)->Ident : nullptr; if (!RelatedClass) { S.Diag(D->getLocStart(), diag::err_objc_attr_not_id) << Attr.getName() << 0; return; } IdentifierInfo *ClassMethod = - Attr.getArgAsIdent(1) ? Attr.getArgAsIdent(1)->Ident : 0; + Attr.getArgAsIdent(1) ? Attr.getArgAsIdent(1)->Ident : nullptr; IdentifierInfo *InstanceMethod = - Attr.getArgAsIdent(2) ? Attr.getArgAsIdent(2)->Ident : 0; + Attr.getArgAsIdent(2) ? Attr.getArgAsIdent(2)->Ident : nullptr; D->addAttr(::new (S.Context) ObjCBridgeRelatedAttr(Attr.getRange(), S.Context, RelatedClass, ClassMethod, InstanceMethod, @@ -3826,11 +3826,11 @@ DLLImportAttr *Sema::mergeDLLImportAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex) { if (D->hasAttr()) { Diag(Range.getBegin(), diag::warn_attribute_ignored) << "'dllimport'"; - return NULL; + return nullptr; } if (D->hasAttr()) - return NULL; + return nullptr; return ::new (Context) DLLImportAttr(Range, Context, AttrSpellingListIndex); } @@ -3850,7 +3850,7 @@ DLLExportAttr *Sema::mergeDLLExportAttr(Decl *D, SourceRange Range, } if (D->hasAttr()) - return NULL; + return nullptr; return ::new (Context) DLLExportAttr(Range, Context, AttrSpellingListIndex); } @@ -3868,7 +3868,7 @@ Sema::mergeMSInheritanceAttr(Decl *D, SourceRange Range, bool BestCase, MSInheritanceAttr::Spelling SemanticSpelling) { if (MSInheritanceAttr *IA = D->getAttr()) { if (IA->getSemanticSpelling() == SemanticSpelling) - return 0; + return nullptr; Diag(IA->getLocation(), diag::err_mismatched_ms_inheritance) << 1 /*previous declaration*/; Diag(Range.getBegin(), diag::note_previous_ms_inheritance); @@ -3879,18 +3879,18 @@ Sema::mergeMSInheritanceAttr(Decl *D, SourceRange Range, bool BestCase, if (RD->hasDefinition()) { if (checkMSInheritanceAttrOnDefinition(RD, Range, BestCase, SemanticSpelling)) { - return 0; + return nullptr; } } else { if (isa(RD)) { Diag(Range.getBegin(), diag::warn_ignored_ms_inheritance) << 1 /*partial specialization*/; - return 0; + return nullptr; } if (RD->getDescribedClassTemplate()) { Diag(Range.getBegin(), diag::warn_ignored_ms_inheritance) << 0 /*primary template*/; - return 0; + return nullptr; } } @@ -4600,7 +4600,7 @@ void Sema::checkUnusedDeclAttributes(Declarator &D) { NamedDecl * Sema::DeclClonePragmaWeak(NamedDecl *ND, IdentifierInfo *II, SourceLocation Loc) { assert(isa(ND) || isa(ND)); - NamedDecl *NewD = 0; + NamedDecl *NewD = nullptr; if (FunctionDecl *FD = dyn_cast(ND)) { FunctionDecl *NewFD; // FIXME: Missing call to CheckFunctionDeclaration(). @@ -4673,7 +4673,7 @@ void Sema::ProcessPragmaWeak(Scope *S, Decl *D) { // have to do this. LoadExternalWeakUndeclaredIdentifiers(); if (!WeakUndeclaredIdentifiers.empty()) { - NamedDecl *ND = NULL; + NamedDecl *ND = nullptr; if (VarDecl *VD = dyn_cast(D)) if (VD->isExternC()) ND = VD; diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 2930d30..2f9f982 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -386,11 +386,11 @@ void Sema::CheckExtraCXXDefaultArguments(Declarator &D) { << SourceRange((*Toks)[1].getLocation(), Toks->back().getLocation()); delete Toks; - chunk.Fun.Params[argIdx].DefaultArgTokens = 0; + chunk.Fun.Params[argIdx].DefaultArgTokens = nullptr; } else if (Param->getDefaultArg()) { Diag(Param->getLocation(), diag::err_param_default_argument_nonfunc) << Param->getDefaultArg()->getSourceRange(); - Param->setDefaultArg(0); + Param->setDefaultArg(nullptr); } } } else if (chunk.Kind != DeclaratorChunk::Paren) { @@ -706,7 +706,7 @@ void Sema::CheckCXXDefaultArguments(FunctionDecl *FD) { for (p = 0; p <= LastMissingDefaultArg; ++p) { ParmVarDecl *Param = FD->getParamDecl(p); if (Param->hasDefaultArg()) { - Param->setDefaultArg(0); + Param->setDefaultArg(nullptr); } } } @@ -1313,7 +1313,7 @@ Sema::CheckBaseSpecifier(CXXRecordDecl *Class, if (Class->isUnion()) { Diag(Class->getLocation(), diag::err_base_clause_on_union) << SpecifierRange; - return 0; + return nullptr; } if (EllipsisLoc.isValid() && @@ -1339,8 +1339,8 @@ Sema::CheckBaseSpecifier(CXXRecordDecl *Class, if (BaseDecl->getCanonicalDecl() != Class->getCanonicalDecl()) Diag(BaseDecl->getLocation(), diag::note_previous_decl) << BaseType; - - return 0; + + return nullptr; } } @@ -1352,14 +1352,14 @@ Sema::CheckBaseSpecifier(CXXRecordDecl *Class, // Base specifiers must be record types. if (!BaseType->isRecordType()) { Diag(BaseLoc, diag::err_base_must_be_class) << SpecifierRange; - return 0; + return nullptr; } // C++ [class.union]p1: // A union shall not be used as a base class. if (BaseType->isUnionType()) { Diag(BaseLoc, diag::err_union_as_base_class) << SpecifierRange; - return 0; + return nullptr; } // C++ [class.derived]p2: @@ -1368,7 +1368,7 @@ Sema::CheckBaseSpecifier(CXXRecordDecl *Class, if (RequireCompleteType(BaseLoc, BaseType, diag::err_incomplete_base_class, SpecifierRange)) { Class->setInvalidDecl(); - return 0; + return nullptr; } // If the base class is polymorphic or isn't empty, the new one is/isn't, too. @@ -1388,7 +1388,7 @@ Sema::CheckBaseSpecifier(CXXRecordDecl *Class, if (CXXBaseDecl->hasFlexibleArrayMember()) { Diag(BaseLoc, diag::err_base_class_has_flexible_array_member) << CXXBaseDecl->getDeclName(); - return 0; + return nullptr; } // C++ [class]p3: @@ -1400,7 +1400,7 @@ Sema::CheckBaseSpecifier(CXXRecordDecl *Class, << FA->isSpelledAsSealed(); Diag(CXXBaseDecl->getLocation(), diag::note_previous_decl) << CXXBaseDecl->getDeclName(); - return 0; + return nullptr; } if (BaseDecl->isInvalidDecl()) @@ -1447,7 +1447,7 @@ Sema::ActOnBaseSpecifier(Decl *classdecl, SourceRange SpecifierRange, } } - TypeSourceInfo *TInfo = 0; + TypeSourceInfo *TInfo = nullptr; GetTypeFromParser(basetype, &TInfo); if (EllipsisLoc.isInvalid() && @@ -1850,10 +1850,10 @@ static bool InitializationHasSideEffects(const FieldDecl &FD) { } static AttributeList *getMSPropertyAttr(AttributeList *list) { - for (AttributeList* it = list; it != 0; it = it->getNext()) + for (AttributeList *it = list; it != nullptr; it = it->getNext()) if (it->isDeclspecPropertyAttribute()) return it; - return 0; + return nullptr; } /// ActOnCXXMemberDeclarator - This is invoked when a C++ class member @@ -1922,7 +1922,7 @@ Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D, else Diag(Loc, diag::err_invalid_member_in_interface) << (InvalidDecl-1) << ""; - return 0; + return nullptr; } } @@ -1999,7 +1999,7 @@ Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D, if (!Name.isIdentifier()) { Diag(Loc, diag::err_bad_variable_name) << Name; - return 0; + return nullptr; } IdentifierInfo *II = Name.getAsIdentifierInfo(); @@ -2022,7 +2022,7 @@ Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D, << SourceRange(TemplateParams->getTemplateLoc(), TemplateParams->getRAngleLoc()); } - return 0; + return nullptr; } if (SS.isSet() && !SS.isInvalid()) { @@ -2047,7 +2047,7 @@ Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D, Member = HandleMSProperty(S, cast(CurContext), Loc, D, BitWidth, InitStyle, AS, MSPropertyAttr); if (!Member) - return 0; + return nullptr; isInstField = false; } else { Member = HandleField(S, cast(CurContext), Loc, D, @@ -2059,7 +2059,7 @@ Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D, Member = HandleDeclarator(S, D, TemplateParameterLists); if (!Member) - return 0; + return nullptr; // Non-instance-fields can't have a bitfield. if (BitWidth) { @@ -2082,7 +2082,7 @@ Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D, << BitWidth->getSourceRange(); } - BitWidth = 0; + BitWidth = nullptr; Member->setInvalidDecl(); } @@ -2293,7 +2293,7 @@ namespace { // In class initializers will point to the constructor. UninitializedFieldVisitor(S, Decls, Constructor).Visit(E); } else { - UninitializedFieldVisitor(S, Decls, 0).Visit(E); + UninitializedFieldVisitor(S, Decls, nullptr).Visit(E); } } @@ -2357,7 +2357,7 @@ void Sema::ActOnFinishCXXInClassMemberInitializer(Decl *D, SourceLocation InitLoc, Expr *InitExpr) { // Pop the notional constructor scope we created earlier. - PopFunctionScopeInfo(0, D); + PopFunctionScopeInfo(nullptr, D); FieldDecl *FD = cast(D); assert(FD->getInClassInitStyle() != ICIS_NoInit && @@ -2412,7 +2412,7 @@ static bool FindBaseInitializer(Sema &SemaRef, const CXXBaseSpecifier *&DirectBaseSpec, const CXXBaseSpecifier *&VirtualBaseSpec) { // First, check for a direct base class. - DirectBaseSpec = 0; + DirectBaseSpec = nullptr; for (const auto &Base : ClassDecl->bases()) { if (SemaRef.Context.hasSameUnqualifiedType(BaseType, Base.getType())) { // We found a direct base of this type. That's what we're @@ -2425,7 +2425,7 @@ static bool FindBaseInitializer(Sema &SemaRef, // Check for a virtual base class. // FIXME: We might be able to short-circuit this if we know in advance that // there are no virtual bases. - VirtualBaseSpec = 0; + VirtualBaseSpec = nullptr; if (!DirectBaseSpec || !DirectBaseSpec->isVirtual()) { // We haven't found a base yet; search the class hierarchy for a // virtual base class. @@ -2562,7 +2562,7 @@ Sema::BuildMemInitializer(Decl *ConstructorD, } // It didn't name a member, so see if it names a class. QualType BaseType; - TypeSourceInfo *TInfo = 0; + TypeSourceInfo *TInfo = nullptr; if (TemplateTypeTy) { BaseType = GetTypeFromParser(TemplateTypeTy, &TInfo); @@ -2747,15 +2747,17 @@ Sema::BuildMemberInitializer(ValueDecl *Member, Expr *Init, // Initialize the member. InitializedEntity MemberEntity = - DirectMember ? InitializedEntity::InitializeMember(DirectMember, 0) - : InitializedEntity::InitializeMember(IndirectMember, 0); + DirectMember ? InitializedEntity::InitializeMember(DirectMember, nullptr) + : InitializedEntity::InitializeMember(IndirectMember, + nullptr); InitializationKind Kind = InitList ? InitializationKind::CreateDirectList(IdLoc) : InitializationKind::CreateDirect(IdLoc, InitRange.getBegin(), InitRange.getEnd()); InitializationSequence InitSeq(*this, MemberEntity, Kind, Args); - ExprResult MemberInit = InitSeq.Perform(*this, MemberEntity, Kind, Args, 0); + ExprResult MemberInit = InitSeq.Perform(*this, MemberEntity, Kind, Args, + nullptr); if (MemberInit.isInvalid()) return true; @@ -2808,7 +2810,7 @@ Sema::BuildDelegatingInitializer(TypeSourceInfo *TInfo, Expr *Init, InitRange.getEnd()); InitializationSequence InitSeq(*this, DelegationEntity, Kind, Args); ExprResult DelegationInit = InitSeq.Perform(*this, DelegationEntity, Kind, - Args, 0); + Args, nullptr); if (DelegationInit.isInvalid()) return true; @@ -2876,8 +2878,8 @@ Sema::BuildBaseInitializer(QualType BaseType, TypeSourceInfo *BaseTInfo, } // Check for direct and virtual base classes. - const CXXBaseSpecifier *DirectBaseSpec = 0; - const CXXBaseSpecifier *VirtualBaseSpec = 0; + const CXXBaseSpecifier *DirectBaseSpec = nullptr; + const CXXBaseSpecifier *VirtualBaseSpec = nullptr; if (!Dependent) { if (Context.hasSameUnqualifiedType(QualType(ClassDecl->getTypeForDecl(),0), BaseType)) @@ -2941,7 +2943,7 @@ Sema::BuildBaseInitializer(QualType BaseType, TypeSourceInfo *BaseTInfo, : InitializationKind::CreateDirect(BaseLoc, InitRange.getBegin(), InitRange.getEnd()); InitializationSequence InitSeq(*this, BaseEntity, Kind, Args); - ExprResult BaseInit = InitSeq.Perform(*this, BaseEntity, Kind, Args, 0); + ExprResult BaseInit = InitSeq.Perform(*this, BaseEntity, Kind, Args, nullptr); if (BaseInit.isInvalid()) return true; @@ -3051,7 +3053,7 @@ BuildImplicitBaseInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor, DeclRefExpr::Create(SemaRef.Context, NestedNameSpecifierLoc(), SourceLocation(), Param, false, Constructor->getLocation(), ParamType, - VK_LValue, 0); + VK_LValue, nullptr); SemaRef.MarkDeclRefReferenced(cast(CopyCtorArg)); @@ -3124,7 +3126,7 @@ BuildImplicitMemberInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor, Expr *MemberExprBase = DeclRefExpr::Create(SemaRef.Context, NestedNameSpecifierLoc(), SourceLocation(), Param, false, - Loc, ParamType, VK_LValue, 0); + Loc, ParamType, VK_LValue, nullptr); SemaRef.MarkDeclRefReferenced(cast(MemberExprBase)); @@ -3145,9 +3147,9 @@ BuildImplicitMemberInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor, /*IsArrow=*/false, SS, /*TemplateKWLoc=*/SourceLocation(), - /*FirstQualifierInScope=*/0, + /*FirstQualifierInScope=*/nullptr, MemberLookup, - /*TemplateArgs=*/0); + /*TemplateArgs=*/nullptr); if (CtorArg.isInvalid()) return true; @@ -3170,7 +3172,7 @@ BuildImplicitMemberInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor, = SemaRef.Context.getAsConstantArrayType(BaseType)) { InitializingArray = true; // Create the iteration variable for this array index. - IdentifierInfo *IterationVarName = 0; + IdentifierInfo *IterationVarName = nullptr; { SmallString<8> Str; llvm::raw_svector_ostream OS(Str); @@ -3324,7 +3326,7 @@ BuildImplicitMemberInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor, } // Nothing to initialize. - CXXMemberInit = 0; + CXXMemberInit = nullptr; return false; } @@ -3436,7 +3438,7 @@ static bool isIncompleteOrZeroLengthArrayType(ASTContext &Context, QualType T) { static bool CollectFieldInitializer(Sema &SemaRef, BaseAndFieldInfo &Info, FieldDecl *Field, - IndirectFieldDecl *Indirect = 0) { + IndirectFieldDecl *Indirect = nullptr) { if (Field->isInvalidDecl()) return false; @@ -3487,7 +3489,7 @@ static bool CollectFieldInitializer(Sema &SemaRef, BaseAndFieldInfo &Info, if (Info.AnyErrorsInInits) return false; - CXXCtorInitializer *Init = 0; + CXXCtorInitializer *Init = nullptr; if (BuildImplicitMemberInitializer(Info.S, Info.Ctor, Info.IIK, Field, Indirect, Init)) return true; @@ -3768,7 +3770,7 @@ static void DiagnoseBaseOrMemInitializerOrder( unsigned NumIdealInits = IdealInitKeys.size(); unsigned IdealIndex = 0; - CXXCtorInitializer *PrevInit = 0; + CXXCtorInitializer *PrevInit = nullptr; for (unsigned InitIndex = 0; InitIndex != Inits.size(); ++InitIndex) { CXXCtorInitializer *Init = Inits[InitIndex]; const void *InitKey = GetKeyForMember(SemaRef.Context, Init); @@ -4050,7 +4052,7 @@ Sema::MarkBaseAndMemberDestructorsReferenced(SourceLocation Location, CheckDerivedToBaseConversion( Context.getTypeDeclType(ClassDecl), VBase.getType(), diag::err_access_dtor_vbase, 0, ClassDecl->getLocation(), - SourceRange(), DeclarationName(), 0); + SourceRange(), DeclarationName(), nullptr); } MarkFunctionReferenced(Location, Dtor); @@ -5272,7 +5274,7 @@ bool Sema::ShouldDeleteSpecialMember(CXXMethodDecl *MD, CXXSpecialMember CSM, // operator is defined as deleted. if (MD->isImplicit() && (CSM == CXXCopyConstructor || CSM == CXXCopyAssignment)) { - CXXMethodDecl *UserDeclaredMove = 0; + CXXMethodDecl *UserDeclaredMove = nullptr; // In Microsoft mode, a user-declared move only causes the deletion of the // corresponding copy operation, not both copy operations. @@ -5318,7 +5320,7 @@ bool Sema::ShouldDeleteSpecialMember(CXXMethodDecl *MD, CXXSpecialMember CSM, // -- for a virtual destructor, lookup of the non-array deallocation function // results in an ambiguity or in a function that is deleted or inaccessible if (CSM == CXXDestructor && MD->isVirtual()) { - FunctionDecl *OperatorDelete = 0; + FunctionDecl *OperatorDelete = nullptr; DeclarationName Name = Context.DeclarationNames.getCXXOperatorName(OO_Delete); if (FindDeallocationFunction(MD->getLocation(), MD->getParent(), Name, @@ -5367,7 +5369,7 @@ static bool findTrivialSpecialMember(Sema &S, CXXRecordDecl *RD, Sema::CXXSpecialMember CSM, unsigned Quals, bool ConstRHS, CXXMethodDecl **Selected) { if (Selected) - *Selected = 0; + *Selected = nullptr; switch (CSM) { case Sema::CXXInvalid: @@ -5386,7 +5388,7 @@ static bool findTrivialSpecialMember(Sema &S, CXXRecordDecl *RD, // If there's a default constructor which could have been trivial, dig it // out. Otherwise, if there's any user-provided default constructor, point // to that as an example of why there's not a trivial one. - CXXConstructorDecl *DefCtor = 0; + CXXConstructorDecl *DefCtor = nullptr; if (RD->needsImplicitDefaultConstructor()) S.DeclareImplicitDefaultConstructor(RD); for (auto *CI : RD->ctors()) { @@ -5493,7 +5495,7 @@ static CXXConstructorDecl *findUserDeclaredCtor(CXXRecordDecl *RD) { return CD; } - return 0; + return nullptr; } /// The kind of subobject we are checking for triviality. The values of this @@ -5519,7 +5521,7 @@ static bool checkTrivialSubobjectCall(Sema &S, SourceLocation SubobjLoc, CXXMethodDecl *Selected; if (findTrivialSpecialMember(S, SubRD, CSM, SubType.getCVRQualifiers(), - ConstRHS, Diagnose ? &Selected : 0)) + ConstRHS, Diagnose ? &Selected : nullptr)) return true; if (Diagnose) { @@ -6080,7 +6082,7 @@ void Sema::ActOnDelayedCXXMethodParameter(Scope *S, Decl *ParamD) { // If this parameter has an unparsed default argument, clear it out // to make way for the parsed default argument. if (Param->hasUnparsedDefaultArg()) - Param->setDefaultArg(0); + Param->setDefaultArg(nullptr); S->AddDecl(Param); if (Param->getDeclName()) @@ -6233,7 +6235,7 @@ bool Sema::CheckDestructor(CXXDestructorDecl *Destructor) { Loc = RD->getLocation(); // If we have a virtual destructor, look up the deallocation function - FunctionDecl *OperatorDelete = 0; + FunctionDecl *OperatorDelete = nullptr; DeclarationName Name = Context.DeclarationNames.getCXXOperatorName(OO_Delete); if (FindDeallocationFunction(Loc, RD, Name, OperatorDelete)) @@ -6556,7 +6558,7 @@ Decl *Sema::ActOnStartNamespaceDef(Scope *NamespcScope, bool AddToKnown = false; Scope *DeclRegionScope = NamespcScope->getParent(); - NamespaceDecl *PrevNS = 0; + NamespaceDecl *PrevNS = nullptr; if (II) { // C++ [namespace.def]p2: // The identifier in an original-namespace-definition shall not @@ -6572,7 +6574,7 @@ Decl *Sema::ActOnStartNamespaceDef(Scope *NamespcScope, const unsigned IDNS = Decl::IDNS_Ordinary | Decl::IDNS_Member | Decl::IDNS_Type | Decl::IDNS_Using | Decl::IDNS_Tag | Decl::IDNS_Namespace; - NamedDecl *PrevDecl = 0; + NamedDecl *PrevDecl = nullptr; DeclContext::lookup_result R = CurContext->getRedeclContext()->lookup(II); for (DeclContext::lookup_iterator I = R.begin(), E = R.end(); I != E; ++I) { @@ -6733,7 +6735,7 @@ NamespaceDecl *Sema::getOrCreateStdNamespace() { /*Inline=*/false, SourceLocation(), SourceLocation(), &PP.getIdentifierTable().get("std"), - /*PrevDecl=*/0); + /*PrevDecl=*/nullptr); getStdNamespace()->setImplicit(true); } @@ -6750,8 +6752,8 @@ bool Sema::isStdInitializerList(QualType Ty, QualType *Element) { if (!StdNamespace) // If we haven't seen namespace std yet, this can't be it. return false; - ClassTemplateDecl *Template = 0; - const TemplateArgument *Arguments = 0; + ClassTemplateDecl *Template = nullptr; + const TemplateArgument *Arguments = nullptr; if (const RecordType *RT = Ty->getAs()) { @@ -6804,14 +6806,14 @@ static ClassTemplateDecl *LookupStdInitializerList(Sema &S, SourceLocation Loc){ NamespaceDecl *Std = S.getStdNamespace(); if (!Std) { S.Diag(Loc, diag::err_implied_std_initializer_list_not_found); - return 0; + return nullptr; } LookupResult Result(S, &S.PP.getIdentifierTable().get("initializer_list"), Loc, Sema::LookupOrdinaryName); if (!S.LookupQualifiedName(Result, Std)) { S.Diag(Loc, diag::err_implied_std_initializer_list_not_found); - return 0; + return nullptr; } ClassTemplateDecl *Template = Result.getAsSingle(); if (!Template) { @@ -6819,7 +6821,7 @@ static ClassTemplateDecl *LookupStdInitializerList(Sema &S, SourceLocation Loc){ // We found something weird. Complain about the first thing we found. NamedDecl *Found = *Result.begin(); S.Diag(Found->getLocation(), diag::err_malformed_std_initializer_list); - return 0; + return nullptr; } // We found some template called std::initializer_list. Now verify that it's @@ -6828,7 +6830,7 @@ static ClassTemplateDecl *LookupStdInitializerList(Sema &S, SourceLocation Loc){ if (Params->getMinRequiredArguments() != 1 || !isa(Params->getParam(0))) { S.Diag(Template->getLocation(), diag::err_malformed_std_initializer_list); - return 0; + return nullptr; } return Template; @@ -6863,7 +6865,7 @@ bool Sema::isInitListConstructor(const CXXConstructorDecl* Ctor) { if (const ReferenceType *RT = ArgType->getAs()) ArgType = RT->getPointeeType().getUnqualifiedType(); - return isStdInitializerList(ArgType, 0); + return isStdInitializerList(ArgType, nullptr); } /// \brief Determine whether a using statement is in a context where it will be @@ -6938,8 +6940,8 @@ Decl *Sema::ActOnUsingDirective(Scope *S, S = S->getParent(); assert(S->getFlags() & Scope::DeclScope && "Invalid Scope."); - UsingDirectiveDecl *UDir = 0; - NestedNameSpecifier *Qualifier = 0; + UsingDirectiveDecl *UDir = nullptr; + NestedNameSpecifier *Qualifier = nullptr; if (SS.isSet()) Qualifier = SS.getScopeRep(); @@ -6947,7 +6949,7 @@ Decl *Sema::ActOnUsingDirective(Scope *S, LookupResult R(*this, NamespcName, IdentLoc, LookupNamespaceName); LookupParsedName(R, S, &SS); if (R.isAmbiguous()) - return 0; + return nullptr; if (R.empty()) { R.clear(); @@ -7048,23 +7050,23 @@ Decl *Sema::ActOnUsingDeclaration(Scope *S, if (getLangOpts().CPlusPlus11) break; - return 0; - + return nullptr; + case UnqualifiedId::IK_DestructorName: Diag(Name.getLocStart(), diag::err_using_decl_destructor) << SS.getRange(); - return 0; - + return nullptr; + case UnqualifiedId::IK_TemplateId: Diag(Name.getLocStart(), diag::err_using_decl_template_id) << SourceRange(Name.TemplateId->LAngleLoc, Name.TemplateId->RAngleLoc); - return 0; + return nullptr; } DeclarationNameInfo TargetNameInfo = GetNameFromUnqualifiedId(Name); DeclarationName TargetName = TargetNameInfo.getName(); if (!TargetName) - return 0; + return nullptr; // Warn about access declarations. if (!HasUsingKeyword) { @@ -7076,7 +7078,7 @@ Decl *Sema::ActOnUsingDeclaration(Scope *S, if (DiagnoseUnexpandedParameterPack(SS, UPPC_UsingDeclaration) || DiagnoseUnexpandedParameterPack(TargetNameInfo, UPPC_UsingDeclaration)) - return 0; + return nullptr; NamedDecl *UD = BuildUsingDeclaration(S, AS, UsingLoc, SS, TargetNameInfo, AttrList, @@ -7168,7 +7170,7 @@ bool Sema::CheckUsingShadowDecl(UsingDecl *Using, NamedDecl *Orig, // // FIXME: but we might be increasing its access, in which case we // should redeclare it. - NamedDecl *NonTag = 0, *Tag = 0; + NamedDecl *NonTag = nullptr, *Tag = nullptr; bool FoundEquivalentDecl = false; for (LookupResult::iterator I = Previous.begin(), E = Previous.end(); I != E; ++I) { @@ -7186,8 +7188,9 @@ bool Sema::CheckUsingShadowDecl(UsingDecl *Using, NamedDecl *Orig, return false; if (FunctionDecl *FD = Target->getAsFunction()) { - NamedDecl *OldDecl = 0; - switch (CheckOverload(0, FD, Previous, OldDecl, /*IsForUsingDecl*/ true)) { + NamedDecl *OldDecl = nullptr; + switch (CheckOverload(nullptr, FD, Previous, OldDecl, + /*IsForUsingDecl*/ true)) { case Ovl_Overload: return false; @@ -7328,7 +7331,7 @@ static CXXBaseSpecifier *findDirectBaseWithType(CXXRecordDecl *Derived, if (BaseType->isDependentType()) AnyDependentBases = true; } - return 0; + return nullptr; } namespace { @@ -7424,7 +7427,7 @@ NamedDecl *Sema::BuildUsingDeclaration(Scope *S, AccessSpecifier AS, if (SS.isEmpty()) { Diag(IdentLoc, diag::err_using_requires_qualname); - return 0; + return nullptr; } // Do the redeclaration lookup in the current scope. @@ -7458,11 +7461,11 @@ NamedDecl *Sema::BuildUsingDeclaration(Scope *S, AccessSpecifier AS, // Check for invalid redeclarations. if (CheckUsingDeclRedeclaration(UsingLoc, HasTypenameKeyword, SS, IdentLoc, Previous)) - return 0; + return nullptr; // Check for bad qualifiers. if (CheckUsingDeclQualifier(UsingLoc, SS, NameInfo, IdentLoc)) - return 0; + return nullptr; DeclContext *LookupContext = computeDeclContext(SS); NamedDecl *D; @@ -7554,7 +7557,7 @@ NamedDecl *Sema::BuildUsingDeclaration(Scope *S, AccessSpecifier AS, NameInfo.setName(Context.DeclarationNames.getCXXConstructorName( Context.getCanonicalType(Context.getRecordType(RD)))); - NameInfo.setNamedTypeInfo(0); + NameInfo.setNamedTypeInfo(nullptr); // Build it and process it as an inheriting constructor. UsingDecl *UD = BuildValid(); @@ -7605,7 +7608,7 @@ NamedDecl *Sema::BuildUsingDeclaration(Scope *S, AccessSpecifier AS, UsingDecl *UD = BuildValid(); for (LookupResult::iterator I = R.begin(), E = R.end(); I != E; ++I) { - UsingShadowDecl *PrevDecl = 0; + UsingShadowDecl *PrevDecl = nullptr; if (!CheckUsingShadowDecl(UD, *I, Previous, PrevDecl)) BuildUsingShadowDecl(S, UD, *I, PrevDecl); } @@ -7718,7 +7721,7 @@ bool Sema::CheckUsingDeclQualifier(SourceLocation UsingLoc, if (!NamedContext || NamedContext->isRecord()) { auto *RD = dyn_cast(NamedContext); if (RD && RequireCompleteDeclContext(const_cast(SS), RD)) - RD = 0; + RD = nullptr; Diag(NameLoc, diag::err_using_decl_can_not_refer_to_class_member) << SS.getRange(); @@ -7897,15 +7900,15 @@ Decl *Sema::ActOnAliasDeclaration(Scope *S, "got alias-declaration outside of declaration scope"); if (Type.isInvalid()) - return 0; + return nullptr; bool Invalid = false; DeclarationNameInfo NameInfo = GetNameFromUnqualifiedId(Name); - TypeSourceInfo *TInfo = 0; + TypeSourceInfo *TInfo = nullptr; GetTypeFromParser(Type.get(), &TInfo); if (DiagnoseClassNameShadow(CurContext, NameInfo)) - return 0; + return nullptr; if (DiagnoseUnexpandedParameterPack(Name.StartLocation, TInfo, UPPC_DeclarationType)) { @@ -7944,8 +7947,8 @@ Decl *Sema::ActOnAliasDeclaration(Scope *S, NamedDecl *NewND; if (TemplateParamLists.size()) { - TypeAliasTemplateDecl *OldDecl = 0; - TemplateParameterList *OldTemplateParams = 0; + TypeAliasTemplateDecl *OldDecl = nullptr; + TemplateParameterList *OldTemplateParams = nullptr; if (TemplateParamLists.size() != 1) { Diag(UsingLoc, diag::err_alias_template_extra_headers) @@ -8000,7 +8003,7 @@ Decl *Sema::ActOnAliasDeclaration(Scope *S, // and check the parameter list. if (CheckTemplateParameterList(TemplateParams, OldTemplateParams, TPC_TypeAliasTemplate)) - return 0; + return nullptr; TypeAliasTemplateDecl *NewDecl = TypeAliasTemplateDecl::Create(Context, CurContext, UsingLoc, @@ -8044,7 +8047,7 @@ Decl *Sema::ActOnNamespaceAliasDef(Scope *S, = LookupSingleName(S, Alias, AliasLoc, LookupOrdinaryName, ForRedeclaration); if (PrevDecl && !isDeclInScope(PrevDecl, CurContext, S)) - PrevDecl = 0; + PrevDecl = nullptr; if (PrevDecl) { if (NamespaceAliasDecl *AD = dyn_cast(PrevDecl)) { @@ -8054,23 +8057,23 @@ Decl *Sema::ActOnNamespaceAliasDef(Scope *S, // declaration to maintain better source information. if (!R.isAmbiguous() && !R.empty() && AD->getNamespace()->Equals(getNamespaceDecl(R.getFoundDecl()))) - return 0; + return nullptr; } unsigned DiagID = isa(PrevDecl) ? diag::err_redefinition : diag::err_redefinition_different_kind; Diag(AliasLoc, DiagID) << Alias; Diag(PrevDecl->getLocation(), diag::note_previous_definition); - return 0; + return nullptr; } if (R.isAmbiguous()) - return 0; + return nullptr; if (R.empty()) { if (!TryNamespaceTypoCorrection(*this, R, S, SS, IdentLoc, Ident)) { Diag(IdentLoc, diag::err_expected_namespace_name) << SS.getRange(); - return 0; + return nullptr; } } @@ -8268,7 +8271,7 @@ CXXConstructorDecl *Sema::DeclareImplicitDefaultConstructor( DeclaringSpecialMember DSM(*this, ClassDecl, CXXDefaultConstructor); if (DSM.isAlreadyBeingDeclared()) - return 0; + return nullptr; bool Constexpr = defaultedSpecialMemberIsConstexpr(*this, ClassDecl, CXXDefaultConstructor, @@ -8282,9 +8285,9 @@ CXXConstructorDecl *Sema::DeclareImplicitDefaultConstructor( = Context.DeclarationNames.getCXXConstructorName(ClassType); DeclarationNameInfo NameInfo(Name, ClassLoc); CXXConstructorDecl *DefaultCon = CXXConstructorDecl::Create( - Context, ClassDecl, ClassLoc, NameInfo, /*Type*/QualType(), /*TInfo=*/0, - /*isExplicit=*/false, /*isInline=*/true, /*isImplicitlyDeclared=*/true, - Constexpr); + Context, ClassDecl, ClassLoc, NameInfo, /*Type*/QualType(), + /*TInfo=*/nullptr, /*isExplicit=*/false, /*isInline=*/true, + /*isImplicitlyDeclared=*/true, Constexpr); DefaultCon->setAccess(AS_public); DefaultCon->setDefaulted(); DefaultCon->setImplicit(); @@ -8370,7 +8373,7 @@ private: /// Information about an inheriting constructor. struct InheritingConstructor { InheritingConstructor() - : DeclaredInDerived(false), BaseCtor(0), DerivedCtor(0) {} + : DeclaredInDerived(false), BaseCtor(nullptr), DerivedCtor(nullptr) {} /// If \c true, a constructor with this signature is already declared /// in the derived class. @@ -8551,7 +8554,7 @@ private: Context.getCanonicalType(Context.getRecordType(Derived))); DeclarationNameInfo NameInfo(Name, UsingLoc); - TemplateParameterList *TemplateParams = 0; + TemplateParameterList *TemplateParams = nullptr; if (const FunctionTemplateDecl *FTD = BaseCtor->getDescribedFunctionTemplate()) { TemplateParams = FTD->getTemplateParameters(); @@ -8588,8 +8591,8 @@ private: TypeSourceInfo *TInfo = Context.getTrivialTypeSourceInfo(FPT->getParamType(I), UsingLoc); ParmVarDecl *PD = ParmVarDecl::Create( - Context, DerivedCtor, UsingLoc, UsingLoc, /*IdentifierInfo=*/0, - FPT->getParamType(I), TInfo, SC_None, /*DefaultArg=*/0); + Context, DerivedCtor, UsingLoc, UsingLoc, /*IdentifierInfo=*/nullptr, + FPT->getParamType(I), TInfo, SC_None, /*DefaultArg=*/nullptr); PD->setScopeInfo(0, I); PD->setImplicit(); ParamDecls.push_back(PD); @@ -8725,7 +8728,7 @@ CXXDestructorDecl *Sema::DeclareImplicitDestructor(CXXRecordDecl *ClassDecl) { DeclaringSpecialMember DSM(*this, ClassDecl, CXXDestructor); if (DSM.isAlreadyBeingDeclared()) - return 0; + return nullptr; // Create the actual destructor declaration. CanQualType ClassType @@ -8736,7 +8739,7 @@ CXXDestructorDecl *Sema::DeclareImplicitDestructor(CXXRecordDecl *ClassDecl) { DeclarationNameInfo NameInfo(Name, ClassLoc); CXXDestructorDecl *Destructor = CXXDestructorDecl::Create(Context, ClassDecl, ClassLoc, NameInfo, - QualType(), 0, /*isInline=*/true, + QualType(), nullptr, /*isInline=*/true, /*isImplicitlyDeclared=*/true); Destructor->setAccess(AS_public); Destructor->setDefaulted(); @@ -8925,8 +8928,8 @@ class MemberBuilder: public ExprBuilder { public: virtual Expr *build(Sema &S, SourceLocation Loc) const override { return assertNotNull(S.BuildMemberReferenceExpr( - Builder.build(S, Loc), Type, Loc, IsArrow, SS, SourceLocation(), 0, - MemberLookup, 0).take()); + Builder.build(S, Loc), Type, Loc, IsArrow, SS, SourceLocation(), + nullptr, MemberLookup, nullptr).take()); } MemberBuilder(const ExprBuilder &Builder, QualType Type, bool IsArrow, @@ -9017,13 +9020,13 @@ buildMemcpyForAssignmentOp(Sema &S, SourceLocation Loc, QualType T, return StmtError(); ExprResult MemCpyRef = S.BuildDeclRefExpr(MemCpy, S.Context.BuiltinFnTy, - VK_RValue, Loc, 0); + VK_RValue, Loc, nullptr); assert(MemCpyRef.isUsable() && "Builtin reference cannot fail"); Expr *CallArgs[] = { To, From, IntegerLiteral::Create(S.Context, Size, SizeType, Loc) }; - ExprResult Call = S.ActOnCallExpr(/*Scope=*/0, MemCpyRef.take(), + ExprResult Call = S.ActOnCallExpr(/*Scope=*/nullptr, MemCpyRef.take(), Loc, CallArgs, Loc); assert(!Call.isInvalid() && "Call to __builtin_memcpy cannot fail!"); @@ -9126,7 +9129,7 @@ buildSingleCopyAssignRecursively(Sema &S, SourceLocation Loc, QualType T, CXXScopeSpec SS; const Type *CanonicalT = S.Context.getCanonicalType(T.getTypePtr()); SS.MakeTrivial(S.Context, - NestedNameSpecifier::Create(S.Context, 0, false, + NestedNameSpecifier::Create(S.Context, nullptr, false, CanonicalT), Loc); @@ -9134,9 +9137,9 @@ buildSingleCopyAssignRecursively(Sema &S, SourceLocation Loc, QualType T, ExprResult OpEqualRef = S.BuildMemberReferenceExpr(To.build(S, Loc), T, Loc, /*isArrow=*/false, SS, /*TemplateKWLoc=*/SourceLocation(), - /*FirstQualifierInScope=*/0, + /*FirstQualifierInScope=*/nullptr, OpLookup, - /*TemplateArgs=*/0, + /*TemplateArgs=*/nullptr, /*SuppressQualifierCheck=*/true); if (OpEqualRef.isInvalid()) return StmtError(); @@ -9144,7 +9147,7 @@ buildSingleCopyAssignRecursively(Sema &S, SourceLocation Loc, QualType T, // Build the call to the assignment operator. Expr *FromInst = From.build(S, Loc); - ExprResult Call = S.BuildCallToMemberFunction(/*Scope=*/0, + ExprResult Call = S.BuildCallToMemberFunction(/*Scope=*/nullptr, OpEqualRef.takeAs(), Loc, FromInst, Loc); if (Call.isInvalid()) @@ -9154,7 +9157,7 @@ buildSingleCopyAssignRecursively(Sema &S, SourceLocation Loc, QualType T, // bail out. We'll replace the whole shebang with a memcpy. CXXMemberCallExpr *CE = dyn_cast(Call.get()); if (CE && CE->getMethodDecl()->isTrivial() && Depth) - return StmtResult((Stmt*)0); + return StmtResult((Stmt*)nullptr); // Convert to an expression-statement, and clean up any produced // temporaries. @@ -9183,7 +9186,7 @@ buildSingleCopyAssignRecursively(Sema &S, SourceLocation Loc, QualType T, QualType SizeType = S.Context.getSizeType(); // Create the iteration variable. - IdentifierInfo *IterationVarName = 0; + IdentifierInfo *IterationVarName = nullptr; { SmallString<8> Str; llvm::raw_svector_ostream OS(Str); @@ -9243,7 +9246,7 @@ buildSingleCopyAssignRecursively(Sema &S, SourceLocation Loc, QualType T, // Construct the loop that copies all elements of this array. return S.ActOnForStmt(Loc, Loc, InitStmt, S.MakeFullExpr(Comparison), - 0, S.MakeFullDiscardedValueExpr(Increment), + nullptr, S.MakeFullDiscardedValueExpr(Increment), Loc, Copy.take()); } @@ -9333,7 +9336,7 @@ CXXMethodDecl *Sema::DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl) { DeclaringSpecialMember DSM(*this, ClassDecl, CXXCopyAssignment); if (DSM.isAlreadyBeingDeclared()) - return 0; + return nullptr; QualType ArgType = Context.getTypeDeclType(ClassDecl); QualType RetType = Context.getLValueReferenceType(ArgType); @@ -9353,8 +9356,8 @@ CXXMethodDecl *Sema::DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl) { DeclarationNameInfo NameInfo(Name, ClassLoc); CXXMethodDecl *CopyAssignment = CXXMethodDecl::Create(Context, ClassDecl, ClassLoc, NameInfo, QualType(), - /*TInfo=*/ 0, /*StorageClass=*/ SC_None, - /*isInline=*/ true, Constexpr, SourceLocation()); + /*TInfo=*/nullptr, /*StorageClass=*/SC_None, + /*isInline=*/true, Constexpr, SourceLocation()); CopyAssignment->setAccess(AS_public); CopyAssignment->setDefaulted(); CopyAssignment->setImplicit(); @@ -9366,9 +9369,10 @@ CXXMethodDecl *Sema::DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl) { // Add the parameter to the operator. ParmVarDecl *FromParam = ParmVarDecl::Create(Context, CopyAssignment, - ClassLoc, ClassLoc, /*Id=*/0, - ArgType, /*TInfo=*/0, - SC_None, 0); + ClassLoc, ClassLoc, + /*Id=*/nullptr, ArgType, + /*TInfo=*/nullptr, SC_None, + nullptr); CopyAssignment->setParams(FromParam); AddOverriddenMethods(ClassDecl, CopyAssignment); @@ -9399,7 +9403,7 @@ static void diagnoseDeprecatedCopyOperation(Sema &S, CXXMethodDecl *CopyOp, assert(CopyOp->isImplicit()); CXXRecordDecl *RD = CopyOp->getParent(); - CXXMethodDecl *UserDeclaredOperation = 0; + CXXMethodDecl *UserDeclaredOperation = nullptr; // In Microsoft mode, assignment operations don't affect constructors and // vice versa. @@ -9707,7 +9711,7 @@ CXXMethodDecl *Sema::DeclareImplicitMoveAssignment(CXXRecordDecl *ClassDecl) { DeclaringSpecialMember DSM(*this, ClassDecl, CXXMoveAssignment); if (DSM.isAlreadyBeingDeclared()) - return 0; + return nullptr; // Note: The following rules are largely analoguous to the move // constructor rules. @@ -9727,7 +9731,7 @@ CXXMethodDecl *Sema::DeclareImplicitMoveAssignment(CXXRecordDecl *ClassDecl) { DeclarationNameInfo NameInfo(Name, ClassLoc); CXXMethodDecl *MoveAssignment = CXXMethodDecl::Create(Context, ClassDecl, ClassLoc, NameInfo, QualType(), - /*TInfo=*/0, /*StorageClass=*/SC_None, + /*TInfo=*/nullptr, /*StorageClass=*/SC_None, /*isInline=*/true, Constexpr, SourceLocation()); MoveAssignment->setAccess(AS_public); MoveAssignment->setDefaulted(); @@ -9740,9 +9744,10 @@ CXXMethodDecl *Sema::DeclareImplicitMoveAssignment(CXXRecordDecl *ClassDecl) { // Add the parameter to the operator. ParmVarDecl *FromParam = ParmVarDecl::Create(Context, MoveAssignment, - ClassLoc, ClassLoc, /*Id=*/0, - ArgType, /*TInfo=*/0, - SC_None, 0); + ClassLoc, ClassLoc, + /*Id=*/nullptr, ArgType, + /*TInfo=*/nullptr, SC_None, + nullptr); MoveAssignment->setParams(FromParam); AddOverriddenMethods(ClassDecl, MoveAssignment); @@ -9834,7 +9839,7 @@ static void checkMoveAssignmentForRepeatedMove(Sema &S, CXXRecordDecl *Class, << Base << BI.getType() << BaseSpec->getSourceRange(); // Only diagnose each vbase once. - Existing = 0; + Existing = nullptr; } } else { // Only walk over bases that have defaulted move assignment operators. @@ -10122,7 +10127,7 @@ CXXConstructorDecl *Sema::DeclareImplicitCopyConstructor( DeclaringSpecialMember DSM(*this, ClassDecl, CXXCopyConstructor); if (DSM.isAlreadyBeingDeclared()) - return 0; + return nullptr; QualType ClassType = Context.getTypeDeclType(ClassDecl); QualType ArgType = ClassType; @@ -10144,7 +10149,7 @@ CXXConstructorDecl *Sema::DeclareImplicitCopyConstructor( // An implicitly-declared copy constructor is an inline public // member of its class. CXXConstructorDecl *CopyConstructor = CXXConstructorDecl::Create( - Context, ClassDecl, ClassLoc, NameInfo, QualType(), /*TInfo=*/0, + Context, ClassDecl, ClassLoc, NameInfo, QualType(), /*TInfo=*/nullptr, /*isExplicit=*/false, /*isInline=*/true, /*isImplicitlyDeclared=*/true, Constexpr); CopyConstructor->setAccess(AS_public); @@ -10159,9 +10164,9 @@ CXXConstructorDecl *Sema::DeclareImplicitCopyConstructor( // Add the parameter to the constructor. ParmVarDecl *FromParam = ParmVarDecl::Create(Context, CopyConstructor, ClassLoc, ClassLoc, - /*IdentifierInfo=*/0, - ArgType, /*TInfo=*/0, - SC_None, 0); + /*IdentifierInfo=*/nullptr, + ArgType, /*TInfo=*/nullptr, + SC_None, nullptr); CopyConstructor->setParams(FromParam); CopyConstructor->setTrivial( @@ -10286,7 +10291,7 @@ CXXConstructorDecl *Sema::DeclareImplicitMoveConstructor( DeclaringSpecialMember DSM(*this, ClassDecl, CXXMoveConstructor); if (DSM.isAlreadyBeingDeclared()) - return 0; + return nullptr; QualType ClassType = Context.getTypeDeclType(ClassDecl); QualType ArgType = Context.getRValueReferenceType(ClassType); @@ -10305,7 +10310,7 @@ CXXConstructorDecl *Sema::DeclareImplicitMoveConstructor( // An implicitly-declared copy/move constructor is an inline public // member of its class. CXXConstructorDecl *MoveConstructor = CXXConstructorDecl::Create( - Context, ClassDecl, ClassLoc, NameInfo, QualType(), /*TInfo=*/0, + Context, ClassDecl, ClassLoc, NameInfo, QualType(), /*TInfo=*/nullptr, /*isExplicit=*/false, /*isInline=*/true, /*isImplicitlyDeclared=*/true, Constexpr); MoveConstructor->setAccess(AS_public); @@ -10320,9 +10325,9 @@ CXXConstructorDecl *Sema::DeclareImplicitMoveConstructor( // Add the parameter to the constructor. ParmVarDecl *FromParam = ParmVarDecl::Create(Context, MoveConstructor, ClassLoc, ClassLoc, - /*IdentifierInfo=*/0, - ArgType, /*TInfo=*/0, - SC_None, 0); + /*IdentifierInfo=*/nullptr, + ArgType, /*TInfo=*/nullptr, + SC_None, nullptr); MoveConstructor->setParams(FromParam); MoveConstructor->setTrivial( @@ -10391,16 +10396,15 @@ void Sema::DefineImplicitLambdaToFunctionPointerConversion( // cache the deduced template arguments for this specialization // so that we can use them to retrieve the corresponding call-operator // and static-invoker. - const TemplateArgumentList *DeducedTemplateArgs = 0; - - + const TemplateArgumentList *DeducedTemplateArgs = nullptr; + // Retrieve the corresponding call-operator specialization. if (Lambda->isGenericLambda()) { assert(Conv->isFunctionTemplateSpecialization()); FunctionTemplateDecl *CallOpTemplate = CallOp->getDescribedFunctionTemplate(); DeducedTemplateArgs = Conv->getTemplateSpecializationArgs(); - void *InsertPos = 0; + void *InsertPos = nullptr; FunctionDecl *CallOpSpec = CallOpTemplate->findSpecialization( DeducedTemplateArgs->data(), DeducedTemplateArgs->size(), @@ -10427,7 +10431,7 @@ void Sema::DefineImplicitLambdaToFunctionPointerConversion( "Must have deduced template arguments from Conversion Operator"); FunctionTemplateDecl *InvokeTemplate = Invoker->getDescribedFunctionTemplate(); - void *InsertPos = 0; + void *InsertPos = nullptr; FunctionDecl *InvokeSpec = InvokeTemplate->findSpecialization( DeducedTemplateArgs->data(), DeducedTemplateArgs->size(), @@ -10488,7 +10492,7 @@ void Sema::DefineImplicitLambdaToBlockPointerConversion( if (!BuildBlock.isInvalid() && !getLangOpts().ObjCAutoRefCount) BuildBlock = ImplicitCastExpr::Create(Context, BuildBlock.get()->getType(), CK_CopyAndAutoreleaseBlockObject, - BuildBlock.get(), 0, VK_RValue); + BuildBlock.get(), nullptr, VK_RValue); if (BuildBlock.isInvalid()) { Diag(CurrentLocation, diag::note_lambda_to_block_conv); @@ -11081,7 +11085,7 @@ Decl *Sema::ActOnStartLinkageSpecification(Scope *S, SourceLocation ExternLoc, if (!Lit->isAscii()) { Diag(LangStr->getExprLoc(), diag::err_language_linkage_spec_not_ascii) << LangStr->getSourceRange(); - return 0; + return nullptr; } StringRef Lang = Lit->getString(); @@ -11093,7 +11097,7 @@ Decl *Sema::ActOnStartLinkageSpecification(Scope *S, SourceLocation ExternLoc, else { Diag(LangStr->getExprLoc(), diag::err_language_linkage_spec_unknown) << LangStr->getSourceRange(); - return 0; + return nullptr; } // FIXME: Add all the various semantics of linkage specifications @@ -11280,7 +11284,7 @@ Decl *Sema::ActOnExceptionDeclarator(Scope *S, Declarator &D) { if (PrevDecl->isTemplateParameter()) { // Maybe we will complain about the shadowed template parameter. DiagnoseTemplateParameterShadow(D.getIdentifierLoc(), PrevDecl); - PrevDecl = 0; + PrevDecl = nullptr; } } @@ -11314,7 +11318,7 @@ Decl *Sema::ActOnStaticAssertDeclaration(SourceLocation StaticAssertLoc, StringLiteral *AssertMessage = cast(AssertMessageExpr); if (DiagnoseUnexpandedParameterPack(AssertExpr, UPPC_StaticAssertExpression)) - return 0; + return nullptr; return BuildStaticAssertDeclaration(StaticAssertLoc, AssertExpr, AssertMessage, RParenLoc, false); @@ -11342,7 +11346,7 @@ Decl *Sema::BuildStaticAssertDeclaration(SourceLocation StaticAssertLoc, if (!Failed && !Cond) { SmallString<256> MsgBuffer; llvm::raw_svector_ostream Msg(MsgBuffer); - AssertMessage->printPretty(Msg, 0, getPrintingPolicy()); + AssertMessage->printPretty(Msg, nullptr, getPrintingPolicy()); Diag(StaticAssertLoc, diag::err_static_assert_failed) << Msg.str() << AssertExpr->getSourceRange(); Failed = true; @@ -11446,12 +11450,12 @@ Decl *Sema::ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc, if (TemplateParameterList *TemplateParams = MatchTemplateParametersToScopeSpecifier( - TagLoc, NameLoc, SS, 0, TempParamLists, /*friend*/ true, + TagLoc, NameLoc, SS, nullptr, TempParamLists, /*friend*/ true, isExplicitSpecialization, Invalid)) { if (TemplateParams->size() > 0) { // This is a declaration of a class template. if (Invalid) - return 0; + return nullptr; return CheckClassTemplate(S, TagSpec, TUK_Friend, TagLoc, SS, Name, NameLoc, Attr, @@ -11467,7 +11471,7 @@ Decl *Sema::ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc, } } - if (Invalid) return 0; + if (Invalid) return nullptr; bool isAllExplicitSpecializations = true; for (unsigned I = TempParamLists.size(); I-- > 0; ) { @@ -11502,7 +11506,7 @@ Decl *Sema::ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc, QualType T = CheckTypenameType(Keyword, TagLoc, QualifierLoc, *Name, NameLoc); if (T.isNull()) - return 0; + return nullptr; TypeSourceInfo *TSI = Context.CreateTypeSourceInfo(T); if (isa(T)) { @@ -11582,10 +11586,10 @@ Decl *Sema::ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS, TypeSourceInfo *TSI = GetTypeForDeclarator(TheDeclarator, S); QualType T = TSI->getType(); if (TheDeclarator.isInvalidType()) - return 0; + return nullptr; if (DiagnoseUnexpandedParameterPack(Loc, TSI, UPPC_FriendDeclaration)) - return 0; + return nullptr; // This is definitely an error in C++98. It's probably meant to // be forbidden in C++0x, too, but the specification is just @@ -11604,7 +11608,7 @@ Decl *Sema::ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS, if (TempParams.size() && !T->isElaboratedTypeSpecifier()) { Diag(Loc, diag::err_tagless_friend_type_template) << DS.getSourceRange(); - return 0; + return nullptr; } // C++98 [class.friend]p1: A friend of a class is a function @@ -11629,8 +11633,8 @@ Decl *Sema::ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS, D = CheckFriendTypeDecl(Loc, DS.getFriendSpecLoc(), TSI); if (!D) - return 0; - + return nullptr; + D->setAccess(AS_public); CurContext->addDecl(D); @@ -11662,7 +11666,7 @@ NamedDecl *Sema::ActOnFriendFunctionDecl(Scope *S, Declarator &D, // It might be worthwhile to try to recover by creating an // appropriate declaration. - return 0; + return nullptr; } // C++ [namespace.memdef]p3 @@ -11689,7 +11693,7 @@ NamedDecl *Sema::ActOnFriendFunctionDecl(Scope *S, Declarator &D, if (DiagnoseUnexpandedParameterPack(Loc, TInfo, UPPC_FriendDeclaration) || DiagnoseUnexpandedParameterPack(NameInfo, UPPC_FriendDeclaration) || DiagnoseUnexpandedParameterPack(SS, UPPC_FriendDeclaration)) - return 0; + return nullptr; // The context we found the declaration in, or in which we should // create the declaration. @@ -11702,7 +11706,7 @@ NamedDecl *Sema::ActOnFriendFunctionDecl(Scope *S, Declarator &D, // - There's no scope specifier and we're in a local class. Only look // for functions declared in the immediately-enclosing block scope. // We recover from invalid scope qualifiers as if they just weren't there. - FunctionDecl *FunctionContainingLocalClass = 0; + FunctionDecl *FunctionContainingLocalClass = nullptr; if ((SS.isInvalid() || !SS.isSet()) && (FunctionContainingLocalClass = cast(CurContext)->isLocalClass())) { @@ -11795,9 +11799,9 @@ NamedDecl *Sema::ActOnFriendFunctionDecl(Scope *S, Declarator &D, // or function template. } else if (!SS.getScopeRep()->isDependent()) { DC = computeDeclContext(SS); - if (!DC) return 0; + if (!DC) return nullptr; - if (RequireCompleteDeclContext(SS, DC)) return 0; + if (RequireCompleteDeclContext(SS, DC)) return nullptr; LookupQualifiedName(Previous, DC); @@ -11817,7 +11821,7 @@ NamedDecl *Sema::ActOnFriendFunctionDecl(Scope *S, Declarator &D, D.setInvalidType(); Diag(Loc, diag::err_qualified_friend_not_found) << Name << TInfo->getType(); - return 0; + return nullptr; } // C++ [class.friend]p1: A friend of a class is a function or @@ -11869,7 +11873,7 @@ NamedDecl *Sema::ActOnFriendFunctionDecl(Scope *S, Declarator &D, Diag(Loc, diag::err_introducing_special_friend) << (D.getName().getKind() == UnqualifiedId::IK_ConstructorName ? 0 : D.getName().getKind() == UnqualifiedId::IK_DestructorName ? 1 : 2); - return 0; + return nullptr; } } @@ -11885,7 +11889,7 @@ NamedDecl *Sema::ActOnFriendFunctionDecl(Scope *S, Declarator &D, bool AddToScope = true; NamedDecl *ND = ActOnFunctionDeclarator(DCScope, D, DC, TInfo, Previous, TemplateParams, AddToScope); - if (!ND) return 0; + if (!ND) return nullptr; assert(ND->getLexicalDeclContext() == CurContext); @@ -12177,7 +12181,8 @@ bool Sema::CheckOverridingFunctionReturnType(const CXXMethodDecl *New, diag::err_covariant_return_inaccessible_base, diag::err_covariant_return_ambiguous_derived_to_base_conv, // FIXME: Should this point to the return type? - New->getLocation(), SourceRange(), New->getDeclName(), 0)) { + New->getLocation(), SourceRange(), New->getDeclName(), + nullptr)) { // FIXME: this note won't trigger for delayed access control // diagnostics, and it's impossible to get an undelayed error // here from access control during the original parse because @@ -12247,7 +12252,8 @@ static bool isStaticDataMember(const Decl *D) { /// class X. void Sema::ActOnCXXEnterDeclInitializer(Scope *S, Decl *D) { // If there is no declaration, there was an error parsing it. - if (D == 0 || D->isInvalidDecl()) return; + if (!D || D->isInvalidDecl()) + return; // We will always have a nested name specifier here, but this declaration // might not be out of line if the specifier names the current namespace: @@ -12267,7 +12273,8 @@ void Sema::ActOnCXXEnterDeclInitializer(Scope *S, Decl *D) { /// initializer for the out-of-line declaration 'D'. void Sema::ActOnCXXExitDeclInitializer(Scope *S, Decl *D) { // If there is no declaration, there was an error parsing it. - if (D == 0 || D->isInvalidDecl()) return; + if (!D || D->isInvalidDecl()) + return; if (isStaticDataMember(D)) PopExpressionEvaluationContext(); @@ -12444,7 +12451,7 @@ bool Sema::DefineUsedVTables() { // Optionally warn if we're emitting a weak vtable. if (Class->isExternallyVisible() && Class->getTemplateSpecializationKind() != TSK_ImplicitInstantiation) { - const FunctionDecl *KeyFunctionDef = 0; + const FunctionDecl *KeyFunctionDef = nullptr; if (!KeyFunction || (KeyFunction->hasBody(KeyFunctionDef) && KeyFunctionDef->isInlined())) @@ -12569,7 +12576,7 @@ void DelegatingCycleHelper(CXXConstructorDecl* Ctor, // Target may not be determinable yet, for instance if this is a dependent // call in an uninstantiated template. if (Target) { - const FunctionDecl *FNTarget = 0; + const FunctionDecl *FNTarget = nullptr; (void)Target->hasBody(FNTarget); Target = const_cast( cast_or_null(FNTarget)); @@ -12577,7 +12584,7 @@ void DelegatingCycleHelper(CXXConstructorDecl* Ctor, CXXConstructorDecl *Canonical = Ctor->getCanonicalDecl(), // Avoid dereferencing a null pointer here. - *TCanonical = Target ? Target->getCanonicalDecl() : 0; + *TCanonical = Target? Target->getCanonicalDecl() : nullptr; if (!Current.insert(Canonical)) return; @@ -12602,7 +12609,7 @@ void DelegatingCycleHelper(CXXConstructorDecl* Ctor, CXXConstructorDecl *C = Target; while (C->getCanonicalDecl() != Canonical) { - const FunctionDecl *FNTarget = 0; + const FunctionDecl *FNTarget = nullptr; (void)C->getTargetConstructor()->hasBody(FNTarget); assert(FNTarget && "Ctor cycle through bodiless function"); @@ -12726,7 +12733,7 @@ bool Sema::checkThisInStaticMemberFunctionAttributes(CXXMethodDecl *Method) { // Check attributes. for (const auto *A : Method->attrs()) { // FIXME: This should be emitted by tblgen. - Expr *Arg = 0; + Expr *Arg = nullptr; ArrayRef Args; if (const auto *G = dyn_cast(A)) Arg = G->getArg(); @@ -12814,7 +12821,7 @@ Sema::checkExceptionSpecification(ExceptionSpecificationType EST, } if (!NoexceptExpr->isValueDependent()) - NoexceptExpr = VerifyIntegerConstantExpression(NoexceptExpr, 0, + NoexceptExpr = VerifyIntegerConstantExpression(NoexceptExpr, nullptr, diag::err_noexcept_needs_constant_expression, /*AllowFold*/ false).take(); EPI.NoexceptExpr = NoexceptExpr; @@ -12874,7 +12881,7 @@ MSPropertyDecl *Sema::HandleMSProperty(Scope *S, RecordDecl *Record, IdentifierInfo *II = D.getIdentifier(); if (!II) { Diag(DeclStart, diag::err_anonymous_property); - return NULL; + return nullptr; } SourceLocation Loc = D.getIdentifierLoc(); @@ -12899,7 +12906,7 @@ MSPropertyDecl *Sema::HandleMSProperty(Scope *S, RecordDecl *Record, << DeclSpec::getSpecifierName(TSCS); // Check to see if this name was declared as a member previously - NamedDecl *PrevDecl = 0; + NamedDecl *PrevDecl = nullptr; LookupResult Previous(*this, II, Loc, LookupMemberName, ForRedeclaration); LookupName(Previous, S); switch (Previous.getResultKind()) { @@ -12922,11 +12929,11 @@ MSPropertyDecl *Sema::HandleMSProperty(Scope *S, RecordDecl *Record, // Maybe we will complain about the shadowed template parameter. DiagnoseTemplateParameterShadow(D.getIdentifierLoc(), PrevDecl); // Just pretend that we didn't see the previous declaration. - PrevDecl = 0; + PrevDecl = nullptr; } if (PrevDecl && !isDeclInScope(PrevDecl, Record, S)) - PrevDecl = 0; + PrevDecl = nullptr; SourceLocation TSSL = D.getLocStart(); const AttributeList::PropertyData &Data = MSPropertyAttr->getPropertyData(); diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index 89878fb..fc9fdb1 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -70,7 +70,7 @@ bool Sema::checkInitMethod(ObjCMethodDecl *method, } else { // If this method was declared in a protocol, we can't check // anything unless we have a receiver type that's an interface. - const ObjCInterfaceDecl *receiverClass = 0; + const ObjCInterfaceDecl *receiverClass = nullptr; if (isa(method->getDeclContext())) { if (receiverTypeIfCall.isNull()) return false; @@ -303,7 +303,7 @@ HasExplicitOwnershipAttr(Sema &S, ParmVarDecl *Param) { /// ActOnStartOfObjCMethodDef - This routine sets up parameters; invisible /// and user declared, in the method definition's AST. void Sema::ActOnStartOfObjCMethodDef(Scope *FnBodyScope, Decl *D) { - assert((getCurMethodDecl() == 0) && "Methodparsing confused"); + assert((getCurMethodDecl() == nullptr) && "Methodparsing confused"); ObjCMethodDecl *MDecl = dyn_cast_or_null(D); // If we don't have a valid method decl, simply return. @@ -375,7 +375,7 @@ void Sema::ActOnStartOfObjCMethodDef(Scope *FnBodyScope, Decl *D) { dyn_cast(MDecl->getDeclContext()); ObjCContainerDecl *ContDeclOfMethodDecl = dyn_cast(IMD->getDeclContext()); - ObjCImplDecl *ImplDeclOfMethodDecl = 0; + ObjCImplDecl *ImplDeclOfMethodDecl = nullptr; if (ObjCInterfaceDecl *OID = dyn_cast(ContDeclOfMethodDecl)) ImplDeclOfMethodDecl = OID->getImplementation(); else if (ObjCCategoryDecl *CD = dyn_cast(ContDeclOfMethodDecl)) { @@ -397,7 +397,7 @@ void Sema::ActOnStartOfObjCMethodDef(Scope *FnBodyScope, Decl *D) { if (MDecl->isDesignatedInitializerForTheInterface()) { getCurFunction()->ObjCIsDesignatedInit = true; getCurFunction()->ObjCWarnForNoDesignatedInitChain = - IC->getSuperClass() != 0; + IC->getSuperClass() != nullptr; } else if (IC->hasDesignatedInitializers()) { getCurFunction()->ObjCIsSecondaryInit = true; getCurFunction()->ObjCWarnForNoInitDelegation = true; @@ -437,7 +437,7 @@ namespace { // function will reject corrections to that class. class ObjCInterfaceValidatorCCC : public CorrectionCandidateCallback { public: - ObjCInterfaceValidatorCCC() : CurrentIDecl(0) {} + ObjCInterfaceValidatorCCC() : CurrentIDecl(nullptr) {} explicit ObjCInterfaceValidatorCCC(ObjCInterfaceDecl *IDecl) : CurrentIDecl(IDecl) {} @@ -523,7 +523,7 @@ ActOnStartClassInterface(SourceLocation AtInterfaceLoc, ObjCInterfaceValidatorCCC Validator(IDecl); if (TypoCorrection Corrected = CorrectTypo( DeclarationNameInfo(SuperName, SuperLoc), LookupOrdinaryName, TUScope, - NULL, Validator, CTK_ErrorRecovery)) { + nullptr, Validator, CTK_ErrorRecovery)) { diagnoseTypo(Corrected, PDiag(diag::err_undef_superclass_suggest) << SuperName << ClassName); PrevDecl = Corrected.getCorrectionDeclAs(); @@ -542,7 +542,7 @@ ActOnStartClassInterface(SourceLocation AtInterfaceLoc, if (SuperClassDecl) (void)DiagnoseUseOfDecl(SuperClassDecl, SuperLoc); - if (PrevDecl && SuperClassDecl == 0) { + if (PrevDecl && !SuperClassDecl) { // The previous declaration was not a class decl. Check if we have a // typedef. If we do, get the underlying class type. if (const TypedefNameDecl *TDecl = @@ -581,7 +581,7 @@ ActOnStartClassInterface(SourceLocation AtInterfaceLoc, SuperClassDecl->getDeclName(), ClassName, SourceRange(AtInterfaceLoc, ClassLoc))) { - SuperClassDecl = 0; + SuperClassDecl = nullptr; } } IDecl->setSuperClass(SuperClassDecl); @@ -638,7 +638,7 @@ Decl *Sema::ActOnCompatibilityAlias(SourceLocation AtLoc, if (ADecl) { Diag(AliasLocation, diag::err_conflicting_aliasing_type) << AliasName; Diag(ADecl->getLocation(), diag::note_previous_declaration); - return 0; + return nullptr; } // Check for class declaration NamedDecl *CDeclU = LookupSingleName(TUScope, ClassName, ClassLocation, @@ -655,11 +655,11 @@ Decl *Sema::ActOnCompatibilityAlias(SourceLocation AtLoc, } } ObjCInterfaceDecl *CDecl = dyn_cast_or_null(CDeclU); - if (CDecl == 0) { + if (!CDecl) { Diag(ClassLocation, diag::warn_undef_interface) << ClassName; if (CDeclU) Diag(CDeclU->getLocation(), diag::note_previous_declaration); - return 0; + return nullptr; } // Everything checked out, instantiate a new alias declaration AST. @@ -713,8 +713,8 @@ Sema::ActOnStartProtocolInterface(SourceLocation AtProtoInterfaceLoc, assert(ProtocolName && "Missing protocol identifier"); ObjCProtocolDecl *PrevDecl = LookupProtocol(ProtocolName, ProtocolLoc, ForRedeclaration); - ObjCProtocolDecl *PDecl = 0; - if (ObjCProtocolDecl *Def = PrevDecl? PrevDecl->getDefinition() : 0) { + ObjCProtocolDecl *PDecl = nullptr; + if (ObjCProtocolDecl *Def = PrevDecl? PrevDecl->getDefinition() : nullptr) { // If we already have a definition, complain. Diag(ProtocolLoc, diag::warn_duplicate_protocol_def) << ProtocolName; Diag(Def->getLocation(), diag::note_previous_definition); @@ -725,7 +725,7 @@ Sema::ActOnStartProtocolInterface(SourceLocation AtProtoInterfaceLoc, // FIXME: Can we turn this into an error? PDecl = ObjCProtocolDecl::Create(Context, CurContext, ProtocolName, ProtocolLoc, AtProtoInterfaceLoc, - /*PrevDecl=*/0); + /*PrevDecl=*/nullptr); PDecl->startDefinition(); } else { if (PrevDecl) { @@ -793,7 +793,8 @@ Sema::FindProtocolDeclaration(bool WarnOnDeclarations, DeclFilterCCC Validator; TypoCorrection Corrected = CorrectTypo( DeclarationNameInfo(ProtocolId[i].first, ProtocolId[i].second), - LookupObjCProtocolName, TUScope, NULL, Validator, CTK_ErrorRecovery); + LookupObjCProtocolName, TUScope, nullptr, Validator, + CTK_ErrorRecovery); if ((PDecl = Corrected.getCorrectionDeclAs())) diagnoseTypo(Corrected, PDiag(diag::err_undeclared_protocol_suggest) << ProtocolId[i].first); @@ -900,7 +901,7 @@ ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc, if (!IDecl || RequireCompleteType(ClassLoc, Context.getObjCInterfaceType(IDecl), diag::err_category_forward_interface, - CategoryName == 0)) { + CategoryName == nullptr)) { // Create an invalid ObjCCategoryDecl to serve as context for // the enclosing method declarations. We mark the decl invalid // to make it clear that this isn't a valid AST. @@ -957,7 +958,7 @@ Decl *Sema::ActOnStartCategoryImplementation( IdentifierInfo *ClassName, SourceLocation ClassLoc, IdentifierInfo *CatName, SourceLocation CatLoc) { ObjCInterfaceDecl *IDecl = getObjCInterfaceDecl(ClassName, ClassLoc, true); - ObjCCategoryDecl *CatIDecl = 0; + ObjCCategoryDecl *CatIDecl = nullptr; if (IDecl && IDecl->hasDefinition()) { CatIDecl = IDecl->FindCategoryDeclaration(CatName); if (!CatIDecl) { @@ -1016,7 +1017,7 @@ Decl *Sema::ActOnStartClassImplementation( IdentifierInfo *ClassName, SourceLocation ClassLoc, IdentifierInfo *SuperClassname, SourceLocation SuperClassLoc) { - ObjCInterfaceDecl *IDecl = 0; + ObjCInterfaceDecl *IDecl = nullptr; // Check for another declaration kind with the same name. NamedDecl *PrevDecl = LookupSingleName(TUScope, ClassName, ClassLoc, LookupOrdinaryName, @@ -1033,7 +1034,7 @@ Decl *Sema::ActOnStartClassImplementation( ObjCInterfaceValidatorCCC Validator; TypoCorrection Corrected = CorrectTypo(DeclarationNameInfo(ClassName, ClassLoc), - LookupOrdinaryName, TUScope, NULL, Validator, + LookupOrdinaryName, TUScope, nullptr, Validator, CTK_NonError); if (Corrected.getCorrectionDeclAs()) { // Suggest the (potentially) correct interface name. Don't provide a @@ -1048,7 +1049,7 @@ Decl *Sema::ActOnStartClassImplementation( } // Check that super class name is valid class name - ObjCInterfaceDecl* SDecl = 0; + ObjCInterfaceDecl *SDecl = nullptr; if (SuperClassname) { // Check if a different kind of symbol declared in this scope. PrevDecl = LookupSingleName(TUScope, SuperClassname, SuperClassLoc, @@ -1060,7 +1061,7 @@ Decl *Sema::ActOnStartClassImplementation( } else { SDecl = dyn_cast_or_null(PrevDecl); if (SDecl && !SDecl->hasDefinition()) - SDecl = 0; + SDecl = nullptr; if (!SDecl) Diag(SuperClassLoc, diag::err_undef_superclass) << SuperClassname << ClassName; @@ -1081,7 +1082,7 @@ Decl *Sema::ActOnStartClassImplementation( // FIXME: Do we support attributes on the @implementation? If so we should // copy them over. IDecl = ObjCInterfaceDecl::Create(Context, CurContext, AtClassImplLoc, - ClassName, /*PrevDecl=*/0, ClassLoc, + ClassName, /*PrevDecl=*/nullptr, ClassLoc, true); IDecl->startDefinition(); if (SDecl) { @@ -1244,7 +1245,7 @@ static void WarnUndefinedMethod(Sema &S, SourceLocation ImpLoc, ObjCMethodDecl *method, bool &IncompleteImpl, unsigned DiagID, - NamedDecl *NeededFor = 0) { + NamedDecl *NeededFor = nullptr) { // No point warning no definition of method which is 'unavailable'. switch (method->getAvailability()) { case AR_Available: @@ -1688,7 +1689,7 @@ static void CheckProtocolMethodDefs(Sema &S, assert (IDecl && "CheckProtocolMethodDefs - IDecl is null"); ObjCInterfaceDecl *Super = IDecl->getSuperClass(); - ObjCInterfaceDecl *NSIDecl = 0; + ObjCInterfaceDecl *NSIDecl = nullptr; // If this protocol is marked 'objc_protocol_requires_explicit_implementation' // then we should check if any class in the super class hierarchy also @@ -1712,7 +1713,7 @@ static void CheckProtocolMethodDefs(Sema &S, // If no super class conforms to the protocol, we should not search // for methods in the super class to implicitly satisfy the protocol. - Super = NULL; + Super = nullptr; } if (S.getLangOpts().ObjCRuntime.isNeXTFamily()) { @@ -1751,7 +1752,7 @@ static void CheckProtocolMethodDefs(Sema &S, true /* instance */, false /* shallowCategory */, true /* followsSuper */, - NULL /* category */))) { + nullptr /* category */))) { // If a method is not implemented in the category implementation but // has been declared in its primary class, superclass, // or in one of their protocols, no need to issue the warning. @@ -1784,7 +1785,7 @@ static void CheckProtocolMethodDefs(Sema &S, false /* class method */, false /* shallowCategoryLookup */, true /* followSuper */, - NULL /* category */))) { + nullptr /* category */))) { // See above comment for instance method lookups. if (C && IDecl->lookupMethod(method->getSelector(), false /* class */, @@ -2220,9 +2221,9 @@ void Sema::addMethodToGlobalList(ObjCMethodList *List, ObjCMethodDecl *Method) { List->setBits(List->getBits()+1); // If the list is empty, make it a singleton list. - if (List->Method == 0) { + if (List->Method == nullptr) { List->Method = Method; - List->setNext(0); + List->setNext(nullptr); return; } @@ -2262,7 +2263,7 @@ void Sema::addMethodToGlobalList(ObjCMethodList *List, ObjCMethodDecl *Method) { // We have a new signature for an existing method - add it. // This is extremely rare. Only 1% of Cocoa selectors are "overloaded". ObjCMethodList *Mem = BumpAlloc.Allocate(); - Previous->setNext(new (Mem) ObjCMethodList(Method, 0)); + Previous->setNext(new (Mem) ObjCMethodList(Method, nullptr)); } /// \brief Read the contents of the method pool for a given selector from @@ -2319,7 +2320,7 @@ ObjCMethodDecl *Sema::LookupMethodInGlobalPool(Selector Sel, SourceRange R, GlobalMethodPool::iterator Pos = MethodPool.find(Sel); if (Pos == MethodPool.end()) - return 0; + return nullptr; // Gather the non-hidden methods. ObjCMethodList &MethList = instance ? Pos->second.first : Pos->second.second; @@ -2337,7 +2338,7 @@ ObjCMethodDecl *Sema::LookupMethodInGlobalPool(Selector Sel, SourceRange R, // If there aren't any visible methods, we're done. // FIXME: Recover if there are any known-but-hidden methods? if (Methods.empty()) - return 0; + return nullptr; if (Methods.size() == 1) return Methods[0]; @@ -2399,7 +2400,7 @@ ObjCMethodDecl *Sema::LookupMethodInGlobalPool(Selector Sel, SourceRange R, ObjCMethodDecl *Sema::LookupImplementedMethodInGlobalPool(Selector Sel) { GlobalMethodPool::iterator Pos = MethodPool.find(Sel); if (Pos == MethodPool.end()) - return 0; + return nullptr; GlobalMethods &Methods = Pos->second; for (const ObjCMethodList *Method = &Methods.first; Method; @@ -2411,7 +2412,7 @@ ObjCMethodDecl *Sema::LookupImplementedMethodInGlobalPool(Selector Sel) { Method = Method->getNext()) if (Method->Method && Method->Method->isDefined()) return Method->Method; - return 0; + return nullptr; } static void @@ -2443,7 +2444,8 @@ static bool HelperIsMethodInObjCType(Sema &S, Selector Sel, return true; if (S.LookupMethodInObjectType(Sel, ObjectType, true/*Instance method*/)) return true; - return S.LookupMethodInObjectType(Sel, ObjectType, false/*Class method*/) != 0; + return S.LookupMethodInObjectType(Sel, ObjectType, false/*Class method*/) != + nullptr; } const ObjCMethodDecl * @@ -2455,7 +2457,7 @@ Sema::SelectorsForTypoCorrection(Selector Sel, if (ObjectType.isNull()) ObjectIsId = ObjectIsClass = false; else if (!ObjectType->isObjCObjectPointerType()) - return 0; + return nullptr; else if (const ObjCObjectPointerType *ObjCPtr = ObjectType->getAsObjCInterfacePointerType()) { ObjectType = QualType(ObjCPtr->getInterfaceType(), 0); @@ -2466,8 +2468,8 @@ Sema::SelectorsForTypoCorrection(Selector Sel, else if (ObjectType->isObjCClassType() || ObjectType->isObjCQualifiedClassType()) ObjectIsId = false; else - return 0; - + return nullptr; + for (GlobalMethodPool::iterator b = MethodPool.begin(), e = MethodPool.end(); b != e; b++) { // instance methods @@ -2499,7 +2501,7 @@ Sema::SelectorsForTypoCorrection(Selector Sel, HelperSelectorsForTypoCorrection(SelectedMethods, Sel.getAsString(), Methods[i]); } - return (SelectedMethods.size() == 1) ? SelectedMethods[0] : NULL; + return (SelectedMethods.size() == 1) ? SelectedMethods[0] : nullptr; } /// DiagnoseDuplicateIvars - @@ -2548,7 +2550,7 @@ Sema::ObjCContainerKind Sema::getObjCContainerKind() const { Decl *Sema::ActOnAtEnd(Scope *S, SourceRange AtEnd, ArrayRef allMethods, ArrayRef allTUVars) { if (getObjCContainerKind() == Sema::OCK_None) - return 0; + return nullptr; assert(AtEnd.isValid() && "Invalid location for '@end'"); @@ -2675,7 +2677,7 @@ Decl *Sema::ActOnAtEnd(Scope *S, SourceRange AtEnd, ArrayRef allMethods, DiagnoseMissingDesignatedInitOverrides(IC, IDecl); bool HasRootClassAttr = IDecl->hasAttr(); - if (IDecl->getSuperClass() == NULL) { + if (IDecl->getSuperClass() == nullptr) { // This class has no superclass, so check that it has been marked with // __attribute((objc_root_class)). if (!HasRootClassAttr) { @@ -3058,19 +3060,19 @@ Decl *Sema::ActOnMethodDeclaration( // Make sure we can establish a context for the method. if (!CurContext->isObjCContainer()) { Diag(MethodLoc, diag::error_missing_method_context); - return 0; + return nullptr; } ObjCContainerDecl *OCD = dyn_cast(CurContext); Decl *ClassDecl = cast(OCD); QualType resultDeclType; bool HasRelatedResultType = false; - TypeSourceInfo *ReturnTInfo = 0; + TypeSourceInfo *ReturnTInfo = nullptr; if (ReturnType) { resultDeclType = GetTypeFromParser(ReturnType, &ReturnTInfo); if (CheckFunctionReturnType(resultDeclType, MethodLoc)) - return 0; + return nullptr; HasRelatedResultType = (resultDeclType == Context.getObjCInstanceType()); } else { // get the type for "id". @@ -3096,7 +3098,7 @@ Decl *Sema::ActOnMethodDeclaration( if (!ArgInfo[i].Type) { ArgType = Context.getObjCIdType(); - DI = 0; + DI = nullptr; } else { ArgType = GetTypeFromParser(ArgInfo[i].Type, &DI); } @@ -3163,7 +3165,7 @@ Decl *Sema::ActOnMethodDeclaration( ProcessDeclAttributeList(TUScope, ObjCMethod, AttrList); // Add the method now. - const ObjCMethodDecl *PrevMethod = 0; + const ObjCMethodDecl *PrevMethod = nullptr; if (ObjCImplDecl *ImpDecl = dyn_cast(ClassDecl)) { if (MethodType == tok::minus) { PrevMethod = ImpDecl->getInstanceMethod(Sel); @@ -3173,7 +3175,7 @@ Decl *Sema::ActOnMethodDeclaration( ImpDecl->addClassMethod(ObjCMethod); } - ObjCMethodDecl *IMD = 0; + ObjCMethodDecl *IMD = nullptr; if (ObjCInterfaceDecl *IDecl = ImpDecl->getClassInterface()) IMD = IDecl->lookupMethod(ObjCMethod->getSelector(), ObjCMethod->isInstanceMethod()); @@ -3459,15 +3461,15 @@ ObjCIvarDecl * Sema::GetIvarBackingPropertyAccessor(const ObjCMethodDecl *Method, const ObjCPropertyDecl *&PDecl) const { if (Method->isClassMethod()) - return 0; + return nullptr; const ObjCInterfaceDecl *IDecl = Method->getClassInterface(); if (!IDecl) - return 0; + return nullptr; Method = IDecl->lookupMethod(Method->getSelector(), /*isInstance=*/true, /*shallowCategoryLookup=*/false, /*followSuper=*/false); if (!Method || !Method->isPropertyAccessor()) - return 0; + return nullptr; if ((PDecl = Method->findPropertyDecl())) if (ObjCIvarDecl *IV = PDecl->getPropertyIvarDecl()) { // property backing ivar must belong to property's class @@ -3477,7 +3479,7 @@ Sema::GetIvarBackingPropertyAccessor(const ObjCMethodDecl *Method, IV->getIdentifier()); return IV; } - return 0; + return nullptr; } namespace { diff --git a/clang/lib/Sema/SemaExceptionSpec.cpp b/clang/lib/Sema/SemaExceptionSpec.cpp index 531c71f..40112a0 100644 --- a/clang/lib/Sema/SemaExceptionSpec.cpp +++ b/clang/lib/Sema/SemaExceptionSpec.cpp @@ -283,7 +283,7 @@ bool Sema::CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New) { case EST_ComputedNoexcept: OS << "noexcept("; - OldProto->getNoexceptExpr()->printPretty(OS, 0, getPrintingPolicy()); + OldProto->getNoexceptExpr()->printPretty(OS, nullptr, getPrintingPolicy()); OS << ")"; break; @@ -455,7 +455,7 @@ bool Sema::CheckEquivalentExceptionSpec(const PartialDiagnostic &DiagID, // throw(std::bad_alloc) as equivalent for operator new and operator new[]. // This is because the implicit declaration changed, but old code would break. if (getLangOpts().CPlusPlus11 && IsOperatorNew) { - const FunctionProtoType *WithExceptions = 0; + const FunctionProtoType *WithExceptions = nullptr; if (OldEST == EST_None && NewEST == EST_Dynamic) WithExceptions = New; else if (OldEST == EST_Dynamic && NewEST == EST_None) diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 33eea16..a9f1197 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -94,11 +94,11 @@ static AvailabilityResult DiagnoseAvailabilityOfDecl(Sema &S, Result = TheEnumDecl->getAvailability(&Message); } - const ObjCPropertyDecl *ObjCPDecl = 0; + const ObjCPropertyDecl *ObjCPDecl = nullptr; if (Result == AR_Deprecated || Result == AR_Unavailable) { if (const ObjCMethodDecl *MD = dyn_cast(D)) { if (const ObjCPropertyDecl *PD = MD->findPropertyDecl()) { - AvailabilityResult PDeclResult = PD->getAvailability(0); + AvailabilityResult PDeclResult = PD->getAvailability(nullptr); if (PDeclResult == Result) ObjCPDecl = PD; } @@ -342,7 +342,7 @@ void Sema::DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc, calleeType = CT_Function; } else if (isa(D)) { QualType type = cast(D)->getType(); - const FunctionType *fn = 0; + const FunctionType *fn = nullptr; if (const PointerType *ptr = type->getAs()) { fn = ptr->getPointeeType()->getAs(); if (!fn) return; @@ -497,7 +497,7 @@ static void DiagnoseDirectIsaAccess(Sema &S, const ObjCIvarRefExpr *OIRE, BaseType = BaseType->getPointeeType(); if (const ObjCObjectType *OTy = BaseType->getAs()) if (ObjCInterfaceDecl *IDecl = OTy->getInterface()) { - ObjCInterfaceDecl *ClassDeclared = 0; + ObjCInterfaceDecl *ClassDeclared = nullptr; ObjCIvarDecl *IV = IDecl->lookupInstanceVariable(Member, ClassDeclared); if (!ClassDeclared->getSuperClass() && (*ClassDeclared->ivar_begin()) == IV) { @@ -590,8 +590,8 @@ ExprResult Sema::DefaultLvalueConversion(Expr *E) { } else if (const ObjCIvarRefExpr *OIRE = dyn_cast(E->IgnoreParenCasts())) - DiagnoseDirectIsaAccess(*this, OIRE, SourceLocation(), /* Expr*/0); - + DiagnoseDirectIsaAccess(*this, OIRE, SourceLocation(), /* Expr*/nullptr); + // C++ [conv.lval]p1: // [...] If T is a non-class type, the type of the prvalue is the // cv-unqualified version of T. Otherwise, the type of the @@ -613,7 +613,7 @@ ExprResult Sema::DefaultLvalueConversion(Expr *E) { ExprNeedsCleanups = true; ExprResult Res = Owned(ImplicitCastExpr::Create(Context, T, CK_LValueToRValue, - E, 0, VK_RValue)); + E, nullptr, VK_RValue)); // C11 6.3.2.1p2: // ... if the lvalue has atomic type, the value has the non-atomic version @@ -621,7 +621,7 @@ ExprResult Sema::DefaultLvalueConversion(Expr *E) { if (const AtomicType *Atomic = T->getAs()) { T = Atomic->getValueType().getUnqualifiedType(); Res = Owned(ImplicitCastExpr::Create(Context, T, CK_AtomicToNonAtomic, - Res.get(), 0, VK_RValue)); + Res.get(), nullptr, VK_RValue)); } return Res; @@ -806,7 +806,7 @@ void Sema::checkVariadicArgument(const Expr *E, VariadicCallType CT) { switch (VAK) { case VAK_ValidInCXX11: DiagRuntimeBehavior( - E->getLocStart(), 0, + E->getLocStart(), nullptr, PDiag(diag::warn_cxx98_compat_pass_non_pod_arg_to_vararg) << Ty << CT); // Fall through. @@ -814,7 +814,7 @@ void Sema::checkVariadicArgument(const Expr *E, VariadicCallType CT) { if (Ty->isRecordType()) { // This is unlikely to be what the user intended. If the class has a // 'c_str' member function, the user probably meant to call that. - DiagRuntimeBehavior(E->getLocStart(), 0, + DiagRuntimeBehavior(E->getLocStart(), nullptr, PDiag(diag::warn_pass_class_arg_to_vararg) << Ty << CT << hasCStrMethod(E) << ".c_str()"); } @@ -822,7 +822,7 @@ void Sema::checkVariadicArgument(const Expr *E, VariadicCallType CT) { case VAK_Undefined: DiagRuntimeBehavior( - E->getLocStart(), 0, + E->getLocStart(), nullptr, PDiag(diag::warn_cannot_pass_non_pod_arg_to_vararg) << getLangOpts().CPlusPlus11 << Ty << CT); break; @@ -830,7 +830,7 @@ void Sema::checkVariadicArgument(const Expr *E, VariadicCallType CT) { case VAK_Invalid: if (Ty->isObjCObjectType()) DiagRuntimeBehavior( - E->getLocStart(), 0, + E->getLocStart(), nullptr, PDiag(diag::err_cannot_pass_objc_interface_to_vararg) << Ty << CT); else @@ -1302,7 +1302,7 @@ Sema::ActOnGenericSelectionExpr(SourceLocation KeyLoc, if (ArgTypes[i]) (void) GetTypeFromParser(ArgTypes[i], &Types[i]); else - Types[i] = 0; + Types[i] = nullptr; } ExprResult ER = CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc, @@ -1715,7 +1715,7 @@ Sema::DecomposeUnqualifiedId(const UnqualifiedId &Id, TemplateArgs = &Buffer; } else { NameInfo = GetNameFromUnqualifiedId(Id); - TemplateArgs = 0; + TemplateArgs = nullptr; } } @@ -1742,7 +1742,7 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, // original lookup would not have found something because it was a // dependent name. DeclContext *DC = (SS.isEmpty() && !CallsUndergoingInstantiation.empty()) - ? CurContext : 0; + ? CurContext : nullptr; while (DC) { if (isa(DC)) { LookupQualifiedName(R, DC); @@ -1800,9 +1800,9 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, CXXDependentScopeMemberExpr::Create( Context, DepThis, DepThisType, true, SourceLocation(), SS.getWithLocInContext(Context), - ULE->getTemplateKeywordLoc(), 0, + ULE->getTemplateKeywordLoc(), nullptr, R.getLookupNameInfo(), - ULE->hasExplicitTemplateArgs() ? &TList : 0); + ULE->hasExplicitTemplateArgs() ? &TList : nullptr); CallsUndergoingInstantiation.back()->setCallee(DepExpr); } else { Diag(R.getNameLoc(), diagnostic) << Name; @@ -2059,9 +2059,9 @@ ExprResult Sema::ActOnIdExpression(Scope *S, QualType ThisType = MD->getThisType(Context); // Since the 'this' expression is synthesized, we don't need to // perform the double-lookup check. - NamedDecl *FirstQualifierInScope = 0; + NamedDecl *FirstQualifierInScope = nullptr; return Owned(CXXDependentScopeMemberExpr::Create( - Context, /*This=*/0, ThisType, /*IsArrow=*/true, + Context, /*This=*/nullptr, ThisType, /*IsArrow=*/true, /*Op=*/SourceLocation(), SS.getWithLocInContext(Context), TemplateKWLoc, FirstQualifierInScope, NameInfo, TemplateArgs)); } @@ -2168,7 +2168,7 @@ Sema::BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS, DeclContext *DC = computeDeclContext(SS, false); if (!DC) return BuildDependentDeclRefExpr(SS, /*TemplateKWLoc=*/SourceLocation(), - NameInfo, /*TemplateArgs=*/0); + NameInfo, /*TemplateArgs=*/nullptr); if (RequireCompleteDeclContext(SS, DC)) return ExprError(); @@ -2181,7 +2181,7 @@ Sema::BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS, if (R.getResultKind() == LookupResult::NotFoundInCurrentInstantiation) return BuildDependentDeclRefExpr(SS, /*TemplateKWLoc=*/SourceLocation(), - NameInfo, /*TemplateArgs=*/0); + NameInfo, /*TemplateArgs=*/nullptr); if (R.empty()) { Diag(NameInfo.getLoc(), diag::err_no_member) @@ -2196,7 +2196,7 @@ Sema::BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS, if (!R.empty() && (*R.begin())->isCXXClassMember() && !IsAddressOfOperand) return BuildPossibleImplicitMemberExpr(SS, /*TemplateKWLoc=*/SourceLocation(), - R, /*TemplateArgs=*/0); + R, /*TemplateArgs=*/nullptr); return BuildDeclarationNameExpr(SS, R, /* ADL */ false); } @@ -2238,11 +2238,11 @@ Sema::LookupInObjCMethod(LookupResult &Lookup, Scope *S, else LookForIvars = (Lookup.isSingleResult() && Lookup.getFoundDecl()->isDefinedOutsideFunctionOrMethod()); - ObjCInterfaceDecl *IFace = 0; + ObjCInterfaceDecl *IFace = nullptr; if (LookForIvars) { IFace = CurMethod->getClassInterface(); ObjCInterfaceDecl *ClassDeclared; - ObjCIvarDecl *IV = 0; + ObjCIvarDecl *IV = nullptr; if (IFace && (IV = IFace->lookupInstanceVariable(II, ClassDeclared))) { // Diagnose using an ivar in a class method. if (IsClassMethod) @@ -2338,7 +2338,7 @@ Sema::LookupInObjCMethod(LookupResult &Lookup, Scope *S, } } // Sentinel value saying that we didn't do anything special. - return Owned((Expr*) 0); + return Owned((Expr*) nullptr); } /// \brief Cast a base object to a member's actual type. @@ -2831,7 +2831,7 @@ ExprResult Sema::BuildDeclarationNameExpr( ExprResult Sema::BuildPredefinedExpr(SourceLocation Loc, PredefinedExpr::IdentType IT) { // Pick the current block, lambda, captured statement or function. - Decl *currentDecl = 0; + Decl *currentDecl = nullptr; if (const BlockScopeInfo *BSI = getCurBlock()) currentDecl = BSI->TheDecl; else if (const LambdaScopeInfo *LSI = getCurLambda()) @@ -3232,7 +3232,7 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) { } ExprResult Sema::ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E) { - assert((E != 0) && "ActOnParenExpr() missing expr"); + assert(E && "ActOnParenExpr() missing expr"); return Owned(new (Context) ParenExpr(L, R, E)); } @@ -3452,7 +3452,7 @@ static bool CheckAlignOfExpr(Sema &S, Expr *E) { return true; } - ValueDecl *D = 0; + ValueDecl *D = nullptr; if (DeclRefExpr *DRE = dyn_cast(E)) { D = DRE->getDecl(); } else if (MemberExpr *ME = dyn_cast(E)) { @@ -3587,7 +3587,7 @@ Sema::ActOnUnaryExprOrTypeTraitExpr(SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, bool IsType, void *TyOrEx, const SourceRange &ArgRange) { // If error parsing type, ignore. - if (TyOrEx == 0) return ExprError(); + if (!TyOrEx) return ExprError(); if (IsType) { TypeSourceInfo *TInfo; @@ -3768,7 +3768,8 @@ Sema::CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, // Use custom logic if this should be the pseudo-object subscript // expression. if (!LangOpts.isSubscriptPointerArithmetic()) - return BuildObjCSubscriptExpression(RLoc, BaseExpr, IndexExpr, 0, 0); + return BuildObjCSubscriptExpression(RLoc, BaseExpr, IndexExpr, nullptr, + nullptr); ResultType = PTy->getPointeeType(); } else if (const PointerType *PTy = RHSTy->getAs()) { @@ -3886,7 +3887,7 @@ ExprResult Sema::BuildCXXDefaultArgExpr(SourceLocation CallLoc, // Instantiate the expression. MultiLevelTemplateArgumentList MutiLevelArgList - = getTemplateInstantiationArgs(FD, 0, /*RelativeToPrimary=*/true); + = getTemplateInstantiationArgs(FD, nullptr, /*RelativeToPrimary=*/true); InstantiatingTemplate Inst(*this, CallLoc, Param, MutiLevelArgList.getInnermost()); @@ -4004,7 +4005,7 @@ static TypoCorrection TryTypoCorrectionForCall(Sema &S, Expr *Fn, if (TypoCorrection Corrected = S.CorrectTypo( DeclarationNameInfo(FuncName, NameLoc), Sema::LookupOrdinaryName, - S.getScopeForContext(S.CurContext), NULL, CCC, + S.getScopeForContext(S.CurContext), nullptr, CCC, Sema::CTK_ErrorRecovery)) { if (NamedDecl *ND = Corrected.getCorrectionDecl()) { if (Corrected.isOverloaded()) { @@ -4480,7 +4481,7 @@ Sema::ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, Expr *NakedFn = Fn->IgnoreParens(); - NamedDecl *NDecl = 0; + NamedDecl *NDecl = nullptr; if (UnaryOperator *UnOp = dyn_cast(NakedFn)) if (UnOp->getOpcode() == UO_AddrOf) NakedFn = UnOp->getSubExpr()->IgnoreParens(); @@ -4522,7 +4523,7 @@ Sema::ActOnCUDAExecConfigExpr(Scope *S, SourceLocation LLLLoc, ConfigDecl, false, ConfigQTy, VK_LValue, LLLLoc); MarkFunctionReferenced(LLLLoc, ConfigDecl); - return ActOnCallExpr(S, ConfigDR, LLLLoc, ExecConfig, GGGLoc, 0, + return ActOnCallExpr(S, ConfigDR, LLLLoc, ExecConfig, GGGLoc, nullptr, /*IsExecConfig=*/true); } @@ -4612,7 +4613,7 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, // C99 6.5.2.2p1 - "The expression that denotes the called function shall // have type pointer to function". FuncT = PT->getPointeeType()->getAs(); - if (FuncT == 0) + if (!FuncT) return ExprError(Diag(LParenLoc, diag::err_typecheck_call_not_function) << Fn->getType() << Fn->getSourceRange()); } else if (const BlockPointerType *BPT = @@ -4671,7 +4672,7 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, if (FDecl) { // Check if we have too few/too many template arguments, based // on our knowledge of the function definition. - const FunctionDecl *Def = 0; + const FunctionDecl *Def = nullptr; if (FDecl->hasBody(Def) && Args.size() != Def->param_size()) { Proto = Def->getType()->getAs(); if (!Proto || !(Proto->isVariadic() && Args.size() >= Def->param_size())) @@ -4793,7 +4794,7 @@ Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, return ExprError(); LiteralExpr = Result.get(); - bool isFileScope = getCurFunctionOrMethodDecl() == 0; + bool isFileScope = getCurFunctionOrMethodDecl() == nullptr; if (isFileScope && !LiteralExpr->isTypeDependent() && !LiteralExpr->isValueDependent() && @@ -4846,7 +4847,7 @@ static void maybeExtendBlockObject(Sema &S, ExprResult &E) { E = ImplicitCastExpr::Create(S.Context, E.get()->getType(), CK_ARCExtendBlockObject, E.get(), - /*base path*/ 0, VK_RValue); + /*base path*/ nullptr, VK_RValue); S.ExprNeedsCleanups = true; } @@ -5141,7 +5142,7 @@ ExprResult Sema::ActOnCastExpr(Scope *S, SourceLocation LParenLoc, Declarator &D, ParsedType &Ty, SourceLocation RParenLoc, Expr *CastExpr) { - assert(!D.isInvalidType() && (CastExpr != 0) && + assert(!D.isInvalidType() && (CastExpr != nullptr) && "ActOnCastExpr(): missing type or expr"); TypeSourceInfo *castTInfo = GetTypeForDeclaratorCast(D, CastExpr->getType()); @@ -5962,9 +5963,9 @@ ExprResult Sema::ActOnConditionalOp(SourceLocation QuestionLoc, Expr *RHSExpr) { // If this is the gnu "x ?: y" extension, analyze the types as though the LHS // was the condition. - OpaqueValueExpr *opaqueValue = 0; - Expr *commonExpr = 0; - if (LHSExpr == 0) { + OpaqueValueExpr *opaqueValue = nullptr; + Expr *commonExpr = nullptr; + if (!LHSExpr) { commonExpr = CondExpr; // Lower out placeholder types first. This is important so that we don't // try to capture a placeholder. This happens in few cases in C++; such @@ -6540,7 +6541,7 @@ Sema::CheckTransparentUnionArgumentConstraints(QualType ArgType, // The field to initialize within the transparent union. RecordDecl *UD = UT->getDecl(); - FieldDecl *InitField = 0; + FieldDecl *InitField = nullptr; // It's compatible if the expression matches any of the fields. for (auto *it : UD->fields()) { if (it->getType()->isPointerType()) { @@ -6776,8 +6777,9 @@ QualType Sema::CheckVectorOperands(ExprResult &LHS, ExprResult &RHS, return LHSType; } if (!LHSVecType && isa(RHSVecType)) { - if (!tryVectorConvertAndSplat(*this, (IsCompAssign ? 0 : &LHS), LHSType, - RHSVecType->getElementType(), RHSType)) + if (!tryVectorConvertAndSplat(*this, (IsCompAssign ? nullptr : &LHS), + LHSType, RHSVecType->getElementType(), + RHSType)) return RHSType; } @@ -7257,7 +7259,7 @@ QualType Sema::CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS, return QualType(); // Check array bounds for pointer arithemtic - CheckArrayAccess(LHS.get(), RHS.get(), /*ArraySubscriptExpr*/0, + CheckArrayAccess(LHS.get(), RHS.get(), /*ArraySubscriptExpr*/nullptr, /*AllowOnePastEnd*/true, /*IndexNegated*/true); if (CompLHSTy) *CompLHSTy = LHS.get()->getType(); @@ -7507,7 +7509,7 @@ static bool convertPointersToCompositeType(Sema &S, SourceLocation Loc, (LHSType->isMemberPointerType() && RHSType->isMemberPointerType())); bool NonStandardCompositeType = false; - bool *BoolPtr = S.isSFINAEContext() ? 0 : &NonStandardCompositeType; + bool *BoolPtr = S.isSFINAEContext() ? nullptr : &NonStandardCompositeType; QualType T = S.FindCompositePointerType(Loc, LHS, RHS, BoolPtr); if (T.isNull()) { diagnoseDistinctPointerComparison(S, Loc, LHS, RHS, /*isError*/true); @@ -7744,7 +7746,7 @@ static ValueDecl *getCompareDecl(Expr *E) { if (Mem->isImplicitAccess()) return Mem->getMemberDecl(); } - return 0; + return nullptr; } // C99 6.5.8, C++ [expr.rel] @@ -7787,7 +7789,7 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS, ValueDecl *DL = getCompareDecl(LHSStripped); ValueDecl *DR = getCompareDecl(RHSStripped); if (DL && DR && DL == DR && !IsWithinTemplateSpecialization(DL)) { - DiagRuntimeBehavior(Loc, 0, PDiag(diag::warn_comparison_always) + DiagRuntimeBehavior(Loc, nullptr, PDiag(diag::warn_comparison_always) << 0 // self- << (Opc == BO_EQ || Opc == BO_LE @@ -7809,7 +7811,7 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS, always_evals_to = 2; // e.g. array1 <= array2 break; } - DiagRuntimeBehavior(Loc, 0, PDiag(diag::warn_comparison_always) + DiagRuntimeBehavior(Loc, nullptr, PDiag(diag::warn_comparison_always) << 1 // array << always_evals_to); } @@ -7821,8 +7823,8 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS, // Warn about comparisons against a string constant (unless the other // operand is null), the user probably wants strcmp. - Expr *literalString = 0; - Expr *literalStringStripped = 0; + Expr *literalString = nullptr; + Expr *literalStringStripped = nullptr; if ((isa(LHSStripped) || isa(LHSStripped)) && !RHSStripped->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNull)) { @@ -7837,7 +7839,7 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS, } if (literalString) { - DiagRuntimeBehavior(Loc, 0, + DiagRuntimeBehavior(Loc, nullptr, PDiag(diag::warn_stringcompare) << isa(literalStringStripped) << literalString->getSourceRange()); @@ -8182,7 +8184,7 @@ QualType Sema::CheckVectorCompareOperands(ExprResult &LHS, ExprResult &RHS, if (DeclRefExpr* DRR = dyn_cast(RHS.get()->IgnoreParenImpCasts())) if (DRL->getDecl() == DRR->getDecl()) - DiagRuntimeBehavior(Loc, 0, + DiagRuntimeBehavior(Loc, nullptr, PDiag(diag::warn_comparison_always) << 0 // self- << 2 // "a constant" @@ -8339,7 +8341,7 @@ static bool IsReadonlyMessage(Expr *E, Sema &S) { ObjCMessageExpr *Base = dyn_cast(ME->getBase()->IgnoreParenImpCasts()); if (!Base) return false; - return Base->getMethodDecl() != 0; + return Base->getMethodDecl() != nullptr; } /// Is the given expression (which must be 'const') a reference to a @@ -8362,7 +8364,7 @@ static NonConstCaptureKind isReferenceToNonConstCapture(Sema &S, Expr *E) { assert(var->hasLocalStorage() && "capture added 'const' to non-local?"); // Decide whether the first capture was for a block or a lambda. - DeclContext *DC = S.CurContext, *Prev = 0; + DeclContext *DC = S.CurContext, *Prev = nullptr; while (DC != var->getDeclContext()) { Prev = DC; DC = DC->getParent(); @@ -8742,7 +8744,7 @@ static ValueDecl *getPrimaryDecl(Expr *E) { // the base's value, so the object the base refers to is // irrelevant. if (cast(E)->isArrow()) - return 0; + return nullptr; // Otherwise, the expression refers to a part of the base return getPrimaryDecl(cast(E)->getBase()); case Stmt::ArraySubscriptExprClass: { @@ -8753,7 +8755,7 @@ static ValueDecl *getPrimaryDecl(Expr *E) { if (ICE->getSubExpr()->getType()->isArrayType()) return getPrimaryDecl(ICE->getSubExpr()); } - return 0; + return nullptr; } case Stmt::UnaryOperatorClass: { UnaryOperator *UO = cast(E); @@ -8764,7 +8766,7 @@ static ValueDecl *getPrimaryDecl(Expr *E) { case UO_Extension: return getPrimaryDecl(UO->getSubExpr()); default: - return 0; + return nullptr; } } case Stmt::ParenExprClass: @@ -8774,7 +8776,7 @@ static ValueDecl *getPrimaryDecl(Expr *E) { // the sub-expression; otherwise, the result here doesn't matter. return getPrimaryDecl(cast(E)->getSubExpr()); default: - return 0; + return nullptr; } } @@ -9159,7 +9161,7 @@ static void checkObjCPointerIntrospection(Sema &S, ExprResult &L, ExprResult &R, if (!S.getLangOpts().ObjC1) return; - const Expr *ObjCPointerExpr = 0, *OtherExpr = 0; + const Expr *ObjCPointerExpr = nullptr, *OtherExpr = nullptr; const Expr *LHS = L.get(); const Expr *RHS = R.get(); @@ -9583,8 +9585,8 @@ ExprResult Sema::ActOnBinOp(Scope *S, SourceLocation TokLoc, tok::TokenKind Kind, Expr *LHSExpr, Expr *RHSExpr) { BinaryOperatorKind Opc = ConvertTokenKindToBinaryOpcode(Kind); - assert((LHSExpr != 0) && "ActOnBinOp(): missing left expression"); - assert((RHSExpr != 0) && "ActOnBinOp(): missing right expression"); + assert(LHSExpr && "ActOnBinOp(): missing left expression"); + assert(RHSExpr && "ActOnBinOp(): missing right expression"); // Emit warnings for tricky precedence issues, e.g. "bitfield & 0x4 == 0" DiagnoseBinOpPrecedence(*this, Opc, TokLoc, LHSExpr, RHSExpr); @@ -9963,11 +9965,11 @@ ExprResult Sema::ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, static Expr *maybeRebuildARCConsumingStmt(Stmt *Statement) { // Should always be wrapped with one of these. ExprWithCleanups *cleanups = dyn_cast(Statement); - if (!cleanups) return 0; + if (!cleanups) return nullptr; ImplicitCastExpr *cast = dyn_cast(cleanups->getSubExpr()); if (!cast || cast->getCastKind() != CK_ARCConsumeObject) - return 0; + return nullptr; // Splice out the cast. This shouldn't modify any interesting // features of the statement. @@ -10002,7 +10004,7 @@ Sema::ActOnStmtExpr(SourceLocation LPLoc, Stmt *SubStmt, PopExpressionEvaluationContext(); bool isFileScope - = (getCurFunctionOrMethodDecl() == 0) && (getCurBlock() == 0); + = (getCurFunctionOrMethodDecl() == nullptr) && (getCurBlock() == nullptr); if (isFileScope) return ExprError(Diag(LPLoc, diag::err_stmtexpr_file_scope)); @@ -10016,7 +10018,7 @@ Sema::ActOnStmtExpr(SourceLocation LPLoc, Stmt *SubStmt, bool StmtExprMayBindToTemp = false; if (!Compound->body_empty()) { Stmt *LastStmt = Compound->body_back(); - LabelStmt *LastLabelStmt = 0; + LabelStmt *LastLabelStmt = nullptr; // If LastStmt is a label, skip down through into the body. while (LabelStmt *Label = dyn_cast(LastStmt)) { LastLabelStmt = Label; @@ -10052,7 +10054,7 @@ Sema::ActOnStmtExpr(SourceLocation LPLoc, Stmt *SubStmt, if (LastExpr.isInvalid()) return ExprError(); - if (LastExpr.get() != 0) { + if (LastExpr.get() != nullptr) { if (!LastLabelStmt) Compound->setLastStmt(LastExpr.take()); else @@ -10174,7 +10176,7 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation BuiltinLoc, : diag::warn_offsetof_non_pod_type; if (!IsSafe && !DidWarnAboutNonPOD && - DiagRuntimeBehavior(BuiltinLoc, 0, + DiagRuntimeBehavior(BuiltinLoc, nullptr, PDiag(DiagID) << SourceRange(CompPtr[0].LocStart, OC.LocEnd) << CurrentType)) @@ -10185,7 +10187,7 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation BuiltinLoc, LookupResult R(*this, OC.U.IdentInfo, OC.LocStart, LookupMemberName); LookupQualifiedName(R, RD); FieldDecl *MemberDecl = R.getAsSingle(); - IndirectFieldDecl *IndirectMemberDecl = 0; + IndirectFieldDecl *IndirectMemberDecl = nullptr; if (!MemberDecl) { if ((IndirectMemberDecl = R.getAsSingle())) MemberDecl = IndirectMemberDecl->getAnonField(); @@ -10340,7 +10342,8 @@ void Sema::ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope) { void Sema::ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo, Scope *CurScope) { - assert(ParamInfo.getIdentifier()==0 && "block-id should have no identifier!"); + assert(ParamInfo.getIdentifier() == nullptr && + "block-id should have no identifier!"); assert(ParamInfo.getContext() == Declarator::BlockLiteralContext); BlockScopeInfo *CurBlock = getCurBlock(); @@ -10411,7 +10414,7 @@ void Sema::ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo, if (ExplicitSignature) { for (unsigned I = 0, E = ExplicitSignature.getNumParams(); I != E; ++I) { ParmVarDecl *Param = ExplicitSignature.getParam(I); - if (Param->getIdentifier() == 0 && + if (Param->getIdentifier() == nullptr && !Param->isImplicit() && !Param->isInvalidDecl() && !getLangOpts().CPlusPlus) @@ -11081,7 +11084,7 @@ namespace { // FIXME: This does the right thing, but maybe we need a more general // fix to TreeTransform? StmtResult TransformLabelStmt(LabelStmt *S) { - S->getDecl()->setStmt(0); + S->getDecl()->setStmt(nullptr); return BaseTransform::TransformLabelStmt(S); } @@ -11509,7 +11512,7 @@ static DeclContext *getParentOfCapturingContextOrNull(DeclContext *DC, VarDecl * if (Diagnose) diagnoseUncapturableValueReference(S, Loc, Var, DC); } - return 0; + return nullptr; } // Certain capturing entities (lambdas, blocks etc.) are not allowed to capture @@ -11586,7 +11589,7 @@ static bool captureInBlock(BlockScopeInfo *BSI, VarDecl *Var, QualType &DeclRefType, const bool Nested, Sema &S) { - Expr *CopyExpr = 0; + Expr *CopyExpr = nullptr; bool ByRef = false; // Blocks are not allowed to capture arrays. @@ -11683,7 +11686,7 @@ static bool captureInCapturedRegion(CapturedRegionScopeInfo *RSI, bool ByRef = true; // Using an LValue reference type is consistent with Lambdas (see below). CaptureType = S.Context.getLValueReferenceType(DeclRefType); - Expr *CopyExpr = 0; + Expr *CopyExpr = nullptr; if (BuildAndDiagnose) { // The current implementation assumes that all variables are captured // by references. Since there is no capture by copy, no expression @@ -11691,9 +11694,9 @@ static bool captureInCapturedRegion(CapturedRegionScopeInfo *RSI, RecordDecl *RD = RSI->TheRecordDecl; FieldDecl *Field - = FieldDecl::Create(S.Context, RD, Loc, Loc, 0, CaptureType, + = FieldDecl::Create(S.Context, RD, Loc, Loc, nullptr, CaptureType, S.Context.getTrivialTypeSourceInfo(CaptureType, Loc), - 0, false, ICIS_NoInit); + nullptr, false, ICIS_NoInit); Field->setImplicit(true); Field->setAccess(AS_private); RD->addDecl(Field); @@ -11725,9 +11728,9 @@ static ExprResult addAsFieldToClosureType(Sema &S, // Build the non-static data member. FieldDecl *Field - = FieldDecl::Create(S.Context, Lambda, Loc, Loc, 0, FieldType, + = FieldDecl::Create(S.Context, Lambda, Loc, Loc, nullptr, FieldType, S.Context.getTrivialTypeSourceInfo(FieldType, Loc), - 0, false, ICIS_NoInit); + nullptr, false, ICIS_NoInit); Field->setImplicit(true); Field->setAccess(AS_private); Lambda->addDecl(Field); @@ -11765,7 +11768,7 @@ static ExprResult addAsFieldToClosureType(Sema &S, while (const ConstantArrayType *Array = S.Context.getAsConstantArrayType(BaseType)) { // Create the iteration variable for this array index. - IdentifierInfo *IterationVarName = 0; + IdentifierInfo *IterationVarName = nullptr; { SmallString<8> Str; llvm::raw_svector_ostream OS(Str); @@ -11913,7 +11916,7 @@ static bool captureInLambda(LambdaScopeInfo *LSI, } // Capture this variable in the lambda. - Expr *CopyExpr = 0; + Expr *CopyExpr = nullptr; if (BuildAndDiagnose) { ExprResult Result = addAsFieldToClosureType(S, LSI, Var, CaptureType, DeclRefType, Loc, @@ -12093,7 +12096,7 @@ bool Sema::tryCaptureVariable(VarDecl *Var, SourceLocation Loc, QualType DeclRefType; return tryCaptureVariable(Var, Loc, Kind, EllipsisLoc, /*BuildAndDiagnose=*/true, CaptureType, - DeclRefType, 0); + DeclRefType, nullptr); } QualType Sema::getCapturedDeclRefType(VarDecl *Var, SourceLocation Loc) { @@ -12103,7 +12106,7 @@ QualType Sema::getCapturedDeclRefType(VarDecl *Var, SourceLocation Loc) { // Determine whether we can capture this variable. if (tryCaptureVariable(Var, Loc, TryCapture_Implicit, SourceLocation(), /*BuildAndDiagnose=*/false, CaptureType, - DeclRefType, 0)) + DeclRefType, nullptr)) return QualType(); return DeclRefType; @@ -12120,7 +12123,7 @@ static inline bool IsVariableNonDependentAndAConstantExpression(VarDecl *Var, if (Var->getType()->isDependentType()) return false; - const VarDecl *DefVD = 0; + const VarDecl *DefVD = nullptr; Var->getAnyInitializer(DefVD); if (!DefVD) return false; @@ -12146,7 +12149,7 @@ void Sema::UpdateMarkingForLValueToRValue(Expr *E) { // variable. if (LambdaScopeInfo *LSI = getCurLambda()) { Expr *SansParensExpr = E->IgnoreParens(); - VarDecl *Var = 0; + VarDecl *Var = nullptr; if (DeclRefExpr *DRE = dyn_cast(SansParensExpr)) Var = dyn_cast(DRE->getFoundDecl()); else if (MemberExpr *ME = dyn_cast(SansParensExpr)) @@ -12185,7 +12188,8 @@ void Sema::CleanupVarDeclMarking() { llvm_unreachable("Unexpcted expression"); } - MarkVarDeclODRUsed(Var, Loc, *this, /*MaxFunctionScopeIndex Pointer*/ 0); + MarkVarDeclODRUsed(Var, Loc, *this, + /*MaxFunctionScopeIndex Pointer*/ nullptr); } MaybeODRUseExprs.clear(); @@ -12296,14 +12300,15 @@ static void DoMarkVarDeclReferenced(Sema &SemaRef, SourceLocation Loc, if (!Var->getType()->isReferenceType()) SemaRef.MaybeODRUseExprs.insert(E); } else - MarkVarDeclODRUsed(Var, Loc, SemaRef, /*MaxFunctionScopeIndex ptr*/0); + MarkVarDeclODRUsed(Var, Loc, SemaRef, + /*MaxFunctionScopeIndex ptr*/ nullptr); } /// \brief Mark a variable referenced, and check whether it is odr-used /// (C++ [basic.def.odr]p2, C99 6.9p3). Note that this should not be /// used directly for normal expressions referring to VarDecl. void Sema::MarkVariableReferenced(SourceLocation Loc, VarDecl *Var) { - DoMarkVarDeclReferenced(*this, Loc, Var, 0); + DoMarkVarDeclReferenced(*this, Loc, Var, nullptr); } static void MarkExprReferenced(Sema &SemaRef, SourceLocation Loc, diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index e4e9b14..e84f2f3 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -106,7 +106,7 @@ ParsedType Sema::getDestructorName(SourceLocation TildeLoc, // For this reason, we're currently only doing the C++03 version of this // code; the C++0x version has to wait until we get a proper spec. QualType SearchType; - DeclContext *LookupCtx = 0; + DeclContext *LookupCtx = nullptr; bool isDependent = false; bool LookInScope = false; @@ -143,7 +143,7 @@ ParsedType Sema::getDestructorName(SourceLocation TildeLoc, } // The second case from the C++03 rules quoted further above. - NestedNameSpecifier *Prefix = 0; + NestedNameSpecifier *Prefix = nullptr; if (AlreadySearched) { // Nothing left to do. } else if (LookAtPrefix && (Prefix = NNS->getPrefix())) { @@ -177,7 +177,7 @@ ParsedType Sema::getDestructorName(SourceLocation TildeLoc, LookInScope = true; } - TypeDecl *NonMatchingTypeDecl = 0; + TypeDecl *NonMatchingTypeDecl = nullptr; LookupResult Found(*this, &II, NameLoc, LookupOrdinaryName); for (unsigned Step = 0; Step != 2; ++Step) { // Look for the name first in the computed lookup context (if we @@ -470,7 +470,7 @@ Sema::ActOnCXXTypeid(SourceLocation OpLoc, SourceLocation LParenLoc, if (isType) { // The operand is a type; handle it as such. - TypeSourceInfo *TInfo = 0; + TypeSourceInfo *TInfo = nullptr; QualType T = GetTypeFromParser(ParsedType::getFromOpaquePtr(TyOrExpr), &TInfo); if (T.isNull()) @@ -546,7 +546,7 @@ Sema::ActOnCXXUuidof(SourceLocation OpLoc, SourceLocation LParenLoc, if (isType) { // The operand is a type; handle it as such. - TypeSourceInfo *TInfo = 0; + TypeSourceInfo *TInfo = nullptr; QualType T = GetTypeFromParser(ParsedType::getFromOpaquePtr(TyOrExpr), &TInfo); if (T.isNull()) @@ -685,13 +685,13 @@ ExprResult Sema::CheckCXXThrowOperand(SourceLocation ThrowLoc, Expr *E, // operation from the operand to the exception object (15.1) can be // omitted by constructing the automatic object directly into the // exception object - const VarDecl *NRVOVariable = 0; + const VarDecl *NRVOVariable = nullptr; if (IsThrownVarInScope) NRVOVariable = getCopyElisionCandidate(QualType(), E, false); - + InitializedEntity Entity = InitializedEntity::InitializeException(ThrowLoc, E->getType(), - /*NRVO=*/NRVOVariable != 0); + /*NRVO=*/NRVOVariable != nullptr); Res = PerformMoveOrCopyInitialization(Entity, NRVOVariable, QualType(), E, IsThrownVarInScope); @@ -748,8 +748,8 @@ Sema::CXXThisScopeRAII::CXXThisScopeRAII(Sema &S, { if (!Enabled || !ContextDecl) return; - - CXXRecordDecl *Record = 0; + + CXXRecordDecl *Record = nullptr; if (ClassTemplateDecl *Template = dyn_cast(ContextDecl)) Record = Template->getTemplatedDecl(); else @@ -772,9 +772,9 @@ Sema::CXXThisScopeRAII::~CXXThisScopeRAII() { static Expr *captureThis(ASTContext &Context, RecordDecl *RD, QualType ThisTy, SourceLocation Loc) { FieldDecl *Field - = FieldDecl::Create(Context, RD, Loc, Loc, 0, ThisTy, + = FieldDecl::Create(Context, RD, Loc, Loc, nullptr, ThisTy, Context.getTrivialTypeSourceInfo(ThisTy, Loc), - 0, false, ICIS_NoInit); + nullptr, false, ICIS_NoInit); Field->setImplicit(true); Field->setAccess(AS_private); RD->addDecl(Field); @@ -829,7 +829,7 @@ bool Sema::CheckCXXThisCapture(SourceLocation Loc, bool Explicit, for (unsigned idx = MaxFunctionScopesIndex; NumClosures; --idx, --NumClosures) { CapturingScopeInfo *CSI = cast(FunctionScopes[idx]); - Expr *ThisExpr = 0; + Expr *ThisExpr = nullptr; QualType ThisTy = getCurrentThisType(); if (LambdaScopeInfo *LSI = dyn_cast(CSI)) // For lambda expressions, build a field and an initializing expression. @@ -958,7 +958,7 @@ Sema::BuildCXXTypeConstructExpr(TypeSourceInfo *TInfo, QualType ResultType = Result.get()->getType(); Result = Owned(CXXFunctionalCastExpr::Create( Context, ResultType, Expr::getValueKindForType(TInfo->getType()), TInfo, - CK_NoOp, Result.take(), /*Path=*/ 0, LParenLoc, RParenLoc)); + CK_NoOp, Result.take(), /*Path=*/ nullptr, LParenLoc, RParenLoc)); } // FIXME: Improve AST representation? @@ -1044,7 +1044,7 @@ Sema::ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal, Declarator &D, Expr *Initializer) { bool TypeContainsAuto = D.getDeclSpec().containsPlaceholderType(); - Expr *ArraySize = 0; + Expr *ArraySize = nullptr; // If the specified type is an array, unwrap it and save the expression. if (D.getNumTypeObjects() > 0 && D.getTypeObject(0).Kind == DeclaratorChunk::Array) { @@ -1085,7 +1085,7 @@ Sema::ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal, .take(); } else { Array.NumElts - = VerifyIntegerConstantExpression(NumElts, 0, + = VerifyIntegerConstantExpression(NumElts, nullptr, diag::err_new_array_nonconst) .take(); } @@ -1096,7 +1096,7 @@ Sema::ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal, } } - TypeSourceInfo *TInfo = GetTypeForDeclarator(D, /*Scope=*/0); + TypeSourceInfo *TInfo = GetTypeForDeclarator(D, /*Scope=*/nullptr); QualType AllocType = TInfo->getType(); if (D.isInvalidType()) return ExprError(); @@ -1223,7 +1223,8 @@ Sema::BuildCXXNew(SourceRange Range, bool UseGlobal, if (CheckAllocatedType(AllocType, TypeRange.getBegin(), TypeRange)) return ExprError(); - if (initStyle == CXXNewExpr::ListInit && isStdInitializerList(AllocType, 0)) { + if (initStyle == CXXNewExpr::ListInit && + isStdInitializerList(AllocType, nullptr)) { Diag(AllocTypeInfo->getTypeLoc().getBeginLoc(), diag::warn_dangling_std_initializer_list) << /*at end of FE*/0 << Inits[0]->getSourceRange(); @@ -1387,8 +1388,8 @@ Sema::BuildCXXNew(SourceRange Range, bool UseGlobal, // be signed, larger than size_t, whatever. } - FunctionDecl *OperatorNew = 0; - FunctionDecl *OperatorDelete = 0; + FunctionDecl *OperatorNew = nullptr; + FunctionDecl *OperatorDelete = nullptr; if (!AllocType->isDependentType() && !Expr::hasAnyTypeDependentArguments(PlacementArgs) && @@ -1676,7 +1677,7 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, // We don't need an operator delete if we're running under // -fno-exceptions. if (!getLangOpts().Exceptions) { - OperatorDelete = 0; + OperatorDelete = nullptr; return false; } @@ -1747,13 +1748,14 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, for (LookupResult::iterator D = FoundDelete.begin(), DEnd = FoundDelete.end(); D != DEnd; ++D) { - FunctionDecl *Fn = 0; + FunctionDecl *Fn = nullptr; if (FunctionTemplateDecl *FnTmpl = dyn_cast((*D)->getUnderlyingDecl())) { // Perform template argument deduction to try to match the // expected function type. TemplateDeductionInfo Info(StartLoc); - if (DeduceTemplateArguments(FnTmpl, 0, ExpectedFunctionType, Fn, Info)) + if (DeduceTemplateArguments(FnTmpl, nullptr, ExpectedFunctionType, Fn, + Info)) continue; } else Fn = cast((*D)->getUnderlyingDecl()); @@ -1867,7 +1869,7 @@ bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, if (FunctionTemplateDecl *FnTemplate = dyn_cast(D)) { AddTemplateOverloadCandidate(FnTemplate, Alloc.getPair(), - /*ExplicitTemplateArgs=*/0, + /*ExplicitTemplateArgs=*/nullptr, Args, Candidates, /*SuppressUserConversions=*/false); continue; @@ -1988,7 +1990,7 @@ void Sema::DeclareGlobalNewDelete() { getOrCreateStdNamespace(), SourceLocation(), SourceLocation(), &PP.getIdentifierTable().get("bad_alloc"), - 0); + nullptr); getStdBadAlloc()->setImplicit(true); } @@ -2086,7 +2088,7 @@ void Sema::DeclareGlobalAllocationFunction(DeclarationName Name, FunctionDecl *Alloc = FunctionDecl::Create(Context, GlobalCtx, SourceLocation(), SourceLocation(), Name, - FnType, /*TInfo=*/0, SC_None, false, true); + FnType, /*TInfo=*/nullptr, SC_None, false, true); Alloc->setImplicit(); if (AddMallocAttr) @@ -2095,9 +2097,9 @@ void Sema::DeclareGlobalAllocationFunction(DeclarationName Name, ParmVarDecl *ParamDecls[2]; for (unsigned I = 0; I != NumParams; ++I) { ParamDecls[I] = ParmVarDecl::Create(Context, Alloc, SourceLocation(), - SourceLocation(), 0, - Params[I], /*TInfo=*/0, - SC_None, 0); + SourceLocation(), nullptr, + Params[I], /*TInfo=*/nullptr, + SC_None, nullptr); ParamDecls[I]->setImplicit(); } Alloc->setParams(ArrayRef(ParamDecls, NumParams)); @@ -2221,7 +2223,7 @@ bool Sema::FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD, return true; } - Operator = 0; + Operator = nullptr; return false; } @@ -2240,7 +2242,7 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, // DR599 amends "pointer type" to "pointer to object type" in both cases. ExprResult Ex = Owned(ExE); - FunctionDecl *OperatorDelete = 0; + FunctionDecl *OperatorDelete = nullptr; bool ArrayFormAsWritten = ArrayForm; bool UsualArrayDeleteWantsSize = false; @@ -2322,7 +2324,7 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, diag::err_address_space_qualified_delete) << Pointee.getUnqualifiedType() << AddressSpace; - CXXRecordDecl *PointeeRD = 0; + CXXRecordDecl *PointeeRD = nullptr; if (Pointee->isVoidType() && !isSFINAEContext()) { // The C++ standard bans deleting a pointer to a non-object type, which // effectively bans deletion of "void*". However, most compilers support @@ -2578,10 +2580,10 @@ static ExprResult BuildCXXCastArgument(Sema &S, Result = S.Owned(ImplicitCastExpr::Create(S.Context, Result.get()->getType(), CK_UserDefinedConversion, - Result.get(), 0, + Result.get(), nullptr, Result.get()->getValueKind())); - S.CheckMemberOperatorAccess(CastLoc, From, /*arg*/ 0, FoundDecl); + S.CheckMemberOperatorAccess(CastLoc, From, /*arg*/ nullptr, FoundDecl); return S.MaybeBindToTemporary(Result.get()); } @@ -2762,13 +2764,13 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType, case ICK_Array_To_Pointer: FromType = Context.getArrayDecayedType(FromType); From = ImpCastExprToType(From, FromType, CK_ArrayToPointerDecay, - VK_RValue, /*BasePath=*/0, CCK).take(); + VK_RValue, /*BasePath=*/nullptr, CCK).take(); break; case ICK_Function_To_Pointer: FromType = Context.getPointerType(FromType); From = ImpCastExprToType(From, FromType, CK_FunctionToPointerDecay, - VK_RValue, /*BasePath=*/0, CCK).take(); + VK_RValue, /*BasePath=*/nullptr, CCK).take(); break; default: @@ -2792,7 +2794,7 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType, return ExprError(); From = ImpCastExprToType(From, ToType, CK_NoOp, - VK_RValue, /*BasePath=*/0, CCK).take(); + VK_RValue, /*BasePath=*/nullptr, CCK).take(); break; case ICK_Integral_Promotion: @@ -2802,17 +2804,17 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType, SCS.Second == ICK_Integral_Promotion && "only enums with fixed underlying type can promote to bool"); From = ImpCastExprToType(From, ToType, CK_IntegralToBoolean, - VK_RValue, /*BasePath=*/0, CCK).take(); + VK_RValue, /*BasePath=*/nullptr, CCK).take(); } else { From = ImpCastExprToType(From, ToType, CK_IntegralCast, - VK_RValue, /*BasePath=*/0, CCK).take(); + VK_RValue, /*BasePath=*/nullptr, CCK).take(); } break; case ICK_Floating_Promotion: case ICK_Floating_Conversion: From = ImpCastExprToType(From, ToType, CK_FloatingCast, - VK_RValue, /*BasePath=*/0, CCK).take(); + VK_RValue, /*BasePath=*/nullptr, CCK).take(); break; case ICK_Complex_Promotion: @@ -2831,22 +2833,22 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType, CK = CK_IntegralComplexCast; } From = ImpCastExprToType(From, ToType, CK, - VK_RValue, /*BasePath=*/0, CCK).take(); + VK_RValue, /*BasePath=*/nullptr, CCK).take(); break; } case ICK_Floating_Integral: if (ToType->isRealFloatingType()) From = ImpCastExprToType(From, ToType, CK_IntegralToFloating, - VK_RValue, /*BasePath=*/0, CCK).take(); + VK_RValue, /*BasePath=*/nullptr, CCK).take(); else From = ImpCastExprToType(From, ToType, CK_FloatingToIntegral, - VK_RValue, /*BasePath=*/0, CCK).take(); + VK_RValue, /*BasePath=*/nullptr, CCK).take(); break; case ICK_Compatible_Conversion: From = ImpCastExprToType(From, ToType, CK_NoOp, - VK_RValue, /*BasePath=*/0, CCK).take(); + VK_RValue, /*BasePath=*/nullptr, CCK).take(); break; case ICK_Writeback_Conversion: @@ -2921,7 +2923,7 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType, From = ImpCastExprToType(From, Context.BoolTy, ScalarTypeToBooleanCastKind(FromType), - VK_RValue, /*BasePath=*/0, CCK).take(); + VK_RValue, /*BasePath=*/nullptr, CCK).take(); break; case ICK_Derived_To_Base: { @@ -2942,12 +2944,12 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType, case ICK_Vector_Conversion: From = ImpCastExprToType(From, ToType, CK_BitCast, - VK_RValue, /*BasePath=*/0, CCK).take(); + VK_RValue, /*BasePath=*/nullptr, CCK).take(); break; case ICK_Vector_Splat: From = ImpCastExprToType(From, ToType, CK_VectorSplat, - VK_RValue, /*BasePath=*/0, CCK).take(); + VK_RValue, /*BasePath=*/nullptr, CCK).take(); break; case ICK_Complex_Real: @@ -2984,7 +2986,7 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType, From = ImpCastExprToType(From, ElType, isFloatingComplex ? CK_FloatingComplexToReal : CK_IntegralComplexToReal, - VK_RValue, /*BasePath=*/0, CCK).take(); + VK_RValue, /*BasePath=*/nullptr, CCK).take(); // x -> y if (Context.hasSameUnqualifiedType(ElType, ToType)) { @@ -2992,19 +2994,19 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType, } else if (ToType->isRealFloatingType()) { From = ImpCastExprToType(From, ToType, isFloatingComplex ? CK_FloatingCast : CK_IntegralToFloating, - VK_RValue, /*BasePath=*/0, CCK).take(); + VK_RValue, /*BasePath=*/nullptr, CCK).take(); } else { assert(ToType->isIntegerType()); From = ImpCastExprToType(From, ToType, isFloatingComplex ? CK_FloatingToIntegral : CK_IntegralCast, - VK_RValue, /*BasePath=*/0, CCK).take(); + VK_RValue, /*BasePath=*/nullptr, CCK).take(); } } break; case ICK_Block_Pointer_Conversion: { From = ImpCastExprToType(From, ToType.getUnqualifiedType(), CK_BitCast, - VK_RValue, /*BasePath=*/0, CCK).take(); + VK_RValue, /*BasePath=*/nullptr, CCK).take(); break; } @@ -3046,7 +3048,7 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType, ExprValueKind VK = ToType->isReferenceType() ? From->getValueKind() : VK_RValue; From = ImpCastExprToType(From, ToType.getNonLValueExprType(Context), - CK_NoOp, VK, /*BasePath=*/0, CCK).take(); + CK_NoOp, VK, /*BasePath=*/nullptr, CCK).take(); if (SCS.DeprecatedStringLiteralToCharPtr && !getLangOpts().WritableStrings) { @@ -3069,7 +3071,7 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType, assert(Context.hasSameType( ToAtomicType->castAs()->getValueType(), From->getType())); From = ImpCastExprToType(From, ToAtomicType, CK_NonAtomicToAtomic, - VK_RValue, 0, CCK).take(); + VK_RValue, nullptr, CCK).take(); } return Owned(From); @@ -3889,7 +3891,8 @@ static bool EvaluateBinaryTypeTrait(Sema &Self, TypeTrait BTT, QualType LhsT, EnterExpressionEvaluationContext Unevaluated(Self, Sema::Unevaluated); Sema::SFINAETrap SFINAE(Self, /*AccessCheckingSFINAE=*/true); Sema::ContextRAII TUContext(Self, Self.Context.getTranslationUnitDecl()); - ExprResult Result = Self.BuildBinOp(/*S=*/0, KeyLoc, BO_Assign, &Lhs, &Rhs); + ExprResult Result = Self.BuildBinOp(/*S=*/nullptr, KeyLoc, BO_Assign, &Lhs, + &Rhs); if (Result.isInvalid() || SFINAE.hasErrorOccurred()) return false; @@ -4577,7 +4580,8 @@ QualType Sema::CXXCheckConditionalOperands(ExprResult &Cond, ExprResult &LHS, // operand. The result is of the common type. bool NonStandardCompositeType = false; QualType Composite = FindCompositePointerType(QuestionLoc, LHS, RHS, - isSFINAEContext()? 0 : &NonStandardCompositeType); + isSFINAEContext() ? nullptr + : &NonStandardCompositeType); if (!Composite.isNull()) { if (NonStandardCompositeType) Diag(QuestionLoc, @@ -4701,7 +4705,7 @@ QualType Sema::FindCompositePointerType(SourceLocation Loc, QualifierUnion.push_back( Composite1.getCVRQualifiers() | Composite2.getCVRQualifiers()); - MemberOfClass.push_back(std::make_pair((const Type *)0, (const Type *)0)); + MemberOfClass.push_back(std::make_pair(nullptr, nullptr)); continue; } @@ -4890,7 +4894,7 @@ ExprResult Sema::MaybeBindToTemporary(Expr *E) { // actual method. FIXME: we should infer retention by selector in // cases where we don't have an actual method. } else { - ObjCMethodDecl *D = 0; + ObjCMethodDecl *D = nullptr; if (ObjCMessageExpr *Send = dyn_cast(E)) { D = Send->getMethodDecl(); } else if (ObjCBoxedExpr *BoxedExpr = dyn_cast(E)) { @@ -4920,7 +4924,7 @@ ExprResult Sema::MaybeBindToTemporary(Expr *E) { CastKind ck = (ReturnsRetained ? CK_ARCConsumeObject : CK_ARCReclaimReturnedObject); - return Owned(ImplicitCastExpr::Create(Context, E->getType(), ck, E, 0, + return Owned(ImplicitCastExpr::Create(Context, E->getType(), ck, E, nullptr, VK_RValue)); } @@ -4930,7 +4934,7 @@ ExprResult Sema::MaybeBindToTemporary(Expr *E) { // Search for the base element type (cf. ASTContext::getBaseElementType) with // a fast path for the common case that the type is directly a RecordType. const Type *T = Context.getCanonicalType(E->getType().getTypePtr()); - const RecordType *RT = 0; + const RecordType *RT = nullptr; while (!RT) { switch (T->getTypeClass()) { case Type::Record: @@ -4954,7 +4958,7 @@ ExprResult Sema::MaybeBindToTemporary(Expr *E) { return Owned(E); bool IsDecltype = ExprEvalContexts.back().IsDecltype; - CXXDestructorDecl *Destructor = IsDecltype ? 0 : LookupDestructor(RD); + CXXDestructorDecl *Destructor = IsDecltype ? nullptr : LookupDestructor(RD); if (Destructor) { MarkFunctionReferenced(E->getExprLoc(), Destructor); @@ -5072,11 +5076,12 @@ ExprResult Sema::ActOnDecltypeExpression(Expr *E) { } CXXBindTemporaryExpr *TopBind = dyn_cast(E); - CallExpr *TopCall = TopBind ? dyn_cast(TopBind->getSubExpr()) : 0; + CallExpr *TopCall = TopBind ? dyn_cast(TopBind->getSubExpr()) + : nullptr; if (TopCall) E = TopCall; else - TopBind = 0; + TopBind = nullptr; // Disable the special decltype handling now. ExprEvalContexts.back().IsDecltype = false; @@ -5214,7 +5219,7 @@ Sema::ActOnStartCXXMemberReference(Scope *S, Expr *Base, SourceLocation OpLoc, // separate note) instead of having the error reported back to here // and giving a diagnostic with a fixit attached to the error itself. (FirstIteration && CurFD && CurFD->isFunctionTemplateSpecialization()) - ? 0 + ? nullptr : &NoArrowOperatorFound); if (Result.isInvalid()) { if (NoArrowOperatorFound) { @@ -5228,7 +5233,7 @@ Sema::ActOnStartCXXMemberReference(Scope *S, Expr *Base, SourceLocation OpLoc, Diag(OpLoc, diag::err_typecheck_member_reference_arrow) << BaseType << Base->getSourceRange(); CallExpr *CE = dyn_cast(Base); - if (Decl *CD = (CE ? CE->getCalleeDecl() : 0)) { + if (Decl *CD = (CE ? CE->getCalleeDecl() : nullptr)) { Diag(CD->getLocStart(), diag::note_member_reference_arrow_from_operator_arrow); } @@ -5300,7 +5305,7 @@ ExprResult Sema::DiagnoseDtorReference(SourceLocation NameLoc, << isa(MemExpr) << FixItHint::CreateInsertion(ExpectedLParenLoc, "()"); - return ActOnCallExpr(/*Scope*/ 0, + return ActOnCallExpr(/*Scope*/ nullptr, MemExpr, /*LPLoc*/ ExpectedLParenLoc, None, @@ -5423,7 +5428,7 @@ ExprResult Sema::BuildPseudoDestructorExpr(Expr *Base, << ScopeTypeInfo->getTypeLoc().getLocalSourceRange(); ScopeType = QualType(); - ScopeTypeInfo = 0; + ScopeTypeInfo = nullptr; } } @@ -5475,7 +5480,7 @@ ExprResult Sema::ActOnPseudoDestructorExpr(Scope *S, Expr *Base, // Convert the name of the type being destructed (following the ~) into a // type (with source-location information). QualType DestructedType; - TypeSourceInfo *DestructedTypeInfo = 0; + TypeSourceInfo *DestructedTypeInfo = nullptr; PseudoDestructorTypeStorage Destructed; if (SecondTypeName.getKind() == UnqualifiedId::IK_Identifier) { ParsedType T = getTypeName(*SecondTypeName.Identifier, @@ -5530,7 +5535,7 @@ ExprResult Sema::ActOnPseudoDestructorExpr(Scope *S, Expr *Base, } // Convert the name of the scope type (the type prior to '::') into a type. - TypeSourceInfo *ScopeTypeInfo = 0; + TypeSourceInfo *ScopeTypeInfo = nullptr; QualType ScopeType; if (FirstTypeName.getKind() == UnqualifiedId::IK_TemplateId || FirstTypeName.Identifier) { @@ -5599,7 +5604,7 @@ ExprResult Sema::ActOnPseudoDestructorExpr(Scope *S, Expr *Base, PseudoDestructorTypeStorage Destructed(DestructedTypeInfo); return BuildPseudoDestructorExpr(Base, OpLoc, OpKind, CXXScopeSpec(), - 0, SourceLocation(), TildeLoc, + nullptr, SourceLocation(), TildeLoc, Destructed, HasTrailingLParen); } @@ -5632,9 +5637,8 @@ ExprResult Sema::BuildCXXMemberCallExpr(Expr *E, NamedDecl *FoundDecl, return Exp; } } - - ExprResult Exp = PerformObjectArgumentInitialization(E, /*Qualifier=*/0, + ExprResult Exp = PerformObjectArgumentInitialization(E, /*Qualifier=*/nullptr, FoundDecl, Method); if (Exp.isInvalid()) return true; @@ -5799,7 +5803,7 @@ ExprResult Sema::IgnoredValueConversions(Expr *E) { static inline bool VariableCanNeverBeAConstantExpression(VarDecl *Var, ASTContext &Context) { if (isa(Var)) return true; - const VarDecl *DefVD = 0; + const VarDecl *DefVD = nullptr; // If there is no initializer - this can not be a constant expression. if (!Var->getAnyInitializer(DefVD)) return true; @@ -5845,8 +5849,8 @@ static void CheckIfAnyEnclosingLambdasMustCaptureAnyPotentialCaptures( const unsigned NumPotentialCaptures = CurrentLSI->getNumPotentialVariableCaptures(); for (unsigned I = 0; I != NumPotentialCaptures; ++I) { - Expr *VarExpr = 0; - VarDecl *Var = 0; + Expr *VarExpr = nullptr; + VarDecl *Var = nullptr; CurrentLSI->getPotentialVariableCapture(I, Var, VarExpr); // If the variable is clearly identified as non-odr-used and the full // expression is not instantiation dependent, only then do we not @@ -5886,13 +5890,13 @@ static void CheckIfAnyEnclosingLambdasMustCaptureAnyPotentialCaptures( if (S.tryCaptureVariable(Var, ExprLoc, S.TryCapture_Implicit, /*EllipsisLoc*/ SourceLocation(), /*BuildAndDiagnose*/false, CaptureType, - DeclRefType, 0)) { + DeclRefType, nullptr)) { // We will never be able to capture this variable, and we need // to be able to in any and all instantiations, so diagnose it. S.tryCaptureVariable(Var, ExprLoc, S.TryCapture_Implicit, /*EllipsisLoc*/ SourceLocation(), /*BuildAndDiagnose*/true, CaptureType, - DeclRefType, 0); + DeclRefType, nullptr); } } } @@ -5903,7 +5907,7 @@ static void CheckIfAnyEnclosingLambdasMustCaptureAnyPotentialCaptures( // 'this' in that lambda (and all its enclosing lambdas). if (const Optional Index = getStackIndexOfNearestEnclosingCaptureCapableLambda( - FunctionScopesArrayRef, /*0 is 'this'*/ 0, S)) { + FunctionScopesArrayRef, /*0 is 'this'*/ nullptr, S)) { const unsigned FunctionScopeIndexOfCapturableLambda = Index.getValue(); S.CheckCXXThisCapture(CurrentLSI->PotentialThisCaptureLocation, /*Explicit*/ false, /*BuildAndDiagnose*/ true, diff --git a/clang/lib/Sema/SemaExprMember.cpp b/clang/lib/Sema/SemaExprMember.cpp index 95e3668..3442b81 100644 --- a/clang/lib/Sema/SemaExprMember.cpp +++ b/clang/lib/Sema/SemaExprMember.cpp @@ -206,7 +206,7 @@ static void diagnoseInstanceReference(Sema &SemaRef, DeclContext *FunctionLevelDC = SemaRef.getFunctionLevelDeclContext(); CXXMethodDecl *Method = dyn_cast(FunctionLevelDC); - CXXRecordDecl *ContextClass = Method ? Method->getParent() : 0; + CXXRecordDecl *ContextClass = Method ? Method->getParent() : nullptr; CXXRecordDecl *RepClass = dyn_cast(Rep->getDeclContext()); bool InStaticMethod = Method && Method->isStatic(); @@ -389,7 +389,7 @@ static Decl *FindGetterSetterNameDeclFromProtocolList(const ObjCProtocolDecl*PDe Context)) return D; } - return 0; + return nullptr; } static Decl *FindGetterSetterNameDecl(const ObjCObjectPointerType *QIdTy, @@ -397,7 +397,7 @@ static Decl *FindGetterSetterNameDecl(const ObjCObjectPointerType *QIdTy, const Selector &Sel, ASTContext &Context) { // Check protocols on qualified interfaces. - Decl *GDecl = 0; + Decl *GDecl = nullptr; for (const auto *I : QIdTy->quals()) { if (Member) if (ObjCPropertyDecl *PD = I->FindPropertyDeclaration(Member)) { @@ -590,7 +590,7 @@ LookupMemberExprInRecord(Sema &SemaRef, LookupResult &R, QualType ObjectType = SS.isSet() ? QualType() : QualType(RTy, 0); bool MOUS; - SemaRef.LookupTemplateName(R, 0, SS, ObjectType, false, MOUS); + SemaRef.LookupTemplateName(R, nullptr, SS, ObjectType, false, MOUS); return false; } @@ -626,7 +626,7 @@ LookupMemberExprInRecord(Sema &SemaRef, LookupResult &R, DeclarationName Name = R.getLookupName(); RecordMemberExprValidatorCCC Validator(RTy); TypoCorrection Corrected = SemaRef.CorrectTypo(R.getLookupNameInfo(), - R.getLookupKind(), NULL, + R.getLookupKind(), nullptr, &SS, Validator, Sema::CTK_ErrorRecovery, DC); R.clear(); @@ -643,7 +643,7 @@ LookupMemberExprInRecord(Sema &SemaRef, LookupResult &R, // information to do overload resolution, so we don't know which previous // declaration to point to. if (Corrected.isOverloaded()) - Corrected.setCorrectionDecl(0); + Corrected.setCorrectionDecl(nullptr); bool DroppedSpecifier = Corrected.WillReplaceSpecifier() && Name.getAsString() == Corrected.getAsString(SemaRef.getLangOpts()); @@ -678,7 +678,7 @@ Sema::BuildMemberReferenceExpr(Expr *Base, QualType BaseType, if (IsArrow) RecordTy = RecordTy->getAs()->getPointeeType(); if (LookupMemberExprInRecord(*this, R, SourceRange(), RecordTy->getAs(), - OpLoc, SS, TemplateArgs != 0)) + OpLoc, SS, TemplateArgs != nullptr)) return ExprError(); // Explicit member accesses. @@ -686,7 +686,7 @@ Sema::BuildMemberReferenceExpr(Expr *Base, QualType BaseType, ExprResult BaseResult = Owned(Base); ExprResult Result = LookupMemberExpr(R, BaseResult, IsArrow, OpLoc, - SS, /*ObjCImpDecl*/ 0, TemplateArgs != 0); + SS, /*ObjCImpDecl*/ nullptr, TemplateArgs != nullptr); if (BaseResult.isInvalid()) return ExprError(); @@ -842,16 +842,13 @@ BuildMSPropertyRefExpr(Sema &S, Expr *BaseExpr, bool IsArrow, } /// \brief Build a MemberExpr AST node. -static MemberExpr *BuildMemberExpr(Sema &SemaRef, - ASTContext &C, Expr *Base, bool isArrow, - const CXXScopeSpec &SS, - SourceLocation TemplateKWLoc, - ValueDecl *Member, - DeclAccessPair FoundDecl, - const DeclarationNameInfo &MemberNameInfo, - QualType Ty, - ExprValueKind VK, ExprObjectKind OK, - const TemplateArgumentListInfo *TemplateArgs = 0) { +static MemberExpr * +BuildMemberExpr(Sema &SemaRef, ASTContext &C, Expr *Base, bool isArrow, + const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, + ValueDecl *Member, DeclAccessPair FoundDecl, + const DeclarationNameInfo &MemberNameInfo, QualType Ty, + ExprValueKind VK, ExprObjectKind OK, + const TemplateArgumentListInfo *TemplateArgs = nullptr) { assert((!isArrow || Base->isRValue()) && "-> base must be a pointer rvalue"); MemberExpr *E = MemberExpr::Create(C, Base, isArrow, SS.getWithLocInContext(C), @@ -1222,7 +1219,7 @@ Sema::LookupMemberExpr(LookupResult &R, ExprResult &BaseExpr, // Returning valid-but-null is how we indicate to the caller that // the lookup result was filled in. - return Owned((Expr*) 0); + return Owned((Expr*) nullptr); } // Handle ivar access to Objective-C objects. @@ -1261,8 +1258,8 @@ Sema::LookupMemberExpr(LookupResult &R, ExprResult &BaseExpr, if (RequireCompleteType(OpLoc, BaseType, diag::err_typecheck_incomplete_tag, BaseExpr.get())) return ExprError(); - - ObjCInterfaceDecl *ClassDeclared = 0; + + ObjCInterfaceDecl *ClassDeclared = nullptr; ObjCIvarDecl *IV = IDecl->lookupInstanceVariable(Member, ClassDeclared); if (!IV) { @@ -1270,9 +1267,9 @@ Sema::LookupMemberExpr(LookupResult &R, ExprResult &BaseExpr, DeclFilterCCC Validator; Validator.IsObjCIvarLookup = IsArrow; if (TypoCorrection Corrected = CorrectTypo(R.getLookupNameInfo(), - LookupMemberName, NULL, NULL, - Validator, CTK_ErrorRecovery, - IDecl)) { + LookupMemberName, nullptr, + nullptr, Validator, + CTK_ErrorRecovery, IDecl)) { IV = Corrected.getCorrectionDeclAs(); diagnoseTypo(Corrected, PDiag(diag::err_typecheck_member_reference_ivar_suggest) @@ -1313,7 +1310,7 @@ Sema::LookupMemberExpr(LookupResult &R, ExprResult &BaseExpr, return ExprError(); if (IV->getAccessControl() != ObjCIvarDecl::Public && IV->getAccessControl() != ObjCIvarDecl::Package) { - ObjCInterfaceDecl *ClassOfMethodDecl = 0; + ObjCInterfaceDecl *ClassOfMethodDecl = nullptr; if (ObjCMethodDecl *MD = getCurMethodDecl()) ClassOfMethodDecl = MD->getClassInterface(); else if (ObjCImpDecl && getCurFunctionDecl()) { @@ -1431,8 +1428,9 @@ Sema::LookupMemberExpr(LookupResult &R, ExprResult &BaseExpr, SelectorTable::constructSetterSelector(PP.getIdentifierTable(), PP.getSelectorTable(), Member); - ObjCMethodDecl *SMD = 0; - if (Decl *SDecl = FindGetterSetterNameDecl(OPT, /*Property id*/0, + ObjCMethodDecl *SMD = nullptr; + if (Decl *SDecl = FindGetterSetterNameDecl(OPT, + /*Property id*/nullptr, SetterSel, Context)) SMD = dyn_cast(SDecl); @@ -1622,7 +1620,7 @@ ExprResult Sema::ActOnMemberAccessExpr(Scope *S, Expr *Base, bool IsArrow = (OpKind == tok::arrow); NamedDecl *FirstQualifierInScope - = (!SS.isSet() ? 0 : FindFirstQualifierInScope(S, SS.getScopeRep())); + = (!SS.isSet() ? nullptr : FindFirstQualifierInScope(S, SS.getScopeRep())); // This is a postfix expression, so get rid of ParenListExprs. ExprResult Result = MaybeConvertParenListExprToParenExpr(S, Base); @@ -1639,7 +1637,7 @@ ExprResult Sema::ActOnMemberAccessExpr(Scope *S, Expr *Base, LookupResult R(*this, NameInfo, LookupMemberName); ExprResult BaseResult = Owned(Base); Result = LookupMemberExpr(R, BaseResult, IsArrow, OpLoc, - SS, ObjCImpDecl, TemplateArgs != 0); + SS, ObjCImpDecl, TemplateArgs != nullptr); if (BaseResult.isInvalid()) return ExprError(); Base = BaseResult.take(); @@ -1752,8 +1750,8 @@ Sema::BuildImplicitMemberExpr(const CXXScopeSpec &SS, // 'this' expression now. QualType ThisTy = getCurrentThisType(); assert(!ThisTy.isNull() && "didn't correctly pre-flight capture of 'this'"); - - Expr *baseExpr = 0; // null signifies implicit access + + Expr *baseExpr = nullptr; // null signifies implicit access if (IsKnownInstance) { SourceLocation Loc = R.getNameLoc(); if (SS.getRange().isValid()) @@ -1761,11 +1759,11 @@ Sema::BuildImplicitMemberExpr(const CXXScopeSpec &SS, CheckCXXThisCapture(Loc); baseExpr = new (Context) CXXThisExpr(loc, ThisTy, /*isImplicit=*/true); } - + return BuildMemberReferenceExpr(baseExpr, ThisTy, /*OpLoc*/ SourceLocation(), /*IsArrow*/ true, SS, TemplateKWLoc, - /*FirstQualifierInScope*/ 0, + /*FirstQualifierInScope*/ nullptr, R, TemplateArgs); } diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp index bf8af29..d9e2828 100644 --- a/clang/lib/Sema/SemaExprObjC.cpp +++ b/clang/lib/Sema/SemaExprObjC.cpp @@ -93,7 +93,7 @@ ExprResult Sema::BuildObjCStringLiteral(SourceLocation AtLoc, StringLiteral *S){ if (!Ty.isNull()) { Ty = Context.getObjCObjectPointerType(Ty); } else if (getLangOpts().NoConstantCFStrings) { - IdentifierInfo *NSIdent=0; + IdentifierInfo *NSIdent=nullptr; std::string StringClass(getLangOpts().ObjCConstantStringClass); if (StringClass.empty()) @@ -133,7 +133,7 @@ ExprResult Sema::BuildObjCStringLiteral(SourceLocation AtLoc, StringLiteral *S){ ObjCInterfaceDecl::Create (Context, Context.getTranslationUnitDecl(), SourceLocation(), NSIdent, - 0, SourceLocation()); + nullptr, SourceLocation()); Ty = Context.getObjCInterfaceType(NSStringIDecl); Context.setObjCNSStringType(Ty); } @@ -182,7 +182,7 @@ static ObjCMethodDecl *getNSNumberFactoryMethod(Sema &S, SourceLocation Loc, S.Diag(Loc, diag::err_invalid_nsnumber_type) << NumberType << R; } - return 0; + return nullptr; } // If we already looked up this method, we're done. @@ -208,15 +208,15 @@ static ObjCMethodDecl *getNSNumberFactoryMethod(Sema &S, SourceLocation Loc, S.NSNumberDecl = ObjCInterfaceDecl::Create(CX, CX.getTranslationUnitDecl(), SourceLocation(), NSNumberId, - 0, SourceLocation()); + nullptr, SourceLocation()); } else { // Otherwise, require a declaration of NSNumber. S.Diag(Loc, diag::err_undeclared_nsnumber); - return 0; + return nullptr; } } else if (!S.NSNumberDecl->hasDefinition()) { S.Diag(Loc, diag::err_undeclared_nsnumber); - return 0; + return nullptr; } // generate the pointer to NSNumber type. @@ -228,7 +228,7 @@ static ObjCMethodDecl *getNSNumberFactoryMethod(Sema &S, SourceLocation Loc, ObjCMethodDecl *Method = S.NSNumberDecl->lookupClassMethod(Sel); if (!Method && S.getLangOpts().DebuggerObjCLiteral) { // create a stub definition this NSNumber factory method. - TypeSourceInfo *ReturnTInfo = 0; + TypeSourceInfo *ReturnTInfo = nullptr; Method = ObjCMethodDecl::Create(CX, SourceLocation(), SourceLocation(), Sel, S.NSNumberPointer, ReturnTInfo, S.NSNumberDecl, @@ -240,13 +240,13 @@ static ObjCMethodDecl *getNSNumberFactoryMethod(Sema &S, SourceLocation Loc, ParmVarDecl *value = ParmVarDecl::Create(S.Context, Method, SourceLocation(), SourceLocation(), &CX.Idents.get("value"), - NumberType, /*TInfo=*/0, SC_None, - 0); + NumberType, /*TInfo=*/nullptr, + SC_None, nullptr); Method->setMethodParams(S.Context, value, None); } if (!validateBoxingMethod(S, Loc, S.NSNumberDecl, Sel, Method)) - return 0; + return nullptr; // Note: if the parameter type is out-of-line, we'll catch it later in the // implicit conversion. @@ -444,10 +444,10 @@ static ExprResult CheckObjCCollectionLiteralElement(Sema &S, Expr *Element, ExprResult Sema::BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr) { if (ValueExpr->isTypeDependent()) { ObjCBoxedExpr *BoxedExpr = - new (Context) ObjCBoxedExpr(ValueExpr, Context.DependentTy, NULL, SR); + new (Context) ObjCBoxedExpr(ValueExpr, Context.DependentTy, nullptr, SR); return Owned(BoxedExpr); } - ObjCMethodDecl *BoxingMethod = NULL; + ObjCMethodDecl *BoxingMethod = nullptr; QualType BoxedType; // Convert the expression to an RValue, so we can check for pointer types... ExprResult RValue = DefaultFunctionArrayLvalueConversion(ValueExpr); @@ -473,7 +473,7 @@ ExprResult Sema::BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr) { NSStringDecl = ObjCInterfaceDecl::Create(Context, TU, SourceLocation(), NSStringId, - 0, SourceLocation()); + nullptr, SourceLocation()); } else { Diag(SR.getBegin(), diag::err_undeclared_nsstring); return ExprError(); @@ -495,7 +495,7 @@ ExprResult Sema::BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr) { BoxingMethod = NSStringDecl->lookupClassMethod(stringWithUTF8String); if (!BoxingMethod && getLangOpts().DebuggerObjCLiteral) { // Debugger needs to work even if NSString hasn't been defined. - TypeSourceInfo *ReturnTInfo = 0; + TypeSourceInfo *ReturnTInfo = nullptr; ObjCMethodDecl *M = ObjCMethodDecl::Create( Context, SourceLocation(), SourceLocation(), stringWithUTF8String, NSStringPointer, ReturnTInfo, NSStringDecl, @@ -510,8 +510,8 @@ ExprResult Sema::BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr) { SourceLocation(), SourceLocation(), &Context.Idents.get("value"), Context.getPointerType(ConstCharType), - /*TInfo=*/0, - SC_None, 0); + /*TInfo=*/nullptr, + SC_None, nullptr); M->setMethodParams(Context, value, None); BoxingMethod = M; } @@ -646,7 +646,7 @@ ExprResult Sema::BuildObjCArrayLiteral(SourceRange SR, MultiExprArg Elements) { Context.getTranslationUnitDecl(), SourceLocation(), NSAPIObj->getNSClassId(NSAPI::ClassId_NSArray), - 0, SourceLocation()); + nullptr, SourceLocation()); if (!NSArrayDecl) { Diag(SR.getBegin(), diag::err_undeclared_nsarray); @@ -661,7 +661,7 @@ ExprResult Sema::BuildObjCArrayLiteral(SourceRange SR, MultiExprArg Elements) { Sel = NSAPIObj->getNSArraySelector(NSAPI::NSArr_arrayWithObjectsCount); ObjCMethodDecl *Method = NSArrayDecl->lookupClassMethod(Sel); if (!Method && getLangOpts().DebuggerObjCLiteral) { - TypeSourceInfo *ReturnTInfo = 0; + TypeSourceInfo *ReturnTInfo = nullptr; Method = ObjCMethodDecl::Create( Context, SourceLocation(), SourceLocation(), Sel, IdT, ReturnTInfo, Context.getTranslationUnitDecl(), false /*Instance*/, @@ -675,14 +675,16 @@ ExprResult Sema::BuildObjCArrayLiteral(SourceRange SR, MultiExprArg Elements) { SourceLocation(), &Context.Idents.get("objects"), Context.getPointerType(IdT), - /*TInfo=*/0, SC_None, 0); + /*TInfo=*/nullptr, + SC_None, nullptr); Params.push_back(objects); ParmVarDecl *cnt = ParmVarDecl::Create(Context, Method, SourceLocation(), SourceLocation(), &Context.Idents.get("cnt"), Context.UnsignedLongTy, - /*TInfo=*/0, SC_None, 0); + /*TInfo=*/nullptr, SC_None, + nullptr); Params.push_back(cnt); Method->setMethodParams(Context, Params, None); } @@ -759,7 +761,7 @@ ExprResult Sema::BuildObjCDictionaryLiteral(SourceRange SR, Context.getTranslationUnitDecl(), SourceLocation(), NSAPIObj->getNSClassId(NSAPI::ClassId_NSDictionary), - 0, SourceLocation()); + nullptr, SourceLocation()); if (!NSDictionaryDecl) { Diag(SR.getBegin(), diag::err_undeclared_nsdictionary); @@ -778,7 +780,7 @@ ExprResult Sema::BuildObjCDictionaryLiteral(SourceRange SR, Method = ObjCMethodDecl::Create(Context, SourceLocation(), SourceLocation(), Sel, IdT, - 0 /*TypeSourceInfo */, + nullptr /*TypeSourceInfo */, Context.getTranslationUnitDecl(), false /*Instance*/, false/*isVariadic*/, /*isPropertyAccessor=*/false, @@ -791,21 +793,24 @@ ExprResult Sema::BuildObjCDictionaryLiteral(SourceRange SR, SourceLocation(), &Context.Idents.get("objects"), Context.getPointerType(IdT), - /*TInfo=*/0, SC_None, 0); + /*TInfo=*/nullptr, SC_None, + nullptr); Params.push_back(objects); ParmVarDecl *keys = ParmVarDecl::Create(Context, Method, SourceLocation(), SourceLocation(), &Context.Idents.get("keys"), Context.getPointerType(IdT), - /*TInfo=*/0, SC_None, 0); + /*TInfo=*/nullptr, SC_None, + nullptr); Params.push_back(keys); ParmVarDecl *cnt = ParmVarDecl::Create(Context, Method, SourceLocation(), SourceLocation(), &Context.Idents.get("cnt"), Context.UnsignedLongTy, - /*TInfo=*/0, SC_None, 0); + /*TInfo=*/nullptr, SC_None, + nullptr); Params.push_back(cnt); Method->setMethodParams(Context, Params, None); } @@ -1115,7 +1120,7 @@ ObjCMethodDecl *Sema::tryCaptureObjCSelf(SourceLocation Loc) { // still have a 'self', and we really do still need to capture it! ObjCMethodDecl *method = dyn_cast(DC); if (!method) - return 0; + return nullptr; tryCaptureVariable(method->getSelfDecl(), Loc); @@ -1200,7 +1205,7 @@ findExplicitInstancetypeDeclarer(const ObjCMethodDecl *MD, return result; } - return 0; + return nullptr; } void Sema::EmitRelatedResultTypeNoteForReturn(QualType destType) { @@ -1407,7 +1412,7 @@ bool Sema::CheckMessageArgumentTypes(QualType ReceiverType, continue; ExprResult Arg = DefaultVariadicArgumentPromotion(Args[i], VariadicMethod, - 0); + nullptr); IsError |= Arg.isInvalid(); Args[i] = Arg.take(); } @@ -1469,7 +1474,7 @@ ObjCMethodDecl *Sema::LookupMethodInObjectType(Selector sel, QualType type, if (ObjCMethodDecl *method = I->lookupMethod(sel, isInstance)) return method; - return 0; + return nullptr; } /// LookupMethodInQualifiedType - Lookups up a method in protocol qualifier @@ -1478,13 +1483,13 @@ ObjCMethodDecl *Sema::LookupMethodInQualifiedType(Selector Sel, const ObjCObjectPointerType *OPT, bool Instance) { - ObjCMethodDecl *MD = 0; + ObjCMethodDecl *MD = nullptr; for (const auto *PROTO : OPT->quals()) { if ((MD = PROTO->lookupMethod(Sel, Instance))) { return MD; } } - return 0; + return nullptr; } static void DiagnoseARCUseOfWeakReceiver(Sema &S, Expr *Receiver) { @@ -1497,8 +1502,8 @@ static void DiagnoseARCUseOfWeakReceiver(Sema &S, Expr *Receiver) { Expr *RExpr = Receiver->IgnoreParenImpCasts(); SourceLocation Loc = RExpr->getLocStart(); QualType T = RExpr->getType(); - const ObjCPropertyDecl *PDecl = 0; - const ObjCMethodDecl *GDecl = 0; + const ObjCPropertyDecl *PDecl = nullptr; + const ObjCMethodDecl *GDecl = nullptr; if (PseudoObjectExpr *POE = dyn_cast(RExpr)) { RExpr = POE->getSyntacticForm(); if (ObjCPropertyRefExpr *PRE = dyn_cast(RExpr)) { @@ -1669,8 +1674,8 @@ HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT, // Attempt to correct for typos in property names. DeclFilterCCC Validator; if (TypoCorrection Corrected = CorrectTypo( - DeclarationNameInfo(MemberName, MemberLoc), LookupOrdinaryName, NULL, - NULL, Validator, CTK_ErrorRecovery, IFace, false, OPT)) { + DeclarationNameInfo(MemberName, MemberLoc), LookupOrdinaryName, + nullptr, nullptr, Validator, CTK_ErrorRecovery, IFace, false, OPT)) { diagnoseTypo(Corrected, PDiag(diag::err_property_not_found_suggest) << MemberName << QualType(OPT, 0)); DeclarationName TypoResult = Corrected.getCorrection(); @@ -1717,7 +1722,7 @@ ActOnClassPropertyRefExpr(IdentifierInfo &receiverName, receiverNameLoc); bool IsSuper = false; - if (IFace == 0) { + if (!IFace) { // If the "receiver" is 'super' in a method, handle it as an expression-like // property reference. if (receiverNamePtr->isStr("super")) { @@ -1735,9 +1740,9 @@ ActOnClassPropertyRefExpr(IdentifierInfo &receiverName, } QualType T = Context.getObjCInterfaceType(Super); T = Context.getObjCObjectPointerType(T); - + return HandleExprPropertyRefExpr(T->getAsObjCInterfacePointerType(), - /*BaseExpr*/0, + /*BaseExpr*/nullptr, SourceLocation()/*OpLoc*/, &propertyName, propertyNameLoc, @@ -1749,8 +1754,8 @@ ActOnClassPropertyRefExpr(IdentifierInfo &receiverName, IFace = CurMethod->getClassInterface()->getSuperClass(); } } - - if (IFace == 0) { + + if (!IFace) { Diag(receiverNameLoc, diag::err_expected_either) << tok::identifier << tok::l_paren; return ExprError(); @@ -1902,8 +1907,8 @@ Sema::ObjCMessageKind Sema::getObjCMessageKind(Scope *S, ObjCInterfaceOrSuperCCC Validator(getCurMethodDecl()); if (TypoCorrection Corrected = CorrectTypo(Result.getLookupNameInfo(), Result.getLookupKind(), S, - NULL, Validator, CTK_ErrorRecovery, NULL, false, NULL, - false)) { + nullptr, Validator, CTK_ErrorRecovery, nullptr, false, + nullptr, false)) { if (Corrected.isKeyword()) { // If we've found the keyword "super" (the only keyword that would be // returned by CorrectTypo), this is a send to super. @@ -1966,16 +1971,16 @@ ExprResult Sema::ActOnSuperMessage(Scope *S, // message to the superclass instance. QualType SuperTy = Context.getObjCInterfaceType(Super); SuperTy = Context.getObjCObjectPointerType(SuperTy); - return BuildInstanceMessage(0, SuperTy, SuperLoc, - Sel, /*Method=*/0, + return BuildInstanceMessage(nullptr, SuperTy, SuperLoc, + Sel, /*Method=*/nullptr, LBracLoc, SelectorLocs, RBracLoc, Args); } // Since we are in a class method, this is a class message to // the superclass. - return BuildClassMessage(/*ReceiverTypeInfo=*/0, + return BuildClassMessage(/*ReceiverTypeInfo=*/nullptr, Context.getObjCInterfaceType(Super), - SuperLoc, Sel, /*Method=*/0, + SuperLoc, Sel, /*Method=*/nullptr, LBracLoc, SelectorLocs, RBracLoc, Args); } @@ -1986,7 +1991,7 @@ ExprResult Sema::BuildClassMessageImplicit(QualType ReceiverType, Selector Sel, ObjCMethodDecl *Method, MultiExprArg Args) { - TypeSourceInfo *receiverTypeInfo = 0; + TypeSourceInfo *receiverTypeInfo = nullptr; if (!ReceiverType.isNull()) receiverTypeInfo = Context.getTrivialTypeSourceInfo(ReceiverType); @@ -2100,13 +2105,13 @@ ExprResult Sema::BuildClassMessage(TypeSourceInfo *ReceiverTypeInfo, assert(SuperLoc.isInvalid() && "Message to super with dependent type"); return Owned(ObjCMessageExpr::Create(Context, ReceiverType, VK_RValue, LBracLoc, ReceiverTypeInfo, - Sel, SelectorLocs, /*Method=*/0, + Sel, SelectorLocs, /*Method=*/nullptr, makeArrayRef(Args, NumArgs),RBracLoc, isImplicit)); } // Find the class to which we are sending this message. - ObjCInterfaceDecl *Class = 0; + ObjCInterfaceDecl *Class = nullptr; const ObjCObjectType *ClassType = ReceiverType->getAs(); if (!ClassType || !(Class = ClassType->getInterface())) { Diag(Loc, diag::err_invalid_receiver_class_message) @@ -2202,8 +2207,9 @@ ExprResult Sema::ActOnClassMessage(Scope *S, ReceiverTypeInfo = Context.getTrivialTypeSourceInfo(ReceiverType, LBracLoc); return BuildClassMessage(ReceiverTypeInfo, ReceiverType, - /*SuperLoc=*/SourceLocation(), Sel, /*Method=*/0, - LBracLoc, SelectorLocs, RBracLoc, Args); + /*SuperLoc=*/SourceLocation(), Sel, + /*Method=*/nullptr, LBracLoc, SelectorLocs, RBracLoc, + Args); } ExprResult Sema::BuildInstanceMessageImplicit(Expr *Receiver, @@ -2293,7 +2299,7 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver, assert(SuperLoc.isInvalid() && "Message to super with dependent type"); return Owned(ObjCMessageExpr::Create(Context, Context.DependentTy, VK_RValue, LBracLoc, Receiver, Sel, - SelectorLocs, /*Method=*/0, + SelectorLocs, /*Method=*/nullptr, makeArrayRef(Args, NumArgs), RBracLoc, isImplicit)); } @@ -2417,7 +2423,7 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver, } } } else { - ObjCInterfaceDecl* ClassDecl = 0; + ObjCInterfaceDecl *ClassDecl = nullptr; // We allow sending a message to a qualified ID ("id"), which is ok as // long as one of the protocols implements the selector (if not, warn). @@ -2437,7 +2443,7 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver, // Try to complete the type. Under ARC, this is a hard error from which // we don't try to recover. - const ObjCInterfaceDecl *forwardClass = 0; + const ObjCInterfaceDecl *forwardClass = nullptr; if (RequireCompleteType(Loc, OCIType->getPointeeType(), getLangOpts().ObjCAutoRefCount ? diag::err_arc_receiver_forward_instance @@ -2450,7 +2456,7 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver, forwardClass = OCIType->getInterfaceDecl(); Diag(Receiver ? Receiver->getLocStart() : SuperLoc, diag::note_receiver_is_id); - Method = 0; + Method = nullptr; } else { Method = ClassDecl->lookupInstanceMethod(Sel); } @@ -2497,8 +2503,8 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver, FunctionScopeInfo *DIFunctionScopeInfo = (Method && Method->getMethodFamily() == OMF_init) - ? getEnclosingFunction() : 0; - + ? getEnclosingFunction() : nullptr; + if (DIFunctionScopeInfo && DIFunctionScopeInfo->ObjCIsDesignatedInit && (SuperLoc.isValid() || isSelfExpr(Receiver))) { @@ -2518,7 +2524,7 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver, } } if (!isDesignatedInitChain) { - const ObjCMethodDecl *InitMethod = 0; + const ObjCMethodDecl *InitMethod = nullptr; bool isDesignated = getCurMethodDecl()->isDesignatedInitializerForTheInterface(&InitMethod); assert(isDesignated && InitMethod); @@ -2736,10 +2742,11 @@ ExprResult Sema::ActOnInstanceMessage(Scope *S, } if (Sel == RespondsToSelectorSel) RemoveSelectorFromWarningCache(*this, Args[0]); - + return BuildInstanceMessage(Receiver, Receiver->getType(), - /*SuperLoc=*/SourceLocation(), Sel, /*Method=*/0, - LBracLoc, SelectorLocs, RBracLoc, Args); + /*SuperLoc=*/SourceLocation(), Sel, + /*Method=*/nullptr, LBracLoc, SelectorLocs, + RBracLoc, Args); } enum ARCConversionTypeClass { @@ -3149,7 +3156,7 @@ static inline T *getObjCBridgeAttr(const TypedefType *TD) { if (RecordDecl *RD = RT->getDecl()) return RD->getAttr(); } - return 0; + return nullptr; } static ObjCBridgeRelatedAttr *ObjCBridgeRelatedAttrFromType(QualType T, @@ -3161,7 +3168,7 @@ static ObjCBridgeRelatedAttr *ObjCBridgeRelatedAttrFromType(QualType T, return ObjCBAttr; T = TDNDecl->getUnderlyingType(); } - return 0; + return nullptr; } static void @@ -3178,7 +3185,7 @@ diagnoseObjCARCConversion(Sema &S, SourceRange castRange, return; QualType castExprType = castExpr->getType(); - TypedefNameDecl *TDNDecl = 0; + TypedefNameDecl *TDNDecl = nullptr; if ((castACTC == ACTC_coreFoundation && exprACTC == ACTC_retainable && ObjCBridgeRelatedAttrFromType(castType, TDNDecl)) || (exprACTC == ACTC_coreFoundation && castACTC == ACTC_retainable && @@ -3224,9 +3231,10 @@ diagnoseObjCARCConversion(Sema &S, SourceRange castRange, DiagnosticBuilder DiagB = (CCK != Sema::CCK_OtherCast) ? S.Diag(noteLoc, diag::note_arc_bridge) : S.Diag(noteLoc, diag::note_arc_cstyle_bridge); - + addFixitForObjCARCConversion(S, DiagB, CCK, afterLParen, - castType, castExpr, realCast, "__bridge ", 0); + castType, castExpr, realCast, "__bridge ", + nullptr); } if (CreateRule != ACC_plusZero) { @@ -3236,10 +3244,10 @@ diagnoseObjCARCConversion(Sema &S, SourceRange castRange, S.Diag(br ? castExpr->getExprLoc() : noteLoc, diag::note_arc_bridge_transfer) << castExprType << br; - + addFixitForObjCARCConversion(S, DiagB, CCK, afterLParen, castType, castExpr, realCast, "__bridge_transfer ", - br ? "CFBridgingRelease" : 0); + br ? "CFBridgingRelease" : nullptr); } return; @@ -3265,7 +3273,8 @@ diagnoseObjCARCConversion(Sema &S, SourceRange castRange, (CCK != Sema::CCK_OtherCast) ? S.Diag(noteLoc, diag::note_arc_bridge) : S.Diag(noteLoc, diag::note_arc_cstyle_bridge); addFixitForObjCARCConversion(S, DiagB, CCK, afterLParen, - castType, castExpr, realCast, "__bridge ", 0); + castType, castExpr, realCast, "__bridge ", + nullptr); } if (CreateRule != ACC_plusZero) { @@ -3275,10 +3284,10 @@ diagnoseObjCARCConversion(Sema &S, SourceRange castRange, S.Diag(br ? castExpr->getExprLoc() : noteLoc, diag::note_arc_bridge_retained) << castType << br; - + addFixitForObjCARCConversion(S, DiagB, CCK, afterLParen, castType, castExpr, realCast, "__bridge_retained ", - br ? "CFBridgingRetain" : 0); + br ? "CFBridgingRetain" : nullptr); } return; @@ -3297,7 +3306,7 @@ static void CheckObjCBridgeNSCast(Sema &S, QualType castType, Expr *castExpr) { TypedefNameDecl *TDNDecl = TD->getDecl(); if (TB *ObjCBAttr = getObjCBridgeAttr(TD)) { if (IdentifierInfo *Parm = ObjCBAttr->getBridgedType()) { - NamedDecl *Target = 0; + NamedDecl *Target = nullptr; // Check for an existing type with this name. LookupResult R(S, DeclarationName(Parm), SourceLocation(), Sema::LookupOrdinaryName); @@ -3350,7 +3359,7 @@ static void CheckObjCBridgeCFCast(Sema &S, QualType castType, Expr *castExpr) { TypedefNameDecl *TDNDecl = TD->getDecl(); if (TB *ObjCBAttr = getObjCBridgeAttr(TD)) { if (IdentifierInfo *Parm = ObjCBAttr->getBridgedType()) { - NamedDecl *Target = 0; + NamedDecl *Target = nullptr; // Check for an existing type with this name. LookupResult R(S, DeclarationName(Parm), SourceLocation(), Sema::LookupOrdinaryName); @@ -3447,7 +3456,7 @@ bool Sema::checkObjCBridgeRelatedComponents(SourceLocation Loc, IdentifierInfo *IMId = ObjCBAttr->getInstanceMethod(); if (!RCId) return false; - NamedDecl *Target = 0; + NamedDecl *Target = nullptr; // Check for an existing type with this name. LookupResult R(*this, DeclarationName(RCId), SourceLocation(), Sema::LookupOrdinaryName); @@ -3507,9 +3516,9 @@ Sema::CheckObjCBridgeRelatedConversions(SourceLocation Loc, return false; ObjCInterfaceDecl *RelatedClass; - ObjCMethodDecl *ClassMethod = 0; - ObjCMethodDecl *InstanceMethod = 0; - TypedefNameDecl *TDNDecl = 0; + ObjCMethodDecl *ClassMethod = nullptr; + ObjCMethodDecl *InstanceMethod = nullptr; + TypedefNameDecl *TDNDecl = nullptr; if (!checkObjCBridgeRelatedComponents(Loc, DestType, SrcType, RelatedClass, ClassMethod, InstanceMethod, TDNDecl, CfToNs)) return false; @@ -3654,7 +3663,7 @@ Sema::CheckObjCARCConversion(SourceRange castRange, QualType castType, case ACC_plusOne: castExpr = ImplicitCastExpr::Create(Context, castExpr->getType(), CK_ARCConsumeObject, castExpr, - 0, VK_RValue); + nullptr, VK_RValue); ExprNeedsCleanups = true; return ACR_okay; } @@ -3856,7 +3865,7 @@ ExprResult Sema::BuildObjCBridgedCast(SourceLocation LParenLoc, // Produce the object before casting it. SubExpr = ImplicitCastExpr::Create(Context, FromType, CK_ARCProduceObject, - SubExpr, 0, VK_RValue); + SubExpr, nullptr, VK_RValue); break; case OBC_BridgeTransfer: { @@ -3895,7 +3904,7 @@ ExprResult Sema::BuildObjCBridgedCast(SourceLocation LParenLoc, if (MustConsume) { ExprNeedsCleanups = true; Result = ImplicitCastExpr::Create(Context, T, CK_ARCConsumeObject, Result, - 0, VK_RValue); + nullptr, VK_RValue); } return Result; @@ -3908,7 +3917,7 @@ ExprResult Sema::ActOnObjCBridgedCast(Scope *S, ParsedType Type, SourceLocation RParenLoc, Expr *SubExpr) { - TypeSourceInfo *TSInfo = 0; + TypeSourceInfo *TSInfo = nullptr; QualType T = GetTypeFromParser(Type, &TSInfo); if (Kind == OBC_Bridge) CheckTollFreeBridgeCast(T, SubExpr); diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index fe1f7c8..a169602 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(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(*PI)); Replacements.back().setField(cast(*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(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(D); if (ConstructorTmpl) Constructor = cast( @@ -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()) && !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(D); if (ConstructorTmpl) Constructor = cast( @@ -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()) && !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(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::iterator CI = Ctors.begin(), CE = Ctors.end(); CI != CE; ++CI) { NamedDecl *D = *CI; - CXXConstructorDecl *Constructor = 0; + CXXConstructorDecl *Constructor = nullptr; if ((Constructor = dyn_cast(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()) Class = cast(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(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(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()); @@ -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; diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp index e6c714e..ef92e7c 100644 --- a/clang/lib/Sema/SemaLambda.cpp +++ b/clang/lib/Sema/SemaLambda.cpp @@ -316,18 +316,18 @@ Sema::getCurrentMangleNumberContext(const DeclContext *DC, if ((IsInNonspecializedTemplate && !(ManglingContextDecl && isa(ManglingContextDecl))) || isInInlineFunction(CurContext)) { - ManglingContextDecl = 0; + ManglingContextDecl = nullptr; return &Context.getManglingNumberContext(DC); } - ManglingContextDecl = 0; - return 0; + ManglingContextDecl = nullptr; + return nullptr; case StaticDataMember: // -- the initializers of nonspecialized static members of template classes if (!IsInNonspecializedTemplate) { - ManglingContextDecl = 0; - return 0; + ManglingContextDecl = nullptr; + return nullptr; } // Fall through to get the current context. @@ -403,7 +403,7 @@ CXXMethodDecl *Sema::startLambdaDefinition(CXXRecordDecl *Class, FunctionTemplateDecl::Create(Context, Class, Method->getLocation(), MethodName, TemplateParams, - Method) : 0; + Method) : nullptr; if (TemplateMethod) { TemplateMethod->setLexicalDeclContext(CurContext); TemplateMethod->setAccess(AS_public); @@ -504,7 +504,7 @@ static EnumDecl *findEnumForBlockReturn(Expr *E) { = dyn_cast(DRE->getDecl())) { return cast(D->getDeclContext()); } - return 0; + return nullptr; } // - it is a comma expression whose RHS is an enumerator-like @@ -512,7 +512,7 @@ static EnumDecl *findEnumForBlockReturn(Expr *E) { if (BinaryOperator *BO = dyn_cast(E)) { if (BO->getOpcode() == BO_Comma) return findEnumForBlockReturn(BO->getRHS()); - return 0; + return nullptr; } // - it is a statement-expression whose value expression is an @@ -520,7 +520,7 @@ static EnumDecl *findEnumForBlockReturn(Expr *E) { if (StmtExpr *SE = dyn_cast(E)) { if (Expr *last = dyn_cast_or_null(SE->getSubStmt()->body_back())) return findEnumForBlockReturn(last); - return 0; + return nullptr; } // - it is a ternary conditional operator (not the GNU ?: @@ -530,7 +530,7 @@ static EnumDecl *findEnumForBlockReturn(Expr *E) { if (EnumDecl *ED = findEnumForBlockReturn(CO->getTrueExpr())) if (ED == findEnumForBlockReturn(CO->getFalseExpr())) return ED; - return 0; + return nullptr; } // (implicitly:) @@ -551,7 +551,7 @@ static EnumDecl *findEnumForBlockReturn(Expr *E) { } // Otherwise, nope. - return 0; + return nullptr; } /// Attempt to find a type T for which the returned expression of the @@ -559,7 +559,7 @@ static EnumDecl *findEnumForBlockReturn(Expr *E) { static EnumDecl *findEnumForBlockReturn(ReturnStmt *ret) { if (Expr *retValue = ret->getRetValue()) return findEnumForBlockReturn(retValue); - return 0; + return nullptr; } /// Attempt to find a common type T for which all of the returned @@ -570,16 +570,16 @@ static EnumDecl *findCommonEnumForBlockReturns(ArrayRef returns) { // Try to find one for the first return. EnumDecl *ED = findEnumForBlockReturn(*i); - if (!ED) return 0; + if (!ED) return nullptr; // Check that the rest of the returns have the same enum. for (++i; i != e; ++i) { if (findEnumForBlockReturn(*i) != ED) - return 0; + return nullptr; } // Never infer an anonymous enum type. - if (!ED->hasNameForLinkage()) return 0; + if (!ED->hasNameForLinkage()) return nullptr; return ED; } @@ -603,7 +603,7 @@ static void adjustBlockReturnsToEnum(Sema &S, ArrayRef returns, Expr *E = (cleanups ? cleanups->getSubExpr() : retValue); E = ImplicitCastExpr::Create(S.Context, returnType, CK_IntegralCast, - E, /*base path*/ 0, VK_RValue); + E, /*base path*/ nullptr, VK_RValue); if (cleanups) { cleanups->setSubExpr(E); } else { @@ -819,7 +819,8 @@ VarDecl *Sema::createLambdaInitCaptureVarDecl(SourceLocation Loc, FieldDecl *Sema::buildInitCaptureField(LambdaScopeInfo *LSI, VarDecl *Var) { FieldDecl *Field = FieldDecl::Create( Context, LSI->Lambda, Var->getLocation(), Var->getLocation(), - 0, Var->getType(), Var->getTypeSourceInfo(), 0, false, ICIS_NoInit); + nullptr, Var->getType(), Var->getTypeSourceInfo(), nullptr, false, + ICIS_NoInit); Field->setImplicit(true); Field->setAccess(AS_private); LSI->Lambda->addDecl(Field); @@ -845,7 +846,7 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro, // has template params, only then are we in a dependent scope. if (TemplateParams) { TmplScope = TmplScope->getParent(); - TmplScope = TmplScope ? TmplScope->getTemplateParamParent() : 0; + TmplScope = TmplScope ? TmplScope->getTemplateParamParent() : nullptr; } if (TmplScope && !TmplScope->decl_empty()) KnownDependent = true; @@ -996,7 +997,7 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro, if (C->Init.isInvalid()) continue; - VarDecl *Var = 0; + VarDecl *Var = nullptr; if (C->Init.isUsable()) { Diag(C->Loc, getLangOpts().CPlusPlus1y ? diag::warn_cxx11_compat_init_capture @@ -1145,8 +1146,8 @@ void Sema::ActOnLambdaError(SourceLocation StartLoc, Scope *CurScope, CXXRecordDecl *Class = LSI->Lambda; Class->setInvalidDecl(); SmallVector Fields(Class->fields()); - ActOnFields(0, Class->getLocation(), Class, Fields, SourceLocation(), - SourceLocation(), 0); + ActOnFields(nullptr, Class->getLocation(), Class, Fields, SourceLocation(), + SourceLocation(), nullptr); CheckCompletedCXXClass(Class); PopFunctionScopeInfo(); @@ -1253,7 +1254,7 @@ static void addFunctionPointerConversion(Sema &S, From->getType(), From->getTypeSourceInfo(), From->getStorageClass(), - /*DefaultArg=*/0)); + /*DefaultArg=*/nullptr)); CallOpConvTL.setParam(I, From); CallOpConvNameTL.setParam(I, From); } @@ -1504,8 +1505,8 @@ ExprResult Sema::ActOnLambdaExpr(SourceLocation StartLoc, Stmt *Body, // Finalize the lambda class. SmallVector Fields(Class->fields()); - ActOnFields(0, Class->getLocation(), Class, Fields, SourceLocation(), - SourceLocation(), 0); + ActOnFields(nullptr, Class->getLocation(), Class, Fields, SourceLocation(), + SourceLocation(), nullptr); CheckCompletedCXXClass(Class); } @@ -1595,7 +1596,7 @@ ExprResult Sema::BuildBlockForLambdaConversion(SourceLocation CurrentLocation, From->getType(), From->getTypeSourceInfo(), From->getStorageClass(), - /*DefaultArg=*/0)); + /*DefaultArg=*/nullptr)); } Block->setParams(BlockParams); @@ -1607,7 +1608,7 @@ ExprResult Sema::BuildBlockForLambdaConversion(SourceLocation CurrentLocation, TypeSourceInfo *CapVarTSI = Context.getTrivialTypeSourceInfo(Src->getType()); VarDecl *CapVar = VarDecl::Create(Context, Block, ConvLocation, - ConvLocation, 0, + ConvLocation, nullptr, Src->getType(), CapVarTSI, SC_None); BlockDecl::Capture Capture(/*Variable=*/CapVar, /*ByRef=*/false, diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index 52f4c84..eb6366c 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -324,9 +324,9 @@ bool LookupResult::sanity() const { assert(ResultKind != Ambiguous || Decls.size() > 1 || (Decls.size() == 1 && (Ambiguity == AmbiguousBaseSubobjects || Ambiguity == AmbiguousBaseSubobjectTypes))); - assert((Paths != NULL) == (ResultKind == Ambiguous && - (Ambiguity == AmbiguousBaseSubobjectTypes || - Ambiguity == AmbiguousBaseSubobjects))); + assert((Paths != nullptr) == (ResultKind == Ambiguous && + (Ambiguity == AmbiguousBaseSubobjectTypes || + Ambiguity == AmbiguousBaseSubobjects))); return true; } @@ -724,7 +724,7 @@ static bool LookupDirect(Sema &S, LookupResult &R, const DeclContext *DC) { // specialization into the result set. We do this to avoid forcing all // callers to perform special deduction for conversion functions. TemplateDeductionInfo Info(R.getNameLoc()); - FunctionDecl *Specialization = 0; + FunctionDecl *Specialization = nullptr; const FunctionProtoType *ConvProto = ConvTemplate->getTemplatedDecl()->getType()->getAs(); @@ -743,7 +743,7 @@ static bool LookupDirect(Sema &S, LookupResult &R, const DeclContext *DC) { // Perform template argument deduction against the type that we would // expect the function to have. - if (R.getSema().DeduceTemplateArguments(ConvTemplate, 0, ExpectedType, + if (R.getSema().DeduceTemplateArguments(ConvTemplate, nullptr, ExpectedType, Specialization, Info) == Sema::TDK_Success) { R.addDecl(Specialization); @@ -793,7 +793,7 @@ static bool isNamespaceOrTranslationUnitScope(Scope *S) { // it leaves the current template parameter scope. static std::pair findOuterContext(Scope *S) { DeclContext *DC = S->getEntity(); - DeclContext *Lexical = 0; + DeclContext *Lexical = nullptr; for (Scope *OuterS = S->getParent(); OuterS; OuterS = OuterS->getParent()) { if (OuterS->getEntity()) { @@ -916,7 +916,7 @@ bool Sema::CppLookupName(LookupResult &R, Scope *S) { UnqualUsingDirectiveSet UDirs; bool VisitedUsingDirectives = false; bool LeftStartingScope = false; - DeclContext *OutsideOfTemplateParamDC = 0; + DeclContext *OutsideOfTemplateParamDC = nullptr; // When performing a scope lookup, we want to find local extern decls. FindLocalExternScope FindLocals(R); @@ -973,7 +973,7 @@ bool Sema::CppLookupName(LookupResult &R, Scope *S) { // findOuterContext(). This implements the name lookup behavior // of C++ [temp.local]p8. Ctx = OutsideOfTemplateParamDC; - OutsideOfTemplateParamDC = 0; + OutsideOfTemplateParamDC = nullptr; } if (Ctx) { @@ -1116,7 +1116,7 @@ bool Sema::CppLookupName(LookupResult &R, Scope *S) { // findOuterContext(). This implements the name lookup behavior // of C++ [temp.local]p8. Ctx = OutsideOfTemplateParamDC; - OutsideOfTemplateParamDC = 0; + OutsideOfTemplateParamDC = nullptr; } if (Ctx) { @@ -1214,7 +1214,7 @@ llvm::DenseSet &Sema::getLookupModules() { I != N; ++I) { Module *M = getDefiningModule(ActiveTemplateInstantiations[I].Entity); if (M && !LookupModulesCache.insert(M).second) - M = 0; + M = nullptr; ActiveTemplateInstantiationLookupModules.push_back(M); } return LookupModulesCache; @@ -1275,7 +1275,7 @@ static NamedDecl *findAcceptableDecl(Sema &SemaRef, NamedDecl *D) { } } - return 0; + return nullptr; } NamedDecl *LookupResult::getAcceptableDeclSlow(NamedDecl *D) const { @@ -1370,10 +1370,10 @@ bool Sema::LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation) { // then we'll need to perform our checks based on the matching // DeclContexts rather than matching scopes. if (S && isNamespaceOrTranslationUnitScope(S)) - S = 0; + S = nullptr; // Compute the DeclContext, if we need it. - DeclContext *DC = 0; + DeclContext *DC = nullptr; if (!S) DC = (*I)->getDeclContext()->getRedeclContext(); @@ -1654,7 +1654,7 @@ bool Sema::LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, Paths.setOrigin(LookupRec); // Look for this member in our base classes - CXXRecordDecl::BaseMatchesCallback *BaseCallback = 0; + CXXRecordDecl::BaseMatchesCallback *BaseCallback = nullptr; switch (R.getLookupKind()) { case LookupObjCImplicitSelfParam: case LookupOrdinaryName: @@ -2401,7 +2401,7 @@ Sema::SpecialMemberOverloadResult *Sema::LookupSpecialMember(CXXRecordDecl *RD, // if necessary and make sure that implicit functions are declared. CanQualType CanTy = Context.getCanonicalType(Context.getTagDeclType(RD)); DeclarationName Name; - Expr *Arg = 0; + Expr *Arg = nullptr; unsigned NumArgs; QualType ArgType = CanTy; @@ -2505,12 +2505,12 @@ Sema::SpecialMemberOverloadResult *Sema::LookupSpecialMember(CXXRecordDecl *RD, dyn_cast(Cand)) { if (SM == CXXCopyAssignment || SM == CXXMoveAssignment) AddMethodTemplateCandidate(Tmpl, DeclAccessPair::make(Tmpl, AS_public), - RD, 0, ThisTy, Classification, + RD, nullptr, ThisTy, Classification, llvm::makeArrayRef(&Arg, NumArgs), OCS, true); else AddTemplateOverloadCandidate(Tmpl, DeclAccessPair::make(Tmpl, AS_public), - 0, llvm::makeArrayRef(&Arg, NumArgs), + nullptr, llvm::makeArrayRef(&Arg, NumArgs), OCS, true); } else { assert(isa(Cand) && "illegal Kind of operator = Decl"); @@ -2530,12 +2530,12 @@ Sema::SpecialMemberOverloadResult *Sema::LookupSpecialMember(CXXRecordDecl *RD, break; case OR_Ambiguous: - Result->setMethod(0); + Result->setMethod(nullptr); Result->setKind(SpecialMemberOverloadResult::Ambiguous); break; case OR_No_Viable_Function: - Result->setMethod(0); + Result->setMethod(nullptr); Result->setKind(SpecialMemberOverloadResult::NoMemberOrDeleted); break; } @@ -2759,7 +2759,7 @@ void ADLResult::insert(NamedDecl *New) { // If we haven't yet seen a decl for this key, or the last decl // was exactly this one, we're done. - if (Old == 0 || Old == New) { + if (Old == nullptr || Old == New) { Old = New; return; } @@ -2968,7 +2968,7 @@ NamedDecl *VisibleDeclsRecord::checkHidden(NamedDecl *ND) { } } - return 0; + return nullptr; } static void LookupVisibleDecls(DeclContext *Ctx, LookupResult &Result, @@ -3118,14 +3118,14 @@ static void LookupVisibleDecls(Scope *S, LookupResult &Result, for (auto *D : S->decls()) { if (NamedDecl *ND = dyn_cast(D)) if ((ND = Result.getAcceptableDecl(ND))) { - Consumer.FoundDecl(ND, Visited.checkHidden(ND), 0, false); + Consumer.FoundDecl(ND, Visited.checkHidden(ND), nullptr, false); Visited.add(ND); } } } // FIXME: C++ [temp.local]p8 - DeclContext *Entity = 0; + DeclContext *Entity = nullptr; if (S->getEntity()) { // Look into this scope's declaration context, along with any of its // parent lookup contexts (e.g., enclosing classes), up to the point @@ -3235,7 +3235,7 @@ void Sema::LookupVisibleDecls(DeclContext *Ctx, LookupNameKind Kind, LabelDecl *Sema::LookupOrCreateLabel(IdentifierInfo *II, SourceLocation Loc, SourceLocation GnuLabelLoc) { // Do a lookup to see if we have a label with this name already. - NamedDecl *Res = 0; + NamedDecl *Res = nullptr; if (GnuLabelLoc.isValid()) { // Local label definitions always shadow existing labels. @@ -3250,8 +3250,8 @@ LabelDecl *Sema::LookupOrCreateLabel(IdentifierInfo *II, SourceLocation Loc, // If we found a label, check to see if it is in the same context as us. // When in a Block, we don't want to reuse a label in an enclosing function. if (Res && Res->getDeclContext() != CurContext) - Res = 0; - if (Res == 0) { + Res = nullptr; + if (!Res) { // If not forward referenced or defined already, create the backing decl. Res = LabelDecl::Create(Context, CurContext, Loc, II); Scope *S = CurScope->getFnParent(); @@ -3297,8 +3297,8 @@ public: bool InBaseClass) override; void FoundName(StringRef Name); void addKeywordResult(StringRef Keyword); - void addName(StringRef Name, NamedDecl *ND, NestedNameSpecifier *NNS = NULL, - bool isKeyword = false); + void addName(StringRef Name, NamedDecl *ND, + NestedNameSpecifier *NNS = nullptr, bool isKeyword = false); void addCorrection(TypoCorrection Correction); typedef TypoResultsMap::iterator result_iterator; @@ -3354,13 +3354,13 @@ void TypoCorrectionConsumer::FoundDecl(NamedDecl *ND, NamedDecl *Hiding, void TypoCorrectionConsumer::FoundName(StringRef Name) { // Compute the edit distance between the typo and the name of this // entity, and add the identifier to the list of results. - addName(Name, NULL); + addName(Name, nullptr); } void TypoCorrectionConsumer::addKeywordResult(StringRef Keyword) { // Compute the edit distance between the typo and this keyword, // and add the keyword to the list of results. - addName(Keyword, NULL, NULL, true); + addName(Keyword, nullptr, nullptr, true); } void TypoCorrectionConsumer::addName(StringRef Name, NamedDecl *ND, @@ -3422,7 +3422,7 @@ static void getNestedNameSpecifierIdentifiers( else Identifiers.clear(); - const IdentifierInfo *II = NULL; + const IdentifierInfo *II = nullptr; switch (NNS->getKind()) { case NestedNameSpecifier::Identifier: @@ -3491,7 +3491,7 @@ class NamespaceSpecifierSet { : Context(Context), CurContextChain(BuildContextChain(CurContext)), isSorted(false) { if (NestedNameSpecifier *NNS = - CurScopeSpec ? CurScopeSpec->getScopeRep() : 0) { + CurScopeSpec ? CurScopeSpec->getScopeRep() : nullptr) { llvm::raw_string_ostream SpecifierOStream(CurNameSpecifier); NNS->print(SpecifierOStream, Context.getPrintingPolicy()); @@ -3531,7 +3531,7 @@ class NamespaceSpecifierSet { DeclContextList NamespaceSpecifierSet::BuildContextChain(DeclContext *Start) { assert(Start && "Building a context chain from a null context"); DeclContextList Chain; - for (DeclContext *DC = Start->getPrimaryContext(); DC != NULL; + for (DeclContext *DC = Start->getPrimaryContext(); DC != nullptr; DC = DC->getLookupParent()) { NamespaceDecl *ND = dyn_cast_or_null(DC); if (!DC->isInlineNamespace() && !DC->isTransparentContext() && @@ -3579,7 +3579,7 @@ static unsigned BuildNestedNameSpecifier(ASTContext &Context, } void NamespaceSpecifierSet::AddNameSpecifier(DeclContext *Ctx) { - NestedNameSpecifier *NNS = NULL; + NestedNameSpecifier *NNS = nullptr; unsigned NumSpecifiers = 0; DeclContextList NamespaceDeclChain(BuildContextChain(Ctx)); DeclContextList FullNamespaceDeclChain(NamespaceDeclChain); @@ -4121,7 +4121,7 @@ TypoCorrection Sema::CorrectTypo(const DeclarationNameInfo &TypoName, bool SSIsTemplate = false; if (NestedNameSpecifier *NNS = - (SS && SS->isValid()) ? SS->getScopeRep() : 0) { + (SS && SS->isValid()) ? SS->getScopeRep() : nullptr) { if (const Type *T = NNS->getAsType()) SSIsTemplate = T->getTypeClass() == Type::TemplateSpecialization; } @@ -4203,14 +4203,14 @@ retry_lookup: case LookupResult::FoundUnresolvedValue: if (TempSS) { // Immediately retry the lookup without the given CXXScopeSpec - TempSS = NULL; + TempSS = nullptr; Candidate.WillReplaceSpecifier(true); goto retry_lookup; } if (TempMemberContext) { if (SS && !TempSS) TempSS = SS; - TempMemberContext = NULL; + TempMemberContext = nullptr; goto retry_lookup; } QualifiedResults.push_back(Candidate); @@ -4274,7 +4274,7 @@ retry_lookup: // it as it is unlikely a qualified version of the class' constructor // is an appropriate correction. if (CXXRecordDecl *NSDecl = - NSType ? NSType->getAsCXXRecordDecl() : 0) { + NSType ? NSType->getAsCXXRecordDecl() : nullptr) { if (NSDecl->getIdentifier() == QR.getCorrectionAsIdentifierInfo()) continue; } @@ -4318,7 +4318,8 @@ retry_lookup: TRDEnd = TmpRes.end(); TRD != TRDEnd; ++TRD) { if (CheckMemberAccess(TC.getCorrectionRange().getBegin(), - NSType ? NSType->getAsCXXRecordDecl() : 0, + NSType ? NSType->getAsCXXRecordDecl() + : nullptr, TRD.getPair()) == AR_accessible) TC.addCorrectionDecl(*TRD); } @@ -4465,7 +4466,7 @@ bool FunctionCallFilterCCC::ValidateCandidate(const TypoCorrection &candidate) { for (TypoCorrection::const_decl_iterator DI = candidate.begin(), DIEnd = candidate.end(); DI != DIEnd; ++DI) { - FunctionDecl *FD = 0; + FunctionDecl *FD = nullptr; NamedDecl *ND = (*DI)->getUnderlyingDecl(); if (FunctionTemplateDecl *FTD = dyn_cast(ND)) FD = FTD->getTemplatedDecl(); @@ -4500,7 +4501,7 @@ bool FunctionCallFilterCCC::ValidateCandidate(const TypoCorrection &candidate) { ? dyn_cast_or_null(MemberFn->getMemberDecl()) : dyn_cast_or_null(CurContext); CXXRecordDecl *CurRD = - CurMD ? CurMD->getParent()->getCanonicalDecl() : 0; + CurMD ? CurMD->getParent()->getCanonicalDecl() : nullptr; CXXRecordDecl *RD = MD->getParent()->getCanonicalDecl(); if (!CurRD || (CurRD != RD && !CurRD->isDerivedFrom(RD))) continue; @@ -4524,7 +4525,7 @@ static const NamedDecl *getDefinitionToImport(const NamedDecl *D) { if (const VarDecl *VD = dyn_cast(D)) return VD->getDefinition(); if (const FunctionDecl *FD = dyn_cast(D)) - return FD->isDefined(FD) ? FD : 0; + return FD->isDefined(FD) ? FD : nullptr; if (const TagDecl *TD = dyn_cast(D)) return TD->getDefinition(); if (const ObjCInterfaceDecl *ID = dyn_cast(D)) @@ -4533,7 +4534,7 @@ static const NamedDecl *getDefinitionToImport(const NamedDecl *D) { return PD->getDefinition(); if (const TemplateDecl *TD = dyn_cast(D)) return getDefinitionToImport(TD->getTemplatedDecl()); - return 0; + return nullptr; } /// \brief Diagnose a successfully-corrected typo. Separated from the correction @@ -4586,7 +4587,7 @@ void Sema::diagnoseTypo(const TypoCorrection &Correction, << CorrectedQuotedStr << (ErrorRecovery ? FixTypo : FixItHint()); NamedDecl *ChosenDecl = - Correction.isKeyword() ? 0 : Correction.getCorrectionDecl(); + Correction.isKeyword() ? nullptr : Correction.getCorrectionDecl(); if (PrevNote.getDiagID() && ChosenDecl) Diag(ChosenDecl->getLocation(), PrevNote) << CorrectedQuotedStr << (ErrorRecovery ? FixItHint() : FixTypo); diff --git a/clang/lib/Sema/SemaObjCProperty.cpp b/clang/lib/Sema/SemaObjCProperty.cpp index dd0721a..23fa024 100644 --- a/clang/lib/Sema/SemaObjCProperty.cpp +++ b/clang/lib/Sema/SemaObjCProperty.cpp @@ -164,7 +164,7 @@ Decl *Sema::ActOnProperty(Scope *S, SourceLocation AtLoc, // Proceed with constructing the ObjCPropertyDecls. ObjCContainerDecl *ClassDecl = cast(CurContext); - ObjCPropertyDecl *Res = 0; + ObjCPropertyDecl *Res = nullptr; if (ObjCCategoryDecl *CDecl = dyn_cast(ClassDecl)) { if (CDecl->IsClassExtension()) { Res = HandlePropertyInClassExtension(S, AtLoc, LParenLoc, @@ -175,7 +175,7 @@ Decl *Sema::ActOnProperty(Scope *S, SourceLocation AtLoc, isOverridingProperty, TSI, MethodImplKind); if (!Res) - return 0; + return nullptr; } } @@ -337,7 +337,7 @@ Sema::HandlePropertyInClassExtension(Scope *S, = ObjCPropertyDecl::findPropertyDecl(Ext, PropertyId)) { Diag(AtLoc, diag::err_duplicate_property); Diag(prevDecl->getLocation(), diag::note_property_declare); - return 0; + return nullptr; } } } @@ -369,7 +369,7 @@ Sema::HandlePropertyInClassExtension(Scope *S, if (!CCPrimary) { Diag(CDecl->getLocation(), diag::err_continuation_class); *isOverridingProperty = true; - return 0; + return nullptr; } // Find the property in continuation class's primary class only. @@ -387,12 +387,14 @@ Sema::HandlePropertyInClassExtension(Scope *S, // A case of continuation class adding a new property in the class. This // is not what it was meant for. However, gcc supports it and so should we. // Make sure setter/getters are declared here. - ProcessPropertyDecl(PrimaryPDecl, CCPrimary, /* redeclaredProperty = */ 0, + ProcessPropertyDecl(PrimaryPDecl, CCPrimary, + /* redeclaredProperty = */ nullptr, /* lexicalDC = */ CDecl); PDecl->setGetterMethodDecl(PrimaryPDecl->getGetterMethodDecl()); PDecl->setSetterMethodDecl(PrimaryPDecl->getSetterMethodDecl()); if (ASTMutationListener *L = Context.getASTMutationListener()) - L->AddedObjCPropertyInClassExtension(PrimaryPDecl, /*OrigProp=*/0, CDecl); + L->AddedObjCPropertyInClassExtension(PrimaryPDecl, /*OrigProp=*/nullptr, + CDecl); return PrimaryPDecl; } if (!Context.hasSameType(PIDecl->getType(), PDecl->getType())) { @@ -412,7 +414,7 @@ Sema::HandlePropertyInClassExtension(Scope *S, Diag(AtLoc, diag::err_type_mismatch_continuation_class) << PDecl->getType(); Diag(PIDecl->getLocation(), diag::note_property_declare); - return 0; + return nullptr; } } @@ -503,7 +505,7 @@ Sema::HandlePropertyInClassExtension(Scope *S, Diag(AtLoc, diag) << CCPrimary->getDeclName(); Diag(PIDecl->getLocation(), diag::note_property_declare); - return 0; + return nullptr; } *isOverridingProperty = true; // Make sure setter decl is synthesized, and added to primary class's list. @@ -803,19 +805,19 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, // Make sure we have a context for the property implementation declaration. if (!ClassImpDecl) { Diag(AtLoc, diag::error_missing_property_context); - return 0; + return nullptr; } if (PropertyIvarLoc.isInvalid()) PropertyIvarLoc = PropertyLoc; SourceLocation PropertyDiagLoc = PropertyLoc; if (PropertyDiagLoc.isInvalid()) PropertyDiagLoc = ClassImpDecl->getLocStart(); - ObjCPropertyDecl *property = 0; - ObjCInterfaceDecl* IDecl = 0; + ObjCPropertyDecl *property = nullptr; + ObjCInterfaceDecl *IDecl = nullptr; // Find the class or category class where this property must have // a declaration. - ObjCImplementationDecl *IC = 0; - ObjCCategoryImplDecl* CatImplClass = 0; + ObjCImplementationDecl *IC = nullptr; + ObjCCategoryImplDecl *CatImplClass = nullptr; if ((IC = dyn_cast(ClassImpDecl))) { IDecl = IC->getClassInterface(); // We always synthesize an interface for an implementation @@ -827,7 +829,7 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, property = IDecl->FindPropertyDeclaration(PropertyId); if (!property) { Diag(PropertyLoc, diag::error_bad_property_decl) << IDecl->getDeclName(); - return 0; + return nullptr; } unsigned PIkind = property->getPropertyAttributesAsWritten(); if ((PIkind & (ObjCPropertyDecl::OBJC_PR_atomic | @@ -844,7 +846,7 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, if (!CD->IsClassExtension()) { Diag(PropertyLoc, diag::error_category_property) << CD->getDeclName(); Diag(property->getLocation(), diag::note_property_declare); - return 0; + return nullptr; } } if (Synthesize&& @@ -887,12 +889,12 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, } else if ((CatImplClass = dyn_cast(ClassImpDecl))) { if (Synthesize) { Diag(AtLoc, diag::error_synthesize_category_decl); - return 0; + return nullptr; } IDecl = CatImplClass->getClassInterface(); if (!IDecl) { Diag(AtLoc, diag::error_missing_property_interface); - return 0; + return nullptr; } ObjCCategoryDecl *Category = IDecl->FindCategoryDeclaration(CatImplClass->getIdentifier()); @@ -900,19 +902,19 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, // If category for this implementation not found, it is an error which // has already been reported eralier. if (!Category) - return 0; + return nullptr; // Look for this property declaration in @implementation's category property = Category->FindPropertyDeclaration(PropertyId); if (!property) { Diag(PropertyLoc, diag::error_bad_category_property_decl) << Category->getDeclName(); - return 0; + return nullptr; } } else { Diag(AtLoc, diag::error_bad_property_context); - return 0; + return nullptr; } - ObjCIvarDecl *Ivar = 0; + ObjCIvarDecl *Ivar = nullptr; bool CompleteTypeErr = false; bool compat = true; // Check that we have a valid, previously declared ivar for @synthesize @@ -960,14 +962,14 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, // an ivar matching property name and issue warning; since this // is the most common case of not using an ivar used for backing // property in non-default synthesis case. - ObjCInterfaceDecl *ClassDeclared=0; + ObjCInterfaceDecl *ClassDeclared=nullptr; ObjCIvarDecl *originalIvar = IDecl->lookupInstanceVariable(property->getIdentifier(), ClassDeclared); if (originalIvar) { Diag(PropertyDiagLoc, diag::warn_autosynthesis_property_ivar_match) - << PropertyId << (Ivar == 0) << PropertyIvar + << PropertyId << (Ivar == nullptr) << PropertyIvar << originalIvar->getIdentifier(); Diag(property->getLocation(), diag::note_property_declare); Diag(originalIvar->getLocation(), diag::note_ivar_decl); @@ -1026,9 +1028,9 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, Ivar = ObjCIvarDecl::Create(Context, ClassImpDecl, PropertyIvarLoc,PropertyIvarLoc, PropertyIvar, - PropertyIvarType, /*Dinfo=*/0, + PropertyIvarType, /*Dinfo=*/nullptr, ObjCIvarDecl::Private, - (Expr *)0, true); + (Expr *)nullptr, true); if (RequireNonAbstractType(PropertyIvarLoc, PropertyIvarType, diag::err_abstract_type_in_decl, @@ -1144,7 +1146,8 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, MarkDeclRefReferenced(SelfExpr); Expr *LoadSelfExpr = ImplicitCastExpr::Create(Context, SelfDecl->getType(), - CK_LValueToRValue, SelfExpr, 0, VK_RValue); + CK_LValueToRValue, SelfExpr, nullptr, + VK_RValue); Expr *IvarRefExpr = new (Context) ObjCIvarRefExpr(Ivar, Ivar->getType(), PropertyDiagLoc, Ivar->getLocation(), @@ -1193,7 +1196,8 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, MarkDeclRefReferenced(SelfExpr); Expr *LoadSelfExpr = ImplicitCastExpr::Create(Context, SelfDecl->getType(), - CK_LValueToRValue, SelfExpr, 0, VK_RValue); + CK_LValueToRValue, SelfExpr, nullptr, + VK_RValue); Expr *lhs = new (Context) ObjCIvarRefExpr(Ivar, Ivar->getType(), PropertyDiagLoc, Ivar->getLocation(), @@ -1239,7 +1243,7 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, = IC->FindPropertyImplDecl(PropertyId)) { Diag(PropertyLoc, diag::error_property_implemented) << PropertyId; Diag(PPIDecl->getLocation(), diag::note_previous_declaration); - return 0; + return nullptr; } IC->addPropertyImplementation(PIDecl); if (getLangOpts().ObjCDefaultSynthProperties && @@ -1248,8 +1252,8 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, // Diagnose if an ivar was lazily synthesdized due to a previous // use and if 1) property is @dynamic or 2) property is synthesized // but it requires an ivar of different name. - ObjCInterfaceDecl *ClassDeclared=0; - ObjCIvarDecl *Ivar = 0; + ObjCInterfaceDecl *ClassDeclared=nullptr; + ObjCIvarDecl *Ivar = nullptr; if (!Synthesize) Ivar = IDecl->lookupInstanceVariable(PropertyId, ClassDeclared); else { @@ -1278,7 +1282,7 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, CatImplClass->FindPropertyImplDecl(PropertyId)) { Diag(PropertyDiagLoc, diag::error_property_implemented) << PropertyId; Diag(PPIDecl->getLocation(), diag::note_previous_declaration); - return 0; + return nullptr; } CatImplClass->addPropertyImplementation(PIDecl); } @@ -1622,7 +1626,7 @@ static void DiagnoseUnimplementedAccessor(Sema &S, // class's protocol, or one of it super classes. This is because, // the class is going to implement them. if (!SMap.count(Method) && - (PrimaryClass == 0 || + (PrimaryClass == nullptr || !PrimaryClass->lookupPropertyAccessor(Method, C))) { S.Diag(IMPDecl->getLocation(), isa(CDecl) ? @@ -1710,7 +1714,7 @@ void Sema::DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl* IMPDecl, InsMap.insert(I->getSelector()); ObjCCategoryDecl *C = dyn_cast(CDecl); - ObjCInterfaceDecl *PrimaryClass = 0; + ObjCInterfaceDecl *PrimaryClass = nullptr; if (C && !C->IsClassExtension()) if ((PrimaryClass = C->getClassInterface())) // Report unimplemented properties in the category as well. @@ -1749,8 +1753,8 @@ Sema::AtomicPropertySetterGetterRules (ObjCImplDecl* IMPDecl, if (getLangOpts().getGC() != LangOptions::NonGC) return; for (const auto *Property : IDecl->properties()) { - ObjCMethodDecl *GetterMethod = 0; - ObjCMethodDecl *SetterMethod = 0; + ObjCMethodDecl *GetterMethod = nullptr; + ObjCMethodDecl *SetterMethod = nullptr; bool LookedUpGetterSetter = false; unsigned Attributes = Property->getPropertyAttributes(); @@ -1792,8 +1796,8 @@ Sema::AtomicPropertySetterGetterRules (ObjCImplDecl* IMPDecl, (GetterMethod ? GetterMethod->getLocation() : SetterMethod->getLocation()); Diag(MethodLoc, diag::warn_atomic_property_rule) - << Property->getIdentifier() << (GetterMethod != 0) - << (SetterMethod != 0); + << Property->getIdentifier() << (GetterMethod != nullptr) + << (SetterMethod != nullptr); // fixit stuff. if (!AttributesAsWritten) { if (Property->getLParenLoc().isValid()) { @@ -1943,8 +1947,9 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property, GetterMethod = ObjCMethodDecl::Create(Context, Loc, Loc, property->getGetterName(), - property->getType(), 0, CD, /*isInstance=*/true, - /*isVariadic=*/false, /*isPropertyAccessor=*/true, + property->getType(), nullptr, CD, + /*isInstance=*/true, /*isVariadic=*/false, + /*isPropertyAccessor=*/true, /*isImplicitlyDeclared=*/true, /*isDefined=*/false, (property->getPropertyImplementation() == ObjCPropertyDecl::Optional) ? @@ -1992,8 +1997,9 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property, SetterMethod = ObjCMethodDecl::Create(Context, Loc, Loc, - property->getSetterName(), Context.VoidTy, 0, - CD, /*isInstance=*/true, /*isVariadic=*/false, + property->getSetterName(), Context.VoidTy, + nullptr, CD, /*isInstance=*/true, + /*isVariadic=*/false, /*isPropertyAccessor=*/true, /*isImplicitlyDeclared=*/true, /*isDefined=*/false, @@ -2008,9 +2014,9 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property, Loc, Loc, property->getIdentifier(), property->getType().getUnqualifiedType(), - /*TInfo=*/0, + /*TInfo=*/nullptr, SC_None, - 0); + nullptr); SetterMethod->setMethodParams(Context, Argument, None); AddPropertyAttrs(*this, SetterMethod, property); diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 3aca692..147325b 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -216,7 +216,7 @@ void StandardConversionSequence::setAsIdentityConversion() { BindsToRvalue = false; BindsImplicitObjectArgumentWithoutRefQualifier = false; ObjCLifetimeConversionBinding = false; - CopyConstructor = 0; + CopyConstructor = nullptr; } /// getRank - Retrieve the rank of this standard conversion sequence @@ -574,7 +574,7 @@ DeductionFailureInfo MakeDeductionFailureInfo(ASTContext &Context, DeductionFailureInfo Result; Result.Result = static_cast(TDK); Result.HasDiagnostic = false; - Result.Data = 0; + Result.Data = nullptr; switch (TDK) { case Sema::TDK_Success: case Sema::TDK_Invalid: @@ -645,12 +645,12 @@ void DeductionFailureInfo::Destroy() { case Sema::TDK_Underqualified: case Sema::TDK_NonDeducedMismatch: // FIXME: Destroy the data? - Data = 0; + Data = nullptr; break; case Sema::TDK_SubstitutionFailure: // FIXME: Destroy the template argument list? - Data = 0; + Data = nullptr; if (PartialDiagnosticAt *Diag = getSFINAEDiagnostic()) { Diag->~PartialDiagnosticAt(); HasDiagnostic = false; @@ -666,7 +666,7 @@ void DeductionFailureInfo::Destroy() { PartialDiagnosticAt *DeductionFailureInfo::getSFINAEDiagnostic() { if (HasDiagnostic) return static_cast(static_cast(Diagnostic)); - return 0; + return nullptr; } TemplateParameter DeductionFailureInfo::getTemplateParameter() { @@ -710,7 +710,7 @@ TemplateArgumentList *DeductionFailureInfo::getTemplateArgumentList() { case Sema::TDK_Underqualified: case Sema::TDK_NonDeducedMismatch: case Sema::TDK_FailedOverloadResolution: - return 0; + return nullptr; case Sema::TDK_SubstitutionFailure: return static_cast(Data); @@ -720,7 +720,7 @@ TemplateArgumentList *DeductionFailureInfo::getTemplateArgumentList() { break; } - return 0; + return nullptr; } const TemplateArgument *DeductionFailureInfo::getFirstArg() { @@ -734,7 +734,7 @@ const TemplateArgument *DeductionFailureInfo::getFirstArg() { case Sema::TDK_InvalidExplicitArguments: case Sema::TDK_SubstitutionFailure: case Sema::TDK_FailedOverloadResolution: - return 0; + return nullptr; case Sema::TDK_Inconsistent: case Sema::TDK_Underqualified: @@ -746,7 +746,7 @@ const TemplateArgument *DeductionFailureInfo::getFirstArg() { break; } - return 0; + return nullptr; } const TemplateArgument *DeductionFailureInfo::getSecondArg() { @@ -760,7 +760,7 @@ const TemplateArgument *DeductionFailureInfo::getSecondArg() { case Sema::TDK_InvalidExplicitArguments: case Sema::TDK_SubstitutionFailure: case Sema::TDK_FailedOverloadResolution: - return 0; + return nullptr; case Sema::TDK_Inconsistent: case Sema::TDK_Underqualified: @@ -772,7 +772,7 @@ const TemplateArgument *DeductionFailureInfo::getSecondArg() { break; } - return 0; + return nullptr; } Expr *DeductionFailureInfo::getExpr() { @@ -780,7 +780,7 @@ Expr *DeductionFailureInfo::getExpr() { Sema::TDK_FailedOverloadResolution) return static_cast(Data); - return 0; + return nullptr; } void OverloadCandidateSet::destroyCandidates() { @@ -830,8 +830,9 @@ namespace { /// without this, they will be immediately diagnosed as errors /// /// Return true on unrecoverable error. -static bool checkPlaceholderForOverload(Sema &S, Expr *&E, - UnbridgedCastsSet *unbridgedCasts = 0) { +static bool +checkPlaceholderForOverload(Sema &S, Expr *&E, + UnbridgedCastsSet *unbridgedCasts = nullptr) { if (const BuiltinType *placeholder = E->getType()->getAsPlaceholderType()) { // We can't handle overloaded expressions here because overload // resolution might reasonably tweak them. @@ -983,7 +984,7 @@ bool Sema::IsOverload(FunctionDecl *New, FunctionDecl *Old, // C++ [temp.fct]p2: // A function template can be overloaded with other function templates // and with normal (non-template) functions. - if ((OldTemplate == 0) != (NewTemplate == 0)) + if ((OldTemplate == nullptr) != (NewTemplate == nullptr)) return true; // Is the function New an overload of the function Old? @@ -1256,7 +1257,7 @@ TryImplicitConversion(Sema &S, Expr *From, QualType ToType, // copy/move constructor, since overloading just assumes that it // exists. When we actually perform initialization, we'll find the // appropriate constructor to copy the returned object, if needed. - ICS.Standard.CopyConstructor = 0; + ICS.Standard.CopyConstructor = nullptr; // Determine whether this is considered a derived-to-base conversion. if (!S.Context.hasSameUnqualifiedType(FromType, ToType)) @@ -1438,7 +1439,7 @@ static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType, SCS.setAsIdentityConversion(); SCS.IncompatibleObjC = false; SCS.setFromType(FromType); - SCS.CopyConstructor = 0; + SCS.CopyConstructor = nullptr; // There are no standard conversions for class types in C++, so // abort early. When overloading in C, however, we do permit @@ -1922,7 +1923,7 @@ bool Sema::IsComplexPromotion(QualType FromType, QualType ToType) { return IsFloatingPointPromotion(FromComplex->getElementType(), ToComplex->getElementType()) || - IsIntegralPromotion(0, FromComplex->getElementType(), + IsIntegralPromotion(nullptr, FromComplex->getElementType(), ToComplex->getElementType()); } @@ -2950,7 +2951,7 @@ IsInitializerListConstructorConversion(Sema &S, Expr *From, QualType ToType, 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(D); if (ConstructorTmpl) @@ -2969,7 +2970,7 @@ IsInitializerListConstructorConversion(Sema &S, Expr *From, QualType ToType, isFirstArgumentCompatibleWithType(S.Context, Constructor, ToType); if (ConstructorTmpl) S.AddTemplateOverloadCandidate(ConstructorTmpl, FoundDecl, - /*ExplicitArgs*/ 0, + /*ExplicitArgs*/ nullptr, From, CandidateSet, SuppressUserConversions); else @@ -3085,7 +3086,7 @@ IsUserDefinedConversion(Sema &S, Expr *From, QualType ToType, 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(D); if (ConstructorTmpl) @@ -3112,7 +3113,7 @@ IsUserDefinedConversion(Sema &S, Expr *From, QualType ToType, } if (ConstructorTmpl) S.AddTemplateOverloadCandidate(ConstructorTmpl, FoundDecl, - /*ExplicitArgs*/ 0, + /*ExplicitArgs*/ nullptr, llvm::makeArrayRef(Args, NumArgs), CandidateSet, SuppressUserConversions); else @@ -4265,7 +4266,7 @@ TryReferenceInit(Sema &S, Expr *Init, QualType DeclType, ICS.Standard.BindsToRvalue = false; ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier = false; ICS.Standard.ObjCLifetimeConversionBinding = ObjCLifetimeConversion; - ICS.Standard.CopyConstructor = 0; + ICS.Standard.CopyConstructor = nullptr; ICS.Standard.DeprecatedStringLiteralToCharPtr = false; // Nothing more to do: the inaccessibility/ambiguity check for @@ -4340,7 +4341,7 @@ TryReferenceInit(Sema &S, Expr *Init, QualType DeclType, ICS.Standard.BindsToRvalue = InitCategory.isRValue(); ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier = false; ICS.Standard.ObjCLifetimeConversionBinding = ObjCLifetimeConversion; - ICS.Standard.CopyConstructor = 0; + ICS.Standard.CopyConstructor = nullptr; ICS.Standard.DeprecatedStringLiteralToCharPtr = false; return ICS; } @@ -4566,7 +4567,7 @@ TryListConversion(Sema &S, InitListExpr *From, QualType ToType, Result.UserDefined.After.setAsIdentityConversion(); Result.UserDefined.After.setFromType(ToType); Result.UserDefined.After.setAllToTypes(ToType); - Result.UserDefined.ConversionFunction = 0; + Result.UserDefined.ConversionFunction = nullptr; } return Result; } @@ -4995,7 +4996,7 @@ ExprResult Sema::CheckConvertedConstantExpression(Expr *From, QualType T, /*InOverloadResolution=*/false, /*CStyle=*/false, /*AllowObjcWritebackConversion=*/false); - StandardConversionSequence *SCS = 0; + StandardConversionSequence *SCS = nullptr; switch (ICS.getKind()) { case ImplicitConversionSequence::StandardConversion: if (!CheckConvertedConstantConversions(*this, ICS.Standard)) @@ -5196,15 +5197,15 @@ diagnoseNoViableConversion(Sema &SemaRef, SourceLocation Loc, Expr *&From, if (SemaRef.isSFINAEContext()) return true; - SemaRef.CheckMemberOperatorAccess(From->getExprLoc(), From, 0, Found); + SemaRef.CheckMemberOperatorAccess(From->getExprLoc(), From, nullptr, Found); ExprResult Result = SemaRef.BuildCXXMemberCallExpr(From, Found, Conversion, HadMultipleCandidates); if (Result.isInvalid()) return true; // Record usage of conversion in an implicit cast. From = ImplicitCastExpr::Create(SemaRef.Context, Result.get()->getType(), - CK_UserDefinedConversion, Result.get(), 0, - Result.get()->getValueKind()); + CK_UserDefinedConversion, Result.get(), + nullptr, Result.get()->getValueKind()); } return false; } @@ -5215,7 +5216,7 @@ static bool recordConversion(Sema &SemaRef, SourceLocation Loc, Expr *&From, DeclAccessPair &Found) { CXXConversionDecl *Conversion = cast(Found->getUnderlyingDecl()); - SemaRef.CheckMemberOperatorAccess(From->getExprLoc(), From, 0, Found); + SemaRef.CheckMemberOperatorAccess(From->getExprLoc(), From, nullptr, Found); QualType ToType = Conversion->getConversionType().getNonReferenceType(); if (!Converter.SuppressConversion) { @@ -5232,8 +5233,8 @@ static bool recordConversion(Sema &SemaRef, SourceLocation Loc, Expr *&From, return true; // Record usage of conversion in an implicit cast. From = ImplicitCastExpr::Create(SemaRef.Context, Result.get()->getType(), - CK_UserDefinedConversion, Result.get(), 0, - Result.get()->getValueKind()); + CK_UserDefinedConversion, Result.get(), + nullptr, Result.get()->getValueKind()); return false; } @@ -5682,12 +5683,12 @@ EnableIfAttr *Sema::CheckEnableIf(FunctionDecl *Function, ArrayRef Args, // FIXME: specific_attr_iterator iterates in reverse order, but // we need to find the first failing one. if (!Function->hasAttrs()) - return 0; + return nullptr; AttrVec Attrs = Function->getAttrs(); AttrVec::iterator E = std::remove_if(Attrs.begin(), Attrs.end(), IsNotEnableIfAttr); if (Attrs.begin() == E) - return 0; + return nullptr; std::reverse(Attrs.begin(), E); SFINAETrap Trap(*this); @@ -5701,7 +5702,7 @@ EnableIfAttr *Sema::CheckEnableIf(FunctionDecl *Function, ArrayRef Args, !isa(Function)) { CXXMethodDecl *Method = cast(Function); ExprResult R = - PerformObjectArgumentInitialization(Args[0], /*Qualifier=*/0, + PerformObjectArgumentInitialization(Args[0], /*Qualifier=*/nullptr, Method, Method); if (R.isInvalid()) { InitializationFailed = true; @@ -5737,7 +5738,7 @@ EnableIfAttr *Sema::CheckEnableIf(FunctionDecl *Function, ArrayRef Args, return EIA; } } - return 0; + return nullptr; } /// \brief Add all of the function declarations in the given function set to @@ -5795,7 +5796,7 @@ void Sema::AddMethodCandidate(DeclAccessPair FoundDecl, assert(isa(TD->getTemplatedDecl()) && "Expected a member function template"); AddMethodTemplateCandidate(TD, FoundDecl, ActingContext, - /*ExplicitArgs*/ 0, + /*ExplicitArgs*/ nullptr, ObjectType, ObjectClassification, Args, CandidateSet, SuppressUserConversions); @@ -5952,7 +5953,7 @@ Sema::AddMethodTemplateCandidate(FunctionTemplateDecl *MethodTmpl, // function template are combined with the set of non-template candidate // functions. TemplateDeductionInfo Info(CandidateSet.getLocation()); - FunctionDecl *Specialization = 0; + FunctionDecl *Specialization = nullptr; if (TemplateDeductionResult Result = DeduceTemplateArguments(MethodTmpl, ExplicitTemplateArgs, Args, Specialization, Info)) { @@ -6002,7 +6003,7 @@ Sema::AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate, // function template are combined with the set of non-template candidate // functions. TemplateDeductionInfo Info(CandidateSet.getLocation()); - FunctionDecl *Specialization = 0; + FunctionDecl *Specialization = nullptr; if (TemplateDeductionResult Result = DeduceTemplateArguments(FunctionTemplate, ExplicitTemplateArgs, Args, Specialization, Info)) { @@ -6252,7 +6253,7 @@ Sema::AddTemplateConversionCandidate(FunctionTemplateDecl *FunctionTemplate, return; TemplateDeductionInfo Info(CandidateSet.getLocation()); - CXXConversionDecl *Specialization = 0; + CXXConversionDecl *Specialization = nullptr; if (TemplateDeductionResult Result = DeduceTemplateArguments(FunctionTemplate, ToType, Specialization, Info)) { @@ -6296,7 +6297,7 @@ void Sema::AddSurrogateCandidate(CXXConversionDecl *Conversion, OverloadCandidate &Candidate = CandidateSet.addCandidate(Args.size() + 1); Candidate.FoundDecl = FoundDecl; - Candidate.Function = 0; + Candidate.Function = nullptr; Candidate.Surrogate = Conversion; Candidate.Viable = true; Candidate.IsSurrogate = true; @@ -6456,8 +6457,8 @@ void Sema::AddBuiltinCandidate(QualType ResultTy, QualType *ParamTys, // Add this candidate OverloadCandidate &Candidate = CandidateSet.addCandidate(Args.size()); - Candidate.FoundDecl = DeclAccessPair::make(0, AS_none); - Candidate.Function = 0; + Candidate.FoundDecl = DeclAccessPair::make(nullptr, AS_none); + Candidate.Function = nullptr; Candidate.IsSurrogate = false; Candidate.IgnoreObjectArgument = false; Candidate.BuiltinTypes.ResultTy = ResultTy; @@ -8802,12 +8803,12 @@ void DiagnoseArityMismatch(Sema &S, Decl *D, unsigned NumFormalArgs) { if (modeCount == 1 && Fn->getParamDecl(0)->getDeclName()) S.Diag(Fn->getLocation(), diag::note_ovl_candidate_arity_one) - << (unsigned) FnKind << (Fn->getDescribedFunctionTemplate() != 0) << mode - << Fn->getParamDecl(0) << NumFormalArgs; + << (unsigned) FnKind << (Fn->getDescribedFunctionTemplate() != nullptr) + << mode << Fn->getParamDecl(0) << NumFormalArgs; else S.Diag(Fn->getLocation(), diag::note_ovl_candidate_arity) - << (unsigned) FnKind << (Fn->getDescribedFunctionTemplate() != 0) << mode - << modeCount << NumFormalArgs; + << (unsigned) FnKind << (Fn->getDescribedFunctionTemplate() != nullptr) + << mode << modeCount << NumFormalArgs; MaybeEmitInheritedConstructorNote(S, Fn); } @@ -9742,7 +9743,7 @@ private: // resulting template argument list is used to generate a single // function template specialization, which is added to the set of // overloaded functions considered. - FunctionDecl *Specialization = 0; + FunctionDecl *Specialization = nullptr; TemplateDeductionInfo Info(FailedCandidates.getLocation()); if (Sema::TemplateDeductionResult Result = S.DeduceTemplateArguments(FunctionTemplate, @@ -9878,7 +9879,7 @@ private: // [...] any function template specializations in the set are // eliminated if the set also contains a non-template function, [...] for (unsigned I = 0, N = Matches.size(); I != N; ) { - if (Matches[I].second->getPrimaryTemplate() == 0) + if (Matches[I].second->getPrimaryTemplate() == nullptr) ++I; else { Matches[I] = Matches[--N]; @@ -9950,12 +9951,12 @@ public: int getNumMatches() const { return Matches.size(); } FunctionDecl* getMatchingFunctionDecl() const { - if (Matches.size() != 1) return 0; + if (Matches.size() != 1) return nullptr; return Matches[0].second; } const DeclAccessPair* getMatchingFunctionAccessPair() const { - if (Matches.size() != 1) return 0; + if (Matches.size() != 1) return nullptr; return &Matches[0].first; } }; @@ -9986,7 +9987,7 @@ Sema::ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, AddressOfFunctionResolver Resolver(*this, AddressOfExpr, TargetType, Complain); int NumMatches = Resolver.getNumMatches(); - FunctionDecl* Fn = 0; + FunctionDecl *Fn = nullptr; if (NumMatches == 0 && Complain) { if (Resolver.IsInvalidFormOfPointerToMemberFunction()) Resolver.ComplainIsInvalidFormOfPointerToMemberFunction(); @@ -10035,7 +10036,7 @@ Sema::ResolveSingleFunctionTemplateSpecialization(OverloadExpr *ovl, // If we didn't actually find any template-ids, we're done. if (!ovl->hasExplicitTemplateArgs()) - return 0; + return nullptr; TemplateArgumentListInfo ExplicitTemplateArgs; ovl->getExplicitTemplateArgs().copyInto(ExplicitTemplateArgs); @@ -10043,7 +10044,7 @@ Sema::ResolveSingleFunctionTemplateSpecialization(OverloadExpr *ovl, // Look through all of the overloaded functions, searching for one // whose type matches exactly. - FunctionDecl *Matched = 0; + FunctionDecl *Matched = nullptr; for (UnresolvedSetIterator I = ovl->decls_begin(), E = ovl->decls_end(); I != E; ++I) { // C++0x [temp.arg.explicit]p3: @@ -10061,7 +10062,7 @@ Sema::ResolveSingleFunctionTemplateSpecialization(OverloadExpr *ovl, // resulting template argument list is used to generate a single // function template specialization, which is added to the set of // overloaded functions considered. - FunctionDecl *Specialization = 0; + FunctionDecl *Specialization = nullptr; TemplateDeductionInfo Info(FailedCandidates.getLocation()); if (TemplateDeductionResult Result = DeduceTemplateArguments(FunctionTemplate, &ExplicitTemplateArgs, @@ -10084,7 +10085,7 @@ Sema::ResolveSingleFunctionTemplateSpecialization(OverloadExpr *ovl, << ovl->getName(); NoteAllOverloadCandidates(ovl); } - return 0; + return nullptr; } Matched = Specialization; @@ -10094,7 +10095,7 @@ Sema::ResolveSingleFunctionTemplateSpecialization(OverloadExpr *ovl, if (Matched && getLangOpts().CPlusPlus1y && Matched->getReturnType()->isUndeducedType() && DeduceReturnType(Matched, ovl->getExprLoc(), Complain)) - return 0; + return nullptr; return Matched; } @@ -10255,7 +10256,7 @@ void Sema::AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE, // It would be nice to avoid this copy. TemplateArgumentListInfo TABuffer; - TemplateArgumentListInfo *ExplicitTemplateArgs = 0; + TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr; if (ULE->hasExplicitTemplateArgs()) { ULE->copyTemplateArgumentsInto(TABuffer); ExplicitTemplateArgs = &TABuffer; @@ -10402,7 +10403,7 @@ DiagnoseTwoPhaseOperatorLookup(Sema &SemaRef, OverloadedOperatorKind Op, LookupResult R(SemaRef, OpName, OpLoc, Sema::LookupOperatorName); return DiagnoseTwoPhaseLookup(SemaRef, OpLoc, CXXScopeSpec(), R, OverloadCandidateSet::CSK_Operator, - /*ExplicitTemplateArgs=*/0, Args); + /*ExplicitTemplateArgs=*/nullptr, Args); } namespace { @@ -10446,7 +10447,7 @@ BuildRecoveryCallExpr(Sema &SemaRef, Scope *S, Expr *Fn, SourceLocation TemplateKWLoc = ULE->getTemplateKeywordLoc(); TemplateArgumentListInfo TABuffer; - TemplateArgumentListInfo *ExplicitTemplateArgs = 0; + TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr; if (ULE->hasExplicitTemplateArgs()) { ULE->copyTemplateArgumentsInto(TABuffer); ExplicitTemplateArgs = &TABuffer; @@ -10455,7 +10456,7 @@ BuildRecoveryCallExpr(Sema &SemaRef, Scope *S, Expr *Fn, LookupResult R(SemaRef, ULE->getName(), ULE->getNameLoc(), Sema::LookupOrdinaryName); FunctionCallFilterCCC Validator(SemaRef, Args.size(), - ExplicitTemplateArgs != 0, + ExplicitTemplateArgs != nullptr, dyn_cast(Fn)); NoTypoCorrectionCCC RejectAll; CorrectionCandidateCallback *CCC = AllowTypoCorrection ? @@ -10489,7 +10490,7 @@ BuildRecoveryCallExpr(Sema &SemaRef, Scope *S, Expr *Fn, // This shouldn't cause an infinite loop because we're giving it // an expression with viable lookup results, which should never // end up here. - return SemaRef.ActOnCallExpr(/*Scope*/ 0, NewFn.take(), LParenLoc, + return SemaRef.ActOnCallExpr(/*Scope*/ nullptr, NewFn.take(), LParenLoc, MultiExprArg(Args.data(), Args.size()), RParenLoc); } @@ -10695,7 +10696,7 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, unsigned OpcIn, if (checkPlaceholderForOverload(*this, Input)) return ExprError(); - Expr *Args[2] = { Input, 0 }; + Expr *Args[2] = { Input, nullptr }; unsigned NumArgs = 1; // For post-increment and post-decrement, add the implicit '0' as @@ -10718,7 +10719,7 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, unsigned OpcIn, VK_RValue, OK_Ordinary, OpLoc)); - CXXRecordDecl *NamingClass = 0; // because lookup ignores member operators + CXXRecordDecl *NamingClass = nullptr; // lookup ignores member operators UnresolvedLookupExpr *Fn = UnresolvedLookupExpr::Create(Context, NamingClass, NestedNameSpecifierLoc(), OpNameInfo, @@ -10741,7 +10742,8 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, unsigned OpcIn, // Add candidates from ADL. AddArgumentDependentLookupCandidates(OpName, OpLoc, ArgsArray, - /*ExplicitTemplateArgs*/0, CandidateSet); + /*ExplicitTemplateArgs*/nullptr, + CandidateSet); // Add builtin operator candidates. AddBuiltinOperatorCandidates(Op, OpLoc, ArgsArray, CandidateSet); @@ -10761,10 +10763,10 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, unsigned OpcIn, // Convert the arguments. if (CXXMethodDecl *Method = dyn_cast(FnDecl)) { - CheckMemberOperatorAccess(OpLoc, Args[0], 0, Best->FoundDecl); + CheckMemberOperatorAccess(OpLoc, Args[0], nullptr, Best->FoundDecl); ExprResult InputRes = - PerformObjectArgumentInitialization(Input, /*Qualifier=*/0, + PerformObjectArgumentInitialization(Input, /*Qualifier=*/nullptr, Best->FoundDecl, Method); if (InputRes.isInvalid()) return ExprError(); @@ -10877,7 +10879,7 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS) { Expr *Args[2] = { LHS, RHS }; - LHS=RHS=0; //Please use only Args instead of LHS/RHS couple + LHS=RHS=nullptr; // Please use only Args instead of LHS/RHS couple BinaryOperator::Opcode Opc = static_cast(OpcIn); OverloadedOperatorKind Op = BinaryOperator::getOverloadedOperator(Opc); @@ -10907,7 +10909,7 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc, } // FIXME: save results of ADL from here? - CXXRecordDecl *NamingClass = 0; // because lookup ignores member operators + CXXRecordDecl *NamingClass = nullptr; // lookup ignores member operators // TODO: provide better source location info in DNLoc component. DeclarationNameInfo OpNameInfo(OpName, OpLoc); UnresolvedLookupExpr *Fn @@ -10955,7 +10957,7 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc, // Add candidates from ADL. AddArgumentDependentLookupCandidates(OpName, OpLoc, Args, - /*ExplicitTemplateArgs*/ 0, + /*ExplicitTemplateArgs*/ nullptr, CandidateSet); // Add builtin operator candidates. @@ -10988,7 +10990,7 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc, return ExprError(); ExprResult Arg0 = - PerformObjectArgumentInitialization(Args[0], /*Qualifier=*/0, + PerformObjectArgumentInitialization(Args[0], /*Qualifier=*/nullptr, Best->FoundDecl, Method); if (Arg0.isInvalid()) return ExprError(); @@ -11154,7 +11156,7 @@ Sema::CreateOverloadedArraySubscriptExpr(SourceLocation LLoc, // expression. if (Args[0]->isTypeDependent() || Args[1]->isTypeDependent()) { - CXXRecordDecl *NamingClass = 0; // because lookup ignores member operators + CXXRecordDecl *NamingClass = nullptr; // lookup ignores member operators // CHECKME: no 'operator' keyword? DeclarationNameInfo OpNameInfo(OpName, LLoc); OpNameInfo.setCXXOperatorNameRange(SourceRange(LLoc, RLoc)); @@ -11208,7 +11210,7 @@ Sema::CreateOverloadedArraySubscriptExpr(SourceLocation LLoc, // Convert the arguments. CXXMethodDecl *Method = cast(FnDecl); ExprResult Arg0 = - PerformObjectArgumentInitialization(Args[0], /*Qualifier=*/0, + PerformObjectArgumentInitialization(Args[0], /*Qualifier=*/nullptr, Best->FoundDecl, Method); if (Arg0.isInvalid()) return ExprError(); @@ -11367,10 +11369,10 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE, resultType, valueKind, RParenLoc); if (CheckCallReturnType(proto->getReturnType(), op->getRHS()->getLocStart(), - call, 0)) + call, nullptr)) return ExprError(); - if (ConvertArgumentsForCall(call, op, 0, proto, Args, RParenLoc)) + if (ConvertArgumentsForCall(call, op, nullptr, proto, Args, RParenLoc)) return ExprError(); if (CheckOtherCall(call, proto)) @@ -11384,9 +11386,9 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE, return ExprError(); MemberExpr *MemExpr; - CXXMethodDecl *Method = 0; - DeclAccessPair FoundDecl = DeclAccessPair::make(0, AS_public); - NestedNameSpecifier *Qualifier = 0; + CXXMethodDecl *Method = nullptr; + DeclAccessPair FoundDecl = DeclAccessPair::make(nullptr, AS_public); + NestedNameSpecifier *Qualifier = nullptr; if (isa(NakedMemExpr)) { MemExpr = cast(NakedMemExpr); Method = cast(MemExpr->getMemberDecl()); @@ -11407,7 +11409,7 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE, OverloadCandidateSet::CSK_Normal); // FIXME: avoid copy. - TemplateArgumentListInfo TemplateArgsBuffer, *TemplateArgs = 0; + TemplateArgumentListInfo TemplateArgsBuffer, *TemplateArgs = nullptr; if (UnresExpr->hasExplicitTemplateArgs()) { UnresExpr->copyTemplateArgumentsInto(TemplateArgsBuffer); TemplateArgs = &TemplateArgsBuffer; @@ -11702,14 +11704,15 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj, UnbridgedCasts.restore(); - if (Best->Function == 0) { + if (Best->Function == nullptr) { // Since there is no function declaration, this is one of the // surrogate candidates. Dig out the conversion function. CXXConversionDecl *Conv = cast( Best->Conversions[0].UserDefined.ConversionFunction); - CheckMemberOperatorAccess(LParenLoc, Object.get(), 0, Best->FoundDecl); + CheckMemberOperatorAccess(LParenLoc, Object.get(), nullptr, + Best->FoundDecl); if (DiagnoseUseOfDecl(Best->FoundDecl, LParenLoc)) return ExprError(); assert(Conv == Best->FoundDecl.getDecl() && @@ -11727,12 +11730,12 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj, // Record usage of conversion in an implicit cast. Call = Owned(ImplicitCastExpr::Create(Context, Call.get()->getType(), CK_UserDefinedConversion, - Call.get(), 0, VK_RValue)); + Call.get(), nullptr, VK_RValue)); return ActOnCallExpr(S, Call.get(), LParenLoc, Args, RParenLoc); } - CheckMemberOperatorAccess(LParenLoc, Object.get(), 0, Best->FoundDecl); + CheckMemberOperatorAccess(LParenLoc, Object.get(), nullptr, Best->FoundDecl); // We found an overloaded operator(). Build a CXXOperatorCallExpr // that calls this method, using Object for the implicit object @@ -11788,7 +11791,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj, // Initialize the implicit object parameter. ExprResult ObjRes = - PerformObjectArgumentInitialization(Object.get(), /*Qualifier=*/0, + PerformObjectArgumentInitialization(Object.get(), /*Qualifier=*/nullptr, Best->FoundDecl, Method); if (ObjRes.isInvalid()) IsError = true; @@ -11830,7 +11833,8 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj, if (Proto->isVariadic()) { // Promote the arguments (C99 6.5.2.2p7). for (unsigned i = NumParams, e = Args.size(); i < e; i++) { - ExprResult Arg = DefaultVariadicArgumentPromotion(Args[i], VariadicMethod, 0); + ExprResult Arg = DefaultVariadicArgumentPromotion(Args[i], VariadicMethod, + nullptr); IsError |= Arg.isInvalid(); TheCall->setArg(i + 1, Arg.take()); } @@ -11931,12 +11935,12 @@ Sema::BuildOverloadedArrowExpr(Scope *S, Expr *Base, SourceLocation OpLoc, return ExprError(); } - CheckMemberOperatorAccess(OpLoc, Base, 0, Best->FoundDecl); + CheckMemberOperatorAccess(OpLoc, Base, nullptr, Best->FoundDecl); // Convert the object parameter. CXXMethodDecl *Method = cast(Best->Function); ExprResult BaseResult = - PerformObjectArgumentInitialization(Base, /*Qualifier=*/0, + PerformObjectArgumentInitialization(Base, /*Qualifier=*/nullptr, Best->FoundDecl, Method); if (BaseResult.isInvalid()) return ExprError(); @@ -12029,7 +12033,7 @@ ExprResult Sema::BuildLiteralOperatorCall(LookupResult &R, if (CheckCallReturnType(FD->getReturnType(), UDSuffixLoc, UDL, FD)) return ExprError(); - if (CheckFunctionCall(FD, UDL, NULL)) + if (CheckFunctionCall(FD, UDL, nullptr)) return ExprError(); return MaybeBindToTemporary(UDL); @@ -12056,16 +12060,16 @@ Sema::BuildForRangeBeginEndCall(Scope *S, SourceLocation Loc, BuildMemberReferenceExpr(Range, Range->getType(), Loc, /*IsPtr=*/false, CXXScopeSpec(), /*TemplateKWLoc=*/SourceLocation(), - /*FirstQualifierInScope=*/0, + /*FirstQualifierInScope=*/nullptr, MemberLookup, - /*TemplateArgs=*/0); + /*TemplateArgs=*/nullptr); if (MemberRef.isInvalid()) { *CallExpr = ExprError(); Diag(Range->getLocStart(), diag::note_in_for_range) << RangeLoc << BEF << Range->getType(); return FRS_DiagnosticIssued; } - *CallExpr = ActOnCallExpr(S, MemberRef.get(), Loc, None, Loc, 0); + *CallExpr = ActOnCallExpr(S, MemberRef.get(), Loc, None, Loc, nullptr); if (CallExpr->isInvalid()) { *CallExpr = ExprError(); Diag(Range->getLocStart(), diag::note_in_for_range) @@ -12075,7 +12079,7 @@ Sema::BuildForRangeBeginEndCall(Scope *S, SourceLocation Loc, } else { UnresolvedSet<0> FoundNames; UnresolvedLookupExpr *Fn = - UnresolvedLookupExpr::Create(Context, /*NamingClass=*/0, + UnresolvedLookupExpr::Create(Context, /*NamingClass=*/nullptr, NestedNameSpecifierLoc(), NameInfo, /*NeedsADL=*/true, /*Overloaded=*/false, FoundNames.begin(), FoundNames.end()); @@ -12095,7 +12099,7 @@ Sema::BuildForRangeBeginEndCall(Scope *S, SourceLocation Loc, return FRS_NoViableFunction; } *CallExpr = FinishOverloadedCallExpr(*this, S, Fn, Fn, Loc, Range, - Loc, 0, CandidateSet, &Best, + Loc, nullptr, CandidateSet, &Best, OverloadResult, /*AllowTypoCorrection=*/false); if (CallExpr->isInvalid() || OverloadResult != OR_Success) { @@ -12137,7 +12141,7 @@ Expr *Sema::FixOverloadedFunctionReference(Expr *E, DeclAccessPair Found, return ImplicitCastExpr::Create(Context, ICE->getType(), ICE->getCastKind(), - SubExpr, 0, + SubExpr, nullptr, ICE->getValueKind()); } @@ -12188,7 +12192,7 @@ Expr *Sema::FixOverloadedFunctionReference(Expr *E, DeclAccessPair Found, if (UnresolvedLookupExpr *ULE = dyn_cast(E)) { // FIXME: avoid copy. - TemplateArgumentListInfo TemplateArgsBuffer, *TemplateArgs = 0; + TemplateArgumentListInfo TemplateArgsBuffer, *TemplateArgs = nullptr; if (ULE->hasExplicitTemplateArgs()) { ULE->copyTemplateArgumentsInto(TemplateArgsBuffer); TemplateArgs = &TemplateArgsBuffer; @@ -12211,7 +12215,7 @@ Expr *Sema::FixOverloadedFunctionReference(Expr *E, DeclAccessPair Found, if (UnresolvedMemberExpr *MemExpr = dyn_cast(E)) { // FIXME: avoid copy. - TemplateArgumentListInfo TemplateArgsBuffer, *TemplateArgs = 0; + TemplateArgumentListInfo TemplateArgsBuffer, *TemplateArgs = nullptr; if (MemExpr->hasExplicitTemplateArgs()) { MemExpr->copyTemplateArgumentsInto(TemplateArgsBuffer); TemplateArgs = &TemplateArgsBuffer; diff --git a/clang/lib/Sema/SemaPseudoObject.cpp b/clang/lib/Sema/SemaPseudoObject.cpp index a28ad5e..94b1943 100644 --- a/clang/lib/Sema/SemaPseudoObject.cpp +++ b/clang/lib/Sema/SemaPseudoObject.cpp @@ -268,7 +268,8 @@ namespace { public: ObjCPropertyOpBuilder(Sema &S, ObjCPropertyRefExpr *refExpr) : PseudoOpBuilder(S, refExpr->getLocation()), RefExpr(refExpr), - SyntacticRefExpr(0), InstanceReceiver(0), Getter(0), Setter(0) { + SyntacticRefExpr(nullptr), InstanceReceiver(nullptr), Getter(nullptr), + Setter(nullptr) { } ExprResult buildRValueOperation(Expr *op); @@ -307,9 +308,9 @@ namespace { ObjCSubscriptOpBuilder(Sema &S, ObjCSubscriptRefExpr *refExpr) : PseudoOpBuilder(S, refExpr->getSourceRange().getBegin()), RefExpr(refExpr), - InstanceBase(0), InstanceKey(0), - AtIndexGetter(0), AtIndexSetter(0) { } - + InstanceBase(nullptr), InstanceKey(nullptr), + AtIndexGetter(nullptr), AtIndexSetter(nullptr) {} + ExprResult buildRValueOperation(Expr *op); ExprResult buildAssignmentOperation(Scope *Sc, SourceLocation opLoc, @@ -579,7 +580,7 @@ bool ObjCPropertyOpBuilder::findGetter() { ObjCPropertyDecl *prop = RefExpr->getExplicitProperty(); Getter = LookupMethodInReceiverType(S, prop->getGetterName(), RefExpr); - return (Getter != 0); + return (Getter != nullptr); } /// Try to find the most accurate setter declaration for the property @@ -644,7 +645,7 @@ bool ObjCPropertyOpBuilder::findSetter(bool warn) { /// Capture the base object of an Objective-C property expression. Expr *ObjCPropertyOpBuilder::rebuildAndCaptureObject(Expr *syntacticBase) { - assert(InstanceReceiver == 0); + assert(InstanceReceiver == nullptr); // If we have a base, capture it in an OVE and rebuild the syntactic // form to use the OVE as its base. @@ -967,8 +968,8 @@ ObjCSubscriptOpBuilder::buildAssignmentOperation(Scope *Sc, /// Capture the base object of an Objective-C Index'ed expression. Expr *ObjCSubscriptOpBuilder::rebuildAndCaptureObject(Expr *syntacticBase) { - assert(InstanceBase == 0); - + assert(InstanceBase == nullptr); + // Capture base expression in an OVE and rebuild the syntactic // form to use the OVE as its base expression. InstanceBase = capture(RefExpr->getBaseExpr()); @@ -1134,7 +1135,7 @@ bool ObjCSubscriptOpBuilder::findAtIndexGetter() { AtIndexGetter = ObjCMethodDecl::Create(S.Context, SourceLocation(), SourceLocation(), AtIndexGetterSelector, S.Context.getObjCIdType() /*ReturnType*/, - 0 /*TypeSourceInfo */, + nullptr /*TypeSourceInfo */, S.Context.getTranslationUnitDecl(), true /*Instance*/, false/*isVariadic*/, /*isPropertyAccessor=*/false, @@ -1147,9 +1148,9 @@ bool ObjCSubscriptOpBuilder::findAtIndexGetter() { : &S.Context.Idents.get("key"), arrayRef ? S.Context.UnsignedLongTy : S.Context.getObjCIdType(), - /*TInfo=*/0, + /*TInfo=*/nullptr, SC_None, - 0); + nullptr); AtIndexGetter->setMethodParams(S.Context, Argument, None); } @@ -1243,7 +1244,7 @@ bool ObjCSubscriptOpBuilder::findAtIndexSetter() { BaseT->isObjCQualifiedIdType()); if (!AtIndexSetter && S.getLangOpts().DebuggerObjCLiteral) { - TypeSourceInfo *ReturnTInfo = 0; + TypeSourceInfo *ReturnTInfo = nullptr; QualType ReturnType = S.Context.VoidTy; AtIndexSetter = ObjCMethodDecl::Create( S.Context, SourceLocation(), SourceLocation(), AtIndexSetterSelector, @@ -1257,9 +1258,9 @@ bool ObjCSubscriptOpBuilder::findAtIndexSetter() { SourceLocation(), SourceLocation(), &S.Context.Idents.get("object"), S.Context.getObjCIdType(), - /*TInfo=*/0, + /*TInfo=*/nullptr, SC_None, - 0); + nullptr); Params.push_back(object); ParmVarDecl *key = ParmVarDecl::Create(S.Context, AtIndexSetter, SourceLocation(), SourceLocation(), @@ -1267,9 +1268,9 @@ bool ObjCSubscriptOpBuilder::findAtIndexSetter() { : &S.Context.Idents.get("key"), arrayRef ? S.Context.UnsignedLongTy : S.Context.getObjCIdType(), - /*TInfo=*/0, + /*TInfo=*/nullptr, SC_None, - 0); + nullptr); Params.push_back(key); AtIndexSetter->setMethodParams(S.Context, Params, None); } @@ -1409,7 +1410,7 @@ ExprResult MSPropertyOpBuilder::buildGet() { ExprResult GetterExpr = S.ActOnMemberAccessExpr( S.getCurScope(), RefExpr->getBaseExpr(), SourceLocation(), RefExpr->isArrow() ? tok::arrow : tok::period, SS, SourceLocation(), - GetterName, 0, true); + GetterName, nullptr, true); if (GetterExpr.isInvalid()) { S.Diag(RefExpr->getMemberLoc(), diag::error_cannot_find_suitable_accessor) << 0 /* getter */ @@ -1439,7 +1440,7 @@ ExprResult MSPropertyOpBuilder::buildSet(Expr *op, SourceLocation sl, ExprResult SetterExpr = S.ActOnMemberAccessExpr( S.getCurScope(), RefExpr->getBaseExpr(), SourceLocation(), RefExpr->isArrow() ? tok::arrow : tok::period, SS, SourceLocation(), - SetterName, 0, true); + SetterName, nullptr, true); if (SetterExpr.isInvalid()) { S.Diag(RefExpr->getMemberLoc(), diag::error_cannot_find_suitable_accessor) << 1 /* setter */ diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp index 83bdc18..7d568ee 100644 --- a/clang/lib/Sema/SemaStmt.cpp +++ b/clang/lib/Sema/SemaStmt.cpp @@ -95,7 +95,7 @@ void Sema::ActOnForEachDeclStmt(DeclGroupPtrTy dg) { // foreach variables are never actually initialized in the way that // the parser came up with. - var->setInit(0); + var->setInit(nullptr); // In ARC, we don't need to retain the iteration variable of a fast // enumeration loop. Rather than actually trying to catch that @@ -289,7 +289,7 @@ void Sema::DiagnoseUnusedExprResult(const Stmt *S) { return; } - DiagRuntimeBehavior(Loc, 0, PDiag(DiagID) << R1 << R2); + DiagRuntimeBehavior(Loc, nullptr, PDiag(DiagID) << R1 << R2); } void Sema::ActOnStartOfCompoundStmt() { @@ -351,7 +351,7 @@ StmtResult Sema::ActOnCaseStmt(SourceLocation CaseLoc, Expr *LHSVal, SourceLocation DotDotDotLoc, Expr *RHSVal, SourceLocation ColonLoc) { - assert((LHSVal != 0) && "missing expression in case statement"); + assert(LHSVal && "missing expression in case statement"); if (getCurFunction()->SwitchStack.empty()) { Diag(CaseLoc, diag::err_case_not_in_switch); @@ -451,7 +451,7 @@ Sema::ActOnIfStmt(SourceLocation IfLoc, FullExprArg CondVal, Decl *CondVar, ExprResult CondResult(CondVal.release()); - VarDecl *ConditionVar = 0; + VarDecl *ConditionVar = nullptr; if (CondVar) { ConditionVar = cast(CondVar); CondResult = CheckConditionVariable(ConditionVar, IfLoc, true); @@ -580,7 +580,7 @@ Sema::ActOnStartOfSwitchStmt(SourceLocation SwitchLoc, Expr *Cond, Decl *CondVar) { ExprResult CondResult; - VarDecl *ConditionVar = 0; + VarDecl *ConditionVar = nullptr; if (CondVar) { ConditionVar = cast(CondVar); CondResult = CheckConditionVariable(ConditionVar, SourceLocation(), false); @@ -757,7 +757,7 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, typedef std::vector > CaseRangesTy; CaseRangesTy CaseRanges; - DefaultStmt *TheDefaultStmt = 0; + DefaultStmt *TheDefaultStmt = nullptr; bool CaseListIsErroneous = false; @@ -964,7 +964,7 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, // Check to see whether the case range overlaps with any // singleton cases. - CaseStmt *OverlapStmt = 0; + CaseStmt *OverlapStmt = nullptr; llvm::APSInt OverlapVal(32); // Find the smallest value >= the lower bound. If I is in the @@ -1208,7 +1208,7 @@ Sema::ActOnWhileStmt(SourceLocation WhileLoc, FullExprArg Cond, Decl *CondVar, Stmt *Body) { ExprResult CondResult(Cond.release()); - VarDecl *ConditionVar = 0; + VarDecl *ConditionVar = nullptr; if (CondVar) { ConditionVar = cast(CondVar); CondResult = CheckConditionVariable(ConditionVar, WhileLoc, true); @@ -1599,8 +1599,8 @@ Sema::ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, for (auto *DI : DS->decls()) { VarDecl *VD = dyn_cast(DI); if (VD && VD->isLocalVarDecl() && !VD->hasLocalStorage()) - VD = 0; - if (VD == 0) { + VD = nullptr; + if (!VD) { Diag(DI->getLocation(), diag::err_non_local_variable_decl_in_for); DI->setInvalidDecl(); } @@ -1615,7 +1615,7 @@ Sema::ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, CheckForRedundantIteration(*this, third.get(), Body); ExprResult SecondResult(second.release()); - VarDecl *ConditionVar = 0; + VarDecl *ConditionVar = nullptr; if (secondVar) { ConditionVar = cast(secondVar); SecondResult = CheckConditionVariable(ConditionVar, ForLoc, true); @@ -1700,7 +1700,7 @@ Sema::CheckObjCForCollectionOperand(SourceLocation forLoc, Expr *collection) { }; Selector selector = Context.Selectors.getSelector(3, &selectorIdents[0]); - ObjCMethodDecl *method = 0; + ObjCMethodDecl *method = nullptr; // If there's an interface, look in both the public and private APIs. if (iface) { @@ -1803,8 +1803,8 @@ Sema::ActOnObjCForCollectionStmt(SourceLocation ForLoc, return StmtError(); return Owned(new (Context) ObjCForCollectionStmt(First, - CollectionExprResult.take(), 0, - ForLoc, RParenLoc)); + CollectionExprResult.take(), + nullptr, ForLoc, RParenLoc)); } /// Finish building a variable declaration for a for-range statement. @@ -1882,7 +1882,7 @@ VarDecl *BuildForRangeVarDecl(Sema &SemaRef, SourceLocation Loc, static bool ObjCEnumerationCollection(Expr *Collection) { return !Collection->isTypeDependent() - && Collection->getType()->getAs() != 0; + && Collection->getType()->getAs() != nullptr; } /// ActOnCXXForRangeStmt - Check and build a C++11 for-range statement. @@ -1950,8 +1950,8 @@ Sema::ActOnCXXForRangeStmt(SourceLocation ForLoc, } return BuildCXXForRangeStmt(ForLoc, ColonLoc, RangeDecl.get(), - /*BeginEndDecl=*/0, /*Cond=*/0, /*Inc=*/0, DS, - RParenLoc, Kind); + /*BeginEndDecl=*/nullptr, /*Cond=*/nullptr, + /*Inc=*/nullptr, DS, RParenLoc, Kind); } /// \brief Create the initialization, compare, and increment steps for @@ -2335,8 +2335,8 @@ Sema::BuildCXXForRangeStmt(SourceLocation ForLoc, SourceLocation ColonLoc, return Owned(new (Context) CXXForRangeStmt(RangeDS, cast_or_null(BeginEndDecl.get()), NotEqExpr.take(), IncrExpr.take(), - LoopVarDS, /*Body=*/0, ForLoc, - ColonLoc, RParenLoc)); + LoopVarDS, /*Body=*/nullptr, + ForLoc, ColonLoc, RParenLoc)); } /// FinishObjCForCollectionStmt - Attach the body to a objective-C foreach @@ -2560,7 +2560,7 @@ Sema::PerformMoveOrCopyInitialization(const InitializedEntity &Entity, // Promote "AsRvalue" to the heap, since we now need this // expression node to persist. Value = ImplicitCastExpr::Create(Context, Value->getType(), - CK_NoOp, Value, 0, VK_XValue); + CK_NoOp, Value, nullptr, VK_XValue); // Complete type-checking the initialization of the return type // using the constructor we found. @@ -2666,7 +2666,7 @@ Sema::ActOnCapScopeReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) { // Otherwise, verify that this result type matches the previous one. We are // pickier with blocks than for normal functions because we don't have GCC // compatibility to worry about here. - const VarDecl *NRVOCandidate = 0; + const VarDecl *NRVOCandidate = nullptr; if (FnRetType->isDependentType()) { // Delay processing for now. TODO: there are lots of dependent // types we can conclusively prove aren't void. @@ -2680,7 +2680,7 @@ Sema::ActOnCapScopeReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) { Diag(ReturnLoc, diag::ext_return_has_void_expr) << "literal" << 2; else { Diag(ReturnLoc, diag::err_return_block_has_expr); - RetValExp = 0; + RetValExp = nullptr; } } } else if (!RetValExp) { @@ -2697,7 +2697,7 @@ Sema::ActOnCapScopeReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) { NRVOCandidate = getCopyElisionCandidate(FnRetType, RetValExp, false); InitializedEntity Entity = InitializedEntity::InitializeResult(ReturnLoc, FnRetType, - NRVOCandidate != 0); + NRVOCandidate != nullptr); ExprResult Res = PerformMoveOrCopyInitialization(Entity, NRVOCandidate, FnRetType, RetValExp); if (Res.isInvalid()) { @@ -2846,7 +2846,7 @@ StmtResult Sema::BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) { QualType FnRetType; QualType RelatedRetType; - const AttrVec *Attrs = 0; + const AttrVec *Attrs = nullptr; bool isObjCMethod = false; if (const FunctionDecl *FD = getCurFunctionDecl()) { @@ -2887,7 +2887,7 @@ StmtResult Sema::BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) { bool HasDependentReturnType = FnRetType->isDependentType(); - ReturnStmt *Result = 0; + ReturnStmt *Result = nullptr; if (FnRetType->isVoidType()) { if (RetValExp) { if (isa(RetValExp)) { @@ -2908,7 +2908,7 @@ StmtResult Sema::BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) { << RetValExp->getSourceRange(); // Drop the expression. - RetValExp = 0; + RetValExp = nullptr; } else if (!RetValExp->isTypeDependent()) { // C99 6.8.6.4p1 (ext_ since GCC warns) unsigned D = diag::ext_return_has_expr; @@ -2963,7 +2963,7 @@ StmtResult Sema::BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) { } } - Result = new (Context) ReturnStmt(ReturnLoc, RetValExp, 0); + Result = new (Context) ReturnStmt(ReturnLoc, RetValExp, nullptr); } else if (!RetValExp && !HasDependentReturnType) { unsigned DiagID = diag::warn_return_missing_expr; // C90 6.6.6.4p4 // C99 6.8.6.4p1 (ext_ since GCC warns) @@ -2976,7 +2976,7 @@ StmtResult Sema::BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) { Result = new (Context) ReturnStmt(ReturnLoc); } else { assert(RetValExp || HasDependentReturnType); - const VarDecl *NRVOCandidate = 0; + const VarDecl *NRVOCandidate = nullptr; QualType RetType = RelatedRetType.isNull() ? FnRetType : RelatedRetType; @@ -2992,7 +2992,7 @@ StmtResult Sema::BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) { // we have a non-void function with an expression, continue checking InitializedEntity Entity = InitializedEntity::InitializeResult(ReturnLoc, RetType, - NRVOCandidate != 0); + NRVOCandidate != nullptr); ExprResult Res = PerformMoveOrCopyInitialization(Entity, NRVOCandidate, RetType, RetValExp); if (Res.isInvalid()) { @@ -3314,11 +3314,12 @@ Sema::CreateCapturedStmtRecordDecl(CapturedDecl *&CD, SourceLocation Loc, while (!(DC->isFunctionOrMethod() || DC->isRecord() || DC->isFileContext())) DC = DC->getParent(); - RecordDecl *RD = 0; + RecordDecl *RD = nullptr; if (getLangOpts().CPlusPlus) - RD = CXXRecordDecl::Create(Context, TTK_Struct, DC, Loc, Loc, /*Id=*/0); + RD = CXXRecordDecl::Create(Context, TTK_Struct, DC, Loc, Loc, + /*Id=*/nullptr); else - RD = RecordDecl::Create(Context, TTK_Struct, DC, Loc, Loc, /*Id=*/0); + RD = RecordDecl::Create(Context, TTK_Struct, DC, Loc, Loc, /*Id=*/nullptr); DC->addDecl(RD); RD->setImplicit(); diff --git a/clang/lib/Sema/SemaStmtAsm.cpp b/clang/lib/Sema/SemaStmtAsm.cpp index e733fd0..6502548 100644 --- a/clang/lib/Sema/SemaStmtAsm.cpp +++ b/clang/lib/Sema/SemaStmtAsm.cpp @@ -381,7 +381,7 @@ ExprResult Sema::LookupInlineAsmIdentifier(CXXScopeSpec &SS, ExprResult Result = ActOnIdExpression(getCurScope(), SS, TemplateKWLoc, Id, /*trailing lparen*/ false, /*is & operand*/ false, - /*CorrectionCandidateCallback=*/0, + /*CorrectionCandidateCallback=*/nullptr, /*IsInlineAsmIdentifier=*/ true); if (IsUnevaluatedContext) @@ -437,7 +437,7 @@ bool Sema::LookupInlineAsmField(StringRef Base, StringRef Member, if (!BaseResult.isSingleResult()) return true; - const RecordType *RT = 0; + const RecordType *RT = nullptr; NamedDecl *FoundDecl = BaseResult.getFoundDecl(); if (VarDecl *VD = dyn_cast(FoundDecl)) RT = VD->getType()->getAs(); diff --git a/clang/lib/Sema/SemaStmtAttr.cpp b/clang/lib/Sema/SemaStmtAttr.cpp index 68d1f622..3bc620b 100644 --- a/clang/lib/Sema/SemaStmtAttr.cpp +++ b/clang/lib/Sema/SemaStmtAttr.cpp @@ -32,11 +32,11 @@ static Attr *handleFallThroughAttr(Sema &S, Stmt *St, const AttributeList &A, S.Diag(L, diag::note_fallthrough_insert_semi_fixit) << FixItHint::CreateInsertion(L, ";"); } - return 0; + return nullptr; } if (S.getCurFunction()->SwitchStack.empty()) { S.Diag(A.getRange().getBegin(), diag::err_fallthrough_attr_outside_switch); - return 0; + return nullptr; } return ::new (S.Context) FallThroughAttr(A.getRange(), S.Context, A.getAttributeSpellingListIndex()); @@ -50,7 +50,7 @@ static Attr *ProcessStmtAttribute(Sema &S, Stmt *St, const AttributeList &A, S.Diag(A.getLoc(), A.isDeclspecAttribute() ? diag::warn_unhandled_ms_attribute_ignored : diag::warn_unknown_attribute_ignored) << A.getName(); - return 0; + return nullptr; case AttributeList::AT_FallThrough: return handleFallThroughAttr(S, St, A, Range); default: @@ -58,7 +58,7 @@ static Attr *ProcessStmtAttribute(Sema &S, Stmt *St, const AttributeList &A, // it as a statement attribute => it is declaration attribute S.Diag(A.getRange().getBegin(), diag::err_attribute_invalid_on_stmt) << A.getName() << St->getLocStart(); - return 0; + return nullptr; } } diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index af80f1a..272c811 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -52,8 +52,8 @@ static NamedDecl *isAcceptableTemplateName(ASTContext &Context, if (isa(D)) { if (!AllowFunctionTemplates && isa(D)) - return 0; - + return nullptr; + return Orig; } @@ -79,10 +79,10 @@ static NamedDecl *isAcceptableTemplateName(ASTContext &Context, return Spec->getSpecializedTemplate(); } - return 0; + return nullptr; } - return 0; + return nullptr; } void Sema::FilterAcceptableTemplateNames(LookupResult &R, @@ -250,7 +250,7 @@ void Sema::LookupTemplateName(LookupResult &Found, bool &MemberOfUnknownSpecialization) { // Determine where to perform name lookup MemberOfUnknownSpecialization = false; - DeclContext *LookupCtx = 0; + DeclContext *LookupCtx = nullptr; bool isDependent = false; if (!ObjectType.isNull()) { // This nested-name-specifier occurs in a member access expression, e.g., @@ -419,10 +419,10 @@ Sema::ActOnDependentIdExpression(const CXXScopeSpec &SS, // Since the 'this' expression is synthesized, we don't need to // perform the double-lookup check. - NamedDecl *FirstQualifierInScope = 0; + NamedDecl *FirstQualifierInScope = nullptr; return Owned(CXXDependentScopeMemberExpr::Create(Context, - /*This*/ 0, ThisType, + /*This*/ nullptr, ThisType, /*IsArrow*/ true, /*Op*/ SourceLocation(), SS.getWithLocInContext(Context), @@ -475,7 +475,7 @@ TemplateDecl *Sema::AdjustDeclIfTemplate(Decl *&D) { D = Temp->getTemplatedDecl(); return Temp; } - return 0; + return nullptr; } ParsedTemplateArgument ParsedTemplateArgument::getTemplatePackExpansion( @@ -716,7 +716,7 @@ Decl *Sema::ActOnNonTypeTemplateParameter(Scope *S, Declarator &D, // template-parameter that is not a template parameter pack. if (Default && IsParameterPack) { Diag(EqualLoc, diag::err_template_param_pack_default_arg); - Default = 0; + Default = nullptr; } // Check the well-formedness of the default template argument, if provided. @@ -907,7 +907,7 @@ Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, if (Previous.isAmbiguous()) return true; - NamedDecl *PrevDecl = 0; + NamedDecl *PrevDecl = nullptr; if (Previous.begin() != Previous.end()) PrevDecl = (*Previous.begin())->getUnderlyingDecl(); @@ -950,7 +950,7 @@ Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, // Declarations in outer scopes don't matter. However, the outermost // context we computed is the semantic context for our new // declaration. - PrevDecl = PrevClassTemplate = 0; + PrevDecl = PrevClassTemplate = nullptr; SemanticContext = OutermostContext; // Check that the chosen semantic context doesn't already contain a @@ -971,7 +971,7 @@ Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, } } else if (PrevDecl && !isDeclInScope(PrevDecl, SemanticContext, S, SS.isValid())) - PrevDecl = PrevClassTemplate = 0; + PrevDecl = PrevClassTemplate = nullptr; if (PrevClassTemplate) { // Ensure that the template parameter lists are compatible. Skip this check @@ -1013,7 +1013,7 @@ Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, // Maybe we will complain about the shadowed template parameter. DiagnoseTemplateParameterShadow(NameLoc, PrevDecl); // Just pretend that we didn't see the previous declaration. - PrevDecl = 0; + PrevDecl = nullptr; } else if (PrevDecl) { // C++ [temp]p5: // A class template shall not have the same name as any other @@ -1032,7 +1032,8 @@ Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, if (!(TUK == TUK_Friend && CurContext->isDependentContext()) && CheckTemplateParameterList( TemplateParams, - PrevClassTemplate ? PrevClassTemplate->getTemplateParameters() : 0, + PrevClassTemplate ? PrevClassTemplate->getTemplateParameters() + : nullptr, (SS.isSet() && SemanticContext && SemanticContext->isRecord() && SemanticContext->isDependentContext()) ? TPC_ClassTemplateMember @@ -1054,7 +1055,7 @@ Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, CXXRecordDecl *NewClass = CXXRecordDecl::Create(Context, Kind, SemanticContext, KWLoc, NameLoc, Name, PrevClassTemplate? - PrevClassTemplate->getTemplatedDecl() : 0, + PrevClassTemplate->getTemplatedDecl() : nullptr, /*DelayTypeCreation=*/true); SetNestedNameSpecifier(NewClass, SS); if (NumOuterTemplateParamLists > 0) @@ -1301,7 +1302,7 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams, // Merge default arguments for template type parameters. TemplateTypeParmDecl *OldTypeParm - = OldParams? cast(*OldParam) : 0; + = OldParams? cast(*OldParam) : nullptr; if (NewTypeParm->isParameterPack()) { assert(!NewTypeParm->hasDefaultArgument() && @@ -1346,7 +1347,7 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams, // Merge default arguments for non-type template parameters NonTypeTemplateParmDecl *OldNonTypeParm - = OldParams? cast(*OldParam) : 0; + = OldParams? cast(*OldParam) : nullptr; if (NewNonTypeParm->isParameterPack()) { assert(!NewNonTypeParm->hasDefaultArgument() && "Parameter packs can't have a default argument!"); @@ -1393,7 +1394,7 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams, // Merge default arguments for template template parameters TemplateTemplateParmDecl *OldTemplateParm - = OldParams? cast(*OldParam) : 0; + = OldParams? cast(*OldParam) : nullptr; if (NewTemplateParm->isParameterPack()) { assert(!NewTemplateParm->hasDefaultArgument() && "Parameter packs can't have a default argument!"); @@ -1766,7 +1767,7 @@ TemplateParameterList *Sema::MatchTemplateParametersToScopeSpecifier( // For a dependent type, the set of template parameters that we // expect to see. - TemplateParameterList *ExpectedTemplateParams = 0; + TemplateParameterList *ExpectedTemplateParams = nullptr; // C++0x [temp.expl.spec]p15: // A member or a member template may be nested within many enclosing @@ -1825,7 +1826,7 @@ TemplateParameterList *Sema::MatchTemplateParametersToScopeSpecifier( if (ParamLists[ParamIdx]->size() == 0) { if (CheckExplicitSpecialization(ParamLists[ParamIdx]->getSourceRange(), false)) - return 0; + return nullptr; } else SawNonEmptyTemplateParameterList = true; } @@ -1846,7 +1847,7 @@ TemplateParameterList *Sema::MatchTemplateParametersToScopeSpecifier( ParamLists[ParamIdx]->getRAngleLoc()) << getRangeOfTypeInNestedNameSpecifier(Context, T, SS); Invalid = true; - return 0; + return nullptr; } // Consume this template header. @@ -1857,7 +1858,7 @@ TemplateParameterList *Sema::MatchTemplateParametersToScopeSpecifier( if (!IsFriend) if (DiagnoseMissingExplicitSpecialization( getRangeOfTypeInNestedNameSpecifier(Context, T, SS))) - return 0; + return nullptr; continue; } @@ -1870,7 +1871,7 @@ TemplateParameterList *Sema::MatchTemplateParametersToScopeSpecifier( if (IsFriend && T->isDependentType()) { if (ParamIdx < ParamLists.size() && DependsOnTemplateParameters(T, ParamLists[ParamIdx])) - ExpectedTemplateParams = 0; + ExpectedTemplateParams = nullptr; else continue; } @@ -1882,9 +1883,9 @@ TemplateParameterList *Sema::MatchTemplateParametersToScopeSpecifier( ExpectedTemplateParams, true, TPL_TemplateMatch)) Invalid = true; - + if (!Invalid && - CheckTemplateParameterList(ParamLists[ParamIdx], 0, + CheckTemplateParameterList(ParamLists[ParamIdx], nullptr, TPC_ClassTemplateMember)) Invalid = true; @@ -1913,11 +1914,11 @@ TemplateParameterList *Sema::MatchTemplateParametersToScopeSpecifier( // Fabricate an empty template parameter list for the invented header. return TemplateParameterList::Create(Context, SourceLocation(), - SourceLocation(), 0, 0, + SourceLocation(), nullptr, 0, SourceLocation()); } - return 0; + return nullptr; } // If there were too many template parameter lists, complain about that now. @@ -1962,7 +1963,7 @@ TemplateParameterList *Sema::MatchTemplateParametersToScopeSpecifier( if (ParamLists.back()->size() == 0 && CheckExplicitSpecialization(ParamLists[ParamIdx]->getSourceRange(), false)) - return 0; + return nullptr; // Return the last template parameter list, which corresponds to the // entity being declared. @@ -2122,7 +2123,7 @@ QualType Sema::CheckTemplateIdType(TemplateName Name, = dyn_cast(Template)) { // Find the class template specialization declaration that // corresponds to these arguments. - void *InsertPos = 0; + void *InsertPos = nullptr; ClassTemplateSpecializationDecl *Decl = ClassTemplate->findSpecialization(Converted.data(), Converted.size(), InsertPos); @@ -2137,7 +2138,7 @@ QualType Sema::CheckTemplateIdType(TemplateName Name, ClassTemplate->getLocation(), ClassTemplate, Converted.data(), - Converted.size(), 0); + Converted.size(), nullptr); ClassTemplate->AddSpecialization(Decl, InsertPos); if (ClassTemplate->isOutOfLine()) Decl->setLexicalDeclContext(ClassTemplate->getLexicalDeclContext()); @@ -2500,8 +2501,8 @@ DeclResult Sema::ActOnVarTemplateSpecialization( } } - void *InsertPos = 0; - VarTemplateSpecializationDecl *PrevDecl = 0; + void *InsertPos = nullptr; + VarTemplateSpecializationDecl *PrevDecl = nullptr; if (IsPartialSpecialization) // FIXME: Template parameter list matters too @@ -2511,7 +2512,7 @@ DeclResult Sema::ActOnVarTemplateSpecialization( PrevDecl = VarTemplate->findSpecialization(Converted.data(), Converted.size(), InsertPos); - VarTemplateSpecializationDecl *Specialization = 0; + VarTemplateSpecializationDecl *Specialization = nullptr; // Check whether we can declare a variable template specialization in // the current scope. @@ -2527,7 +2528,7 @@ DeclResult Sema::ActOnVarTemplateSpecialization( // the list of outer template parameters to reflect our new declaration. Specialization = PrevDecl; Specialization->setLocation(TemplateNameLoc); - PrevDecl = 0; + PrevDecl = nullptr; } else if (IsPartialSpecialization) { // Create a new class template partial specialization declaration node. VarTemplatePartialSpecializationDecl *PrevPartial = @@ -2672,7 +2673,7 @@ Sema::CheckVarTemplateId(VarTemplateDecl *Template, SourceLocation TemplateLoc, // Find the variable template specialization declaration that // corresponds to these arguments. - void *InsertPos = 0; + void *InsertPos = nullptr; if (VarTemplateSpecializationDecl *Spec = Template->findSpecialization( Converted.data(), Converted.size(), InsertPos)) // If we already have a variable template specialization, return it. @@ -2825,7 +2826,7 @@ Sema::CheckVarTemplateId(const CXXScopeSpec &SS, // Build an ordinary singleton decl ref. return BuildDeclarationNameExpr(SS, NameInfo, Var, - /*FoundD=*/0, TemplateArgs); + /*FoundD=*/nullptr, TemplateArgs); } ExprResult Sema::BuildTemplateIdExpr(const CXXScopeSpec &SS, @@ -2887,7 +2888,7 @@ Sema::BuildQualifiedTemplateIdExpr(CXXScopeSpec &SS, bool MemberOfUnknownSpecialization; LookupResult R(*this, NameInfo, LookupOrdinaryName); - LookupTemplateName(R, (Scope*) 0, SS, QualType(), /*Entering*/ false, + LookupTemplateName(R, (Scope*)nullptr, SS, QualType(), /*Entering*/ false, MemberOfUnknownSpecialization); if (R.isAmbiguous()) @@ -2931,7 +2932,7 @@ TemplateNameKind Sema::ActOnDependentTemplateName(Scope *S, diag::ext_template_outside_of_template) << FixItHint::CreateRemoval(TemplateKWLoc); - DeclContext *LookupCtx = 0; + DeclContext *LookupCtx = nullptr; if (SS.isSet()) LookupCtx = computeDeclContext(SS, EnteringContext); if (!LookupCtx && ObjectType) @@ -3133,7 +3134,7 @@ SubstDefaultTemplateArgument(Sema &SemaRef, Template, Converted, SourceRange(TemplateLoc, RAngleLoc)); if (Inst.isInvalid()) - return 0; + return nullptr; TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack, Converted.data(), Converted.size()); @@ -3454,7 +3455,8 @@ bool Sema::CheckTemplateArgument(NamedDecl *Param, ExprResult E = Owned(DependentScopeDeclRefExpr::Create(Context, SS.getWithLocInContext(Context), TemplateKWLoc, - NameInfo, 0)); + NameInfo, + nullptr)); // If we parsed the template argument as a pack expansion, create a // pack expansion expression. @@ -4630,7 +4632,7 @@ static bool CheckTemplateArgumentPointerToMember(Sema &S, // template-parameter shall be one of: [...] // // -- a pointer to member expressed as described in 5.3.1. - DeclRefExpr *DRE = 0; + DeclRefExpr *DRE = nullptr; // In C++98/03 mode, give an extension warning on any extra parentheses. // See http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#773 @@ -4657,7 +4659,7 @@ static bool CheckTemplateArgumentPointerToMember(Sema &S, if (UnOp->getOpcode() == UO_AddrOf) { DRE = dyn_cast(UnOp->getSubExpr()); if (DRE && !DRE->getQualifier()) - DRE = 0; + DRE = nullptr; } } // A constant of pointer-to-member type. @@ -4676,7 +4678,7 @@ static bool CheckTemplateArgumentPointerToMember(Sema &S, } } - DRE = 0; + DRE = nullptr; } if (!DRE) @@ -5161,7 +5163,7 @@ Sema::BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg, QualType ClassType = Context.getTypeDeclType(cast(VD->getDeclContext())); NestedNameSpecifier *Qualifier - = NestedNameSpecifier::Create(Context, 0, false, + = NestedNameSpecifier::Create(Context, nullptr, false, ClassType.getTypePtr()); CXXScopeSpec SS; SS.MakeTrivial(Context, Qualifier, Loc); @@ -5287,7 +5289,8 @@ Sema::BuildExpressionFromIntegralTemplateArgument(const TemplateArgument &Arg, if (OrigT->isEnumeralType()) { // FIXME: This is a hack. We need a better way to handle substituted // non-type template parameters. - E = CStyleCastExpr::Create(Context, OrigT, VK_RValue, CK_IntegralCast, E, 0, + E = CStyleCastExpr::Create(Context, OrigT, VK_RValue, CK_IntegralCast, E, + nullptr, Context.getTrivialTypeSourceInfo(OrigT, Loc), Loc, Loc); } @@ -6040,8 +6043,8 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, } } - void *InsertPos = 0; - ClassTemplateSpecializationDecl *PrevDecl = 0; + void *InsertPos = nullptr; + ClassTemplateSpecializationDecl *PrevDecl = nullptr; if (isPartialSpecialization) // FIXME: Template parameter list matters, too @@ -6054,7 +6057,7 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, = ClassTemplate->findSpecialization(Converted.data(), Converted.size(), InsertPos); - ClassTemplateSpecializationDecl *Specialization = 0; + ClassTemplateSpecializationDecl *Specialization = nullptr; // Check whether we can declare a class template specialization in // the current scope. @@ -6291,7 +6294,7 @@ Decl *Sema::ActOnTemplateDeclarator(Scope *S, Decl *Sema::ActOnStartOfFunctionTemplateDef(Scope *FnBodyScope, MultiTemplateParamsArg TemplateParameterLists, Declarator &D) { - assert(getCurFunctionDecl() == 0 && "Function parsing confused"); + assert(getCurFunctionDecl() == nullptr && "Function parsing confused"); DeclaratorChunk::FunctionTypeInfo &FTI = D.getFunctionTypeInfo(); if (FTI.hasPrototype) { @@ -6628,7 +6631,7 @@ bool Sema::CheckFunctionTemplateSpecialization( // specializing this template. // FIXME: It is somewhat wasteful to build TemplateDeductionInfo Info(FailedCandidates.getLocation()); - FunctionDecl *Specialization = 0; + FunctionDecl *Specialization = nullptr; if (TemplateDeductionResult TDK = DeduceTemplateArguments( cast(FunTmpl->getFirstDecl()), ExplicitTemplateArgs, FT, Specialization, Info)) { @@ -6652,7 +6655,7 @@ bool Sema::CheckFunctionTemplateSpecialization( FD->getLocation(), PDiag(diag::err_function_template_spec_no_match) << FD->getDeclName(), PDiag(diag::err_function_template_spec_ambiguous) - << FD->getDeclName() << (ExplicitTemplateArgs != 0), + << FD->getDeclName() << (ExplicitTemplateArgs != nullptr), PDiag(diag::note_function_template_spec_matched)); if (Result == Candidates.end()) @@ -6721,7 +6724,7 @@ bool Sema::CheckFunctionTemplateSpecialization( const TemplateArgumentList* TemplArgs = new (Context) TemplateArgumentList(Specialization->getTemplateSpecializationArgs()); FD->setFunctionTemplateSpecialization(Specialization->getPrimaryTemplate(), - TemplArgs, /*InsertPos=*/0, + TemplArgs, /*InsertPos=*/nullptr, SpecInfo->getTemplateSpecializationKind(), ExplicitTemplateArgs); @@ -6751,9 +6754,9 @@ Sema::CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous) { assert(!isa(Member) && "Only for non-template members"); // Try to find the member we are instantiating. - NamedDecl *Instantiation = 0; - NamedDecl *InstantiatedFrom = 0; - MemberSpecializationInfo *MSInfo = 0; + NamedDecl *Instantiation = nullptr; + NamedDecl *InstantiatedFrom = nullptr; + MemberSpecializationInfo *MSInfo = nullptr; if (Previous.empty()) { // Nowhere to look anyway. @@ -7060,7 +7063,7 @@ Sema::ActOnExplicitInstantiation(Scope *S, // Find the class template specialization declaration that // corresponds to these arguments. - void *InsertPos = 0; + void *InsertPos = nullptr; ClassTemplateSpecializationDecl *PrevDecl = ClassTemplate->findSpecialization(Converted.data(), Converted.size(), InsertPos); @@ -7077,7 +7080,7 @@ Sema::ActOnExplicitInstantiation(Scope *S, SS.isSet())) return true; - ClassTemplateSpecializationDecl *Specialization = 0; + ClassTemplateSpecializationDecl *Specialization = nullptr; bool HasNoEffect = false; if (PrevDecl) { @@ -7099,7 +7102,7 @@ Sema::ActOnExplicitInstantiation(Scope *S, // (Other source locations will be updated later.) Specialization = PrevDecl; Specialization->setLocation(TemplateNameLoc); - PrevDecl = 0; + PrevDecl = nullptr; } } @@ -7516,7 +7519,7 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S, } // FIXME: Create an ExplicitInstantiation node? - return (Decl*) 0; + return (Decl*) nullptr; } // If the declarator is a template-id, translate the parser's template @@ -7556,10 +7559,11 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S, continue; TemplateDeductionInfo Info(FailedCandidates.getLocation()); - FunctionDecl *Specialization = 0; + FunctionDecl *Specialization = nullptr; if (TemplateDeductionResult TDK = DeduceTemplateArguments(FunTmpl, - (HasExplicitTemplateArgs ? &TemplateArgs : 0), + (HasExplicitTemplateArgs ? &TemplateArgs + : nullptr), R, Specialization, Info)) { // Keep track of almost-matches. FailedCandidates.addCandidate() @@ -7612,7 +7616,7 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S, // FIXME: We may still want to build some representation of this // explicit specialization. if (HasNoEffect) - return (Decl*) 0; + return (Decl*) nullptr; } Specialization->setTemplateSpecializationKind(TSK, D.getIdentifierLoc()); @@ -7649,7 +7653,7 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S, D.getCXXScopeSpec().isSet()); // FIXME: Create some kind of ExplicitInstantiationDecl here. - return (Decl*) 0; + return (Decl*) nullptr; } TypeResult @@ -7861,7 +7865,7 @@ Sema::CheckTypenameType(ElaboratedTypeKeyword Keyword, LookupResult Result(*this, Name, IILoc, LookupOrdinaryName); LookupQualifiedName(Result, Ctx); unsigned DiagID = 0; - Decl *Referenced = 0; + Decl *Referenced = nullptr; switch (Result.getResultKind()) { case LookupResult::NotFound: { // If we're looking up 'type' within a template named 'enable_if', produce diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp index 8a0589a..246107e 100644 --- a/clang/lib/Sema/SemaTemplateDeduction.cpp +++ b/clang/lib/Sema/SemaTemplateDeduction.cpp @@ -126,7 +126,7 @@ DeduceTemplateArgumentsByTypeMatch(Sema &S, unsigned TDF, bool PartialOrdering = false, SmallVectorImpl * - RefParamComparisons = 0); + RefParamComparisons = nullptr); static Sema::TemplateDeductionResult DeduceTemplateArguments(Sema &S, @@ -155,7 +155,7 @@ static NonTypeTemplateParmDecl *getDeducedParameterFromExpr(Expr *E) { if (DeclRefExpr *DRE = dyn_cast(E)) return dyn_cast(DRE->getDecl()); - return 0; + return nullptr; } /// \brief Determine whether two declaration pointers refer to the same @@ -382,7 +382,7 @@ DeduceNonTypeTemplateArgument(Sema &S, assert(NTTP->getDepth() == 0 && "Cannot deduce non-type template argument with depth > 0"); - D = D ? cast(D->getCanonicalDecl()) : 0; + D = D ? cast(D->getCanonicalDecl()) : nullptr; TemplateArgument New(D, NTTP->getType()->isReferenceType()); DeducedTemplateArgument NewDeduced(New); DeducedTemplateArgument Result = checkDeducedTemplateArguments(S.Context, @@ -715,7 +715,7 @@ DeduceTemplateArguments(Sema &S, unsigned TDF, bool PartialOrdering = false, SmallVectorImpl * - RefParamComparisons = 0) { + RefParamComparisons = nullptr) { // Fast-path check to see if we have too many/too few arguments. if (NumParams != NumArgs && !(NumParams && isa(Params[NumParams - 1])) && @@ -2461,7 +2461,7 @@ Sema::DeduceTemplateArguments(VarTemplatePartialSpecializationDecl *Partial, static bool isSimpleTemplateIdType(QualType T) { if (const TemplateSpecializationType *Spec = T->getAs()) - return Spec->getTemplateName().getAsTemplateDecl() != 0; + return Spec->getTemplateName().getAsTemplateDecl() != nullptr; return false; } @@ -2600,7 +2600,7 @@ Sema::SubstituteExplicitTemplateArguments( // and the end of the function-definition, member-declarator, or // declarator. unsigned ThisTypeQuals = 0; - CXXRecordDecl *ThisContext = 0; + CXXRecordDecl *ThisContext = nullptr; if (CXXMethodDecl *Method = dyn_cast(Function)) { ThisContext = Method->getParent(); ThisTypeQuals = Method->getTypeQualifiers(); @@ -3052,7 +3052,7 @@ ResolveOverloadForDeduction(Sema &S, TemplateParameterList *TemplateParams, return QualType(); // Otherwise, see if we can resolve a function type - FunctionDecl *Specialization = 0; + FunctionDecl *Specialization = nullptr; TemplateDeductionInfo Info(Ovl->getNameLoc()); if (S.DeduceTemplateArguments(FunTmpl, &ExplicitTemplateArgs, Specialization, Info)) @@ -3144,7 +3144,7 @@ static bool AdjustFunctionParmAndArgTypesForDeduction(Sema &S, if (ArgType == S.Context.OverloadTy) { ArgType = ResolveOverloadForDeduction(S, TemplateParams, Arg, ParamType, - ParamRefType != 0); + ParamRefType != nullptr); if (ArgType.isNull()) return true; } @@ -3313,7 +3313,7 @@ Sema::TemplateDeductionResult Sema::DeduceTemplateArguments( *ExplicitTemplateArgs, Deduced, ParamTypes, - 0, + nullptr, Info); if (Result) return Result; @@ -3679,7 +3679,7 @@ SpecializeCorrespondingLambdaCallOperatorAndInvoker( FunctionTemplateDecl *CallOpTemplate = CallOpGeneric->getDescribedFunctionTemplate(); - FunctionDecl *CallOpSpecialized = 0; + FunctionDecl *CallOpSpecialized = nullptr; // Use the deduced arguments of the conversion function, to specialize our // generic lambda's call operator. if (Sema::TemplateDeductionResult Result @@ -3705,7 +3705,7 @@ SpecializeCorrespondingLambdaCallOperatorAndInvoker( // specialized our corresponding call operator, we are ready to // specialize the static invoker with the deduced arguments of our // ptr-to-function. - FunctionDecl *InvokerSpecialized = 0; + FunctionDecl *InvokerSpecialized = nullptr; FunctionTemplateDecl *InvokerTemplate = LambdaClass-> getLambdaStaticInvoker()->getDescribedFunctionTemplate(); @@ -3848,7 +3848,7 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *ConversionTemplate, // Create an Instantiation Scope for finalizing the operator. LocalInstantiationScope InstScope(*this); // Finish template argument deduction. - FunctionDecl *ConversionSpecialized = 0; + FunctionDecl *ConversionSpecialized = nullptr; TemplateDeductionResult Result = FinishTemplateArgumentDeduction(ConversionTemplate, Deduced, 0, ConversionSpecialized, Info); @@ -4017,8 +4017,8 @@ Sema::DeduceAutoType(TypeLoc Type, Expr *&Init, QualType &Result) { // Build template void Func(FuncParam); TemplateTypeParmDecl *TemplParam = - TemplateTypeParmDecl::Create(Context, 0, SourceLocation(), Loc, 0, 0, 0, - false, false); + TemplateTypeParmDecl::Create(Context, nullptr, SourceLocation(), Loc, 0, 0, + nullptr, false, false); QualType TemplArg = QualType(TemplParam->getTypeForDecl(), 0); NamedDecl *TemplParamPtr = TemplParam; FixedSizeTemplateParameterList<1> TemplateParams(Loc, Loc, &TemplParamPtr, @@ -4363,7 +4363,7 @@ Sema::getMoreSpecializedTemplate(FunctionTemplateDecl *FT1, unsigned NumCallArguments2) { SmallVector RefParamComparisons; bool Better1 = isAtLeastAsSpecializedAs(*this, Loc, FT1, FT2, TPOC, - NumCallArguments1, 0); + NumCallArguments1, nullptr); bool Better2 = isAtLeastAsSpecializedAs(*this, Loc, FT2, FT1, TPOC, NumCallArguments2, &RefParamComparisons); @@ -4372,7 +4372,7 @@ Sema::getMoreSpecializedTemplate(FunctionTemplateDecl *FT1, return Better1? FT1 : FT2; if (!Better1 && !Better2) // Neither is better than the other - return 0; + return nullptr; // C++0x [temp.deduct.partial]p10: // If for each type being considered a given template is at least as @@ -4398,13 +4398,13 @@ Sema::getMoreSpecializedTemplate(FunctionTemplateDecl *FT1, RefParamComparisons[I].ParamIsRvalueRef) { Better2 = true; if (Better1) - return 0; + return nullptr; continue; } else if (!RefParamComparisons[I].ParamIsRvalueRef && RefParamComparisons[I].ArgIsRvalueRef) { Better1 = true; if (Better2) - return 0; + return nullptr; continue; } @@ -4419,13 +4419,13 @@ Sema::getMoreSpecializedTemplate(FunctionTemplateDecl *FT1, case ParamMoreQualified: Better1 = true; if (Better2) - return 0; + return nullptr; continue; case ArgMoreQualified: Better2 = true; if (Better1) - return 0; + return nullptr; continue; } @@ -4446,7 +4446,7 @@ Sema::getMoreSpecializedTemplate(FunctionTemplateDecl *FT1, if (Variadic1 != Variadic2) return Variadic1? FT2 : FT1; - return 0; + return nullptr; } /// \brief Determine if the two templates are equivalent. @@ -4611,7 +4611,7 @@ Sema::getMoreSpecializedPartialSpecialization( PS2->getTemplateParameters(), PT2, PT1, Info, Deduced, TDF_None, /*PartialOrdering=*/true, - /*RefParamComparisons=*/0); + /*RefParamComparisons=*/nullptr); if (Better1) { SmallVector DeducedArgs(Deduced.begin(),Deduced.end()); InstantiatingTemplate Inst(*this, Loc, PS2, DeducedArgs, Info); @@ -4625,7 +4625,7 @@ Sema::getMoreSpecializedPartialSpecialization( bool Better2 = !DeduceTemplateArgumentsByTypeMatch( *this, PS1->getTemplateParameters(), PT1, PT2, Info, Deduced, TDF_None, /*PartialOrdering=*/true, - /*RefParamComparisons=*/0); + /*RefParamComparisons=*/nullptr); if (Better2) { SmallVector DeducedArgs(Deduced.begin(), Deduced.end()); @@ -4635,7 +4635,7 @@ Sema::getMoreSpecializedPartialSpecialization( } if (Better1 == Better2) - return 0; + return nullptr; return Better1 ? PS1 : PS2; } @@ -4669,7 +4669,7 @@ Sema::getMoreSpecializedPartialSpecialization( bool Better1 = !DeduceTemplateArgumentsByTypeMatch( *this, PS2->getTemplateParameters(), PT2, PT1, Info, Deduced, TDF_None, /*PartialOrdering=*/true, - /*RefParamComparisons=*/0); + /*RefParamComparisons=*/nullptr); if (Better1) { SmallVector DeducedArgs(Deduced.begin(), Deduced.end()); @@ -4686,7 +4686,7 @@ Sema::getMoreSpecializedPartialSpecialization( PS1->getTemplateParameters(), PT1, PT2, Info, Deduced, TDF_None, /*PartialOrdering=*/true, - /*RefParamComparisons=*/0); + /*RefParamComparisons=*/nullptr); if (Better2) { SmallVector DeducedArgs(Deduced.begin(),Deduced.end()); InstantiatingTemplate Inst(*this, Loc, PS1, DeducedArgs, Info); @@ -4696,7 +4696,7 @@ Sema::getMoreSpecializedPartialSpecialization( } if (Better1 == Better2) - return 0; + return nullptr; return Better1? PS1 : PS2; } diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp index 657ea64..fae1222 100644 --- a/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -532,8 +532,8 @@ void Sema::PrintInstantiationStack() { std::string Name; if (!Parm->getName().empty()) Name = std::string(" '") + Parm->getName().str() + "'"; - - TemplateParameterList *TemplateParams = 0; + + TemplateParameterList *TemplateParams = nullptr; if (TemplateDecl *Template = dyn_cast(Active->Template)) TemplateParams = Template->getTemplateParameters(); else @@ -552,7 +552,7 @@ void Sema::PrintInstantiationStack() { } case ActiveTemplateInstantiation::DefaultTemplateArgumentChecking: { - TemplateParameterList *TemplateParams = 0; + TemplateParameterList *TemplateParams = nullptr; if (TemplateDecl *Template = dyn_cast(Active->Template)) TemplateParams = Template->getTemplateParameters(); else @@ -581,7 +581,7 @@ void Sema::PrintInstantiationStack() { Optional Sema::isSFINAEContext() const { if (InNonInstantiationSFINAEContext) - return Optional(0); + return Optional(nullptr); for (SmallVectorImpl::const_reverse_iterator Active = ActiveTemplateInstantiations.rbegin(), @@ -761,11 +761,11 @@ namespace { NestedNameSpecifierLoc QualifierLoc, QualType T); - TemplateName TransformTemplateName(CXXScopeSpec &SS, - TemplateName Name, - SourceLocation NameLoc, - QualType ObjectType = QualType(), - NamedDecl *FirstQualifierInScope = 0); + TemplateName + TransformTemplateName(CXXScopeSpec &SS, TemplateName Name, + SourceLocation NameLoc, + QualType ObjectType = QualType(), + NamedDecl *FirstQualifierInScope = nullptr); ExprResult TransformPredefinedExpr(PredefinedExpr *E); ExprResult TransformDeclRefExpr(DeclRefExpr *E); @@ -885,7 +885,7 @@ getPackSubstitutedTemplateArgument(Sema &S, TemplateArgument Arg) { Decl *TemplateInstantiator::TransformDecl(SourceLocation Loc, Decl *D) { if (!D) - return 0; + return nullptr; if (TemplateTemplateParmDecl *TTP = dyn_cast(D)) { if (TTP->getDepth() < TemplateArgs.getNumLevels()) { @@ -921,7 +921,7 @@ Decl *TemplateInstantiator::TransformDecl(SourceLocation Loc, Decl *D) { Decl *TemplateInstantiator::TransformDefinition(SourceLocation Loc, Decl *D) { Decl *Inst = getSema().SubstDecl(D, getSema().CurContext, TemplateArgs); if (!Inst) - return 0; + return nullptr; getSema().CurrentInstantiationScope->InstantiatedLocal(D, Inst); return Inst; @@ -945,8 +945,8 @@ TemplateInstantiator::TransformFirstQualifierInScope(NamedDecl *D, "Missing argument pack"); if (getSema().ArgumentPackSubstitutionIndex == -1) - return 0; - + return nullptr; + Arg = getPackSubstitutedTemplateArgument(getSema(), Arg); } @@ -959,7 +959,7 @@ TemplateInstantiator::TransformFirstQualifierInScope(NamedDecl *D, // The resulting type is not a tag; complain. getSema().Diag(Loc, diag::err_nested_name_spec_non_tag) << T; - return 0; + return nullptr; } } @@ -1155,7 +1155,7 @@ ExprResult TemplateInstantiator::transformNonTypeTemplateParmRef( return ExprError(); } else { // Propagate NULL template argument. - VD = 0; + VD = nullptr; } // Derive the type we want the substituted decl to have. This had @@ -1393,7 +1393,7 @@ TemplateInstantiator::TransformTemplateTypeParmType(TypeLocBuilder &TLB, // the template parameter list of a member template inside the // template we are instantiating). Create a new template type // parameter with the template "level" reduced by one. - TemplateTypeParmDecl *NewTTPDecl = 0; + TemplateTypeParmDecl *NewTTPDecl = nullptr; if (TemplateTypeParmDecl *OldTTPDecl = T->getDecl()) NewTTPDecl = cast_or_null( TransformDecl(TL.getNameLoc(), OldTTPDecl)); @@ -1486,7 +1486,7 @@ TypeSourceInfo *Sema::SubstType(TypeLoc TL, "instantiation stack"); if (TL.getType().isNull()) - return 0; + return nullptr; if (!TL.getType()->isInstantiationDependentType() && !TL.getType()->isVariablyModifiedType()) { @@ -1502,7 +1502,7 @@ TypeSourceInfo *Sema::SubstType(TypeLoc TL, TLB.reserve(TL.getFullDataSize()); QualType Result = Instantiator.TransformType(TLB, TL); if (Result.isNull()) - return 0; + return nullptr; return TLB.getTypeSourceInfo(Context, Result); } @@ -1588,7 +1588,7 @@ TypeSourceInfo *Sema::SubstFunctionDeclType(TypeSourceInfo *T, Result = Instantiator.TransformType(TLB, TL); } if (Result.isNull()) - return 0; + return nullptr; return TLB.getTypeSourceInfo(Context, Result); } @@ -1599,8 +1599,8 @@ ParmVarDecl *Sema::SubstParmVarDecl(ParmVarDecl *OldParm, Optional NumExpansions, bool ExpectParameterPack) { TypeSourceInfo *OldDI = OldParm->getTypeSourceInfo(); - TypeSourceInfo *NewDI = 0; - + TypeSourceInfo *NewDI = nullptr; + TypeLoc OldTL = OldDI->getTypeLoc(); if (PackExpansionTypeLoc ExpansionTL = OldTL.getAs()) { @@ -1609,8 +1609,8 @@ ParmVarDecl *Sema::SubstParmVarDecl(ParmVarDecl *OldParm, NewDI = SubstType(ExpansionTL.getPatternLoc(), TemplateArgs, OldParm->getLocation(), OldParm->getDeclName()); if (!NewDI) - return 0; - + return nullptr; + if (NewDI->getType()->containsUnexpandedParameterPack()) { // We still have unexpanded parameter packs, which means that // our function parameter is still a function parameter pack. @@ -1625,7 +1625,7 @@ ParmVarDecl *Sema::SubstParmVarDecl(ParmVarDecl *OldParm, Diag(OldParm->getLocation(), diag::err_function_parameter_pack_without_parameter_packs) << NewDI->getType(); - return 0; + return nullptr; } } else { NewDI = SubstType(OldDI, TemplateArgs, OldParm->getLocation(), @@ -1633,11 +1633,11 @@ ParmVarDecl *Sema::SubstParmVarDecl(ParmVarDecl *OldParm, } if (!NewDI) - return 0; + return nullptr; if (NewDI->getType()->isVoidType()) { Diag(OldParm->getLocation(), diag::err_param_with_void_type); - return 0; + return nullptr; } ParmVarDecl *NewParm = CheckParameter(Context.getTranslationUnitDecl(), @@ -1647,8 +1647,8 @@ ParmVarDecl *Sema::SubstParmVarDecl(ParmVarDecl *OldParm, NewDI->getType(), NewDI, OldParm->getStorageClass()); if (!NewParm) - return 0; - + return nullptr; + // Mark the (new) default argument as uninstantiated (if any). if (OldParm->hasUninstantiatedDefaultArg()) { Expr *Arg = OldParm->getUninstantiatedDefaultArg(); @@ -1698,8 +1698,9 @@ bool Sema::SubstParmTypes(SourceLocation Loc, TemplateInstantiator Instantiator(*this, TemplateArgs, Loc, DeclarationName()); - return Instantiator.TransformFunctionTypeParams(Loc, Params, NumParams, 0, - ParamTypes, OutParams); + return Instantiator.TransformFunctionTypeParams(Loc, Params, NumParams, + nullptr, ParamTypes, + OutParams); } /// \brief Perform substitution on the base class specifiers of the @@ -2012,8 +2013,8 @@ Sema::InstantiateClass(SourceLocation PointOfInstantiation, } // Finish checking fields. - ActOnFields(0, Instantiation->getLocation(), Instantiation, Fields, - SourceLocation(), SourceLocation(), 0); + ActOnFields(nullptr, Instantiation->getLocation(), Instantiation, Fields, + SourceLocation(), SourceLocation(), nullptr); CheckCompletedCXXClass(Instantiation); // Attach any in-class member initializers now the class is complete. @@ -2228,7 +2229,7 @@ bool Sema::InstantiateClassTemplateSpecialization( return true; ClassTemplateDecl *Template = ClassTemplateSpec->getSpecializedTemplate(); - CXXRecordDecl *Pattern = 0; + CXXRecordDecl *Pattern = nullptr; // C++ [temp.class.spec.match]p1: // When a class template is used in a context that requires an @@ -2684,7 +2685,7 @@ LocalInstantiationScope::findInstantiationOf(const Decl *D) { if (const TagDecl *Tag = dyn_cast(CheckD)) CheckD = Tag->getPreviousDecl(); else - CheckD = 0; + CheckD = nullptr; } while (CheckD); // If we aren't combined with our outer scope, we're done. @@ -2696,13 +2697,13 @@ LocalInstantiationScope::findInstantiationOf(const Decl *D) { // deduction, we may not have values for template parameters yet. if (isa(D) || isa(D) || isa(D)) - return 0; + return nullptr; // If we didn't find the decl, then we either have a sema bug, or we have a // forward reference to a label declaration. Return null to indicate that // we have an uninstantiated label. assert(isa(D) && "declaration not instantiated in this scope"); - return 0; + return nullptr; } void LocalInstantiationScope::InstantiatedLocal(const Decl *D, Decl *Inst) { @@ -2749,7 +2750,7 @@ NamedDecl *LocalInstantiationScope::getPartiallySubstitutedPack( const TemplateArgument **ExplicitArgs, unsigned *NumExplicitArgs) const { if (ExplicitArgs) - *ExplicitArgs = 0; + *ExplicitArgs = nullptr; if (NumExplicitArgs) *NumExplicitArgs = 0; @@ -2767,6 +2768,6 @@ NamedDecl *LocalInstantiationScope::getPartiallySubstitutedPack( if (!Current->CombineWithOuterScope) break; } - - return 0; + + return nullptr; } diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 66afaaa..2a0f56b 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -132,7 +132,7 @@ static void instantiateDependentAlignedAttr( static void instantiateDependentEnableIfAttr( Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const EnableIfAttr *A, const Decl *Tmpl, Decl *New) { - Expr *Cond = 0; + Expr *Cond = nullptr; { EnterExpressionEvaluationContext Unevaluated(S, Sema::Unevaluated); ExprResult Result = S.SubstExpr(A->getCond(), TemplateArgs); @@ -187,7 +187,7 @@ void Sema::InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs, if (TmplAttr->isLateParsed() && LateAttrs) { // Late parsed attributes must be instantiated and attached after the // enclosing class has been instantiated. See Sema::InstantiateClass. - LocalInstantiationScope *Saved = 0; + LocalInstantiationScope *Saved = nullptr; if (CurrentInstantiationScope) Saved = CurrentInstantiationScope->cloneScopes(OuterMostScope); LateAttrs->push_back(LateInstantiatedAttribute(TmplAttr, Saved, New)); @@ -297,7 +297,7 @@ Decl *TemplateDeclInstantiator::InstantiateTypedefNameDecl(TypedefNameDecl *D, NamedDecl *InstPrev = SemaRef.FindInstantiatedDecl(D->getLocation(), Prev, TemplateArgs); if (!InstPrev) - return 0; + return nullptr; TypedefNameDecl *InstPrevTypedef = cast(InstPrev); @@ -335,11 +335,11 @@ TemplateDeclInstantiator::VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D) { TemplateParameterList *TempParams = D->getTemplateParameters(); TemplateParameterList *InstParams = SubstTemplateParams(TempParams); if (!InstParams) - return 0; + return nullptr; TypeAliasDecl *Pattern = D->getTemplatedDecl(); - TypeAliasTemplateDecl *PrevAliasTemplate = 0; + TypeAliasTemplateDecl *PrevAliasTemplate = nullptr; if (Pattern->getPreviousDecl()) { DeclContext::lookup_result Found = Owner->lookup(Pattern->getDeclName()); if (!Found.empty()) { @@ -350,7 +350,7 @@ TemplateDeclInstantiator::VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D) { TypeAliasDecl *AliasInst = cast_or_null( InstantiateTypedefNameDecl(Pattern, /*IsTypeAlias=*/true)); if (!AliasInst) - return 0; + return nullptr; TypeAliasTemplateDecl *Inst = TypeAliasTemplateDecl::Create(SemaRef.Context, Owner, D->getLocation(), @@ -380,7 +380,7 @@ Decl *TemplateDeclInstantiator::VisitVarDecl(VarDecl *D, if (const RecordType *RecordTy = D->getType()->getAs()) if (RecordTy->getDecl()->isAnonymousStructOrUnion()) if (!VisitCXXRecordDecl(cast(RecordTy->getDecl()))) - return 0; + return nullptr; // Do substitution on the type of the declaration TypeSourceInfo *DI = SemaRef.SubstType(D->getTypeSourceInfo(), @@ -388,12 +388,12 @@ Decl *TemplateDeclInstantiator::VisitVarDecl(VarDecl *D, D->getTypeSpecStartLoc(), D->getDeclName()); if (!DI) - return 0; + return nullptr; if (DI->getType()->isFunctionType()) { SemaRef.Diag(D->getLocation(), diag::err_variable_instantiates_to_function) << D->isStaticDataMember() << DI->getType(); - return 0; + return nullptr; } DeclContext *DC = Owner; @@ -412,7 +412,7 @@ Decl *TemplateDeclInstantiator::VisitVarDecl(VarDecl *D, // Substitute the nested name specifier, if any. if (SubstQualifier(D, Var)) - return 0; + return nullptr; SemaRef.BuildVariableInstantiation(Var, D, TemplateArgs, LateAttrs, Owner, StartingScope, InstantiatingVarTemplate); @@ -461,7 +461,7 @@ Decl *TemplateDeclInstantiator::VisitFieldDecl(FieldDecl *D) { Expr *BitWidth = D->getBitWidth(); if (Invalid) - BitWidth = 0; + BitWidth = nullptr; else if (BitWidth) { // The bit-width expression is a constant expression. EnterExpressionEvaluationContext Unevaluated(SemaRef, @@ -471,7 +471,7 @@ Decl *TemplateDeclInstantiator::VisitFieldDecl(FieldDecl *D) { = SemaRef.SubstExpr(BitWidth, TemplateArgs); if (InstantiatedBitWidth.isInvalid()) { Invalid = true; - BitWidth = 0; + BitWidth = nullptr; } else BitWidth = InstantiatedBitWidth.takeAs(); } @@ -485,10 +485,10 @@ Decl *TemplateDeclInstantiator::VisitFieldDecl(FieldDecl *D) { D->getInClassInitStyle(), D->getInnerLocStart(), D->getAccess(), - 0); + nullptr); if (!Field) { cast(Owner)->setInvalidDecl(); - return 0; + return nullptr; } SemaRef.InstantiateAttrs(TemplateArgs, D, Field, LateAttrs, StartingScope); @@ -570,7 +570,7 @@ Decl *TemplateDeclInstantiator::VisitIndirectFieldDecl(IndirectFieldDecl *D) { NamedDecl *Next = SemaRef.FindInstantiatedDecl(D->getLocation(), PI, TemplateArgs); if (!Next) - return 0; + return nullptr; NamedChain[i++] = Next; } @@ -604,12 +604,12 @@ Decl *TemplateDeclInstantiator::VisitFriendDecl(FriendDecl *D) { D->getLocation(), DeclarationName()); } if (!InstTy) - return 0; + return nullptr; FriendDecl *FD = SemaRef.CheckFriendTypeDecl(D->getLocStart(), D->getFriendLoc(), InstTy); if (!FD) - return 0; + return nullptr; FD->setAccess(AS_public); FD->setUnsupportedFriend(D->isUnsupportedFriend()); @@ -625,7 +625,7 @@ Decl *TemplateDeclInstantiator::VisitFriendDecl(FriendDecl *D) { // objects, with the most important detail being that the target // decl should almost certainly not be placed in Owner. Decl *NewND = Visit(ND); - if (!NewND) return 0; + if (!NewND) return nullptr; FriendDecl *FD = FriendDecl::Create(SemaRef.Context, Owner, D->getLocation(), @@ -646,7 +646,7 @@ Decl *TemplateDeclInstantiator::VisitStaticAssertDecl(StaticAssertDecl *D) { ExprResult InstantiatedAssertExpr = SemaRef.SubstExpr(AssertExpr, TemplateArgs); if (InstantiatedAssertExpr.isInvalid()) - return 0; + return nullptr; return SemaRef.BuildStaticAssertDeclaration(D->getLocation(), InstantiatedAssertExpr.get(), @@ -656,12 +656,12 @@ Decl *TemplateDeclInstantiator::VisitStaticAssertDecl(StaticAssertDecl *D) { } Decl *TemplateDeclInstantiator::VisitEnumDecl(EnumDecl *D) { - EnumDecl *PrevDecl = 0; + EnumDecl *PrevDecl = nullptr; if (D->getPreviousDecl()) { NamedDecl *Prev = SemaRef.FindInstantiatedDecl(D->getLocation(), D->getPreviousDecl(), TemplateArgs); - if (!Prev) return 0; + if (!Prev) return nullptr; PrevDecl = cast(Prev); } @@ -694,7 +694,7 @@ Decl *TemplateDeclInstantiator::VisitEnumDecl(EnumDecl *D) { Enum->setAccess(D->getAccess()); // Forward the mangling number from the template to the instantiated decl. SemaRef.Context.setManglingNumber(Enum, SemaRef.Context.getManglingNumber(D)); - if (SubstQualifier(D, Enum)) return 0; + if (SubstQualifier(D, Enum)) return nullptr; Owner->addDecl(Enum); EnumDecl *Def = D->getDefinition(); @@ -736,10 +736,10 @@ void TemplateDeclInstantiator::InstantiateEnumDefinition( SmallVector Enumerators; - EnumConstantDecl *LastEnumConst = 0; + EnumConstantDecl *LastEnumConst = nullptr; for (auto *EC : Pattern->enumerators()) { // The specified value for the enumerator. - ExprResult Value = SemaRef.Owned((Expr *)0); + ExprResult Value = SemaRef.Owned((Expr *)nullptr); if (Expr *UninstValue = EC->getInitExpr()) { // The enumerator's value expression is a constant expression. EnterExpressionEvaluationContext Unevaluated(SemaRef, @@ -751,7 +751,7 @@ void TemplateDeclInstantiator::InstantiateEnumDefinition( // Drop the initial value and continue. bool isInvalid = false; if (Value.isInvalid()) { - Value = SemaRef.Owned((Expr *)0); + Value = SemaRef.Owned((Expr *)nullptr); isInvalid = true; } @@ -787,7 +787,7 @@ void TemplateDeclInstantiator::InstantiateEnumDefinition( SemaRef.ActOnEnumBody(Enum->getLocation(), SourceLocation(), Enum->getRBraceLoc(), Enum, Enumerators, - 0, 0); + nullptr, nullptr); } Decl *TemplateDeclInstantiator::VisitEnumConstantDecl(EnumConstantDecl *D) { @@ -803,7 +803,7 @@ Decl *TemplateDeclInstantiator::VisitClassTemplateDecl(ClassTemplateDecl *D) { TemplateParameterList *TempParams = D->getTemplateParameters(); TemplateParameterList *InstParams = SubstTemplateParams(TempParams); if (!InstParams) - return NULL; + return nullptr; CXXRecordDecl *Pattern = D->getTemplatedDecl(); @@ -815,11 +815,11 @@ Decl *TemplateDeclInstantiator::VisitClassTemplateDecl(ClassTemplateDecl *D) { QualifierLoc = SemaRef.SubstNestedNameSpecifierLoc(QualifierLoc, TemplateArgs); if (!QualifierLoc) - return 0; + return nullptr; } - CXXRecordDecl *PrevDecl = 0; - ClassTemplateDecl *PrevClassTemplate = 0; + CXXRecordDecl *PrevDecl = nullptr; + ClassTemplateDecl *PrevClassTemplate = nullptr; if (!isFriend && Pattern->getPreviousDecl()) { DeclContext::lookup_result Found = Owner->lookup(Pattern->getDeclName()); @@ -840,7 +840,7 @@ Decl *TemplateDeclInstantiator::VisitClassTemplateDecl(ClassTemplateDecl *D) { CXXScopeSpec SS; SS.Adopt(QualifierLoc); DC = SemaRef.computeDeclContext(SS); - if (!DC) return 0; + if (!DC) return nullptr; } else { DC = SemaRef.FindInstantiatedContext(Pattern->getLocation(), Pattern->getDeclContext(), @@ -863,7 +863,7 @@ Decl *TemplateDeclInstantiator::VisitClassTemplateDecl(ClassTemplateDecl *D) { SemaRef.Diag(Pattern->getLocation(), diag::err_not_tag_in_scope) << D->getTemplatedDecl()->getTagKind() << Pattern->getDeclName() << DC << QualifierLoc.getSourceRange(); - return 0; + return nullptr; } bool AdoptedPreviousTemplateParams = false; @@ -902,7 +902,7 @@ Decl *TemplateDeclInstantiator::VisitClassTemplateDecl(ClassTemplateDecl *D) { Complain, Sema::TPL_TemplateMatch)) { if (Complain) - return 0; + return nullptr; AdoptedPreviousTemplateParams = true; InstParams = PrevParams; @@ -913,7 +913,7 @@ Decl *TemplateDeclInstantiator::VisitClassTemplateDecl(ClassTemplateDecl *D) { if (!AdoptedPreviousTemplateParams && SemaRef.CheckTemplateParameterList(InstParams, PrevParams, Sema::TPC_ClassTemplate)) - return 0; + return nullptr; } } @@ -990,12 +990,12 @@ TemplateDeclInstantiator::VisitClassTemplatePartialSpecializationDecl( DeclContext::lookup_result Found = Owner->lookup(ClassTemplate->getDeclName()); if (Found.empty()) - return 0; + return nullptr; ClassTemplateDecl *InstClassTemplate = dyn_cast(Found.front()); if (!InstClassTemplate) - return 0; + return nullptr; if (ClassTemplatePartialSpecializationDecl *Result = InstClassTemplate->findPartialSpecInstantiatedFromMember(D)) @@ -1014,10 +1014,10 @@ Decl *TemplateDeclInstantiator::VisitVarTemplateDecl(VarTemplateDecl *D) { TemplateParameterList *TempParams = D->getTemplateParameters(); TemplateParameterList *InstParams = SubstTemplateParams(TempParams); if (!InstParams) - return NULL; + return nullptr; VarDecl *Pattern = D->getTemplatedDecl(); - VarTemplateDecl *PrevVarTemplate = 0; + VarTemplateDecl *PrevVarTemplate = nullptr; if (Pattern->getPreviousDecl()) { DeclContext::lookup_result Found = Owner->lookup(Pattern->getDeclName()); @@ -1095,9 +1095,9 @@ TemplateDeclInstantiator::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) { TemplateParameterList *TempParams = D->getTemplateParameters(); TemplateParameterList *InstParams = SubstTemplateParams(TempParams); if (!InstParams) - return NULL; + return nullptr; - FunctionDecl *Instantiated = 0; + FunctionDecl *Instantiated = nullptr; if (CXXMethodDecl *DMethod = dyn_cast(D->getTemplatedDecl())) Instantiated = cast_or_null(VisitCXXMethodDecl(DMethod, InstParams)); @@ -1107,7 +1107,7 @@ TemplateDeclInstantiator::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) { InstParams)); if (!Instantiated) - return 0; + return nullptr; // Link the instantiated function template declaration to the function // template from which it was instantiated. @@ -1137,14 +1137,14 @@ TemplateDeclInstantiator::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) { } Decl *TemplateDeclInstantiator::VisitCXXRecordDecl(CXXRecordDecl *D) { - CXXRecordDecl *PrevDecl = 0; + CXXRecordDecl *PrevDecl = nullptr; if (D->isInjectedClassName()) PrevDecl = cast(Owner); else if (D->getPreviousDecl()) { NamedDecl *Prev = SemaRef.FindInstantiatedDecl(D->getLocation(), D->getPreviousDecl(), TemplateArgs); - if (!Prev) return 0; + if (!Prev) return nullptr; PrevDecl = cast(Prev); } @@ -1155,7 +1155,7 @@ Decl *TemplateDeclInstantiator::VisitCXXRecordDecl(CXXRecordDecl *D) { // Substitute the nested name specifier, if any. if (SubstQualifier(D, Record)) - return 0; + return nullptr; Record->setImplicit(D->isImplicit()); // FIXME: Check against AS_none is an ugly hack to work around the issue that @@ -1230,7 +1230,7 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D, if (FunctionTemplate && !TemplateParams) { ArrayRef Innermost = TemplateArgs.getInnermost(); - void *InsertPos = 0; + void *InsertPos = nullptr; FunctionDecl *SpecFunc = FunctionTemplate->findSpecialization(Innermost.begin(), Innermost.size(), InsertPos); @@ -1246,7 +1246,7 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D, else isFriend = (D->getFriendObjectKind() != Decl::FOK_None); - bool MergeWithParentScope = (TemplateParams != 0) || + bool MergeWithParentScope = (TemplateParams != nullptr) || Owner->isFunctionOrMethod() || !(isa(Owner) && cast(Owner)->isDefinedOutsideFunctionOrMethod()); @@ -1255,7 +1255,7 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D, SmallVector Params; TypeSourceInfo *TInfo = SubstFunctionType(D, Params); if (!TInfo) - return 0; + return nullptr; QualType T = adjustFunctionTypeForInstantiation(SemaRef.Context, D, TInfo); NestedNameSpecifierLoc QualifierLoc = D->getQualifierLoc(); @@ -1263,7 +1263,7 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D, QualifierLoc = SemaRef.SubstNestedNameSpecifierLoc(QualifierLoc, TemplateArgs); if (!QualifierLoc) - return 0; + return nullptr; } // If we're instantiating a local function declaration, put the result @@ -1277,7 +1277,7 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D, CXXScopeSpec SS; SS.Adopt(QualifierLoc); DC = SemaRef.computeDeclContext(SS); - if (!DC) return 0; + if (!DC) return nullptr; } else { DC = SemaRef.FindInstantiatedContext(D->getLocation(), D->getDeclContext(), TemplateArgs); @@ -1351,7 +1351,7 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D, TemplateArgumentList::CreateCopy(SemaRef.Context, Innermost.begin(), Innermost.size()), - /*InsertPos=*/0); + /*InsertPos=*/nullptr); } else if (isFriend) { // Note, we need this connection even if the friend doesn't have a body. // Its body may exist but not have been attached yet due to deferred @@ -1385,14 +1385,14 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D, Info->getRAngleLoc()); if (SemaRef.Subst(Info->getTemplateArgs(), Info->getNumTemplateArgs(), ExplicitArgs, TemplateArgs)) - return 0; + return nullptr; // Map the candidate templates to their instantiations. for (unsigned I = 0, E = Info->getNumTemplates(); I != E; ++I) { Decl *Temp = SemaRef.FindInstantiatedDecl(D->getLocation(), Info->getTemplate(I), TemplateArgs); - if (!Temp) return 0; + if (!Temp) return nullptr; Previous.addDecl(cast(Temp)); } @@ -1418,7 +1418,7 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D, Previous.clear(); } - SemaRef.CheckFunctionDeclaration(/*Scope*/ 0, Function, Previous, + SemaRef.CheckFunctionDeclaration(/*Scope*/ nullptr, Function, Previous, isExplicitSpecialization); NamedDecl *PrincipalDecl = (TemplateParams @@ -1441,7 +1441,7 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D, // to these implicit definitions. if (D->isThisDeclarationADefinition()) { // Check for a function body. - const FunctionDecl *Definition = 0; + const FunctionDecl *Definition = nullptr; if (Function->isDefined(Definition) && Definition->getTemplateSpecializationKind() == TSK_Undeclared) { SemaRef.Diag(Function->getLocation(), diag::err_redefinition) @@ -1508,7 +1508,7 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D, // specialization for this particular set of template arguments. ArrayRef Innermost = TemplateArgs.getInnermost(); - void *InsertPos = 0; + void *InsertPos = nullptr; FunctionDecl *SpecFunc = FunctionTemplate->findSpecialization(Innermost.begin(), Innermost.size(), @@ -1525,7 +1525,7 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D, else isFriend = (D->getFriendObjectKind() != Decl::FOK_None); - bool MergeWithParentScope = (TemplateParams != 0) || + bool MergeWithParentScope = (TemplateParams != nullptr) || !(isa(Owner) && cast(Owner)->isDefinedOutsideFunctionOrMethod()); LocalInstantiationScope Scope(SemaRef, MergeWithParentScope); @@ -1539,7 +1539,7 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D, TemplateParameterList *TempParams = D->getTemplateParameterList(I); TemplateParameterList *InstParams = SubstTemplateParams(TempParams); if (!InstParams) - return NULL; + return nullptr; TempParamLists[I] = InstParams; } } @@ -1547,7 +1547,7 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D, SmallVector Params; TypeSourceInfo *TInfo = SubstFunctionType(D, Params); if (!TInfo) - return 0; + return nullptr; QualType T = adjustFunctionTypeForInstantiation(SemaRef.Context, D, TInfo); NestedNameSpecifierLoc QualifierLoc = D->getQualifierLoc(); @@ -1555,7 +1555,7 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D, QualifierLoc = SemaRef.SubstNestedNameSpecifierLoc(QualifierLoc, TemplateArgs); if (!QualifierLoc) - return 0; + return nullptr; } DeclContext *DC = Owner; @@ -1566,18 +1566,18 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D, DC = SemaRef.computeDeclContext(SS); if (DC && SemaRef.RequireCompleteDeclContext(SS, DC)) - return 0; + return nullptr; } else { DC = SemaRef.FindInstantiatedContext(D->getLocation(), D->getDeclContext(), TemplateArgs); } - if (!DC) return 0; + if (!DC) return nullptr; } // Build the instantiated method declaration. CXXRecordDecl *Record = cast(DC); - CXXMethodDecl *Method = 0; + CXXMethodDecl *Method = nullptr; SourceLocation StartLoc = D->getInnerLocStart(); DeclarationNameInfo NameInfo @@ -1603,7 +1603,7 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D, Sema::InstantiatingTemplate Inst(SemaRef, Constructor->getLocation(), Inh); if (Inst.isInvalid()) - return 0; + return nullptr; Sema::ContextRAII SavedContext(SemaRef, Inh->getDeclContext()); LocalInstantiationScope LocalScope(SemaRef); @@ -1614,7 +1614,7 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D, Inh = cast_or_null( SemaRef.SubstDecl(Inh, Inh->getDeclContext(), InheritedArgs)); if (!Inh) - return 0; + return nullptr; } cast(Method)->setInheritedConstructor(Inh); } @@ -1675,7 +1675,7 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D, TemplateArgumentList::CreateCopy(SemaRef.Context, Innermost.begin(), Innermost.size()), - /*InsertPos=*/0); + /*InsertPos=*/nullptr); } else if (!isFriend) { // Record that this is an instantiation of a member function. Method->setInstantiationOfMemberFunction(D, TSK_ImplicitInstantiation); @@ -1718,7 +1718,7 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D, } if (!IsClassScopeSpecialization) - SemaRef.CheckFunctionDeclaration(0, Method, Previous, false); + SemaRef.CheckFunctionDeclaration(nullptr, Method, Previous, false); if (D->isPure()) SemaRef.CheckPureMethod(Method, SourceRange()); @@ -1836,13 +1836,13 @@ Decl *TemplateDeclInstantiator::VisitNonTypeTemplateParmDecl( D->getLocation(), D->getDeclName()); if (!NewDI) - return 0; + return nullptr; ExpandedParameterPackTypesAsWritten.push_back(NewDI); QualType NewT =SemaRef.CheckNonTypeTemplateParameterType(NewDI->getType(), D->getLocation()); if (NewT.isNull()) - return 0; + return nullptr; ExpandedParameterPackTypes.push_back(NewT); } @@ -1871,7 +1871,7 @@ Decl *TemplateDeclInstantiator::VisitNonTypeTemplateParmDecl( TemplateArgs, Expand, RetainExpansion, NumExpansions)) - return 0; + return nullptr; if (Expand) { for (unsigned I = 0; I != *NumExpansions; ++I) { @@ -1880,14 +1880,14 @@ Decl *TemplateDeclInstantiator::VisitNonTypeTemplateParmDecl( D->getLocation(), D->getDeclName()); if (!NewDI) - return 0; + return nullptr; ExpandedParameterPackTypesAsWritten.push_back(NewDI); QualType NewT = SemaRef.CheckNonTypeTemplateParameterType( NewDI->getType(), D->getLocation()); if (NewT.isNull()) - return 0; + return nullptr; ExpandedParameterPackTypes.push_back(NewT); } @@ -1905,12 +1905,12 @@ Decl *TemplateDeclInstantiator::VisitNonTypeTemplateParmDecl( D->getLocation(), D->getDeclName()); if (!NewPattern) - return 0; + return nullptr; DI = SemaRef.CheckPackExpansion(NewPattern, Expansion.getEllipsisLoc(), NumExpansions); if (!DI) - return 0; + return nullptr; T = DI->getType(); } @@ -1919,7 +1919,7 @@ Decl *TemplateDeclInstantiator::VisitNonTypeTemplateParmDecl( DI = SemaRef.SubstType(D->getTypeSourceInfo(), TemplateArgs, D->getLocation(), D->getDeclName()); if (!DI) - return 0; + return nullptr; // Check that this type is acceptable for a non-type template parameter. T = SemaRef.CheckNonTypeTemplateParameterType(DI->getType(), @@ -2005,7 +2005,7 @@ TemplateDeclInstantiator::VisitTemplateTemplateParmDecl( TemplateParameterList *Expansion = SubstTemplateParams(D->getExpansionTemplateParameters(I)); if (!Expansion) - return 0; + return nullptr; ExpandedParams.push_back(Expansion); } @@ -2030,7 +2030,7 @@ TemplateDeclInstantiator::VisitTemplateTemplateParmDecl( TemplateArgs, Expand, RetainExpansion, NumExpansions)) - return 0; + return nullptr; if (Expand) { for (unsigned I = 0; I != *NumExpansions; ++I) { @@ -2038,7 +2038,7 @@ TemplateDeclInstantiator::VisitTemplateTemplateParmDecl( LocalInstantiationScope Scope(SemaRef); TemplateParameterList *Expansion = SubstTemplateParams(TempParams); if (!Expansion) - return 0; + return nullptr; ExpandedParams.push_back(Expansion); } @@ -2055,7 +2055,7 @@ TemplateDeclInstantiator::VisitTemplateTemplateParmDecl( LocalInstantiationScope Scope(SemaRef); InstParams = SubstTemplateParams(TempParams); if (!InstParams) - return 0; + return nullptr; } } else { // Perform the actual substitution of template parameters within a new, @@ -2063,7 +2063,7 @@ TemplateDeclInstantiator::VisitTemplateTemplateParmDecl( LocalInstantiationScope Scope(SemaRef); InstParams = SubstTemplateParams(TempParams); if (!InstParams) - return 0; + return nullptr; } // Build the template template parameter. @@ -2140,7 +2140,7 @@ Decl *TemplateDeclInstantiator::VisitUsingDecl(UsingDecl *D) { = SemaRef.SubstNestedNameSpecifierLoc(D->getQualifierLoc(), TemplateArgs); if (!QualifierLoc) - return 0; + return nullptr; // The name info is non-dependent, so no transformation // is required. @@ -2200,9 +2200,9 @@ Decl *TemplateDeclInstantiator::VisitUsingDecl(UsingDecl *D) { cast_or_null(SemaRef.FindInstantiatedDecl( Shadow->getLocation(), Shadow->getTargetDecl(), TemplateArgs)); if (!InstTarget) - return 0; + return nullptr; - UsingShadowDecl *PrevDecl = 0; + UsingShadowDecl *PrevDecl = nullptr; if (CheckRedeclaration) { if (SemaRef.CheckUsingShadowDecl(NewUD, InstTarget, Prev, PrevDecl)) continue; @@ -2212,7 +2212,8 @@ Decl *TemplateDeclInstantiator::VisitUsingDecl(UsingDecl *D) { } UsingShadowDecl *InstShadow = - SemaRef.BuildUsingShadowDecl(/*Scope*/0, NewUD, InstTarget, PrevDecl); + SemaRef.BuildUsingShadowDecl(/*Scope*/nullptr, NewUD, InstTarget, + PrevDecl); SemaRef.Context.setInstantiatedFromUsingShadowDecl(InstShadow, Shadow); if (isFunctionScope) @@ -2224,7 +2225,7 @@ Decl *TemplateDeclInstantiator::VisitUsingDecl(UsingDecl *D) { Decl *TemplateDeclInstantiator::VisitUsingShadowDecl(UsingShadowDecl *D) { // Ignore these; we handle them in bulk when processing the UsingDecl. - return 0; + return nullptr; } Decl * TemplateDeclInstantiator @@ -2233,7 +2234,7 @@ Decl * TemplateDeclInstantiator = SemaRef.SubstNestedNameSpecifierLoc(D->getQualifierLoc(), TemplateArgs); if (!QualifierLoc) - return 0; + return nullptr; CXXScopeSpec SS; SS.Adopt(QualifierLoc); @@ -2242,8 +2243,8 @@ Decl * TemplateDeclInstantiator // Hence, no transformation is required for it. DeclarationNameInfo NameInfo(D->getDeclName(), D->getLocation()); NamedDecl *UD = - SemaRef.BuildUsingDeclaration(/*Scope*/ 0, D->getAccess(), - D->getUsingLoc(), SS, NameInfo, 0, + SemaRef.BuildUsingDeclaration(/*Scope*/ nullptr, D->getAccess(), + D->getUsingLoc(), SS, NameInfo, nullptr, /*instantiation*/ true, /*typename*/ true, D->getTypenameLoc()); if (UD) @@ -2257,7 +2258,7 @@ Decl * TemplateDeclInstantiator NestedNameSpecifierLoc QualifierLoc = SemaRef.SubstNestedNameSpecifierLoc(D->getQualifierLoc(), TemplateArgs); if (!QualifierLoc) - return 0; + return nullptr; CXXScopeSpec SS; SS.Adopt(QualifierLoc); @@ -2266,8 +2267,8 @@ Decl * TemplateDeclInstantiator = SemaRef.SubstDeclarationNameInfo(D->getNameInfo(), TemplateArgs); NamedDecl *UD = - SemaRef.BuildUsingDeclaration(/*Scope*/ 0, D->getAccess(), - D->getUsingLoc(), SS, NameInfo, 0, + SemaRef.BuildUsingDeclaration(/*Scope*/ nullptr, D->getAccess(), + D->getUsingLoc(), SS, NameInfo, nullptr, /*instantiation*/ true, /*typename*/ false, SourceLocation()); if (UD) @@ -2281,13 +2282,13 @@ Decl *TemplateDeclInstantiator::VisitClassScopeFunctionSpecializationDecl( ClassScopeFunctionSpecializationDecl *Decl) { CXXMethodDecl *OldFD = Decl->getSpecialization(); CXXMethodDecl *NewFD = cast(VisitCXXMethodDecl(OldFD, - 0, true)); + nullptr, true)); LookupResult Previous(SemaRef, NewFD->getNameInfo(), Sema::LookupOrdinaryName, Sema::ForRedeclaration); TemplateArgumentListInfo TemplateArgs; - TemplateArgumentListInfo* TemplateArgsPtr = 0; + TemplateArgumentListInfo *TemplateArgsPtr = nullptr; if (Decl->hasExplicitTemplateArgs()) { TemplateArgs = Decl->templateArgs(); TemplateArgsPtr = &TemplateArgs; @@ -2327,11 +2328,11 @@ Decl *TemplateDeclInstantiator::VisitOMPThreadPrivateDecl( } Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D) { - return VisitFunctionDecl(D, 0); + return VisitFunctionDecl(D, nullptr); } Decl *TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D) { - return VisitCXXMethodDecl(D, 0); + return VisitCXXMethodDecl(D, nullptr); } Decl *TemplateDeclInstantiator::VisitRecordDecl(RecordDecl *D) { @@ -2354,11 +2355,11 @@ TemplateDeclInstantiator::VisitClassTemplateSpecializationDecl( DeclContext::lookup_result Found = Owner->lookup(ClassTemplate->getDeclName()); if (Found.empty()) - return 0; + return nullptr; ClassTemplateDecl *InstClassTemplate = dyn_cast(Found.front()); if (!InstClassTemplate) - return 0; + return nullptr; // Substitute into the template arguments of the class template explicit // specialization. @@ -2371,7 +2372,7 @@ TemplateDeclInstantiator::VisitClassTemplateSpecializationDecl( ArgLocs.push_back(Loc.getArgLoc(I)); if (SemaRef.Subst(ArgLocs.data(), ArgLocs.size(), InstTemplateArgs, TemplateArgs)) - return 0; + return nullptr; // Check that the template argument list is well-formed for this // class template. @@ -2381,11 +2382,11 @@ TemplateDeclInstantiator::VisitClassTemplateSpecializationDecl( InstTemplateArgs, false, Converted)) - return 0; + return nullptr; // Figure out where to insert this class template explicit specialization // in the member template's set of class template explicit specializations. - void *InsertPos = 0; + void *InsertPos = nullptr; ClassTemplateSpecializationDecl *PrevDecl = InstClassTemplate->findSpecialization(Converted.data(), Converted.size(), InsertPos); @@ -2400,7 +2401,7 @@ TemplateDeclInstantiator::VisitClassTemplateSpecializationDecl( PrevDecl->getSpecializationKind(), PrevDecl->getPointOfInstantiation(), Ignored)) - return 0; + return nullptr; // If PrevDecl was a definition and D is also a definition, diagnose. // This happens in cases like: @@ -2419,7 +2420,7 @@ TemplateDeclInstantiator::VisitClassTemplateSpecializationDecl( SemaRef.Diag(D->getLocation(), diag::err_redefinition) << PrevDecl; SemaRef.Diag(PrevDecl->getDefinition()->getLocation(), diag::note_previous_definition); - return 0; + return nullptr; } // Create the class template partial specialization declaration. @@ -2441,7 +2442,7 @@ TemplateDeclInstantiator::VisitClassTemplateSpecializationDecl( // Substitute the nested name specifier, if any. if (SubstQualifier(D, InstD)) - return 0; + return nullptr; // Build the canonical type that describes the converted template // arguments of the class template explicit specialization. @@ -2476,7 +2477,7 @@ TemplateDeclInstantiator::VisitClassTemplateSpecializationDecl( SemaRef.InstantiateClass(D->getLocation(), InstD, D, TemplateArgs, TSK_ImplicitInstantiation, /*Complain=*/true)) - return 0; + return nullptr; return InstD; } @@ -2496,7 +2497,7 @@ Decl *TemplateDeclInstantiator::VisitVarTemplateSpecializationDecl( if (SemaRef.Subst(TemplateArgsInfo.getArgumentArray(), TemplateArgsInfo.size(), VarTemplateArgsInfo, TemplateArgs)) - return 0; + return nullptr; // Check that the template argument list is well-formed for this template. SmallVector Converted; @@ -2504,11 +2505,11 @@ Decl *TemplateDeclInstantiator::VisitVarTemplateSpecializationDecl( VarTemplate, VarTemplate->getLocStart(), const_cast(VarTemplateArgsInfo), false, Converted)) - return 0; + return nullptr; // Find the variable template specialization declaration that // corresponds to these arguments. - void *InsertPos = 0; + void *InsertPos = nullptr; if (VarTemplateSpecializationDecl *VarSpec = VarTemplate->findSpecialization( Converted.data(), Converted.size(), InsertPos)) // If we already have a variable template specialization, return it. @@ -2528,19 +2529,19 @@ Decl *TemplateDeclInstantiator::VisitVarTemplateSpecializationDecl( if (const RecordType *RecordTy = D->getType()->getAs()) if (RecordTy->getDecl()->isAnonymousStructOrUnion()) if (!VisitCXXRecordDecl(cast(RecordTy->getDecl()))) - return 0; + return nullptr; // Do substitution on the type of the declaration TypeSourceInfo *DI = SemaRef.SubstType(D->getTypeSourceInfo(), TemplateArgs, D->getTypeSpecStartLoc(), D->getDeclName()); if (!DI) - return 0; + return nullptr; if (DI->getType()->isFunctionType()) { SemaRef.Diag(D->getLocation(), diag::err_variable_instantiates_to_function) << D->isStaticDataMember() << DI->getType(); - return 0; + return nullptr; } // Build the instantiated declaration @@ -2554,7 +2555,7 @@ Decl *TemplateDeclInstantiator::VisitVarTemplateSpecializationDecl( // Substitute the nested name specifier, if any. if (SubstQualifier(D, Var)) - return 0; + return nullptr; SemaRef.BuildVariableInstantiation(Var, D, TemplateArgs, LateAttrs, Owner, StartingScope); @@ -2574,7 +2575,7 @@ Decl *TemplateDeclInstantiator::VisitFriendTemplateDecl(FriendTemplateDecl *D) { SemaRef.Diag(D->getLocation(), DiagID) << D->getDeclKindName(); - return 0; + return nullptr; } Decl *TemplateDeclInstantiator::VisitDecl(Decl *D) { @@ -2585,7 +2586,7 @@ Decl *Sema::SubstDecl(Decl *D, DeclContext *Owner, const MultiLevelTemplateArgumentList &TemplateArgs) { TemplateDeclInstantiator Instantiator(*this, Owner, TemplateArgs); if (D->isInvalidDecl()) - return 0; + return nullptr; return Instantiator.Visit(D); } @@ -2614,7 +2615,7 @@ TemplateDeclInstantiator::SubstTemplateParams(TemplateParameterList *L) { // Clean up if we had an error. if (Invalid) - return NULL; + return nullptr; TemplateParameterList *InstL = TemplateParameterList::Create(SemaRef.Context, L->getTemplateLoc(), @@ -2648,7 +2649,7 @@ TemplateDeclInstantiator::InstantiateClassTemplatePartialSpecialization( TemplateParameterList *TempParams = PartialSpec->getTemplateParameters(); TemplateParameterList *InstParams = SubstTemplateParams(TempParams); if (!InstParams) - return 0; + return nullptr; // Substitute into the template arguments of the class template partial // specialization. @@ -2659,7 +2660,7 @@ TemplateDeclInstantiator::InstantiateClassTemplatePartialSpecialization( if (SemaRef.Subst(TemplArgInfo->getTemplateArgs(), TemplArgInfo->NumTemplateArgs, InstTemplateArgs, TemplateArgs)) - return 0; + return nullptr; // Check that the template argument list is well-formed for this // class template. @@ -2669,11 +2670,11 @@ TemplateDeclInstantiator::InstantiateClassTemplatePartialSpecialization( InstTemplateArgs, false, Converted)) - return 0; + return nullptr; // Figure out where to insert this class template partial specialization // in the member template's set of class template partial specializations. - void *InsertPos = 0; + void *InsertPos = nullptr; ClassTemplateSpecializationDecl *PrevDecl = ClassTemplate->findPartialSpecialization(Converted.data(), Converted.size(), InsertPos); @@ -2719,7 +2720,7 @@ TemplateDeclInstantiator::InstantiateClassTemplatePartialSpecialization( << WrittenTy->getType(); SemaRef.Diag(PrevDecl->getLocation(), diag::note_prev_partial_spec_here) << SemaRef.Context.getTypeDeclType(PrevDecl); - return 0; + return nullptr; } @@ -2736,17 +2737,18 @@ TemplateDeclInstantiator::InstantiateClassTemplatePartialSpecialization( Converted.size(), InstTemplateArgs, CanonType, - 0); + nullptr); // Substitute the nested name specifier, if any. if (SubstQualifier(PartialSpec, InstPartialSpec)) - return 0; + return nullptr; InstPartialSpec->setInstantiatedFromMember(PartialSpec); InstPartialSpec->setTypeAsWritten(WrittenTy); // Add this partial specialization to the set of class template partial // specializations. - ClassTemplate->AddPartialSpecialization(InstPartialSpec, /*InsertPos=*/0); + ClassTemplate->AddPartialSpecialization(InstPartialSpec, + /*InsertPos=*/nullptr); return InstPartialSpec; } @@ -2775,7 +2777,7 @@ TemplateDeclInstantiator::InstantiateVarTemplatePartialSpecialization( TemplateParameterList *TempParams = PartialSpec->getTemplateParameters(); TemplateParameterList *InstParams = SubstTemplateParams(TempParams); if (!InstParams) - return 0; + return nullptr; // Substitute into the template arguments of the variable template partial // specialization. @@ -2786,18 +2788,18 @@ TemplateDeclInstantiator::InstantiateVarTemplatePartialSpecialization( if (SemaRef.Subst(TemplArgInfo->getTemplateArgs(), TemplArgInfo->NumTemplateArgs, InstTemplateArgs, TemplateArgs)) - return 0; + return nullptr; // Check that the template argument list is well-formed for this // class template. SmallVector Converted; if (SemaRef.CheckTemplateArgumentList(VarTemplate, PartialSpec->getLocation(), InstTemplateArgs, false, Converted)) - return 0; + return nullptr; // Figure out where to insert this variable template partial specialization // in the member template's set of variable template partial specializations. - void *InsertPos = 0; + void *InsertPos = nullptr; VarTemplateSpecializationDecl *PrevDecl = VarTemplate->findPartialSpecialization(Converted.data(), Converted.size(), InsertPos); @@ -2839,7 +2841,7 @@ TemplateDeclInstantiator::InstantiateVarTemplatePartialSpecialization( << WrittenTy->getType(); SemaRef.Diag(PrevDecl->getLocation(), diag::note_var_prev_partial_spec_here); - return 0; + return nullptr; } // Do substitution on the type of the declaration @@ -2847,13 +2849,13 @@ TemplateDeclInstantiator::InstantiateVarTemplatePartialSpecialization( PartialSpec->getTypeSourceInfo(), TemplateArgs, PartialSpec->getTypeSpecStartLoc(), PartialSpec->getDeclName()); if (!DI) - return 0; + return nullptr; if (DI->getType()->isFunctionType()) { SemaRef.Diag(PartialSpec->getLocation(), diag::err_variable_instantiates_to_function) << PartialSpec->isStaticDataMember() << DI->getType(); - return 0; + return nullptr; } // Create the variable template partial specialization declaration. @@ -2866,14 +2868,14 @@ TemplateDeclInstantiator::InstantiateVarTemplatePartialSpecialization( // Substitute the nested name specifier, if any. if (SubstQualifier(PartialSpec, InstPartialSpec)) - return 0; + return nullptr; InstPartialSpec->setInstantiatedFromMember(PartialSpec); InstPartialSpec->setTypeAsWritten(WrittenTy); // Add this partial specialization to the set of variable template partial // specializations. The instantiation of the initializer is not necessary. - VarTemplate->AddPartialSpecialization(InstPartialSpec, /*InsertPos=*/0); + VarTemplate->AddPartialSpecialization(InstPartialSpec, /*InsertPos=*/nullptr); SemaRef.BuildVariableInstantiation(InstPartialSpec, PartialSpec, TemplateArgs, LateAttrs, Owner, StartingScope); @@ -2887,8 +2889,8 @@ TemplateDeclInstantiator::SubstFunctionType(FunctionDecl *D, TypeSourceInfo *OldTInfo = D->getTypeSourceInfo(); assert(OldTInfo && "substituting function without type source info"); assert(Params.empty() && "parameter vector is non-empty at start"); - - CXXRecordDecl *ThisContext = 0; + + CXXRecordDecl *ThisContext = nullptr; unsigned ThisTypeQuals = 0; if (CXXMethodDecl *Method = dyn_cast(D)) { ThisContext = cast(Owner); @@ -2901,7 +2903,7 @@ TemplateDeclInstantiator::SubstFunctionType(FunctionDecl *D, D->getDeclName(), ThisContext, ThisTypeQuals); if (!NewTInfo) - return 0; + return nullptr; TypeLoc OldTL = OldTInfo->getTypeLoc().IgnoreParens(); if (FunctionProtoTypeLoc OldProtoLoc = OldTL.getAs()) { @@ -2954,7 +2956,7 @@ TemplateDeclInstantiator::SubstFunctionType(FunctionDecl *D, ParmVarDecl *Parm = cast_or_null(VisitParmVarDecl(OldParam)); if (!Parm) - return 0; + return nullptr; Params.push_back(Parm); } } @@ -2973,7 +2975,7 @@ TemplateDeclInstantiator::SubstFunctionType(FunctionDecl *D, if (SemaRef.SubstParmTypes(D->getLocation(), D->param_begin(), D->getNumParams(), TemplateArgs, ParamTypes, &Params)) - return 0; + return nullptr; } return NewTInfo; @@ -3036,7 +3038,7 @@ static void InstantiateExceptionSpec(Sema &SemaRef, FunctionDecl *New, // "pointer to cv-qualifier-seq X" between the optional cv-qualifer-seq // and the end of the function-definition, member-declarator, or // declarator. - CXXRecordDecl *ThisContext = 0; + CXXRecordDecl *ThisContext = nullptr; unsigned ThisTypeQuals = 0; if (CXXMethodDecl *Method = dyn_cast(New)) { ThisContext = Method->getParent(); @@ -3118,7 +3120,7 @@ static void InstantiateExceptionSpec(Sema &SemaRef, FunctionDecl *New, Exceptions.push_back(T); } - Expr *NoexceptExpr = 0; + Expr *NoexceptExpr = nullptr; if (Expr *OldNoexceptExpr = Proto->getNoexceptExpr()) { EnterExpressionEvaluationContext Unevaluated(SemaRef, Sema::ConstantEvaluated); @@ -3132,7 +3134,7 @@ static void InstantiateExceptionSpec(Sema &SemaRef, FunctionDecl *New, !NoexceptExpr->isValueDependent()) NoexceptExpr = SemaRef.VerifyIntegerConstantExpression(NoexceptExpr, - 0, diag::err_noexcept_needs_constant_expression, + nullptr, diag::err_noexcept_needs_constant_expression, /*AllowFold*/ false).take(); } } @@ -3169,7 +3171,7 @@ void Sema::InstantiateExceptionSpec(SourceLocation PointOfInstantiation, LocalInstantiationScope Scope(*this); MultiLevelTemplateArgumentList TemplateArgs = - getTemplateInstantiationArgs(Decl, 0, /*RelativeToPrimary*/true); + getTemplateInstantiationArgs(Decl, nullptr, /*RelativeToPrimary*/true); FunctionDecl *Template = Proto->getExceptionSpecTemplate(); addInstantiatedParametersToScope(*this, Decl, Template, Scope, TemplateArgs); @@ -3415,14 +3417,14 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, if (PatternDecl->isDefaulted()) SetDeclDefaulted(Function, PatternDecl->getLocation()); else { - ActOnStartOfFunctionDef(0, Function); + ActOnStartOfFunctionDef(nullptr, Function); // Enter the scope of this instantiation. We don't use // PushDeclContext because we don't have a scope. Sema::ContextRAII savedContext(*this, Function); MultiLevelTemplateArgumentList TemplateArgs = - getTemplateInstantiationArgs(Function, 0, false, PatternDecl); + getTemplateInstantiationArgs(Function, nullptr, false, PatternDecl); addInstantiatedParametersToScope(*this, Function, PatternDecl, Scope, TemplateArgs); @@ -3488,11 +3490,11 @@ VarTemplateSpecializationDecl *Sema::BuildVarTemplateInstantiation( LateInstantiatedAttrVec *LateAttrs, LocalInstantiationScope *StartingScope) { if (FromVar->isInvalidDecl()) - return 0; + return nullptr; InstantiatingTemplate Inst(*this, PointOfInstantiation, FromVar); if (Inst.isInvalid()) - return 0; + return nullptr; MultiLevelTemplateArgumentList TemplateArgLists; TemplateArgLists.addOuterTemplateArguments(&TemplateArgList); @@ -3537,7 +3539,7 @@ VarTemplateSpecializationDecl *Sema::CompleteVarTemplateSpecializationDecl( SubstType(PatternDecl->getTypeSourceInfo(), TemplateArgs, PatternDecl->getTypeSpecStartLoc(), PatternDecl->getDeclName()); if (!DI) - return 0; + return nullptr; // Update the type of this variable template specialization. VarSpec->setType(DI->getType()); @@ -3725,7 +3727,7 @@ void Sema::InstantiateVariableDefinition(SourceLocation PointOfInstantiation, VarTemplateSpecializationDecl *VarSpec = dyn_cast(Var); - VarDecl *PatternDecl = 0, *Def = 0; + VarDecl *PatternDecl = nullptr, *Def = nullptr; MultiLevelTemplateArgumentList TemplateArgs = getTemplateInstantiationArgs(Var); @@ -3935,7 +3937,7 @@ void Sema::InstantiateVariableDefinition(SourceLocation PointOfInstantiation, TemplateDeclInstantiator Instantiator(*this, Var->getDeclContext(), TemplateArgs); Var = cast_or_null(Instantiator.VisitVarTemplateSpecializationDecl( - VarSpec->getSpecializedTemplate(), Def, 0, + VarSpec->getSpecializedTemplate(), Def, nullptr, VarSpec->getTemplateArgsInfo(), VarSpec->getTemplateArgs().asArray())); if (Var) { llvm::PointerUnion(*first); - return 0; + return nullptr; } /// \brief Finds the instantiation of the given declaration context @@ -4425,7 +4427,7 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, return D; if (D->isInvalidDecl()) - return 0; + return nullptr; // If we didn't find the decl, then we must have a label decl that hasn't // been found yet. Lazily instantiate it and return it now. @@ -4509,7 +4511,7 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, ParentDC = FindInstantiatedContext(Loc, ParentDC, TemplateArgs); if (!ParentDC) - return 0; + return nullptr; if (ParentDC != D->getDeclContext()) { // We performed some kind of instantiation in the parent context, @@ -4528,13 +4530,13 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, IsBeingInstantiated = true; if (!Tag->isBeingDefined() && RequireCompleteType(Loc, T, diag::err_incomplete_type)) - return 0; + return nullptr; ParentDC = Tag->getDecl(); } } - NamedDecl *Result = 0; + NamedDecl *Result = nullptr; if (D->getDeclName()) { DeclContext::lookup_result Found = ParentDC->lookup(D->getDeclName()); Result = findInstantiationOf(Context, D, Found.begin(), Found.end()); diff --git a/clang/lib/Sema/SemaTemplateVariadic.cpp b/clang/lib/Sema/SemaTemplateVariadic.cpp index 8439f9f..9480c11 100644 --- a/clang/lib/Sema/SemaTemplateVariadic.cpp +++ b/clang/lib/Sema/SemaTemplateVariadic.cpp @@ -223,7 +223,7 @@ Sema::DiagnoseUnexpandedParameterPacks(SourceLocation Loc, llvm::SmallPtrSet NamesKnown; for (unsigned I = 0, N = Unexpanded.size(); I != N; ++I) { - IdentifierInfo *Name = 0; + IdentifierInfo *Name = nullptr; if (const TemplateTypeParmType *TTP = Unexpanded[I].first.dyn_cast()) Name = TTP->getIdentifier(); @@ -463,7 +463,7 @@ Sema::CheckPackExpansion(TypeSourceInfo *Pattern, SourceLocation EllipsisLoc, Pattern->getTypeLoc().getSourceRange(), EllipsisLoc, NumExpansions); if (Result.isNull()) - return 0; + return nullptr; TypeLocBuilder TLB; TLB.pushFullCopy(Pattern->getTypeLoc()); @@ -798,8 +798,8 @@ ExprResult Sema::ActOnSizeofParameterPackExpr(Scope *S, // The identifier in a sizeof... expression shall name a parameter pack. LookupResult R(*this, &Name, NameLoc, LookupOrdinaryName); LookupName(R, S); - - NamedDecl *ParameterPack = 0; + + NamedDecl *ParameterPack = nullptr; ParameterPackValidatorCCC Validator; switch (R.getResultKind()) { case LookupResult::Found: @@ -809,7 +809,7 @@ ExprResult Sema::ActOnSizeofParameterPackExpr(Scope *S, case LookupResult::NotFound: case LookupResult::NotFoundInCurrentInstantiation: if (TypoCorrection Corrected = CorrectTypo(R.getLookupNameInfo(), - R.getLookupKind(), S, 0, + R.getLookupKind(), S, nullptr, Validator, CTK_ErrorRecovery)) { diagnoseTypo(Corrected, PDiag(diag::err_sizeof_pack_no_pack_name_suggest) << &Name, diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index cb8fc24..dec2b17 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -79,7 +79,8 @@ static void diagnoseBadTypeAttribute(Sema &S, const AttributeList &attr, StringRef name = attr.getName()->getName(); // The GC attributes are usually written with macros; special-case them. - IdentifierInfo *II = attr.isArgIdent(0) ? attr.getArgAsIdent(0)->Ident : 0; + IdentifierInfo *II = attr.isArgIdent(0) ? attr.getArgAsIdent(0)->Ident + : nullptr; if (useExpansionLoc && loc.isMacroID() && II) { if (II->isStr("strong")) { if (S.findMacroSpelling(loc, "__strong")) name = "__strong"; @@ -223,14 +224,14 @@ namespace { assert(hasSavedAttrs); if (savedAttrs.empty()) { - getMutableDeclSpec().getAttributes().set(0); + getMutableDeclSpec().getAttributes().set(nullptr); return; } getMutableDeclSpec().getAttributes().set(savedAttrs[0]); for (unsigned i = 0, e = savedAttrs.size() - 1; i != e; ++i) savedAttrs[i]->setNext(savedAttrs[i+1]); - savedAttrs.back()->setNext(0); + savedAttrs.back()->setNext(nullptr); } }; } @@ -310,7 +311,7 @@ static DeclaratorChunk *maybeMovePastReturnType(Declarator &declarator, unsigned i) { assert(i <= declarator.getNumTypeObjects()); - DeclaratorChunk *result = 0; + DeclaratorChunk *result = nullptr; // First, look inwards past parens for a function declarator. for (; i != 0; --i) { @@ -378,7 +379,7 @@ static void distributeObjCPointerTypeAttr(TypeProcessingState &state, case DeclaratorChunk::BlockPointer: { // But don't move an ARC ownership attribute to the return type // of a block. - DeclaratorChunk *destChunk = 0; + DeclaratorChunk *destChunk = nullptr; if (state.isProcessingDeclSpec() && attr.getKind() == AttributeList::AT_ObjCOwnership) destChunk = maybeMovePastReturnType(declarator, i - 1); @@ -662,7 +663,7 @@ static void maybeSynthesizeBlockSignature(TypeProcessingState &state, /*HasProto=*/true, /*IsAmbiguous=*/false, /*LParenLoc=*/NoLoc, - /*ArgInfo=*/0, + /*ArgInfo=*/nullptr, /*NumArgs=*/0, /*EllipsisLoc=*/NoLoc, /*RParenLoc=*/NoLoc, @@ -674,10 +675,10 @@ static void maybeSynthesizeBlockSignature(TypeProcessingState &state, /*MutableLoc=*/NoLoc, EST_None, /*ESpecLoc=*/NoLoc, - /*Exceptions=*/0, - /*ExceptionRanges=*/0, + /*Exceptions=*/nullptr, + /*ExceptionRanges=*/nullptr, /*NumExceptions=*/0, - /*NoexceptExpr=*/0, + /*NoexceptExpr=*/nullptr, loc, loc, declarator)); // For consistency, make sure the state still has us as processing @@ -1590,7 +1591,7 @@ QualType Sema::BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM, llvm::APSInt ConstVal(Context.getTypeSize(Context.getSizeType())); if (!ArraySize) { if (ASM == ArrayType::Star) - T = Context.getVariableArrayType(T, 0, ASM, Quals, Brackets); + T = Context.getVariableArrayType(T, nullptr, ASM, Quals, Brackets); else T = Context.getIncompleteArrayType(T, ASM, Quals); } else if (ArraySize->isTypeDependent() || ArraySize->isValueDependent()) { @@ -1871,11 +1872,11 @@ QualType Sema::BuildBlockPointerType(QualType T, QualType Sema::GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo) { QualType QT = Ty.get(); if (QT.isNull()) { - if (TInfo) *TInfo = 0; + if (TInfo) *TInfo = nullptr; return QualType(); } - TypeSourceInfo *DI = 0; + TypeSourceInfo *DI = nullptr; if (const LocInfoType *LIT = dyn_cast(QT)) { QT = LIT->getType(); DI = LIT->getTypeSourceInfo(); @@ -2107,10 +2108,10 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state, Sema &SemaRef = state.getSema(); Declarator &D = state.getDeclarator(); QualType T; - ReturnTypeInfo = 0; + ReturnTypeInfo = nullptr; // The TagDecl owned by the DeclSpec. - TagDecl *OwnedTagDecl = 0; + TagDecl *OwnedTagDecl = nullptr; bool ContainsPlaceholderType = false; @@ -2870,7 +2871,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, S.Diag(FTI.getEllipsisLoc(), diag::err_ellipsis_first_param); } - if (FTI.NumParams && FTI.Params[0].Param == 0) { + if (FTI.NumParams && FTI.Params[0].Param == nullptr) { // C99 6.7.5.3p3: Reject int(x,y,z) when it's not a function // definition. S.Diag(FTI.Params[0].IdentLoc, @@ -2970,7 +2971,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, SmallVector Exceptions; SmallVector DynamicExceptions; SmallVector DynamicExceptionRanges; - Expr *NoexceptExpr = 0; + Expr *NoexceptExpr = nullptr; if (FTI.getExceptionSpecType() == EST_Dynamic) { // FIXME: It's rather inefficient to have to split into two vectors @@ -3256,7 +3257,7 @@ TypeSourceInfo *Sema::GetTypeForDeclarator(Declarator &D, Scope *S) { TypeProcessingState state(*this, D); - TypeSourceInfo *ReturnTypeInfo = 0; + TypeSourceInfo *ReturnTypeInfo = nullptr; QualType T = GetDeclSpecTypeForDeclarator(state, ReturnTypeInfo); if (T.isNull()) return Context.getNullTypeSourceInfo(); @@ -3291,7 +3292,7 @@ static void transferARCOwnershipToDeclaratorChunk(TypeProcessingState &state, if (attr->getKind() == AttributeList::AT_ObjCOwnership) return; - const char *attrStr = 0; + const char *attrStr = nullptr; switch (ownership) { case Qualifiers::OCL_None: llvm_unreachable("no ownership!"); case Qualifiers::OCL_ExplicitNone: attrStr = "none"; break; @@ -3310,7 +3311,7 @@ static void transferARCOwnershipToDeclaratorChunk(TypeProcessingState &state, // so that we don't make an AttributedType for it). AttributeList *attr = D.getAttributePool() .create(&S.Context.Idents.get("objc_ownership"), SourceLocation(), - /*scope*/ 0, SourceLocation(), + /*scope*/ nullptr, SourceLocation(), /*args*/ &Args, 1, AttributeList::AS_GNU); spliceAttrIntoList(*attr, chunk.getAttrListRef()); @@ -3371,7 +3372,7 @@ static void transferARCOwnership(TypeProcessingState &state, TypeSourceInfo *Sema::GetTypeForDeclaratorCast(Declarator &D, QualType FromTy) { TypeProcessingState state(*this, D); - TypeSourceInfo *ReturnTypeInfo = 0; + TypeSourceInfo *ReturnTypeInfo = nullptr; QualType declSpecTy = GetDeclSpecTypeForDeclarator(state, ReturnTypeInfo); if (declSpecTy.isNull()) return Context.getNullTypeSourceInfo(); @@ -3521,7 +3522,7 @@ namespace { Visit(TL.getPointeeLoc()); } void VisitTemplateSpecializationTypeLoc(TemplateSpecializationTypeLoc TL) { - TypeSourceInfo *TInfo = 0; + TypeSourceInfo *TInfo = nullptr; Sema::GetTypeFromParser(DS.getRepAsType(), &TInfo); // If we got no declarator info from previous Sema routines, @@ -3553,7 +3554,7 @@ namespace { TL.setTypeofLoc(DS.getTypeSpecTypeLoc()); TL.setParensRange(DS.getTypeofParensRange()); assert(DS.getRepAsType()); - TypeSourceInfo *TInfo = 0; + TypeSourceInfo *TInfo = nullptr; Sema::GetTypeFromParser(DS.getRepAsType(), &TInfo); TL.setUnderlyingTInfo(TInfo); } @@ -3563,7 +3564,7 @@ namespace { TL.setKWLoc(DS.getTypeSpecTypeLoc()); TL.setParensRange(DS.getTypeofParensRange()); assert(DS.getRepAsType()); - TypeSourceInfo *TInfo = 0; + TypeSourceInfo *TInfo = nullptr; Sema::GetTypeFromParser(DS.getRepAsType(), &TInfo); TL.setUnderlyingTInfo(TInfo); } @@ -3586,7 +3587,7 @@ namespace { ElaboratedTypeKeyword Keyword = TypeWithKeyword::getKeywordForTypeSpec(DS.getTypeSpecType()); if (DS.getTypeSpecType() == TST_typename) { - TypeSourceInfo *TInfo = 0; + TypeSourceInfo *TInfo = nullptr; Sema::GetTypeFromParser(DS.getRepAsType(), &TInfo); if (TInfo) { TL.copy(TInfo->getTypeLoc().castAs()); @@ -3602,7 +3603,7 @@ namespace { } void VisitDependentNameTypeLoc(DependentNameTypeLoc TL) { assert(DS.getTypeSpecType() == TST_typename); - TypeSourceInfo *TInfo = 0; + TypeSourceInfo *TInfo = nullptr; Sema::GetTypeFromParser(DS.getRepAsType(), &TInfo); assert(TInfo); TL.copy(TInfo->getTypeLoc().castAs()); @@ -3610,7 +3611,7 @@ namespace { void VisitDependentTemplateSpecializationTypeLoc( DependentTemplateSpecializationTypeLoc TL) { assert(DS.getTypeSpecType() == TST_typename); - TypeSourceInfo *TInfo = 0; + TypeSourceInfo *TInfo = nullptr; Sema::GetTypeFromParser(DS.getRepAsType(), &TInfo); assert(TInfo); TL.copy( @@ -3626,7 +3627,7 @@ namespace { TL.setKWLoc(DS.getTypeSpecTypeLoc()); TL.setParensRange(DS.getTypeofParensRange()); - TypeSourceInfo *TInfo = 0; + TypeSourceInfo *TInfo = nullptr; Sema::GetTypeFromParser(DS.getRepAsType(), &TInfo); assert(TInfo); TL.getValueLoc().initializeFullCopy(TInfo->getTypeLoc()); @@ -3864,7 +3865,8 @@ void LocInfoType::getAsStringInternal(std::string &Str, TypeResult Sema::ActOnTypeName(Scope *S, Declarator &D) { // C99 6.7.6: Type names have no identifier. This is already validated by // the parser. - assert(D.getIdentifier() == 0 && "Type name should have no identifier!"); + assert(D.getIdentifier() == nullptr && + "Type name should have no identifier!"); TypeSourceInfo *TInfo = GetTypeForDeclarator(D, S); QualType T = TInfo->getType(); @@ -4269,7 +4271,7 @@ namespace { } else { const Type *DTy = Ty->getUnqualifiedDesugaredType(); if (Ty == DTy) { - Fn = 0; + Fn = nullptr; return; } @@ -4279,7 +4281,7 @@ namespace { } } - bool isFunctionType() const { return (Fn != 0); } + bool isFunctionType() const { return (Fn != nullptr); } const FunctionType *get() const { return Fn; } QualType wrap(Sema &S, const FunctionType *New) { @@ -5157,7 +5159,7 @@ bool Sema::RequireCompleteTypeImpl(SourceLocation Loc, QualType T, // "Can't ask whether a dependent type is complete"); // If we have a complete type, we're done. - NamedDecl *Def = 0; + NamedDecl *Def = nullptr; if (!T->isIncompleteType(&Def)) { // If we know about the definition but it is not visible, complain. NamedDecl *SuggestedDef = 0; @@ -5451,7 +5453,7 @@ QualType Sema::getElaboratedType(ElaboratedTypeKeyword Keyword, else { if (Keyword == ETK_None) return T; - NNS = 0; + NNS = nullptr; } return Context.getElaboratedType(Keyword, NNS, T); } diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index 1764272..ef82b82 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -371,7 +371,7 @@ public: /// \returns true if an error occurred, false otherwise. bool TransformExprs(Expr **Inputs, unsigned NumInputs, bool IsCall, SmallVectorImpl &Outputs, - bool *ArgChanged = 0); + bool *ArgChanged = nullptr); /// \brief Transform the given declaration, which is referenced from a type /// or expression. @@ -433,10 +433,10 @@ public: /// By default, transforms all of the types and declarations within the /// nested-name-specifier. Subclasses may override this function to provide /// alternate behavior. - NestedNameSpecifierLoc TransformNestedNameSpecifierLoc( - NestedNameSpecifierLoc NNS, - QualType ObjectType = QualType(), - NamedDecl *FirstQualifierInScope = 0); + NestedNameSpecifierLoc + TransformNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, + QualType ObjectType = QualType(), + NamedDecl *FirstQualifierInScope = nullptr); /// \brief Transform the given declaration name. /// @@ -467,11 +467,11 @@ public: /// By default, transforms the template name by transforming the declarations /// and nested-name-specifiers that occur within the template name. /// Subclasses may override this function to provide alternate behavior. - TemplateName TransformTemplateName(CXXScopeSpec &SS, - TemplateName Name, - SourceLocation NameLoc, - QualType ObjectType = QualType(), - NamedDecl *FirstQualifierInScope = 0); + TemplateName + TransformTemplateName(CXXScopeSpec &SS, TemplateName Name, + SourceLocation NameLoc, + QualType ObjectType = QualType(), + NamedDecl *FirstQualifierInScope = nullptr); /// \brief Transform the given template argument. /// @@ -848,7 +848,8 @@ public: CXXScopeSpec SS; SS.Adopt(QualifierLoc); TemplateName InstName - = getDerived().RebuildTemplateName(SS, *Name, NameLoc, QualType(), 0); + = getDerived().RebuildTemplateName(SS, *Name, NameLoc, QualType(), + nullptr); if (InstName.isNull()) return QualType(); @@ -866,7 +867,7 @@ public: getDerived().RebuildTemplateSpecializationType(InstName, NameLoc, Args); if (T.isNull()) return QualType(); - if (Keyword == ETK_None && QualifierLoc.getNestedNameSpecifier() == 0) + if (Keyword == ETK_None && QualifierLoc.getNestedNameSpecifier() == nullptr) return T; return SemaRef.Context.getElaboratedType(Keyword, @@ -912,7 +913,7 @@ public: if (SemaRef.RequireCompleteDeclContext(SS, DC)) return QualType(); - TagDecl *Tag = 0; + TagDecl *Tag = nullptr; SemaRef.LookupQualifiedName(Result, DC); switch (Result.getResultKind()) { case LookupResult::NotFound: @@ -1079,7 +1080,7 @@ public: SourceLocation ColonLoc, Stmt *SubStmt) { return getSema().ActOnDefaultStmt(DefaultLoc, ColonLoc, SubStmt, - /*CurScope=*/0); + /*CurScope=*/nullptr); } /// \brief Build a new label statement. @@ -1474,7 +1475,7 @@ public: SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id) { - VarDecl *Var = getSema().BuildExceptionDeclaration(0, Declarator, + VarDecl *Var = getSema().BuildExceptionDeclaration(nullptr, Declarator, StartLoc, IdLoc, Id); if (Var) getSema().CurContext->addDecl(Var); @@ -1624,7 +1625,7 @@ public: ExprResult RebuildUnaryOperator(SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *SubExpr) { - return getSema().BuildUnaryOp(/*Scope=*/0, OpLoc, Opc, SubExpr); + return getSema().BuildUnaryOp(/*Scope=*/nullptr, OpLoc, Opc, SubExpr); } /// \brief Build a new builtin offsetof expression. @@ -1676,7 +1677,7 @@ public: SourceLocation LBracketLoc, Expr *RHS, SourceLocation RBracketLoc) { - return getSema().ActOnArraySubscriptExpr(/*Scope=*/0, LHS, + return getSema().ActOnArraySubscriptExpr(/*Scope=*/nullptr, LHS, LBracketLoc, RHS, RBracketLoc); } @@ -1688,8 +1689,8 @@ public: ExprResult RebuildCallExpr(Expr *Callee, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, - Expr *ExecConfig = 0) { - return getSema().ActOnCallExpr(/*Scope=*/0, Callee, LParenLoc, + Expr *ExecConfig = nullptr) { + return getSema().ActOnCallExpr(/*Scope=*/nullptr, Callee, LParenLoc, Args, RParenLoc, ExecConfig); } @@ -1757,7 +1758,7 @@ public: ExprResult RebuildBinaryOperator(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHS, Expr *RHS) { - return getSema().BuildBinOp(/*Scope=*/0, OpLoc, Opc, LHS, RHS); + return getSema().BuildBinOp(/*Scope=*/nullptr, OpLoc, Opc, LHS, RHS); } /// \brief Build a new conditional operator expression. @@ -1811,9 +1812,9 @@ public: return getSema().BuildMemberReferenceExpr(Base, Base->getType(), OpLoc, /*IsArrow*/ false, SS, SourceLocation(), - /*FirstQualifierInScope*/ 0, + /*FirstQualifierInScope*/ nullptr, NameInfo, - /* TemplateArgs */ 0); + /* TemplateArgs */ nullptr); } /// \brief Build a new initializer list expression. @@ -2495,7 +2496,7 @@ public: Sema::LookupMemberName); ExprResult Result = getSema().LookupMemberExpr(R, Base, IsArrow, /*FIME:*/IvarLoc, - SS, 0, + SS, nullptr, false); if (Result.isInvalid() || Base.isInvalid()) return ExprError(); @@ -2506,9 +2507,9 @@ public: return getSema().BuildMemberReferenceExpr(Base.get(), Base.get()->getType(), /*FIXME:*/IvarLoc, IsArrow, SS, SourceLocation(), - /*FirstQualifierInScope=*/0, + /*FirstQualifierInScope=*/nullptr, R, - /*TemplateArgs=*/0); + /*TemplateArgs=*/nullptr); } /// \brief Build a new Objective-C property reference expression. @@ -2525,7 +2526,7 @@ public: bool IsArrow = false; ExprResult Result = getSema().LookupMemberExpr(R, Base, IsArrow, /*FIME:*/PropertyLoc, - SS, 0, false); + SS, nullptr, false); if (Result.isInvalid() || Base.isInvalid()) return ExprError(); @@ -2535,9 +2536,8 @@ public: return getSema().BuildMemberReferenceExpr(Base.get(), Base.get()->getType(), /*FIXME:*/PropertyLoc, IsArrow, SS, SourceLocation(), - /*FirstQualifierInScope=*/0, - R, - /*TemplateArgs=*/0); + /*FirstQualifierInScope=*/nullptr, + R, /*TemplateArgs=*/nullptr); } /// \brief Build a new Objective-C property reference expression. @@ -2569,7 +2569,7 @@ public: Sema::LookupMemberName); ExprResult Result = getSema().LookupMemberExpr(R, Base, IsArrow, OpLoc, - SS, 0, false); + SS, nullptr, false); if (Result.isInvalid() || Base.isInvalid()) return ExprError(); @@ -2579,9 +2579,9 @@ public: return getSema().BuildMemberReferenceExpr(Base.get(), Base.get()->getType(), OpLoc, IsArrow, SS, SourceLocation(), - /*FirstQualifierInScope=*/0, + /*FirstQualifierInScope=*/nullptr, R, - /*TemplateArgs=*/0); + /*TemplateArgs=*/nullptr); } /// \brief Build a new shuffle vector expression. @@ -2961,7 +2961,7 @@ TreeTransform::TransformNestedNameSpecifierLoc( switch (QNNS->getKind()) { case NestedNameSpecifier::Identifier: - if (SemaRef.BuildCXXNestedNameSpecifier(/*Scope=*/0, + if (SemaRef.BuildCXXNestedNameSpecifier(/*Scope=*/nullptr, *QNNS->getAsIdentifier(), Q.getLocalBeginLoc(), Q.getLocalEndLoc(), @@ -3029,7 +3029,7 @@ TreeTransform::TransformNestedNameSpecifierLoc( } // The qualifier-in-scope and object type only apply to the leftmost entity. - FirstQualifierInScope = 0; + FirstQualifierInScope = nullptr; ObjectType = QualType(); } @@ -3078,7 +3078,7 @@ TreeTransform NewCanTy = SemaRef.Context.getCanonicalType(NewTInfo->getType()); } else { - NewTInfo = 0; + NewTInfo = nullptr; TemporaryBase Rebase(*this, NameInfo.getLoc(), Name); QualType NewT = getDerived().TransformType(Name.getCXXNameType()); if (NewT.isNull()) @@ -3129,7 +3129,7 @@ TreeTransform::TransformTemplateName(CXXScopeSpec &SS, if (SS.getScopeRep()) { // These apply to the scope specifier, not the template. ObjectType = QualType(); - FirstQualifierInScope = 0; + FirstQualifierInScope = nullptr; } if (!getDerived().AlwaysRebuild() && @@ -3248,7 +3248,7 @@ bool TreeTransform::TransformTemplateArgument( case TemplateArgument::Type: { TypeSourceInfo *DI = Input.getTypeSourceInfo(); - if (DI == NULL) + if (!DI) DI = InventTypeSourceInfo(Input.getArgument().getAsType()); DI = getDerived().TransformType(DI); @@ -3518,7 +3518,7 @@ TypeSourceInfo *TreeTransform::TransformType(TypeSourceInfo *DI) { QualType Result = getDerived().TransformType(TLB, TL); if (Result.isNull()) - return 0; + return nullptr; return TLB.getTypeSourceInfo(SemaRef.Context, Result); } @@ -3662,7 +3662,7 @@ TypeSourceInfo *TreeTransform::TransformTSIInObjectScope( SpecTL.getTemplateNameLoc(), ObjectType, UnqualLookup); if (Template.isNull()) - return 0; + return nullptr; Result = getDerived().TransformTemplateSpecializationType(TLB, SpecTL, Template); @@ -3676,7 +3676,7 @@ TypeSourceInfo *TreeTransform::TransformTSIInObjectScope( SpecTL.getTemplateNameLoc(), ObjectType, UnqualLookup); if (Template.isNull()) - return 0; + return nullptr; Result = getDerived().TransformDependentTemplateSpecializationType(TLB, SpecTL, @@ -3688,7 +3688,7 @@ TypeSourceInfo *TreeTransform::TransformTSIInObjectScope( } if (Result.isNull()) - return 0; + return nullptr; return TLB.getTypeSourceInfo(SemaRef.Context, Result); } @@ -3864,7 +3864,7 @@ TreeTransform::TransformMemberPointerType(TypeLocBuilder &TLB, return QualType(); TypeSourceInfo* OldClsTInfo = TL.getClassTInfo(); - TypeSourceInfo* NewClsTInfo = 0; + TypeSourceInfo *NewClsTInfo = nullptr; if (OldClsTInfo) { NewClsTInfo = getDerived().TransformType(OldClsTInfo); if (!NewClsTInfo) @@ -3971,7 +3971,7 @@ QualType TreeTransform::TransformIncompleteArrayType( IncompleteArrayTypeLoc NewTL = TLB.push(Result); NewTL.setLBracketLoc(TL.getLBracketLoc()); NewTL.setRBracketLoc(TL.getRBracketLoc()); - NewTL.setSizeExpr(0); + NewTL.setSizeExpr(nullptr); return Result; } @@ -4159,7 +4159,7 @@ ParmVarDecl *TreeTransform::TransformFunctionTypeParam( ParmVarDecl *OldParm, int indexAdjustment, Optional NumExpansions, bool ExpectParameterPack) { TypeSourceInfo *OldDI = OldParm->getTypeSourceInfo(); - TypeSourceInfo *NewDI = 0; + TypeSourceInfo *NewDI = nullptr; if (NumExpansions && isa(OldDI->getType())) { // If we're substituting into a pack expansion type and we know the @@ -4174,14 +4174,14 @@ ParmVarDecl *TreeTransform::TransformFunctionTypeParam( QualType Result = getDerived().TransformType(TLB, OldExpansionTL.getPatternLoc()); if (Result.isNull()) - return 0; + return nullptr; Result = RebuildPackExpansionType(Result, OldExpansionTL.getPatternLoc().getSourceRange(), OldExpansionTL.getEllipsisLoc(), NumExpansions); if (Result.isNull()) - return 0; + return nullptr; PackExpansionTypeLoc NewExpansionTL = TLB.push(Result); @@ -4190,7 +4190,7 @@ ParmVarDecl *TreeTransform::TransformFunctionTypeParam( } else NewDI = getDerived().TransformType(OldDI); if (!NewDI) - return 0; + return nullptr; if (NewDI == OldDI && indexAdjustment == 0) return OldParm; @@ -4203,7 +4203,7 @@ ParmVarDecl *TreeTransform::TransformFunctionTypeParam( NewDI->getType(), NewDI, OldParm->getStorageClass(), - /* DefArg */ NULL); + /* DefArg */ nullptr); newParm->setScopeInfo(OldParm->getFunctionScopeDepth(), OldParm->getFunctionScopeIndex() + indexAdjustment); return newParm; @@ -4223,7 +4223,7 @@ bool TreeTransform:: assert(OldParm->getFunctionScopeIndex() == i); Optional NumExpansions; - ParmVarDecl *NewParm = 0; + ParmVarDecl *NewParm = nullptr; if (OldParm->isParameterPack()) { // We have a function parameter pack that may need to be expanded. SmallVector Unexpanded; @@ -4352,7 +4352,7 @@ bool TreeTransform:: OutParamTypes.push_back(NewType); if (PVars) - PVars->push_back(0); + PVars->push_back(nullptr); } // We're done with the pack expansion. @@ -4369,7 +4369,7 @@ bool TreeTransform:: OutParamTypes.push_back(NewType); if (PVars) - PVars->push_back(0); + PVars->push_back(nullptr); } // We'll substitute the parameter now without expanding the pack @@ -4391,7 +4391,7 @@ bool TreeTransform:: OutParamTypes.push_back(NewType); if (PVars) - PVars->push_back(0); + PVars->push_back(nullptr); } #ifndef NDEBUG @@ -4409,7 +4409,7 @@ template QualType TreeTransform::TransformFunctionProtoType(TypeLocBuilder &TLB, FunctionProtoTypeLoc TL) { - return getDerived().TransformFunctionProtoType(TLB, TL, 0, 0); + return getDerived().TransformFunctionProtoType(TLB, TL, nullptr, 0); } template @@ -4617,8 +4617,8 @@ QualType TreeTransform::TransformDecltypeType(TypeLocBuilder &TLB, const DecltypeType *T = TL.getTypePtr(); // decltype expressions are not potentially evaluated contexts - EnterExpressionEvaluationContext Unevaluated(SemaRef, Sema::Unevaluated, 0, - /*IsDecltype=*/ true); + EnterExpressionEvaluationContext Unevaluated(SemaRef, Sema::Unevaluated, + nullptr, /*IsDecltype=*/ true); ExprResult E = getDerived().TransformExpr(T->getUnderlyingExpr()); if (E.isInvalid()) @@ -5444,7 +5444,7 @@ StmtResult TreeTransform::TransformIfStmt(IfStmt *S) { // Transform the condition ExprResult Cond; - VarDecl *ConditionVar = 0; + VarDecl *ConditionVar = nullptr; if (S->getConditionVariable()) { ConditionVar = cast_or_null( @@ -5461,7 +5461,7 @@ TreeTransform::TransformIfStmt(IfStmt *S) { // Convert the condition to a boolean value. if (S->getCond()) { - ExprResult CondE = getSema().ActOnBooleanCondition(0, S->getIfLoc(), + ExprResult CondE = getSema().ActOnBooleanCondition(nullptr, S->getIfLoc(), Cond.get()); if (CondE.isInvalid()) return StmtError(); @@ -5501,7 +5501,7 @@ StmtResult TreeTransform::TransformSwitchStmt(SwitchStmt *S) { // Transform the condition. ExprResult Cond; - VarDecl *ConditionVar = 0; + VarDecl *ConditionVar = nullptr; if (S->getConditionVariable()) { ConditionVar = cast_or_null( @@ -5539,7 +5539,7 @@ StmtResult TreeTransform::TransformWhileStmt(WhileStmt *S) { // Transform the condition ExprResult Cond; - VarDecl *ConditionVar = 0; + VarDecl *ConditionVar = nullptr; if (S->getConditionVariable()) { ConditionVar = cast_or_null( @@ -5556,7 +5556,8 @@ TreeTransform::TransformWhileStmt(WhileStmt *S) { if (S->getCond()) { // Convert the condition to a boolean value. - ExprResult CondE = getSema().ActOnBooleanCondition(0, S->getWhileLoc(), + ExprResult CondE = getSema().ActOnBooleanCondition(nullptr, + S->getWhileLoc(), Cond.get()); if (CondE.isInvalid()) return StmtError(); @@ -5616,7 +5617,7 @@ TreeTransform::TransformForStmt(ForStmt *S) { // Transform the condition ExprResult Cond; - VarDecl *ConditionVar = 0; + VarDecl *ConditionVar = nullptr; if (S->getConditionVariable()) { ConditionVar = cast_or_null( @@ -5633,7 +5634,8 @@ TreeTransform::TransformForStmt(ForStmt *S) { if (S->getCond()) { // Convert the condition to a boolean value. - ExprResult CondE = getSema().ActOnBooleanCondition(0, S->getForLoc(), + ExprResult CondE = getSema().ActOnBooleanCondition(nullptr, + S->getForLoc(), Cond.get()); if (CondE.isInvalid()) return StmtError(); @@ -5888,9 +5890,9 @@ template StmtResult TreeTransform::TransformObjCAtCatchStmt(ObjCAtCatchStmt *S) { // Transform the @catch parameter, if there is one. - VarDecl *Var = 0; + VarDecl *Var = nullptr; if (VarDecl *FromVar = S->getCatchParamDecl()) { - TypeSourceInfo *TSInfo = 0; + TypeSourceInfo *TSInfo = nullptr; if (FromVar->getTypeSourceInfo()) { TSInfo = getDerived().TransformType(FromVar->getTypeSourceInfo()); if (!TSInfo) @@ -6041,7 +6043,7 @@ TreeTransform::TransformObjCForCollectionStmt( template StmtResult TreeTransform::TransformCXXCatchStmt(CXXCatchStmt *S) { // Transform the exception declaration, if any. - VarDecl *Var = 0; + VarDecl *Var = nullptr; if (VarDecl *ExceptionDecl = S->getExceptionDecl()) { TypeSourceInfo *T = getDerived().TransformType(ExceptionDecl->getTypeSourceInfo()); @@ -6194,7 +6196,7 @@ TreeTransform::TransformMSDependentExistsStmt( CXXScopeSpec SS; SS.Adopt(QualifierLoc); bool Dependent = false; - switch (getSema().CheckMicrosoftIfExistsSymbol(/*S=*/0, SS, NameInfo)) { + switch (getSema().CheckMicrosoftIfExistsSymbol(/*S=*/nullptr, SS, NameInfo)) { case Sema::IER_Exists: if (S->isIfExists()) break; @@ -6349,7 +6351,7 @@ template StmtResult TreeTransform::TransformOMPParallelDirective(OMPParallelDirective *D) { DeclarationNameInfo DirName; - getDerived().getSema().StartOpenMPDSABlock(OMPD_parallel, DirName, 0); + getDerived().getSema().StartOpenMPDSABlock(OMPD_parallel, DirName, nullptr); StmtResult Res = getDerived().TransformOMPExecutableDirective(D); getDerived().getSema().EndOpenMPDSABlock(Res.get()); return Res; @@ -6359,7 +6361,7 @@ template StmtResult TreeTransform::TransformOMPSimdDirective(OMPSimdDirective *D) { DeclarationNameInfo DirName; - getDerived().getSema().StartOpenMPDSABlock(OMPD_simd, DirName, 0); + getDerived().getSema().StartOpenMPDSABlock(OMPD_simd, DirName, nullptr); StmtResult Res = getDerived().TransformOMPExecutableDirective(D); getDerived().getSema().EndOpenMPDSABlock(Res.get()); return Res; @@ -6370,7 +6372,7 @@ OMPClause * TreeTransform::TransformOMPIfClause(OMPIfClause *C) { ExprResult Cond = getDerived().TransformExpr(C->getCondition()); if (Cond.isInvalid()) - return 0; + return nullptr; return getDerived().RebuildOMPIfClause(Cond.take(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd()); } @@ -6380,7 +6382,7 @@ OMPClause * TreeTransform::TransformOMPNumThreadsClause(OMPNumThreadsClause *C) { ExprResult NumThreads = getDerived().TransformExpr(C->getNumThreads()); if (NumThreads.isInvalid()) - return 0; + return nullptr; return getDerived().RebuildOMPNumThreadsClause(NumThreads.take(), C->getLocStart(), C->getLParenLoc(), @@ -6392,7 +6394,7 @@ OMPClause * TreeTransform::TransformOMPSafelenClause(OMPSafelenClause *C) { ExprResult E = getDerived().TransformExpr(C->getSafelen()); if (E.isInvalid()) - return 0; + return nullptr; return getDerived().RebuildOMPSafelenClause( E.take(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd()); } @@ -6425,7 +6427,7 @@ TreeTransform::TransformOMPPrivateClause(OMPPrivateClause *C) { for (auto *VE : C->varlists()) { ExprResult EVar = getDerived().TransformExpr(cast(VE)); if (EVar.isInvalid()) - return 0; + return nullptr; Vars.push_back(EVar.take()); } return getDerived().RebuildOMPPrivateClause(Vars, @@ -6443,7 +6445,7 @@ TreeTransform::TransformOMPFirstprivateClause( for (auto *VE : C->varlists()) { ExprResult EVar = getDerived().TransformExpr(cast(VE)); if (EVar.isInvalid()) - return 0; + return nullptr; Vars.push_back(EVar.take()); } return getDerived().RebuildOMPFirstprivateClause(Vars, @@ -6460,7 +6462,7 @@ TreeTransform::TransformOMPSharedClause(OMPSharedClause *C) { for (auto *VE : C->varlists()) { ExprResult EVar = getDerived().TransformExpr(cast(VE)); if (EVar.isInvalid()) - return 0; + return nullptr; Vars.push_back(EVar.take()); } return getDerived().RebuildOMPSharedClause(Vars, @@ -6477,12 +6479,12 @@ TreeTransform::TransformOMPLinearClause(OMPLinearClause *C) { for (auto *VE : C->varlists()) { ExprResult EVar = getDerived().TransformExpr(cast(VE)); if (EVar.isInvalid()) - return 0; + return nullptr; Vars.push_back(EVar.take()); } ExprResult Step = getDerived().TransformExpr(C->getStep()); if (Step.isInvalid()) - return 0; + return nullptr; return getDerived().RebuildOMPLinearClause( Vars, Step.take(), C->getLocStart(), C->getLParenLoc(), C->getColonLoc(), C->getLocEnd()); @@ -6496,7 +6498,7 @@ TreeTransform::TransformOMPCopyinClause(OMPCopyinClause *C) { for (auto *VE : C->varlists()) { ExprResult EVar = getDerived().TransformExpr(cast(VE)); if (EVar.isInvalid()) - return 0; + return nullptr; Vars.push_back(EVar.take()); } return getDerived().RebuildOMPCopyinClause(Vars, @@ -6551,7 +6553,7 @@ TreeTransform::TransformDeclRefExpr(DeclRefExpr *E) { return SemaRef.Owned(E); } - TemplateArgumentListInfo TransArgs, *TemplateArgs = 0; + TemplateArgumentListInfo TransArgs, *TemplateArgs = nullptr; if (E->hasExplicitTemplateArgs()) { TemplateArgs = &TransArgs; TransArgs.setLAngleLoc(E->getLAngleLoc()); @@ -6622,7 +6624,7 @@ TreeTransform::TransformGenericSelectionExpr(GenericSelectionExpr *E) { return ExprError(); AssocTypes.push_back(AssocType); } else { - AssocTypes.push_back(0); + AssocTypes.push_back(nullptr); } ExprResult AssocExpr = getDerived().TransformExpr(E->getAssocExpr(i)); @@ -6934,7 +6936,7 @@ TreeTransform::TransformMemberExpr(MemberExpr *E) { // first-qualifier-in-scope here, just in case we had a dependent // base (and therefore couldn't do the check) and a // nested-name-qualifier (and therefore could do the lookup). - NamedDecl *FirstQualifierInScope = 0; + NamedDecl *FirstQualifierInScope = nullptr; return getDerived().RebuildMemberExpr(Base.get(), FakeOperatorLoc, E->isArrow(), @@ -6944,7 +6946,7 @@ TreeTransform::TransformMemberExpr(MemberExpr *E) { Member, FoundDecl, (E->hasExplicitTemplateArgs() - ? &TransArgs : 0), + ? &TransArgs : nullptr), FirstQualifierInScope); } @@ -6999,7 +7001,7 @@ TransformBinaryConditionalOperator(BinaryConditionalOperator *e) { return getDerived().RebuildConditionalOperator(commonExpr.take(), e->getQuestionLoc(), - 0, + nullptr, e->getColonLoc(), rhs.get()); } @@ -7714,7 +7716,7 @@ TreeTransform::TransformCXXNewExpr(CXXNewExpr *E) { return ExprError(); // Transform new operator and delete operator. - FunctionDecl *OperatorNew = 0; + FunctionDecl *OperatorNew = nullptr; if (E->getOperatorNew()) { OperatorNew = cast_or_null( getDerived().TransformDecl(E->getLocStart(), @@ -7723,7 +7725,7 @@ TreeTransform::TransformCXXNewExpr(CXXNewExpr *E) { return ExprError(); } - FunctionDecl *OperatorDelete = 0; + FunctionDecl *OperatorDelete = nullptr; if (E->getOperatorDelete()) { OperatorDelete = cast_or_null( getDerived().TransformDecl(E->getLocStart(), @@ -7808,7 +7810,7 @@ TreeTransform::TransformCXXDeleteExpr(CXXDeleteExpr *E) { return ExprError(); // Transform the delete operator, if known. - FunctionDecl *OperatorDelete = 0; + FunctionDecl *OperatorDelete = nullptr; if (E->getOperatorDelete()) { OperatorDelete = cast_or_null( getDerived().TransformDecl(E->getLocStart(), @@ -7854,7 +7856,7 @@ TreeTransform::TransformCXXPseudoDestructorExpr( ParsedType ObjectTypePtr; bool MayBePseudoDestructor = false; - Base = SemaRef.ActOnStartCXXMemberReference(0, Base.get(), + Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(), E->getOperatorLoc(), E->isArrow()? tok::arrow : tok::period, ObjectTypePtr, @@ -7877,7 +7879,7 @@ TreeTransform::TransformCXXPseudoDestructorExpr( if (E->getDestroyedTypeInfo()) { TypeSourceInfo *DestroyedTypeInfo = getDerived().TransformTypeInObjectScope(E->getDestroyedTypeInfo(), - ObjectType, 0, SS); + ObjectType, nullptr, SS); if (!DestroyedTypeInfo) return ExprError(); Destroyed = DestroyedTypeInfo; @@ -7891,7 +7893,7 @@ TreeTransform::TransformCXXPseudoDestructorExpr( ParsedType T = SemaRef.getDestructorName(E->getTildeLoc(), *E->getDestroyedTypeIdentifier(), E->getDestroyedTypeLoc(), - /*Scope=*/0, + /*Scope=*/nullptr, SS, ObjectTypePtr, false); if (!T) @@ -7902,11 +7904,11 @@ TreeTransform::TransformCXXPseudoDestructorExpr( E->getDestroyedTypeLoc()); } - TypeSourceInfo *ScopeTypeInfo = 0; + TypeSourceInfo *ScopeTypeInfo = nullptr; if (E->getScopeTypeInfo()) { CXXScopeSpec EmptySS; ScopeTypeInfo = getDerived().TransformTypeInObjectScope( - E->getScopeTypeInfo(), ObjectType, 0, EmptySS); + E->getScopeTypeInfo(), ObjectType, nullptr, EmptySS); if (!ScopeTypeInfo) return ExprError(); } @@ -8225,10 +8227,10 @@ TreeTransform::TransformDependentScopeDeclRefExpr( return SemaRef.Owned(E); return getDerived().RebuildDependentScopeDeclRefExpr(QualifierLoc, - TemplateKWLoc, - NameInfo, - /*TemplateArgs*/ 0, - IsAddressOfOperand); + TemplateKWLoc, + NameInfo, + /*TemplateArgs*/nullptr, + IsAddressOfOperand); } TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc()); @@ -8403,8 +8405,8 @@ TreeTransform::TransformLambdaExpr(LambdaExpr *E) { TypeSourceInfo *OldCallOpTSI = E->getCallOperator()->getTypeSourceInfo(); FunctionProtoTypeLoc OldCallOpFPTL = OldCallOpTSI->getTypeLoc().getAs(); - TypeSourceInfo *NewCallOpTSI = 0; - + TypeSourceInfo *NewCallOpTSI = nullptr; + const bool CallOpWasAlreadyTransformed = getDerived().AlreadyTransformed(OldCallOpTSI->getType()); @@ -8420,7 +8422,7 @@ TreeTransform::TransformLambdaExpr(LambdaExpr *E) { TypeLocBuilder NewCallOpTLBuilder; QualType NewCallOpType = TransformFunctionProtoType(NewCallOpTLBuilder, OldCallOpFPTL, - 0, 0); + nullptr, 0); NewCallOpTSI = NewCallOpTLBuilder.getTypeSourceInfo(getSema().Context, NewCallOpType); } @@ -8618,7 +8620,7 @@ TreeTransform::TransformLambdaScope(LambdaExpr *E, getSema().PushExpressionEvaluationContext(Sema::PotentiallyEvaluated); if (Invalid) { - getSema().ActOnLambdaError(E->getLocStart(), /*CurScope=*/0, + getSema().ActOnLambdaError(E->getLocStart(), /*CurScope=*/nullptr, /*IsInstantiation=*/true); return ExprError(); } @@ -8626,13 +8628,14 @@ TreeTransform::TransformLambdaScope(LambdaExpr *E, // Instantiate the body of the lambda expression. StmtResult Body = getDerived().TransformStmt(E->getBody()); if (Body.isInvalid()) { - getSema().ActOnLambdaError(E->getLocStart(), /*CurScope=*/0, + getSema().ActOnLambdaError(E->getLocStart(), /*CurScope=*/nullptr, /*IsInstantiation=*/true); return ExprError(); } return getSema().ActOnLambdaExpr(E->getLocStart(), Body.take(), - /*CurScope=*/0, /*IsInstantiation=*/true); + /*CurScope=*/nullptr, + /*IsInstantiation=*/true); } template @@ -8667,7 +8670,7 @@ ExprResult TreeTransform::TransformCXXDependentScopeMemberExpr( CXXDependentScopeMemberExpr *E) { // Transform the base of the expression. - ExprResult Base((Expr*) 0); + ExprResult Base((Expr*) nullptr); Expr *OldBase; QualType BaseType; QualType ObjectType; @@ -8680,7 +8683,7 @@ TreeTransform::TransformCXXDependentScopeMemberExpr( // Start the member reference and compute the object's type. ParsedType ObjectTy; bool MayBePseudoDestructor = false; - Base = SemaRef.ActOnStartCXXMemberReference(0, Base.get(), + Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(), E->getOperatorLoc(), E->isArrow()? tok::arrow : tok::period, ObjectTy, @@ -8691,7 +8694,7 @@ TreeTransform::TransformCXXDependentScopeMemberExpr( ObjectType = ObjectTy.get(); BaseType = ((Expr*) Base.get())->getType(); } else { - OldBase = 0; + OldBase = nullptr; BaseType = getDerived().TransformType(E->getBaseType()); ObjectType = BaseType->getAs()->getPointeeType(); } @@ -8743,7 +8746,7 @@ TreeTransform::TransformCXXDependentScopeMemberExpr( TemplateKWLoc, FirstQualifierInScope, NameInfo, - /*TemplateArgs*/ 0); + /*TemplateArgs*/nullptr); } TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc()); @@ -8767,7 +8770,7 @@ template ExprResult TreeTransform::TransformUnresolvedMemberExpr(UnresolvedMemberExpr *Old) { // Transform the base of the expression. - ExprResult Base((Expr*) 0); + ExprResult Base((Expr*) nullptr); QualType BaseType; if (!Old->isImplicitAccess()) { Base = getDerived().TransformExpr(Old->getBase()); @@ -8851,7 +8854,7 @@ TreeTransform::TransformUnresolvedMemberExpr(UnresolvedMemberExpr *Old) // first-qualifier-in-scope here, just in case we had a dependent // base (and therefore couldn't do the check) and a // nested-name-qualifier (and therefore could do the lookup). - NamedDecl *FirstQualifierInScope = 0; + NamedDecl *FirstQualifierInScope = nullptr; return getDerived().RebuildUnresolvedMemberExpr(Base.get(), BaseType, @@ -8862,7 +8865,7 @@ TreeTransform::TransformUnresolvedMemberExpr(UnresolvedMemberExpr *Old) FirstQualifierInScope, R, (Old->hasExplicitTemplateArgs() - ? &TransArgs : 0)); + ? &TransArgs : nullptr)); } template @@ -9396,7 +9399,7 @@ ExprResult TreeTransform::TransformBlockExpr(BlockExpr *E) { BlockDecl *oldBlock = E->getBlockDecl(); - SemaRef.ActOnBlockStart(E->getCaretLocation(), /*Scope=*/0); + SemaRef.ActOnBlockStart(E->getCaretLocation(), /*Scope=*/nullptr); BlockScopeInfo *blockScope = SemaRef.getCurBlock(); blockScope->TheDecl->setIsVariadic(oldBlock->isVariadic()); @@ -9410,8 +9413,8 @@ TreeTransform::TransformBlockExpr(BlockExpr *E) { if (getDerived().TransformFunctionTypeParams(E->getCaretLocation(), oldBlock->param_begin(), oldBlock->param_size(), - 0, paramTypes, ¶ms)) { - getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/0); + nullptr, paramTypes, ¶ms)) { + getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr); return ExprError(); } @@ -9436,7 +9439,7 @@ TreeTransform::TransformBlockExpr(BlockExpr *E) { // Transform the body StmtResult body = getDerived().TransformStmt(E->getBody()); if (body.isInvalid()) { - getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/0); + getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr); return ExprError(); } @@ -9462,7 +9465,7 @@ TreeTransform::TransformBlockExpr(BlockExpr *E) { #endif return SemaRef.ActOnBlockStmtExpr(E->getCaretLocation(), body.get(), - /*Scope=*/0); + /*Scope=*/nullptr); } template @@ -9569,7 +9572,7 @@ TreeTransform::RebuildConstantArrayType(QualType ElementType, const llvm::APInt &Size, unsigned IndexTypeQuals, SourceRange BracketsRange) { - return getDerived().RebuildArrayType(ElementType, SizeMod, &Size, 0, + return getDerived().RebuildArrayType(ElementType, SizeMod, &Size, nullptr, IndexTypeQuals, BracketsRange); } @@ -9579,7 +9582,7 @@ TreeTransform::RebuildIncompleteArrayType(QualType ElementType, ArrayType::ArraySizeModifier SizeMod, unsigned IndexTypeQuals, SourceRange BracketsRange) { - return getDerived().RebuildArrayType(ElementType, SizeMod, 0, 0, + return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr, nullptr, IndexTypeQuals, BracketsRange); } @@ -9590,7 +9593,7 @@ TreeTransform::RebuildVariableArrayType(QualType ElementType, Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange) { - return getDerived().RebuildArrayType(ElementType, SizeMod, 0, + return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr, SizeExpr, IndexTypeQuals, BracketsRange); } @@ -9602,7 +9605,7 @@ TreeTransform::RebuildDependentSizedArrayType(QualType ElementType, Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange) { - return getDerived().RebuildArrayType(ElementType, SizeMod, 0, + return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr, SizeExpr, IndexTypeQuals, BracketsRange); } @@ -9734,7 +9737,7 @@ TreeTransform::RebuildTemplateName(CXXScopeSpec &SS, TemplateName.setIdentifier(&Name, NameLoc); Sema::TemplateTy Template; SourceLocation TemplateKWLoc; // FIXME: retrieve it from caller. - getSema().ActOnDependentTemplateName(/*Scope=*/0, + getSema().ActOnDependentTemplateName(/*Scope=*/nullptr, SS, TemplateKWLoc, TemplateName, ParsedType::make(ObjectType), /*EnteringContext=*/false, @@ -9754,7 +9757,7 @@ TreeTransform::RebuildTemplateName(CXXScopeSpec &SS, Name.setOperatorFunctionId(NameLoc, Operator, SymbolLocations); SourceLocation TemplateKWLoc; // FIXME: retrieve it from caller. Sema::TemplateTy Template; - getSema().ActOnDependentTemplateName(/*Scope=*/0, + getSema().ActOnDependentTemplateName(/*Scope=*/nullptr, SS, TemplateKWLoc, Name, ParsedType::make(ObjectType), /*EnteringContext=*/false, @@ -9781,8 +9784,8 @@ TreeTransform::RebuildCXXOperatorCallExpr(OverloadedOperatorKind Op, Second, OpLoc); } else if (Op == OO_Arrow) { // -> is never a builtin operation. - return SemaRef.BuildOverloadedArrowExpr(0, First, OpLoc); - } else if (Second == 0 || isPostIncDec) { + return SemaRef.BuildOverloadedArrowExpr(nullptr, First, OpLoc); + } else if (Second == nullptr || isPostIncDec) { if (!First->getType()->isOverloadableType()) { // The argument is not of overloadable type, so try to create a // built-in unary operation. @@ -9824,7 +9827,7 @@ TreeTransform::RebuildCXXOperatorCallExpr(OverloadedOperatorKind Op, // Add any functions found via argument-dependent lookup. Expr *Args[2] = { First, Second }; - unsigned NumArgs = 1 + (Second != 0); + unsigned NumArgs = 1 + (Second != nullptr); // Create the overloaded operator invocation for unary operators. if (NumArgs == 1 || isPostIncDec) { @@ -9902,9 +9905,9 @@ TreeTransform::RebuildCXXPseudoDestructorExpr(Expr *Base, return getSema().BuildMemberReferenceExpr(Base, BaseType, OperatorLoc, isArrow, SS, TemplateKWLoc, - /*FIXME: FirstQualifier*/ 0, + /*FIXME: FirstQualifier*/ nullptr, NameInfo, - /*TemplateArgs*/ 0); + /*TemplateArgs*/ nullptr); } template @@ -9925,7 +9928,7 @@ TreeTransform::TransformCapturedStmt(CapturedStmt *S) { Params.push_back(std::make_pair(StringRef(), QualType())); } } - getSema().ActOnCapturedRegionStart(Loc, /*CurScope*/0, + getSema().ActOnCapturedRegionStart(Loc, /*CurScope*/nullptr, S->getCapturedRegionKind(), Params); StmtResult Body = getDerived().TransformStmt(S->getCapturedStmt()); diff --git a/clang/lib/Sema/TypeLocBuilder.cpp b/clang/lib/Sema/TypeLocBuilder.cpp index c7d43b7..be99540 100644 --- a/clang/lib/Sema/TypeLocBuilder.cpp +++ b/clang/lib/Sema/TypeLocBuilder.cpp @@ -62,7 +62,7 @@ void TypeLocBuilder::grow(size_t NewCapacity) { TypeLoc TypeLocBuilder::pushImpl(QualType T, size_t LocalSize, unsigned LocalAlignment) { #ifndef NDEBUG - QualType TLast = TypeLoc(T, 0).getNextTypeLoc().getType(); + QualType TLast = TypeLoc(T, nullptr).getNextTypeLoc().getType(); assert(TLast == LastTy && "mismatch between last type and new type's inner type"); LastTy = T; diff --git a/clang/lib/Sema/TypeLocBuilder.h b/clang/lib/Sema/TypeLocBuilder.h index b1e9098..c3f874e 100644 --- a/clang/lib/Sema/TypeLocBuilder.h +++ b/clang/lib/Sema/TypeLocBuilder.h @@ -94,7 +94,7 @@ class TypeLocBuilder { /// Pushes space for a new TypeLoc of the given type. Invalidates /// any TypeLocs previously retrieved from this builder. template TyLocType push(QualType T) { - TyLocType Loc = TypeLoc(T, 0).castAs(); + TyLocType Loc = TypeLoc(T, nullptr).castAs(); size_t LocalSize = Loc.getLocalDataSize(); unsigned LocalAlign = Loc.getLocalDataAlignment(); return pushImpl(T, LocalSize, LocalAlign).castAs();