diff options
author | Craig Topper <craig.topper@gmail.com> | 2014-06-09 02:03:06 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2014-06-09 02:03:06 +0000 |
commit | f61be9c971d20d1f30f5444e525990b78a71d65e (patch) | |
tree | b4f659ba8282a1e3b34ca932f1e87e1a61f42479 /clang-tools-extra/clang-modernize/LoopConvert | |
parent | 3fe0c876c427d8da80fd1bd2f94f2605fc802268 (diff) | |
download | bcm5719-llvm-f61be9c971d20d1f30f5444e525990b78a71d65e.tar.gz bcm5719-llvm-f61be9c971d20d1f30f5444e525990b78a71d65e.zip |
[C++11] Use 'nullptr'.
llvm-svn: 210447
Diffstat (limited to 'clang-tools-extra/clang-modernize/LoopConvert')
4 files changed, 23 insertions, 23 deletions
diff --git a/clang-tools-extra/clang-modernize/LoopConvert/LoopActions.cpp b/clang-tools-extra/clang-modernize/LoopConvert/LoopActions.cpp index 9512bf73a61..ed726946257 100644 --- a/clang-tools-extra/clang-modernize/LoopConvert/LoopActions.cpp +++ b/clang-tools-extra/clang-modernize/LoopConvert/LoopActions.cpp @@ -73,9 +73,9 @@ class ForLoopIndexUseVisitor Context(Context), IndexVar(IndexVar), EndVar(EndVar), ContainerExpr(ContainerExpr), ArrayBoundExpr(ArrayBoundExpr), ContainerNeedsDereference(ContainerNeedsDereference), - OnlyUsedAsIndex(true), AliasDecl(NULL), ConfidenceLevel(RL_Safe), - NextStmtParent(NULL), CurrStmtParent(NULL), ReplaceWithAliasUse(false), - AliasFromForInit(false) { + OnlyUsedAsIndex(true), AliasDecl(nullptr), ConfidenceLevel(RL_Safe), + NextStmtParent(nullptr), CurrStmtParent(nullptr), + ReplaceWithAliasUse(false), AliasFromForInit(false) { if (ContainerExpr) { addComponent(ContainerExpr); llvm::FoldingSetNodeID ID; @@ -208,7 +208,7 @@ static StringRef getStringFromRange(SourceManager &SourceMgr, SourceRange Range) { if (SourceMgr.getFileID(Range.getBegin()) != SourceMgr.getFileID(Range.getEnd())) - return NULL; + return nullptr; CharSourceRange SourceChars(Range, true); return Lexer::getSourceText(SourceChars, SourceMgr, LangOpts); @@ -224,7 +224,7 @@ static const DeclRefExpr *getDeclRef(const Expr *E) { static const VarDecl *getReferencedVariable(const Expr *E) { if (const DeclRefExpr *DRE = getDeclRef(E)) return dyn_cast<VarDecl>(DRE->getDecl()); - return NULL; + return nullptr; } /// \brief Returns true when the given expression is a member expression @@ -277,14 +277,14 @@ static bool areSameExpr(ASTContext *Context, const Expr *First, /// as being initialized from `v.begin()` static const Expr *digThroughConstructors(const Expr *E) { if (!E) - return NULL; + return nullptr; E = E->IgnoreParenImpCasts(); if (const CXXConstructExpr *ConstructExpr = dyn_cast<CXXConstructExpr>(E)) { // The initial constructor must take exactly one parameter, but base class // and deferred constructors can take more. if (ConstructExpr->getNumArgs() != 1 || ConstructExpr->getConstructionKind() != CXXConstructExpr::CK_Complete) - return NULL; + return nullptr; E = ConstructExpr->getArg(0); if (const MaterializeTemporaryExpr *Temp = dyn_cast<MaterializeTemporaryExpr>(E)) @@ -298,13 +298,13 @@ static const Expr *digThroughConstructors(const Expr *E) { /// operand. Otherwise, return NULL. static const Expr *getDereferenceOperand(const Expr *E) { if (const UnaryOperator *Uop = dyn_cast<UnaryOperator>(E)) - return Uop->getOpcode() == UO_Deref ? Uop->getSubExpr() : NULL; + return Uop->getOpcode() == UO_Deref ? Uop->getSubExpr() : nullptr; if (const CXXOperatorCallExpr *OpCall = dyn_cast<CXXOperatorCallExpr>(E)) return OpCall->getOperator() == OO_Star && OpCall->getNumArgs() == 1 ? - OpCall->getArg(0) : NULL; + OpCall->getArg(0) : nullptr; - return NULL; + return nullptr; } /// \brief Returns true when the Container contains an Expr equivalent to E. @@ -879,19 +879,19 @@ static const Expr *getContainerFromBeginEndCall(const Expr *Init, bool IsBegin, const CXXMemberCallExpr *TheCall = dyn_cast_or_null<CXXMemberCallExpr>(digThroughConstructors(Init)); if (!TheCall || TheCall->getNumArgs() != 0) - return NULL; + return nullptr; const MemberExpr *Member = dyn_cast<MemberExpr>(TheCall->getCallee()); if (!Member) - return NULL; + return nullptr; const std::string Name = Member->getMemberDecl()->getName(); const std::string TargetName = IsBegin ? "begin" : "end"; if (Name != TargetName) - return NULL; + return nullptr; const Expr *SourceExpr = Member->getBase(); if (!SourceExpr) - return NULL; + return nullptr; *IsArrow = Member->isArrow(); return SourceExpr; @@ -912,7 +912,7 @@ static const Expr *findContainer(ASTContext *Context, const Expr *BeginExpr, const Expr *BeginContainerExpr = getContainerFromBeginEndCall(BeginExpr, /*IsBegin=*/true, &BeginIsArrow); if (!BeginContainerExpr) - return NULL; + return nullptr; const Expr *EndContainerExpr = getContainerFromBeginEndCall(EndExpr, /*IsBegin=*/false, &EndIsArrow); @@ -920,7 +920,7 @@ static const Expr *findContainer(ASTContext *Context, const Expr *BeginExpr, // for (IteratorType It = Obj.begin(), E = Obj->end(); It != E; ++It) { } if (!EndContainerExpr || BeginIsArrow != EndIsArrow || !areSameExpr(Context, EndContainerExpr, BeginContainerExpr)) - return NULL; + return nullptr; *ContainerNeedsDereference = BeginIsArrow; return BeginContainerExpr; @@ -1056,7 +1056,7 @@ void LoopFixer::run(const MatchFinder::MatchResult &Result) { if (FixerKind != LFK_Array && !EndVar) ConfidenceLevel.lowerTo(RL_Reasonable); - const Expr *ContainerExpr = NULL; + const Expr *ContainerExpr = nullptr; bool DerefByValue = false; bool DerefByConstRef = false; bool ContainerNeedsDereference = false; @@ -1072,7 +1072,7 @@ void LoopFixer::run(const MatchFinder::MatchResult &Result) { const CXXMemberCallExpr *BeginCall = Nodes.getNodeAs<CXXMemberCallExpr>(BeginCallName); - assert(BeginCall != 0 && "Bad Callback. No begin call expression."); + assert(BeginCall && "Bad Callback. No begin call expression."); QualType CanonicalBeginType = BeginCall->getMethodDecl()->getReturnType().getCanonicalType(); @@ -1091,7 +1091,7 @@ void LoopFixer::run(const MatchFinder::MatchResult &Result) { return; } - DerefByValue = Nodes.getNodeAs<QualType>(DerefByValueResultName) != 0; + DerefByValue = Nodes.getNodeAs<QualType>(DerefByValueResultName) != nullptr; if (!DerefByValue) { if (const QualType *DerefType = Nodes.getNodeAs<QualType>(DerefByRefResultName)) { diff --git a/clang-tools-extra/clang-modernize/LoopConvert/StmtAncestor.cpp b/clang-tools-extra/clang-modernize/LoopConvert/StmtAncestor.cpp index 33f576bd814..d5ab9a5c3f3 100644 --- a/clang-tools-extra/clang-modernize/LoopConvert/StmtAncestor.cpp +++ b/clang-tools-extra/clang-modernize/LoopConvert/StmtAncestor.cpp @@ -68,7 +68,7 @@ bool DependencyFinderASTVisitor::VisitDeclRefExpr(DeclRefExpr *DeclRef) { bool DependencyFinderASTVisitor::VisitVarDecl(VarDecl *V) { const Stmt *Curr = DeclParents->lookup(V); // First, see if the variable was declared within an inner scope of the loop. - while (Curr != NULL) { + while (Curr != nullptr) { if (Curr == ContainingStmt) { DependsOnInsideVariable = true; return false; diff --git a/clang-tools-extra/clang-modernize/LoopConvert/StmtAncestor.h b/clang-tools-extra/clang-modernize/LoopConvert/StmtAncestor.h index b6cffe836fb..e2ee2b9fd4e 100644 --- a/clang-tools-extra/clang-modernize/LoopConvert/StmtAncestor.h +++ b/clang-tools-extra/clang-modernize/LoopConvert/StmtAncestor.h @@ -43,7 +43,7 @@ class StmtAncestorASTVisitor : public clang::RecursiveASTVisitor<StmtAncestorASTVisitor> { public: StmtAncestorASTVisitor() { - StmtStack.push_back(NULL); + StmtStack.push_back(nullptr); } /// \brief Run the analysis on the TranslationUnitDecl. diff --git a/clang-tools-extra/clang-modernize/LoopConvert/VariableNaming.cpp b/clang-tools-extra/clang-modernize/LoopConvert/VariableNaming.cpp index 853e4830ca6..6771c945712 100644 --- a/clang-tools-extra/clang-modernize/LoopConvert/VariableNaming.cpp +++ b/clang-tools-extra/clang-modernize/LoopConvert/VariableNaming.cpp @@ -65,7 +65,7 @@ std::string VariableNamer::createIndexName() { /// We also check to see if the same identifier was generated by this loop /// converter in a loop nested within SourceStmt. bool VariableNamer::declarationExists(StringRef Symbol) { - assert(Context != 0 && "Expected an ASTContext"); + assert(Context != nullptr && "Expected an ASTContext"); IdentifierInfo &Ident = Context->Idents.get(Symbol); // Check if the symbol is not an identifier (ie. is a keyword or alias). @@ -77,7 +77,7 @@ bool VariableNamer::declarationExists(StringRef Symbol) { return true; // Determine if the symbol was generated in a parent context. - for (const Stmt *S = SourceStmt; S != NULL; S = ReverseAST->lookup(S)) { + for (const Stmt *S = SourceStmt; S != nullptr; S = ReverseAST->lookup(S)) { StmtGeneratedVarNameMap::const_iterator I = GeneratedDecls->find(S); if (I != GeneratedDecls->end() && I->second == Symbol) return true; |