[clang-tools-extra] r210447 - [C++11] Use 'nullptr'.

Craig Topper craig.topper at gmail.com
Sun Jun 8 19:03:07 PDT 2014


Author: ctopper
Date: Sun Jun  8 21:03:06 2014
New Revision: 210447

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

Modified:
    clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
    clang-tools-extra/trunk/clang-modernize/AddOverride/AddOverride.cpp
    clang-tools-extra/trunk/clang-modernize/AddOverride/AddOverrideActions.cpp
    clang-tools-extra/trunk/clang-modernize/Core/IncludeDirectives.cpp
    clang-tools-extra/trunk/clang-modernize/Core/ReplacementHandling.cpp
    clang-tools-extra/trunk/clang-modernize/LoopConvert/LoopActions.cpp
    clang-tools-extra/trunk/clang-modernize/LoopConvert/StmtAncestor.cpp
    clang-tools-extra/trunk/clang-modernize/LoopConvert/StmtAncestor.h
    clang-tools-extra/trunk/clang-modernize/LoopConvert/VariableNaming.cpp
    clang-tools-extra/trunk/clang-modernize/PassByValue/PassByValue.h
    clang-tools-extra/trunk/clang-modernize/PassByValue/PassByValueActions.h
    clang-tools-extra/trunk/clang-modernize/UseNullptr/NullptrActions.cpp
    clang-tools-extra/trunk/clang-modernize/tool/ClangModernize.cpp
    clang-tools-extra/trunk/clang-query/QueryParser.h
    clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
    clang-tools-extra/trunk/modularize/Modularize.cpp
    clang-tools-extra/trunk/modularize/ModuleAssistant.cpp
    clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp
    clang-tools-extra/trunk/module-map-checker/ModuleMapChecker.cpp
    clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp
    clang-tools-extra/trunk/unittests/clang-modernize/IncludeDirectivesTest.cpp
    clang-tools-extra/trunk/unittests/clang-modernize/TransformTest.cpp

Modified: clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp?rev=210447&r1=210446&r2=210447&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp (original)
+++ clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp Sun Jun  8 21:03:06 2014
@@ -67,7 +67,7 @@ collectReplacementsFromDirectory(const l
       continue;
     }
 
