From 9369232c48ec8cc9a26c6405f87f14a44f30cdd8 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Sat, 17 May 2014 18:49:24 +0000 Subject: [PATCH] [C++11] Use 'nullptr'. ASTMatchers edition. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209070 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/ASTMatchers/ASTMatchFinder.cpp | 34 ++++++++++++------------ lib/ASTMatchers/Dynamic/Marshallers.h | 4 +-- lib/ASTMatchers/Dynamic/Parser.cpp | 8 +++--- lib/ASTMatchers/Dynamic/VariantValue.cpp | 2 +- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/ASTMatchers/ASTMatchFinder.cpp b/lib/ASTMatchers/ASTMatchFinder.cpp index 72a9d0344a..23708e2ff0 100644 --- a/lib/ASTMatchers/ASTMatchFinder.cpp +++ b/lib/ASTMatchers/ASTMatchFinder.cpp @@ -137,7 +137,7 @@ public: // of the public API of this class. bool TraverseDecl(Decl *DeclNode) { ScopedIncrement ScopedDepth(&CurrentDepth); - return (DeclNode == NULL) || traverse(*DeclNode); + return (DeclNode == nullptr) || traverse(*DeclNode); } bool TraverseStmt(Stmt *StmtNode) { ScopedIncrement ScopedDepth(&CurrentDepth); @@ -145,11 +145,11 @@ public: if (Traversal == ASTMatchFinder::TK_IgnoreImplicitCastsAndParentheses) { const Expr *ExprNode = dyn_cast_or_null(StmtNode); - if (ExprNode != NULL) { + if (ExprNode) { StmtToTraverse = ExprNode->IgnoreParenImpCasts(); } } - return (StmtToTraverse == NULL) || traverse(*StmtToTraverse); + return (StmtToTraverse == nullptr) || traverse(*StmtToTraverse); } // We assume that the QualType and the contained type are on the same // hierarchy level. Thus, we try to match either of them. @@ -180,7 +180,7 @@ public: } bool TraverseNestedNameSpecifier(NestedNameSpecifier *NNS) { ScopedIncrement ScopedDepth(&CurrentDepth); - return (NNS == NULL) || traverse(*NNS); + return (NNS == nullptr) || traverse(*NNS); } bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS) { if (!NNS) @@ -295,7 +295,7 @@ public: MatchASTVisitor( std::vector > * MatcherCallbackPairs) - : MatcherCallbackPairs(MatcherCallbackPairs), ActiveASTContext(NULL) {} + : MatcherCallbackPairs(MatcherCallbackPairs), ActiveASTContext(nullptr) {} void onStartOfTranslationUnit() { for (std::vector() drills through typedefs. - if (TypeNode->getAs() != NULL || - TypeNode->getAs() != NULL || - TypeNode->getAs() != NULL) + if (TypeNode->getAs() != nullptr || + TypeNode->getAs() != nullptr || + TypeNode->getAs() != nullptr) // Dependent names and template TypeNode parameters will be matched when // the template is instantiated. - return NULL; + return nullptr; TemplateSpecializationType const *TemplateType = TypeNode->getAs(); - if (TemplateType == NULL) { + if (!TemplateType) { return TypeNode->getAsCXXRecordDecl(); } if (TemplateType->getTemplateName().isDependent()) // Dependent template specializations will be matched when the // template is instantiated. - return NULL; + return nullptr; // For template specialization types which are specializing a template // declaration which is an explicit or partial specialization of another @@ -642,7 +642,7 @@ static CXXRecordDecl *getAsCXXRecordDecl(const Type *TypeNode) { // another template declaration, getAsCXXRecordDecl() returns NULL and // we get the CXXRecordDecl of the templated declaration. CXXRecordDecl *SpecializationDecl = TemplateType->getAsCXXRecordDecl(); - if (SpecializationDecl != NULL) { + if (SpecializationDecl) { return SpecializationDecl; } NamedDecl *Templated = @@ -671,7 +671,7 @@ bool MatchASTVisitor::classIsDerivedFrom(const CXXRecordDecl *Declaration, return true; CXXRecordDecl *ClassDecl = getAsCXXRecordDecl(TypeNode); - if (ClassDecl == NULL) + if (!ClassDecl) continue; if (ClassDecl == Declaration) { // This can happen for recursive template definitions; if the @@ -690,7 +690,7 @@ bool MatchASTVisitor::classIsDerivedFrom(const CXXRecordDecl *Declaration, } bool MatchASTVisitor::TraverseDecl(Decl *DeclNode) { - if (DeclNode == NULL) { + if (!DeclNode) { return true; } match(*DeclNode); @@ -698,7 +698,7 @@ bool MatchASTVisitor::TraverseDecl(Decl *DeclNode) { } bool MatchASTVisitor::TraverseStmt(Stmt *StmtNode) { - if (StmtNode == NULL) { + if (!StmtNode) { return true; } match(*StmtNode); @@ -744,7 +744,7 @@ public: private: void HandleTranslationUnit(ASTContext &Context) override { - if (ParsingDone != NULL) { + if (ParsingDone != nullptr) { ParsingDone->run(); } Finder->matchAST(Context); @@ -765,7 +765,7 @@ MatchFinder::MatchResult::MatchResult(const BoundNodes &Nodes, MatchFinder::MatchCallback::~MatchCallback() {} MatchFinder::ParsingDoneTestCallback::~ParsingDoneTestCallback() {} -MatchFinder::MatchFinder() : ParsingDone(NULL) {} +MatchFinder::MatchFinder() : ParsingDone(nullptr) {} MatchFinder::~MatchFinder() {} diff --git a/lib/ASTMatchers/Dynamic/Marshallers.h b/lib/ASTMatchers/Dynamic/Marshallers.h index 77268076f0..439d3d5a3a 100644 --- a/lib/ASTMatchers/Dynamic/Marshallers.h +++ b/lib/ASTMatchers/Dynamic/Marshallers.h @@ -149,8 +149,8 @@ public: /// would produce a trivial matcher that will either always or never match. /// Such matchers are excluded from code completion results. virtual bool isConvertibleTo( - ast_type_traits::ASTNodeKind Kind, unsigned *Specificity = 0, - ast_type_traits::ASTNodeKind *LeastDerivedKind = 0) const = 0; + ast_type_traits::ASTNodeKind Kind, unsigned *Specificity = nullptr, + ast_type_traits::ASTNodeKind *LeastDerivedKind = nullptr) const = 0; /// Returns whether the matcher will, given a matcher of any type T, yield a /// matcher of type T. diff --git a/lib/ASTMatchers/Dynamic/Parser.cpp b/lib/ASTMatchers/Dynamic/Parser.cpp index 7034381189..25629d99a7 100644 --- a/lib/ASTMatchers/Dynamic/Parser.cpp +++ b/lib/ASTMatchers/Dynamic/Parser.cpp @@ -58,7 +58,7 @@ class Parser::CodeTokenizer { public: explicit CodeTokenizer(StringRef MatcherCode, Diagnostics *Error) : Code(MatcherCode), StartOfLine(MatcherCode), Line(1), Error(Error), - CodeCompletionLocation(0) { + CodeCompletionLocation(nullptr) { NextToken = getNextToken(); } @@ -90,7 +90,7 @@ private: if (CodeCompletionLocation && CodeCompletionLocation <= Code.data()) { Result.Kind = TokenInfo::TK_CodeCompletion; Result.Text = StringRef(CodeCompletionLocation, 0); - CodeCompletionLocation = 0; + CodeCompletionLocation = nullptr; return Result; } @@ -143,7 +143,7 @@ private: // cause the portion of the identifier before the code completion // location to become a code completion token. if (CodeCompletionLocation == Code.data() + TokenLength) { - CodeCompletionLocation = 0; + CodeCompletionLocation = nullptr; Result.Kind = TokenInfo::TK_CodeCompletion; Result.Text = Code.substr(0, TokenLength); Code = Code.drop_front(TokenLength); @@ -335,7 +335,7 @@ bool Parser::parseMatcherExpressionImpl(const TokenInfo &NameToken, TokenInfo EndToken; { - ScopedContextEntry SCE(this, Ctor ? *Ctor : 0); + ScopedContextEntry SCE(this, Ctor ? *Ctor : nullptr); while (Tokenizer->nextTokenKind() != TokenInfo::TK_Eof) { if (Tokenizer->nextTokenKind() == TokenInfo::TK_CloseParen) { diff --git a/lib/ASTMatchers/Dynamic/VariantValue.cpp b/lib/ASTMatchers/Dynamic/VariantValue.cpp index 9c7262e34f..18c989432f 100644 --- a/lib/ASTMatchers/Dynamic/VariantValue.cpp +++ b/lib/ASTMatchers/Dynamic/VariantValue.cpp @@ -71,7 +71,7 @@ public: virtual void makeTypedMatcher(MatcherOps &Ops) const { bool FoundIsExact = false; - const DynTypedMatcher *Found = NULL; + const DynTypedMatcher *Found = nullptr; int NumFound = 0; for (size_t i = 0, e = Matchers.size(); i != e; ++i) { bool IsExactMatch; -- 2.40.0