From 613c4e1cde9bc967e9610869c5eacc6ec74c39ef Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Mon, 12 May 2014 05:36:57 +0000 Subject: [PATCH] [C++11] Use 'nullptr'. AST edition. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208517 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/APValue.cpp | 9 +- lib/AST/ASTContext.cpp | 322 ++++++++++---------- lib/AST/ASTDiagnostic.cpp | 27 +- lib/AST/ASTDumper.cpp | 24 +- lib/AST/ASTImporter.cpp | 464 ++++++++++++++--------------- lib/AST/ASTTypeTraits.cpp | 2 +- lib/AST/CXXInheritance.cpp | 12 +- lib/AST/Comment.cpp | 2 +- lib/AST/CommentCommandTraits.cpp | 4 +- lib/AST/CommentParser.cpp | 6 +- lib/AST/CommentSema.cpp | 11 +- lib/AST/Decl.cpp | 154 +++++----- lib/AST/DeclBase.cpp | 36 +-- lib/AST/DeclCXX.cpp | 121 ++++---- lib/AST/DeclFriend.cpp | 2 +- lib/AST/DeclObjC.cpp | 157 +++++----- lib/AST/DeclOpenMP.cpp | 2 +- lib/AST/DeclPrinter.cpp | 37 +-- lib/AST/DeclTemplate.cpp | 73 ++--- lib/AST/DeclarationName.cpp | 16 +- lib/AST/Expr.cpp | 45 +-- lib/AST/ExprCXX.cpp | 66 ++-- lib/AST/ExprClassification.cpp | 7 +- lib/AST/ExprConstant.cpp | 113 +++---- lib/AST/ExternalASTSource.cpp | 6 +- lib/AST/ItaniumMangle.cpp | 52 ++-- lib/AST/MangleNumberingContext.cpp | 4 +- lib/AST/MicrosoftMangle.cpp | 24 +- lib/AST/NSAPI.cpp | 6 +- lib/AST/NestedNameSpecifier.cpp | 22 +- lib/AST/ParentMap.cpp | 8 +- lib/AST/RecordLayout.cpp | 6 +- lib/AST/RecordLayoutBuilder.cpp | 55 ++-- lib/AST/Stmt.cpp | 39 ++- lib/AST/StmtIterator.cpp | 8 +- lib/AST/StmtPrinter.cpp | 22 +- lib/AST/StmtProfile.cpp | 8 +- lib/AST/TemplateBase.cpp | 6 +- lib/AST/TemplateName.cpp | 4 +- lib/AST/Type.cpp | 51 ++-- lib/AST/TypeLoc.cpp | 4 +- lib/AST/TypePrinter.cpp | 14 +- lib/AST/VTableBuilder.cpp | 37 +-- 43 files changed, 1069 insertions(+), 1019 deletions(-) diff --git a/lib/AST/APValue.cpp b/lib/AST/APValue.cpp index 049518e933..e7b5a6be34 100644 --- a/lib/AST/APValue.cpp +++ b/lib/AST/APValue.cpp @@ -117,7 +117,7 @@ APValue::StructData::~StructData() { delete [] Elts; } -APValue::UnionData::UnionData() : Field(0), Value(new APValue) {} +APValue::UnionData::UnionData() : Field(nullptr), Value(new APValue) {} APValue::UnionData::~UnionData () { delete Value; } @@ -404,7 +404,8 @@ void APValue::printPretty(raw_ostream &Out, ASTContext &Ctx, QualType Ty) const{ if (const ValueDecl *VD = Base.dyn_cast()) Out << *VD; else - Base.get()->printPretty(Out, 0, Ctx.getPrintingPolicy()); + Base.get()->printPretty(Out, nullptr, + Ctx.getPrintingPolicy()); if (!O.isZero()) { Out << " + " << (O / S); if (IsReference) @@ -425,12 +426,12 @@ void APValue::printPretty(raw_ostream &Out, ASTContext &Ctx, QualType Ty) const{ ElemTy = VD->getType(); } else { const Expr *E = Base.get(); - E->printPretty(Out, 0, Ctx.getPrintingPolicy()); + E->printPretty(Out, nullptr, Ctx.getPrintingPolicy()); ElemTy = E->getType(); } ArrayRef Path = getLValuePath(); - const CXXRecordDecl *CastToBase = 0; + const CXXRecordDecl *CastToBase = nullptr; for (unsigned I = 0, N = Path.size(); I != N; ++I) { if (ElemTy->getAs()) { // The lvalue refers to a class type, so the next path entry is a base diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index e46a6c024d..3b15e282bb 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -77,23 +77,23 @@ RawComment *ASTContext::getRawCommentForDeclNoCache(const Decl *D) const { // User can not attach documentation to implicit declarations. if (D->isImplicit()) - return NULL; + return nullptr; // User can not attach documentation to implicit instantiations. if (const FunctionDecl *FD = dyn_cast(D)) { if (FD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation) - return NULL; + return nullptr; } if (const VarDecl *VD = dyn_cast(D)) { if (VD->isStaticDataMember() && VD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation) - return NULL; + return nullptr; } if (const CXXRecordDecl *CRD = dyn_cast(D)) { if (CRD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation) - return NULL; + return nullptr; } if (const ClassTemplateSpecializationDecl *CTSD = @@ -101,35 +101,35 @@ RawComment *ASTContext::getRawCommentForDeclNoCache(const Decl *D) const { TemplateSpecializationKind TSK = CTSD->getSpecializationKind(); if (TSK == TSK_ImplicitInstantiation || TSK == TSK_Undeclared) - return NULL; + return nullptr; } if (const EnumDecl *ED = dyn_cast(D)) { if (ED->getTemplateSpecializationKind() == TSK_ImplicitInstantiation) - return NULL; + return nullptr; } if (const TagDecl *TD = dyn_cast(D)) { // When tag declaration (but not definition!) is part of the // decl-specifier-seq of some other declaration, it doesn't get comment if (TD->isEmbeddedInDeclarator() && !TD->isCompleteDefinition()) - return NULL; + return nullptr; } // TODO: handle comments for function parameters properly. if (isa(D)) - return NULL; + return nullptr; // TODO: we could look up template parameter documentation in the template // documentation. if (isa(D) || isa(D) || isa(D)) - return NULL; + return nullptr; ArrayRef RawComments = Comments.getComments(); // If there are no comments anywhere, we won't find anything. if (RawComments.empty()) - return NULL; + return nullptr; // Find declaration location. // For Objective-C declarations we generally don't expect to have multiple @@ -167,7 +167,7 @@ RawComment *ASTContext::getRawCommentForDeclNoCache(const Decl *D) const { // If the declaration doesn't map directly to a location in a file, we // can't find the comment. if (DeclLoc.isInvalid() || !DeclLoc.isFileID()) - return NULL; + return nullptr; // Find the comment that occurs just after this declaration. ArrayRef::iterator Comment; @@ -221,12 +221,12 @@ RawComment *ASTContext::getRawCommentForDeclNoCache(const Decl *D) const { // The comment just after the declaration was not a trailing comment. // Let's look at the previous comment. if (Comment == RawComments.begin()) - return NULL; + return nullptr; --Comment; // Check that we actually have a non-member Doxygen comment. if (!(*Comment)->isDocumentation() || (*Comment)->isTrailingComment()) - return NULL; + return nullptr; // Decompose the end of the comment. std::pair CommentEndDecomp @@ -235,14 +235,14 @@ RawComment *ASTContext::getRawCommentForDeclNoCache(const Decl *D) const { // If the comment and the declaration aren't in the same file, then they // aren't related. if (DeclLocDecomp.first != CommentEndDecomp.first) - return NULL; + return nullptr; // Get the corresponding buffer. bool Invalid = false; const char *Buffer = SourceMgr.getBufferData(DeclLocDecomp.first, &Invalid).data(); if (Invalid) - return NULL; + return nullptr; // Extract text between the comment and declaration. StringRef Text(Buffer + CommentEndDecomp.second, @@ -251,7 +251,7 @@ RawComment *ASTContext::getRawCommentForDeclNoCache(const Decl *D) const { // There should be no other declarations or preprocessor directives between // comment and declaration. if (Text.find_first_of(";{}#@") != StringRef::npos) - return NULL; + return nullptr; return *Comment; } @@ -349,8 +349,8 @@ const RawComment *ASTContext::getRawCommentForAnyRedecl( } // Search for comments attached to declarations in the redeclaration chain. - const RawComment *RC = NULL; - const Decl *OriginalDeclForRC = NULL; + const RawComment *RC = nullptr; + const Decl *OriginalDeclForRC = nullptr; for (auto I : D->redecls()) { llvm::DenseMap::iterator Pos = RedeclComments.find(I); @@ -433,14 +433,14 @@ comments::FullComment *ASTContext::cloneFullComment(comments::FullComment *FC, comments::FullComment *ASTContext::getLocalCommentForDeclUncached(const Decl *D) const { const RawComment *RC = getRawCommentForDeclNoCache(D); - return RC ? RC->parse(*this, 0, D) : 0; + return RC ? RC->parse(*this, nullptr, D) : nullptr; } comments::FullComment *ASTContext::getCommentForDecl( const Decl *D, const Preprocessor *PP) const { if (D->isInvalidDecl()) - return NULL; + return nullptr; D = adjustDeclToTemplate(D); const Decl *Canonical = D->getCanonicalDecl(); @@ -497,7 +497,7 @@ comments::FullComment *ASTContext::getCommentForDecl( } else if (const CXXRecordDecl *RD = dyn_cast(D)) { if (!(RD = RD->getDefinition())) - return NULL; + return nullptr; // Check non-virtual bases. for (const auto &I : RD->bases()) { if (I.isVirtual() || (I.getAccessSpecifier() != AS_public)) @@ -528,7 +528,7 @@ comments::FullComment *ASTContext::getCommentForDecl( } } } - return NULL; + return nullptr; } // If the RawComment was attached to other redeclaration of this Decl, we @@ -589,7 +589,7 @@ ASTContext::getCanonicalTemplateTemplateParmDecl( // Check if we already have a canonical template template parameter. llvm::FoldingSetNodeID ID; CanonicalTemplateTemplateParm::Profile(ID, TTP); - void *InsertPos = 0; + void *InsertPos = nullptr; CanonicalTemplateTemplateParm *Canonical = CanonTemplateTemplateParms.FindNodeOrInsertPos(ID, InsertPos); if (Canonical) @@ -608,7 +608,7 @@ ASTContext::getCanonicalTemplateTemplateParmDecl( SourceLocation(), SourceLocation(), TTP->getDepth(), - TTP->getIndex(), 0, false, + TTP->getIndex(), nullptr, false, TTP->isParameterPack())); else if (NonTypeTemplateParmDecl *NTTP = dyn_cast(*P)) { @@ -628,7 +628,7 @@ ASTContext::getCanonicalTemplateTemplateParmDecl( SourceLocation(), SourceLocation(), NTTP->getDepth(), - NTTP->getPosition(), 0, + NTTP->getPosition(), nullptr, T, TInfo, ExpandedTypes.data(), @@ -639,7 +639,7 @@ ASTContext::getCanonicalTemplateTemplateParmDecl( SourceLocation(), SourceLocation(), NTTP->getDepth(), - NTTP->getPosition(), 0, + NTTP->getPosition(), nullptr, T, NTTP->isParameterPack(), TInfo); @@ -656,7 +656,7 @@ ASTContext::getCanonicalTemplateTemplateParmDecl( SourceLocation(), TTP->getDepth(), TTP->getPosition(), TTP->isParameterPack(), - 0, + nullptr, TemplateParameterList::Create(*this, SourceLocation(), SourceLocation(), CanonParams.data(), @@ -665,7 +665,7 @@ ASTContext::getCanonicalTemplateTemplateParmDecl( // Get the new insert position for the node we care about. Canonical = CanonTemplateTemplateParms.FindNodeOrInsertPos(ID, InsertPos); - assert(Canonical == 0 && "Shouldn't be in the map!"); + assert(!Canonical && "Shouldn't be in the map!"); (void)Canonical; // Create the canonical template template parameter entry. @@ -675,7 +675,7 @@ ASTContext::getCanonicalTemplateTemplateParmDecl( } CXXABI *ASTContext::createCXXABI(const TargetInfo &T) { - if (!LangOpts.CPlusPlus) return 0; + if (!LangOpts.CPlusPlus) return nullptr; switch (T.getCXXABI().getKind()) { case TargetCXXABI::GenericARM: @@ -730,27 +730,27 @@ ASTContext::ASTContext(LangOptions& LOpts, SourceManager &SM, TemplateSpecializationTypes(this_()), DependentTemplateSpecializationTypes(this_()), SubstTemplateTemplateParmPacks(this_()), - GlobalNestedNameSpecifier(0), - Int128Decl(0), UInt128Decl(0), Float128StubDecl(0), - BuiltinVaListDecl(0), - ObjCIdDecl(0), ObjCSelDecl(0), ObjCClassDecl(0), ObjCProtocolClassDecl(0), - BOOLDecl(0), - CFConstantStringTypeDecl(0), ObjCInstanceTypeDecl(0), - FILEDecl(0), - jmp_bufDecl(0), sigjmp_bufDecl(0), ucontext_tDecl(0), - BlockDescriptorType(0), BlockDescriptorExtendedType(0), - cudaConfigureCallDecl(0), + GlobalNestedNameSpecifier(nullptr), + Int128Decl(nullptr), UInt128Decl(nullptr), Float128StubDecl(nullptr), + BuiltinVaListDecl(nullptr), + ObjCIdDecl(nullptr), ObjCSelDecl(nullptr), ObjCClassDecl(nullptr), + ObjCProtocolClassDecl(nullptr), BOOLDecl(nullptr), + CFConstantStringTypeDecl(nullptr), ObjCInstanceTypeDecl(nullptr), + FILEDecl(nullptr), + jmp_bufDecl(nullptr), sigjmp_bufDecl(nullptr), ucontext_tDecl(nullptr), + BlockDescriptorType(nullptr), BlockDescriptorExtendedType(nullptr), + cudaConfigureCallDecl(nullptr), NullTypeSourceInfo(QualType()), FirstLocalImport(), LastLocalImport(), SourceMgr(SM), LangOpts(LOpts), - AddrSpaceMap(0), Target(0), PrintingPolicy(LOpts), + AddrSpaceMap(nullptr), Target(nullptr), PrintingPolicy(LOpts), Idents(idents), Selectors(sels), BuiltinInfo(builtins), DeclarationNames(*this), - ExternalSource(0), Listener(0), + ExternalSource(nullptr), Listener(nullptr), Comments(SM), CommentsLoaded(false), CommentCommandTraits(BumpAlloc, LOpts.CommentOpts), - LastSDM(0, 0) + LastSDM(nullptr, 0) { TUDecl = TranslationUnitDecl::Create(*this); } @@ -1109,7 +1109,7 @@ FunctionDecl *ASTContext::getClassScopeSpecializationPattern( llvm::DenseMap::const_iterator Pos = ClassScopeSpecializationPattern.find(FD); if (Pos == ClassScopeSpecializationPattern.end()) - return 0; + return nullptr; return Pos->second; } @@ -1126,7 +1126,7 @@ ASTContext::getInstantiatedFromUsingDecl(UsingDecl *UUD) { llvm::DenseMap::const_iterator Pos = InstantiatedFromUsingDecl.find(UUD); if (Pos == InstantiatedFromUsingDecl.end()) - return 0; + return nullptr; return Pos->second; } @@ -1146,7 +1146,7 @@ ASTContext::getInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst) { llvm::DenseMap::const_iterator Pos = InstantiatedFromUsingShadowDecl.find(Inst); if (Pos == InstantiatedFromUsingShadowDecl.end()) - return 0; + return nullptr; return Pos->second; } @@ -1162,7 +1162,7 @@ FieldDecl *ASTContext::getInstantiatedFromUnnamedFieldDecl(FieldDecl *Field) { llvm::DenseMap::iterator Pos = InstantiatedFromUnnamedFieldDecl.find(Field); if (Pos == InstantiatedFromUnnamedFieldDecl.end()) - return 0; + return nullptr; return Pos->second; } @@ -1182,7 +1182,7 @@ ASTContext::overridden_methods_begin(const CXXMethodDecl *Method) const { llvm::DenseMap::const_iterator Pos = OverriddenMethods.find(Method->getCanonicalDecl()); if (Pos == OverriddenMethods.end()) - return 0; + return nullptr; return Pos->second.begin(); } @@ -1192,7 +1192,7 @@ ASTContext::overridden_methods_end(const CXXMethodDecl *Method) const { llvm::DenseMap::const_iterator Pos = OverriddenMethods.find(Method->getCanonicalDecl()); if (Pos == OverriddenMethods.end()) - return 0; + return nullptr; return Pos->second.end(); } @@ -1894,7 +1894,7 @@ ObjCImplementationDecl *ASTContext::getObjCImplementation(ObjCInterfaceDecl *D) I = ObjCImpls.find(D); if (I != ObjCImpls.end()) return cast(I->second); - return 0; + return nullptr; } /// \brief Get the implementation of ObjCCategoryDecl, or NULL if none exists. ObjCCategoryImplDecl *ASTContext::getObjCImplementation(ObjCCategoryDecl *D) { @@ -1902,7 +1902,7 @@ ObjCCategoryImplDecl *ASTContext::getObjCImplementation(ObjCCategoryDecl *D) { I = ObjCImpls.find(D); if (I != ObjCImpls.end()) return cast(I->second); - return 0; + return nullptr; } /// \brief Set the implementation of ObjCInterfaceDecl. @@ -1930,7 +1930,7 @@ const ObjCInterfaceDecl *ASTContext::getObjContainingInterface( dyn_cast(ND->getDeclContext())) return IMD->getClassInterface(); - return 0; + return nullptr; } /// \brief Get the copy initialization expression of VarDecl,or NULL if @@ -1941,7 +1941,7 @@ Expr *ASTContext::getBlockVarCopyInits(const VarDecl*VD) { "getBlockVarCopyInits - not __block var"); llvm::DenseMap::iterator I = BlockVarCopyInits.find(VD); - return (I != BlockVarCopyInits.end()) ? cast(I->second) : 0; + return (I != BlockVarCopyInits.end()) ? cast(I->second) : nullptr; } /// \brief Set the copy inialization expression of a block var decl. @@ -1975,7 +1975,7 @@ TypeSourceInfo *ASTContext::getTrivialTypeSourceInfo(QualType T, const ASTRecordLayout & ASTContext::getASTObjCInterfaceLayout(const ObjCInterfaceDecl *D) const { - return getObjCLayout(D, 0); + return getObjCLayout(D, nullptr); } const ASTRecordLayout & @@ -1996,7 +1996,7 @@ ASTContext::getExtQualType(const Type *baseType, Qualifiers quals) const { // Check if we've already instantiated this type. llvm::FoldingSetNodeID ID; ExtQuals::Profile(ID, baseType, quals); - void *insertPos = 0; + void *insertPos = nullptr; if (ExtQuals *eq = ExtQualNodes.FindNodeOrInsertPos(ID, insertPos)) { assert(eq->getQualifiers() == quals); return QualType(eq, fastQuals); @@ -2108,7 +2108,7 @@ QualType ASTContext::getComplexType(QualType T) const { llvm::FoldingSetNodeID ID; ComplexType::Profile(ID, T); - void *InsertPos = 0; + void *InsertPos = nullptr; if (ComplexType *CT = ComplexTypes.FindNodeOrInsertPos(ID, InsertPos)) return QualType(CT, 0); @@ -2120,7 +2120,7 @@ QualType ASTContext::getComplexType(QualType T) const { // Get the new insert position for the node we care about. ComplexType *NewIP = ComplexTypes.FindNodeOrInsertPos(ID, InsertPos); - assert(NewIP == 0 && "Shouldn't be in the map!"); (void)NewIP; + assert(!NewIP && "Shouldn't be in the map!"); (void)NewIP; } ComplexType *New = new (*this, TypeAlignment) ComplexType(T, Canonical); Types.push_back(New); @@ -2136,7 +2136,7 @@ QualType ASTContext::getPointerType(QualType T) const { llvm::FoldingSetNodeID ID; PointerType::Profile(ID, T); - void *InsertPos = 0; + void *InsertPos = nullptr; if (PointerType *PT = PointerTypes.FindNodeOrInsertPos(ID, InsertPos)) return QualType(PT, 0); @@ -2148,7 +2148,7 @@ QualType ASTContext::getPointerType(QualType T) const { // Get the new insert position for the node we care about. PointerType *NewIP = PointerTypes.FindNodeOrInsertPos(ID, InsertPos); - assert(NewIP == 0 && "Shouldn't be in the map!"); (void)NewIP; + assert(!NewIP && "Shouldn't be in the map!"); (void)NewIP; } PointerType *New = new (*this, TypeAlignment) PointerType(T, Canonical); Types.push_back(New); @@ -2159,7 +2159,7 @@ QualType ASTContext::getPointerType(QualType T) const { QualType ASTContext::getAdjustedType(QualType Orig, QualType New) const { llvm::FoldingSetNodeID ID; AdjustedType::Profile(ID, Orig, New); - void *InsertPos = 0; + void *InsertPos = nullptr; AdjustedType *AT = AdjustedTypes.FindNodeOrInsertPos(ID, InsertPos); if (AT) return QualType(AT, 0); @@ -2168,7 +2168,7 @@ QualType ASTContext::getAdjustedType(QualType Orig, QualType New) const { // Get the new insert position for the node we care about. AT = AdjustedTypes.FindNodeOrInsertPos(ID, InsertPos); - assert(AT == 0 && "Shouldn't be in the map!"); + assert(!AT && "Shouldn't be in the map!"); AT = new (*this, TypeAlignment) AdjustedType(Type::Adjusted, Orig, New, Canonical); @@ -2199,7 +2199,7 @@ QualType ASTContext::getDecayedType(QualType T) const { llvm::FoldingSetNodeID ID; AdjustedType::Profile(ID, T, Decayed); - void *InsertPos = 0; + void *InsertPos = nullptr; AdjustedType *AT = AdjustedTypes.FindNodeOrInsertPos(ID, InsertPos); if (AT) return QualType(AT, 0); @@ -2208,7 +2208,7 @@ QualType ASTContext::getDecayedType(QualType T) const { // Get the new insert position for the node we care about. AT = AdjustedTypes.FindNodeOrInsertPos(ID, InsertPos); - assert(AT == 0 && "Shouldn't be in the map!"); + assert(!AT && "Shouldn't be in the map!"); AT = new (*this, TypeAlignment) DecayedType(T, Decayed, Canonical); Types.push_back(AT); @@ -2225,7 +2225,7 @@ QualType ASTContext::getBlockPointerType(QualType T) const { llvm::FoldingSetNodeID ID; BlockPointerType::Profile(ID, T); - void *InsertPos = 0; + void *InsertPos = nullptr; if (BlockPointerType *PT = BlockPointerTypes.FindNodeOrInsertPos(ID, InsertPos)) return QualType(PT, 0); @@ -2239,7 +2239,7 @@ QualType ASTContext::getBlockPointerType(QualType T) const { // Get the new insert position for the node we care about. BlockPointerType *NewIP = BlockPointerTypes.FindNodeOrInsertPos(ID, InsertPos); - assert(NewIP == 0 && "Shouldn't be in the map!"); (void)NewIP; + assert(!NewIP && "Shouldn't be in the map!"); (void)NewIP; } BlockPointerType *New = new (*this, TypeAlignment) BlockPointerType(T, Canonical); @@ -2260,7 +2260,7 @@ ASTContext::getLValueReferenceType(QualType T, bool SpelledAsLValue) const { llvm::FoldingSetNodeID ID; ReferenceType::Profile(ID, T, SpelledAsLValue); - void *InsertPos = 0; + void *InsertPos = nullptr; if (LValueReferenceType *RT = LValueReferenceTypes.FindNodeOrInsertPos(ID, InsertPos)) return QualType(RT, 0); @@ -2277,7 +2277,7 @@ ASTContext::getLValueReferenceType(QualType T, bool SpelledAsLValue) const { // Get the new insert position for the node we care about. LValueReferenceType *NewIP = LValueReferenceTypes.FindNodeOrInsertPos(ID, InsertPos); - assert(NewIP == 0 && "Shouldn't be in the map!"); (void)NewIP; + assert(!NewIP && "Shouldn't be in the map!"); (void)NewIP; } LValueReferenceType *New @@ -2297,7 +2297,7 @@ QualType ASTContext::getRValueReferenceType(QualType T) const { llvm::FoldingSetNodeID ID; ReferenceType::Profile(ID, T, false); - void *InsertPos = 0; + void *InsertPos = nullptr; if (RValueReferenceType *RT = RValueReferenceTypes.FindNodeOrInsertPos(ID, InsertPos)) return QualType(RT, 0); @@ -2314,7 +2314,7 @@ QualType ASTContext::getRValueReferenceType(QualType T) const { // Get the new insert position for the node we care about. RValueReferenceType *NewIP = RValueReferenceTypes.FindNodeOrInsertPos(ID, InsertPos); - assert(NewIP == 0 && "Shouldn't be in the map!"); (void)NewIP; + assert(!NewIP && "Shouldn't be in the map!"); (void)NewIP; } RValueReferenceType *New @@ -2332,7 +2332,7 @@ QualType ASTContext::getMemberPointerType(QualType T, const Type *Cls) const { llvm::FoldingSetNodeID ID; MemberPointerType::Profile(ID, T, Cls); - void *InsertPos = 0; + void *InsertPos = nullptr; if (MemberPointerType *PT = MemberPointerTypes.FindNodeOrInsertPos(ID, InsertPos)) return QualType(PT, 0); @@ -2346,7 +2346,7 @@ QualType ASTContext::getMemberPointerType(QualType T, const Type *Cls) const { // Get the new insert position for the node we care about. MemberPointerType *NewIP = MemberPointerTypes.FindNodeOrInsertPos(ID, InsertPos); - assert(NewIP == 0 && "Shouldn't be in the map!"); (void)NewIP; + assert(!NewIP && "Shouldn't be in the map!"); (void)NewIP; } MemberPointerType *New = new (*this, TypeAlignment) MemberPointerType(T, Cls, Canonical); @@ -2374,7 +2374,7 @@ QualType ASTContext::getConstantArrayType(QualType EltTy, llvm::FoldingSetNodeID ID; ConstantArrayType::Profile(ID, EltTy, ArySize, ASM, IndexTypeQuals); - void *InsertPos = 0; + void *InsertPos = nullptr; if (ConstantArrayType *ATP = ConstantArrayTypes.FindNodeOrInsertPos(ID, InsertPos)) return QualType(ATP, 0); @@ -2391,7 +2391,7 @@ QualType ASTContext::getConstantArrayType(QualType EltTy, // Get the new insert position for the node we care about. ConstantArrayType *NewIP = ConstantArrayTypes.FindNodeOrInsertPos(ID, InsertPos); - assert(NewIP == 0 && "Shouldn't be in the map!"); (void)NewIP; + assert(!NewIP && "Shouldn't be in the map!"); (void)NewIP; } ConstantArrayType *New = new(*this,TypeAlignment) @@ -2509,7 +2509,7 @@ QualType ASTContext::getVariableArrayDecayedType(QualType type) const { const IncompleteArrayType *iat = cast(ty); result = getVariableArrayType( getVariableArrayDecayedType(iat->getElementType()), - /*size*/ 0, + /*size*/ nullptr, ArrayType::Normal, iat->getIndexTypeCVRQualifiers(), SourceRange()); @@ -2521,7 +2521,7 @@ QualType ASTContext::getVariableArrayDecayedType(QualType type) const { const VariableArrayType *vat = cast(ty); result = getVariableArrayType( getVariableArrayDecayedType(vat->getElementType()), - /*size*/ 0, + /*size*/ nullptr, ArrayType::Star, vat->getIndexTypeCVRQualifiers(), vat->getBracketsRange()); @@ -2591,7 +2591,7 @@ QualType ASTContext::getDependentSizedArrayType(QualType elementType, SplitQualType canonElementType = getCanonicalType(elementType).split(); - void *insertPos = 0; + void *insertPos = nullptr; llvm::FoldingSetNodeID ID; DependentSizedArrayType::Profile(ID, *this, QualType(canonElementType.Ty, 0), @@ -2636,7 +2636,7 @@ QualType ASTContext::getIncompleteArrayType(QualType elementType, llvm::FoldingSetNodeID ID; IncompleteArrayType::Profile(ID, elementType, ASM, elementTypeQuals); - void *insertPos = 0; + void *insertPos = nullptr; if (IncompleteArrayType *iat = IncompleteArrayTypes.FindNodeOrInsertPos(ID, insertPos)) return QualType(iat, 0); @@ -2676,7 +2676,7 @@ QualType ASTContext::getVectorType(QualType vecType, unsigned NumElts, llvm::FoldingSetNodeID ID; VectorType::Profile(ID, vecType, NumElts, Type::Vector, VecKind); - void *InsertPos = 0; + void *InsertPos = nullptr; if (VectorType *VTP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos)) return QualType(VTP, 0); @@ -2688,7 +2688,7 @@ QualType ASTContext::getVectorType(QualType vecType, unsigned NumElts, // Get the new insert position for the node we care about. VectorType *NewIP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos); - assert(NewIP == 0 && "Shouldn't be in the map!"); (void)NewIP; + assert(!NewIP && "Shouldn't be in the map!"); (void)NewIP; } VectorType *New = new (*this, TypeAlignment) VectorType(vecType, NumElts, Canonical, VecKind); @@ -2707,7 +2707,7 @@ ASTContext::getExtVectorType(QualType vecType, unsigned NumElts) const { llvm::FoldingSetNodeID ID; VectorType::Profile(ID, vecType, NumElts, Type::ExtVector, VectorType::GenericVector); - void *InsertPos = 0; + void *InsertPos = nullptr; if (VectorType *VTP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos)) return QualType(VTP, 0); @@ -2719,7 +2719,7 @@ ASTContext::getExtVectorType(QualType vecType, unsigned NumElts) const { // Get the new insert position for the node we care about. VectorType *NewIP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos); - assert(NewIP == 0 && "Shouldn't be in the map!"); (void)NewIP; + assert(!NewIP && "Shouldn't be in the map!"); (void)NewIP; } ExtVectorType *New = new (*this, TypeAlignment) ExtVectorType(vecType, NumElts, Canonical); @@ -2736,7 +2736,7 @@ ASTContext::getDependentSizedExtVectorType(QualType vecType, DependentSizedExtVectorType::Profile(ID, *this, getCanonicalType(vecType), SizeExpr); - void *InsertPos = 0; + void *InsertPos = nullptr; DependentSizedExtVectorType *Canon = DependentSizedExtVectorTypes.FindNodeOrInsertPos(ID, InsertPos); DependentSizedExtVectorType *New; @@ -2782,7 +2782,7 @@ ASTContext::getFunctionNoProtoType(QualType ResultTy, llvm::FoldingSetNodeID ID; FunctionNoProtoType::Profile(ID, ResultTy, Info); - void *InsertPos = 0; + void *InsertPos = nullptr; if (FunctionNoProtoType *FT = FunctionNoProtoTypes.FindNodeOrInsertPos(ID, InsertPos)) return QualType(FT, 0); @@ -2794,7 +2794,7 @@ ASTContext::getFunctionNoProtoType(QualType ResultTy, // Get the new insert position for the node we care about. FunctionNoProtoType *NewIP = FunctionNoProtoTypes.FindNodeOrInsertPos(ID, InsertPos); - assert(NewIP == 0 && "Shouldn't be in the map!"); (void)NewIP; + assert(!NewIP && "Shouldn't be in the map!"); (void)NewIP; } FunctionProtoType::ExtInfo newInfo = Info.withCallingConv(CallConv); @@ -2823,7 +2823,7 @@ ASTContext::getFunctionType(QualType ResultTy, ArrayRef ArgArray, FunctionProtoType::Profile(ID, ResultTy, ArgArray.begin(), NumArgs, EPI, *this); - void *InsertPos = 0; + void *InsertPos = nullptr; if (FunctionProtoType *FTP = FunctionProtoTypes.FindNodeOrInsertPos(ID, InsertPos)) return QualType(FTP, 0); @@ -2863,7 +2863,7 @@ ASTContext::getFunctionType(QualType ResultTy, ArrayRef ArgArray, // Get the new insert position for the node we care about. FunctionProtoType *NewIP = FunctionProtoTypes.FindNodeOrInsertPos(ID, InsertPos); - assert(NewIP == 0 && "Shouldn't be in the map!"); (void)NewIP; + assert(!NewIP && "Shouldn't be in the map!"); (void)NewIP; } // FunctionProtoType objects are allocated with extra bytes after @@ -3007,7 +3007,7 @@ QualType ASTContext::getAttributedType(AttributedType::Kind attrKind, llvm::FoldingSetNodeID id; AttributedType::Profile(id, attrKind, modifiedType, equivalentType); - void *insertPos = 0; + void *insertPos = nullptr; AttributedType *type = AttributedTypes.FindNodeOrInsertPos(id, insertPos); if (type) return QualType(type, 0); @@ -3031,7 +3031,7 @@ ASTContext::getSubstTemplateTypeParmType(const TemplateTypeParmType *Parm, llvm::FoldingSetNodeID ID; SubstTemplateTypeParmType::Profile(ID, Parm, Replacement); - void *InsertPos = 0; + void *InsertPos = nullptr; SubstTemplateTypeParmType *SubstParm = SubstTemplateTypeParmTypes.FindNodeOrInsertPos(ID, InsertPos); @@ -3060,7 +3060,7 @@ QualType ASTContext::getSubstTemplateTypeParmPackType( llvm::FoldingSetNodeID ID; SubstTemplateTypeParmPackType::Profile(ID, Parm, ArgPack); - void *InsertPos = 0; + void *InsertPos = nullptr; if (SubstTemplateTypeParmPackType *SubstParm = SubstTemplateTypeParmPackTypes.FindNodeOrInsertPos(ID, InsertPos)) return QualType(SubstParm, 0); @@ -3089,7 +3089,7 @@ QualType ASTContext::getTemplateTypeParmType(unsigned Depth, unsigned Index, TemplateTypeParmDecl *TTPDecl) const { llvm::FoldingSetNodeID ID; TemplateTypeParmType::Profile(ID, Depth, Index, ParameterPack, TTPDecl); - void *InsertPos = 0; + void *InsertPos = nullptr; TemplateTypeParmType *TypeParm = TemplateTypeParmTypes.FindNodeOrInsertPos(ID, InsertPos); @@ -3230,7 +3230,7 @@ ASTContext::getCanonicalTemplateSpecializationType(TemplateName Template, TemplateSpecializationType::Profile(ID, CanonTemplate, CanonArgs.data(), NumArgs, *this); - void *InsertPos = 0; + void *InsertPos = nullptr; TemplateSpecializationType *Spec = TemplateSpecializationTypes.FindNodeOrInsertPos(ID, InsertPos); @@ -3258,7 +3258,7 @@ ASTContext::getElaboratedType(ElaboratedTypeKeyword Keyword, llvm::FoldingSetNodeID ID; ElaboratedType::Profile(ID, Keyword, NNS, NamedType); - void *InsertPos = 0; + void *InsertPos = nullptr; ElaboratedType *T = ElaboratedTypes.FindNodeOrInsertPos(ID, InsertPos); if (T) return QualType(T, 0); @@ -3282,7 +3282,7 @@ ASTContext::getParenType(QualType InnerType) const { llvm::FoldingSetNodeID ID; ParenType::Profile(ID, InnerType); - void *InsertPos = 0; + void *InsertPos = nullptr; ParenType *T = ParenTypes.FindNodeOrInsertPos(ID, InsertPos); if (T) return QualType(T, 0); @@ -3320,7 +3320,7 @@ QualType ASTContext::getDependentNameType(ElaboratedTypeKeyword Keyword, llvm::FoldingSetNodeID ID; DependentNameType::Profile(ID, Keyword, NNS, Name); - void *InsertPos = 0; + void *InsertPos = nullptr; DependentNameType *T = DependentNameTypes.FindNodeOrInsertPos(ID, InsertPos); if (T) @@ -3361,7 +3361,7 @@ ASTContext::getDependentTemplateSpecializationType( DependentTemplateSpecializationType::Profile(ID, *this, Keyword, NNS, Name, NumArgs, Args); - void *InsertPos = 0; + void *InsertPos = nullptr; DependentTemplateSpecializationType *T = DependentTemplateSpecializationTypes.FindNodeOrInsertPos(ID, InsertPos); if (T) @@ -3407,7 +3407,7 @@ QualType ASTContext::getPackExpansionType(QualType Pattern, assert(Pattern->containsUnexpandedParameterPack() && "Pack expansions must expand one or more parameter packs"); - void *InsertPos = 0; + void *InsertPos = nullptr; PackExpansionType *T = PackExpansionTypes.FindNodeOrInsertPos(ID, InsertPos); if (T) @@ -3482,7 +3482,7 @@ QualType ASTContext::getObjCObjectType(QualType BaseType, // Look in the folding set for an existing type. llvm::FoldingSetNodeID ID; ObjCObjectTypeImpl::Profile(ID, BaseType, Protocols, NumProtocols); - void *InsertPos = 0; + void *InsertPos = nullptr; if (ObjCObjectType *QT = ObjCObjectTypes.FindNodeOrInsertPos(ID, InsertPos)) return QualType(QT, 0); @@ -3591,7 +3591,7 @@ QualType ASTContext::getObjCObjectPointerType(QualType ObjectT) const { llvm::FoldingSetNodeID ID; ObjCObjectPointerType::Profile(ID, ObjectT); - void *InsertPos = 0; + void *InsertPos = nullptr; if (ObjCObjectPointerType *QT = ObjCObjectPointerTypes.FindNodeOrInsertPos(ID, InsertPos)) return QualType(QT, 0); @@ -3650,7 +3650,7 @@ QualType ASTContext::getTypeOfExprType(Expr *tofExpr) const { llvm::FoldingSetNodeID ID; DependentTypeOfExprType::Profile(ID, *this, tofExpr); - void *InsertPos = 0; + void *InsertPos = nullptr; DependentTypeOfExprType *Canon = DependentTypeOfExprTypes.FindNodeOrInsertPos(ID, InsertPos); if (Canon) { @@ -3702,7 +3702,7 @@ QualType ASTContext::getDecltypeType(Expr *e, QualType UnderlyingType) const { llvm::FoldingSetNodeID ID; DependentDecltypeType::Profile(ID, *this, e); - void *InsertPos = 0; + void *InsertPos = nullptr; DependentDecltypeType *Canon = DependentDecltypeTypes.FindNodeOrInsertPos(ID, InsertPos); if (Canon) { @@ -3748,7 +3748,7 @@ QualType ASTContext::getAutoType(QualType DeducedType, bool IsDecltypeAuto, return getAutoDeductType(); // Look in the folding set for an existing type. - void *InsertPos = 0; + void *InsertPos = nullptr; llvm::FoldingSetNodeID ID; AutoType::Profile(ID, DeducedType, IsDecltypeAuto, IsDependent); if (AutoType *AT = AutoTypes.FindNodeOrInsertPos(ID, InsertPos)) @@ -3771,7 +3771,7 @@ QualType ASTContext::getAtomicType(QualType T) const { llvm::FoldingSetNodeID ID; AtomicType::Profile(ID, T); - void *InsertPos = 0; + void *InsertPos = nullptr; if (AtomicType *AT = AtomicTypes.FindNodeOrInsertPos(ID, InsertPos)) return QualType(AT, 0); @@ -3783,7 +3783,7 @@ QualType ASTContext::getAtomicType(QualType T) const { // Get the new insert position for the node we care about. AtomicType *NewIP = AtomicTypes.FindNodeOrInsertPos(ID, InsertPos); - assert(NewIP == 0 && "Shouldn't be in the map!"); (void)NewIP; + assert(!NewIP && "Shouldn't be in the map!"); (void)NewIP; } AtomicType *New = new (*this, TypeAlignment) AtomicType(T, Canonical); Types.push_back(New); @@ -4142,7 +4142,7 @@ ASTContext::getCanonicalTemplateArgument(const TemplateArgument &Arg) const { NestedNameSpecifier * ASTContext::getCanonicalNestedNameSpecifier(NestedNameSpecifier *NNS) const { if (!NNS) - return 0; + return nullptr; switch (NNS->getKind()) { case NestedNameSpecifier::Identifier: @@ -4154,13 +4154,13 @@ ASTContext::getCanonicalNestedNameSpecifier(NestedNameSpecifier *NNS) const { case NestedNameSpecifier::Namespace: // A namespace is canonical; build a nested-name-specifier with // this namespace and no prefix. - return NestedNameSpecifier::Create(*this, 0, + return NestedNameSpecifier::Create(*this, nullptr, NNS->getAsNamespace()->getOriginalNamespace()); case NestedNameSpecifier::NamespaceAlias: // A namespace is canonical; build a nested-name-specifier with // this namespace and no prefix. - return NestedNameSpecifier::Create(*this, 0, + return NestedNameSpecifier::Create(*this, nullptr, NNS->getAsNamespaceAlias()->getNamespace() ->getOriginalNamespace()); @@ -4182,8 +4182,8 @@ ASTContext::getCanonicalNestedNameSpecifier(NestedNameSpecifier *NNS) const { // Otherwise, just canonicalize the type, and force it to be a TypeSpec. // FIXME: Why are TypeSpec and TypeSpecWithTemplate distinct in the // first place? - return NestedNameSpecifier::Create(*this, 0, false, - const_cast(T.getTypePtr())); + return NestedNameSpecifier::Create(*this, nullptr, false, + const_cast(T.getTypePtr())); } case NestedNameSpecifier::Global: @@ -4205,7 +4205,7 @@ const ArrayType *ASTContext::getAsArrayType(QualType T) const { // Handle the common negative case fast. if (!isa(T.getCanonicalType())) - return 0; + return nullptr; // Apply any qualifiers from the array type to the element type. This // implements C99 6.7.3p8: "If the specification of an array type includes @@ -4220,7 +4220,7 @@ const ArrayType *ASTContext::getAsArrayType(QualType T) const { // If we have a simple case, just return now. const ArrayType *ATy = dyn_cast(split.Ty); - if (ATy == 0 || qs.empty()) + if (!ATy || qs.empty()) return ATy; // Otherwise, we have an array and we have qualifiers on it. Push the @@ -4506,7 +4506,7 @@ static const Type *getIntegerTypeForEnum(const EnumType *ET) { // FIXME: In C++, enum types are never integer types. if (ET->getDecl()->isComplete() && !ET->getDecl()->isScoped()) return ET->getDecl()->getIntegerType().getTypePtr(); - return NULL; + return nullptr; } /// getIntegerTypeOrder - Returns the highest ranked integer type: @@ -4578,9 +4578,9 @@ QualType ASTContext::getCFConstantStringType() const { for (unsigned i = 0; i < 4; ++i) { FieldDecl *Field = FieldDecl::Create(*this, CFConstantStringTypeDecl, SourceLocation(), - SourceLocation(), 0, - FieldTypes[i], /*TInfo=*/0, - /*BitWidth=*/0, + SourceLocation(), nullptr, + FieldTypes[i], /*TInfo=*/nullptr, + /*BitWidth=*/nullptr, /*Mutable=*/false, ICIS_NoInit); Field->setAccess(AS_public); @@ -4630,8 +4630,8 @@ QualType ASTContext::getBlockDescriptorType() const { for (size_t i = 0; i < 2; ++i) { FieldDecl *Field = FieldDecl::Create( *this, RD, SourceLocation(), SourceLocation(), - &Idents.get(FieldNames[i]), FieldTypes[i], /*TInfo=*/0, - /*BitWidth=*/0, /*Mutable=*/false, ICIS_NoInit); + &Idents.get(FieldNames[i]), FieldTypes[i], /*TInfo=*/nullptr, + /*BitWidth=*/nullptr, /*Mutable=*/false, ICIS_NoInit); Field->setAccess(AS_public); RD->addDecl(Field); } @@ -4669,8 +4669,8 @@ QualType ASTContext::getBlockDescriptorExtendedType() const { for (size_t i = 0; i < 4; ++i) { FieldDecl *Field = FieldDecl::Create( *this, RD, SourceLocation(), SourceLocation(), - &Idents.get(FieldNames[i]), FieldTypes[i], /*TInfo=*/0, - /*BitWidth=*/0, + &Idents.get(FieldNames[i]), FieldTypes[i], /*TInfo=*/nullptr, + /*BitWidth=*/nullptr, /*Mutable=*/false, ICIS_NoInit); Field->setAccess(AS_public); RD->addDecl(Field); @@ -4890,7 +4890,7 @@ void ASTContext::getObjCEncodingForMethodParameter(Decl::ObjCDeclQualifier QT, // Encode type qualifer, 'in', 'inout', etc. for the parameter. getObjCEncodingForTypeQualifier(QT, S); // Encode parameter type. - getObjCEncodingForTypeImpl(T, S, true, true, 0, + getObjCEncodingForTypeImpl(T, S, true, true, nullptr, true /*OutermostType*/, false /*EncodingProperty*/, false /*StructField*/, @@ -4958,19 +4958,19 @@ ASTContext::getObjCPropertyImplDeclForPropertyDecl( const ObjCPropertyDecl *PD, const Decl *Container) const { if (!Container) - return 0; + return nullptr; if (const ObjCCategoryImplDecl *CID = dyn_cast(Container)) { for (auto *PID : CID->property_impls()) if (PID->getPropertyDecl() == PD) return PID; - } else { - const ObjCImplementationDecl *OID=cast(Container); - for (auto *PID : OID->property_impls()) - if (PID->getPropertyDecl() == PD) - return PID; - } - return 0; + } else { + const ObjCImplementationDecl *OID=cast(Container); + for (auto *PID : OID->property_impls()) + if (PID->getPropertyDecl() == PD) + return PID; + } + return nullptr; } /// getObjCEncodingForPropertyDecl - Return the encoded type for this @@ -5003,7 +5003,7 @@ void ASTContext::getObjCEncodingForPropertyDecl(const ObjCPropertyDecl *PD, std::string& S) const { // Collect information from the property implementation decl(s). bool Dynamic = false; - ObjCPropertyImplDecl *SynthesizePID = 0; + ObjCPropertyImplDecl *SynthesizePID = nullptr; if (ObjCPropertyImplDecl *PropertyImpDecl = getObjCPropertyImplDeclForPropertyDecl(PD, Container)) { @@ -5019,7 +5019,7 @@ void ASTContext::getObjCEncodingForPropertyDecl(const ObjCPropertyDecl *PD, // Encode result type. // GCC has some special rules regarding encoding of properties which // closely resembles encoding of ivars. - getObjCEncodingForTypeImpl(PD->getType(), S, true, true, 0, + getObjCEncodingForTypeImpl(PD->getType(), S, true, true, nullptr, true /* outermost type */, true /* encoding for property */); @@ -5223,15 +5223,15 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S, case Type::Complex: { const ComplexType *CT = T->castAs(); S += 'j'; - getObjCEncodingForTypeImpl(CT->getElementType(), S, false, false, 0, false, - false); + getObjCEncodingForTypeImpl(CT->getElementType(), S, false, false, nullptr, + false, false); return; } case Type::Atomic: { const AtomicType *AT = T->castAs(); S += 'A'; - getObjCEncodingForTypeImpl(AT->getValueType(), S, false, false, 0, + getObjCEncodingForTypeImpl(AT->getValueType(), S, false, false, nullptr, false, false); return; } @@ -5303,7 +5303,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S, getLegacyIntegralTypeEncoding(PointeeTy); getObjCEncodingForTypeImpl(PointeeTy, S, false, ExpandPointedToStructures, - NULL); + nullptr); return; } @@ -5516,7 +5516,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S, } getObjCEncodingForTypeImpl(PointeeTy, S, false, ExpandPointedToStructures, - NULL, + nullptr, false, false, false, false, false, /*EncodePointerToObjCTypedef*/true); return; @@ -5648,7 +5648,7 @@ void ASTContext::getObjCEncodingForStructureImpl(RecordDecl *RDecl, // Mark the end of the structure. uint64_t offs = toBits(size); FieldOrBaseOffsets.insert(FieldOrBaseOffsets.upper_bound(offs), - std::make_pair(offs, (NamedDecl*)0)); + std::make_pair(offs, nullptr)); } for (; CurLayObj != FieldOrBaseOffsets.end(); ++CurLayObj) { @@ -5668,7 +5668,7 @@ void ASTContext::getObjCEncodingForStructureImpl(RecordDecl *RDecl, #endif NamedDecl *dcl = CurLayObj->second; - if (dcl == 0) + if (!dcl) break; // reached end of structure. if (CXXRecordDecl *base = dyn_cast(dcl)) { @@ -5727,7 +5727,7 @@ void ASTContext::getObjCEncodingForTypeQualifier(Decl::ObjCDeclQualifier QT, TypedefDecl *ASTContext::getObjCIdDecl() const { if (!ObjCIdDecl) { - QualType T = getObjCObjectType(ObjCBuiltinIdTy, 0, 0); + QualType T = getObjCObjectType(ObjCBuiltinIdTy, nullptr, 0); T = getObjCObjectPointerType(T); ObjCIdDecl = buildImplicitTypedef(T, "id"); } @@ -5744,7 +5744,7 @@ TypedefDecl *ASTContext::getObjCSelDecl() const { TypedefDecl *ASTContext::getObjCClassDecl() const { if (!ObjCClassDecl) { - QualType T = getObjCObjectType(ObjCBuiltinClassTy, 0, 0); + QualType T = getObjCObjectType(ObjCBuiltinClassTy, nullptr, 0); T = getObjCObjectPointerType(T); ObjCClassDecl = buildImplicitTypedef(T, "Class"); } @@ -5757,7 +5757,7 @@ ObjCInterfaceDecl *ASTContext::getObjCProtocolDecl() const { = ObjCInterfaceDecl::Create(*this, getTranslationUnitDecl(), SourceLocation(), &Idents.get("Protocol"), - /*PrevDecl=*/0, + /*PrevDecl=*/nullptr, SourceLocation(), true); } @@ -5789,9 +5789,9 @@ CreateAArch64ABIBuiltinVaListDecl(const ASTContext *Context) { NamespaceDecl *NS; NS = NamespaceDecl::Create(const_cast(*Context), Context->getTranslationUnitDecl(), - /*Inline*/false, SourceLocation(), + /*Inline*/ false, SourceLocation(), SourceLocation(), &Context->Idents.get("std"), - /*PrevDecl*/0); + /*PrevDecl*/ nullptr); NS->setImplicit(); VaListTagDecl->setDeclContext(NS); } @@ -5829,8 +5829,8 @@ CreateAArch64ABIBuiltinVaListDecl(const ASTContext *Context) { SourceLocation(), SourceLocation(), &Context->Idents.get(FieldNames[i]), - FieldTypes[i], /*TInfo=*/0, - /*BitWidth=*/0, + FieldTypes[i], /*TInfo=*/nullptr, + /*BitWidth=*/nullptr, /*Mutable=*/false, ICIS_NoInit); Field->setAccess(AS_public); @@ -5881,8 +5881,8 @@ static TypedefDecl *CreatePowerABIBuiltinVaListDecl(const ASTContext *Context) { SourceLocation(), SourceLocation(), &Context->Idents.get(FieldNames[i]), - FieldTypes[i], /*TInfo=*/0, - /*BitWidth=*/0, + FieldTypes[i], /*TInfo=*/nullptr, + /*BitWidth=*/nullptr, /*Mutable=*/false, ICIS_NoInit); Field->setAccess(AS_public); @@ -5941,8 +5941,8 @@ CreateX86_64ABIBuiltinVaListDecl(const ASTContext *Context) { SourceLocation(), SourceLocation(), &Context->Idents.get(FieldNames[i]), - FieldTypes[i], /*TInfo=*/0, - /*BitWidth=*/0, + FieldTypes[i], /*TInfo=*/nullptr, + /*BitWidth=*/nullptr, /*Mutable=*/false, ICIS_NoInit); Field->setAccess(AS_public); @@ -5987,7 +5987,7 @@ CreateAAPCSABIBuiltinVaListDecl(const ASTContext *Context) { Context->getTranslationUnitDecl(), /*Inline*/false, SourceLocation(), SourceLocation(), &Context->Idents.get("std"), - /*PrevDecl*/0); + /*PrevDecl*/ nullptr); NS->setImplicit(); VaListDecl->setDeclContext(NS); } @@ -6001,8 +6001,8 @@ CreateAAPCSABIBuiltinVaListDecl(const ASTContext *Context) { SourceLocation(), &Context->Idents.get("__ap"), Context->getPointerType(Context->VoidTy), - /*TInfo=*/0, - /*BitWidth=*/0, + /*TInfo=*/nullptr, + /*BitWidth=*/nullptr, /*Mutable=*/false, ICIS_NoInit); Field->setAccess(AS_public); @@ -6050,8 +6050,8 @@ CreateSystemZBuiltinVaListDecl(const ASTContext *Context) { SourceLocation(), SourceLocation(), &Context->Idents.get(FieldNames[i]), - FieldTypes[i], /*TInfo=*/0, - /*BitWidth=*/0, + FieldTypes[i], /*TInfo=*/nullptr, + /*BitWidth=*/nullptr, /*Mutable=*/false, ICIS_NoInit); Field->setAccess(AS_public); @@ -6161,7 +6161,7 @@ ASTContext::getQualifiedTemplateName(NestedNameSpecifier *NNS, llvm::FoldingSetNodeID ID; QualifiedTemplateName::Profile(ID, NNS, TemplateKeyword, Template); - void *InsertPos = 0; + void *InsertPos = nullptr; QualifiedTemplateName *QTN = QualifiedTemplateNames.FindNodeOrInsertPos(ID, InsertPos); if (!QTN) { @@ -6184,7 +6184,7 @@ ASTContext::getDependentTemplateName(NestedNameSpecifier *NNS, llvm::FoldingSetNodeID ID; DependentTemplateName::Profile(ID, NNS, Name); - void *InsertPos = 0; + void *InsertPos = nullptr; DependentTemplateName *QTN = DependentTemplateNames.FindNodeOrInsertPos(ID, InsertPos); @@ -6219,8 +6219,8 @@ ASTContext::getDependentTemplateName(NestedNameSpecifier *NNS, llvm::FoldingSetNodeID ID; DependentTemplateName::Profile(ID, NNS, Operator); - - void *InsertPos = 0; + + void *InsertPos = nullptr; DependentTemplateName *QTN = DependentTemplateNames.FindNodeOrInsertPos(ID, InsertPos); @@ -6251,8 +6251,8 @@ ASTContext::getSubstTemplateTemplateParm(TemplateTemplateParmDecl *param, TemplateName replacement) const { llvm::FoldingSetNodeID ID; SubstTemplateTemplateParmStorage::Profile(ID, param, replacement); - - void *insertPos = 0; + + void *insertPos = nullptr; SubstTemplateTemplateParmStorage *subst = SubstTemplateTemplateParms.FindNodeOrInsertPos(ID, insertPos); @@ -6270,8 +6270,8 @@ ASTContext::getSubstTemplateTemplateParmPack(TemplateTemplateParmDecl *Param, ASTContext &Self = const_cast(*this); llvm::FoldingSetNodeID ID; SubstTemplateTemplateParmPackStorage::Profile(ID, Self, Param, ArgPack); - - void *InsertPos = 0; + + void *InsertPos = nullptr; SubstTemplateTemplateParmPackStorage *Subst = SubstTemplateTemplateParmPacks.FindNodeOrInsertPos(ID, InsertPos); @@ -8070,7 +8070,7 @@ ASTContext::getMaterializedTemporaryValue(const MaterializeTemporaryExpr *E, llvm::DenseMap::iterator I = MaterializedTemporaryValues.find(E); - return I == MaterializedTemporaryValues.end() ? 0 : &I->second; + return I == MaterializedTemporaryValues.end() ? nullptr : &I->second; } bool ASTContext::AtomicUsesUnsupportedLibcall(const AtomicExpr *E) const { @@ -8133,7 +8133,7 @@ namespace { template bool TraverseNode(T *Node, bool(VisitorBase:: *traverse) (T *)) { - if (Node == NULL) + if (!Node) return true; if (ParentStack.size() > 0) // FIXME: Currently we add the same parent multiple times, for example diff --git a/lib/AST/ASTDiagnostic.cpp b/lib/AST/ASTDiagnostic.cpp index 539e666a48..bd5c209a9a 100644 --- a/lib/AST/ASTDiagnostic.cpp +++ b/lib/AST/ASTDiagnostic.cpp @@ -498,10 +498,11 @@ class TemplateDiff { DiffNode(unsigned ParentNode = 0) : Kind(Invalid), NextNode(0), ChildNode(0), ParentNode(ParentNode), - FromType(), ToType(), FromExpr(0), ToExpr(0), FromTD(0), ToTD(0), - IsValidFromInt(false), IsValidToInt(false), FromValueDecl(0), - ToValueDecl(0), FromAddressOf(false), ToAddressOf(false), - FromDefault(false), ToDefault(false), Same(false) { } + FromType(), ToType(), FromExpr(nullptr), ToExpr(nullptr), + FromTD(nullptr), ToTD(nullptr), IsValidFromInt(false), + IsValidToInt(false), FromValueDecl(nullptr), ToValueDecl(nullptr), + FromAddressOf(false), ToAddressOf(false), FromDefault(false), + ToDefault(false), Same(false) {} }; /// FlatTree - A flattened tree used to store the DiffNodes. @@ -746,7 +747,7 @@ class TemplateDiff { TSTiterator(ASTContext &Context, const TemplateSpecializationType *TST) : TST(TST), DesugarTST(GetTemplateSpecializationType(Context, TST->desugar())), - Index(0), CurrentTA(0), EndTA(0) { + Index(0), CurrentTA(nullptr), EndTA(nullptr) { if (isEnd()) return; // Set to first template argument. If not a parameter pack, done. @@ -837,13 +838,13 @@ class TemplateDiff { const RecordType *RT = Ty->getAs(); if (!RT) - return 0; + return nullptr; const ClassTemplateSpecializationDecl *CTSD = dyn_cast(RT->getDecl()); if (!CTSD) - return 0; + return nullptr; Ty = Context.getTemplateSpecializationType( TemplateName(CTSD->getSpecializedTemplate()), @@ -915,9 +916,9 @@ class TemplateDiff { // Handle Expressions if (NonTypeTemplateParmDecl *DefaultNTTPD = dyn_cast(ParamND)) { - Expr *FromExpr = 0, *ToExpr = 0; + Expr *FromExpr = nullptr, *ToExpr = nullptr; llvm::APSInt FromInt, ToInt; - ValueDecl *FromValueDecl = 0, *ToValueDecl = 0; + ValueDecl *FromValueDecl = nullptr, *ToValueDecl = nullptr; unsigned ParamWidth = 128; // Safe default if (DefaultNTTPD->getType()->isIntegralOrEnumerationType()) ParamWidth = Context.getIntWidth(DefaultNTTPD->getType()); @@ -1100,7 +1101,7 @@ class TemplateDiff { /// GetExpr - Retrieves the template expression argument, including default /// arguments. Expr *GetExpr(const TSTiterator &Iter, NonTypeTemplateParmDecl *DefaultNTTPD) { - Expr *ArgExpr = 0; + Expr *ArgExpr = nullptr; bool isVariadic = DefaultNTTPD->isParameterPack(); if (!Iter.isEnd()) @@ -1164,7 +1165,7 @@ class TemplateDiff { bool isVariadic = DefaultTTPD->isParameterPack(); TemplateArgument TA = DefaultTTPD->getDefaultArgument().getArgument(); - TemplateDecl *DefaultTD = 0; + TemplateDecl *DefaultTD = nullptr; if (TA.getKind() != TemplateArgument::Null) DefaultTD = TA.getAsTemplate().getAsTemplateDecl(); @@ -1173,7 +1174,7 @@ class TemplateDiff { if (!isVariadic) return DefaultTD; - return 0; + return nullptr; } /// IsSameConvertedInt - Returns true if both integers are equal when @@ -1444,7 +1445,7 @@ class TemplateDiff { if (!E) OS << "(no argument)"; else - E->printPretty(OS, 0, Policy); return; + E->printPretty(OS, nullptr, Policy); } /// PrintTemplateTemplate - Handles printing of template template arguments, diff --git a/lib/AST/ASTDumper.cpp b/lib/AST/ASTDumper.cpp index 76699bd568..e4ddba33cc 100644 --- a/lib/AST/ASTDumper.cpp +++ b/lib/AST/ASTDumper.cpp @@ -155,11 +155,11 @@ namespace { const Decl *Prev; bool PrevRef; public: - ChildDumper(ASTDumper &Dumper) : Dumper(Dumper), Prev(0) {} + ChildDumper(ASTDumper &Dumper) : Dumper(Dumper), Prev(nullptr) {} ~ChildDumper() { if (Prev) { Dumper.lastChild(); - dump(0); + dump(nullptr); } } @@ -178,14 +178,14 @@ namespace { // Give up ownership of the children of the node. By calling this, // the caller takes back responsibility for calling lastChild(). - void release() { dump(0); } + void release() { dump(nullptr); } }; public: ASTDumper(raw_ostream &OS, const CommandTraits *Traits, const SourceManager *SM) : OS(OS), Traits(Traits), SM(SM), IsFirstLine(true), MoreChildren(false), - LastLocFilename(""), LastLocLine(~0U), FC(0), + LastLocFilename(""), LastLocLine(~0U), FC(nullptr), ShowColors(SM && SM->getDiagnostics().getShowColors()) { } ASTDumper(raw_ostream &OS, const CommandTraits *Traits, @@ -216,7 +216,7 @@ namespace { void dumpBareType(QualType T); void dumpType(QualType T); void dumpBareDeclRef(const Decl *Node); - void dumpDeclRef(const Decl *Node, const char *Label = 0); + void dumpDeclRef(const Decl *Node, const char *Label = nullptr); void dumpName(const NamedDecl *D); bool hasNodes(const DeclContext *DC); void dumpDeclContext(const DeclContext *DC); @@ -1991,7 +1991,7 @@ void ASTDumper::dumpFullComment(const FullComment *C) { FC = C; dumpComment(C); - FC = 0; + FC = nullptr; } void ASTDumper::dumpComment(const Comment *C) { @@ -2158,17 +2158,17 @@ LLVM_DUMP_METHOD void Stmt::dump(SourceManager &SM) const { } LLVM_DUMP_METHOD void Stmt::dump(raw_ostream &OS, SourceManager &SM) const { - ASTDumper P(OS, 0, &SM); + ASTDumper P(OS, nullptr, &SM); P.dumpStmt(this); } LLVM_DUMP_METHOD void Stmt::dump() const { - ASTDumper P(llvm::errs(), 0, 0); + ASTDumper P(llvm::errs(), nullptr, nullptr); P.dumpStmt(this); } LLVM_DUMP_METHOD void Stmt::dumpColor() const { - ASTDumper P(llvm::errs(), 0, 0, /*ShowColors*/true); + ASTDumper P(llvm::errs(), nullptr, nullptr, /*ShowColors*/true); P.dumpStmt(this); } @@ -2176,7 +2176,9 @@ LLVM_DUMP_METHOD void Stmt::dumpColor() const { // Comment method implementations //===----------------------------------------------------------------------===// -LLVM_DUMP_METHOD void Comment::dump() const { dump(llvm::errs(), 0, 0); } +LLVM_DUMP_METHOD void Comment::dump() const { + dump(llvm::errs(), nullptr, nullptr); +} LLVM_DUMP_METHOD void Comment::dump(const ASTContext &Context) const { dump(llvm::errs(), &Context.getCommentCommandTraits(), @@ -2192,6 +2194,6 @@ void Comment::dump(raw_ostream &OS, const CommandTraits *Traits, LLVM_DUMP_METHOD void Comment::dumpColor() const { const FullComment *FC = dyn_cast(this); - ASTDumper D(llvm::errs(), 0, 0, /*ShowColors*/true); + ASTDumper D(llvm::errs(), nullptr, nullptr, /*ShowColors*/true); D.dumpFullComment(FC); } diff --git a/lib/AST/ASTImporter.cpp b/lib/AST/ASTImporter.cpp index 17ccb7fc4d..e996c7eff2 100644 --- a/lib/AST/ASTImporter.cpp +++ b/lib/AST/ASTImporter.cpp @@ -81,7 +81,7 @@ namespace clang { bool ImportDeclParts(NamedDecl *D, DeclContext *&DC, DeclContext *&LexicalDC, DeclarationName &Name, SourceLocation &Loc); - void ImportDefinitionIfNeeded(Decl *FromD, Decl *ToD = 0); + void ImportDefinitionIfNeeded(Decl *FromD, Decl *ToD = nullptr); void ImportDeclarationNameLoc(const DeclarationNameInfo &From, DeclarationNameInfo& To); void ImportDeclContext(DeclContext *FromDC, bool ForceImport = false); @@ -1749,7 +1749,7 @@ QualType ASTNodeImporter::VisitTemplateSpecializationType( } QualType ASTNodeImporter::VisitElaboratedType(const ElaboratedType *T) { - NestedNameSpecifier *ToQualifier = 0; + NestedNameSpecifier *ToQualifier = nullptr; // Note: the qualifier in an ElaboratedType is optional. if (T->getQualifier()) { ToQualifier = Importer.Import(T->getQualifier()); @@ -2060,8 +2060,8 @@ TemplateParameterList *ASTNodeImporter::ImportTemplateParameterList( P != PEnd; ++P) { Decl *To = Importer.Import(*P); if (!To) - return 0; - + return nullptr; + ToParams.push_back(cast(To)); } @@ -2221,7 +2221,7 @@ bool ASTNodeImporter::IsStructuralMatch(VarTemplateDecl *From, Decl *ASTNodeImporter::VisitDecl(Decl *D) { Importer.FromDiag(D->getLocation(), diag::err_unsupported_ast_node) << D->getDeclKindName(); - return 0; + return nullptr; } Decl *ASTNodeImporter::VisitTranslationUnitDecl(TranslationUnitDecl *D) { @@ -2239,9 +2239,9 @@ Decl *ASTNodeImporter::VisitNamespaceDecl(NamespaceDecl *D) { DeclarationName Name; SourceLocation Loc; if (ImportDeclParts(D, DC, LexicalDC, Name, Loc)) - return 0; - - NamespaceDecl *MergeWithNamespace = 0; + return nullptr; + + NamespaceDecl *MergeWithNamespace = nullptr; if (!Name) { // This is an anonymous namespace. Adopt an existing anonymous // namespace if we can. @@ -2281,7 +2281,7 @@ Decl *ASTNodeImporter::VisitNamespaceDecl(NamespaceDecl *D) { D->isInline(), Importer.Import(D->getLocStart()), Loc, Name.getAsIdentifierInfo(), - /*PrevDecl=*/0); + /*PrevDecl=*/nullptr); ToNamespace->setLexicalDeclContext(LexicalDC); LexicalDC->addDeclInternal(ToNamespace); @@ -2307,8 +2307,8 @@ Decl *ASTNodeImporter::VisitTypedefNameDecl(TypedefNameDecl *D, bool IsAlias) { DeclarationName Name; SourceLocation Loc; if (ImportDeclParts(D, DC, LexicalDC, Name, Loc)) - return 0; - + return nullptr; + // If this typedef is not in block scope, determine whether we've // seen a typedef with the same name (that we can merge with) or any // other entity by that name (which name lookup could conflict with). @@ -2335,15 +2335,15 @@ Decl *ASTNodeImporter::VisitTypedefNameDecl(TypedefNameDecl *D, bool IsAlias) { ConflictingDecls.data(), ConflictingDecls.size()); if (!Name) - return 0; + return nullptr; } } // Import the underlying type of this typedef; QualType T = Importer.Import(D->getUnderlyingType()); if (T.isNull()) - return 0; - + return nullptr; + // Create the new typedef node. TypeSourceInfo *TInfo = Importer.Import(D->getTypeSourceInfo()); SourceLocation StartL = Importer.Import(D->getLocStart()); @@ -2381,8 +2381,8 @@ Decl *ASTNodeImporter::VisitEnumDecl(EnumDecl *D) { DeclarationName Name; SourceLocation Loc; if (ImportDeclParts(D, DC, LexicalDC, Name, Loc)) - return 0; - + return nullptr; + // Figure out what enum name we're looking for. unsigned IDNS = Decl::IDNS_Tag; DeclarationName SearchName = Name; @@ -2425,7 +2425,7 @@ Decl *ASTNodeImporter::VisitEnumDecl(EnumDecl *D) { // Create the enum declaration. EnumDecl *D2 = EnumDecl::Create(Importer.getToContext(), DC, Importer.Import(D->getLocStart()), - Loc, Name.getAsIdentifierInfo(), 0, + Loc, Name.getAsIdentifierInfo(), nullptr, D->isScoped(), D->isScopedUsingClassTag(), D->isFixed()); // Import the qualifier, if any. @@ -2438,12 +2438,12 @@ Decl *ASTNodeImporter::VisitEnumDecl(EnumDecl *D) { // Import the integer type. QualType ToIntegerType = Importer.Import(D->getIntegerType()); if (ToIntegerType.isNull()) - return 0; + return nullptr; D2->setIntegerType(ToIntegerType); // Import the definition if (D->isCompleteDefinition() && ImportDefinition(D, D2)) - return 0; + return nullptr; return D2; } @@ -2456,8 +2456,8 @@ Decl *ASTNodeImporter::VisitRecordDecl(RecordDecl *D) { if (Definition && Definition != D) { Decl *ImportedDef = Importer.Import(Definition); if (!ImportedDef) - return 0; - + return nullptr; + return Importer.Imported(D, ImportedDef); } @@ -2466,8 +2466,8 @@ Decl *ASTNodeImporter::VisitRecordDecl(RecordDecl *D) { DeclarationName Name; SourceLocation Loc; if (ImportDeclParts(D, DC, LexicalDC, Name, Loc)) - return 0; - + return nullptr; + // Figure out what structure name we're looking for. unsigned IDNS = Decl::IDNS_Tag; DeclarationName SearchName = Name; @@ -2478,7 +2478,7 @@ Decl *ASTNodeImporter::VisitRecordDecl(RecordDecl *D) { IDNS |= Decl::IDNS_Ordinary; // We may already have a record of the same name; try to find and match it. - RecordDecl *AdoptDecl = 0; + RecordDecl *AdoptDecl = nullptr; if (!DC->isFunctionOrMethod()) { SmallVector ConflictingDecls; SmallVector FoundDecls; @@ -2581,8 +2581,8 @@ Decl *ASTNodeImporter::VisitRecordDecl(RecordDecl *D) { Importer.Imported(D, D2); if (D->isCompleteDefinition() && ImportDefinition(D, D2, IDK_Default)) - return 0; - + return nullptr; + return D2; } @@ -2592,11 +2592,11 @@ Decl *ASTNodeImporter::VisitEnumConstantDecl(EnumConstantDecl *D) { DeclarationName Name; SourceLocation Loc; if (ImportDeclParts(D, DC, LexicalDC, Name, Loc)) - return 0; + return nullptr; QualType T = Importer.Import(D->getType()); if (T.isNull()) - return 0; + return nullptr; // Determine whether there are any other declarations with the same name and // in the same context. @@ -2623,14 +2623,14 @@ Decl *ASTNodeImporter::VisitEnumConstantDecl(EnumConstantDecl *D) { ConflictingDecls.data(), ConflictingDecls.size()); if (!Name) - return 0; + return nullptr; } } Expr *Init = Importer.Import(D->getInitExpr()); if (D->getInitExpr() && !Init) - return 0; - + return nullptr; + EnumConstantDecl *ToEnumerator = EnumConstantDecl::Create(Importer.getToContext(), cast(DC), Loc, Name.getAsIdentifierInfo(), T, @@ -2648,7 +2648,7 @@ Decl *ASTNodeImporter::VisitFunctionDecl(FunctionDecl *D) { DeclarationName Name; SourceLocation Loc; if (ImportDeclParts(D, DC, LexicalDC, Name, Loc)) - return 0; + return nullptr; // Try to find a function in our own ("to") context with the same name, same // type, and in the same context as the function we're importing. @@ -2694,7 +2694,7 @@ Decl *ASTNodeImporter::VisitFunctionDecl(FunctionDecl *D) { ConflictingDecls.data(), ConflictingDecls.size()); if (!Name) - return 0; + return nullptr; } } @@ -2724,21 +2724,21 @@ Decl *ASTNodeImporter::VisitFunctionDecl(FunctionDecl *D) { // Import the type. QualType T = Importer.Import(FromTy); if (T.isNull()) - return 0; - + return nullptr; + // Import the function parameters. SmallVector Parameters; for (auto P : D->params()) { ParmVarDecl *ToP = cast_or_null(Importer.Import(P)); if (!ToP) - return 0; - + return nullptr; + Parameters.push_back(ToP); } // Create the imported function. TypeSourceInfo *TInfo = Importer.Import(D->getTypeSourceInfo()); - FunctionDecl *ToFunction = 0; + FunctionDecl *ToFunction = nullptr; if (CXXConstructorDecl *FromConstructor = dyn_cast(D)) { ToFunction = CXXConstructorDecl::Create(Importer.getToContext(), cast(DC), @@ -2803,7 +2803,7 @@ Decl *ASTNodeImporter::VisitFunctionDecl(FunctionDecl *D) { // Update FunctionProtoType::ExtProtoInfo. QualType T = Importer.Import(D->getType()); if (T.isNull()) - return 0; + return nullptr; ToFunction->setType(T); } @@ -2854,8 +2854,8 @@ Decl *ASTNodeImporter::VisitFieldDecl(FieldDecl *D) { DeclarationName Name; SourceLocation Loc; if (ImportDeclParts(D, DC, LexicalDC, Name, Loc)) - return 0; - + return nullptr; + // Determine whether we've already imported this field. SmallVector FoundDecls; DC->localUncachedLookup(Name, FoundDecls); @@ -2875,20 +2875,20 @@ Decl *ASTNodeImporter::VisitFieldDecl(FieldDecl *D) { << Name << D->getType() << FoundField->getType(); Importer.ToDiag(FoundField->getLocation(), diag::note_odr_value_here) << FoundField->getType(); - return 0; + return nullptr; } } // Import the type. QualType T = Importer.Import(D->getType()); if (T.isNull()) - return 0; - + return nullptr; + TypeSourceInfo *TInfo = Importer.Import(D->getTypeSourceInfo()); Expr *BitWidth = Importer.Import(D->getBitWidth()); if (!BitWidth && D->getBitWidth()) - return 0; - + return nullptr; + FieldDecl *ToField = FieldDecl::Create(Importer.getToContext(), DC, Importer.Import(D->getInnerLocStart()), Loc, Name.getAsIdentifierInfo(), @@ -2910,7 +2910,7 @@ Decl *ASTNodeImporter::VisitIndirectFieldDecl(IndirectFieldDecl *D) { DeclarationName Name; SourceLocation Loc; if (ImportDeclParts(D, DC, LexicalDC, Name, Loc)) - return 0; + return nullptr; // Determine whether we've already imported this field. SmallVector FoundDecls; @@ -2937,14 +2937,14 @@ Decl *ASTNodeImporter::VisitIndirectFieldDecl(IndirectFieldDecl *D) { << Name << D->getType() << FoundField->getType(); Importer.ToDiag(FoundField->getLocation(), diag::note_odr_value_here) << FoundField->getType(); - return 0; + return nullptr; } } // Import the type. QualType T = Importer.Import(D->getType()); if (T.isNull()) - return 0; + return nullptr; NamedDecl **NamedChain = new (Importer.getToContext())NamedDecl*[D->getChainingSize()]; @@ -2953,7 +2953,7 @@ Decl *ASTNodeImporter::VisitIndirectFieldDecl(IndirectFieldDecl *D) { for (auto *PI : D->chain()) { Decl *D = Importer.Import(PI); if (!D) - return 0; + return nullptr; NamedChain[i++] = cast(D); } @@ -2974,8 +2974,8 @@ Decl *ASTNodeImporter::VisitObjCIvarDecl(ObjCIvarDecl *D) { DeclarationName Name; SourceLocation Loc; if (ImportDeclParts(D, DC, LexicalDC, Name, Loc)) - return 0; - + return nullptr; + // Determine whether we've already imported this ivar SmallVector FoundDecls; DC->localUncachedLookup(Name, FoundDecls); @@ -2991,20 +2991,20 @@ Decl *ASTNodeImporter::VisitObjCIvarDecl(ObjCIvarDecl *D) { << Name << D->getType() << FoundIvar->getType(); Importer.ToDiag(FoundIvar->getLocation(), diag::note_odr_value_here) << FoundIvar->getType(); - return 0; + return nullptr; } } // Import the type. QualType T = Importer.Import(D->getType()); if (T.isNull()) - return 0; - + return nullptr; + TypeSourceInfo *TInfo = Importer.Import(D->getTypeSourceInfo()); Expr *BitWidth = Importer.Import(D->getBitWidth()); if (!BitWidth && D->getBitWidth()) - return 0; - + return nullptr; + ObjCIvarDecl *ToIvar = ObjCIvarDecl::Create(Importer.getToContext(), cast(DC), Importer.Import(D->getInnerLocStart()), @@ -3024,12 +3024,12 @@ Decl *ASTNodeImporter::VisitVarDecl(VarDecl *D) { DeclarationName Name; SourceLocation Loc; if (ImportDeclParts(D, DC, LexicalDC, Name, Loc)) - return 0; - + return nullptr; + // Try to find a variable in our own ("to") context with the same name and // in the same context as the variable we're importing. if (D->isFileVarDecl()) { - VarDecl *MergeWithVar = 0; + VarDecl *MergeWithVar = nullptr; SmallVector ConflictingDecls; unsigned IDNS = Decl::IDNS_Ordinary; SmallVector FoundDecls; @@ -3058,8 +3058,8 @@ Decl *ASTNodeImporter::VisitVarDecl(VarDecl *D) { // Import the type. QualType T = Importer.Import(D->getType()); if (T.isNull()) - return 0; - + return nullptr; + FoundVar->setType(T); MergeWithVar = FoundVar; break; @@ -3110,15 +3110,15 @@ Decl *ASTNodeImporter::VisitVarDecl(VarDecl *D) { ConflictingDecls.data(), ConflictingDecls.size()); if (!Name) - return 0; + return nullptr; } } // Import the type. QualType T = Importer.Import(D->getType()); if (T.isNull()) - return 0; - + return nullptr; + // Create the imported variable. TypeSourceInfo *TInfo = Importer.Import(D->getTypeSourceInfo()); VarDecl *ToVar = VarDecl::Create(Importer.getToContext(), DC, @@ -3134,7 +3134,7 @@ Decl *ASTNodeImporter::VisitVarDecl(VarDecl *D) { // Merge the initializer. if (ImportDefinition(D, ToVar)) - return 0; + return nullptr; return ToVar; } @@ -3147,16 +3147,16 @@ Decl *ASTNodeImporter::VisitImplicitParamDecl(ImplicitParamDecl *D) { // Import the name of this declaration. DeclarationName Name = Importer.Import(D->getDeclName()); if (D->getDeclName() && !Name) - return 0; - + return nullptr; + // Import the location of this declaration. SourceLocation Loc = Importer.Import(D->getLocation()); // Import the parameter's type. QualType T = Importer.Import(D->getType()); if (T.isNull()) - return 0; - + return nullptr; + // Create the imported parameter. ImplicitParamDecl *ToParm = ImplicitParamDecl::Create(Importer.getToContext(), DC, @@ -3173,23 +3173,23 @@ Decl *ASTNodeImporter::VisitParmVarDecl(ParmVarDecl *D) { // Import the name of this declaration. DeclarationName Name = Importer.Import(D->getDeclName()); if (D->getDeclName() && !Name) - return 0; - + return nullptr; + // Import the location of this declaration. SourceLocation Loc = Importer.Import(D->getLocation()); // Import the parameter's type. QualType T = Importer.Import(D->getType()); if (T.isNull()) - return 0; - + return nullptr; + // Create the imported parameter. TypeSourceInfo *TInfo = Importer.Import(D->getTypeSourceInfo()); ParmVarDecl *ToParm = ParmVarDecl::Create(Importer.getToContext(), DC, Importer.Import(D->getInnerLocStart()), Loc, Name.getAsIdentifierInfo(), T, TInfo, D->getStorageClass(), - /*FIXME: Default argument*/ 0); + /*FIXME: Default argument*/nullptr); ToParm->setHasInheritedDefaultArg(D->hasInheritedDefaultArg()); return Importer.Imported(D, ToParm); } @@ -3200,8 +3200,8 @@ Decl *ASTNodeImporter::VisitObjCMethodDecl(ObjCMethodDecl *D) { DeclarationName Name; SourceLocation Loc; if (ImportDeclParts(D, DC, LexicalDC, Name, Loc)) - return 0; - + return nullptr; + SmallVector FoundDecls; DC->localUncachedLookup(Name, FoundDecls); for (unsigned I = 0, N = FoundDecls.size(); I != N; ++I) { @@ -3218,7 +3218,7 @@ Decl *ASTNodeImporter::VisitObjCMethodDecl(ObjCMethodDecl *D) { Importer.ToDiag(FoundMethod->getLocation(), diag::note_odr_objc_method_here) << D->isInstanceMethod() << Name; - return 0; + return nullptr; } // Check the number of parameters. @@ -3229,7 +3229,7 @@ Decl *ASTNodeImporter::VisitObjCMethodDecl(ObjCMethodDecl *D) { Importer.ToDiag(FoundMethod->getLocation(), diag::note_odr_objc_method_here) << D->isInstanceMethod() << Name; - return 0; + return nullptr; } // Check parameter types. @@ -3244,7 +3244,7 @@ Decl *ASTNodeImporter::VisitObjCMethodDecl(ObjCMethodDecl *D) { << (*P)->getType() << (*FoundP)->getType(); Importer.ToDiag((*FoundP)->getLocation(), diag::note_odr_value_here) << (*FoundP)->getType(); - return 0; + return nullptr; } } @@ -3256,7 +3256,7 @@ Decl *ASTNodeImporter::VisitObjCMethodDecl(ObjCMethodDecl *D) { Importer.ToDiag(FoundMethod->getLocation(), diag::note_odr_objc_method_here) << D->isInstanceMethod() << Name; - return 0; + return nullptr; } // FIXME: Any other bits we need to merge? @@ -3267,7 +3267,7 @@ Decl *ASTNodeImporter::VisitObjCMethodDecl(ObjCMethodDecl *D) { // Import the result type. QualType ResultTy = Importer.Import(D->getReturnType()); if (ResultTy.isNull()) - return 0; + return nullptr; TypeSourceInfo *ReturnTInfo = Importer.Import(D->getReturnTypeSourceInfo()); @@ -3285,8 +3285,8 @@ Decl *ASTNodeImporter::VisitObjCMethodDecl(ObjCMethodDecl *D) { for (auto *FromP : D->params()) { ParmVarDecl *ToP = cast_or_null(Importer.Import(FromP)); if (!ToP) - return 0; - + return nullptr; + ToParams.push_back(ToP); } @@ -3311,13 +3311,13 @@ Decl *ASTNodeImporter::VisitObjCCategoryDecl(ObjCCategoryDecl *D) { DeclarationName Name; SourceLocation Loc; if (ImportDeclParts(D, DC, LexicalDC, Name, Loc)) - return 0; - + return nullptr; + ObjCInterfaceDecl *ToInterface = cast_or_null(Importer.Import(D->getClassInterface())); if (!ToInterface) - return 0; - + return nullptr; + // Determine if we've already encountered this category. ObjCCategoryDecl *MergeWithCategory = ToInterface->FindCategoryDeclaration(Name.getAsIdentifierInfo()); @@ -3347,7 +3347,7 @@ Decl *ASTNodeImporter::VisitObjCCategoryDecl(ObjCCategoryDecl *D) { ObjCProtocolDecl *ToProto = cast_or_null(Importer.Import(*FromProto)); if (!ToProto) - return 0; + return nullptr; Protocols.push_back(ToProto); ProtocolLocs.push_back(Importer.Import(*FromProtoLoc)); } @@ -3369,8 +3369,8 @@ Decl *ASTNodeImporter::VisitObjCCategoryDecl(ObjCCategoryDecl *D) { = cast_or_null( Importer.Import(D->getImplementation())); if (!Impl) - return 0; - + return nullptr; + ToCategory->setImplementation(Impl); } @@ -3425,8 +3425,8 @@ Decl *ASTNodeImporter::VisitObjCProtocolDecl(ObjCProtocolDecl *D) { if (Definition && Definition != D) { Decl *ImportedDef = Importer.Import(Definition); if (!ImportedDef) - return 0; - + return nullptr; + return Importer.Imported(D, ImportedDef); } @@ -3435,9 +3435,9 @@ Decl *ASTNodeImporter::VisitObjCProtocolDecl(ObjCProtocolDecl *D) { DeclarationName Name; SourceLocation Loc; if (ImportDeclParts(D, DC, LexicalDC, Name, Loc)) - return 0; + return nullptr; - ObjCProtocolDecl *MergeWithProtocol = 0; + ObjCProtocolDecl *MergeWithProtocol = nullptr; SmallVector FoundDecls; DC->localUncachedLookup(Name, FoundDecls); for (unsigned I = 0, N = FoundDecls.size(); I != N; ++I) { @@ -3453,7 +3453,7 @@ Decl *ASTNodeImporter::VisitObjCProtocolDecl(ObjCProtocolDecl *D) { ToProto = ObjCProtocolDecl::Create(Importer.getToContext(), DC, Name.getAsIdentifierInfo(), Loc, Importer.Import(D->getAtStartLoc()), - /*PrevDecl=*/0); + /*PrevDecl=*/nullptr); ToProto->setLexicalDeclContext(LexicalDC); LexicalDC->addDeclInternal(ToProto); } @@ -3461,8 +3461,8 @@ Decl *ASTNodeImporter::VisitObjCProtocolDecl(ObjCProtocolDecl *D) { Importer.Imported(D, ToProto); if (D->isThisDeclarationADefinition() && ImportDefinition(D, ToProto)) - return 0; - + return nullptr; + return ToProto; } @@ -3570,8 +3570,8 @@ Decl *ASTNodeImporter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *D) { if (Definition && Definition != D) { Decl *ImportedDef = Importer.Import(Definition); if (!ImportedDef) - return 0; - + return nullptr; + return Importer.Imported(D, ImportedDef); } @@ -3580,10 +3580,10 @@ Decl *ASTNodeImporter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *D) { DeclarationName Name; SourceLocation Loc; if (ImportDeclParts(D, DC, LexicalDC, Name, Loc)) - return 0; + return nullptr; // Look for an existing interface with the same name. - ObjCInterfaceDecl *MergeWithIface = 0; + ObjCInterfaceDecl *MergeWithIface = nullptr; SmallVector FoundDecls; DC->localUncachedLookup(Name, FoundDecls); for (unsigned I = 0, N = FoundDecls.size(); I != N; ++I) { @@ -3600,7 +3600,7 @@ Decl *ASTNodeImporter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *D) { ToIface = ObjCInterfaceDecl::Create(Importer.getToContext(), DC, Importer.Import(D->getAtStartLoc()), Name.getAsIdentifierInfo(), - /*PrevDecl=*/0,Loc, + /*PrevDecl=*/nullptr, Loc, D->isImplicitInterfaceDecl()); ToIface->setLexicalDeclContext(LexicalDC); LexicalDC->addDeclInternal(ToIface); @@ -3608,8 +3608,8 @@ Decl *ASTNodeImporter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *D) { Importer.Imported(D, ToIface); if (D->isThisDeclarationADefinition() && ImportDefinition(D, ToIface)) - return 0; - + return nullptr; + return ToIface; } @@ -3617,14 +3617,14 @@ Decl *ASTNodeImporter::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D) { ObjCCategoryDecl *Category = cast_or_null( Importer.Import(D->getCategoryDecl())); if (!Category) - return 0; - + return nullptr; + ObjCCategoryImplDecl *ToImpl = Category->getImplementation(); if (!ToImpl) { DeclContext *DC = Importer.ImportContext(D->getDeclContext()); if (!DC) - return 0; - + return nullptr; + SourceLocation CategoryNameLoc = Importer.Import(D->getCategoryNameLoc()); ToImpl = ObjCCategoryImplDecl::Create(Importer.getToContext(), DC, Importer.Import(D->getIdentifier()), @@ -3637,8 +3637,8 @@ Decl *ASTNodeImporter::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D) { if (D->getDeclContext() != D->getLexicalDeclContext()) { LexicalDC = Importer.ImportContext(D->getLexicalDeclContext()); if (!LexicalDC) - return 0; - + return nullptr; + ToImpl->setLexicalDeclContext(LexicalDC); } @@ -3656,15 +3656,15 @@ Decl *ASTNodeImporter::VisitObjCImplementationDecl(ObjCImplementationDecl *D) { ObjCInterfaceDecl *Iface = cast_or_null( Importer.Import(D->getClassInterface())); if (!Iface) - return 0; + return nullptr; // Import the superclass, if any. - ObjCInterfaceDecl *Super = 0; + ObjCInterfaceDecl *Super = nullptr; if (D->getSuperClass()) { Super = cast_or_null( Importer.Import(D->getSuperClass())); if (!Super) - return 0; + return nullptr; } ObjCImplementationDecl *Impl = Iface->getImplementation(); @@ -3684,7 +3684,7 @@ Decl *ASTNodeImporter::VisitObjCImplementationDecl(ObjCImplementationDecl *D) { DeclContext *LexicalDC = Importer.ImportContext(D->getLexicalDeclContext()); if (!LexicalDC) - return 0; + return nullptr; Impl->setLexicalDeclContext(LexicalDC); } @@ -3719,7 +3719,7 @@ Decl *ASTNodeImporter::VisitObjCImplementationDecl(ObjCImplementationDecl *D) { else Importer.FromDiag(D->getLocation(), diag::note_odr_objc_missing_superclass); - return 0; + return nullptr; } } @@ -3735,7 +3735,7 @@ Decl *ASTNodeImporter::VisitObjCPropertyDecl(ObjCPropertyDecl *D) { DeclarationName Name; SourceLocation Loc; if (ImportDeclParts(D, DC, LexicalDC, Name, Loc)) - return 0; + return nullptr; // Check whether we have already imported this property. SmallVector FoundDecls; @@ -3750,7 +3750,7 @@ Decl *ASTNodeImporter::VisitObjCPropertyDecl(ObjCPropertyDecl *D) { << Name << D->getType() << FoundProp->getType(); Importer.ToDiag(FoundProp->getLocation(), diag::note_odr_value_here) << FoundProp->getType(); - return 0; + return nullptr; } // FIXME: Check property attributes, getters, setters, etc.? @@ -3764,7 +3764,7 @@ Decl *ASTNodeImporter::VisitObjCPropertyDecl(ObjCPropertyDecl *D) { // Import the type. TypeSourceInfo *T = Importer.Import(D->getTypeSourceInfo()); if (!T) - return 0; + return nullptr; // Create the new property. ObjCPropertyDecl *ToProperty @@ -3796,31 +3796,31 @@ Decl *ASTNodeImporter::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D) { ObjCPropertyDecl *Property = cast_or_null( Importer.Import(D->getPropertyDecl())); if (!Property) - return 0; + return nullptr; DeclContext *DC = Importer.ImportContext(D->getDeclContext()); if (!DC) - return 0; - + return nullptr; + // Import the lexical declaration context. DeclContext *LexicalDC = DC; if (D->getDeclContext() != D->getLexicalDeclContext()) { LexicalDC = Importer.ImportContext(D->getLexicalDeclContext()); if (!LexicalDC) - return 0; + return nullptr; } ObjCImplDecl *InImpl = dyn_cast(LexicalDC); if (!InImpl) - return 0; + return nullptr; // Import the ivar (for an @synthesize). - ObjCIvarDecl *Ivar = 0; + ObjCIvarDecl *Ivar = nullptr; if (D->getPropertyIvarDecl()) { Ivar = cast_or_null( Importer.Import(D->getPropertyIvarDecl())); if (!Ivar) - return 0; + return nullptr; } ObjCPropertyImplDecl *ToImpl @@ -3849,7 +3849,7 @@ Decl *ASTNodeImporter::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D) { diag::note_odr_objc_property_impl_kind) << D->getPropertyDecl()->getDeclName() << (D->getPropertyImplementation() == ObjCPropertyImplDecl::Dynamic); - return 0; + return nullptr; } // For @synthesize, check that we have the same @@ -3863,7 +3863,7 @@ Decl *ASTNodeImporter::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D) { Importer.FromDiag(D->getPropertyIvarDeclLoc(), diag::note_odr_objc_synthesize_ivar_here) << D->getPropertyIvarDecl()->getDeclName(); - return 0; + return nullptr; } // Merge the existing implementation with the new implementation. @@ -3895,21 +3895,21 @@ ASTNodeImporter::VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) { // Import the name of this declaration. DeclarationName Name = Importer.Import(D->getDeclName()); if (D->getDeclName() && !Name) - return 0; - + return nullptr; + // Import the location of this declaration. SourceLocation Loc = Importer.Import(D->getLocation()); // Import the type of this declaration. QualType T = Importer.Import(D->getType()); if (T.isNull()) - return 0; - + return nullptr; + // Import type-source information. TypeSourceInfo *TInfo = Importer.Import(D->getTypeSourceInfo()); if (D->getTypeSourceInfo() && !TInfo) - return 0; - + return nullptr; + // FIXME: Import default argument. return NonTypeTemplateParmDecl::Create(Importer.getToContext(), @@ -3925,8 +3925,8 @@ ASTNodeImporter::VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) { // Import the name of this declaration. DeclarationName Name = Importer.Import(D->getDeclName()); if (D->getDeclName() && !Name) - return 0; - + return nullptr; + // Import the location of this declaration. SourceLocation Loc = Importer.Import(D->getLocation()); @@ -3934,8 +3934,8 @@ ASTNodeImporter::VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) { TemplateParameterList *TemplateParams = ImportTemplateParameterList(D->getTemplateParameters()); if (!TemplateParams) - return 0; - + return nullptr; + // FIXME: Import default argument. return TemplateTemplateParmDecl::Create(Importer.getToContext(), @@ -3956,8 +3956,8 @@ Decl *ASTNodeImporter::VisitClassTemplateDecl(ClassTemplateDecl *D) { Decl *ImportedDef = Importer.Import(Definition->getDescribedClassTemplate()); if (!ImportedDef) - return 0; - + return nullptr; + return Importer.Imported(D, ImportedDef); } @@ -3966,8 +3966,8 @@ Decl *ASTNodeImporter::VisitClassTemplateDecl(ClassTemplateDecl *D) { DeclarationName Name; SourceLocation Loc; if (ImportDeclParts(D, DC, LexicalDC, Name, Loc)) - return 0; - + return nullptr; + // We may already have a template of the same name; try to find and match it. if (!DC->isFunctionOrMethod()) { SmallVector ConflictingDecls; @@ -4000,7 +4000,7 @@ Decl *ASTNodeImporter::VisitClassTemplateDecl(ClassTemplateDecl *D) { } if (!Name) - return 0; + return nullptr; } CXXRecordDecl *DTemplated = D->getTemplatedDecl(); @@ -4020,12 +4020,12 @@ Decl *ASTNodeImporter::VisitClassTemplateDecl(ClassTemplateDecl *D) { TemplateParameterList *TemplateParams = ImportTemplateParameterList(D->getTemplateParameters()); if (!TemplateParams) - return 0; - + return nullptr; + ClassTemplateDecl *D2 = ClassTemplateDecl::Create(Importer.getToContext(), DC, Loc, Name, TemplateParams, D2Templated, - /*PrevDecl=*/0); + /*PrevDecl=*/nullptr); D2Templated->setDescribedClassTemplate(D2); D2->setAccess(D->getAccess()); @@ -4053,8 +4053,8 @@ Decl *ASTNodeImporter::VisitClassTemplateSpecializationDecl( if (Definition && Definition != D) { Decl *ImportedDef = Importer.Import(Definition); if (!ImportedDef) - return 0; - + return nullptr; + return Importer.Imported(D, ImportedDef); } @@ -4062,18 +4062,18 @@ Decl *ASTNodeImporter::VisitClassTemplateSpecializationDecl( = cast_or_null(Importer.Import( D->getSpecializedTemplate())); if (!ClassTemplate) - return 0; - + return nullptr; + // Import the context of this declaration. DeclContext *DC = ClassTemplate->getDeclContext(); if (!DC) - return 0; - + return nullptr; + DeclContext *LexicalDC = DC; if (D->getDeclContext() != D->getLexicalDeclContext()) { LexicalDC = Importer.ImportContext(D->getLexicalDeclContext()); if (!LexicalDC) - return 0; + return nullptr; } // Import the location of this declaration. @@ -4085,10 +4085,10 @@ Decl *ASTNodeImporter::VisitClassTemplateSpecializationDecl( if (ImportTemplateArguments(D->getTemplateArgs().data(), D->getTemplateArgs().size(), TemplateArgs)) - return 0; - + return nullptr; + // Try to find an existing specialization with these template arguments. - void *InsertPos = 0; + void *InsertPos = nullptr; ClassTemplateSpecializationDecl *D2 = ClassTemplate->findSpecialization(TemplateArgs.data(), TemplateArgs.size(), InsertPos); @@ -4114,7 +4114,7 @@ Decl *ASTNodeImporter::VisitClassTemplateSpecializationDecl( ClassTemplate, TemplateArgs.data(), TemplateArgs.size(), - /*PrevDecl=*/0); + /*PrevDecl=*/nullptr); D2->setSpecializationKind(D->getSpecializationKind()); // Add this specialization to the class template. @@ -4130,8 +4130,8 @@ Decl *ASTNodeImporter::VisitClassTemplateSpecializationDecl( Importer.Imported(D, D2); if (D->isCompleteDefinition() && ImportDefinition(D, D2)) - return 0; - + return nullptr; + return D2; } @@ -4145,7 +4145,7 @@ Decl *ASTNodeImporter::VisitVarTemplateDecl(VarTemplateDecl *D) { if (Definition && Definition != D->getTemplatedDecl()) { Decl *ImportedDef = Importer.Import(Definition->getDescribedVarTemplate()); if (!ImportedDef) - return 0; + return nullptr; return Importer.Imported(D, ImportedDef); } @@ -4155,7 +4155,7 @@ Decl *ASTNodeImporter::VisitVarTemplateDecl(VarTemplateDecl *D) { DeclarationName Name; SourceLocation Loc; if (ImportDeclParts(D, DC, LexicalDC, Name, Loc)) - return 0; + return nullptr; // We may already have a template of the same name; try to find and match it. assert(!DC->isFunctionOrMethod() && @@ -4187,14 +4187,14 @@ Decl *ASTNodeImporter::VisitVarTemplateDecl(VarTemplateDecl *D) { } if (!Name) - return 0; + return nullptr; VarDecl *DTemplated = D->getTemplatedDecl(); // Import the type. QualType T = Importer.Import(DTemplated->getType()); if (T.isNull()) - return 0; + return nullptr; // Create the declaration that is being templated. SourceLocation StartLoc = Importer.Import(DTemplated->getLocStart()); @@ -4212,13 +4212,13 @@ Decl *ASTNodeImporter::VisitVarTemplateDecl(VarTemplateDecl *D) { // Merge the initializer. if (ImportDefinition(DTemplated, D2Templated)) - return 0; + return nullptr; // Create the variable template declaration itself. TemplateParameterList *TemplateParams = ImportTemplateParameterList(D->getTemplateParameters()); if (!TemplateParams) - return 0; + return nullptr; VarTemplateDecl *D2 = VarTemplateDecl::Create( Importer.getToContext(), DC, Loc, Name, TemplateParams, D2Templated); @@ -4249,7 +4249,7 @@ Decl *ASTNodeImporter::VisitVarTemplateSpecializationDecl( if (Definition && Definition != D) { Decl *ImportedDef = Importer.Import(Definition); if (!ImportedDef) - return 0; + return nullptr; return Importer.Imported(D, ImportedDef); } @@ -4257,18 +4257,18 @@ Decl *ASTNodeImporter::VisitVarTemplateSpecializationDecl( VarTemplateDecl *VarTemplate = cast_or_null( Importer.Import(D->getSpecializedTemplate())); if (!VarTemplate) - return 0; + return nullptr; // Import the context of this declaration. DeclContext *DC = VarTemplate->getDeclContext(); if (!DC) - return 0; + return nullptr; DeclContext *LexicalDC = DC; if (D->getDeclContext() != D->getLexicalDeclContext()) { LexicalDC = Importer.ImportContext(D->getLexicalDeclContext()); if (!LexicalDC) - return 0; + return nullptr; } // Import the location of this declaration. @@ -4279,10 +4279,10 @@ Decl *ASTNodeImporter::VisitVarTemplateSpecializationDecl( SmallVector TemplateArgs; if (ImportTemplateArguments(D->getTemplateArgs().data(), D->getTemplateArgs().size(), TemplateArgs)) - return 0; + return nullptr; // Try to find an existing specialization with these template arguments. - void *InsertPos = 0; + void *InsertPos = nullptr; VarTemplateSpecializationDecl *D2 = VarTemplate->findSpecialization( TemplateArgs.data(), TemplateArgs.size(), InsertPos); if (D2) { @@ -4305,7 +4305,7 @@ Decl *ASTNodeImporter::VisitVarTemplateSpecializationDecl( // Import the type. QualType T = Importer.Import(D->getType()); if (T.isNull()) - return 0; + return nullptr; TypeSourceInfo *TInfo = Importer.Import(D->getTypeSourceInfo()); // Create a new specialization. @@ -4328,7 +4328,7 @@ Decl *ASTNodeImporter::VisitVarTemplateSpecializationDecl( Importer.Imported(D, D2); if (D->isThisDeclarationADefinition() && ImportDefinition(D, D2)) - return 0; + return nullptr; return D2; } @@ -4340,7 +4340,7 @@ Decl *ASTNodeImporter::VisitVarTemplateSpecializationDecl( Stmt *ASTNodeImporter::VisitStmt(Stmt *S) { Importer.FromDiag(S->getLocStart(), diag::err_unsupported_ast_node) << S->getStmtClassName(); - return 0; + return nullptr; } //---------------------------------------------------------------------------- @@ -4349,24 +4349,24 @@ Stmt *ASTNodeImporter::VisitStmt(Stmt *S) { Expr *ASTNodeImporter::VisitExpr(Expr *E) { Importer.FromDiag(E->getLocStart(), diag::err_unsupported_ast_node) << E->getStmtClassName(); - return 0; + return nullptr; } Expr *ASTNodeImporter::VisitDeclRefExpr(DeclRefExpr *E) { ValueDecl *ToD = cast_or_null(Importer.Import(E->getDecl())); if (!ToD) - return 0; + return nullptr; - NamedDecl *FoundD = 0; + NamedDecl *FoundD = nullptr; if (E->getDecl() != E->getFoundDecl()) { FoundD = cast_or_null(Importer.Import(E->getFoundDecl())); if (!FoundD) - return 0; + return nullptr; } QualType T = Importer.Import(E->getType()); if (T.isNull()) - return 0; + return nullptr; DeclRefExpr *DRE = DeclRefExpr::Create(Importer.getToContext(), Importer.Import(E->getQualifierLoc()), @@ -4376,7 +4376,7 @@ Expr *ASTNodeImporter::VisitDeclRefExpr(DeclRefExpr *E) { Importer.Import(E->getLocation()), T, E->getValueKind(), FoundD, - /*FIXME:TemplateArgs=*/0); + /*FIXME:TemplateArgs=*/nullptr); if (E->hadMultipleCandidates()) DRE->setHadMultipleCandidates(true); return DRE; @@ -4385,7 +4385,7 @@ Expr *ASTNodeImporter::VisitDeclRefExpr(DeclRefExpr *E) { Expr *ASTNodeImporter::VisitIntegerLiteral(IntegerLiteral *E) { QualType T = Importer.Import(E->getType()); if (T.isNull()) - return 0; + return nullptr; return IntegerLiteral::Create(Importer.getToContext(), E->getValue(), T, @@ -4395,8 +4395,8 @@ Expr *ASTNodeImporter::VisitIntegerLiteral(IntegerLiteral *E) { Expr *ASTNodeImporter::VisitCharacterLiteral(CharacterLiteral *E) { QualType T = Importer.Import(E->getType()); if (T.isNull()) - return 0; - + return nullptr; + return new (Importer.getToContext()) CharacterLiteral(E->getValue(), E->getKind(), T, Importer.Import(E->getLocation())); @@ -4405,8 +4405,8 @@ Expr *ASTNodeImporter::VisitCharacterLiteral(CharacterLiteral *E) { Expr *ASTNodeImporter::VisitParenExpr(ParenExpr *E) { Expr *SubExpr = Importer.Import(E->getSubExpr()); if (!SubExpr) - return 0; - + return nullptr; + return new (Importer.getToContext()) ParenExpr(Importer.Import(E->getLParen()), Importer.Import(E->getRParen()), @@ -4416,12 +4416,12 @@ Expr *ASTNodeImporter::VisitParenExpr(ParenExpr *E) { Expr *ASTNodeImporter::VisitUnaryOperator(UnaryOperator *E) { QualType T = Importer.Import(E->getType()); if (T.isNull()) - return 0; + return nullptr; Expr *SubExpr = Importer.Import(E->getSubExpr()); if (!SubExpr) - return 0; - + return nullptr; + return new (Importer.getToContext()) UnaryOperator(SubExpr, E->getOpcode(), T, E->getValueKind(), E->getObjectKind(), @@ -4435,8 +4435,8 @@ Expr *ASTNodeImporter::VisitUnaryExprOrTypeTraitExpr( if (E->isArgumentType()) { TypeSourceInfo *TInfo = Importer.Import(E->getArgumentTypeInfo()); if (!TInfo) - return 0; - + return nullptr; + return new (Importer.getToContext()) UnaryExprOrTypeTraitExpr(E->getKind(), TInfo, ResultType, Importer.Import(E->getOperatorLoc()), @@ -4445,8 +4445,8 @@ Expr *ASTNodeImporter::VisitUnaryExprOrTypeTraitExpr( Expr *SubExpr = Importer.Import(E->getArgumentExpr()); if (!SubExpr) - return 0; - + return nullptr; + return new (Importer.getToContext()) UnaryExprOrTypeTraitExpr(E->getKind(), SubExpr, ResultType, Importer.Import(E->getOperatorLoc()), @@ -4456,16 +4456,16 @@ Expr *ASTNodeImporter::VisitUnaryExprOrTypeTraitExpr( Expr *ASTNodeImporter::VisitBinaryOperator(BinaryOperator *E) { QualType T = Importer.Import(E->getType()); if (T.isNull()) - return 0; + return nullptr; Expr *LHS = Importer.Import(E->getLHS()); if (!LHS) - return 0; - + return nullptr; + Expr *RHS = Importer.Import(E->getRHS()); if (!RHS) - return 0; - + return nullptr; + return new (Importer.getToContext()) BinaryOperator(LHS, RHS, E->getOpcode(), T, E->getValueKind(), E->getObjectKind(), @@ -4476,24 +4476,24 @@ Expr *ASTNodeImporter::VisitBinaryOperator(BinaryOperator *E) { Expr *ASTNodeImporter::VisitCompoundAssignOperator(CompoundAssignOperator *E) { QualType T = Importer.Import(E->getType()); if (T.isNull()) - return 0; - + return nullptr; + QualType CompLHSType = Importer.Import(E->getComputationLHSType()); if (CompLHSType.isNull()) - return 0; - + return nullptr; + QualType CompResultType = Importer.Import(E->getComputationResultType()); if (CompResultType.isNull()) - return 0; - + return nullptr; + Expr *LHS = Importer.Import(E->getLHS()); if (!LHS) - return 0; - + return nullptr; + Expr *RHS = Importer.Import(E->getRHS()); if (!RHS) - return 0; - + return nullptr; + return new (Importer.getToContext()) CompoundAssignOperator(LHS, RHS, E->getOpcode(), T, E->getValueKind(), @@ -4513,15 +4513,15 @@ static bool ImportCastPath(CastExpr *E, CXXCastPath &Path) { Expr *ASTNodeImporter::VisitImplicitCastExpr(ImplicitCastExpr *E) { QualType T = Importer.Import(E->getType()); if (T.isNull()) - return 0; + return nullptr; Expr *SubExpr = Importer.Import(E->getSubExpr()); if (!SubExpr) - return 0; + return nullptr; CXXCastPath BasePath; if (ImportCastPath(E, BasePath)) - return 0; + return nullptr; return ImplicitCastExpr::Create(Importer.getToContext(), T, E->getCastKind(), SubExpr, &BasePath, E->getValueKind()); @@ -4530,19 +4530,19 @@ Expr *ASTNodeImporter::VisitImplicitCastExpr(ImplicitCastExpr *E) { Expr *ASTNodeImporter::VisitCStyleCastExpr(CStyleCastExpr *E) { QualType T = Importer.Import(E->getType()); if (T.isNull()) - return 0; - + return nullptr; + Expr *SubExpr = Importer.Import(E->getSubExpr()); if (!SubExpr) - return 0; + return nullptr; TypeSourceInfo *TInfo = Importer.Import(E->getTypeInfoAsWritten()); if (!TInfo && E->getTypeInfoAsWritten()) - return 0; - + return nullptr; + CXXCastPath BasePath; if (ImportCastPath(E, BasePath)) - return 0; + return nullptr; return CStyleCastExpr::Create(Importer.getToContext(), T, E->getValueKind(), E->getCastKind(), @@ -4596,7 +4596,7 @@ TypeSourceInfo *ASTImporter::Import(TypeSourceInfo *FromTSI) { // on the type and a single location. Implement a real version of this. QualType T = Import(FromTSI->getType()); if (T.isNull()) - return 0; + return nullptr; return ToContext.getTrivialTypeSourceInfo(T, FromTSI->getTypeLoc().getLocStart()); @@ -4604,7 +4604,7 @@ TypeSourceInfo *ASTImporter::Import(TypeSourceInfo *FromTSI) { Decl *ASTImporter::Import(Decl *FromD) { if (!FromD) - return 0; + return nullptr; ASTNodeImporter Importer(*this); @@ -4619,8 +4619,8 @@ Decl *ASTImporter::Import(Decl *FromD) { // Import the type Decl *ToD = Importer.Visit(FromD); if (!ToD) - return 0; - + return nullptr; + // Record the imported declaration. ImportedDecls[FromD] = ToD; @@ -4655,8 +4655,8 @@ DeclContext *ASTImporter::ImportContext(DeclContext *FromDC) { DeclContext *ToDC = cast_or_null(Import(cast(FromDC))); if (!ToDC) - return 0; - + return nullptr; + // When we're using a record/enum/Objective-C class/protocol as a context, we // need it to have a definition. if (RecordDecl *ToRecord = dyn_cast(ToDC)) { @@ -4706,14 +4706,14 @@ DeclContext *ASTImporter::ImportContext(DeclContext *FromDC) { Expr *ASTImporter::Import(Expr *FromE) { if (!FromE) - return 0; + return nullptr; return cast_or_null(Import(cast(FromE))); } Stmt *ASTImporter::Import(Stmt *FromS) { if (!FromS) - return 0; + return nullptr; // Check whether we've already imported this declaration. llvm::DenseMap::iterator Pos = ImportedStmts.find(FromS); @@ -4724,8 +4724,8 @@ Stmt *ASTImporter::Import(Stmt *FromS) { ASTNodeImporter Importer(*this); Stmt *ToS = Importer.Visit(FromS); if (!ToS) - return 0; - + return nullptr; + // Record the imported declaration. ImportedStmts[FromS] = ToS; return ToS; @@ -4733,7 +4733,7 @@ Stmt *ASTImporter::Import(Stmt *FromS) { NestedNameSpecifier *ASTImporter::Import(NestedNameSpecifier *FromNNS) { if (!FromNNS) - return 0; + return nullptr; NestedNameSpecifier *prefix = Import(FromNNS->getPrefix()); @@ -4742,21 +4742,21 @@ NestedNameSpecifier *ASTImporter::Import(NestedNameSpecifier *FromNNS) { if (IdentifierInfo *II = Import(FromNNS->getAsIdentifier())) { return NestedNameSpecifier::Create(ToContext, prefix, II); } - return 0; + return nullptr; case NestedNameSpecifier::Namespace: if (NamespaceDecl *NS = cast(Import(FromNNS->getAsNamespace()))) { return NestedNameSpecifier::Create(ToContext, prefix, NS); } - return 0; + return nullptr; case NestedNameSpecifier::NamespaceAlias: if (NamespaceAliasDecl *NSAD = cast(Import(FromNNS->getAsNamespaceAlias()))) { return NestedNameSpecifier::Create(ToContext, prefix, NSAD); } - return 0; + return nullptr; case NestedNameSpecifier::Global: return NestedNameSpecifier::GlobalSpecifier(ToContext); @@ -4771,7 +4771,7 @@ NestedNameSpecifier *ASTImporter::Import(NestedNameSpecifier *FromNNS) { bTemplate, T.getTypePtr()); } } - return 0; + return nullptr; } llvm_unreachable("Invalid nested name specifier kind"); @@ -5034,7 +5034,7 @@ DeclarationName ASTImporter::Import(DeclarationName FromName) { IdentifierInfo *ASTImporter::Import(const IdentifierInfo *FromId) { if (!FromId) - return 0; + return nullptr; return &ToContext.Idents.get(FromId->getName()); } diff --git a/lib/AST/ASTTypeTraits.cpp b/lib/AST/ASTTypeTraits.cpp index 02d82d819e..baa8e48779 100644 --- a/lib/AST/ASTTypeTraits.cpp +++ b/lib/AST/ASTTypeTraits.cpp @@ -77,7 +77,7 @@ void DynTypedNode::print(llvm::raw_ostream &OS, else if (const Decl *D = get()) D->print(OS, PP); else if (const Stmt *S = get()) - S->printPretty(OS, 0, PP); + S->printPretty(OS, nullptr, PP); else if (const Type *T = get()) QualType(T, 0).print(OS, PP); else diff --git a/lib/AST/CXXInheritance.cpp b/lib/AST/CXXInheritance.cpp index eef043cc5a..6e80ee7c28 100644 --- a/lib/AST/CXXInheritance.cpp +++ b/lib/AST/CXXInheritance.cpp @@ -58,7 +58,7 @@ void CXXBasePaths::clear() { Paths.clear(); ClassSubobjects.clear(); ScratchPath.clear(); - DetectedVirtual = 0; + DetectedVirtual = nullptr; } /// @brief Swaps the contents of this CXXBasePaths structure with the @@ -203,7 +203,7 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context, if (BaseSpec.isVirtual()) { VisitBase = !Subobjects.first; Subobjects.first = true; - if (isDetectingVirtual() && DetectedVirtual == 0) { + if (isDetectingVirtual() && DetectedVirtual == nullptr) { // If this is the first virtual we find, remember it. If it turns out // there is no base path here, we'll reset it later. DetectedVirtual = BaseType->getAs(); @@ -286,7 +286,7 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context, // If we set a virtual earlier, and this isn't a path, forget it again. if (SetVirtual && !FoundPathThroughBase) { - DetectedVirtual = 0; + DetectedVirtual = nullptr; } } @@ -325,7 +325,7 @@ bool CXXRecordDecl::lookupInBases(BaseMatchesCallback *BaseMatches, for (CXXBasePath::iterator PE = P->begin(), PEEnd = P->end(); PE != PEEnd && !Hidden; ++PE) { if (PE->Base->isVirtual()) { - CXXRecordDecl *VBase = 0; + CXXRecordDecl *VBase = nullptr; if (const RecordType *Record = PE->Base->getType()->getAs()) VBase = cast(Record->getDecl()); if (!VBase) @@ -339,7 +339,7 @@ bool CXXRecordDecl::lookupInBases(BaseMatchesCallback *BaseMatches, HidingPEnd = Paths.end(); HidingP != HidingPEnd; ++HidingP) { - CXXRecordDecl *HidingClass = 0; + CXXRecordDecl *HidingClass = nullptr; if (const RecordType *Record = HidingP->back().Base->getType()->getAs()) HidingClass = cast(Record->getDecl()); @@ -625,7 +625,7 @@ FinalOverriderCollector::~FinalOverriderCollector() { void CXXRecordDecl::getFinalOverriders(CXXFinalOverriderMap &FinalOverriders) const { FinalOverriderCollector Collector; - Collector.Collect(this, false, 0, FinalOverriders); + Collector.Collect(this, false, nullptr, FinalOverriders); // Weed out any final overriders that come from virtual base class // subobjects that were hidden by other subobjects along any path. diff --git a/lib/AST/Comment.cpp b/lib/AST/Comment.cpp index b0b2351074..4f433467f9 100644 --- a/lib/AST/Comment.cpp +++ b/lib/AST/Comment.cpp @@ -136,7 +136,7 @@ void DeclInfo::fill() { IsInstanceMethod = false; IsClassMethod = false; ParamVars = None; - TemplateParameters = NULL; + TemplateParameters = nullptr; if (!CommentDecl) { // If there is no declaration, the defaults is our only guess. diff --git a/lib/AST/CommentCommandTraits.cpp b/lib/AST/CommentCommandTraits.cpp index 8879aac628..a7b07a40c9 100644 --- a/lib/AST/CommentCommandTraits.cpp +++ b/lib/AST/CommentCommandTraits.cpp @@ -113,7 +113,7 @@ const CommandInfo *CommandTraits::getBuiltinCommandInfo( unsigned CommandID) { if (CommandID < llvm::array_lengthof(Commands)) return &Commands[CommandID]; - return NULL; + return nullptr; } const CommandInfo *CommandTraits::getRegisteredCommandInfo( @@ -122,7 +122,7 @@ const CommandInfo *CommandTraits::getRegisteredCommandInfo( if (RegisteredCommands[i]->Name == Name) return RegisteredCommands[i]; } - return NULL; + return nullptr; } const CommandInfo *CommandTraits::getRegisteredCommandInfo( diff --git a/lib/AST/CommentParser.cpp b/lib/AST/CommentParser.cpp index 03e01015b9..cb37ec35f4 100644 --- a/lib/AST/CommentParser.cpp +++ b/lib/AST/CommentParser.cpp @@ -311,9 +311,9 @@ void Parser::parseBlockCommandArgs(BlockCommandComment *BC, BlockCommandComment *Parser::parseBlockCommand() { assert(Tok.is(tok::backslash_command) || Tok.is(tok::at_command)); - ParamCommandComment *PC = 0; - TParamCommandComment *TPC = 0; - BlockCommandComment *BC = 0; + ParamCommandComment *PC = nullptr; + TParamCommandComment *TPC = nullptr; + BlockCommandComment *BC = nullptr; const CommandInfo *Info = Traits.getCommandInfo(Tok.getCommandID()); CommandMarkerKind CommandMarker = Tok.is(tok::backslash_command) ? CMK_Backslash : CMK_At; diff --git a/lib/AST/CommentSema.cpp b/lib/AST/CommentSema.cpp index 4bcd3427df..12823c37df 100644 --- a/lib/AST/CommentSema.cpp +++ b/lib/AST/CommentSema.cpp @@ -29,7 +29,8 @@ Sema::Sema(llvm::BumpPtrAllocator &Allocator, const SourceManager &SourceMgr, DiagnosticsEngine &Diags, CommandTraits &Traits, const Preprocessor *PP) : Allocator(Allocator), SourceMgr(SourceMgr), Diags(Diags), Traits(Traits), - PP(PP), ThisDeclInfo(NULL), BriefCommand(NULL), HeaderfileCommand(NULL) { + PP(PP), ThisDeclInfo(nullptr), BriefCommand(nullptr), + HeaderfileCommand(nullptr) { } void Sema::setDecl(const Decl *D) { @@ -623,7 +624,7 @@ void Sema::checkReturnsCommand(const BlockCommandComment *Command) { void Sema::checkBlockCommandDuplicate(const BlockCommandComment *Command) { const CommandInfo *Info = Traits.getCommandInfo(Command->getCommandID()); - const BlockCommandComment *PrevCommand = NULL; + const BlockCommandComment *PrevCommand = nullptr; if (Info->IsBriefCommand) { if (!BriefCommand) { BriefCommand = Command; @@ -723,7 +724,7 @@ void Sema::resolveParamCommandIndexes(const FullComment *FC) { SmallVector ParamVarDocs; ArrayRef ParamVars = getParamVars(); - ParamVarDocs.resize(ParamVars.size(), NULL); + ParamVarDocs.resize(ParamVars.size(), nullptr); // First pass over all \\param commands: resolve all parameter names. for (Comment::child_iterator I = FC->child_begin(), E = FC->child_end(); @@ -962,7 +963,7 @@ class SimpleTypoCorrector { public: SimpleTypoCorrector(StringRef Typo) : Typo(Typo), MaxEditDistance((Typo.size() + 2) / 3), - BestDecl(NULL), BestEditDistance(MaxEditDistance + 1), + BestDecl(nullptr), BestEditDistance(MaxEditDistance + 1), BestIndex(0), NextIndex(0) { } @@ -970,7 +971,7 @@ public: const NamedDecl *getBestDecl() const { if (BestEditDistance > MaxEditDistance) - return NULL; + return nullptr; return BestDecl; } diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index b264be15ed..49466b2d98 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -286,7 +286,7 @@ static LinkageInfo getLVForDecl(const NamedDecl *D, LVComputationKind computation); static const Decl *getOutermostFuncOrBlockContext(const Decl *D) { - const Decl *Ret = NULL; + const Decl *Ret = nullptr; const DeclContext *DC = D->getDeclContext(); while (DC->getDeclKind() != Decl::TranslationUnit) { if (isa(DC) || isa(DC)) @@ -490,7 +490,7 @@ static bool useInlineVisibilityHidden(const NamedDecl *D) { TSK = MSI->getTemplateSpecializationKind(); } - const FunctionDecl *Def = 0; + const FunctionDecl *Def = nullptr; // InlineVisibilityHidden only applies to definitions, and // isInlined() only gives meaningful answers on definitions // anyway. @@ -818,7 +818,7 @@ static LinkageInfo getLVForClassMember(const NamedDecl *D, // we need to completely ignore the visibility from it. // Specifically, if this decl exists and has an explicit attribute. - const NamedDecl *explicitSpecSuppressor = 0; + const NamedDecl *explicitSpecSuppressor = nullptr; if (const CXXMethodDecl *MD = dyn_cast(D)) { // If the type of the function uses a type with unique-external @@ -1240,7 +1240,7 @@ public: // We have just computed the linkage for this decl. By induction we know // that all other computed linkages match, check that the one we just // computed also does. - NamedDecl *Old = NULL; + NamedDecl *Old = nullptr; for (auto I : D->redecls()) { NamedDecl *T = cast(I); if (T == D) @@ -1313,7 +1313,7 @@ void NamedDecl::printQualifiedName(raw_ostream &OS, else OS << *RD; } else if (const FunctionDecl *FD = dyn_cast(*I)) { - const FunctionProtoType *FT = 0; + const FunctionProtoType *FT = nullptr; if (FD->hasWrittenPrototype()) FT = dyn_cast(FD->getType()->castAs()); @@ -1580,13 +1580,13 @@ void QualifierInfo::setTemplateParameterListsInfo(ASTContext &Context, unsigned NumTPLists, TemplateParameterList **TPLists) { - assert((NumTPLists == 0 || TPLists != 0) && + assert((NumTPLists == 0 || TPLists != nullptr) && "Empty array of template parameters with positive size!"); // Free previous template parameters (if any). if (NumTemplParamLists > 0) { Context.Deallocate(TemplParamLists); - TemplParamLists = 0; + TemplParamLists = nullptr; NumTemplParamLists = 0; } // Set info on matched template parameter lists (if any). @@ -1637,8 +1637,8 @@ VarDecl *VarDecl::Create(ASTContext &C, DeclContext *DC, } VarDecl *VarDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) VarDecl(Var, 0, SourceLocation(), SourceLocation(), 0, - QualType(), 0, SC_None); + return new (C, ID) VarDecl(Var, nullptr, SourceLocation(), SourceLocation(), + nullptr, QualType(), nullptr, SC_None); } void VarDecl::setStorageClass(StorageClass SC) { @@ -1806,14 +1806,14 @@ VarDecl::DefinitionKind VarDecl::isThisDeclarationADefinition( VarDecl *VarDecl::getActingDefinition() { DefinitionKind Kind = isThisDeclarationADefinition(); if (Kind != TentativeDefinition) - return 0; + return nullptr; - VarDecl *LastTentative = 0; + VarDecl *LastTentative = nullptr; VarDecl *First = getFirstDecl(); for (auto I : First->redecls()) { Kind = I->isThisDeclarationADefinition(); if (Kind == Definition) - return 0; + return nullptr; else if (Kind == TentativeDefinition) LastTentative = I; } @@ -1826,7 +1826,7 @@ VarDecl *VarDecl::getDefinition(ASTContext &C) { if (I->isThisDeclarationADefinition(C) == Definition) return I; } - return 0; + return nullptr; } VarDecl::DefinitionKind VarDecl::hasDefinition(ASTContext &C) const { @@ -1849,7 +1849,7 @@ const Expr *VarDecl::getAnyInitializer(const VarDecl *&D) const { return Expr; } } - return 0; + return nullptr; } bool VarDecl::isOutOfLine() const { @@ -1870,14 +1870,14 @@ bool VarDecl::isOutOfLine() const { VarDecl *VarDecl::getOutOfLineDefinition() { if (!isStaticDataMember()) - return 0; - + return nullptr; + for (auto RD : redecls()) { if (RD->getLexicalDeclContext()->isFileContext()) return RD; } - - return 0; + + return nullptr; } void VarDecl::setInit(Expr *I) { @@ -1954,7 +1954,7 @@ APValue *VarDecl::evaluateValue( // first time it is evaluated. FIXME: The notes won't always be emitted the // first time we try evaluation, so might not be produced at all. if (Eval->WasEvaluated) - return Eval->Evaluated.isUninit() ? 0 : &Eval->Evaluated; + return Eval->Evaluated.isUninit() ? nullptr : &Eval->Evaluated; const Expr *Init = cast(Eval->Value); assert(!Init->isValueDependent()); @@ -1963,7 +1963,7 @@ APValue *VarDecl::evaluateValue( // FIXME: Produce a diagnostic for self-initialization. Eval->CheckedICE = true; Eval->IsICE = false; - return 0; + return nullptr; } Eval->IsEvaluating = true; @@ -1989,7 +1989,7 @@ APValue *VarDecl::evaluateValue( Eval->IsICE = Result && Notes.empty(); } - return Result ? &Eval->Evaluated : 0; + return Result ? &Eval->Evaluated : nullptr; } bool VarDecl::checkInitIsICE() const { @@ -2031,8 +2031,8 @@ bool VarDecl::checkInitIsICE() const { VarDecl *VarDecl::getInstantiatedFromStaticDataMember() const { if (MemberSpecializationInfo *MSI = getMemberSpecializationInfo()) return cast(MSI->getInstantiatedFrom()); - - return 0; + + return nullptr; } TemplateSpecializationKind VarDecl::getTemplateSpecializationKind() const { @@ -2072,7 +2072,7 @@ MemberSpecializationInfo *VarDecl::getMemberSpecializationInfo() const { // return getASTContext().getInstantiatedFromStaticDataMember(this); return getASTContext().getTemplateOrSpecializationInfo(this) .dyn_cast(); - return 0; + return nullptr; } void VarDecl::setTemplateSpecializationKind(TemplateSpecializationKind TSK, @@ -2127,8 +2127,9 @@ QualType ParmVarDecl::getOriginalType() const { } ParmVarDecl *ParmVarDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) ParmVarDecl(ParmVar, 0, SourceLocation(), SourceLocation(), - 0, QualType(), 0, SC_None, 0); + return new (C, ID) ParmVarDecl(ParmVar, nullptr, SourceLocation(), + SourceLocation(), nullptr, QualType(), + nullptr, SC_None, nullptr); } SourceRange ParmVarDecl::getSourceRange() const { @@ -2239,12 +2240,12 @@ bool FunctionDecl::isDefined(const FunctionDecl *&Definition) const { Stmt *FunctionDecl::getBody(const FunctionDecl *&Definition) const { if (!hasBody(Definition)) - return 0; + return nullptr; if (Definition->Body) return Definition->Body.get(getASTContext().getExternalSource()); - return 0; + return nullptr; } void FunctionDecl::setBody(Stmt *B) { @@ -2376,23 +2377,23 @@ FunctionDecl * FunctionDecl::getCorrespondingUnsizedGlobalDeallocationFunction() const { ASTContext &Ctx = getASTContext(); if (!Ctx.getLangOpts().SizedDeallocation) - return 0; + return nullptr; if (getDeclName().getNameKind() != DeclarationName::CXXOperatorName) - return 0; + return nullptr; if (getDeclName().getCXXOverloadedOperator() != OO_Delete && getDeclName().getCXXOverloadedOperator() != OO_Array_Delete) - return 0; + return nullptr; if (isa(getDeclContext())) - return 0; + return nullptr; if (!getDeclContext()->getRedeclContext()->isTranslationUnit()) - return 0; + return nullptr; if (getNumParams() != 2 || isVariadic() || !Ctx.hasSameType(getType()->castAs()->getParamType(1), Ctx.getSizeType())) - return 0; + return nullptr; // This is a sized deallocation function. Find the corresponding unsized // deallocation function. @@ -2402,7 +2403,7 @@ FunctionDecl::getCorrespondingUnsizedGlobalDeallocationFunction() const { if (FunctionDecl *FD = dyn_cast(*RI)) if (FD->getNumParams() == 1 && !FD->isVariadic()) return FD; - return 0; + return nullptr; } LanguageLinkage FunctionDecl::getLanguageLinkage() const { @@ -2453,7 +2454,7 @@ FunctionDecl::setPreviousDeclaration(FunctionDecl *PrevDecl) { if (FunctionTemplateDecl *FunTmpl = getDescribedFunctionTemplate()) { FunctionTemplateDecl *PrevFunTmpl - = PrevDecl? PrevDecl->getDescribedFunctionTemplate() : 0; + = PrevDecl? PrevDecl->getDescribedFunctionTemplate() : nullptr; assert((!PrevDecl || PrevFunTmpl) && "Function/function template mismatch"); FunTmpl->setPreviousDecl(PrevFunTmpl); } @@ -2527,7 +2528,7 @@ unsigned FunctionDecl::getNumParams() const { void FunctionDecl::setParams(ASTContext &C, ArrayRef NewParamInfo) { - assert(ParamInfo == 0 && "Already has param info!"); + assert(!ParamInfo && "Already has param info!"); assert(NewParamInfo.size() == getNumParams() && "Parameter count mismatch!"); // Zero params -> null pointer. @@ -2753,7 +2754,7 @@ const IdentifierInfo *FunctionDecl::getLiteralIdentifier() const { if (getDeclName().getNameKind() == DeclarationName::CXXLiteralOperatorName) return getDeclName().getCXXLiteralIdentifier(); else - return 0; + return nullptr; } FunctionDecl::TemplatedKind FunctionDecl::getTemplatedKind() const { @@ -2775,8 +2776,8 @@ FunctionDecl::TemplatedKind FunctionDecl::getTemplatedKind() const { FunctionDecl *FunctionDecl::getInstantiatedFromMemberFunction() const { if (MemberSpecializationInfo *Info = getMemberSpecializationInfo()) return cast(Info->getInstantiatedFrom()); - - return 0; + + return nullptr; } void @@ -2806,7 +2807,7 @@ bool FunctionDecl::isImplicitlyInstantiable() const { // It is possible to instantiate TSK_ExplicitSpecialization kind // if the FunctionDecl has a class scope specialization pattern. case TSK_ExplicitSpecialization: - return getClassScopeSpecializationPattern() != 0; + return getClassScopeSpecializationPattern() != nullptr; case TSK_ExplicitInstantiationDeclaration: // Handled below. @@ -2889,7 +2890,7 @@ FunctionTemplateDecl *FunctionDecl::getPrimaryTemplate() const { .dyn_cast()) { return Info->Template.getPointer(); } - return 0; + return nullptr; } FunctionDecl *FunctionDecl::getClassScopeSpecializationPattern() const { @@ -2903,7 +2904,7 @@ FunctionDecl::getTemplateSpecializationArgs() const { .dyn_cast()) { return Info->TemplateArguments; } - return 0; + return nullptr; } const ASTTemplateArgumentListInfo * @@ -2913,7 +2914,7 @@ FunctionDecl::getTemplateSpecializationArgsAsWritten() const { .dyn_cast()) { return Info->TemplateArgumentsAsWritten; } - return 0; + return nullptr; } void @@ -3148,8 +3149,9 @@ FieldDecl *FieldDecl::Create(const ASTContext &C, DeclContext *DC, } FieldDecl *FieldDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) FieldDecl(Field, 0, SourceLocation(), SourceLocation(), - 0, QualType(), 0, 0, false, ICIS_NoInit); + return new (C, ID) FieldDecl(Field, nullptr, SourceLocation(), + SourceLocation(), nullptr, QualType(), nullptr, + nullptr, false, ICIS_NoInit); } bool FieldDecl::isAnonymousStructOrUnion() const { @@ -3271,7 +3273,7 @@ TagDecl *TagDecl::getDefinition() const { if (R->isCompleteDefinition()) return R; - return 0; + return nullptr; } void TagDecl::setQualifierInfo(NestedNameSpecifierLoc QualifierLoc) { @@ -3286,7 +3288,7 @@ void TagDecl::setQualifierInfo(NestedNameSpecifierLoc QualifierLoc) { if (hasExtInfo()) { if (getExtInfo()->NumTemplParamLists == 0) { getASTContext().Deallocate(getExtInfo()); - NamedDeclOrQualifier = (TypedefNameDecl*) 0; + NamedDeclOrQualifier = (TypedefNameDecl*)nullptr; } else getExtInfo()->QualifierLoc = QualifierLoc; @@ -3326,8 +3328,9 @@ EnumDecl *EnumDecl::Create(ASTContext &C, DeclContext *DC, } EnumDecl *EnumDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - EnumDecl *Enum = new (C, ID) EnumDecl(0, SourceLocation(), SourceLocation(), - 0, 0, false, false, false); + EnumDecl *Enum = new (C, ID) EnumDecl(nullptr, SourceLocation(), + SourceLocation(), nullptr, nullptr, + false, false, false); Enum->MayHaveOutOfDateDef = C.getLangOpts().Modules; return Enum; } @@ -3373,7 +3376,7 @@ EnumDecl *EnumDecl::getInstantiatedFromMemberEnum() const { if (SpecializationInfo) return cast(SpecializationInfo->getInstantiatedFrom()); - return 0; + return nullptr; } void EnumDecl::setInstantiationOfMemberEnum(ASTContext &C, EnumDecl *ED, @@ -3410,8 +3413,9 @@ RecordDecl *RecordDecl::Create(const ASTContext &C, TagKind TK, DeclContext *DC, } RecordDecl *RecordDecl::CreateDeserialized(const ASTContext &C, unsigned ID) { - RecordDecl *R = new (C, ID) RecordDecl(Record, TTK_Struct, 0, SourceLocation(), - SourceLocation(), 0, 0); + RecordDecl *R = new (C, ID) RecordDecl(Record, TTK_Struct, nullptr, + SourceLocation(), SourceLocation(), + nullptr, nullptr); R->MayHaveOutOfDateDef = C.getLangOpts().Modules; return R; } @@ -3483,7 +3487,7 @@ void RecordDecl::LoadFieldsFromExternalStorage() const { //===----------------------------------------------------------------------===// void BlockDecl::setParams(ArrayRef NewParamInfo) { - assert(ParamInfo == 0 && "Already has param info!"); + assert(!ParamInfo && "Already has param info!"); // Zero params -> null pointer. if (!NewParamInfo.empty()) { @@ -3501,7 +3505,7 @@ void BlockDecl::setCaptures(ASTContext &Context, if (begin == end) { NumCaptures = 0; - Captures = 0; + Captures = nullptr; return; } @@ -3535,25 +3539,26 @@ SourceRange BlockDecl::getSourceRange() const { void TranslationUnitDecl::anchor() { } TranslationUnitDecl *TranslationUnitDecl::Create(ASTContext &C) { - return new (C, (DeclContext*)0) TranslationUnitDecl(C); + return new (C, (DeclContext *)nullptr) TranslationUnitDecl(C); } void LabelDecl::anchor() { } LabelDecl *LabelDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation IdentL, IdentifierInfo *II) { - return new (C, DC) LabelDecl(DC, IdentL, II, 0, IdentL); + return new (C, DC) LabelDecl(DC, IdentL, II, nullptr, IdentL); } LabelDecl *LabelDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation IdentL, IdentifierInfo *II, SourceLocation GnuLabelL) { assert(GnuLabelL != IdentL && "Use this only for GNU local labels"); - return new (C, DC) LabelDecl(DC, IdentL, II, 0, GnuLabelL); + return new (C, DC) LabelDecl(DC, IdentL, II, nullptr, GnuLabelL); } LabelDecl *LabelDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) LabelDecl(0, SourceLocation(), 0, 0, SourceLocation()); + return new (C, ID) LabelDecl(nullptr, SourceLocation(), nullptr, nullptr, + SourceLocation()); } void ValueDecl::anchor() { } @@ -3577,7 +3582,8 @@ ImplicitParamDecl *ImplicitParamDecl::Create(ASTContext &C, DeclContext *DC, ImplicitParamDecl *ImplicitParamDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) ImplicitParamDecl(0, SourceLocation(), 0, QualType()); + return new (C, ID) ImplicitParamDecl(nullptr, SourceLocation(), nullptr, + QualType()); } FunctionDecl *FunctionDecl::Create(ASTContext &C, DeclContext *DC, @@ -3596,8 +3602,8 @@ FunctionDecl *FunctionDecl::Create(ASTContext &C, DeclContext *DC, } FunctionDecl *FunctionDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) FunctionDecl(Function, 0, SourceLocation(), - DeclarationNameInfo(), QualType(), 0, + return new (C, ID) FunctionDecl(Function, nullptr, SourceLocation(), + DeclarationNameInfo(), QualType(), nullptr, SC_None, false, false); } @@ -3606,7 +3612,7 @@ BlockDecl *BlockDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L) { } BlockDecl *BlockDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) BlockDecl(0, SourceLocation()); + return new (C, ID) BlockDecl(nullptr, SourceLocation()); } CapturedDecl *CapturedDecl::Create(ASTContext &C, DeclContext *DC, @@ -3618,7 +3624,7 @@ CapturedDecl *CapturedDecl::Create(ASTContext &C, DeclContext *DC, CapturedDecl *CapturedDecl::CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumParams) { return new (C, ID, NumParams * sizeof(ImplicitParamDecl *)) - CapturedDecl(0, NumParams); + CapturedDecl(nullptr, NumParams); } EnumConstantDecl *EnumConstantDecl::Create(ASTContext &C, EnumDecl *CD, @@ -3630,8 +3636,8 @@ EnumConstantDecl *EnumConstantDecl::Create(ASTContext &C, EnumDecl *CD, EnumConstantDecl * EnumConstantDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) EnumConstantDecl(0, SourceLocation(), 0, QualType(), 0, - llvm::APSInt()); + return new (C, ID) EnumConstantDecl(nullptr, SourceLocation(), nullptr, + QualType(), nullptr, llvm::APSInt()); } void IndirectFieldDecl::anchor() { } @@ -3645,8 +3651,9 @@ IndirectFieldDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, IndirectFieldDecl *IndirectFieldDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) IndirectFieldDecl(0, SourceLocation(), DeclarationName(), - QualType(), 0, 0); + return new (C, ID) IndirectFieldDecl(nullptr, SourceLocation(), + DeclarationName(), QualType(), nullptr, + 0); } SourceRange EnumConstantDecl::getSourceRange() const { @@ -3667,7 +3674,8 @@ TypedefDecl *TypedefDecl::Create(ASTContext &C, DeclContext *DC, void TypedefNameDecl::anchor() { } TypedefDecl *TypedefDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) TypedefDecl(0, SourceLocation(), SourceLocation(), 0, 0); + return new (C, ID) TypedefDecl(nullptr, SourceLocation(), SourceLocation(), + nullptr, nullptr); } TypeAliasDecl *TypeAliasDecl::Create(ASTContext &C, DeclContext *DC, @@ -3678,7 +3686,8 @@ TypeAliasDecl *TypeAliasDecl::Create(ASTContext &C, DeclContext *DC, } TypeAliasDecl *TypeAliasDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) TypeAliasDecl(0, SourceLocation(), SourceLocation(), 0, 0); + return new (C, ID) TypeAliasDecl(nullptr, SourceLocation(), SourceLocation(), + nullptr, nullptr); } SourceRange TypedefDecl::getSourceRange() const { @@ -3708,7 +3717,8 @@ FileScopeAsmDecl *FileScopeAsmDecl::Create(ASTContext &C, DeclContext *DC, FileScopeAsmDecl *FileScopeAsmDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) FileScopeAsmDecl(0, 0, SourceLocation(), SourceLocation()); + return new (C, ID) FileScopeAsmDecl(nullptr, nullptr, SourceLocation(), + SourceLocation()); } void EmptyDecl::anchor() {} @@ -3718,7 +3728,7 @@ EmptyDecl *EmptyDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L) { } EmptyDecl *EmptyDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) EmptyDecl(0, SourceLocation()); + return new (C, ID) EmptyDecl(nullptr, SourceLocation()); } //===----------------------------------------------------------------------===// diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index f15639130a..1743b91454 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -164,7 +164,7 @@ FunctionDecl *Decl::getAsFunction() { return FD; if (const FunctionTemplateDecl *FTD = dyn_cast(this)) return FTD->getTemplatedDecl(); - return 0; + return nullptr; } bool Decl::isTemplateDecl() const { @@ -178,7 +178,7 @@ const DeclContext *Decl::getParentFunctionOrMethod() const { if (DC->isFunctionOrMethod()) return DC; - return 0; + return nullptr; } @@ -487,8 +487,8 @@ bool Decl::isWeakImported() const { return true; if (const auto *Availability = dyn_cast(A)) { - if (CheckAvailability(getASTContext(), Availability, 0) - == AR_NotYetIntroduced) + if (CheckAvailability(getASTContext(), Availability, + nullptr) == AR_NotYetIntroduced) return true; } } @@ -709,7 +709,7 @@ const FunctionType *Decl::getFunctionType(bool BlocksToo) const { else if (const TypedefNameDecl *D = dyn_cast(this)) Ty = D->getUnderlyingType(); else - return 0; + return nullptr; if (Ty->isFunctionPointerType()) Ty = Ty->getAs()->getPointeeType(); @@ -738,7 +738,7 @@ template static Decl *getNonClosureContext(T *D) { } else if (CapturedDecl *CD = dyn_cast(D)) { return getNonClosureContext(CD->getParent()); } else { - return 0; + return nullptr; } } @@ -943,8 +943,8 @@ std::pair DeclContext::BuildDeclChain(ArrayRef Decls, bool FieldsAlreadyLoaded) { // Build up a chain of declarations via the Decl::NextInContextAndBits field. - Decl *FirstNewDecl = 0; - Decl *PrevDecl = 0; + Decl *FirstNewDecl = nullptr; + Decl *PrevDecl = nullptr; for (unsigned I = 0, N = Decls.size(); I != N; ++I) { if (FieldsAlreadyLoaded && isa(Decls[I])) continue; @@ -1105,7 +1105,7 @@ void DeclContext::removeDecl(Decl *D) { // Remove D from the decl chain. This is O(n) but hopefully rare. if (D == FirstDecl) { if (D == LastDecl) - FirstDecl = LastDecl = 0; + FirstDecl = LastDecl = nullptr; else FirstDecl = D->NextInContextAndBits.getPointer(); } else { @@ -1120,7 +1120,7 @@ void DeclContext::removeDecl(Decl *D) { } // Mark that D is no longer in the decl chain. - D->NextInContextAndBits.setPointer(0); + D->NextInContextAndBits.setPointer(nullptr); // Remove D from the lookup table if necessary. if (isa(D)) { @@ -1303,7 +1303,7 @@ DeclContext::lookup(DeclarationName Name) { } } - return lookup_result(lookup_iterator(0), lookup_iterator(0)); + return lookup_result(lookup_iterator(nullptr), lookup_iterator(nullptr)); } StoredDeclsMap *Map = LookupPtr.getPointer(); @@ -1311,11 +1311,11 @@ DeclContext::lookup(DeclarationName Name) { Map = buildLookup(); if (!Map) - return lookup_result(lookup_iterator(0), lookup_iterator(0)); + return lookup_result(lookup_iterator(nullptr), lookup_iterator(nullptr)); StoredDeclsMap::iterator I = Map->find(Name); if (I == Map->end()) - return lookup_result(lookup_iterator(0), lookup_iterator(0)); + return lookup_result(lookup_iterator(nullptr), lookup_iterator(nullptr)); return I->second.getLookupResult(); } @@ -1352,12 +1352,12 @@ DeclContext::noload_lookup(DeclarationName Name) { } if (!Map) - return lookup_result(lookup_iterator(0), lookup_iterator(0)); + return lookup_result(lookup_iterator(nullptr), lookup_iterator(nullptr)); StoredDeclsMap::iterator I = Map->find(Name); - return I != Map->end() - ? I->second.getLookupResult() - : lookup_result(lookup_iterator(0), lookup_iterator(0)); + return I != Map->end() ? I->second.getLookupResult() + : lookup_result(lookup_iterator(nullptr), + lookup_iterator(nullptr)); } void DeclContext::localUncachedLookup(DeclarationName Name, @@ -1596,7 +1596,7 @@ DependentDiagnostic *DependentDiagnostic::Create(ASTContext &C, // Allocate the copy of the PartialDiagnostic via the ASTContext's // BumpPtrAllocator, rather than the ASTContext itself. - PartialDiagnostic::Storage *DiagStorage = 0; + PartialDiagnostic::Storage *DiagStorage = nullptr; if (PDiag.hasStorage()) DiagStorage = new (C) PartialDiagnostic::Storage; diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp index 8d183b2534..4cd35fc462 100644 --- a/lib/AST/DeclCXX.cpp +++ b/lib/AST/DeclCXX.cpp @@ -86,7 +86,7 @@ CXXRecordDecl::CXXRecordDecl(Kind K, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl) : RecordDecl(K, TK, DC, StartLoc, IdLoc, Id, PrevDecl), - DefinitionData(PrevDecl ? PrevDecl->DefinitionData : 0), + DefinitionData(PrevDecl ? PrevDecl->DefinitionData : nullptr), TemplateOrInstantiation() { } CXXRecordDecl *CXXRecordDecl::Create(const ASTContext &C, TagKind TK, @@ -109,7 +109,8 @@ CXXRecordDecl *CXXRecordDecl::CreateLambda(const ASTContext &C, DeclContext *DC, bool Dependent, bool IsGeneric, LambdaCaptureDefault CaptureDefault) { CXXRecordDecl *R = - new (C, DC) CXXRecordDecl(CXXRecord, TTK_Class, DC, Loc, Loc, 0, 0); + new (C, DC) CXXRecordDecl(CXXRecord, TTK_Class, DC, Loc, Loc, nullptr, + nullptr); R->IsBeingDefined = true; R->DefinitionData = new (C) struct LambdaDefinitionData(R, Info, Dependent, @@ -117,14 +118,15 @@ CXXRecordDecl *CXXRecordDecl::CreateLambda(const ASTContext &C, DeclContext *DC, CaptureDefault); R->MayHaveOutOfDateDef = false; R->setImplicit(true); - C.getTypeDeclType(R, /*PrevDecl=*/0); + C.getTypeDeclType(R, /*PrevDecl=*/nullptr); return R; } CXXRecordDecl * CXXRecordDecl::CreateDeserialized(const ASTContext &C, unsigned ID) { CXXRecordDecl *R = new (C, ID) CXXRecordDecl( - CXXRecord, TTK_Struct, 0, SourceLocation(), SourceLocation(), 0, 0); + CXXRecord, TTK_Struct, nullptr, SourceLocation(), SourceLocation(), + nullptr, nullptr); R->MayHaveOutOfDateDef = false; return R; } @@ -386,7 +388,7 @@ bool CXXRecordDecl::hasAnyDependentBases() const { if (!isDependentContext()) return false; - return !forallBases(SawBase, 0); + return !forallBases(SawBase, nullptr); } bool CXXRecordDecl::isTriviallyCopyable() const { @@ -972,7 +974,7 @@ bool CXXRecordDecl::isGenericLambda() const { } CXXMethodDecl* CXXRecordDecl::getLambdaCallOperator() const { - if (!isLambda()) return 0; + if (!isLambda()) return nullptr; DeclarationName Name = getASTContext().DeclarationNames.getCXXOperatorName(OO_Call); DeclContext::lookup_const_result Calls = lookup(Name); @@ -989,11 +991,11 @@ CXXMethodDecl* CXXRecordDecl::getLambdaCallOperator() const { } CXXMethodDecl* CXXRecordDecl::getLambdaStaticInvoker() const { - if (!isLambda()) return 0; + if (!isLambda()) return nullptr; DeclarationName Name = &getASTContext().Idents.get(getLambdaStaticInvokerName()); DeclContext::lookup_const_result Invoker = lookup(Name); - if (Invoker.empty()) return 0; + if (Invoker.empty()) return nullptr; assert(Invoker.size() == 1 && "More than one static invoker operator!"); NamedDecl *InvokerFun = Invoker.front(); if (FunctionTemplateDecl *InvokerTemplate = @@ -1007,7 +1009,7 @@ void CXXRecordDecl::getCaptureFields( llvm::DenseMap &Captures, FieldDecl *&ThisCapture) const { Captures.clear(); - ThisCapture = 0; + ThisCapture = nullptr; LambdaDefinitionData &Lambda = getLambdaData(); RecordDecl::field_iterator Field = field_begin(); @@ -1023,11 +1025,11 @@ void CXXRecordDecl::getCaptureFields( TemplateParameterList * CXXRecordDecl::getGenericLambdaTemplateParameterList() const { - if (!isLambda()) return 0; + if (!isLambda()) return nullptr; CXXMethodDecl *CallOp = getLambdaCallOperator(); if (FunctionTemplateDecl *Tmpl = CallOp->getDescribedFunctionTemplate()) return Tmpl->getTemplateParameters(); - return 0; + return nullptr; } static CanQualType GetConversionType(ASTContext &Context, NamedDecl *Conv) { @@ -1204,8 +1206,8 @@ void CXXRecordDecl::removeConversion(const NamedDecl *ConvDecl) { CXXRecordDecl *CXXRecordDecl::getInstantiatedFromMemberClass() const { if (MemberSpecializationInfo *MSInfo = getMemberSpecializationInfo()) return cast(MSInfo->getInstantiatedFrom()); - - return 0; + + return nullptr; } void @@ -1255,14 +1257,14 @@ CXXDestructorDecl *CXXRecordDecl::getDestructor() const { DeclContext::lookup_const_result R = lookup(Name); if (R.empty()) - return 0; + return nullptr; CXXDestructorDecl *Dtor = cast(R.front()); return Dtor; } void CXXRecordDecl::completeDefinition() { - completeDefinition(0); + completeDefinition(nullptr); } void CXXRecordDecl::completeDefinition(CXXFinalOverriderMap *FinalOverriders) { @@ -1374,7 +1376,7 @@ CXXMethodDecl::getCorrespondingMethodInClass(const CXXRecordDecl *RD, if (MayBeBase && recursivelyOverrides(this, MD)) return MD; } - return NULL; + return nullptr; } lookup_const_result Candidates = RD->lookup(getDeclName()); @@ -1398,7 +1400,7 @@ CXXMethodDecl::getCorrespondingMethodInClass(const CXXRecordDecl *RD, return T; } - return NULL; + return nullptr; } CXXMethodDecl * @@ -1413,8 +1415,8 @@ CXXMethodDecl::Create(ASTContext &C, CXXRecordDecl *RD, } CXXMethodDecl *CXXMethodDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) CXXMethodDecl(CXXMethod, 0, SourceLocation(), - DeclarationNameInfo(), QualType(), 0, + return new (C, ID) CXXMethodDecl(CXXMethod, nullptr, SourceLocation(), + DeclarationNameInfo(), QualType(), nullptr, SC_None, false, false, SourceLocation()); } @@ -1512,12 +1514,12 @@ void CXXMethodDecl::addOverriddenMethod(const CXXMethodDecl *MD) { } CXXMethodDecl::method_iterator CXXMethodDecl::begin_overridden_methods() const { - if (isa(this)) return 0; + if (isa(this)) return nullptr; return getASTContext().overridden_methods_begin(this); } CXXMethodDecl::method_iterator CXXMethodDecl::end_overridden_methods() const { - if (isa(this)) return 0; + if (isa(this)) return nullptr; return getASTContext().overridden_methods_end(this); } @@ -1647,7 +1649,7 @@ const Type *CXXCtorInitializer::getBaseClass() const { if (isBaseInitializer()) return Initializee.get()->getType().getTypePtr(); else - return 0; + return nullptr; } SourceLocation CXXCtorInitializer::getSourceLocation() const { @@ -1678,9 +1680,9 @@ void CXXConstructorDecl::anchor() { } CXXConstructorDecl * CXXConstructorDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) CXXConstructorDecl(0, SourceLocation(), + return new (C, ID) CXXConstructorDecl(nullptr, SourceLocation(), DeclarationNameInfo(), QualType(), - 0, false, false, false, false); + nullptr, false, false, false, false); } CXXConstructorDecl * @@ -1703,8 +1705,8 @@ CXXConstructorDecl *CXXConstructorDecl::getTargetConstructor() const { Expr *E = (*init_begin())->getInit()->IgnoreImplicit(); if (CXXConstructExpr *Construct = dyn_cast(E)) return Construct->getConstructor(); - - return 0; + + return nullptr; } bool CXXConstructorDecl::isDefaultConstructor() const { @@ -1740,8 +1742,8 @@ bool CXXConstructorDecl::isCopyOrMoveConstructor(unsigned &TypeQuals) const { // all other parameters have default arguments. if ((getNumParams() < 1) || (getNumParams() > 1 && !getParamDecl(1)->hasDefaultArg()) || - (getPrimaryTemplate() != 0) || - (getDescribedFunctionTemplate() != 0)) + (getPrimaryTemplate() != nullptr) || + (getDescribedFunctionTemplate() != nullptr)) return false; const ParmVarDecl *Param = getParamDecl(0); @@ -1789,8 +1791,8 @@ bool CXXConstructorDecl::isConvertingConstructor(bool AllowExplicit) const { bool CXXConstructorDecl::isSpecializationCopyingObject() const { if ((getNumParams() < 1) || (getNumParams() > 1 && !getParamDecl(1)->hasDefaultArg()) || - (getPrimaryTemplate() == 0) || - (getDescribedFunctionTemplate() != 0)) + (getPrimaryTemplate() == nullptr) || + (getDescribedFunctionTemplate() != nullptr)) return false; const ParmVarDecl *Param = getParamDecl(0); @@ -1811,7 +1813,7 @@ const CXXConstructorDecl *CXXConstructorDecl::getInheritedConstructor() const { // Hack: we store the inherited constructor in the overridden method table method_iterator It = getASTContext().overridden_methods_begin(this); if (It == getASTContext().overridden_methods_end(this)) - return 0; + return nullptr; return cast(*It); } @@ -1829,7 +1831,8 @@ void CXXDestructorDecl::anchor() { } CXXDestructorDecl * CXXDestructorDecl::CreateDeserialized(ASTContext &C, unsigned ID) { return new (C, ID) CXXDestructorDecl( - 0, SourceLocation(), DeclarationNameInfo(), QualType(), 0, false, false); + nullptr, SourceLocation(), DeclarationNameInfo(), QualType(), nullptr, + false, false); } CXXDestructorDecl * @@ -1849,9 +1852,9 @@ void CXXConversionDecl::anchor() { } CXXConversionDecl * CXXConversionDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) CXXConversionDecl(0, SourceLocation(), + return new (C, ID) CXXConversionDecl(nullptr, SourceLocation(), DeclarationNameInfo(), QualType(), - 0, false, false, false, + nullptr, false, false, false, SourceLocation()); } @@ -1888,8 +1891,8 @@ LinkageSpecDecl *LinkageSpecDecl::Create(ASTContext &C, LinkageSpecDecl *LinkageSpecDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) LinkageSpecDecl(0, SourceLocation(), SourceLocation(), - lang_c, false); + return new (C, ID) LinkageSpecDecl(nullptr, SourceLocation(), + SourceLocation(), lang_c, false); } void UsingDirectiveDecl::anchor() { } @@ -1909,9 +1912,10 @@ UsingDirectiveDecl *UsingDirectiveDecl::Create(ASTContext &C, DeclContext *DC, UsingDirectiveDecl *UsingDirectiveDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) UsingDirectiveDecl(0, SourceLocation(), SourceLocation(), + return new (C, ID) UsingDirectiveDecl(nullptr, SourceLocation(), + SourceLocation(), NestedNameSpecifierLoc(), - SourceLocation(), 0, 0); + SourceLocation(), nullptr, nullptr); } NamespaceDecl *UsingDirectiveDecl::getNominatedNamespace() { @@ -1926,8 +1930,8 @@ NamespaceDecl::NamespaceDecl(DeclContext *DC, bool Inline, SourceLocation IdLoc, IdentifierInfo *Id, NamespaceDecl *PrevDecl) : NamedDecl(Namespace, DC, IdLoc, Id), DeclContext(Namespace), - LocStart(StartLoc), RBraceLoc(), AnonOrFirstNamespaceAndInline(0, Inline) -{ + LocStart(StartLoc), RBraceLoc(), + AnonOrFirstNamespaceAndInline(nullptr, Inline) { setPreviousDecl(PrevDecl); if (PrevDecl) @@ -1942,8 +1946,8 @@ NamespaceDecl *NamespaceDecl::Create(ASTContext &C, DeclContext *DC, } NamespaceDecl *NamespaceDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) NamespaceDecl(0, false, SourceLocation(), SourceLocation(), - 0, 0); + return new (C, ID) NamespaceDecl(nullptr, false, SourceLocation(), + SourceLocation(), nullptr, nullptr); } NamespaceDecl *NamespaceDecl::getNextRedeclarationImpl() { @@ -1973,16 +1977,18 @@ NamespaceAliasDecl *NamespaceAliasDecl::Create(ASTContext &C, DeclContext *DC, NamespaceAliasDecl * NamespaceAliasDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) NamespaceAliasDecl(0, SourceLocation(), SourceLocation(), - 0, NestedNameSpecifierLoc(), - SourceLocation(), 0); + return new (C, ID) NamespaceAliasDecl(nullptr, SourceLocation(), + SourceLocation(), nullptr, + NestedNameSpecifierLoc(), + SourceLocation(), nullptr); } void UsingShadowDecl::anchor() { } UsingShadowDecl * UsingShadowDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) UsingShadowDecl(0, SourceLocation(), 0, 0); + return new (C, ID) UsingShadowDecl(nullptr, SourceLocation(), nullptr, + nullptr); } UsingDecl *UsingShadowDecl::getUsingDecl() const { @@ -2034,8 +2040,9 @@ UsingDecl *UsingDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation UL, } UsingDecl *UsingDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) UsingDecl(0, SourceLocation(), NestedNameSpecifierLoc(), - DeclarationNameInfo(), false); + return new (C, ID) UsingDecl(nullptr, SourceLocation(), + NestedNameSpecifierLoc(), DeclarationNameInfo(), + false); } SourceRange UsingDecl::getSourceRange() const { @@ -2057,9 +2064,10 @@ UnresolvedUsingValueDecl::Create(ASTContext &C, DeclContext *DC, UnresolvedUsingValueDecl * UnresolvedUsingValueDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) UnresolvedUsingValueDecl(0, QualType(), SourceLocation(), + return new (C, ID) UnresolvedUsingValueDecl(nullptr, QualType(), + SourceLocation(), NestedNameSpecifierLoc(), - DeclarationNameInfo()); + DeclarationNameInfo()); } SourceRange UnresolvedUsingValueDecl::getSourceRange() const { @@ -2085,8 +2093,8 @@ UnresolvedUsingTypenameDecl::Create(ASTContext &C, DeclContext *DC, UnresolvedUsingTypenameDecl * UnresolvedUsingTypenameDecl::CreateDeserialized(ASTContext &C, unsigned ID) { return new (C, ID) UnresolvedUsingTypenameDecl( - 0, SourceLocation(), SourceLocation(), NestedNameSpecifierLoc(), - SourceLocation(), 0); + nullptr, SourceLocation(), SourceLocation(), NestedNameSpecifierLoc(), + SourceLocation(), nullptr); } void StaticAssertDecl::anchor() { } @@ -2103,8 +2111,8 @@ StaticAssertDecl *StaticAssertDecl::Create(ASTContext &C, DeclContext *DC, StaticAssertDecl *StaticAssertDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) StaticAssertDecl(0, SourceLocation(), 0, 0, - SourceLocation(), false); + return new (C, ID) StaticAssertDecl(nullptr, SourceLocation(), nullptr, + nullptr, SourceLocation(), false); } MSPropertyDecl *MSPropertyDecl::Create(ASTContext &C, DeclContext *DC, @@ -2118,8 +2126,9 @@ MSPropertyDecl *MSPropertyDecl::Create(ASTContext &C, DeclContext *DC, MSPropertyDecl *MSPropertyDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) MSPropertyDecl(0, SourceLocation(), DeclarationName(), - QualType(), 0, SourceLocation(), 0, 0); + return new (C, ID) MSPropertyDecl(nullptr, SourceLocation(), + DeclarationName(), QualType(), nullptr, + SourceLocation(), nullptr, nullptr); } static const char *getAccessName(AccessSpecifier AS) { diff --git a/lib/AST/DeclFriend.cpp b/lib/AST/DeclFriend.cpp index 02374c78b8..a996cab093 100644 --- a/lib/AST/DeclFriend.cpp +++ b/lib/AST/DeclFriend.cpp @@ -62,5 +62,5 @@ FriendDecl *FriendDecl::CreateDeserialized(ASTContext &C, unsigned ID, FriendDecl *CXXRecordDecl::getFirstFriend() const { ExternalASTSource *Source = getParentASTContext().getExternalSource(); Decl *First = data().FirstFriend.get(Source); - return First ? cast(First) : 0; + return First ? cast(First) : nullptr; } diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp index 4bea9f948b..42462a1b14 100644 --- a/lib/AST/DeclObjC.cpp +++ b/lib/AST/DeclObjC.cpp @@ -25,7 +25,7 @@ using namespace clang; //===----------------------------------------------------------------------===// void ObjCListBase::set(void *const* InList, unsigned Elts, ASTContext &Ctx) { - List = 0; + List = nullptr; if (Elts == 0) return; // Setting to an empty list is a noop. @@ -60,7 +60,7 @@ ObjCContainerDecl::getIvarDecl(IdentifierInfo *Id) const { if (ObjCIvarDecl *ivar = dyn_cast(*Ivar)) return ivar; } - return 0; + return nullptr; } // Get the local instance/class method declared in this interface. @@ -72,7 +72,7 @@ ObjCContainerDecl::getMethod(Selector Sel, bool isInstance, if (const ObjCProtocolDecl *Proto = dyn_cast(this)) { if (const ObjCProtocolDecl *Def = Proto->getDefinition()) if (Def->isHidden() && !AllowHidden) - return 0; + return nullptr; } // Since instance & class methods can have the same name, the loop below @@ -90,7 +90,7 @@ ObjCContainerDecl::getMethod(Selector Sel, bool isInstance, if (MD && MD->isInstanceMethod() == isInstance) return MD; } - return 0; + return nullptr; } /// HasUserDeclaredSetterMethod - This routine returns 'true' if a user declared setter @@ -157,7 +157,7 @@ ObjCPropertyDecl::findPropertyDecl(const DeclContext *DC, if (const ObjCProtocolDecl *Proto = dyn_cast(DC)) { if (const ObjCProtocolDecl *Def = Proto->getDefinition()) if (Def->isHidden()) - return 0; + return nullptr; } DeclContext::lookup_const_result R = DC->lookup(propertyID); @@ -166,7 +166,7 @@ ObjCPropertyDecl::findPropertyDecl(const DeclContext *DC, if (ObjCPropertyDecl *PD = dyn_cast(*I)) return PD; - return 0; + return nullptr; } IdentifierInfo * @@ -187,7 +187,7 @@ ObjCContainerDecl::FindPropertyDeclaration(IdentifierInfo *PropertyId) const { if (const ObjCProtocolDecl *Proto = dyn_cast(this)) { if (const ObjCProtocolDecl *Def = Proto->getDefinition()) if (Def->isHidden()) - return 0; + return nullptr; } if (ObjCPropertyDecl *PD = @@ -233,7 +233,7 @@ ObjCContainerDecl::FindPropertyDeclaration(IdentifierInfo *PropertyId) const { break; } } - return 0; + return nullptr; } void ObjCInterfaceDecl::anchor() { } @@ -247,8 +247,8 @@ ObjCInterfaceDecl::FindPropertyVisibleInPrimaryClass( IdentifierInfo *PropertyId) const { // FIXME: Should make sure no callers ever do this. if (!hasDefinition()) - return 0; - + return nullptr; + if (data().ExternallyCompleted) LoadExternalDefinition(); @@ -261,7 +261,7 @@ ObjCInterfaceDecl::FindPropertyVisibleInPrimaryClass( if (ObjCPropertyDecl *P = I->FindPropertyDeclaration(PropertyId)) return P; - return 0; + return nullptr; } void ObjCInterfaceDecl::collectPropertiesToImplement(PropertyMap &PM, @@ -294,7 +294,7 @@ const ObjCInterfaceDecl *ObjCInterfaceDecl::isObjCRequiresPropertyDefs() const { return Class; Class = Class->getSuperClass(); } - return 0; + return nullptr; } void ObjCInterfaceDecl::mergeClassExtensionProtocolList( @@ -350,7 +350,7 @@ ObjCInterfaceDecl::findInterfaceWithDesignatedInitializers() const { break; IFace = IFace->getSuperClass(); } - return 0; + return nullptr; } static bool isIntroducingInitializers(const ObjCInterfaceDecl *D) { @@ -483,13 +483,13 @@ ObjCIvarDecl *ObjCInterfaceDecl::lookupInstanceVariable(IdentifierInfo *ID, ObjCInterfaceDecl *&clsDeclared) { // FIXME: Should make sure no callers ever do this. if (!hasDefinition()) - return 0; + return nullptr; if (data().ExternallyCompleted) LoadExternalDefinition(); ObjCInterfaceDecl* ClassDecl = this; - while (ClassDecl != NULL) { + while (ClassDecl != nullptr) { if (ObjCIvarDecl *I = ClassDecl->getIvarDecl(ID)) { clsDeclared = ClassDecl; return I; @@ -504,7 +504,7 @@ ObjCIvarDecl *ObjCInterfaceDecl::lookupInstanceVariable(IdentifierInfo *ID, ClassDecl = ClassDecl->getSuperClass(); } - return NULL; + return nullptr; } /// lookupInheritedClass - This method returns ObjCInterfaceDecl * of the super @@ -514,18 +514,18 @@ ObjCInterfaceDecl *ObjCInterfaceDecl::lookupInheritedClass( const IdentifierInfo*ICName) { // FIXME: Should make sure no callers ever do this. if (!hasDefinition()) - return 0; + return nullptr; if (data().ExternallyCompleted) LoadExternalDefinition(); ObjCInterfaceDecl* ClassDecl = this; - while (ClassDecl != NULL) { + while (ClassDecl != nullptr) { if (ClassDecl->getIdentifier() == ICName) return ClassDecl; ClassDecl = ClassDecl->getSuperClass(); } - return NULL; + return nullptr; } ObjCProtocolDecl * @@ -534,7 +534,7 @@ ObjCInterfaceDecl::lookupNestedProtocol(IdentifierInfo *Name) { if (P->lookupProtocolNamed(Name)) return P; ObjCInterfaceDecl *SuperClass = getSuperClass(); - return SuperClass ? SuperClass->lookupNestedProtocol(Name) : NULL; + return SuperClass ? SuperClass->lookupNestedProtocol(Name) : nullptr; } /// lookupMethod - This method returns an instance/class method by looking in @@ -549,10 +549,10 @@ ObjCMethodDecl *ObjCInterfaceDecl::lookupMethod(Selector Sel, { // FIXME: Should make sure no callers ever do this. if (!hasDefinition()) - return 0; + return nullptr; const ObjCInterfaceDecl* ClassDecl = this; - ObjCMethodDecl *MethodDecl = 0; + ObjCMethodDecl *MethodDecl = nullptr; if (data().ExternallyCompleted) LoadExternalDefinition(); @@ -585,12 +585,12 @@ ObjCMethodDecl *ObjCInterfaceDecl::lookupMethod(Selector Sel, } if (!followSuper) - return NULL; + return nullptr; // Get the super class (if any). ClassDecl = ClassDecl->getSuperClass(); } - return NULL; + return nullptr; } // Will search "local" class/category implementations for a method decl. @@ -601,12 +601,12 @@ ObjCMethodDecl *ObjCInterfaceDecl::lookupPrivateMethod( bool Instance) const { // FIXME: Should make sure no callers ever do this. if (!hasDefinition()) - return 0; + return nullptr; if (data().ExternallyCompleted) LoadExternalDefinition(); - ObjCMethodDecl *Method = 0; + ObjCMethodDecl *Method = nullptr; if (ObjCImplementationDecl *ImpDecl = getImplementation()) Method = Instance ? ImpDecl->getInstanceMethod(Sel) : ImpDecl->getClassMethod(Sel); @@ -650,7 +650,7 @@ ObjCMethodDecl *ObjCMethodDecl::Create( ObjCMethodDecl *ObjCMethodDecl::CreateDeserialized(ASTContext &C, unsigned ID) { return new (C, ID) ObjCMethodDecl(SourceLocation(), SourceLocation(), - Selector(), QualType(), 0, 0); + Selector(), QualType(), nullptr, nullptr); } bool ObjCMethodDecl::isThisDeclarationADesignatedInitializer() const { @@ -684,7 +684,7 @@ void ObjCMethodDecl::setAsRedeclaration(const ObjCMethodDecl *PrevMethod) { void ObjCMethodDecl::setParamsAndSelLocs(ASTContext &C, ArrayRef Params, ArrayRef SelLocs) { - ParamsAndSelLocs = 0; + ParamsAndSelLocs = nullptr; NumParams = Params.size(); if (Params.empty() && SelLocs.empty()) return; @@ -723,7 +723,7 @@ void ObjCMethodDecl::setMethodParams(ASTContext &C, /// Otherwise it will return itself. ObjCMethodDecl *ObjCMethodDecl::getNextRedeclarationImpl() { ASTContext &Ctx = getASTContext(); - ObjCMethodDecl *Redecl = 0; + ObjCMethodDecl *Redecl = nullptr; if (HasRedeclaration) Redecl = const_cast(Ctx.getObjCMethodRedeclaration(this)); if (Redecl) @@ -948,7 +948,7 @@ ObjCInterfaceDecl *ObjCMethodDecl::getClassInterface() { if (ObjCImplDecl *IMD = dyn_cast(getDeclContext())) return IMD->getClassInterface(); if (isa(getDeclContext())) - return 0; + return nullptr; llvm_unreachable("unknown method context"); } @@ -1083,11 +1083,11 @@ ObjCMethodDecl::findPropertyDecl(bool CheckOverrides) const { Selector Sel = getSelector(); unsigned NumArgs = Sel.getNumArgs(); if (NumArgs > 1) - return 0; + return nullptr; if (!isInstanceMethod() || getMethodFamily() != OMF_None) - return 0; - + return nullptr; + if (isPropertyAccessor()) { const ObjCContainerDecl *Container = cast(getParent()); // If container is class extension, find its primary class. @@ -1108,7 +1108,7 @@ ObjCMethodDecl::findPropertyDecl(bool CheckOverrides) const { } if (!CheckOverrides) - return 0; + return nullptr; typedef SmallVector OverridesTy; OverridesTy Overrides; @@ -1119,8 +1119,7 @@ ObjCMethodDecl::findPropertyDecl(bool CheckOverrides) const { return Prop; } - return 0; - + return nullptr; } //===----------------------------------------------------------------------===// @@ -1143,9 +1142,11 @@ ObjCInterfaceDecl *ObjCInterfaceDecl::Create(const ASTContext &C, ObjCInterfaceDecl *ObjCInterfaceDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - ObjCInterfaceDecl *Result = new (C, ID) ObjCInterfaceDecl(0, SourceLocation(), - 0, SourceLocation(), - 0, false); + ObjCInterfaceDecl *Result = new (C, ID) ObjCInterfaceDecl(nullptr, + SourceLocation(), + nullptr, + SourceLocation(), + nullptr, false); Result->Data.setInt(!C.getLangOpts().Modules); return Result; } @@ -1155,7 +1156,7 @@ ObjCInterfaceDecl(DeclContext *DC, SourceLocation atLoc, IdentifierInfo *Id, SourceLocation CLoc, ObjCInterfaceDecl *PrevDecl, bool isInternal) : ObjCContainerDecl(ObjCInterface, DC, Id, CLoc, atLoc), - TypeForDecl(0), Data() + TypeForDecl(nullptr), Data() { setPreviousDecl(PrevDecl); @@ -1208,7 +1209,7 @@ ObjCImplementationDecl *ObjCInterfaceDecl::getImplementation() const { } // FIXME: Should make sure no callers ever do this. - return 0; + return nullptr; } void ObjCInterfaceDecl::setImplementation(ObjCImplementationDecl *ImplD) { @@ -1241,9 +1242,9 @@ namespace { ObjCIvarDecl *ObjCInterfaceDecl::all_declared_ivar_begin() { // FIXME: Should make sure no callers ever do this. if (!hasDefinition()) - return 0; - - ObjCIvarDecl *curIvar = 0; + return nullptr; + + ObjCIvarDecl *curIvar = nullptr; if (!data().IvarList) { if (!ivar_empty()) { ObjCInterfaceDecl::ivar_iterator I = ivar_begin(), E = ivar_end(); @@ -1313,7 +1314,7 @@ ObjCCategoryDecl * ObjCInterfaceDecl::FindCategoryDeclaration(IdentifierInfo *CategoryId) const { // FIXME: Should make sure no callers ever do this. if (!hasDefinition()) - return 0; + return nullptr; if (data().ExternallyCompleted) LoadExternalDefinition(); @@ -1321,8 +1322,8 @@ ObjCInterfaceDecl::FindCategoryDeclaration(IdentifierInfo *CategoryId) const { for (auto *Cat : visible_categories()) if (Cat->getIdentifier() == CategoryId) return Cat; - - return 0; + + return nullptr; } ObjCMethodDecl * @@ -1333,7 +1334,7 @@ ObjCInterfaceDecl::getCategoryInstanceMethod(Selector Sel) const { return MD; } - return 0; + return nullptr; } ObjCMethodDecl *ObjCInterfaceDecl::getCategoryClassMethod(Selector Sel) const { @@ -1342,8 +1343,8 @@ ObjCMethodDecl *ObjCInterfaceDecl::getCategoryClassMethod(Selector Sel) const { if (ObjCMethodDecl *MD = Impl->getClassMethod(Sel)) return MD; } - - return 0; + + return nullptr; } /// ClassImplementsProtocol - Checks that 'lProto' protocol @@ -1423,7 +1424,7 @@ ObjCIvarDecl *ObjCIvarDecl::Create(ASTContext &C, ObjCContainerDecl *DC, else ID = cast(DC)->getClassInterface(); } - ID->setIvarList(0); + ID->setIvarList(nullptr); } return new (C, DC) ObjCIvarDecl(DC, StartLoc, IdLoc, Id, T, TInfo, ac, BW, @@ -1431,8 +1432,9 @@ ObjCIvarDecl *ObjCIvarDecl::Create(ASTContext &C, ObjCContainerDecl *DC, } ObjCIvarDecl *ObjCIvarDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) ObjCIvarDecl(0, SourceLocation(), SourceLocation(), 0, - QualType(), 0, ObjCIvarDecl::None, 0, false); + return new (C, ID) ObjCIvarDecl(nullptr, SourceLocation(), SourceLocation(), + nullptr, QualType(), nullptr, + ObjCIvarDecl::None, nullptr, false); } const ObjCInterfaceDecl *ObjCIvarDecl::getContainingInterface() const { @@ -1474,8 +1476,9 @@ ObjCAtDefsFieldDecl ObjCAtDefsFieldDecl *ObjCAtDefsFieldDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) ObjCAtDefsFieldDecl(0, SourceLocation(), SourceLocation(), - 0, QualType(), 0); + return new (C, ID) ObjCAtDefsFieldDecl(nullptr, SourceLocation(), + SourceLocation(), nullptr, QualType(), + nullptr); } //===----------------------------------------------------------------------===// @@ -1509,7 +1512,8 @@ ObjCProtocolDecl *ObjCProtocolDecl::Create(ASTContext &C, DeclContext *DC, ObjCProtocolDecl *ObjCProtocolDecl::CreateDeserialized(ASTContext &C, unsigned ID) { ObjCProtocolDecl *Result = - new (C, ID) ObjCProtocolDecl(0, 0, SourceLocation(), SourceLocation(), 0); + new (C, ID) ObjCProtocolDecl(nullptr, nullptr, SourceLocation(), + SourceLocation(), nullptr); Result->Data.setInt(!C.getLangOpts().Modules); return Result; } @@ -1524,20 +1528,20 @@ ObjCProtocolDecl *ObjCProtocolDecl::lookupProtocolNamed(IdentifierInfo *Name) { if ((PDecl = I->lookupProtocolNamed(Name))) return PDecl; - return NULL; + return nullptr; } // lookupMethod - Lookup a instance/class method in the protocol and protocols // it inherited. ObjCMethodDecl *ObjCProtocolDecl::lookupMethod(Selector Sel, bool isInstance) const { - ObjCMethodDecl *MethodDecl = NULL; + ObjCMethodDecl *MethodDecl = nullptr; // If there is no definition or the definition is hidden, we don't find // anything. const ObjCProtocolDecl *Def = getDefinition(); if (!Def || Def->isHidden()) - return NULL; + return nullptr; if ((MethodDecl = getMethod(Sel, isInstance))) return MethodDecl; @@ -1545,7 +1549,7 @@ ObjCMethodDecl *ObjCProtocolDecl::lookupMethod(Selector Sel, for (const auto *I : protocols()) if ((MethodDecl = I->lookupMethod(Sel, isInstance))) return MethodDecl; - return NULL; + return nullptr; } void ObjCProtocolDecl::allocateDefinitionData() { @@ -1631,8 +1635,9 @@ ObjCCategoryDecl *ObjCCategoryDecl::Create(ASTContext &C, DeclContext *DC, ObjCCategoryDecl *ObjCCategoryDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) ObjCCategoryDecl(0, SourceLocation(), SourceLocation(), - SourceLocation(), 0, 0); + return new (C, ID) ObjCCategoryDecl(nullptr, SourceLocation(), + SourceLocation(), SourceLocation(), + nullptr, nullptr); } ObjCCategoryImplDecl *ObjCCategoryDecl::getImplementation() const { @@ -1666,15 +1671,16 @@ ObjCCategoryImplDecl::Create(ASTContext &C, DeclContext *DC, ObjCCategoryImplDecl *ObjCCategoryImplDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) ObjCCategoryImplDecl(0, 0, 0, SourceLocation(), - SourceLocation(), SourceLocation()); + return new (C, ID) ObjCCategoryImplDecl(nullptr, nullptr, nullptr, + SourceLocation(), SourceLocation(), + SourceLocation()); } ObjCCategoryDecl *ObjCCategoryImplDecl::getCategoryDecl() const { // The class interface might be NULL if we are working with invalid code. if (const ObjCInterfaceDecl *ID = getClassInterface()) return ID->FindCategoryDeclaration(getIdentifier()); - return 0; + return nullptr; } @@ -1713,7 +1719,7 @@ FindPropertyImplIvarDecl(IdentifierInfo *ivarId) const { if (PID->getPropertyIvarDecl() && PID->getPropertyIvarDecl()->getIdentifier() == ivarId) return PID; - return 0; + return nullptr; } /// FindPropertyImplDecl - This method looks up a previous ObjCPropertyImplDecl @@ -1725,7 +1731,7 @@ FindPropertyImplDecl(IdentifierInfo *Id) const { for (auto *PID : property_impls()) if (PID->getPropertyDecl()->getIdentifier() == Id) return PID; - return 0; + return nullptr; } raw_ostream &clang::operator<<(raw_ostream &OS, @@ -1758,8 +1764,8 @@ ObjCImplementationDecl::Create(ASTContext &C, DeclContext *DC, ObjCImplementationDecl * ObjCImplementationDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) ObjCImplementationDecl(0, 0, 0, SourceLocation(), - SourceLocation()); + return new (C, ID) ObjCImplementationDecl(nullptr, nullptr, nullptr, + SourceLocation(), SourceLocation()); } void ObjCImplementationDecl::setIvarInitializers(ASTContext &C, @@ -1797,7 +1803,8 @@ ObjCCompatibleAliasDecl::Create(ASTContext &C, DeclContext *DC, ObjCCompatibleAliasDecl * ObjCCompatibleAliasDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) ObjCCompatibleAliasDecl(0, SourceLocation(), 0, 0); + return new (C, ID) ObjCCompatibleAliasDecl(nullptr, SourceLocation(), + nullptr, nullptr); } //===----------------------------------------------------------------------===// @@ -1818,8 +1825,9 @@ ObjCPropertyDecl *ObjCPropertyDecl::Create(ASTContext &C, DeclContext *DC, ObjCPropertyDecl *ObjCPropertyDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) ObjCPropertyDecl(0, SourceLocation(), 0, SourceLocation(), - SourceLocation(), 0); + return new (C, ID) ObjCPropertyDecl(nullptr, SourceLocation(), nullptr, + SourceLocation(), SourceLocation(), + nullptr); } //===----------------------------------------------------------------------===// @@ -1840,8 +1848,9 @@ ObjCPropertyImplDecl *ObjCPropertyImplDecl::Create(ASTContext &C, ObjCPropertyImplDecl *ObjCPropertyImplDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) ObjCPropertyImplDecl(0, SourceLocation(), SourceLocation(), - 0, Dynamic, 0, SourceLocation()); + return new (C, ID) ObjCPropertyImplDecl(nullptr, SourceLocation(), + SourceLocation(), nullptr, Dynamic, + nullptr, SourceLocation()); } SourceRange ObjCPropertyImplDecl::getSourceRange() const { diff --git a/lib/AST/DeclOpenMP.cpp b/lib/AST/DeclOpenMP.cpp index 37d4ae2571..5f8b42b3f9 100644 --- a/lib/AST/DeclOpenMP.cpp +++ b/lib/AST/DeclOpenMP.cpp @@ -40,7 +40,7 @@ OMPThreadPrivateDecl *OMPThreadPrivateDecl::CreateDeserialized(ASTContext &C, unsigned ID, unsigned N) { OMPThreadPrivateDecl *D = new (C, ID, N * sizeof(Expr *)) - OMPThreadPrivateDecl(OMPThreadPrivate, 0, SourceLocation()); + OMPThreadPrivateDecl(OMPThreadPrivate, nullptr, SourceLocation()); D->NumVars = N; return D; } diff --git a/lib/AST/DeclPrinter.cpp b/lib/AST/DeclPrinter.cpp index 9b68cd2649..558654d887 100644 --- a/lib/AST/DeclPrinter.cpp +++ b/lib/AST/DeclPrinter.cpp @@ -85,7 +85,7 @@ namespace { void VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D); void PrintTemplateParameters(const TemplateParameterList *Params, - const TemplateArgumentList *Args = 0); + const TemplateArgumentList *Args = nullptr); void prettyPrintAttributes(Decl *D); }; } @@ -379,7 +379,7 @@ void DeclPrinter::VisitEnumConstantDecl(EnumConstantDecl *D) { Out << *D; if (Expr *Init = D->getInitExpr()) { Out << " = "; - Init->printPretty(Out, 0, Policy, Indentation); + Init->printPretty(Out, nullptr, Policy, Indentation); } } @@ -416,7 +416,7 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) { } if (const FunctionType *AFT = Ty->getAs()) { - const FunctionProtoType *FT = 0; + const FunctionProtoType *FT = nullptr; if (D->hasWrittenPrototype()) FT = dyn_cast(AFT); @@ -480,7 +480,7 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) { if (FT->getExceptionSpecType() == EST_ComputedNoexcept) { Proto += "("; llvm::raw_string_ostream EOut(Proto); - FT->getNoexceptExpr()->printPretty(EOut, 0, SubPolicy, + FT->getNoexceptExpr()->printPretty(EOut, nullptr, SubPolicy, Indentation); EOut.flush(); Proto += EOut.str(); @@ -518,9 +518,9 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) { Init = Tmp->getSubExpr(); Init = Init->IgnoreParens(); - - Expr *SimpleInit = 0; - Expr **Args = 0; + + Expr *SimpleInit = nullptr; + Expr **Args = nullptr; unsigned NumArgs = 0; if (ParenListExpr *ParenList = dyn_cast(Init)) { Args = ParenList->getExprs(); @@ -533,7 +533,7 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) { SimpleInit = Init; if (SimpleInit) - SimpleInit->printPretty(Out, 0, Policy, Indentation); + SimpleInit->printPretty(Out, nullptr, Policy, Indentation); else { for (unsigned I = 0; I != NumArgs; ++I) { if (isa(Args[I])) @@ -541,7 +541,7 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) { if (I) Out << ", "; - Args[I]->printPretty(Out, 0, Policy, Indentation); + Args[I]->printPretty(Out, nullptr, Policy, Indentation); } } } @@ -586,7 +586,7 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) { } else Out << ' '; - D->getBody()->printPretty(Out, 0, SubPolicy, Indentation); + D->getBody()->printPretty(Out, nullptr, SubPolicy, Indentation); Out << '\n'; } } @@ -627,7 +627,7 @@ void DeclPrinter::VisitFieldDecl(FieldDecl *D) { if (D->isBitField()) { Out << " : "; - D->getBitWidth()->printPretty(Out, 0, Policy, Indentation); + D->getBitWidth()->printPretty(Out, nullptr, Policy, Indentation); } Expr *Init = D->getInClassInitializer(); @@ -636,7 +636,7 @@ void DeclPrinter::VisitFieldDecl(FieldDecl *D) { Out << " "; else Out << " = "; - Init->printPretty(Out, 0, Policy, Indentation); + Init->printPretty(Out, nullptr, Policy, Indentation); } prettyPrintAttributes(D); } @@ -691,7 +691,7 @@ void DeclPrinter::VisitVarDecl(VarDecl *D) { else if (D->getInitStyle() == VarDecl::CInit) { Out << " = "; } - Init->printPretty(Out, 0, Policy, Indentation); + Init->printPretty(Out, nullptr, Policy, Indentation); if ((D->getInitStyle() == VarDecl::CallInit) && !isa(Init)) Out << ")"; } @@ -705,7 +705,7 @@ void DeclPrinter::VisitParmVarDecl(ParmVarDecl *D) { void DeclPrinter::VisitFileScopeAsmDecl(FileScopeAsmDecl *D) { Out << "__asm ("; - D->getAsmString()->printPretty(Out, 0, Policy, Indentation); + D->getAsmString()->printPretty(Out, nullptr, Policy, Indentation); Out << ")"; } @@ -716,9 +716,9 @@ void DeclPrinter::VisitImportDecl(ImportDecl *D) { void DeclPrinter::VisitStaticAssertDecl(StaticAssertDecl *D) { Out << "static_assert("; - D->getAssertExpr()->printPretty(Out, 0, Policy, Indentation); + D->getAssertExpr()->printPretty(Out, nullptr, Policy, Indentation); Out << ", "; - D->getMessage()->printPretty(Out, 0, Policy, Indentation); + D->getMessage()->printPretty(Out, nullptr, Policy, Indentation); Out << ")"; } @@ -856,7 +856,8 @@ void DeclPrinter::PrintTemplateParameters(const TemplateParameterList *Params, Args->get(i).print(Policy, Out); } else if (NTTP->hasDefaultArgument()) { Out << " = "; - NTTP->getDefaultArgument()->printPretty(Out, 0, Policy, Indentation); + NTTP->getDefaultArgument()->printPretty(Out, nullptr, Policy, + Indentation); } } else if (const TemplateTemplateParmDecl *TTPD = dyn_cast(Param)) { @@ -940,7 +941,7 @@ void DeclPrinter::VisitObjCMethodDecl(ObjCMethodDecl *OMD) { if (OMD->getBody() && !Policy.TerseOutput) { Out << ' '; - OMD->getBody()->printPretty(Out, 0, Policy); + OMD->getBody()->printPretty(Out, nullptr, Policy); Out << '\n'; } else if (Policy.PolishForDeclaration) diff --git a/lib/AST/DeclTemplate.cpp b/lib/AST/DeclTemplate.cpp index 408e8548b1..4a934747e9 100644 --- a/lib/AST/DeclTemplate.cpp +++ b/lib/AST/DeclTemplate.cpp @@ -170,7 +170,7 @@ RedeclarableTemplateDecl::findSpecializationImpl( llvm::FoldingSetNodeID ID; EntryType::Profile(ID,Args,NumArgs, getASTContext()); EntryType *Entry = Specs.FindNodeOrInsertPos(ID, InsertPos); - return Entry ? SETraits::getMostRecentDecl(Entry) : 0; + return Entry ? SETraits::getMostRecentDecl(Entry) : nullptr; } /// \brief Generate the injected template arguments for the given template @@ -234,8 +234,8 @@ FunctionTemplateDecl *FunctionTemplateDecl::Create(ASTContext &C, FunctionTemplateDecl *FunctionTemplateDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) FunctionTemplateDecl(0, SourceLocation(), DeclarationName(), - 0, 0); + return new (C, ID) FunctionTemplateDecl(nullptr, SourceLocation(), + DeclarationName(), nullptr, nullptr); } RedeclarableTemplateDecl::CommonBase * @@ -250,7 +250,7 @@ void FunctionTemplateDecl::LoadLazySpecializations() const { if (CommonPtr->LazySpecializations) { ASTContext &Context = getASTContext(); uint32_t *Specs = CommonPtr->LazySpecializations; - CommonPtr->LazySpecializations = 0; + CommonPtr->LazySpecializations = nullptr; for (uint32_t I = 0, N = *Specs++; I != N; ++I) (void)Context.getExternalSource()->GetExternalDecl(Specs[I]); } @@ -323,7 +323,7 @@ void ClassTemplateDecl::LoadLazySpecializations() const { if (CommonPtr->LazySpecializations) { ASTContext &Context = getASTContext(); uint32_t *Specs = CommonPtr->LazySpecializations; - CommonPtr->LazySpecializations = 0; + CommonPtr->LazySpecializations = nullptr; for (uint32_t I = 0, N = *Specs++; I != N; ++I) (void)Context.getExternalSource()->GetExternalDecl(Specs[I]); } @@ -417,7 +417,7 @@ ClassTemplateDecl::findPartialSpecialization(QualType T) { return P->getMostRecentDecl(); } - return 0; + return nullptr; } ClassTemplatePartialSpecializationDecl * @@ -432,7 +432,7 @@ ClassTemplateDecl::findPartialSpecInstantiatedFromMember( return P->getMostRecentDecl(); } - return 0; + return nullptr; } QualType @@ -478,8 +478,8 @@ TemplateTypeParmDecl::Create(const ASTContext &C, DeclContext *DC, TemplateTypeParmDecl * TemplateTypeParmDecl::CreateDeserialized(const ASTContext &C, unsigned ID) { - return new (C, ID) TemplateTypeParmDecl(0, SourceLocation(), SourceLocation(), - 0, false); + return new (C, ID) TemplateTypeParmDecl(nullptr, SourceLocation(), + SourceLocation(), nullptr, false); } SourceLocation TemplateTypeParmDecl::getDefaultArgumentLoc() const { @@ -523,7 +523,7 @@ NonTypeTemplateParmDecl::NonTypeTemplateParmDecl(DeclContext *DC, unsigned NumExpandedTypes, TypeSourceInfo **ExpandedTInfos) : DeclaratorDecl(NonTypeTemplateParm, DC, IdLoc, Id, T, TInfo, StartLoc), - TemplateParmPosition(D, P), DefaultArgumentAndInherited(0, false), + TemplateParmPosition(D, P), DefaultArgumentAndInherited(nullptr, false), ParameterPack(true), ExpandedParameterPack(true), NumExpandedTypes(NumExpandedTypes) { @@ -563,9 +563,9 @@ NonTypeTemplateParmDecl::Create(const ASTContext &C, DeclContext *DC, NonTypeTemplateParmDecl * NonTypeTemplateParmDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) NonTypeTemplateParmDecl(0, SourceLocation(), - SourceLocation(), 0, 0, 0, - QualType(), false, 0); + return new (C, ID) NonTypeTemplateParmDecl(nullptr, SourceLocation(), + SourceLocation(), 0, 0, nullptr, + QualType(), false, nullptr); } NonTypeTemplateParmDecl * @@ -573,8 +573,8 @@ NonTypeTemplateParmDecl::CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumExpandedTypes) { unsigned Extra = NumExpandedTypes * 2 * sizeof(void*); return new (C, ID, Extra) NonTypeTemplateParmDecl( - 0, SourceLocation(), SourceLocation(), 0, 0, 0, QualType(), 0, - 0, NumExpandedTypes, 0); + nullptr, SourceLocation(), SourceLocation(), 0, 0, nullptr, QualType(), + nullptr, nullptr, NumExpandedTypes, nullptr); } SourceRange NonTypeTemplateParmDecl::getSourceRange() const { @@ -631,16 +631,16 @@ TemplateTemplateParmDecl::Create(const ASTContext &C, DeclContext *DC, TemplateTemplateParmDecl * TemplateTemplateParmDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) TemplateTemplateParmDecl(0, SourceLocation(), 0, 0, false, - 0, 0); + return new (C, ID) TemplateTemplateParmDecl(nullptr, SourceLocation(), 0, 0, + false, nullptr, nullptr); } TemplateTemplateParmDecl * TemplateTemplateParmDecl::CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumExpansions) { return new (C, ID, sizeof(TemplateParameterList*) * NumExpansions) - TemplateTemplateParmDecl(0, SourceLocation(), 0, 0, 0, 0, - NumExpansions, 0); + TemplateTemplateParmDecl(nullptr, SourceLocation(), 0, 0, nullptr, + nullptr, NumExpansions, nullptr); } //===----------------------------------------------------------------------===// @@ -667,7 +667,7 @@ FunctionTemplateSpecializationInfo::Create(ASTContext &C, FunctionDecl *FD, const TemplateArgumentList *TemplateArgs, const TemplateArgumentListInfo *TemplateArgsAsWritten, SourceLocation POI) { - const ASTTemplateArgumentListInfo *ArgsAsWritten = 0; + const ASTTemplateArgumentListInfo *ArgsAsWritten = nullptr; if (TemplateArgsAsWritten) ArgsAsWritten = ASTTemplateArgumentListInfo::Create(C, *TemplateArgsAsWritten); @@ -699,14 +699,15 @@ ClassTemplateSpecializationDecl(ASTContext &Context, Kind DK, TagKind TK, SpecializedTemplate->getIdentifier(), PrevDecl), SpecializedTemplate(SpecializedTemplate), - ExplicitInfo(0), + ExplicitInfo(nullptr), TemplateArgs(TemplateArgumentList::CreateCopy(Context, Args, NumArgs)), SpecializationKind(TSK_Undeclared) { } ClassTemplateSpecializationDecl::ClassTemplateSpecializationDecl(Kind DK) - : CXXRecordDecl(DK, TTK_Struct, 0, SourceLocation(), SourceLocation(), 0, 0), - ExplicitInfo(0), + : CXXRecordDecl(DK, TTK_Struct, nullptr, SourceLocation(), SourceLocation(), + nullptr, nullptr), + ExplicitInfo(nullptr), SpecializationKind(TSK_Undeclared) { } @@ -777,7 +778,7 @@ ClassTemplateSpecializationDecl::getSourceRange() const { typedef ClassTemplatePartialSpecializationDecl CTPSDecl; CTPSDecl *ctpsd = const_cast(cast(this)); CTPSDecl *inst_from = ctpsd->getInstantiatedFromMember(); - assert(inst_from != 0); + assert(inst_from != nullptr); return inst_from->getSourceRange(); } else { @@ -816,7 +817,7 @@ ClassTemplatePartialSpecializationDecl(ASTContext &Context, TagKind TK, SpecializedTemplate, Args, NumArgs, PrevDecl), TemplateParams(Params), ArgsAsWritten(ArgInfos), - InstantiatedFromMember(0, false) + InstantiatedFromMember(nullptr, false) { AdoptTemplateParameterList(Params, this); } @@ -893,8 +894,8 @@ TypeAliasTemplateDecl *TypeAliasTemplateDecl::Create(ASTContext &C, TypeAliasTemplateDecl *TypeAliasTemplateDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) TypeAliasTemplateDecl(0, SourceLocation(), DeclarationName(), - 0, 0); + return new (C, ID) TypeAliasTemplateDecl(nullptr, SourceLocation(), + DeclarationName(), nullptr, nullptr); } void TypeAliasTemplateDecl::DeallocateCommon(void *Ptr) { @@ -917,7 +918,7 @@ ClassScopeFunctionSpecializationDecl * ClassScopeFunctionSpecializationDecl::CreateDeserialized(ASTContext &C, unsigned ID) { return new (C, ID) ClassScopeFunctionSpecializationDecl( - 0, SourceLocation(), 0, false, TemplateArgumentListInfo()); + nullptr, SourceLocation(), nullptr, false, TemplateArgumentListInfo()); } //===----------------------------------------------------------------------===// @@ -935,7 +936,7 @@ VarTemplateDecl *VarTemplateDecl::getDefinition() { return CurD; CurD = CurD->getPreviousDecl(); } - return 0; + return nullptr; } VarTemplateDecl *VarTemplateDecl::Create(ASTContext &C, DeclContext *DC, @@ -957,7 +958,7 @@ void VarTemplateDecl::LoadLazySpecializations() const { if (CommonPtr->LazySpecializations) { ASTContext &Context = getASTContext(); uint32_t *Specs = CommonPtr->LazySpecializations; - CommonPtr->LazySpecializations = 0; + CommonPtr->LazySpecializations = nullptr; for (uint32_t I = 0, N = *Specs++; I != N; ++I) (void)Context.getExternalSource()->GetExternalDecl(Specs[I]); } @@ -1049,7 +1050,7 @@ VarTemplateDecl::findPartialSpecInstantiatedFromMember( return P->getMostRecentDecl(); } - return 0; + return nullptr; } //===----------------------------------------------------------------------===// @@ -1062,14 +1063,14 @@ VarTemplateSpecializationDecl::VarTemplateSpecializationDecl( unsigned NumArgs) : VarDecl(DK, DC, StartLoc, IdLoc, SpecializedTemplate->getIdentifier(), T, TInfo, S), - SpecializedTemplate(SpecializedTemplate), ExplicitInfo(0), + SpecializedTemplate(SpecializedTemplate), ExplicitInfo(nullptr), TemplateArgs(TemplateArgumentList::CreateCopy(Context, Args, NumArgs)), SpecializationKind(TSK_Undeclared) {} VarTemplateSpecializationDecl::VarTemplateSpecializationDecl(Kind DK) - : VarDecl(DK, 0, SourceLocation(), SourceLocation(), 0, QualType(), 0, - SC_None), - ExplicitInfo(0), SpecializationKind(TSK_Undeclared) {} + : VarDecl(DK, nullptr, SourceLocation(), SourceLocation(), nullptr, + QualType(), nullptr, SC_None), + ExplicitInfo(nullptr), SpecializationKind(TSK_Undeclared) {} VarTemplateSpecializationDecl *VarTemplateSpecializationDecl::Create( ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, @@ -1126,7 +1127,7 @@ VarTemplatePartialSpecializationDecl::VarTemplatePartialSpecializationDecl( DC, StartLoc, IdLoc, SpecializedTemplate, T, TInfo, S, Args, NumArgs), TemplateParams(Params), ArgsAsWritten(ArgInfos), - InstantiatedFromMember(0, false) { + InstantiatedFromMember(nullptr, false) { // TODO: The template parameters should be in DC by now. Verify. // AdoptTemplateParameterList(Params, DC); } diff --git a/lib/AST/DeclarationName.cpp b/lib/AST/DeclarationName.cpp index f9041c043c..b7c2877200 100644 --- a/lib/AST/DeclarationName.cpp +++ b/lib/AST/DeclarationName.cpp @@ -167,7 +167,7 @@ raw_ostream &operator<<(raw_ostream &OS, DeclarationName N) { case DeclarationName::CXXOperatorName: { static const char* const OperatorNames[NUM_OVERLOADED_OPERATORS] = { - 0, + nullptr, #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \ Spelling, #include "clang/Basic/OperatorKinds.def" @@ -273,7 +273,7 @@ IdentifierInfo *DeclarationName::getCXXLiteralIdentifier() const { if (CXXLiteralOperatorIdName *CXXLit = getAsCXXLiteralOperatorIdName()) return CXXLit->ID; else - return 0; + return nullptr; } void *DeclarationName::getFETokenInfoAsVoidSlow() const { @@ -346,7 +346,7 @@ DeclarationNameTable::DeclarationNameTable(const ASTContext &C) : Ctx(C) { for (unsigned Op = 0; Op < NUM_OVERLOADED_OPERATORS; ++Op) { CXXOperatorNames[Op].ExtraKindOrNumArgs = Op + DeclarationNameExtra::CXXConversionFunction; - CXXOperatorNames[Op].FETokenInfo = 0; + CXXOperatorNames[Op].FETokenInfo = nullptr; } } @@ -407,14 +407,14 @@ DeclarationNameTable::getCXXSpecialName(DeclarationName::NameKind Kind, ID.AddInteger(EKind); ID.AddPointer(Ty.getAsOpaquePtr()); - void *InsertPos = 0; + void *InsertPos = nullptr; if (CXXSpecialName *Name = SpecialNames->FindNodeOrInsertPos(ID, InsertPos)) return DeclarationName(Name); CXXSpecialName *SpecialName = new (Ctx) CXXSpecialName; SpecialName->ExtraKindOrNumArgs = EKind; SpecialName->Type = Ty; - SpecialName->FETokenInfo = 0; + SpecialName->FETokenInfo = nullptr; SpecialNames->InsertNode(SpecialName, InsertPos); return DeclarationName(SpecialName); @@ -434,7 +434,7 @@ DeclarationNameTable::getCXXLiteralOperatorName(IdentifierInfo *II) { llvm::FoldingSetNodeID ID; ID.AddPointer(II); - void *InsertPos = 0; + void *InsertPos = nullptr; if (CXXLiteralOperatorIdName *Name = LiteralNames->FindNodeOrInsertPos(ID, InsertPos)) return DeclarationName (Name); @@ -442,7 +442,7 @@ DeclarationNameTable::getCXXLiteralOperatorName(IdentifierInfo *II) { CXXLiteralOperatorIdName *LiteralName = new (Ctx) CXXLiteralOperatorIdName; LiteralName->ExtraKindOrNumArgs = DeclarationNameExtra::CXXLiteralOperator; LiteralName->ID = II; - LiteralName->FETokenInfo = 0; + LiteralName->FETokenInfo = nullptr; LiteralNames->InsertNode(LiteralName, InsertPos); return DeclarationName(LiteralName); @@ -455,7 +455,7 @@ DeclarationNameLoc::DeclarationNameLoc(DeclarationName Name) { case DeclarationName::CXXConstructorName: case DeclarationName::CXXDestructorName: case DeclarationName::CXXConversionFunctionName: - NamedType.TInfo = 0; + NamedType.TInfo = nullptr; break; case DeclarationName::CXXOperatorName: CXXOperatorName.BeginOpNameLoc = SourceLocation().getRawEncoding(); diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 4ddd0a239a..6d8b165e71 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -44,7 +44,7 @@ const CXXRecordDecl *Expr::getBestDynamicClassType() const { DerivedType = PTy->getPointeeType(); if (DerivedType->isDependentType()) - return NULL; + return nullptr; const RecordType *Ty = DerivedType->castAs(); Decl *D = Ty->getDecl(); @@ -402,7 +402,7 @@ DeclRefExpr *DeclRefExpr::Create(const ASTContext &Context, const TemplateArgumentListInfo *TemplateArgs) { // Filter out cases where the found Decl is the same as the value refenenced. if (D == FoundD) - FoundD = 0; + FoundD = nullptr; std::size_t Size = sizeof(DeclRefExpr); if (QualifierLoc) @@ -499,7 +499,7 @@ std::string PredefinedExpr::ComputeName(IdentType IT, const Decl *CurrentDecl) { if (const FunctionDecl* Pattern = FD->getTemplateInstantiationPattern()) Decl = Pattern; const FunctionType *AFT = Decl->getType()->getAs(); - const FunctionProtoType *FT = 0; + const FunctionProtoType *FT = nullptr; if (FD->hasWrittenPrototype()) FT = dyn_cast(AFT); @@ -1132,7 +1132,7 @@ CallExpr::CallExpr(const ASTContext& C, Expr *fn, ArrayRef args, } CallExpr::CallExpr(const ASTContext &C, StmtClass SC, EmptyShell Empty) - : Expr(SC, Empty), SubExprs(0), NumArgs(0) { + : Expr(SC, Empty), SubExprs(nullptr), NumArgs(0) { // FIXME: Why do we allocate this? SubExprs = new (C) Stmt*[PREARGS_START]; CallExprBits.NumPreArgs = 0; @@ -1140,7 +1140,7 @@ CallExpr::CallExpr(const ASTContext &C, StmtClass SC, EmptyShell Empty) CallExpr::CallExpr(const ASTContext &C, StmtClass SC, unsigned NumPreArgs, EmptyShell Empty) - : Expr(SC, Empty), SubExprs(0), NumArgs(0) { + : Expr(SC, Empty), SubExprs(nullptr), NumArgs(0) { // FIXME: Why do we allocate this? SubExprs = new (C) Stmt*[PREARGS_START+NumPreArgs]; CallExprBits.NumPreArgs = NumPreArgs; @@ -1167,7 +1167,7 @@ Decl *CallExpr::getCalleeDecl() { if (MemberExpr *ME = dyn_cast(CEE)) return ME->getMemberDecl(); - return 0; + return nullptr; } FunctionDecl *CallExpr::getDirectCallee() { @@ -1196,7 +1196,7 @@ void CallExpr::setNumArgs(const ASTContext& C, unsigned NumArgs) { // Null out new args. for (unsigned i = getNumArgs()+PREARGS_START+NumPreArgs; i != NumArgs+PREARGS_START+NumPreArgs; ++i) - NewSubExprs[i] = 0; + NewSubExprs[i] = nullptr; if (SubExprs) C.Deallocate(SubExprs); SubExprs = NewSubExprs; @@ -1638,7 +1638,7 @@ const char *CastExpr::getCastKindName() const { } Expr *CastExpr::getSubExprAsWritten() { - Expr *SubExpr = 0; + Expr *SubExpr = nullptr; CastExpr *E = this; do { SubExpr = E->getSubExpr(); @@ -1834,7 +1834,7 @@ InitListExpr::InitListExpr(const ASTContext &C, SourceLocation lbraceloc, : Expr(InitListExprClass, QualType(), VK_RValue, OK_Ordinary, false, false, false, false), InitExprs(C, initExprs.size()), - LBraceLoc(lbraceloc), RBraceLoc(rbraceloc), AltForm(0, true) + LBraceLoc(lbraceloc), RBraceLoc(rbraceloc), AltForm(nullptr, true) { sawArrayRangeDesignator(false); for (unsigned I = 0; I != initExprs.size(); ++I) { @@ -1857,14 +1857,14 @@ void InitListExpr::reserveInits(const ASTContext &C, unsigned NumInits) { } void InitListExpr::resizeInits(const ASTContext &C, unsigned NumInits) { - InitExprs.resize(C, NumInits, 0); + InitExprs.resize(C, NumInits, nullptr); } Expr *InitListExpr::updateInit(const ASTContext &C, unsigned Init, Expr *expr) { if (Init >= InitExprs.size()) { - InitExprs.insert(C, InitExprs.end(), Init - InitExprs.size() + 1, 0); + InitExprs.insert(C, InitExprs.end(), Init - InitExprs.size() + 1, nullptr); setInit(Init, expr); - return 0; + return nullptr; } Expr *Result = cast_or_null(InitExprs[Init]); @@ -1878,7 +1878,7 @@ void InitListExpr::setArrayFiller(Expr *filler) { // Fill out any "holes" in the array due to designated initializers. Expr **inits = getInits(); for (unsigned i = 0, e = getNumInits(); i != e; ++i) - if (inits[i] == 0) + if (inits[i] == nullptr) inits[i] = filler; } @@ -3258,7 +3258,7 @@ FieldDecl *Expr::getSourceBitField() { return BinOp->getRHS()->getSourceBitField(); } - return 0; + return nullptr; } bool Expr::refersToVectorElement() const { @@ -3364,8 +3364,9 @@ ObjCMessageExpr::ObjCMessageExpr(QualType T, SelectorOrMethod(reinterpret_cast(Method? Method : Sel.getAsOpaquePtr())), Kind(IsInstanceSuper? SuperInstance : SuperClass), - HasMethod(Method != 0), IsDelegateInitCall(false), IsImplicit(isImplicit), - SuperLoc(SuperLoc), LBracLoc(LBracLoc), RBracLoc(RBracLoc) + HasMethod(Method != nullptr), IsDelegateInitCall(false), + IsImplicit(isImplicit), SuperLoc(SuperLoc), LBracLoc(LBracLoc), + RBracLoc(RBracLoc) { initArgsAndSelLocs(Args, SelLocs, SelLocsK); setReceiverPointer(SuperType.getAsOpaquePtr()); @@ -3388,8 +3389,8 @@ ObjCMessageExpr::ObjCMessageExpr(QualType T, SelectorOrMethod(reinterpret_cast(Method? Method : Sel.getAsOpaquePtr())), Kind(Class), - HasMethod(Method != 0), IsDelegateInitCall(false), IsImplicit(isImplicit), - LBracLoc(LBracLoc), RBracLoc(RBracLoc) + HasMethod(Method != nullptr), IsDelegateInitCall(false), + IsImplicit(isImplicit), LBracLoc(LBracLoc), RBracLoc(RBracLoc) { initArgsAndSelLocs(Args, SelLocs, SelLocsK); setReceiverPointer(Receiver); @@ -3413,8 +3414,8 @@ ObjCMessageExpr::ObjCMessageExpr(QualType T, SelectorOrMethod(reinterpret_cast(Method? Method : Sel.getAsOpaquePtr())), Kind(Instance), - HasMethod(Method != 0), IsDelegateInitCall(false), IsImplicit(isImplicit), - LBracLoc(LBracLoc), RBracLoc(RBracLoc) + HasMethod(Method != nullptr), IsDelegateInitCall(false), + IsImplicit(isImplicit), LBracLoc(LBracLoc), RBracLoc(RBracLoc) { initArgsAndSelLocs(Args, SelLocs, SelLocsK); setReceiverPointer(Receiver); @@ -3596,7 +3597,7 @@ ObjCInterfaceDecl *ObjCMessageExpr::getReceiverInterface() const { if (const ObjCObjectType *Ty = T->getAs()) return Ty->getInterface(); - return 0; + return nullptr; } StringRef ObjCBridgedCastExpr::getBridgeKindName() const { @@ -3969,7 +3970,7 @@ PseudoObjectExpr::PseudoObjectExpr(QualType type, ExprValueKind VK, ExprBits.ContainsUnexpandedParameterPack = true; if (isa(E)) - assert(cast(E)->getSourceExpr() != 0 && + assert(cast(E)->getSourceExpr() != nullptr && "opaque-value semantic expressions for pseudo-object " "operations must have sources"); } diff --git a/lib/AST/ExprCXX.cpp b/lib/AST/ExprCXX.cpp index 04f4d40c77..d6002a7824 100644 --- a/lib/AST/ExprCXX.cpp +++ b/lib/AST/ExprCXX.cpp @@ -67,19 +67,19 @@ UuidAttr *CXXUuidofExpr::GetUuidAttrOfType(QualType QT, // Loop all record redeclaration looking for an uuid attribute. CXXRecordDecl *RD = Ty->getAsCXXRecordDecl(); if (!RD) - return 0; + return nullptr; // __uuidof can grab UUIDs from template arguments. if (ClassTemplateSpecializationDecl *CTSD = dyn_cast(RD)) { const TemplateArgumentList &TAL = CTSD->getTemplateArgs(); - UuidAttr *UuidForRD = 0; + UuidAttr *UuidForRD = nullptr; for (unsigned I = 0, N = TAL.size(); I != N; ++I) { const TemplateArgument &TA = TAL[I]; bool SeenMultipleGUIDs = false; - UuidAttr *UuidForTA = 0; + UuidAttr *UuidForTA = nullptr; if (TA.getKind() == TemplateArgument::Type) UuidForTA = GetUuidAttrOfType(TA.getAsType(), &SeenMultipleGUIDs); else if (TA.getKind() == TemplateArgument::Declaration) @@ -101,7 +101,7 @@ UuidAttr *CXXUuidofExpr::GetUuidAttrOfType(QualType QT, if (SeenMultipleGUIDs) { if (RDHasMultipleGUIDsPtr) *RDHasMultipleGUIDsPtr = true; - return 0; + return nullptr; } } @@ -112,7 +112,7 @@ UuidAttr *CXXUuidofExpr::GetUuidAttrOfType(QualType QT, if (auto Uuid = I->getAttr()) return Uuid; - return 0; + return nullptr; } StringRef CXXUuidofExpr::getUuidAsStringRef(ASTContext &Context) const { @@ -149,14 +149,15 @@ CXXNewExpr::CXXNewExpr(const ASTContext &C, bool globalNew, ty->isDependentType(), ty->isDependentType(), ty->isInstantiationDependentType(), ty->containsUnexpandedParameterPack()), - SubExprs(0), OperatorNew(operatorNew), OperatorDelete(operatorDelete), + SubExprs(nullptr), OperatorNew(operatorNew), OperatorDelete(operatorDelete), AllocatedTypeInfo(allocatedTypeInfo), TypeIdParens(typeIdParens), Range(Range), DirectInitRange(directInitRange), GlobalNew(globalNew), UsualArrayDeleteWantsSize(usualArrayDeleteWantsSize) { - assert((initializer != 0 || initializationStyle == NoInit) && + assert((initializer != nullptr || initializationStyle == NoInit) && "Only NoInit can have no initializer."); StoredInitializationStyle = initializer ? initializationStyle + 1 : 0; - AllocateArgsArray(C, arraySize != 0, placementArgs.size(), initializer != 0); + AllocateArgsArray(C, arraySize != nullptr, placementArgs.size(), + initializer != nullptr); unsigned i = 0; if (Array) { if (arraySize->isInstantiationDependent()) @@ -201,7 +202,7 @@ CXXNewExpr::CXXNewExpr(const ASTContext &C, bool globalNew, void CXXNewExpr::AllocateArgsArray(const ASTContext &C, bool isArray, unsigned numPlaceArgs, bool hasInitializer){ - assert(SubExprs == 0 && "SubExprs already allocated"); + assert(SubExprs == nullptr && "SubExprs already allocated"); Array = isArray; NumPlacementArgs = numPlaceArgs; @@ -343,9 +344,9 @@ OverloadExpr::OverloadExpr(StmtClass K, const ASTContext &C, QualifierLoc.getNestedNameSpecifier() ->containsUnexpandedParameterPack()))), NameInfo(NameInfo), QualifierLoc(QualifierLoc), - Results(0), NumResults(End - Begin), - HasTemplateKWAndArgsInfo(TemplateArgs != 0 || TemplateKWLoc.isValid()) -{ + Results(nullptr), NumResults(End - Begin), + HasTemplateKWAndArgsInfo(TemplateArgs != nullptr || + TemplateKWLoc.isValid()) { NumResults = End - Begin; if (NumResults) { // Determine whether this expression is type-dependent. @@ -396,7 +397,7 @@ OverloadExpr::OverloadExpr(StmtClass K, const ASTContext &C, void OverloadExpr::initializeResults(const ASTContext &C, UnresolvedSetIterator Begin, UnresolvedSetIterator End) { - assert(Results == 0 && "Results already initialized!"); + assert(!Results && "Results already initialized!"); NumResults = End - Begin; if (NumResults) { Results = static_cast( @@ -431,7 +432,7 @@ DependentScopeDeclRefExpr::DependentScopeDeclRefExpr(QualType T, QualifierLoc.getNestedNameSpecifier() ->containsUnexpandedParameterPack()))), QualifierLoc(QualifierLoc), NameInfo(NameInfo), - HasTemplateKWAndArgsInfo(Args != 0 || TemplateKWLoc.isValid()) + HasTemplateKWAndArgsInfo(Args != nullptr || TemplateKWLoc.isValid()) { if (Args) { bool Dependent = true; @@ -476,7 +477,7 @@ DependentScopeDeclRefExpr::CreateEmpty(const ASTContext &C, DependentScopeDeclRefExpr *E = new (Mem) DependentScopeDeclRefExpr(QualType(), NestedNameSpecifierLoc(), SourceLocation(), - DeclarationNameInfo(), 0); + DeclarationNameInfo(), nullptr); E->HasTemplateKWAndArgsInfo = HasTemplateKWAndArgsInfo; return E; } @@ -542,7 +543,7 @@ Expr *CXXMemberCallExpr::getImplicitObjectArgument() const { return BO->getLHS(); // FIXME: Will eventually need to cope with member pointers. - return 0; + return nullptr; } CXXMethodDecl *CXXMemberCallExpr::getMethodDecl() const { @@ -551,14 +552,14 @@ CXXMethodDecl *CXXMemberCallExpr::getMethodDecl() const { return cast(MemExpr->getMemberDecl()); // FIXME: Will eventually need to cope with member pointers. - return 0; + return nullptr; } CXXRecordDecl *CXXMemberCallExpr::getRecordDecl() const { Expr* ThisArg = getImplicitObjectArgument(); if (!ThisArg) - return 0; + return nullptr; if (ThisArg->getType()->isAnyPointerType()) return ThisArg->getType()->getPointeeType()->getAsCXXRecordDecl(); @@ -864,7 +865,7 @@ CXXConstructExpr::CXXConstructExpr(const ASTContext &C, StmtClass SC, Elidable(elidable), HadMultipleCandidates(HadMultipleCandidates), ListInitialization(ListInitialization), ZeroInitialization(ZeroInitialization), - ConstructKind(ConstructKind), Args(0) + ConstructKind(ConstructKind), Args(nullptr) { if (NumArgs) { Args = new (C) Stmt*[args.size()]; @@ -894,8 +895,8 @@ LambdaCapture::LambdaCapture(SourceLocation Loc, bool Implicit, Bits |= Capture_Implicit; switch (Kind) { - case LCK_This: - assert(Var == 0 && "'this' capture cannot have a variable!"); + case LCK_This: + assert(!Var && "'this' capture cannot have a variable!"); break; case LCK_ByCopy: @@ -1185,7 +1186,8 @@ CXXDependentScopeMemberExpr::CXXDependentScopeMemberExpr(const ASTContext &C, ->containsUnexpandedParameterPack()) || MemberNameInfo.containsUnexpandedParameterPack())), Base(Base), BaseType(BaseType), IsArrow(IsArrow), - HasTemplateKWAndArgsInfo(TemplateArgs != 0 || TemplateKWLoc.isValid()), + HasTemplateKWAndArgsInfo(TemplateArgs != nullptr || + TemplateKWLoc.isValid()), OperatorLoc(OperatorLoc), QualifierLoc(QualifierLoc), FirstQualifierFoundInScope(FirstQualifierFoundInScope), MemberNameInfo(MemberNameInfo) { @@ -1258,26 +1260,26 @@ CXXDependentScopeMemberExpr::CreateEmpty(const ASTContext &C, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs) { if (!HasTemplateKWAndArgsInfo) - return new (C) CXXDependentScopeMemberExpr(C, 0, QualType(), + return new (C) CXXDependentScopeMemberExpr(C, nullptr, QualType(), 0, SourceLocation(), - NestedNameSpecifierLoc(), 0, - DeclarationNameInfo()); + NestedNameSpecifierLoc(), + nullptr, DeclarationNameInfo()); std::size_t size = sizeof(CXXDependentScopeMemberExpr) + ASTTemplateKWAndArgsInfo::sizeFor(NumTemplateArgs); void *Mem = C.Allocate(size, llvm::alignOf()); CXXDependentScopeMemberExpr *E - = new (Mem) CXXDependentScopeMemberExpr(C, 0, QualType(), + = new (Mem) CXXDependentScopeMemberExpr(C, nullptr, QualType(), 0, SourceLocation(), NestedNameSpecifierLoc(), - SourceLocation(), 0, - DeclarationNameInfo(), 0); + SourceLocation(), nullptr, + DeclarationNameInfo(), nullptr); E->HasTemplateKWAndArgsInfo = true; return E; } bool CXXDependentScopeMemberExpr::isImplicitAccess() const { - if (Base == 0) + if (!Base) return true; return cast(Base)->isImplicitCXXThis(); @@ -1331,7 +1333,7 @@ UnresolvedMemberExpr::UnresolvedMemberExpr(const ASTContext &C, } bool UnresolvedMemberExpr::isImplicitAccess() const { - if (Base == 0) + if (!Base) return true; return cast(Base)->isImplicitCXXThis(); @@ -1380,7 +1382,7 @@ CXXRecordDecl *UnresolvedMemberExpr::getNamingClass() const { // If there was a nested name specifier, it names the naming class. // It can't be dependent: after all, we were actually able to do the // lookup. - CXXRecordDecl *Record = 0; + CXXRecordDecl *Record = nullptr; if (getQualifier()) { const Type *T = getQualifier()->getAsType(); assert(T && "qualifier in member expression does not name type"); @@ -1443,7 +1445,7 @@ FunctionParmPackExpr::CreateEmpty(const ASTContext &Context, unsigned NumParams) { return new (Context.Allocate(sizeof(FunctionParmPackExpr) + sizeof(ParmVarDecl*) * NumParams)) - FunctionParmPackExpr(QualType(), 0, SourceLocation(), 0, 0); + FunctionParmPackExpr(QualType(), nullptr, SourceLocation(), 0, nullptr); } void MaterializeTemporaryExpr::setExtendingDecl(const ValueDecl *ExtendedBy, diff --git a/lib/AST/ExprClassification.cpp b/lib/AST/ExprClassification.cpp index 55b9f13b29..d3d25308a3 100644 --- a/lib/AST/ExprClassification.cpp +++ b/lib/AST/ExprClassification.cpp @@ -549,8 +549,8 @@ static Cl::Kinds ClassifyConditional(ASTContext &Ctx, const Expr *True, // category of the other. bool TrueIsThrow = isa(True->IgnoreParenImpCasts()); bool FalseIsThrow = isa(False->IgnoreParenImpCasts()); - if (const Expr *NonThrow = TrueIsThrow ? (FalseIsThrow ? 0 : False) - : (FalseIsThrow ? True : 0)) + if (const Expr *NonThrow = TrueIsThrow ? (FalseIsThrow ? nullptr : False) + : (FalseIsThrow ? True : nullptr)) return ClassifyInternal(Ctx, NonThrow); // [Otherwise] the result [...] is a prvalue. @@ -593,7 +593,8 @@ static Cl::ModifiableType IsModifiable(ASTContext &Ctx, const Expr *E, // Assignment to a property in ObjC is an implicit setter access. But a // setter might not exist. if (const ObjCPropertyRefExpr *Expr = dyn_cast(E)) { - if (Expr->isImplicitProperty() && Expr->getImplicitPropertySetter() == 0) + if (Expr->isImplicitProperty() && + Expr->getImplicitPropertySetter() == nullptr) return Cl::CM_NoSetterProperty; } diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index 16c5a5214d..c1468cba15 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -320,7 +320,7 @@ namespace { APValue *getTemporary(const void *Key) { MapTy::iterator I = Temporaries.find(Key); - return I == Temporaries.end() ? 0 : &I->second; + return I == Temporaries.end() ? nullptr : &I->second; } APValue &createTemporary(const void *Key, bool IsLifetimeExtended); }; @@ -347,7 +347,8 @@ namespace { PartialDiagnostic *Diag; public: - explicit OptionalDiagnostic(PartialDiagnostic *Diag = 0) : Diag(Diag) {} + explicit OptionalDiagnostic(PartialDiagnostic *Diag = nullptr) + : Diag(Diag) {} template OptionalDiagnostic &operator<<(const T &v) { @@ -506,12 +507,13 @@ namespace { bool checkingForOverflow() { return EvalMode == EM_EvaluateForOverflow; } EvalInfo(const ASTContext &C, Expr::EvalStatus &S, EvaluationMode Mode) - : Ctx(const_cast(C)), EvalStatus(S), CurrentCall(0), + : Ctx(const_cast(C)), EvalStatus(S), CurrentCall(nullptr), CallStackDepth(0), NextCallIndex(1), StepsLeft(getLangOpts().ConstexprStepLimit), - BottomFrame(*this, SourceLocation(), 0, 0, 0), - EvaluatingDecl((const ValueDecl*)0), EvaluatingDeclValue(0), - HasActiveDiagnostic(false), EvalMode(Mode) {} + BottomFrame(*this, SourceLocation(), nullptr, nullptr, nullptr), + EvaluatingDecl((const ValueDecl *)nullptr), + EvaluatingDeclValue(nullptr), HasActiveDiagnostic(false), + EvalMode(Mode) {} void setEvaluatingDecl(APValue::LValueBase Base, APValue &Value) { EvaluatingDecl = Base; @@ -544,7 +546,7 @@ namespace { CallStackFrame *Frame = CurrentCall; while (Frame->Index > CallIndex) Frame = Frame->Caller; - return (Frame->Index == CallIndex) ? Frame : 0; + return (Frame->Index == CallIndex) ? Frame : nullptr; } bool nextStep(const Stmt *S) { @@ -741,7 +743,7 @@ namespace { public: SpeculativeEvaluationRAII(EvalInfo &Info, - SmallVectorImpl *NewDiag = 0) + SmallVectorImpl *NewDiag = nullptr) : Info(Info), Old(Info.EvalStatus) { Info.EvalStatus.Diag = NewDiag; // If we're speculatively evaluating, we may have skipped over some @@ -1301,7 +1303,7 @@ static bool CheckLValueConstantExpression(EvalInfo &Info, SourceLocation Loc, /// Check that this core constant expression is of literal type, and if not, /// produce an appropriate diagnostic. static bool CheckLiteralType(EvalInfo &Info, const Expr *E, - const LValue *This = 0) { + const LValue *This = nullptr) { if (!E->isRValue() || E->getType()->isLiteralType(Info.Ctx)) return true; @@ -1762,7 +1764,7 @@ static bool CastToDerivedClass(EvalInfo &Info, const Expr *E, LValue &Result, static bool HandleLValueDirectBase(EvalInfo &Info, const Expr *E, LValue &Obj, const CXXRecordDecl *Derived, const CXXRecordDecl *Base, - const ASTRecordLayout *RL = 0) { + const ASTRecordLayout *RL = nullptr) { if (!RL) { if (Derived->isInvalidDecl()) return false; RL = &Info.Ctx.getASTRecordLayout(Derived); @@ -1815,7 +1817,7 @@ static bool HandleLValueBasePath(EvalInfo &Info, const CastExpr *E, /// currently described by LVal. static bool HandleLValueMember(EvalInfo &Info, const Expr *E, LValue &LVal, const FieldDecl *FD, - const ASTRecordLayout *RL = 0) { + const ASTRecordLayout *RL = nullptr) { if (!RL) { if (FD->getParent()->isInvalidDecl()) return false; RL = &Info.Ctx.getASTRecordLayout(FD->getParent()); @@ -2070,7 +2072,7 @@ struct CompleteObject { /// The type of the complete object. QualType Type; - CompleteObject() : Value(0) {} + CompleteObject() : Value(nullptr) {} CompleteObject(APValue *Value, QualType Type) : Value(Value), Type(Type) { assert(Value && "missing value for complete object"); @@ -2098,7 +2100,7 @@ findSubobject(EvalInfo &Info, const Expr *E, const CompleteObject &Obj, APValue *O = Obj.Value; QualType ObjType = Obj.Type; - const FieldDecl *LastField = 0; + const FieldDecl *LastField = nullptr; // Walk the designator's path to find the subobject. for (unsigned I = 0, N = Sub.Entries.size(); /**/; ++I) { @@ -2121,7 +2123,7 @@ findSubobject(EvalInfo &Info, const Expr *E, const CompleteObject &Obj, return true; } - LastField = 0; + LastField = nullptr; if (ObjType->isArrayType()) { // Next subobject is an array element. const ConstantArrayType *CAT = Info.Ctx.getAsConstantArrayType(ObjType); @@ -2404,7 +2406,7 @@ CompleteObject findCompleteObject(EvalInfo &Info, const Expr *E, AccessKinds AK, return CompleteObject(); } - CallStackFrame *Frame = 0; + CallStackFrame *Frame = nullptr; if (LVal.CallIndex) { Frame = Info.getCallFrame(LVal.CallIndex); if (!Frame) { @@ -2429,7 +2431,7 @@ CompleteObject findCompleteObject(EvalInfo &Info, const Expr *E, AccessKinds AK, } // Compute value storage location and type of base object. - APValue *BaseVal = 0; + APValue *BaseVal = nullptr; QualType BaseType = getType(LVal.Base); if (const ValueDecl *D = LVal.Base.dyn_cast()) { @@ -2799,7 +2801,7 @@ struct IncDecSubobjectHandler { // if we're post-incrementing a complex. if (Old) { *Old = Subobj; - Old = 0; + Old = nullptr; } switch (Subobj.getKind()) { @@ -2957,14 +2959,14 @@ static const ValueDecl *HandleMemberPointerAccess(EvalInfo &Info, bool IncludeMember = true) { MemberPtr MemPtr; if (!EvaluateMemberPointer(RHS, MemPtr, Info)) - return 0; + return nullptr; // C++11 [expr.mptr.oper]p6: If the second operand is the null pointer to // member value, the behavior is undefined. if (!MemPtr.getDecl()) { // FIXME: Specific diagnostic. Info.Diag(RHS); - return 0; + return nullptr; } if (MemPtr.isDerivedMember()) { @@ -2974,7 +2976,7 @@ static const ValueDecl *HandleMemberPointerAccess(EvalInfo &Info, if (LV.Designator.MostDerivedPathLength + MemPtr.Path.size() > LV.Designator.Entries.size()) { Info.Diag(RHS); - return 0; + return nullptr; } unsigned PathLengthToMember = LV.Designator.Entries.size() - MemPtr.Path.size(); @@ -2984,14 +2986,14 @@ static const ValueDecl *HandleMemberPointerAccess(EvalInfo &Info, const CXXRecordDecl *MPDecl = MemPtr.Path[I]; if (LVDecl->getCanonicalDecl() != MPDecl->getCanonicalDecl()) { Info.Diag(RHS); - return 0; + return nullptr; } } // Truncate the lvalue to the appropriate derived class. if (!CastToDerivedClass(Info, RHS, LV, MemPtr.getContainingRecord(), PathLengthToMember)) - return 0; + return nullptr; } else if (!MemPtr.Path.empty()) { // Extend the LValue path with the member pointer's path. LV.Designator.Entries.reserve(LV.Designator.Entries.size() + @@ -3006,24 +3008,24 @@ static const ValueDecl *HandleMemberPointerAccess(EvalInfo &Info, for (unsigned I = 1, N = MemPtr.Path.size(); I != N; ++I) { const CXXRecordDecl *Base = MemPtr.Path[N - I - 1]; if (!HandleLValueDirectBase(Info, RHS, LV, RD, Base)) - return 0; + return nullptr; RD = Base; } // Finally cast to the class containing the member. if (!HandleLValueDirectBase(Info, RHS, LV, RD, MemPtr.getContainingRecord())) - return 0; + return nullptr; } // Add the member. Note that we cannot build bound member functions here. if (IncludeMember) { if (const FieldDecl *FD = dyn_cast(MemPtr.getDecl())) { if (!HandleLValueMember(Info, RHS, LV, FD)) - return 0; + return nullptr; } else if (const IndirectFieldDecl *IFD = dyn_cast(MemPtr.getDecl())) { if (!HandleLValueIndirectMember(Info, RHS, LV, IFD)) - return 0; + return nullptr; } else { llvm_unreachable("can't construct reference to bound member function"); } @@ -3043,7 +3045,7 @@ static const ValueDecl *HandleMemberPointerAccess(EvalInfo &Info, MemberPtr MemPtr; EvaluateMemberPointer(BO->getRHS(), MemPtr, Info); } - return 0; + return nullptr; } return HandleMemberPointerAccess(Info, BO->getLHS()->getType(), LV, @@ -3147,12 +3149,13 @@ static bool EvaluateCond(EvalInfo &Info, const VarDecl *CondDecl, } static EvalStmtResult EvaluateStmt(APValue &Result, EvalInfo &Info, - const Stmt *S, const SwitchCase *SC = 0); + const Stmt *S, + const SwitchCase *SC = nullptr); /// Evaluate the body of a loop, and translate the result as appropriate. static EvalStmtResult EvaluateLoopBody(APValue &Result, EvalInfo &Info, const Stmt *Body, - const SwitchCase *Case = 0) { + const SwitchCase *Case = nullptr) { BlockScopeRAII Scope(Info); switch (EvalStmtResult ESR = EvaluateStmt(Result, Info, Body, Case)) { case ESR_Break: @@ -3186,7 +3189,7 @@ static EvalStmtResult EvaluateSwitch(APValue &Result, EvalInfo &Info, // Find the switch case corresponding to the value of the condition. // FIXME: Cache this lookup. - const SwitchCase *Found = 0; + const SwitchCase *Found = nullptr; for (const SwitchCase *SC = SS->getSwitchCaseList(); SC; SC = SC->getNextSwitchCase()) { if (isa(SC)) { @@ -3251,7 +3254,7 @@ static EvalStmtResult EvaluateStmt(APValue &Result, EvalInfo &Info, case Stmt::CaseStmtClass: case Stmt::DefaultStmtClass: if (Case == S) - Case = 0; + Case = nullptr; break; case Stmt::IfStmtClass: { @@ -3344,7 +3347,7 @@ static EvalStmtResult EvaluateStmt(APValue &Result, EvalInfo &Info, for (const auto *BI : CS->body()) { EvalStmtResult ESR = EvaluateStmt(Result, Info, BI, Case); if (ESR == ESR_Succeeded) - Case = 0; + Case = nullptr; else if (ESR != ESR_CaseNotFound) return ESR; } @@ -3393,7 +3396,7 @@ static EvalStmtResult EvaluateStmt(APValue &Result, EvalInfo &Info, EvalStmtResult ESR = EvaluateLoopBody(Result, Info, DS->getBody(), Case); if (ESR != ESR_Continue) return ESR; - Case = 0; + Case = nullptr; FullExpressionRAII CondScope(Info); if (!EvaluateAsBooleanCondition(DS->getCond(), Continue, Info)) @@ -3689,7 +3692,7 @@ static bool HandleConstructorCall(SourceLocation CallLoc, const LValue &This, APValue *Value = &Result; // Determine the subobject to initialize. - FieldDecl *FD = 0; + FieldDecl *FD = nullptr; if (I->isBaseInitializer()) { QualType BaseType(I->getBaseClass(), 0); #ifndef NDEBUG @@ -3956,14 +3959,14 @@ public: const Expr *Callee = E->getCallee()->IgnoreParens(); QualType CalleeType = Callee->getType(); - const FunctionDecl *FD = 0; - LValue *This = 0, ThisVal; + const FunctionDecl *FD = nullptr; + LValue *This = nullptr, ThisVal; ArrayRef Args(E->getArgs(), E->getNumArgs()); bool HasQualifier = false; // Extract function decl and 'this' pointer from the callee. if (CalleeType->isSpecificBuiltinType(BuiltinType::BoundMember)) { - const ValueDecl *Member = 0; + const ValueDecl *Member = nullptr; if (const MemberExpr *ME = dyn_cast(Callee)) { // Explicit bound member calls, such as x.f() or p->g(); if (!EvaluateObjectArgument(Info, ME->getBase(), ThisVal)) @@ -4025,7 +4028,7 @@ public: isa(FD) && cast(FD)->isVirtual()) return Error(E, diag::note_constexpr_virtual_call); - const FunctionDecl *Definition = 0; + const FunctionDecl *Definition = nullptr; Stmt *Body = FD->getBody(Definition); APValue Result; @@ -4377,7 +4380,7 @@ bool LValueExprEvaluator::VisitDeclRefExpr(const DeclRefExpr *E) { } bool LValueExprEvaluator::VisitVarDecl(const Expr *E, const VarDecl *VD) { - CallStackFrame *Frame = 0; + CallStackFrame *Frame = nullptr; if (VD->hasLocalStorage() && Info.CurrentCall->Index > 1) Frame = Info.CurrentCall; @@ -4554,7 +4557,7 @@ bool LValueExprEvaluator::VisitUnaryPreIncDec(const UnaryOperator *UO) { return handleIncDec( this->Info, UO, Result, UO->getSubExpr()->getType(), - UO->isIncrementOp(), 0); + UO->isIncrementOp(), nullptr); } bool LValueExprEvaluator::VisitCompoundAssignOperator( @@ -4622,7 +4625,7 @@ public: return true; } bool ZeroInitialization(const Expr *E) { - return Success((Expr*)0); + return Success((Expr*)nullptr); } bool VisitBinaryOperator(const BinaryOperator *E); @@ -4750,7 +4753,7 @@ bool PointerExprEvaluator::VisitCastExpr(const CastExpr* E) { if (Value.isInt()) { unsigned Size = Info.Ctx.getTypeSize(E->getType()); uint64_t N = Value.getInt().extOrTrunc(Size).getZExtValue(); - Result.Base = (Expr*)0; + Result.Base = (Expr*)nullptr; Result.Offset = CharUnits::fromQuantity(N); Result.CallIndex = 0; Result.Designator.setInvalid(); @@ -4822,7 +4825,7 @@ public: return true; } bool ZeroInitialization(const Expr *E) { - return Success((const ValueDecl*)0); + return Success((const ValueDecl*)nullptr); } bool VisitCastExpr(const CastExpr *E); @@ -4972,7 +4975,7 @@ bool RecordExprEvaluator::ZeroInitialization(const Expr *E) { // object's first non-static named data member is zero-initialized RecordDecl::field_iterator I = RD->field_begin(); if (I == RD->field_end()) { - Result = APValue((const FieldDecl*)0); + Result = APValue((const FieldDecl*)nullptr); return true; } @@ -5119,7 +5122,7 @@ bool RecordExprEvaluator::VisitCXXConstructExpr(const CXXConstructExpr *E) { return ZeroInitialization(E); } - const FunctionDecl *Definition = 0; + const FunctionDecl *Definition = nullptr; FD->getBody(Definition); if (!CheckConstexprFunction(Info, E->getExprLoc(), FD, Definition)) @@ -5506,7 +5509,7 @@ bool ArrayExprEvaluator::VisitInitListExpr(const InitListExpr *E) { unsigned NumEltsToInit = E->getNumInits(); unsigned NumElts = CAT->getSize().getZExtValue(); - const Expr *FillerExpr = E->hasArrayFiller() ? E->getArrayFiller() : 0; + const Expr *FillerExpr = E->hasArrayFiller() ? E->getArrayFiller() : nullptr; // If the initializer might depend on the array index, run it for each // array element. For now, just whitelist non-class value-initialization. @@ -5601,7 +5604,7 @@ bool ArrayExprEvaluator::VisitCXXConstructExpr(const CXXConstructExpr *E, return EvaluateInPlace(*Value, Info, Subobject, &VIE); } - const FunctionDecl *Definition = 0; + const FunctionDecl *Definition = nullptr; FD->getBody(Definition); if (!CheckConstexprFunction(Info, E->getExprLoc(), FD, Definition)) @@ -6277,11 +6280,11 @@ class DataRecursiveIntBinOpEvaluator { const Expr *E; EvalResult LHSResult; // meaningful only for binary operator expression. enum { AnyExprKind, BinOpKind, BinOpVisitedLHSKind } Kind; - - Job() : StoredInfo(0) { } + + Job() : StoredInfo(nullptr) {} void startSpeculativeEval(EvalInfo &Info) { OldEvalStatus = Info.EvalStatus; - Info.EvalStatus.Diag = 0; + Info.EvalStatus.Diag = nullptr; StoredInfo = &Info; } ~Job() { @@ -8645,7 +8648,7 @@ static bool EvaluateCPlusPlus11IntegralConstantExpr(const ASTContext &Ctx, bool Expr::isIntegerConstantExpr(const ASTContext &Ctx, SourceLocation *Loc) const { if (Ctx.getLangOpts().CPlusPlus11) - return EvaluateCPlusPlus11IntegralConstantExpr(Ctx, this, 0, Loc); + return EvaluateCPlusPlus11IntegralConstantExpr(Ctx, this, nullptr, Loc); ICEDiag D = CheckICE(this, Ctx); if (D.Kind != IK_ICE) { @@ -8714,7 +8717,7 @@ bool Expr::EvaluateWithSubstitution(APValue &Value, ASTContext &Ctx, } // Build fake call to Callee. - CallStackFrame Frame(Info, Callee->getLocation(), Callee, /*This*/0, + CallStackFrame Frame(Info, Callee->getLocation(), Callee, /*This*/nullptr, ArgValues.data()); return Evaluate(Value, Info, this) && !Info.EvalStatus.HasSideEffects; } @@ -8735,7 +8738,7 @@ bool Expr::isPotentialConstantExpr(const FunctionDecl *FD, EvalInfo::EM_PotentialConstantExpression); const CXXMethodDecl *MD = dyn_cast(FD); - const CXXRecordDecl *RD = MD ? MD->getParent()->getCanonicalDecl() : 0; + const CXXRecordDecl *RD = MD ? MD->getParent()->getCanonicalDecl() : nullptr; // Fabricate an arbitrary expression on the stack and pretend that it // is a temporary being used as the 'this' pointer. @@ -8754,7 +8757,7 @@ bool Expr::isPotentialConstantExpr(const FunctionDecl *FD, Info.setEvaluatingDecl(This.getLValueBase(), Scratch); HandleConstructorCall(Loc, This, Args, CD, Info, Scratch); } else - HandleFunctionCall(Loc, FD, (MD && MD->isInstance()) ? &This : 0, + HandleFunctionCall(Loc, FD, (MD && MD->isInstance()) ? &This : nullptr, Args, FD->getBody(), Info, Scratch); return Diags.empty(); @@ -8777,7 +8780,7 @@ bool Expr::isPotentialConstantExprUnevaluated(Expr *E, (void)Success; assert(Success && "Failed to set up arguments for potential constant evaluation"); - CallStackFrame Frame(Info, SourceLocation(), FD, 0, ArgValues.data()); + CallStackFrame Frame(Info, SourceLocation(), FD, nullptr, ArgValues.data()); APValue ResultScratch; Evaluate(ResultScratch, Info, E); diff --git a/lib/AST/ExternalASTSource.cpp b/lib/AST/ExternalASTSource.cpp index 96ebe92ce3..05a17db6bf 100644 --- a/lib/AST/ExternalASTSource.cpp +++ b/lib/AST/ExternalASTSource.cpp @@ -23,7 +23,7 @@ ExternalASTSource::~ExternalASTSource() { } void ExternalASTSource::PrintStats() { } Decl *ExternalASTSource::GetExternalDecl(uint32_t ID) { - return 0; + return nullptr; } Selector ExternalASTSource::GetExternalSelector(uint32_t ID) { @@ -35,12 +35,12 @@ uint32_t ExternalASTSource::GetNumExternalSelectors() { } Stmt *ExternalASTSource::GetExternalDeclStmt(uint64_t Offset) { - return 0; + return nullptr; } CXXBaseSpecifier * ExternalASTSource::GetExternalCXXBaseSpecifiers(uint64_t Offset) { - return 0; + return nullptr; } bool diff --git a/lib/AST/ItaniumMangle.cpp b/lib/AST/ItaniumMangle.cpp index 4a07fbf563..f1a16b5033 100644 --- a/lib/AST/ItaniumMangle.cpp +++ b/lib/AST/ItaniumMangle.cpp @@ -88,7 +88,7 @@ static const RecordDecl *GetLocalClassDecl(const Decl *D) { D = cast(DC); DC = getEffectiveDeclContext(D); } - return 0; + return nullptr; } static const FunctionDecl *getStructor(const FunctionDecl *fn) { @@ -253,7 +253,7 @@ class CXXNameMangler { public: CXXNameMangler(ItaniumMangleContextImpl &C, raw_ostream &Out_, - const NamedDecl *D = 0) + const NamedDecl *D = nullptr) : Context(C), Out(Out_), Structor(getStructor(D)), StructorType(0), SeqID(0) { // These can't be mangled without a ctor type or dtor type. @@ -559,7 +559,7 @@ isTemplate(const NamedDecl *ND, const TemplateArgumentList *&TemplateArgs) { return Spec->getSpecializedTemplate(); } - return 0; + return nullptr; } void CXXNameMangler::mangleName(const NamedDecl *ND) { @@ -586,7 +586,7 @@ void CXXNameMangler::mangleName(const NamedDecl *ND) { if (DC->isTranslationUnit() || isStdNamespace(DC)) { // Check if we have a template. - const TemplateArgumentList *TemplateArgs = 0; + const TemplateArgumentList *TemplateArgs = nullptr; if (const TemplateDecl *TD = isTemplate(ND, TemplateArgs)) { mangleUnscopedTemplateName(TD); mangleTemplateArgs(*TemplateArgs); @@ -1000,26 +1000,27 @@ void CXXNameMangler::mangleUnresolvedPrefix(NestedNameSpecifier *qualifier, // Pretend we had a different nested name specifier. newQualifier = NestedNameSpecifier::Create(getASTContext(), - /*prefix*/ 0, + /*prefix*/ nullptr, /*template*/ false, type.getTypePtr()); } else if (NamespaceDecl *nspace = dyn_cast(firstQualifierLookup)) { newQualifier = NestedNameSpecifier::Create(getASTContext(), - /*prefix*/ 0, + /*prefix*/ nullptr, nspace); } else if (NamespaceAliasDecl *alias = dyn_cast(firstQualifierLookup)) { newQualifier = NestedNameSpecifier::Create(getASTContext(), - /*prefix*/ 0, + /*prefix*/ nullptr, alias); } else { // No sensible mangling to do here. - newQualifier = 0; + newQualifier = nullptr; } if (newQualifier) - return mangleUnresolvedPrefix(newQualifier, /*lookup*/ 0, recursive); + return mangleUnresolvedPrefix(newQualifier, /*lookup*/ nullptr, + recursive); } else { Out << "sr"; @@ -1042,7 +1043,7 @@ void CXXNameMangler::mangleUnresolvedName(NestedNameSpecifier *qualifier, DeclarationName name, unsigned knownArity) { if (qualifier) mangleUnresolvedPrefix(qualifier, firstQualifierLookup); - mangleUnqualifiedName(0, name, knownArity); + mangleUnqualifiedName(nullptr, name, knownArity); } static const FieldDecl *FindFirstNamedDataMember(const RecordDecl *RD) { @@ -1057,10 +1058,10 @@ static const FieldDecl *FindFirstNamedDataMember(const RecordDecl *RD) { if (const FieldDecl *NamedDataMember = FindFirstNamedDataMember(RT->getDecl())) return NamedDataMember; - } + } // We didn't find a named data member. - return 0; + return nullptr; } void CXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND, @@ -1266,7 +1267,7 @@ void CXXNameMangler::mangleNestedName(const NamedDecl *ND, } // Check if we have a template. - const TemplateArgumentList *TemplateArgs = 0; + const TemplateArgumentList *TemplateArgs = nullptr; if (const TemplateDecl *TD = isTemplate(ND, TemplateArgs)) { mangleTemplatePrefix(TD, NoFunction); mangleTemplateArgs(*TemplateArgs); @@ -1506,7 +1507,7 @@ void CXXNameMangler::manglePrefix(const DeclContext *DC, bool NoFunction) { return; // Check if we have a template. - const TemplateArgumentList *TemplateArgs = 0; + const TemplateArgumentList *TemplateArgs = nullptr; if (const TemplateDecl *TD = isTemplate(ND, TemplateArgs)) { mangleTemplatePrefix(TD); mangleTemplateArgs(*TemplateArgs); @@ -1530,7 +1531,7 @@ void CXXNameMangler::mangleTemplatePrefix(TemplateName Template) { if (OverloadedTemplateStorage *Overloaded = Template.getAsOverloadedTemplate()) { - mangleUnqualifiedName(0, (*Overloaded->begin())->getDeclName(), + mangleUnqualifiedName(nullptr, (*Overloaded->begin())->getDeclName(), UnknownArity); return; } @@ -1572,8 +1573,8 @@ void CXXNameMangler::mangleTemplatePrefix(const TemplateDecl *ND, void CXXNameMangler::mangleType(TemplateName TN) { if (mangleSubstitution(TN)) return; - - TemplateDecl *TD = 0; + + TemplateDecl *TD = nullptr; switch (TN.getKind()) { case TemplateName::QualifiedTemplate: @@ -1600,7 +1601,7 @@ void CXXNameMangler::mangleType(TemplateName TN) { // ::= // ::= - mangleUnresolvedPrefix(Dependent->getQualifier(), 0); + mangleUnresolvedPrefix(Dependent->getQualifier(), nullptr); mangleSourceName(Dependent->getIdentifier()); break; } @@ -2172,7 +2173,7 @@ void CXXNameMangler::mangleType(const ComplexType *T) { void CXXNameMangler::mangleNeonVectorType(const VectorType *T) { QualType EltType = T->getElementType(); assert(EltType->isBuiltinType() && "Neon vector element not a BuiltinType"); - const char *EltName = 0; + const char *EltName = nullptr; if (T->getVectorKind() == VectorType::NeonPolyVector) { switch (cast(EltType)->getKind()) { case BuiltinType::SChar: @@ -2205,7 +2206,7 @@ void CXXNameMangler::mangleNeonVectorType(const VectorType *T) { llvm_unreachable("unexpected Neon vector element type"); } } - const char *BaseName = 0; + const char *BaseName = nullptr; unsigned BitSize = (T->getNumElements() * getASTContext().getTypeSize(EltType)); if (BitSize == 64) @@ -2769,15 +2770,15 @@ recurse: case Expr::MemberExprClass: { const MemberExpr *ME = cast(E); mangleMemberExpr(ME->getBase(), ME->isArrow(), - ME->getQualifier(), 0, ME->getMemberDecl()->getDeclName(), - Arity); + ME->getQualifier(), nullptr, + ME->getMemberDecl()->getDeclName(), Arity); break; } case Expr::UnresolvedMemberExprClass: { const UnresolvedMemberExpr *ME = cast(E); mangleMemberExpr(ME->getBase(), ME->isArrow(), - ME->getQualifier(), 0, ME->getMemberName(), + ME->getQualifier(), nullptr, ME->getMemberName(), Arity); if (ME->hasExplicitTemplateArgs()) mangleTemplateArgs(ME->getExplicitTemplateArgs()); @@ -2797,7 +2798,7 @@ recurse: case Expr::UnresolvedLookupExprClass: { const UnresolvedLookupExpr *ULE = cast(E); - mangleUnresolvedName(ULE->getQualifier(), 0, ULE->getName(), Arity); + mangleUnresolvedName(ULE->getQualifier(), nullptr, ULE->getName(), Arity); // All the productions end in a // base-unresolved-name, where are just tacked @@ -3060,7 +3061,8 @@ recurse: case Expr::DependentScopeDeclRefExprClass: { const DependentScopeDeclRefExpr *DRE = cast(E); - mangleUnresolvedName(DRE->getQualifier(), 0, DRE->getDeclName(), Arity); + mangleUnresolvedName(DRE->getQualifier(), nullptr, DRE->getDeclName(), + Arity); // All the productions end in a // base-unresolved-name, where are just tacked diff --git a/lib/AST/MangleNumberingContext.cpp b/lib/AST/MangleNumberingContext.cpp index b46a085dc9..5f40f0347d 100644 --- a/lib/AST/MangleNumberingContext.cpp +++ b/lib/AST/MangleNumberingContext.cpp @@ -33,13 +33,13 @@ MangleNumberingContext::getManglingNumber(const CXXMethodDecl *CallOperator) { unsigned MangleNumberingContext::getManglingNumber(const BlockDecl *BD) { // FIXME: Compute a BlockPointerType? Not obvious how. - const Type *Ty = 0; + const Type *Ty = nullptr; return ++ManglingNumbers[Ty]; } unsigned MangleNumberingContext::getStaticLocalNumber(const VarDecl *VD) { // FIXME: Compute a BlockPointerType? Not obvious how. - const Type *Ty = 0; + const Type *Ty = nullptr; return ++ManglingNumbers[Ty]; } diff --git a/lib/AST/MicrosoftMangle.cpp b/lib/AST/MicrosoftMangle.cpp index 8a85760975..618a5379e8 100644 --- a/lib/AST/MicrosoftMangle.cpp +++ b/lib/AST/MicrosoftMangle.cpp @@ -196,7 +196,7 @@ public: enum QualifierMangleMode { QMM_Drop, QMM_Mangle, QMM_Escape, QMM_Result }; MicrosoftCXXNameMangler(MicrosoftMangleContextImpl &C, raw_ostream &Out_) - : Context(C), Out(Out_), Structor(0), StructorType(-1), + : Context(C), Out(Out_), Structor(nullptr), StructorType(-1), UseNameBackReferences(true), PointersAre64Bit(C.getASTContext().getTargetInfo().getPointerWidth(0) == 64) {} @@ -223,7 +223,8 @@ public: void mangleNumber(int64_t Number); void mangleType(QualType T, SourceRange Range, QualifierMangleMode QMM = QMM_Mangle); - void mangleFunctionType(const FunctionType *T, const FunctionDecl *D = 0, + void mangleFunctionType(const FunctionType *T, + const FunctionDecl *D = nullptr, bool ForceInstMethod = false); void mangleNestedName(const NamedDecl *ND); @@ -415,7 +416,7 @@ void MicrosoftCXXNameMangler::mangleVariableEncoding(const VarDecl *VD) { Ty->isMemberPointerType()) { mangleType(Ty, TL.getSourceRange(), QMM_Drop); manglePointerExtQualifiers( - Ty.getDesugaredType(getASTContext()).getLocalQualifiers(), 0); + Ty.getDesugaredType(getASTContext()).getLocalQualifiers(), nullptr); if (const MemberPointerType *MPT = Ty->getAs()) { mangleQualifiers(MPT->getPointeeType().getQualifiers(), true); // Member pointers are suffixed with a back reference to the member @@ -621,7 +622,7 @@ isTemplate(const NamedDecl *ND, const TemplateArgumentList *&TemplateArgs) { return Spec->getSpecializedTemplate(); } - return 0; + return nullptr; } void MicrosoftCXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND, @@ -632,7 +633,7 @@ void MicrosoftCXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND, // ::= // Check if we have a template. - const TemplateArgumentList *TemplateArgs = 0; + const TemplateArgumentList *TemplateArgs = nullptr; if (const TemplateDecl *TD = isTemplate(ND, TemplateArgs)) { // Function templates aren't considered for name back referencing. This // makes sense since function templates aren't likely to occur multiple @@ -1063,7 +1064,7 @@ void MicrosoftCXXNameMangler::mangleExpression(const Expr *E) { return; } - const CXXUuidofExpr *UE = 0; + const CXXUuidofExpr *UE = nullptr; if (const UnaryOperator *UO = dyn_cast(E)) { if (UO->getOpcode() == UO_AddrOf) UE = dyn_cast(UO->getSubExpr()); @@ -1153,9 +1154,9 @@ void MicrosoftCXXNameMangler::mangleTemplateArg(const TemplateDecl *TD, if (const MemberPointerType *MPT = T->getAs()) { const CXXRecordDecl *RD = MPT->getMostRecentCXXRecordDecl(); if (MPT->isMemberFunctionPointerType()) - mangleMemberFunctionPointer(RD, 0); + mangleMemberFunctionPointer(RD, nullptr); else - mangleMemberDataPointer(RD, 0); + mangleMemberDataPointer(RD, nullptr); } else { Out << "$0A@"; } @@ -1538,7 +1539,7 @@ void MicrosoftCXXNameMangler::mangleFunctionType(const FunctionType *T, // this pointer. if (IsInstMethod) { Qualifiers Quals = Qualifiers::fromCVRMask(Proto->getTypeQuals()); - manglePointerExtQualifiers(Quals, 0); + manglePointerExtQualifiers(Quals, nullptr); mangleRefQualifier(Proto->getRefQualifier()); mangleQualifiers(Quals, false); } @@ -1810,7 +1811,7 @@ void MicrosoftCXXNameMangler::mangleType(const MemberPointerType *T, if (const FunctionProtoType *FPT = PointeeType->getAs()) { Out << '8'; mangleName(T->getClass()->castAs()->getDecl()); - mangleFunctionType(FPT, 0, true); + mangleFunctionType(FPT, nullptr, true); } else { mangleQualifiers(PointeeType.getQualifiers(), true); mangleName(T->getClass()->castAs()->getDecl()); @@ -2176,7 +2177,8 @@ void MicrosoftMangleContextImpl::mangleThunk(const CXXMethodDecl *MD, Mangler.mangleName(MD); mangleThunkThisAdjustment(MD, Thunk.This, Mangler, Out); if (!Thunk.Return.isEmpty()) - assert(Thunk.Method != 0 && "Thunk info should hold the overridee decl"); + assert(Thunk.Method != nullptr && + "Thunk info should hold the overridee decl"); const CXXMethodDecl *DeclForFPT = Thunk.Method ? Thunk.Method : MD; Mangler.mangleFunctionType( diff --git a/lib/AST/NSAPI.cpp b/lib/AST/NSAPI.cpp index a862630bbf..986b3b5398 100644 --- a/lib/AST/NSAPI.cpp +++ b/lib/AST/NSAPI.cpp @@ -14,9 +14,9 @@ using namespace clang; NSAPI::NSAPI(ASTContext &ctx) - : Ctx(ctx), ClassIds(), BOOLId(0), NSIntegerId(0), NSUIntegerId(0), - NSASCIIStringEncodingId(0), NSUTF8StringEncodingId(0) { -} + : Ctx(ctx), ClassIds(), BOOLId(nullptr), NSIntegerId(nullptr), + NSUIntegerId(nullptr), NSASCIIStringEncodingId(nullptr), + NSUTF8StringEncodingId(nullptr) {} IdentifierInfo *NSAPI::getNSClassId(NSClassIdKindKind K) const { static const char *ClassName[NumClassIds] = { diff --git a/lib/AST/NestedNameSpecifier.cpp b/lib/AST/NestedNameSpecifier.cpp index b03c4e09fa..e4b39b58ab 100644 --- a/lib/AST/NestedNameSpecifier.cpp +++ b/lib/AST/NestedNameSpecifier.cpp @@ -30,7 +30,7 @@ NestedNameSpecifier::FindOrInsert(const ASTContext &Context, llvm::FoldingSetNodeID ID; Mockup.Profile(ID); - void *InsertPos = 0; + void *InsertPos = nullptr; NestedNameSpecifier *NNS = Context.NestedNameSpecifiers.FindNodeOrInsertPos(ID, InsertPos); if (!NNS) { @@ -61,7 +61,8 @@ NestedNameSpecifier::Create(const ASTContext &Context, const NamespaceDecl *NS) { assert(NS && "Namespace cannot be NULL"); assert((!Prefix || - (Prefix->getAsType() == 0 && Prefix->getAsIdentifier() == 0)) && + (Prefix->getAsType() == nullptr && + Prefix->getAsIdentifier() == nullptr)) && "Broken nested name specifier"); NestedNameSpecifier Mockup; Mockup.Prefix.setPointer(Prefix); @@ -76,7 +77,8 @@ NestedNameSpecifier::Create(const ASTContext &Context, NamespaceAliasDecl *Alias) { assert(Alias && "Namespace alias cannot be NULL"); assert((!Prefix || - (Prefix->getAsType() == 0 && Prefix->getAsIdentifier() == 0)) && + (Prefix->getAsType() == nullptr && + Prefix->getAsIdentifier() == nullptr)) && "Broken nested name specifier"); NestedNameSpecifier Mockup; Mockup.Prefix.setPointer(Prefix); @@ -101,7 +103,7 @@ NestedNameSpecifier * NestedNameSpecifier::Create(const ASTContext &Context, IdentifierInfo *II) { assert(II && "Identifier cannot be NULL"); NestedNameSpecifier Mockup; - Mockup.Prefix.setPointer(0); + Mockup.Prefix.setPointer(nullptr); Mockup.Prefix.setInt(StoredIdentifier); Mockup.Specifier = II; return FindOrInsert(Context, Mockup); @@ -117,7 +119,7 @@ NestedNameSpecifier::GlobalSpecifier(const ASTContext &Context) { } NestedNameSpecifier::SpecifierKind NestedNameSpecifier::getKind() const { - if (Specifier == 0) + if (!Specifier) return Global; switch (Prefix.getInt()) { @@ -144,7 +146,7 @@ NamespaceDecl *NestedNameSpecifier::getAsNamespace() const { if (Prefix.getInt() == StoredNamespaceOrAlias) return dyn_cast(static_cast(Specifier)); - return 0; + return nullptr; } /// \brief Retrieve the namespace alias stored in this nested name @@ -153,7 +155,7 @@ NamespaceAliasDecl *NestedNameSpecifier::getAsNamespaceAlias() const { if (Prefix.getInt() == StoredNamespaceOrAlias) return dyn_cast(static_cast(Specifier)); - return 0; + return nullptr; } @@ -437,7 +439,7 @@ namespace { NestedNameSpecifierLocBuilder:: NestedNameSpecifierLocBuilder(const NestedNameSpecifierLocBuilder &Other) - : Representation(Other.Representation), Buffer(0), + : Representation(Other.Representation), Buffer(nullptr), BufferSize(0), BufferCapacity(0) { if (!Other.Buffer) @@ -477,7 +479,7 @@ operator=(const NestedNameSpecifierLocBuilder &Other) { if (!Other.Buffer) { // Empty. - Buffer = 0; + Buffer = nullptr; BufferSize = 0; return *this; } @@ -599,7 +601,7 @@ void NestedNameSpecifierLocBuilder::Adopt(NestedNameSpecifierLoc Other) { free(Buffer); if (!Other) { - Representation = 0; + Representation = nullptr; BufferSize = 0; return; } diff --git a/lib/AST/ParentMap.cpp b/lib/AST/ParentMap.cpp index ff44d938d3..a991302a25 100644 --- a/lib/AST/ParentMap.cpp +++ b/lib/AST/ParentMap.cpp @@ -37,7 +37,7 @@ static void BuildParentMap(MapTy& M, Stmt* S, // If we are rebuilding the map, clear out any existing state. if (M[POE->getSyntacticForm()]) for (Stmt::child_range I = S->children(); I; ++I) - M[*I] = 0; + M[*I] = nullptr; M[POE->getSyntacticForm()] = S; BuildParentMap(M, POE->getSyntacticForm(), OV_Transparent); @@ -92,7 +92,7 @@ static void BuildParentMap(MapTy& M, Stmt* S, } } -ParentMap::ParentMap(Stmt* S) : Impl(0) { +ParentMap::ParentMap(Stmt *S) : Impl(nullptr) { if (S) { MapTy *M = new MapTy(); BuildParentMap(*M, S); @@ -120,7 +120,7 @@ void ParentMap::setParent(const Stmt *S, const Stmt *Parent) { Stmt* ParentMap::getParent(Stmt* S) const { MapTy* M = (MapTy*) Impl; MapTy::iterator I = M->find(S); - return I == M->end() ? 0 : I->second; + return I == M->end() ? nullptr : I->second; } Stmt *ParentMap::getParentIgnoreParens(Stmt *S) const { @@ -146,7 +146,7 @@ Stmt *ParentMap::getParentIgnoreParenImpCasts(Stmt *S) const { } Stmt *ParentMap::getOuterParenParent(Stmt *S) const { - Stmt *Paren = 0; + Stmt *Paren = nullptr; while (isa(S)) { Paren = S; S = getParent(S); diff --git a/lib/AST/RecordLayout.cpp b/lib/AST/RecordLayout.cpp index 9d46cc60ca..38e28d44d0 100644 --- a/lib/AST/RecordLayout.cpp +++ b/lib/AST/RecordLayout.cpp @@ -35,8 +35,8 @@ ASTRecordLayout::ASTRecordLayout(const ASTContext &Ctx, CharUnits size, const uint64_t *fieldoffsets, unsigned fieldcount) : Size(size), DataSize(datasize), Alignment(alignment), - RequiredAlignment(requiredAlignment), FieldOffsets(0), - FieldCount(fieldcount), CXXInfo(0) { + RequiredAlignment(requiredAlignment), FieldOffsets(nullptr), + FieldCount(fieldcount), CXXInfo(nullptr) { if (FieldCount > 0) { FieldOffsets = new (Ctx) uint64_t[FieldCount]; memcpy(FieldOffsets, fieldoffsets, FieldCount * sizeof(*FieldOffsets)); @@ -63,7 +63,7 @@ ASTRecordLayout::ASTRecordLayout(const ASTContext &Ctx, const BaseOffsetsMapTy& BaseOffsets, const VBaseOffsetsMapTy& VBaseOffsets) : Size(size), DataSize(datasize), Alignment(alignment), - RequiredAlignment(requiredAlignment), FieldOffsets(0), + RequiredAlignment(requiredAlignment), FieldOffsets(nullptr), FieldCount(fieldcount), CXXInfo(new (Ctx) CXXRecordLayoutInfo) { if (FieldCount > 0) { diff --git a/lib/AST/RecordLayoutBuilder.cpp b/lib/AST/RecordLayoutBuilder.cpp index 91ce533c56..db64f315f9 100644 --- a/lib/AST/RecordLayoutBuilder.cpp +++ b/lib/AST/RecordLayoutBuilder.cpp @@ -634,9 +634,9 @@ protected: MaxFieldAlignment(CharUnits::Zero()), DataSize(0), NonVirtualSize(CharUnits::Zero()), NonVirtualAlignment(CharUnits::One()), - PrimaryBase(0), PrimaryBaseIsVirtual(false), + PrimaryBase(nullptr), PrimaryBaseIsVirtual(false), HasOwnVFPtr(false), - FirstNearlyEmptyVBase(0) { } + FirstNearlyEmptyVBase(nullptr) {} /// Reset this RecordLayoutBuilder to a fresh state, using the given /// alignment as the initial alignment. This is used for the @@ -866,11 +866,11 @@ RecordLayoutBuilder::ComputeBaseSubobjectInfo(const CXXRecordDecl *RD, Info->Class = RD; Info->IsVirtual = IsVirtual; - Info->Derived = 0; - Info->PrimaryVirtualBaseInfo = 0; - - const CXXRecordDecl *PrimaryVirtualBase = 0; - BaseSubobjectInfo *PrimaryVirtualBaseInfo = 0; + Info->Derived = nullptr; + Info->PrimaryVirtualBaseInfo = nullptr; + + const CXXRecordDecl *PrimaryVirtualBase = nullptr; + BaseSubobjectInfo *PrimaryVirtualBaseInfo = nullptr; // Check if this base has a primary virtual base. if (RD->getNumVBases()) { @@ -887,8 +887,8 @@ RecordLayoutBuilder::ComputeBaseSubobjectInfo(const CXXRecordDecl *RD, if (PrimaryVirtualBaseInfo->Derived) { // We did have info about this primary base, and it turns out that it // has already been claimed as a primary virtual base for another - // base. - PrimaryVirtualBase = 0; + // base. + PrimaryVirtualBase = nullptr; } else { // We can claim this base as our primary base. Info->PrimaryVirtualBaseInfo = PrimaryVirtualBaseInfo; @@ -929,7 +929,8 @@ void RecordLayoutBuilder::ComputeBaseSubobjectInfo(const CXXRecordDecl *RD) { const CXXRecordDecl *BaseDecl = I.getType()->getAsCXXRecordDecl(); // Compute the base subobject info for this base. - BaseSubobjectInfo *Info = ComputeBaseSubobjectInfo(BaseDecl, IsVirtual, 0); + BaseSubobjectInfo *Info = ComputeBaseSubobjectInfo(BaseDecl, IsVirtual, + nullptr); if (IsVirtual) { // ComputeBaseInfo has already added this base for us. @@ -976,8 +977,8 @@ RecordLayoutBuilder::LayoutNonVirtualBases(const CXXRecordDecl *RD) { // If the primary virtual base was a primary virtual base of some other // base class we'll have to steal it. BaseSubobjectInfo *PrimaryBaseInfo = VirtualBaseInfo.lookup(PrimaryBase); - PrimaryBaseInfo->Derived = 0; - + PrimaryBaseInfo->Derived = nullptr; + // We have a virtual primary base, insert it as an indirect primary base. IndirectPrimaryBases.insert(PrimaryBase); @@ -1935,13 +1936,13 @@ static const CXXMethodDecl *computeKeyFunction(ASTContext &Context, const CXXRecordDecl *RD) { // If a class isn't polymorphic it doesn't have a key function. if (!RD->isPolymorphic()) - return 0; + return nullptr; // A class that is not externally visible doesn't have a key function. (Or // at least, there's no point to assigning a key function to such a class; // this doesn't affect the ABI.) if (!RD->isExternallyVisible()) - return 0; + return nullptr; // Template instantiations don't have key functions per Itanium C++ ABI 5.2.6. // Same behavior as GCC. @@ -1949,7 +1950,7 @@ static const CXXMethodDecl *computeKeyFunction(ASTContext &Context, if (TSK == TSK_ImplicitInstantiation || TSK == TSK_ExplicitInstantiationDeclaration || TSK == TSK_ExplicitInstantiationDefinition) - return 0; + return nullptr; bool allowInlineFunctions = Context.getTargetInfo().getCXXABI().canKeyFunctionBeInline(); @@ -1987,7 +1988,7 @@ static const CXXMethodDecl *computeKeyFunction(ASTContext &Context, return MD; } - return 0; + return nullptr; } DiagnosticBuilder @@ -2354,8 +2355,8 @@ MicrosoftRecordLayoutBuilder::initializeCXXLayout(const CXXRecordDecl *RD) { LeadsWithZeroSizedBase = false; HasOwnVFPtr = false; HasVBPtr = false; - PrimaryBase = 0; - SharedVBPtrBase = 0; + PrimaryBase = nullptr; + SharedVBPtrBase = nullptr; // Calculate pointer size and alignment. These are used for vfptr and vbprt // injection. PointerInfo.Size = @@ -2374,7 +2375,7 @@ MicrosoftRecordLayoutBuilder::layoutNonVirtualBases(const CXXRecordDecl *RD) { // first. We use these passes to calculate some additional aggregated // information about the bases, such as reqruied alignment and the presence of // zero sized members. - const ASTRecordLayout* PreviousBaseLayout = 0; + const ASTRecordLayout *PreviousBaseLayout = nullptr; // Iterate through the bases and lay out the non-virtual ones. for (const auto &I : RD->bases()) { const CXXRecordDecl *BaseDecl = I.getType()->getAsCXXRecordDecl(); @@ -2611,7 +2612,7 @@ void MicrosoftRecordLayoutBuilder::layoutVirtualBases(const CXXRecordDecl *RD) { llvm::SmallPtrSet HasVtordispSet = computeVtorDispSet(RD); // Iterate through the virtual bases and lay them out. - const ASTRecordLayout* PreviousBaseLayout = 0; + const ASTRecordLayout *PreviousBaseLayout = nullptr; for (const auto &I : RD->vbases()) { const CXXRecordDecl *BaseDecl = I.getType()->getAsCXXRecordDecl(); const ASTRecordLayout &BaseLayout = Context.getASTRecordLayout(BaseDecl); @@ -2790,7 +2791,7 @@ ASTContext::getASTRecordLayout(const RecordDecl *D) const { const ASTRecordLayout *Entry = ASTRecordLayouts[D]; if (Entry) return *Entry; - const ASTRecordLayout *NewEntry = 0; + const ASTRecordLayout *NewEntry = nullptr; if (isMsLayout(D) && !D->getASTContext().getExternalSource()) { NewEntry = BuildMicrosoftASTRecordLayout(D); @@ -2826,10 +2827,10 @@ ASTContext::getASTRecordLayout(const RecordDecl *D) const { EmptySubobjects.SizeOfLargestEmptySubobject, Builder.PrimaryBase, Builder.PrimaryBaseIsVirtual, - 0, false, false, + nullptr, false, false, Builder.Bases, Builder.VBases); } else { - RecordLayoutBuilder Builder(*this, /*EmptySubobjects=*/0); + RecordLayoutBuilder Builder(*this, /*EmptySubobjects=*/nullptr); Builder.Layout(D); NewEntry = @@ -2854,7 +2855,7 @@ ASTContext::getASTRecordLayout(const RecordDecl *D) const { const CXXMethodDecl *ASTContext::getCurrentKeyFunction(const CXXRecordDecl *RD) { if (!getTargetInfo().getCXXABI().hasKeyFunctions()) - return 0; + return nullptr; assert(RD->getDefinition() && "Cannot get key function for forward decl!"); RD = cast(RD->getDefinition()); @@ -2935,10 +2936,10 @@ ASTContext::getObjCLayout(const ObjCInterfaceDecl *D, // entries later; however we shouldn't look up implementations // frequently. if (SynthCount == 0) - return getObjCLayout(D, 0); + return getObjCLayout(D, nullptr); } - RecordLayoutBuilder Builder(*this, /*EmptySubobjects=*/0); + RecordLayoutBuilder Builder(*this, /*EmptySubobjects=*/nullptr); Builder.Layout(D); const ASTRecordLayout *NewEntry = @@ -3090,7 +3091,7 @@ void ASTContext::DumpRecordLayout(const RecordDecl *RD, if (const CXXRecordDecl *CXXRD = dyn_cast(RD)) if (!Simple) - return DumpCXXRecordLayout(OS, CXXRD, *this, CharUnits(), 0, 0, + return DumpCXXRecordLayout(OS, CXXRD, *this, CharUnits(), 0, nullptr, /*IncludeVirtualBases=*/true); OS << "Type: " << getTypeDeclType(RD).getAsString() << "\n"; diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp index 8e937fb08b..e6468f760a 100644 --- a/lib/AST/Stmt.cpp +++ b/lib/AST/Stmt.cpp @@ -65,13 +65,13 @@ void Stmt::PrintStats() { unsigned sum = 0; llvm::errs() << "\n*** Stmt/Expr Stats:\n"; for (int i = 0; i != Stmt::lastStmtConstant+1; i++) { - if (StmtClassInfo[i].Name == 0) continue; + if (StmtClassInfo[i].Name == nullptr) continue; sum += StmtClassInfo[i].Counter; } llvm::errs() << " " << sum << " stmts/exprs total.\n"; sum = 0; for (int i = 0; i != Stmt::lastStmtConstant+1; i++) { - if (StmtClassInfo[i].Name == 0) continue; + if (StmtClassInfo[i].Name == nullptr) continue; if (StmtClassInfo[i].Counter == 0) continue; llvm::errs() << " " << StmtClassInfo[i].Counter << " " << StmtClassInfo[i].Name << ", " << StmtClassInfo[i].Size @@ -260,7 +260,7 @@ CompoundStmt::CompoundStmt(const ASTContext &C, ArrayRef Stmts, "NumStmts doesn't fit in bits of CompoundStmtBits.NumStmts!"); if (Stmts.size() == 0) { - Body = 0; + Body = nullptr; return; } @@ -554,7 +554,7 @@ unsigned GCCAsmStmt::AnalyzeAsmString(SmallVectorImpl&Pieces, // Find the ']'. const char *NameEnd = (const char*)memchr(CurPtr, ']', StrEnd-CurPtr); - if (NameEnd == 0) + if (NameEnd == nullptr) return diag::err_asm_unterminated_symbolic_operand_name; if (NameEnd == CurPtr) return diag::err_asm_empty_symbolic_operand_name; @@ -720,8 +720,7 @@ ObjCAtTryStmt::ObjCAtTryStmt(SourceLocation atTryLoc, Stmt *atTryStmt, Stmt **CatchStmts, unsigned NumCatchStmts, Stmt *atFinallyStmt) : Stmt(ObjCAtTryStmtClass), AtTryLoc(atTryLoc), - NumCatchStmts(NumCatchStmts), HasFinally(atFinallyStmt != 0) -{ + NumCatchStmts(NumCatchStmts), HasFinally(atFinallyStmt != nullptr) { Stmt **Stmts = getStmts(); Stmts[0] = atTryStmt; for (unsigned I = 0; I != NumCatchStmts; ++I) @@ -738,7 +737,7 @@ ObjCAtTryStmt *ObjCAtTryStmt::Create(const ASTContext &Context, unsigned NumCatchStmts, Stmt *atFinallyStmt) { unsigned Size = sizeof(ObjCAtTryStmt) + - (1 + NumCatchStmts + (atFinallyStmt != 0)) * sizeof(Stmt *); + (1 + NumCatchStmts + (atFinallyStmt != nullptr)) * sizeof(Stmt *); void *Mem = Context.Allocate(Size, llvm::alignOf()); return new (Mem) ObjCAtTryStmt(atTryLoc, atTryStmt, CatchStmts, NumCatchStmts, atFinallyStmt); @@ -833,7 +832,7 @@ IfStmt::IfStmt(const ASTContext &C, SourceLocation IL, VarDecl *var, Expr *cond, VarDecl *IfStmt::getConditionVariable() const { if (!SubExprs[VAR]) - return 0; + return nullptr; DeclStmt *DS = cast(SubExprs[VAR]); return cast(DS->getSingleDecl()); @@ -841,7 +840,7 @@ VarDecl *IfStmt::getConditionVariable() const { void IfStmt::setConditionVariable(const ASTContext &C, VarDecl *V) { if (!V) { - SubExprs[VAR] = 0; + SubExprs[VAR] = nullptr; return; } @@ -864,7 +863,7 @@ ForStmt::ForStmt(const ASTContext &C, Stmt *Init, Expr *Cond, VarDecl *condVar, VarDecl *ForStmt::getConditionVariable() const { if (!SubExprs[CONDVAR]) - return 0; + return nullptr; DeclStmt *DS = cast(SubExprs[CONDVAR]); return cast(DS->getSingleDecl()); @@ -872,7 +871,7 @@ VarDecl *ForStmt::getConditionVariable() const { void ForStmt::setConditionVariable(const ASTContext &C, VarDecl *V) { if (!V) { - SubExprs[CONDVAR] = 0; + SubExprs[CONDVAR] = nullptr; return; } @@ -882,16 +881,16 @@ void ForStmt::setConditionVariable(const ASTContext &C, VarDecl *V) { } SwitchStmt::SwitchStmt(const ASTContext &C, VarDecl *Var, Expr *cond) - : Stmt(SwitchStmtClass), FirstCase(0), AllEnumCasesCovered(0) + : Stmt(SwitchStmtClass), FirstCase(nullptr), AllEnumCasesCovered(0) { setConditionVariable(C, Var); SubExprs[COND] = cond; - SubExprs[BODY] = NULL; + SubExprs[BODY] = nullptr; } VarDecl *SwitchStmt::getConditionVariable() const { if (!SubExprs[VAR]) - return 0; + return nullptr; DeclStmt *DS = cast(SubExprs[VAR]); return cast(DS->getSingleDecl()); @@ -899,7 +898,7 @@ VarDecl *SwitchStmt::getConditionVariable() const { void SwitchStmt::setConditionVariable(const ASTContext &C, VarDecl *V) { if (!V) { - SubExprs[VAR] = 0; + SubExprs[VAR] = nullptr; return; } @@ -925,7 +924,7 @@ WhileStmt::WhileStmt(const ASTContext &C, VarDecl *Var, Expr *cond, Stmt *body, VarDecl *WhileStmt::getConditionVariable() const { if (!SubExprs[VAR]) - return 0; + return nullptr; DeclStmt *DS = cast(SubExprs[VAR]); return cast(DS->getSingleDecl()); @@ -933,7 +932,7 @@ VarDecl *WhileStmt::getConditionVariable() const { void WhileStmt::setConditionVariable(const ASTContext &C, VarDecl *V) { if (!V) { - SubExprs[VAR] = 0; + SubExprs[VAR] = nullptr; return; } @@ -947,7 +946,7 @@ LabelDecl *IndirectGotoStmt::getConstantTarget() { if (AddrLabelExpr *E = dyn_cast(getTarget()->IgnoreParenImpCasts())) return E->getLabel(); - return 0; + return nullptr; } // ReturnStmt @@ -1049,8 +1048,8 @@ CapturedStmt::CapturedStmt(Stmt *S, CapturedRegionKind Kind, CapturedStmt::CapturedStmt(EmptyShell Empty, unsigned NumCaptures) : Stmt(CapturedStmtClass, Empty), NumCaptures(NumCaptures), - CapDeclAndKind(0, CR_Default), TheRecordDecl(0) { - getStoredStmts()[NumCaptures] = 0; + CapDeclAndKind(nullptr, CR_Default), TheRecordDecl(nullptr) { + getStoredStmts()[NumCaptures] = nullptr; } CapturedStmt *CapturedStmt::Create(const ASTContext &Context, Stmt *S, diff --git a/lib/AST/StmtIterator.cpp b/lib/AST/StmtIterator.cpp index 6e85375ed2..1ccba04d9f 100644 --- a/lib/AST/StmtIterator.cpp +++ b/lib/AST/StmtIterator.cpp @@ -27,7 +27,7 @@ static inline const VariableArrayType *FindVA(const Type* t) { t = vt->getElementType().getTypePtr(); } - return NULL; + return nullptr; } void StmtIteratorBase::NextVA() { @@ -54,7 +54,7 @@ void StmtIteratorBase::NextVA() { } void StmtIteratorBase::NextDecl(bool ImmediateAdvance) { - assert (getVAPtr() == NULL); + assert(getVAPtr() == nullptr); assert(inDeclGroup()); if (ImmediateAdvance) @@ -93,12 +93,12 @@ bool StmtIteratorBase::HandleDecl(Decl* D) { } StmtIteratorBase::StmtIteratorBase(Decl** dgi, Decl** dge) - : stmt(0), DGI(dgi), RawVAPtr(DeclGroupMode), DGE(dge) { + : stmt(nullptr), DGI(dgi), RawVAPtr(DeclGroupMode), DGE(dge) { NextDecl(false); } StmtIteratorBase::StmtIteratorBase(const VariableArrayType* t) - : stmt(0), DGI(0), RawVAPtr(SizeOfTypeVAMode) { + : stmt(nullptr), DGI(nullptr), RawVAPtr(SizeOfTypeVAMode) { RawVAPtr |= reinterpret_cast(t); } diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp index 8cc2306b25..f3ecff9ad3 100644 --- a/lib/AST/StmtPrinter.cpp +++ b/lib/AST/StmtPrinter.cpp @@ -603,19 +603,19 @@ public: void OMPClausePrinter::VisitOMPIfClause(OMPIfClause *Node) { OS << "if("; - Node->getCondition()->printPretty(OS, 0, Policy, 0); + Node->getCondition()->printPretty(OS, nullptr, Policy, 0); OS << ")"; } void OMPClausePrinter::VisitOMPNumThreadsClause(OMPNumThreadsClause *Node) { OS << "num_threads("; - Node->getNumThreads()->printPretty(OS, 0, Policy, 0); + Node->getNumThreads()->printPretty(OS, nullptr, Policy, 0); OS << ")"; } void OMPClausePrinter::VisitOMPSafelenClause(OMPSafelenClause *Node) { OS << "safelen("; - Node->getSafelen()->printPretty(OS, 0, Policy, 0); + Node->getSafelen()->printPretty(OS, nullptr, Policy, 0); OS << ")"; } @@ -641,7 +641,7 @@ void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) { cast(DRE->getDecl())->printQualifiedName(OS); } else { OS << (I == Node->varlist_begin() ? StartSym : ','); - (*I)->printPretty(OS, 0, Policy, 0); + (*I)->printPretty(OS, nullptr, Policy, 0); } } } @@ -674,9 +674,9 @@ void OMPClausePrinter::VisitOMPLinearClause(OMPLinearClause *Node) { if (!Node->varlist_empty()) { OS << "linear"; VisitOMPClauseList(Node, '('); - if (Node->getStep() != 0) { + if (Node->getStep() != nullptr) { OS << ": "; - Node->getStep()->printPretty(OS, 0, Policy, 0); + Node->getStep()->printPretty(OS, nullptr, Policy, 0); } OS << ")"; } @@ -1069,7 +1069,7 @@ void StmtPrinter::VisitMemberExpr(MemberExpr *Node) { MemberExpr *ParentMember = dyn_cast(Node->getBase()); FieldDecl *ParentDecl = ParentMember - ? dyn_cast(ParentMember->getMemberDecl()) : NULL; + ? dyn_cast(ParentMember->getMemberDecl()) : nullptr; if (!ParentDecl || !ParentDecl->isAnonymousStructOrUnion()) OS << (Node->isArrow() ? "->" : "."); @@ -1261,7 +1261,7 @@ void StmtPrinter::VisitPseudoObjectExpr(PseudoObjectExpr *Node) { } void StmtPrinter::VisitAtomicExpr(AtomicExpr *Node) { - const char *Name = 0; + const char *Name = nullptr; switch (Node->getOp()) { #define BUILTIN(ID, TYPE, ATTRS) #define ATOMIC_BUILTIN(ID, TYPE, ATTRS) \ @@ -1473,7 +1473,7 @@ void StmtPrinter::VisitCXXThisExpr(CXXThisExpr *Node) { } void StmtPrinter::VisitCXXThrowExpr(CXXThrowExpr *Node) { - if (Node->getSubExpr() == 0) + if (!Node->getSubExpr()) OS << "throw"; else { OS << "throw "; @@ -1989,14 +1989,14 @@ void StmtPrinter::VisitAsTypeExpr(AsTypeExpr *Node) { //===----------------------------------------------------------------------===// void Stmt::dumpPretty(const ASTContext &Context) const { - printPretty(llvm::errs(), 0, PrintingPolicy(Context.getLangOpts())); + printPretty(llvm::errs(), nullptr, PrintingPolicy(Context.getLangOpts())); } void Stmt::printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation) const { - if (this == 0) { + if (this == nullptr) { OS << ""; return; } diff --git a/lib/AST/StmtProfile.cpp b/lib/AST/StmtProfile.cpp index e7db0e6fce..5dbaa0e832 100644 --- a/lib/AST/StmtProfile.cpp +++ b/lib/AST/StmtProfile.cpp @@ -558,7 +558,7 @@ void StmtProfiler::VisitGenericSelectionExpr(const GenericSelectionExpr *S) { for (unsigned i = 0; i != S->getNumAssocs(); ++i) { QualType T = S->getAssocType(i); if (T.isNull()) - ID.AddPointer(0); + ID.AddPointer(nullptr); else VisitType(T); VisitExpr(S->getAssocExpr(i)); @@ -952,10 +952,10 @@ StmtProfiler::VisitCXXPseudoDestructorExpr(const CXXPseudoDestructorExpr *S) { VisitExpr(S); ID.AddBoolean(S->isArrow()); VisitNestedNameSpecifier(S->getQualifier()); - ID.AddBoolean(S->getScopeTypeInfo() != 0); + ID.AddBoolean(S->getScopeTypeInfo() != nullptr); if (S->getScopeTypeInfo()) VisitType(S->getScopeTypeInfo()->getType()); - ID.AddBoolean(S->getDestroyedTypeInfo() != 0); + ID.AddBoolean(S->getDestroyedTypeInfo() != nullptr); if (S->getDestroyedTypeInfo()) VisitType(S->getDestroyedType()); else @@ -1216,7 +1216,7 @@ void StmtProfiler::VisitDecl(const Decl *D) { } } - ID.AddPointer(D? D->getCanonicalDecl() : 0); + ID.AddPointer(D? D->getCanonicalDecl() : nullptr); } void StmtProfiler::VisitType(QualType T) { diff --git a/lib/AST/TemplateBase.cpp b/lib/AST/TemplateBase.cpp index 52f95bf25a..d7ae73cf12 100644 --- a/lib/AST/TemplateBase.cpp +++ b/lib/AST/TemplateBase.cpp @@ -248,7 +248,7 @@ void TemplateArgument::Profile(llvm::FoldingSetNodeID &ID, break; case Declaration: - ID.AddPointer(getAsDecl()? getAsDecl()->getCanonicalDecl() : 0); + ID.AddPointer(getAsDecl()? getAsDecl()->getCanonicalDecl() : nullptr); break; case Template: @@ -386,7 +386,7 @@ void TemplateArgument::print(const PrintingPolicy &Policy, } case Expression: - getAsExpr()->printPretty(Out, 0, Policy); + getAsExpr()->printPretty(Out, nullptr, Policy); break; case Pack: @@ -489,7 +489,7 @@ const DiagnosticBuilder &clang::operator<<(const DiagnosticBuilder &DB, LangOptions LangOpts; LangOpts.CPlusPlus = true; PrintingPolicy Policy(LangOpts); - Arg.getAsExpr()->printPretty(OS, 0, Policy); + Arg.getAsExpr()->printPretty(OS, nullptr, Policy); return DB << OS.str(); } diff --git a/lib/AST/TemplateName.cpp b/lib/AST/TemplateName.cpp index 8767c635f6..77c8fd5d1e 100644 --- a/lib/AST/TemplateName.cpp +++ b/lib/AST/TemplateName.cpp @@ -78,7 +78,7 @@ TemplateDecl *TemplateName::getAsTemplateDecl() const { if (SubstTemplateTemplateParmStorage *sub = getAsSubstTemplateTemplateParm()) return sub->getReplacement().getAsTemplateDecl(); - return 0; + return nullptr; } bool TemplateName::isDependent() const { @@ -121,7 +121,7 @@ bool TemplateName::containsUnexpandedParameterPack() const { return DTN->getQualifier() && DTN->getQualifier()->containsUnexpandedParameterPack(); - return getAsSubstTemplateTemplateParmPack() != 0; + return getAsSubstTemplateTemplateParmPack() != nullptr; } void diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index e9002b4e87..c2d46742de 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -45,7 +45,7 @@ bool Qualifiers::isStrictSupersetOf(Qualifiers Other) const { const IdentifierInfo* QualType::getBaseTypeIdentifier() const { const Type* ty = getTypePtr(); - NamedDecl *ND = NULL; + NamedDecl *ND = nullptr; if (ty->isPointerType() || ty->isReferenceType()) return ty->getPointeeType().getBaseTypeIdentifier(); else if (ty->isRecordType()) @@ -60,7 +60,7 @@ const IdentifierInfo* QualType::getBaseTypeIdentifier() const { if (ND) return ND->getIdentifier(); - return NULL; + return nullptr; } bool QualType::isConstant(QualType T, ASTContext &Ctx) { @@ -202,7 +202,7 @@ const Type *Type::getArrayElementTypeNoTypeQual() const { // If the canonical form of this type isn't the right kind, reject it. if (!isa(CanonicalType)) - return 0; + return nullptr; // If this is a typedef for an array type, strip the typedef off without // losing all typedef information. @@ -410,7 +410,7 @@ const ComplexType *Type::getAsComplexIntegerType() const { if (const ComplexType *Complex = getAs()) if (Complex->getElementType()->isIntegerType()) return Complex; - return 0; + return nullptr; } QualType Type::getPointeeType() const { @@ -439,13 +439,13 @@ const RecordType *Type::getAsStructureType() const { // If the canonical form of this type isn't the right kind, reject it. if (const RecordType *RT = dyn_cast(CanonicalType)) { if (!RT->getDecl()->isStruct()) - return 0; + return nullptr; // If this is a typedef for a structure type, strip the typedef off without // losing all typedef information. return cast(getUnqualifiedDesugaredType()); } - return 0; + return nullptr; } const RecordType *Type::getAsUnionType() const { @@ -458,14 +458,14 @@ const RecordType *Type::getAsUnionType() const { // If the canonical form of this type isn't the right kind, reject it. if (const RecordType *RT = dyn_cast(CanonicalType)) { if (!RT->getDecl()->isUnion()) - return 0; + return nullptr; // If this is a typedef for a union type, strip the typedef off without // losing all typedef information. return cast(getUnqualifiedDesugaredType()); } - return 0; + return nullptr; } ObjCObjectType::ObjCObjectType(QualType Canonical, QualType Base, @@ -489,11 +489,11 @@ const ObjCObjectType *Type::getAsObjCQualifiedInterfaceType() const { if (const ObjCObjectType *T = getAs()) if (T->getNumProtocols() && T->getInterface()) return T; - return 0; + return nullptr; } bool Type::isObjCQualifiedInterfaceType() const { - return getAsObjCQualifiedInterfaceType() != 0; + return getAsObjCQualifiedInterfaceType() != nullptr; } const ObjCObjectPointerType *Type::getAsObjCQualifiedIdType() const { @@ -503,7 +503,7 @@ const ObjCObjectPointerType *Type::getAsObjCQualifiedIdType() const { if (OPT->isObjCQualifiedIdType()) return OPT; } - return 0; + return nullptr; } const ObjCObjectPointerType *Type::getAsObjCQualifiedClassType() const { @@ -513,7 +513,7 @@ const ObjCObjectPointerType *Type::getAsObjCQualifiedClassType() const { if (OPT->isObjCQualifiedClassType()) return OPT; } - return 0; + return nullptr; } const ObjCObjectPointerType *Type::getAsObjCInterfacePointerType() const { @@ -521,7 +521,7 @@ const ObjCObjectPointerType *Type::getAsObjCInterfacePointerType() const { if (OPT->getInterfaceType()) return OPT; } - return 0; + return nullptr; } const CXXRecordDecl *Type::getPointeeCXXRecordDecl() const { @@ -531,12 +531,12 @@ const CXXRecordDecl *Type::getPointeeCXXRecordDecl() const { else if (const ReferenceType *RT = getAs()) PointeeType = RT->getPointeeType(); else - return 0; + return nullptr; if (const RecordType *RT = PointeeType->getAs()) return dyn_cast(RT->getDecl()); - return 0; + return nullptr; } CXXRecordDecl *Type::getAsCXXRecordDecl() const { @@ -545,8 +545,8 @@ CXXRecordDecl *Type::getAsCXXRecordDecl() const { else if (const InjectedClassNameType *Injected = getAs()) return Injected->getDecl(); - - return 0; + + return nullptr; } namespace { @@ -556,7 +556,7 @@ namespace { using TypeVisitor::Visit; AutoType *Visit(QualType T) { if (T.isNull()) - return 0; + return nullptr; return Visit(T.getTypePtr()); } @@ -695,7 +695,7 @@ bool Type::isChar32Type() const { /// types. bool Type::isAnyCharacterType() const { const BuiltinType *BT = dyn_cast(CanonicalType); - if (BT == 0) return false; + if (!BT) return false; switch (BT->getKind()) { default: return false; case BuiltinType::Char_U: @@ -901,8 +901,8 @@ bool Type::isConstantSizeType() const { /// determine its size. bool Type::isIncompleteType(NamedDecl **Def) const { if (Def) - *Def = 0; - + *Def = nullptr; + switch (CanonicalType->getTypeClass()) { default: return false; case Builtin: @@ -1598,8 +1598,9 @@ FunctionProtoType::FunctionProtoType(QualType result, ArrayRef params, result->containsUnexpandedParameterPack(), epi.ExtInfo), NumParams(params.size()), NumExceptions(epi.NumExceptions), ExceptionSpecType(epi.ExceptionSpecType), - HasAnyConsumedParams(epi.ConsumedParameters != 0), Variadic(epi.Variadic), - HasTrailingReturn(epi.HasTrailingReturn), RefQualifier(epi.RefQualifier) { + HasAnyConsumedParams(epi.ConsumedParameters != nullptr), + Variadic(epi.Variadic), HasTrailingReturn(epi.HasTrailingReturn), + RefQualifier(epi.RefQualifier) { assert(NumParams == params.size() && "function has too many parameters"); // Fill in the trailing argument array. @@ -1682,7 +1683,7 @@ FunctionProtoType::getNoexceptSpec(const ASTContext &ctx) const { return NR_Dependent; llvm::APSInt value; - bool isICE = noexceptExpr->isIntegerConstantExpr(value, ctx, 0, + bool isICE = noexceptExpr->isIntegerConstantExpr(value, ctx, nullptr, /*evaluated*/false); (void)isICE; assert(isICE && "AST should not contain bad noexcept expressions."); @@ -1923,7 +1924,7 @@ CXXRecordDecl *InjectedClassNameType::getDecl() const { } IdentifierInfo *TemplateTypeParmType::getIdentifier() const { - return isCanonicalUnqualified() ? 0 : getDecl()->getIdentifier(); + return isCanonicalUnqualified() ? nullptr : getDecl()->getIdentifier(); } SubstTemplateTypeParmPackType:: diff --git a/lib/AST/TypeLoc.cpp b/lib/AST/TypeLoc.cpp index 22a51bc345..208d695632 100644 --- a/lib/AST/TypeLoc.cpp +++ b/lib/AST/TypeLoc.cpp @@ -55,7 +55,7 @@ namespace { /// \brief Returns the alignment of the type source info data block. unsigned TypeLoc::getLocalAlignmentForType(QualType Ty) { if (Ty.isNull()) return 1; - return TypeAligner().Visit(TypeLoc(Ty, 0)); + return TypeAligner().Visit(TypeLoc(Ty, nullptr)); } namespace { @@ -73,7 +73,7 @@ namespace { /// \brief Returns the size of the type source info data block. unsigned TypeLoc::getFullDataSizeForType(QualType Ty) { unsigned Total = 0; - TypeLoc TyLoc(Ty, 0); + TypeLoc TyLoc(Ty, nullptr); unsigned MaxAlign = 1; while (!TyLoc.isNull()) { unsigned Align = getLocalAlignmentForType(TyLoc.getType()); diff --git a/lib/AST/TypePrinter.cpp b/lib/AST/TypePrinter.cpp index 89ec8d6bbc..dfb43a0a84 100644 --- a/lib/AST/TypePrinter.cpp +++ b/lib/AST/TypePrinter.cpp @@ -466,7 +466,7 @@ void TypePrinter::printVariableArrayAfter(const VariableArrayType *T, OS << '*'; if (T->getSizeExpr()) - T->getSizeExpr()->printPretty(OS, 0, Policy); + T->getSizeExpr()->printPretty(OS, nullptr, Policy); OS << ']'; printAfter(T->getElementType(), OS); @@ -501,7 +501,7 @@ void TypePrinter::printDependentSizedArrayAfter( raw_ostream &OS) { OS << '['; if (T->getSizeExpr()) - T->getSizeExpr()->printPretty(OS, 0, Policy); + T->getSizeExpr()->printPretty(OS, nullptr, Policy); OS << ']'; printAfter(T->getElementType(), OS); } @@ -516,7 +516,7 @@ void TypePrinter::printDependentSizedExtVectorAfter( raw_ostream &OS) { OS << " __attribute__((ext_vector_type("; if (T->getSizeExpr()) - T->getSizeExpr()->printPretty(OS, 0, Policy); + T->getSizeExpr()->printPretty(OS, nullptr, Policy); OS << ")))"; printAfter(T->getElementType(), OS); } @@ -593,7 +593,7 @@ FunctionProtoType::printExceptionSpecification(raw_ostream &OS, OS << " noexcept"; if (getExceptionSpecType() == EST_ComputedNoexcept) { OS << '('; - getNoexceptExpr()->printPretty(OS, 0, Policy); + getNoexceptExpr()->printPretty(OS, nullptr, Policy); OS << ')'; } } @@ -761,7 +761,7 @@ void TypePrinter::printTypedefAfter(const TypedefType *T, raw_ostream &OS) { } void TypePrinter::printTypeOfExprBefore(const TypeOfExprType *T, raw_ostream &OS) { OS << "typeof "; - T->getUnderlyingExpr()->printPretty(OS, 0, Policy); + T->getUnderlyingExpr()->printPretty(OS, nullptr, Policy); spaceBeforePlaceHolder(OS); } void TypePrinter::printTypeOfExprAfter(const TypeOfExprType *T, @@ -777,7 +777,7 @@ void TypePrinter::printTypeOfAfter(const TypeOfType *T, raw_ostream &OS) { } void TypePrinter::printDecltypeBefore(const DecltypeType *T, raw_ostream &OS) { OS << "decltype("; - T->getUnderlyingExpr()->printPretty(OS, 0, Policy); + T->getUnderlyingExpr()->printPretty(OS, nullptr, Policy); OS << ')'; spaceBeforePlaceHolder(OS); } @@ -1424,7 +1424,7 @@ void QualType::dump(const char *msg) const { llvm::errs() << '\n'; } -LLVM_DUMP_METHOD void QualType::dump() const { dump(0); } +LLVM_DUMP_METHOD void QualType::dump() const { dump(nullptr); } LLVM_DUMP_METHOD void Type::dump() const { QualType(this, 0).dump(); } diff --git a/lib/AST/VTableBuilder.cpp b/lib/AST/VTableBuilder.cpp index b45f2aa252..6dc3956157 100644 --- a/lib/AST/VTableBuilder.cpp +++ b/lib/AST/VTableBuilder.cpp @@ -44,9 +44,9 @@ struct BaseOffset { /// path from the derived class to the base class involves a virtual base /// class. CharUnits NonVirtualOffset; - - BaseOffset() : DerivedClass(0), VirtualBase(0), - NonVirtualOffset(CharUnits::Zero()) { } + + BaseOffset() : DerivedClass(nullptr), VirtualBase(nullptr), + NonVirtualOffset(CharUnits::Zero()) { } BaseOffset(const CXXRecordDecl *DerivedClass, const CXXRecordDecl *VirtualBase, CharUnits NonVirtualOffset) : DerivedClass(DerivedClass), VirtualBase(VirtualBase), @@ -70,8 +70,9 @@ public: /// Offset - the base offset of the overrider's parent in the layout class. CharUnits Offset; - - OverriderInfo() : Method(0), VirtualBase(0), Offset(CharUnits::Zero()) { } + + OverriderInfo() : Method(nullptr), VirtualBase(nullptr), + Offset(CharUnits::Zero()) { } }; private: @@ -221,8 +222,8 @@ static BaseOffset ComputeBaseOffset(ASTContext &Context, CharUnits NonVirtualOffset = CharUnits::Zero(); unsigned NonVirtualStart = 0; - const CXXRecordDecl *VirtualBase = 0; - + const CXXRecordDecl *VirtualBase = nullptr; + // First, look for the virtual base class. for (int I = Path.size(), E = 0; I != E; --I) { const CXXBasePathElement &Element = Path[I - 1]; @@ -1295,7 +1296,7 @@ ThisAdjustment ItaniumVTableBuilder::ComputeThisAdjustment( // We don't have vcall offsets for this virtual base, go ahead and // build them. VCallAndVBaseOffsetBuilder Builder(MostDerivedClass, MostDerivedClass, - /*FinalOverriders=*/0, + /*FinalOverriders=*/nullptr, BaseSubobject(Offset.VirtualBase, CharUnits::Zero()), /*BaseIsVirtual=*/true, @@ -1449,8 +1450,8 @@ FindNearestOverriddenMethod(const CXXMethodDecl *MD, return OverriddenMD; } } - - return 0; + + return nullptr; } void ItaniumVTableBuilder::AddMethods( @@ -1504,7 +1505,7 @@ void ItaniumVTableBuilder::AddMethods( llvm_unreachable("Found a duplicate primary base!"); } - const CXXDestructorDecl *ImplicitVirtualDtor = 0; + const CXXDestructorDecl *ImplicitVirtualDtor = nullptr; typedef llvm::SmallVector NewVirtualFunctionsTy; NewVirtualFunctionsTy NewVirtualFunctions; @@ -2143,7 +2144,7 @@ void ItaniumVTableBuilder::dumpLayout(raw_ostream &Out) { ThunkInfoVectorTy ThunksVector = Thunks[MD]; std::sort(ThunksVector.begin(), ThunksVector.end(), [](const ThunkInfo &LHS, const ThunkInfo &RHS) { - assert(LHS.Method == 0 && RHS.Method == 0); + assert(LHS.Method == nullptr && RHS.Method == nullptr); return std::tie(LHS.This, LHS.Return) < std::tie(RHS.This, RHS.Return); }); @@ -2289,8 +2290,8 @@ ItaniumVTableContext::getVirtualBaseOffsetOffset(const CXXRecordDecl *RD, VirtualBaseClassOffsetOffsets.find(ClassPair); if (I != VirtualBaseClassOffsetOffsets.end()) return I->second; - - VCallAndVBaseOffsetBuilder Builder(RD, RD, /*FinalOverriders=*/0, + + VCallAndVBaseOffsetBuilder Builder(RD, RD, /*FinalOverriders=*/nullptr, BaseSubobject(RD, CharUnits::Zero()), /*BaseIsVirtual=*/false, /*OffsetInLayoutClass=*/CharUnits::Zero()); @@ -2534,7 +2535,7 @@ private: // pointing to the middle of a section. BasesSetVectorTy VisitedBases; - AddMethods(BaseSubobject(MostDerivedClass, CharUnits::Zero()), 0, 0, + AddMethods(BaseSubobject(MostDerivedClass, CharUnits::Zero()), 0, nullptr, VisitedBases); assert(Components.size() && "vftable can't be empty"); @@ -2815,7 +2816,7 @@ void VFTableBuilder::AddMethods(BaseSubobject Base, unsigned BaseDepth, // See if this class expands a vftable of the base we look at, which is either // the one defined by the vfptr base path or the primary base of the current class. - const CXXRecordDecl *NextBase = 0, *NextLastVBase = LastVBase; + const CXXRecordDecl *NextBase = nullptr, *NextLastVBase = LastVBase; CharUnits NextBaseOffset; if (BaseDepth < WhichVFPtr.PathToBaseWithVPtr.size()) { NextBase = WhichVFPtr.PathToBaseWithVPtr[BaseDepth]; @@ -2944,7 +2945,7 @@ void VFTableBuilder::AddMethods(BaseSubobject Base, unsigned BaseDepth, } AddMethod(OverriderMD, ThunkInfo(ThisAdjustmentOffset, ReturnAdjustment, - ReturnAdjustingThunk ? MD : 0)); + ReturnAdjustingThunk ? MD : nullptr)); } } @@ -3236,7 +3237,7 @@ void MicrosoftVTableContext::computeVTablePaths(bool ForVBTables, static bool extendPath(VPtrInfo *P) { if (P->NextBaseToMangle) { P->MangledPath.push_back(P->NextBaseToMangle); - P->NextBaseToMangle = 0; // Prevent the path from being extended twice. + P->NextBaseToMangle = nullptr;// Prevent the path from being extended twice. return true; } return false; -- 2.40.0