r209070 - [C++11] Use 'nullptr'. ASTMatchers edition.

Craig Topper craig.topper at gmail.com
Sat May 17 11:49:25 PDT 2014


Author: ctopper
Date: Sat May 17 13:49:24 2014
New Revision: 209070

URL: http://llvm.org/viewvc/llvm-project?rev=209070&view=rev
Log:
[C++11] Use 'nullptr'. ASTMatchers edition.

Modified:
    cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp
    cfe/trunk/lib/ASTMatchers/Dynamic/Marshallers.h
    cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
    cfe/trunk/lib/ASTMatchers/Dynamic/VariantValue.cpp

Modified: cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp?rev=209070&r1=209069&r2=209070&view=diff
==============================================================================
--- cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp Sat May 17 13:49:24 2014
@@ -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<Expr>(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<std::pair<internal::DynTypedMatcher, MatchCallback *> > *
           MatcherCallbackPairs)
-      : MatcherCallbackPairs(MatcherCallbackPairs), ActiveASTContext(NULL) {}
+      : MatcherCallbackPairs(MatcherCallbackPairs), ActiveASTContext(nullptr) {}
 
   void onStartOfTranslationUnit() {
     for (std::vector<std::pair<internal::DynTypedMatcher,
@@ -616,21 +616,21 @@ private:
 
 static CXXRecordDecl *getAsCXXRecordDecl(const Type *TypeNode) {
   // Type::getAs<...>() drills through typedefs.
-  if (TypeNode->getAs<DependentNameType>() != NULL ||
-      TypeNode->getAs<DependentTemplateSpecializationType>() != NULL ||
-      TypeNode->getAs<TemplateTypeParmType>() != NULL)
+  if (TypeNode->getAs<DependentNameType>() != nullptr ||
+      TypeNode->getAs<DependentTemplateSpecializationType>() != nullptr ||
+      TypeNode->getAs<TemplateTypeParmType>() != nullptr)
     // Dependent names and template TypeNode parameters will be matched when
     // the template is instantiated.
-    return NULL;
+    return nullptr;
   TemplateSpecializationType const *TemplateType =
       TypeNode->getAs<TemplateSpecializationType>();
-  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
   // 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
       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
 }
 
 bool MatchASTVisitor::TraverseDecl(Decl *DeclNode) {
-  if (DeclNode == NULL) {
+  if (!DeclNode) {
     return true;
   }
   match(*DeclNode);
@@ -698,7 +698,7 @@ bool MatchASTVisitor::TraverseDecl(Decl
 }
 
 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(co
 MatchFinder::MatchCallback::~MatchCallback() {}
 MatchFinder::ParsingDoneTestCallback::~ParsingDoneTestCallback() {}
 
-MatchFinder::MatchFinder() : ParsingDone(NULL) {}
+MatchFinder::MatchFinder() : ParsingDone(nullptr) {}
 
 MatchFinder::~MatchFinder() {}
 

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Marshallers.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Marshallers.h?rev=209070&r1=209069&r2=209070&view=diff
==============================================================================
--- cfe/trunk/lib/ASTMatchers/Dynamic/Marshallers.h (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Marshallers.h Sat May 17 13:49:24 2014
@@ -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.

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp?rev=209070&r1=209069&r2=209070&view=diff
==============================================================================
--- cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp Sat May 17 13:49:24 2014
@@ -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(
   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) {

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/VariantValue.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/VariantValue.cpp?rev=209070&r1=209069&r2=209070&view=diff
==============================================================================
--- cfe/trunk/lib/ASTMatchers/Dynamic/VariantValue.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/VariantValue.cpp Sat May 17 13:49:24 2014
@@ -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;





More information about the cfe-commits mailing list