-    yaml::Input YIn(Out->getBuffer(), NULL, &eatDiagnostics);
+    yaml::Input YIn(Out->getBuffer(), nullptr, &eatDiagnostics);
     tooling::TranslationUnitReplacements TU;
     YIn >> TU;
     if (YIn.error()) {

Modified: clang-tools-extra/trunk/clang-modernize/AddOverride/AddOverride.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-modernize/AddOverride/AddOverride.cpp?rev=210447&r1=210446&r2=210447&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-modernize/AddOverride/AddOverride.cpp (original)
+++ clang-tools-extra/trunk/clang-modernize/AddOverride/AddOverride.cpp Sun Jun  8 21:03:06 2014
@@ -51,7 +51,7 @@ int AddOverrideTransform::apply(const Co
 
 bool AddOverrideTransform::handleBeginSource(clang::CompilerInstance &CI,
                                              llvm::StringRef Filename) {
-  assert(Fixer != NULL && "Fixer must be set");
+  assert(Fixer != nullptr && "Fixer must be set");
   Fixer->setPreprocessor(CI.getPreprocessor());
   return Transform::handleBeginSource(CI, Filename);
 }

Modified: clang-tools-extra/trunk/clang-modernize/AddOverride/AddOverrideActions.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-modernize/AddOverride/AddOverrideActions.cpp?rev=210447&r1=210446&r2=210447&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-modernize/AddOverride/AddOverrideActions.cpp (original)
+++ clang-tools-extra/trunk/clang-modernize/AddOverride/AddOverrideActions.cpp Sun Jun  8 21:03:06 2014
@@ -88,7 +88,7 @@ void AddOverrideFixer::run(const MatchFi
 
   std::string ReplacementText = " override";
   if (DetectMacros) {
-    assert(PP != 0 && "No access to Preprocessor object for macro detection");
+    assert(PP && "No access to Preprocessor object for macro detection");
     clang::TokenValue Tokens[] = { PP->getIdentifierInfo("override") };
     llvm::StringRef MacroName = PP->getLastMacroWithSpelling(StartLoc, Tokens);
     if (!MacroName.empty())

Modified: clang-tools-extra/trunk/clang-modernize/Core/IncludeDirectives.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-modernize/Core/IncludeDirectives.cpp?rev=210447&r1=210446&r2=210447&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-modernize/Core/IncludeDirectives.cpp (original)
+++ clang-tools-extra/trunk/clang-modernize/Core/IncludeDirectives.cpp Sun Jun  8 21:03:06 2014
@@ -32,7 +32,7 @@ class IncludeDirectivesPPCallback : publ
   // Struct helping the detection of header guards in the various callbacks
   struct GuardDetection {
     GuardDetection(FileID FID)
-      : FID(FID), Count(0), TheMacro(0), CountAtEndif(0) {}
+      : FID(FID), Count(0), TheMacro(nullptr), CountAtEndif(0) {}
 
     FileID FID;
     // count for relevant preprocessor directives
@@ -58,7 +58,8 @@ class IncludeDirectivesPPCallback : publ
   };
 
 public:
-  IncludeDirectivesPPCallback(IncludeDirectives *Self) : Self(Self), Guard(0) {}
+  IncludeDirectivesPPCallback(IncludeDirectives *Self)
+      : Self(Self), Guard(nullptr) {}
 
 private:
   virtual ~IncludeDirectivesPPCallback() {}
@@ -148,7 +149,7 @@ private:
     // If this #ifndef is the top-most directive and the symbol isn't defined
     // store those information in the guard detection, the next step will be to
     // check for the define.
-    if (Guard->Count == 1 && MD == 0) {
+    if (Guard->Count == 1 && MD == nullptr) {
       IdentifierInfo *MII = MacroNameTok.getIdentifierInfo();
 
       if (MII->hasMacroDefinition())
@@ -165,7 +166,7 @@ private:
     // If this #define is the second directive of the file and the symbol
     // defined is the same as the one checked in the #ifndef then store the
     // information about this define.
-    if (Guard->Count == 2 && Guard->TheMacro != 0) {
+    if (Guard->Count == 2 && Guard->TheMacro != nullptr) {
       IdentifierInfo *MII = MacroNameTok.getIdentifierInfo();
 
       // macro unrelated to the ifndef, doesn't look like a proper header guard

Modified: clang-tools-extra/trunk/clang-modernize/Core/ReplacementHandling.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-modernize/Core/ReplacementHandling.cpp?rev=210447&r1=210446&r2=210447&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-modernize/Core/ReplacementHandling.cpp (original)
+++ clang-tools-extra/trunk/clang-modernize/Core/ReplacementHandling.cpp Sun Jun  8 21:03:06 2014
@@ -101,12 +101,12 @@ bool ReplacementHandling::applyReplaceme
   Argv.push_back(DestinationDir.c_str());
 
   // Argv array needs to be null terminated.
-  Argv.push_back(0);
+  Argv.push_back(nullptr);
 
   std::string ErrorMsg;
   bool ExecutionFailed = false;
-  int ReturnCode = ExecuteAndWait(CARPath.c_str(), Argv.data(), /* env */ 0,
-                                  /* redirects */ 0,
+  int ReturnCode = ExecuteAndWait(CARPath.c_str(), Argv.data(),
+                                  /* env */ nullptr, /* redirects */ nullptr,
                                   /* secondsToWait */ 0, /* memoryLimit */ 0,
                                   &ErrorMsg, &ExecutionFailed);
   if (ExecutionFailed || !ErrorMsg.empty()) {

Modified: clang-tools-extra/trunk/clang-modernize/LoopConvert/LoopActions.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-modernize/LoopConvert/LoopActions.cpp?rev=210447&r1=210446&r2=210447&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-modernize/LoopConvert/LoopActions.cpp (original)
+++ clang-tools-extra/trunk/clang-modernize/LoopConvert/LoopActions.cpp Sun Jun  8 21:03:06 2014
@@ -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(Sour
                                     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(con
 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 *Cont
 /// 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 *digThroughConstructor
 /// 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 *getContainerFromBegin
   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(ASTCont
   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(ASTCont
   //  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::M
   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::M
 
     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::M
         return;
     }
 
-    DerefByValue = Nodes.getNodeAs<QualType>(DerefByValueResultName) != 0;
+    DerefByValue = Nodes.getNodeAs<QualType>(DerefByValueResultName) != nullptr;
     if (!DerefByValue) {
       if (const QualType *DerefType =
               Nodes.getNodeAs<QualType>(DerefByRefResultName)) {

Modified: clang-tools-extra/trunk/clang-modernize/LoopConvert/StmtAncestor.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-modernize/LoopConvert/StmtAncestor.cpp?rev=210447&r1=210446&r2=210447&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-modernize/LoopConvert/StmtAncestor.cpp (original)
+++ clang-tools-extra/trunk/clang-modernize/LoopConvert/StmtAncestor.cpp Sun Jun  8 21:03:06 2014
@@ -68,7 +68,7 @@ bool DependencyFinderASTVisitor::VisitDe
 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;

Modified: clang-tools-extra/trunk/clang-modernize/LoopConvert/StmtAncestor.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-modernize/LoopConvert/StmtAncestor.h?rev=210447&r1=210446&r2=210447&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-modernize/LoopConvert/StmtAncestor.h (original)
+++ clang-tools-extra/trunk/clang-modernize/LoopConvert/StmtAncestor.h Sun Jun  8 21:03:06 2014
@@ -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.

Modified: clang-tools-extra/trunk/clang-modernize/LoopConvert/VariableNaming.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-modernize/LoopConvert/VariableNaming.cpp?rev=210447&r1=210446&r2=210447&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-modernize/LoopConvert/VariableNaming.cpp (original)
+++ clang-tools-extra/trunk/clang-modernize/LoopConvert/VariableNaming.cpp Sun Jun  8 21:03:06 2014
@@ -65,7 +65,7 @@ std::string VariableNamer::createIndexNa
 /// 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(St
     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;

Modified: clang-tools-extra/trunk/clang-modernize/PassByValue/PassByValue.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-modernize/PassByValue/PassByValue.h?rev=210447&r1=210446&r2=210447&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-modernize/PassByValue/PassByValue.h (original)
+++ clang-tools-extra/trunk/clang-modernize/PassByValue/PassByValue.h Sun Jun  8 21:03:06 2014
@@ -55,7 +55,7 @@ class ConstructorParamReplacer;
 class PassByValueTransform : public Transform {
 public:
   PassByValueTransform(const TransformOptions &Options)
-      : Transform("PassByValue", Options), Replacer(0) {}
+      : Transform("PassByValue", Options), Replacer(nullptr) {}
 
   /// \see Transform::apply().
   virtual int apply(const clang::tooling::CompilationDatabase &Database,

Modified: clang-tools-extra/trunk/clang-modernize/PassByValue/PassByValueActions.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-modernize/PassByValue/PassByValueActions.h?rev=210447&r1=210446&r2=210447&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-modernize/PassByValue/PassByValueActions.h (original)
+++ clang-tools-extra/trunk/clang-modernize/PassByValue/PassByValueActions.h Sun Jun  8 21:03:06 2014
@@ -54,7 +54,7 @@ public:
   ConstructorParamReplacer(unsigned &AcceptedChanges, unsigned &RejectedChanges,
                            Transform &Owner)
       : AcceptedChanges(AcceptedChanges), RejectedChanges(RejectedChanges),
-        Owner(Owner), IncludeManager(0) {}
+        Owner(Owner), IncludeManager(nullptr) {}
 
   void setIncludeDirectives(IncludeDirectives *Includes) {
     IncludeManager = Includes;

Modified: clang-tools-extra/trunk/clang-modernize/UseNullptr/NullptrActions.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-modernize/UseNullptr/NullptrActions.cpp?rev=210447&r1=210446&r2=210447&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-modernize/UseNullptr/NullptrActions.cpp (original)
+++ clang-tools-extra/trunk/clang-modernize/UseNullptr/NullptrActions.cpp Sun Jun  8 21:03:06 2014
@@ -151,7 +151,7 @@ public:
                       unsigned &AcceptedChanges, Transform &Owner)
       : SM(Context.getSourceManager()), Context(Context),
         UserNullMacros(UserNullMacros), AcceptedChanges(AcceptedChanges),
-        Owner(Owner), FirstSubExpr(0), PruneSubtree(false) {}
+        Owner(Owner), FirstSubExpr(nullptr), PruneSubtree(false) {}
 
   bool TraverseStmt(Stmt *S) {
     // Stop traversing down the tree if requested.
@@ -167,7 +167,7 @@ public:
   bool VisitStmt(Stmt *S) {
     CastExpr *C = dyn_cast<CastExpr>(S);
     if (!C) {
-      FirstSubExpr = 0;
+      FirstSubExpr = nullptr;
       return true;
     } else if (!FirstSubExpr) {
       FirstSubExpr = C->getSubExpr()->IgnoreParens();

Modified: clang-tools-extra/trunk/clang-modernize/tool/ClangModernize.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-modernize/tool/ClangModernize.cpp?rev=210447&r1=210446&r2=210447&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-modernize/tool/ClangModernize.cpp (original)
+++ clang-tools-extra/trunk/clang-modernize/tool/ClangModernize.cpp Sun Jun  8 21:03:06 2014
@@ -217,9 +217,9 @@ static CompilerVersions handleSupportedC
     Version *V = llvm::StringSwitch<Version *>(Compiler)
         .Case("clang", &RequiredVersions.Clang)
         .Case("gcc", &RequiredVersions.Gcc).Case("icc", &RequiredVersions.Icc)
-        .Case("msvc", &RequiredVersions.Msvc).Default(NULL);
+        .Case("msvc", &RequiredVersions.Msvc).Default(nullptr);
 
-    if (V == NULL) {
+    if (V == nullptr) {
       llvm::errs() << ProgName << ": " << Compiler
                    << ": unsupported platform\n";
       Error = true;
@@ -279,7 +279,7 @@ CompilationDatabase *autoDetectCompilati
   }
 
   ErrorMessage = "Could not determine sources to transform";
-  return 0;
+  return nullptr;
 }
 
 // Predicate definition for determining whether a file is not included.

Modified: clang-tools-extra/trunk/clang-query/QueryParser.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/QueryParser.h?rev=210447&r1=210446&r2=210447&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-query/QueryParser.h (original)
+++ clang-tools-extra/trunk/clang-query/QueryParser.h Sun Jun  8 21:03:06 2014
@@ -37,8 +37,8 @@ public:
 
 private:
   QueryParser(StringRef Line, const QuerySession &QS)
-      : Begin(Line.data()), End(Line.data() + Line.size()), CompletionPos(0),
-        QS(QS) {}
+      : Begin(Line.data()), End(Line.data() + Line.size()),
+        CompletionPos(nullptr), QS(QS) {}
 
   StringRef lexWord();
 

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=210447&r1=210446&r2=210447&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Sun Jun  8 21:03:06 2014
@@ -115,7 +115,7 @@ public:
       DiagnosticBuilder Diag =
           Diags.Report(Loc, Diags.getCustomDiagID(Level, "%0"))
           << Message.Message;
-      if (Fixes != NULL) {
+      if (Fixes != nullptr) {
         for (const tooling::Replacement &Fix : *Fixes) {
           SourceLocation FixLoc =
               getLocation(Fix.getFilePath(), Fix.getOffset());

Modified: clang-tools-extra/trunk/modularize/Modularize.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/Modularize.cpp?rev=210447&r1=210446&r2=210447&view=diff
==============================================================================
--- clang-tools-extra/trunk/modularize/Modularize.cpp (original)
+++ clang-tools-extra/trunk/modularize/Modularize.cpp Sun Jun  8 21:03:06 2014
@@ -353,7 +353,7 @@ struct Location {
     Column = SM.getColumnNumber(Decomposed.first, Decomposed.second);
   }
 
-  operator bool() const { return File != 0; }
+  operator bool() const { return File != nullptr; }
 
   friend bool operator==(const Location &X, const Location &Y) {
     return X.File == Y.File && X.Line == Y.Line && X.Column == Y.Column;

Modified: clang-tools-extra/trunk/modularize/ModuleAssistant.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/ModuleAssistant.cpp?rev=210447&r1=210446&r2=210447&view=diff
==============================================================================
--- clang-tools-extra/trunk/modularize/ModuleAssistant.cpp (original)
+++ clang-tools-extra/trunk/modularize/ModuleAssistant.cpp Sun Jun  8 21:03:06 2014
@@ -124,7 +124,7 @@ Module *Module::findSubModule(llvm::Stri
     if ((*I)->Name == SubName)
       return *I;
   }
-  return 0;
+  return nullptr;
 }
 
 // Implementation functions:
@@ -135,7 +135,7 @@ Module *Module::findSubModule(llvm::Stri
 static const char *ReservedNames[] = {
   "config_macros", "export",   "module", "conflict", "framework",
   "requires",      "exclude",  "header", "private",  "explicit",
-  "link",          "umbrella", "extern", "use",      0 // Flag end.
+  "link",          "umbrella", "extern", "use",      nullptr // Flag end.
 };
 
 // Convert module name to a non-keyword.
@@ -143,7 +143,7 @@ static const char *ReservedNames[] = {
 static std::string
 ensureNoCollisionWithReservedName(llvm::StringRef MightBeReservedName) {
   std::string SafeName = MightBeReservedName;
-  for (int Index = 0; ReservedNames[Index] != 0; ++Index) {
+  for (int Index = 0; ReservedNames[Index] != nullptr; ++Index) {
     if (MightBeReservedName == ReservedNames[Index]) {
       SafeName.insert(0, "_");
       break;
@@ -190,7 +190,7 @@ static bool addModuleDescription(Module
     std::string Stem = llvm::sys::path::stem(*I);
     Stem = ensureNoCollisionWithReservedName(Stem);
     Module *SubModule = CurrentModule->findSubModule(Stem);
-    if (SubModule == 0) {
+    if (!SubModule) {
       SubModule = new Module(Stem);
       CurrentModule->SubModules.push_back(SubModule);
     }
@@ -222,7 +222,7 @@ static Module *loadModuleDescriptions(
        I != E; ++I) {
     // Add as a module.
     if (!addModuleDescription(RootModule, *I, HeaderPrefix, Dependencies))
-      return NULL;
+      return nullptr;
   }
 
   return RootModule;

Modified: clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp?rev=210447&r1=210446&r2=210447&view=diff
==============================================================================
--- clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp (original)
+++ clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp Sun Jun  8 21:03:06 2014
@@ -411,15 +411,15 @@ std::string getMacroExpandedString(clang
     int ArgNo = (II && Args ? MI->getArgumentNum(II) : -1);
     if (ArgNo == -1) {
       // This isn't an argument, just add it.
-      if (II == NULL)
+      if (II == nullptr)
         Expanded += PP.getSpelling((*I)); // Not an identifier.
       else {
         // Token is for an identifier.
         std::string Name = II->getName().str();
         // Check for nexted macro references.
         clang::MacroInfo *MacroInfo = PP.getMacroInfo(II);
-        if (MacroInfo != NULL)
-          Expanded += getMacroExpandedString(PP, Name, MacroInfo, NULL);
+        if (MacroInfo)
+          Expanded += getMacroExpandedString(PP, Name, MacroInfo, nullptr);
         else
           Expanded += Name;
       }
@@ -441,14 +441,14 @@ std::string getMacroExpandedString(clang
     for (unsigned ArgumentIndex = 0; ArgumentIndex < NumToks; ++ArgumentIndex) {
       const clang::Token &AT = ResultArgToks[ArgumentIndex];
       clang::IdentifierInfo *II = AT.getIdentifierInfo();
-      if (II == NULL)
+      if (II == nullptr)
         Expanded += PP.getSpelling(AT); // Not an identifier.
       else {
         // It's an identifier.  Check for further expansion.
         std::string Name = II->getName().str();
         clang::MacroInfo *MacroInfo = PP.getMacroInfo(II);
-        if (MacroInfo != NULL)
-          Expanded += getMacroExpandedString(PP, Name, MacroInfo, NULL);
+        if (MacroInfo)
+          Expanded += getMacroExpandedString(PP, Name, MacroInfo, nullptr);
         else
           Expanded += Name;
       }
@@ -483,15 +483,15 @@ std::string getExpandedString(clang::Pre
     int ArgNo = (II && Args ? MI->getArgumentNum(II) : -1);
     if (ArgNo == -1) {
       // This isn't an argument, just add it.
-      if (II == NULL)
+      if (II == nullptr)
         Expanded += PP.getSpelling((*I)); // Not an identifier.
       else {
         // Token is for an identifier.
         std::string Name = II->getName().str();
         // Check for nexted macro references.
         clang::MacroInfo *MacroInfo = PP.getMacroInfo(II);
-        if (MacroInfo != NULL)
-          Expanded += getMacroExpandedString(PP, Name, MacroInfo, NULL);
+        if (MacroInfo)
+          Expanded += getMacroExpandedString(PP, Name, MacroInfo, nullptr);
         else
           Expanded += Name;
       }
@@ -513,14 +513,14 @@ std::string getExpandedString(clang::Pre
     for (unsigned ArgumentIndex = 0; ArgumentIndex < NumToks; ++ArgumentIndex) {
       const clang::Token &AT = ResultArgToks[ArgumentIndex];
       clang::IdentifierInfo *II = AT.getIdentifierInfo();
-      if (II == NULL)
+      if (II == nullptr)
         Expanded += PP.getSpelling(AT); // Not an identifier.
       else {
         // It's an identifier.  Check for further expansion.
         std::string Name = II->getName().str();
         clang::MacroInfo *MacroInfo = PP.getMacroInfo(II);
-        if (MacroInfo != NULL)
-          Expanded += getMacroExpandedString(PP, Name, MacroInfo, NULL);
+        if (MacroInfo)
+          Expanded += getMacroExpandedString(PP, Name, MacroInfo, nullptr);
         else
           Expanded += Name;
       }
@@ -701,7 +701,7 @@ public:
         return &*I; // Found.
       }
     }
-    return NULL; // Not found.
+    return nullptr; // Not found.
   }
 
   // Add a macro expansion instance.
@@ -793,7 +793,7 @@ public:
         return &*I; // Found.
       }
     }
-    return NULL; // Not found.
+    return nullptr; // Not found.
   }
 
   // Add a conditional expansion instance.
@@ -1126,7 +1126,7 @@ public:
           CondTracker.findMacroExpansionInstance(addString(MacroExpanded),
                                                  DefinitionKey);
       // If found, just add the inclusion path to the instance.
-      if (MacroInfo != NULL)
+      if (MacroInfo)
         MacroInfo->addInclusionPathHandle(InclusionPathHandle);
       else {
         // Otherwise add a new instance with the unique value.
@@ -1169,7 +1169,7 @@ public:
       ConditionalExpansionInstance *MacroInfo =
           CondTracker.findConditionalExpansionInstance(ConditionValue);
       // If found, just add the inclusion path to the instance.
-      if (MacroInfo != NULL)
+      if (MacroInfo)
         MacroInfo->addInclusionPathHandle(InclusionPathHandle);
       else {
         // Otherwise add a new instance with the unique value.
@@ -1357,7 +1357,7 @@ void PreprocessorCallbacks::FileChanged(
   case ExitFile: {
     const clang::FileEntry *F =
         PP.getSourceManager().getFileEntryForID(PrevFID);
-    if (F != NULL)
+    if (F)
       PPTracker.handleHeaderExit(F->getName());
   } break;
   case SystemHeaderPragma:
@@ -1422,7 +1422,7 @@ void PreprocessorCallbacks::Ifdef(clang:
                                   const clang::Token &MacroNameTok,
                                   const clang::MacroDirective *MD) {
   clang::PPCallbacks::ConditionValueKind IsDefined =
-    (MD != 0 ? clang::PPCallbacks::CVK_True : clang::PPCallbacks::CVK_False );
+    (MD ? clang::PPCallbacks::CVK_True : clang::PPCallbacks::CVK_False );
   PPTracker.addConditionalExpansionInstance(
       PP, PPTracker.getCurrentHeaderHandle(), Loc, clang::tok::pp_ifdef,
       IsDefined, PP.getSpelling(MacroNameTok),
@@ -1433,7 +1433,7 @@ void PreprocessorCallbacks::Ifndef(clang
                                    const clang::Token &MacroNameTok,
                                    const clang::MacroDirective *MD) {
   clang::PPCallbacks::ConditionValueKind IsNotDefined =
-    (MD == 0 ? clang::PPCallbacks::CVK_True : clang::PPCallbacks::CVK_False );
+    (!MD ? clang::PPCallbacks::CVK_True : clang::PPCallbacks::CVK_False );
   PPTracker.addConditionalExpansionInstance(
       PP, PPTracker.getCurrentHeaderHandle(), Loc, clang::tok::pp_ifndef,
       IsNotDefined, PP.getSpelling(MacroNameTok),

Modified: clang-tools-extra/trunk/module-map-checker/ModuleMapChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/module-map-checker/ModuleMapChecker.cpp?rev=210447&r1=210446&r2=210447&view=diff
==============================================================================
--- clang-tools-extra/trunk/module-map-checker/ModuleMapChecker.cpp (original)
+++ clang-tools-extra/trunk/module-map-checker/ModuleMapChecker.cpp Sun Jun  8 21:03:06 2014
@@ -290,7 +290,7 @@ bool ModuleMapChecker::loadModuleMap() {
 
   // Because the module map parser uses a ForwardingDiagnosticConsumer,
   // which doesn't forward the BeginSourceFile call, we do it explicitly here.
-  DC.BeginSourceFile(*LangOpts, 0);
+  DC.BeginSourceFile(*LangOpts, nullptr);
 
   // Parse module.map file into module map.
   if (ModMap->parseModuleMapFile(ModuleMapEntry, false))

Modified: clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp?rev=210447&r1=210446&r2=210447&view=diff
==============================================================================
--- clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp (original)
+++ clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp Sun Jun  8 21:03:06 2014
@@ -468,7 +468,7 @@ void PPCallbacksTracker::appendArgument(
   }
   const clang::FileEntry *FileEntry =
       PP.getSourceManager().getFileEntryForID(Value);
-  if (FileEntry == 0) {
+  if (!FileEntry) {
     appendArgument(Name, "(getFileEntryForID failed)");
     return;
   }
@@ -478,7 +478,7 @@ void PPCallbacksTracker::appendArgument(
 // Append a FileEntry argument to the top trace item.
 void PPCallbacksTracker::appendArgument(const char *Name,
                                         const clang::FileEntry *Value) {
-  if (Value == 0) {
+  if (!Value) {
     appendArgument(Name, "(null)");
     return;
   }

Modified: clang-tools-extra/trunk/unittests/clang-modernize/IncludeDirectivesTest.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-modernize/IncludeDirectivesTest.cpp?rev=210447&r1=210446&r2=210447&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/clang-modernize/IncludeDirectivesTest.cpp (original)
+++ clang-tools-extra/trunk/unittests/clang-modernize/IncludeDirectivesTest.cpp Sun Jun  8 21:03:06 2014
@@ -41,7 +41,7 @@ namespace {
 class TestAddIncludeAction : public PreprocessOnlyAction {
 public:
   TestAddIncludeAction(StringRef Include, tooling::Replacements &Replaces,
-                       const char *HeaderToModify = 0)
+                       const char *HeaderToModify = nullptr)
       : Include(Include), Replaces(Replaces), HeaderToModify(HeaderToModify) {
     // some headers that the tests can include
     mapVirtualHeader("foo-inner.h", "#pragma once\n");

Modified: clang-tools-extra/trunk/unittests/clang-modernize/TransformTest.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-modernize/TransformTest.cpp?rev=210447&r1=210446&r2=210447&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/clang-modernize/TransformTest.cpp (original)
+++ clang-tools-extra/trunk/unittests/clang-modernize/TransformTest.cpp Sun Jun  8 21:03:06 2014
@@ -187,7 +187,7 @@ public:
   virtual void
   run(const clang::ast_matchers::MatchFinder::MatchResult &Result) {
     const VarDecl *Decl = Result.Nodes.getNodeAs<VarDecl>("decl");
-    ASSERT_TRUE(Decl != 0);
+    ASSERT_TRUE(Decl != nullptr);
 
     const SourceManager &SM = *Result.SourceManager;
 





More information about the cfe-commits mailing list