aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2014-06-09 02:03:06 +0000
committerCraig Topper <craig.topper@gmail.com>2014-06-09 02:03:06 +0000
commit0913826cddeb71f5cb78b345313897b0534e2030 (patch)
treefa59b1e44b2c0d941db80155cbe8bdd601226059
parentac560ec8cb8ae943afe2f10a954f70b146cd1cd6 (diff)
[C++11] Use 'nullptr'.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@210447 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp2
-rw-r--r--clang-modernize/AddOverride/AddOverride.cpp2
-rw-r--r--clang-modernize/AddOverride/AddOverrideActions.cpp2
-rw-r--r--clang-modernize/Core/IncludeDirectives.cpp9
-rw-r--r--clang-modernize/Core/ReplacementHandling.cpp6
-rw-r--r--clang-modernize/LoopConvert/LoopActions.cpp38
-rw-r--r--clang-modernize/LoopConvert/StmtAncestor.cpp2
-rw-r--r--clang-modernize/LoopConvert/StmtAncestor.h2
-rw-r--r--clang-modernize/LoopConvert/VariableNaming.cpp4
-rw-r--r--clang-modernize/PassByValue/PassByValue.h2
-rw-r--r--clang-modernize/PassByValue/PassByValueActions.h2
-rw-r--r--clang-modernize/UseNullptr/NullptrActions.cpp4
-rw-r--r--clang-modernize/tool/ClangModernize.cpp6
-rw-r--r--clang-query/QueryParser.h4
-rw-r--r--clang-tidy/ClangTidy.cpp2
-rw-r--r--modularize/Modularize.cpp2
-rw-r--r--modularize/ModuleAssistant.cpp10
-rw-r--r--modularize/PreprocessorTracker.cpp38
-rw-r--r--module-map-checker/ModuleMapChecker.cpp2
-rw-r--r--pp-trace/PPCallbacksTracker.cpp4
-rw-r--r--unittests/clang-modernize/IncludeDirectivesTest.cpp2
-rw-r--r--unittests/clang-modernize/TransformTest.cpp2
22 files changed, 74 insertions, 73 deletions
diff --git a/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp b/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
index 48787cb0..67b8b0f6 100644
--- a/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
+++ b/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
@@ -67,7 +67,7 @@ collectReplacementsFromDirectory(const llvm::StringRef Directory,
continue;
}
- yaml::Input YIn(Out->getBuffer(), NULL, &eatDiagnostics);
+ yaml::Input YIn(Out->getBuffer(), nullptr, &eatDiagnostics);
tooling::TranslationUnitReplacements TU;
YIn >> TU;
if (YIn.error()) {
diff --git a/clang-modernize/AddOverride/AddOverride.cpp b/clang-modernize/AddOverride/AddOverride.cpp
index 9c58a8f0..e9c03cc7 100644
--- a/clang-modernize/AddOverride/AddOverride.cpp
+++ b/clang-modernize/AddOverride/AddOverride.cpp
@@ -51,7 +51,7 @@ int AddOverrideTransform::apply(const CompilationDatabase &Database,
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);
}
diff --git a/clang-modernize/AddOverride/AddOverrideActions.cpp b/clang-modernize/AddOverride/AddOverrideActions.cpp
index eec6cf40..e9731bd1 100644
--- a/clang-modernize/AddOverride/AddOverrideActions.cpp
+++ b/clang-modernize/AddOverride/AddOverrideActions.cpp
@@ -88,7 +88,7 @@ void AddOverrideFixer::run(const MatchFinder::MatchResult &Result) {
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())
diff --git a/clang-modernize/Core/IncludeDirectives.cpp b/clang-modernize/Core/IncludeDirectives.cpp
index 8b96f1a1..54519b5e 100644
--- a/clang-modernize/Core/IncludeDirectives.cpp
+++ b/clang-modernize/Core/IncludeDirectives.cpp
@@ -32,7 +32,7 @@ class IncludeDirectivesPPCallback : public clang::PPCallbacks {
// 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 : public clang::PPCallbacks {
};
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
diff --git a/clang-modernize/Core/ReplacementHandling.cpp b/clang-modernize/Core/ReplacementHandling.cpp
index 4b2b1d85..5add9803 100644
--- a/clang-modernize/Core/ReplacementHandling.cpp
+++ b/clang-modernize/Core/ReplacementHandling.cpp
@@ -101,12 +101,12 @@ bool ReplacementHandling::applyReplacements() {
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()) {
diff --git a/clang-modernize/LoopConvert/LoopActions.cpp b/clang-modernize/LoopConvert/LoopActions.cpp
index 9512bf73..ed726946 100644
--- a/clang-modernize/LoopConvert/LoopActions.cpp
+++ b/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-modernize/LoopConvert/StmtAncestor.cpp b/clang-modernize/LoopConvert/StmtAncestor.cpp
index 33f576bd..d5ab9a5c 100644
--- a/clang-modernize/LoopConvert/StmtAncestor.cpp
+++ b/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-modernize/LoopConvert/StmtAncestor.h b/clang-modernize/LoopConvert/StmtAncestor.h
index b6cffe83..e2ee2b9f 100644
--- a/clang-modernize/LoopConvert/StmtAncestor.h
+++ b/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-modernize/LoopConvert/VariableNaming.cpp b/clang-modernize/LoopConvert/VariableNaming.cpp
index 853e4830..6771c945 100644
--- a/clang-modernize/LoopConvert/VariableNaming.cpp
+++ b/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;
diff --git a/clang-modernize/PassByValue/PassByValue.h b/clang-modernize/PassByValue/PassByValue.h
index cfd45559..a8e6ebd7 100644
--- a/clang-modernize/PassByValue/PassByValue.h
+++ b/clang-modernize/PassByValue/PassByValue.h
@@ -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,
diff --git a/clang-modernize/PassByValue/PassByValueActions.h b/clang-modernize/PassByValue/PassByValueActions.h
index 4046992f..c31937a6 100644
--- a/clang-modernize/PassByValue/PassByValueActions.h
+++ b/clang-modernize/PassByValue/PassByValueActions.h
@@ -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;
diff --git a/clang-modernize/UseNullptr/NullptrActions.cpp b/clang-modernize/UseNullptr/NullptrActions.cpp
index c37ef455..76f00574 100644
--- a/clang-modernize/UseNullptr/NullptrActions.cpp
+++ b/clang-modernize/UseNullptr/NullptrActions.cpp
@@ -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();
diff --git a/clang-modernize/tool/ClangModernize.cpp b/clang-modernize/tool/ClangModernize.cpp
index ce5dcd0c..31e8925b 100644
--- a/clang-modernize/tool/ClangModernize.cpp
+++ b/clang-modernize/tool/ClangModernize.cpp
@@ -217,9 +217,9 @@ static CompilerVersions handleSupportedCompilers(const char *ProgName,
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 *autoDetectCompilations(std::string &ErrorMessage) {
}
ErrorMessage = "Could not determine sources to transform";
- return 0;
+ return nullptr;
}
// Predicate definition for determining whether a file is not included.
diff --git a/clang-query/QueryParser.h b/clang-query/QueryParser.h
index 5ebeaf2c..0e5b5184 100644
--- a/clang-query/QueryParser.h
+++ b/clang-query/QueryParser.h
@@ -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();
diff --git a/clang-tidy/ClangTidy.cpp b/clang-tidy/ClangTidy.cpp
index 5a3af2c2..7b903dfe 100644
--- a/clang-tidy/ClangTidy.cpp
+++ b/clang-tidy/ClangTidy.cpp
@@ -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());
diff --git a/modularize/Modularize.cpp b/modularize/Modularize.cpp
index 52bd6893..5dc11b2b 100644
--- a/modularize/Modularize.cpp
+++ b/modularize/Modularize.cpp
@@ -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;
diff --git a/modularize/ModuleAssistant.cpp b/modularize/ModuleAssistant.cpp
index 384ac1b8..ba9912df 100644
--- a/modularize/ModuleAssistant.cpp
+++ b/modularize/ModuleAssistant.cpp
@@ -124,7 +124,7 @@ Module *Module::findSubModule(llvm::StringRef SubName) {
if ((*I)->Name == SubName)
return *I;
}
- return 0;
+ return nullptr;
}
// Implementation functions:
@@ -135,7 +135,7 @@ Module *Module::findSubModule(llvm::StringRef SubName) {
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 *RootModule,
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;
diff --git a/modularize/PreprocessorTracker.cpp b/modularize/PreprocessorTracker.cpp
index 22989ee4..e71a2b0a 100644
--- a/modularize/PreprocessorTracker.cpp
+++ b/modularize/PreprocessorTracker.cpp
@@ -411,15 +411,15 @@ std::string getMacroExpandedString(clang::Preprocessor &PP,
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::Preprocessor &PP,
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::Preprocessor &PP,
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::Preprocessor &PP,
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::SourceLocation Loc,
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::SourceLocation Loc,
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),
diff --git a/module-map-checker/ModuleMapChecker.cpp b/module-map-checker/ModuleMapChecker.cpp
index a0f8c99e..3d117e2a 100644
--- a/module-map-checker/ModuleMapChecker.cpp
+++ b/module-map-checker/ModuleMapChecker.cpp
@@ -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))
diff --git a/pp-trace/PPCallbacksTracker.cpp b/pp-trace/PPCallbacksTracker.cpp
index 465ad1bf..b2ac9203 100644
--- a/pp-trace/PPCallbacksTracker.cpp
+++ b/pp-trace/PPCallbacksTracker.cpp
@@ -468,7 +468,7 @@ void PPCallbacksTracker::appendArgument(const char *Name, clang::FileID Value) {
}
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(const char *Name, clang::FileID Value) {
// 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;
}
diff --git a/unittests/clang-modernize/IncludeDirectivesTest.cpp b/unittests/clang-modernize/IncludeDirectivesTest.cpp
index f01c7492..dfb4b99b 100644
--- a/unittests/clang-modernize/IncludeDirectivesTest.cpp
+++ b/unittests/clang-modernize/IncludeDirectivesTest.cpp
@@ -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");
diff --git a/unittests/clang-modernize/TransformTest.cpp b/unittests/clang-modernize/TransformTest.cpp
index d1a8e785..18866c20 100644
--- a/unittests/clang-modernize/TransformTest.cpp
+++ b/unittests/clang-modernize/TransformTest.cpp
@@ -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;