From: Craig Topper Date: Mon, 9 Jun 2014 02:04:02 +0000 (+0000) Subject: [C++11] Use 'nullptr'. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e4fb2d3430ca2002316f9f0c9374f2c0b749d151;p=clang [C++11] Use 'nullptr'. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210448 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Sema/SemaInternal.h b/include/clang/Sema/SemaInternal.h index 4ee10478e4..114211b840 100644 --- a/include/clang/Sema/SemaInternal.h +++ b/include/clang/Sema/SemaInternal.h @@ -27,8 +27,8 @@ inline PartialDiagnostic Sema::PDiag(unsigned DiagID) { inline bool FTIHasSingleVoidParameter(const DeclaratorChunk::FunctionTypeInfo &FTI) { - return FTI.NumParams == 1 && !FTI.isVariadic && FTI.Params[0].Ident == 0 && - FTI.Params[0].Param && + return FTI.NumParams == 1 && !FTI.isVariadic && + FTI.Params[0].Ident == nullptr && FTI.Params[0].Param && cast(FTI.Params[0].Param)->getType()->isVoidType(); } diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index f682c2c04a..7c2c739cf6 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -2276,7 +2276,7 @@ static const Expr *isSimpleArrayDecayOperand(const Expr *E) { // If this isn't just an array->pointer decay, bail out. const auto *CE = dyn_cast(E); if (!CE || CE->getCastKind() != CK_ArrayToPointerDecay) - return 0; + return nullptr; // If this is a decay from variable width array, bail out. const Expr *SubExpr = CE->getSubExpr(); diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 9cb84f890a..b2d87db488 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -563,7 +563,7 @@ void CodeGenModule::AddGlobalCtor(llvm::Function *Ctor, int Priority, /// when the module is unloaded. void CodeGenModule::AddGlobalDtor(llvm::Function *Dtor, int Priority) { // FIXME: Type coercion of void()* types. - GlobalDtors.push_back(Structor(Priority, Dtor, 0)); + GlobalDtors.push_back(Structor(Priority, Dtor, nullptr)); } void CodeGenModule::EmitCtorList(const CtorList &Fns, const char *GlobalName) { diff --git a/lib/CodeGen/MicrosoftRTTI.cpp b/lib/CodeGen/MicrosoftRTTI.cpp index 12f7f59b57..bc0c1f6081 100644 --- a/lib/CodeGen/MicrosoftRTTI.cpp +++ b/lib/CodeGen/MicrosoftRTTI.cpp @@ -117,7 +117,7 @@ static llvm::GlobalVariable *getTypeInfoVTable(CodeGenModule &CGM) { return new llvm::GlobalVariable(CGM.getModule(), CGM.Int8PtrTy, /*Constant=*/true, llvm::GlobalVariable::ExternalLinkage, - /*Initializer=*/0, MangledName); + /*Initializer=*/nullptr, MangledName); } namespace { @@ -154,7 +154,7 @@ uint32_t MSRTTIClass::initialize(const MSRTTIClass *Parent, const CXXBaseSpecifier *Specifier) { Flags = HasHierarchyDescriptor; if (!Parent) { - VirtualRoot = 0; + VirtualRoot = nullptr; OffsetInVBase = 0; } else { if (Specifier->getAccessSpecifier() != AS_public) @@ -259,7 +259,7 @@ llvm::GlobalVariable *MSRTTIBuilder::getClassHierarchyDescriptor() { // Serialize the class hierarchy and initialize the CHD Fields. SmallVector Classes; serializeClassHierarchy(Classes, RD); - Classes.front().initialize(/*Parent=*/0, /*Specifier=*/0); + Classes.front().initialize(/*Parent=*/nullptr, /*Specifier=*/nullptr); detectAmbiguousBases(Classes); int Flags = 0; for (auto Class : Classes) { @@ -280,7 +280,8 @@ llvm::GlobalVariable *MSRTTIBuilder::getClassHierarchyDescriptor() { // Forward-declare the class hierarchy descriptor auto Type = getClassHierarchyDescriptorType(CGM); auto CHD = new llvm::GlobalVariable(Module, Type, /*Constant=*/true, Linkage, - /*Initializer=*/0, MangledName.c_str()); + /*Initializer=*/nullptr, + MangledName.c_str()); // Initialize the base class ClassHierarchyDescriptor. llvm::Constant *Fields[] = { @@ -310,7 +311,7 @@ MSRTTIBuilder::getBaseClassArray(SmallVectorImpl &Classes) { auto PtrType = getBaseClassDescriptorType(CGM)->getPointerTo(); auto ArrayType = llvm::ArrayType::get(PtrType, Classes.size() + 1); auto BCA = new llvm::GlobalVariable(Module, ArrayType, - /*Constant=*/true, Linkage, /*Initializer=*/0, MangledName.c_str()); + /*Constant=*/true, Linkage, /*Initializer=*/nullptr, MangledName.c_str()); // Initialize the BaseClassArray. SmallVector BaseClassArrayData; @@ -348,7 +349,8 @@ MSRTTIBuilder::getBaseClassDescriptor(const MSRTTIClass &Class) { // Forward-declare the base class descriptor. auto Type = getBaseClassDescriptorType(CGM); auto BCD = new llvm::GlobalVariable(Module, Type, /*Constant=*/true, Linkage, - /*Initializer=*/0, MangledName.c_str()); + /*Initializer=*/nullptr, + MangledName.c_str()); // Initialize the BaseClassDescriptor. llvm::Constant *Fields[] = { @@ -389,7 +391,7 @@ MSRTTIBuilder::getCompleteObjectLocator(const VPtrInfo *Info) { // Forward-declare the complete object locator. llvm::StructType *Type = getCompleteObjectLocatorType(CGM); auto COL = new llvm::GlobalVariable(Module, Type, /*Constant=*/true, Linkage, - /*Initializer=*/0, MangledName.c_str()); + /*Initializer=*/nullptr, MangledName.c_str()); // Initialize the CompleteObjectLocator. llvm::Constant *Fields[] = { diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index a61c6b880d..e6aa61dddb 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -835,7 +835,7 @@ private: /// \brief Determine whether ')' is ending a cast. bool rParenEndsCast(const FormatToken &Tok) { - FormatToken *LeftOfParens = NULL; + FormatToken *LeftOfParens = nullptr; if (Tok.MatchingParen) LeftOfParens = Tok.MatchingParen->getPreviousNonComment(); bool IsCast = false; @@ -858,8 +858,9 @@ private: IsCast = true; // If there is an identifier after the (), it is likely a cast, unless // there is also an identifier before the (). - else if (LeftOfParens && (LeftOfParens->Tok.getIdentifierInfo() == NULL || - LeftOfParens->is(tok::kw_return)) && + else if (LeftOfParens && + (LeftOfParens->Tok.getIdentifierInfo() == nullptr || + LeftOfParens->is(tok::kw_return)) && LeftOfParens->Type != TT_OverloadedOperator && LeftOfParens->isNot(tok::at) && LeftOfParens->Type != TT_TemplateCloser && Tok.Next) { diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp index b561636a16..aead148b66 100644 --- a/lib/Lex/Preprocessor.cpp +++ b/lib/Lex/Preprocessor.cpp @@ -60,7 +60,7 @@ Preprocessor::Preprocessor(IntrusiveRefCntPtr PPOpts, ModuleLoader &TheModuleLoader, IdentifierInfoLookup *IILookup, bool OwnsHeaders, TranslationUnitKind TUKind) - : PPOpts(PPOpts), Diags(&diags), LangOpts(opts), Target(0), + : PPOpts(PPOpts), Diags(&diags), LangOpts(opts), Target(nullptr), FileMgr(Headers.getFileMgr()), SourceMgr(SM), HeaderInfo(Headers), TheModuleLoader(TheModuleLoader), ExternalSource(nullptr), Identifiers(opts, IILookup), IncrementalProcessing(false), TUKind(TUKind), @@ -70,7 +70,7 @@ Preprocessor::Preprocessor(IntrusiveRefCntPtr PPOpts, SkipMainFilePreamble(0, true), CurPPLexer(nullptr), CurDirLookup(nullptr), CurLexerKind(CLK_Lexer), CurSubmodule(nullptr), Callbacks(nullptr), MacroArgCache(nullptr), Record(nullptr), - MIChainHead(nullptr), MICache(nullptr), DeserialMIChainHead(0) { + MIChainHead(nullptr), MICache(nullptr), DeserialMIChainHead(nullptr) { OwnsHeaderSearch = OwnsHeaders; ScratchBuf = new ScratchBuffer(SourceMgr); diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp index 7b353e085b..8ed5c984fd 100644 --- a/lib/Parse/ParseStmt.cpp +++ b/lib/Parse/ParseStmt.cpp @@ -1766,8 +1766,8 @@ StmtResult Parser::ParsePragmaLoopHint(StmtVector &Stmts, bool OnlyStatement, ArgsUnion ArgHints[] = {Hint.OptionLoc, Hint.ValueLoc, ArgsUnion(Hint.ValueExpr)}; // FIXME: Replace AS_Keyword with Pragma spelling AS_Pragma. - TempAttrs.addNew(Hint.LoopLoc->Ident, Hint.Range, 0, Hint.LoopLoc->Loc, - ArgHints, 3, AttributeList::AS_Keyword); + TempAttrs.addNew(Hint.LoopLoc->Ident, Hint.Range, nullptr, + Hint.LoopLoc->Loc, ArgHints, 3, AttributeList::AS_Keyword); } // Get the next statement. diff --git a/lib/Sema/DeclSpec.cpp b/lib/Sema/DeclSpec.cpp index 69415ce34d..d7372b7a27 100644 --- a/lib/Sema/DeclSpec.cpp +++ b/lib/Sema/DeclSpec.cpp @@ -178,7 +178,7 @@ DeclaratorChunk DeclaratorChunk::getFunction(bool hasProto, I.Kind = Function; I.Loc = LocalRangeBegin; I.EndLoc = LocalRangeEnd; - I.Fun.AttrList = 0; + I.Fun.AttrList = nullptr; I.Fun.hasPrototype = hasProto; I.Fun.isVariadic = EllipsisLoc.isValid(); I.Fun.isAmbiguous = isAmbiguous; @@ -188,7 +188,7 @@ DeclaratorChunk DeclaratorChunk::getFunction(bool hasProto, I.Fun.DeleteParams = false; I.Fun.TypeQuals = TypeQuals; I.Fun.NumParams = NumParams; - I.Fun.Params = 0; + I.Fun.Params = nullptr; I.Fun.RefQualifierIsLValueRef = RefQualifierIsLvalueRef; I.Fun.RefQualifierLoc = RefQualifierLoc.getRawEncoding(); I.Fun.ConstQualifierLoc = ConstQualifierLoc.getRawEncoding(); @@ -197,8 +197,8 @@ DeclaratorChunk DeclaratorChunk::getFunction(bool hasProto, I.Fun.ExceptionSpecType = ESpecType; I.Fun.ExceptionSpecLoc = ESpecLoc.getRawEncoding(); I.Fun.NumExceptions = 0; - I.Fun.Exceptions = 0; - I.Fun.NoexceptExpr = 0; + I.Fun.Exceptions = nullptr; + I.Fun.NoexceptExpr = nullptr; I.Fun.HasTrailingReturnType = TrailingReturnType.isUsable() || TrailingReturnType.isInvalid(); I.Fun.TrailingReturnType = TrailingReturnType.get(); @@ -657,7 +657,7 @@ bool DeclSpec::SetTypeSpecType(TST T, SourceLocation TagKwLoc, DeclRep = Rep; TSTLoc = TagKwLoc; TSTNameLoc = TagNameLoc; - TypeSpecOwned = Owned && Rep != 0; + TypeSpecOwned = Owned && Rep != nullptr; return false; } @@ -1169,7 +1169,7 @@ void DeclSpec::Finish(DiagnosticsEngine &D, Preprocessor &PP, const PrintingPoli bool DeclSpec::isMissingDeclaratorOk() { TST tst = getTypeSpecType(); - return isDeclRep(tst) && getRepAsDecl() != 0 && + return isDeclRep(tst) && getRepAsDecl() != nullptr && StorageClassSpec != DeclSpec::SCS_typedef; } diff --git a/lib/Sema/SemaOpenMP.cpp b/lib/Sema/SemaOpenMP.cpp index 4ebca79795..ddedf72684 100644 --- a/lib/Sema/SemaOpenMP.cpp +++ b/lib/Sema/SemaOpenMP.cpp @@ -1032,7 +1032,7 @@ bool OpenMPIterationSpaceChecker::CheckInit(Stmt *S) { /// variable (which may be the loop variable) if possible. static const VarDecl *GetInitVarDecl(const Expr *E) { if (!E) - return 0; + return nullptr; E = E->IgnoreParenImpCasts(); if (auto *CE = dyn_cast_or_null(E)) if (const CXXConstructorDecl *Ctor = CE->getConstructor()) diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index ceeddcec89..5cf9a54441 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -5127,7 +5127,7 @@ static bool hasVisibleDefinition(Sema &S, NamedDecl *D, NamedDecl **Suggested) { ED = NewED; if (ED->isFixed()) { // If the enum has a fixed underlying type, any declaration of it will do. - *Suggested = 0; + *Suggested = nullptr; for (auto *Redecl : ED->redecls()) { if (LookupResult::isVisible(S, Redecl)) return true; @@ -5162,7 +5162,7 @@ bool Sema::RequireCompleteTypeImpl(SourceLocation Loc, QualType T, NamedDecl *Def = nullptr; if (!T->isIncompleteType(&Def)) { // If we know about the definition but it is not visible, complain. - NamedDecl *SuggestedDef = 0; + NamedDecl *SuggestedDef = nullptr; if (!Diagnoser.Suppressed && Def && !hasVisibleDefinition(*this, Def, &SuggestedDef)) { // Suppress this error outside of a SFINAE context if we've already