r209191 - [C++11] Use 'nullptr'. Analysis edition.
Craig Topper
craig.topper at gmail.com
Mon May 19 21:30:08 PDT 2014
Author: ctopper
Date: Mon May 19 23:30:07 2014
New Revision: 209191
URL: http://llvm.org/viewvc/llvm-project?rev=209191&view=rev
Log:
[C++11] Use 'nullptr'. Analysis edition.
Modified:
cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp
cfe/trunk/lib/Analysis/BodyFarm.cpp
cfe/trunk/lib/Analysis/CFG.cpp
cfe/trunk/lib/Analysis/CFGStmtMap.cpp
cfe/trunk/lib/Analysis/CallGraph.cpp
cfe/trunk/lib/Analysis/Consumed.cpp
cfe/trunk/lib/Analysis/FormatString.cpp
cfe/trunk/lib/Analysis/FormatStringParsing.h
cfe/trunk/lib/Analysis/LiveVariables.cpp
cfe/trunk/lib/Analysis/PostOrderCFGView.cpp
cfe/trunk/lib/Analysis/PrintfFormatString.cpp
cfe/trunk/lib/Analysis/PseudoConstantAnalysis.cpp
cfe/trunk/lib/Analysis/ReachableCode.cpp
cfe/trunk/lib/Analysis/ScanfFormatString.cpp
cfe/trunk/lib/Analysis/ThreadSafety.cpp
cfe/trunk/lib/Analysis/UninitializedValues.cpp
Modified: cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp?rev=209191&r1=209190&r2=209191&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp (original)
+++ cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp Mon May 19 23:30:07 2014
@@ -41,11 +41,11 @@ AnalysisDeclContext::AnalysisDeclContext
: Manager(Mgr),
D(d),
cfgBuildOptions(buildOptions),
- forcedBlkExprs(0),
+ forcedBlkExprs(nullptr),
builtCFG(false),
builtCompleteCFG(false),
- ReferencedBlockVars(0),
- ManagedAnalyses(0)
+ ReferencedBlockVars(nullptr),
+ ManagedAnalyses(nullptr)
{
cfgBuildOptions.forcedBlkExprs = &forcedBlkExprs;
}
@@ -54,11 +54,11 @@ AnalysisDeclContext::AnalysisDeclContext
const Decl *d)
: Manager(Mgr),
D(d),
- forcedBlkExprs(0),
+ forcedBlkExprs(nullptr),
builtCFG(false),
builtCompleteCFG(false),
- ReferencedBlockVars(0),
- ManagedAnalyses(0)
+ ReferencedBlockVars(nullptr),
+ ManagedAnalyses(nullptr)
{
cfgBuildOptions.forcedBlkExprs = &forcedBlkExprs;
}
@@ -140,7 +140,7 @@ const ImplicitParamDecl *AnalysisDeclCon
}
}
- return NULL;
+ return nullptr;
}
void AnalysisDeclContext::registerForcedBlockExpression(const Stmt *stmt) {
@@ -191,7 +191,7 @@ CFG *AnalysisDeclContext::getCFG() {
addParentsForSyntheticStmts(cfg.get(), *PM);
// The Observer should only observe one build of the CFG.
- getCFGBuildOptions().Observer = 0;
+ getCFGBuildOptions().Observer = nullptr;
}
return cfg.get();
}
@@ -210,7 +210,7 @@ CFG *AnalysisDeclContext::getUnoptimized
addParentsForSyntheticStmts(completeCFG.get(), *PM);
// The Observer should only observe one build of the CFG.
- getCFGBuildOptions().Observer = 0;
+ getCFGBuildOptions().Observer = nullptr;
}
return completeCFG.get();
}
@@ -223,8 +223,8 @@ CFGStmtMap *AnalysisDeclContext::getCFGS
cfgStmtMap.reset(CFGStmtMap::Build(c, &getParentMap()));
return cfgStmtMap.get();
}
-
- return 0;
+
+ return nullptr;
}
CFGReverseBlockReachabilityAnalysis *AnalysisDeclContext::getCFGReachablityAnalysis() {
@@ -235,8 +235,8 @@ CFGReverseBlockReachabilityAnalysis *Ana
CFA.reset(new CFGReverseBlockReachabilityAnalysis(*c));
return CFA.get();
}
-
- return 0;
+
+ return nullptr;
}
void AnalysisDeclContext::dumpCFG(bool ShowColors) {
@@ -401,7 +401,7 @@ const StackFrameContext *LocationContext
return SFC;
LC = LC->getParent();
}
- return NULL;
+ return nullptr;
}
bool LocationContext::inTopFrame() const {
Modified: cfe/trunk/lib/Analysis/BodyFarm.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BodyFarm.cpp?rev=209191&r1=209190&r2=209191&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/BodyFarm.cpp (original)
+++ cfe/trunk/lib/Analysis/BodyFarm.cpp Mon May 19 23:30:07 2014
@@ -128,20 +128,20 @@ UnaryOperator *ASTMaker::makeDereference
ImplicitCastExpr *ASTMaker::makeLvalueToRvalue(const Expr *Arg, QualType Ty) {
return ImplicitCastExpr::Create(C, Ty, CK_LValueToRValue,
- const_cast<Expr*>(Arg), 0, VK_RValue);
+ const_cast<Expr*>(Arg), nullptr, VK_RValue);
}
Expr *ASTMaker::makeIntegralCast(const Expr *Arg, QualType Ty) {
if (Arg->getType() == Ty)
return const_cast<Expr*>(Arg);
-
+
return ImplicitCastExpr::Create(C, Ty, CK_IntegralCast,
- const_cast<Expr*>(Arg), 0, VK_RValue);
+ const_cast<Expr*>(Arg), nullptr, VK_RValue);
}
ImplicitCastExpr *ASTMaker::makeIntegralCastToBoolean(const Expr *Arg) {
return ImplicitCastExpr::Create(C, C.BoolTy, CK_IntegralToBoolean,
- const_cast<Expr*>(Arg), 0, VK_RValue);
+ const_cast<Expr*>(Arg), nullptr, VK_RValue);
}
ObjCBoolLiteralExpr *ASTMaker::makeObjCBool(bool Val) {
@@ -159,7 +159,8 @@ ObjCIvarRefExpr *ASTMaker::makeObjCIvarR
ReturnStmt *ASTMaker::makeReturn(const Expr *RetVal) {
- return new (C) ReturnStmt(SourceLocation(), const_cast<Expr*>(RetVal), 0);
+ return new (C) ReturnStmt(SourceLocation(), const_cast<Expr*>(RetVal),
+ nullptr);
}
//===----------------------------------------------------------------------===//
@@ -172,24 +173,24 @@ typedef Stmt *(*FunctionFarmer)(ASTConte
static Stmt *create_dispatch_once(ASTContext &C, const FunctionDecl *D) {
// Check if we have at least two parameters.
if (D->param_size() != 2)
- return 0;
+ return nullptr;
// Check if the first parameter is a pointer to integer type.
const ParmVarDecl *Predicate = D->getParamDecl(0);
QualType PredicateQPtrTy = Predicate->getType();
const PointerType *PredicatePtrTy = PredicateQPtrTy->getAs<PointerType>();
if (!PredicatePtrTy)
- return 0;
+ return nullptr;
QualType PredicateTy = PredicatePtrTy->getPointeeType();
if (!PredicateTy->isIntegerType())
- return 0;
-
+ return nullptr;
+
// Check if the second parameter is the proper block type.
const ParmVarDecl *Block = D->getParamDecl(1);
QualType Ty = Block->getType();
if (!isDispatchBlock(Ty))
- return 0;
-
+ return nullptr;
+
// Everything checks out. Create a fakse body that checks the predicate,
// sets it, and calls the block. Basically, an AST dump of:
//
@@ -242,7 +243,7 @@ static Stmt *create_dispatch_once(ASTCon
SourceLocation());
// (5) Create the 'if' statement.
- IfStmt *If = new (C) IfStmt(C, SourceLocation(), 0, UO, CS);
+ IfStmt *If = new (C) IfStmt(C, SourceLocation(), nullptr, UO, CS);
return If;
}
@@ -250,14 +251,14 @@ static Stmt *create_dispatch_once(ASTCon
static Stmt *create_dispatch_sync(ASTContext &C, const FunctionDecl *D) {
// Check if we have at least two parameters.
if (D->param_size() != 2)
- return 0;
-
+ return nullptr;
+
// Check if the second parameter is a block.
const ParmVarDecl *PV = D->getParamDecl(1);
QualType Ty = PV->getType();
if (!isDispatchBlock(Ty))
- return 0;
-
+ return nullptr;
+
// Everything checks out. Create a fake body that just calls the block.
// This is basically just an AST dump of:
//
@@ -277,8 +278,8 @@ static Stmt *create_OSAtomicCompareAndSw
{
// There are exactly 3 arguments.
if (D->param_size() != 3)
- return 0;
-
+ return nullptr;
+
// Signature:
// _Bool OSAtomicCompareAndSwapPtr(void *__oldValue,
// void *__newValue,
@@ -293,8 +294,8 @@ static Stmt *create_OSAtomicCompareAndSw
QualType ResultTy = D->getReturnType();
bool isBoolean = ResultTy->isBooleanType();
if (!isBoolean && !ResultTy->isIntegralType(C))
- return 0;
-
+ return nullptr;
+
const ParmVarDecl *OldValue = D->getParamDecl(0);
QualType OldValueTy = OldValue->getType();
@@ -307,7 +308,7 @@ static Stmt *create_OSAtomicCompareAndSw
QualType TheValueTy = TheValue->getType();
const PointerType *PT = TheValueTy->getAs<PointerType>();
if (!PT)
- return 0;
+ return nullptr;
QualType PointeeTy = PT->getPointeeType();
ASTMaker M(C);
@@ -346,9 +347,9 @@ static Stmt *create_OSAtomicCompareAndSw
/// Construct the If.
Stmt *If =
- new (C) IfStmt(C, SourceLocation(), 0, Comparison, Body,
+ new (C) IfStmt(C, SourceLocation(), nullptr, Comparison, Body,
SourceLocation(), Else);
-
+
return If;
}
@@ -358,15 +359,15 @@ Stmt *BodyFarm::getBody(const FunctionDe
Optional<Stmt *> &Val = Bodies[D];
if (Val.hasValue())
return Val.getValue();
-
- Val = 0;
-
- if (D->getIdentifier() == 0)
- return 0;
+
+ Val = nullptr;
+
+ if (D->getIdentifier() == nullptr)
+ return nullptr;
StringRef Name = D->getName();
if (Name.empty())
- return 0;
+ return nullptr;
FunctionFarmer FF;
@@ -378,7 +379,7 @@ Stmt *BodyFarm::getBody(const FunctionDe
FF = llvm::StringSwitch<FunctionFarmer>(Name)
.Case("dispatch_sync", create_dispatch_sync)
.Case("dispatch_once", create_dispatch_once)
- .Default(NULL);
+ .Default(nullptr);
}
if (FF) { Val = FF(C, D); }
@@ -390,11 +391,11 @@ static Stmt *createObjCPropertyGetter(AS
// First, find the backing ivar.
const ObjCIvarDecl *IVar = Prop->getPropertyIvarDecl();
if (!IVar)
- return 0;
+ return nullptr;
// Ignore weak variables, which have special behavior.
if (Prop->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_weak)
- return 0;
+ return nullptr;
// Look to see if Sema has synthesized a body for us. This happens in
// Objective-C++ because the return value may be a C++ class type with a
@@ -420,10 +421,10 @@ static Stmt *createObjCPropertyGetter(AS
// copyable.
if (!Ctx.hasSameUnqualifiedType(IVar->getType(),
Prop->getType().getNonReferenceType()))
- return 0;
+ return nullptr;
if (!IVar->getType()->isObjCLifetimeType() &&
!IVar->getType().isTriviallyCopyableType(Ctx))
- return 0;
+ return nullptr;
// Generate our body:
// return self->_ivar;
@@ -447,22 +448,22 @@ static Stmt *createObjCPropertyGetter(AS
Stmt *BodyFarm::getBody(const ObjCMethodDecl *D) {
// We currently only know how to synthesize property accessors.
if (!D->isPropertyAccessor())
- return 0;
+ return nullptr;
D = D->getCanonicalDecl();
Optional<Stmt *> &Val = Bodies[D];
if (Val.hasValue())
return Val.getValue();
- Val = 0;
+ Val = nullptr;
const ObjCPropertyDecl *Prop = D->findPropertyDecl();
if (!Prop)
- return 0;
+ return nullptr;
// For now, we only synthesize getters.
if (D->param_size() != 0)
- return 0;
+ return nullptr;
Val = createObjCPropertyGetter(C, Prop);
Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=209191&r1=209190&r2=209191&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Mon May 19 23:30:07 2014
@@ -112,7 +112,7 @@ public:
/// Incrementing invalid iterator is allowed and will result in invalid
/// iterator.
const_iterator()
- : Scope(NULL), VarIter(0) {}
+ : Scope(nullptr), VarIter(0) {}
/// Create valid iterator. In case when S.Prev is an invalid iterator and
/// I is equal to 0, this will create invalid iterator.
@@ -207,7 +207,7 @@ int LocalScope::const_iterator::distance
/// build process. It consists of CFGBlock that specifies position in CFG graph
/// and LocalScope::const_iterator that specifies position in LocalScope graph.
struct BlockScopePosPair {
- BlockScopePosPair() : block(0) {}
+ BlockScopePosPair() : block(nullptr) {}
BlockScopePosPair(CFGBlock *b, LocalScope::const_iterator scopePos)
: block(b), scopePosition(scopePos) {}
@@ -336,11 +336,11 @@ public:
explicit CFGBuilder(ASTContext *astContext,
const CFG::BuildOptions &buildOpts)
: Context(astContext), cfg(new CFG()), // crew a new CFG
- Block(NULL), Succ(NULL),
- SwitchTerminatedBlock(NULL), DefaultCaseBlock(NULL),
- TryTerminatedBlock(NULL), badCFG(false), BuildOpts(buildOpts),
- switchExclusivelyCovered(false), switchCond(0),
- cachedEntry(0), lastLookup(0) {}
+ Block(nullptr), Succ(nullptr),
+ SwitchTerminatedBlock(nullptr), DefaultCaseBlock(nullptr),
+ TryTerminatedBlock(nullptr), badCFG(false), BuildOpts(buildOpts),
+ switchExclusivelyCovered(false), switchCond(nullptr),
+ cachedEntry(nullptr), lastLookup(nullptr) {}
// buildCFG - Used by external clients to construct the CFG.
CFG* buildCFG(const Decl *D, Stmt *Statement);
@@ -443,8 +443,9 @@ private:
LocalScope* createOrReuseLocalScope(LocalScope* Scope);
void addLocalScopeForStmt(Stmt *S);
- LocalScope* addLocalScopeForDeclStmt(DeclStmt *DS, LocalScope* Scope = NULL);
- LocalScope* addLocalScopeForVarDecl(VarDecl *VD, LocalScope* Scope = NULL);
+ LocalScope* addLocalScopeForDeclStmt(DeclStmt *DS,
+ LocalScope* Scope = nullptr);
+ LocalScope* addLocalScopeForVarDecl(VarDecl *VD, LocalScope* Scope = nullptr);
void addLocalScopeAndDtors(Stmt *S);
@@ -840,13 +841,13 @@ bool CFGBuilder::alwaysAdd(const Stmt *s
if (!fb) {
// No need to update 'cachedEntry', since it will always be null.
- assert(cachedEntry == 0);
+ assert(!cachedEntry);
return shouldAdd;
}
CFG::BuildOptions::ForcedBlkExprs::iterator itr = fb->find(stmt);
if (itr == fb->end()) {
- cachedEntry = 0;
+ cachedEntry = nullptr;
return shouldAdd;
}
@@ -865,7 +866,7 @@ static const VariableArrayType *FindVA(c
t = vt->getElementType().getTypePtr();
}
- return 0;
+ return nullptr;
}
/// BuildCFG - Constructs a CFG from an AST (a Stmt*). The AST can represent an
@@ -876,14 +877,14 @@ static const VariableArrayType *FindVA(c
CFG* CFGBuilder::buildCFG(const Decl *D, Stmt *Statement) {
assert(cfg.get());
if (!Statement)
- return NULL;
+ return nullptr;
// Create an empty block that will serve as the exit block for the CFG. Since
// this is the first block added to the CFG, it will be implicitly registered
// as the exit block.
Succ = createBlock();
assert(Succ == &cfg->getExit());
- Block = NULL; // the EXIT block is empty. Create all other blocks lazily.
+ Block = nullptr; // the EXIT block is empty. Create all other blocks lazily.
if (BuildOpts.AddImplicitDtors)
if (const CXXDestructorDecl *DD = dyn_cast_or_null<CXXDestructorDecl>(D))
@@ -893,7 +894,7 @@ CFG* CFGBuilder::buildCFG(const Decl *D,
CFGBlock *B = addStmt(Statement);
if (badCFG)
- return NULL;
+ return nullptr;
// For C++ constructor add initializers to CFG.
if (const CXXConstructorDecl *CD = dyn_cast_or_null<CXXConstructorDecl>(D)) {
@@ -901,7 +902,7 @@ CFG* CFGBuilder::buildCFG(const Decl *D,
E = CD->init_rend(); I != E; ++I) {
B = addInitializer(*I);
if (badCFG)
- return NULL;
+ return nullptr;
}
}
@@ -1156,7 +1157,7 @@ void CFGBuilder::addLocalScopeForStmt(St
if (!BuildOpts.AddImplicitDtors)
return;
- LocalScope *Scope = 0;
+ LocalScope *Scope = nullptr;
// For compound statement we will be creating explicit scope.
if (CompoundStmt *CS = dyn_cast<CompoundStmt>(S)) {
@@ -1278,7 +1279,7 @@ void CFGBuilder::prependAutomaticObjDtor
CFGBlock *CFGBuilder::Visit(Stmt * S, AddStmtChoice asc) {
if (!S) {
badCFG = true;
- return 0;
+ return nullptr;
}
if (Expr *E = dyn_cast<Expr>(S))
@@ -1503,9 +1504,10 @@ CFGBlock *CFGBuilder::VisitLogicalOperat
appendStmt(ConfluenceBlock, B);
if (badCFG)
- return 0;
+ return nullptr;
- return VisitLogicalOperator(B, 0, ConfluenceBlock, ConfluenceBlock).first;
+ return VisitLogicalOperator(B, nullptr, ConfluenceBlock,
+ ConfluenceBlock).first;
}
std::pair<CFGBlock*, CFGBlock*>
@@ -1553,7 +1555,7 @@ CFGBuilder::VisitLogicalOperator(BinaryO
while (false);
if (badCFG)
- return std::make_pair((CFGBlock*)0, (CFGBlock*)0);
+ return std::make_pair(nullptr, nullptr);
// Generate the blocks for evaluating the LHS.
Expr *LHS = B->getLHS()->IgnoreParens();
@@ -1580,7 +1582,7 @@ CFGBuilder::VisitLogicalOperator(BinaryO
CFGBlock *EntryLHSBlock = addStmt(LHS);
if (badCFG)
- return std::make_pair((CFGBlock*)0, (CFGBlock*)0);
+ return std::make_pair(nullptr, nullptr);
// See if this is a known constant.
TryResult KnownVal = tryEvaluateBool(LHS);
@@ -1646,7 +1648,7 @@ CFGBlock *CFGBuilder::VisitBreakStmt(Bre
// "break" is a control-flow statement. Thus we stop processing the current
// block.
if (badCFG)
- return 0;
+ return nullptr;
// Now create a new block that ends with the break statement.
Block = createBlock(false);
@@ -1734,7 +1736,7 @@ CFGBlock *CFGBuilder::VisitCallExpr(Call
if (Block) {
Succ = Block;
if (badCFG)
- return 0;
+ return nullptr;
}
if (NoReturn)
@@ -1760,26 +1762,26 @@ CFGBlock *CFGBuilder::VisitChooseExpr(Ch
CFGBlock *ConfluenceBlock = Block ? Block : createBlock();
appendStmt(ConfluenceBlock, C);
if (badCFG)
- return 0;
+ return nullptr;
AddStmtChoice alwaysAdd = asc.withAlwaysAdd(true);
Succ = ConfluenceBlock;
- Block = NULL;
+ Block = nullptr;
CFGBlock *LHSBlock = Visit(C->getLHS(), alwaysAdd);
if (badCFG)
- return 0;
+ return nullptr;
Succ = ConfluenceBlock;
- Block = NULL;
+ Block = nullptr;
CFGBlock *RHSBlock = Visit(C->getRHS(), alwaysAdd);
if (badCFG)
- return 0;
+ return nullptr;
Block = createBlock(false);
// See if this is a known constant.
const TryResult& KnownVal = tryEvaluateBool(C->getCond());
- addSuccessor(Block, KnownVal.isFalse() ? NULL : LHSBlock);
- addSuccessor(Block, KnownVal.isTrue() ? NULL : RHSBlock);
+ addSuccessor(Block, KnownVal.isFalse() ? nullptr : LHSBlock);
+ addSuccessor(Block, KnownVal.isTrue() ? nullptr : RHSBlock);
Block->setTerminator(C);
return addStmt(C->getCond());
}
@@ -1797,7 +1799,7 @@ CFGBlock *CFGBuilder::VisitCompoundStmt(
LastBlock = newBlock;
if (badCFG)
- return NULL;
+ return nullptr;
}
return LastBlock;
@@ -1806,14 +1808,14 @@ CFGBlock *CFGBuilder::VisitCompoundStmt(
CFGBlock *CFGBuilder::VisitConditionalOperator(AbstractConditionalOperator *C,
AddStmtChoice asc) {
const BinaryConditionalOperator *BCO = dyn_cast<BinaryConditionalOperator>(C);
- const OpaqueValueExpr *opaqueValue = (BCO ? BCO->getOpaqueValue() : NULL);
+ const OpaqueValueExpr *opaqueValue = (BCO ? BCO->getOpaqueValue() : nullptr);
// Create the confluence block that will "merge" the results of the ternary
// expression.
CFGBlock *ConfluenceBlock = Block ? Block : createBlock();
appendStmt(ConfluenceBlock, C);
if (badCFG)
- return 0;
+ return nullptr;
AddStmtChoice alwaysAdd = asc.withAlwaysAdd(true);
@@ -1822,14 +1824,14 @@ CFGBlock *CFGBuilder::VisitConditionalOp
// value that is returned instead.
// e.g: x ?: y is shorthand for: x ? x : y;
Succ = ConfluenceBlock;
- Block = NULL;
- CFGBlock *LHSBlock = 0;
+ Block = nullptr;
+ CFGBlock *LHSBlock = nullptr;
const Expr *trueExpr = C->getTrueExpr();
if (trueExpr != opaqueValue) {
LHSBlock = Visit(C->getTrueExpr(), alwaysAdd);
if (badCFG)
- return 0;
- Block = NULL;
+ return nullptr;
+ Block = nullptr;
}
else
LHSBlock = ConfluenceBlock;
@@ -1838,7 +1840,7 @@ CFGBlock *CFGBuilder::VisitConditionalOp
Succ = ConfluenceBlock;
CFGBlock *RHSBlock = Visit(C->getFalseExpr(), alwaysAdd);
if (badCFG)
- return 0;
+ return nullptr;
// If the condition is a logical '&&' or '||', build a more accurate CFG.
if (BinaryOperator *Cond =
@@ -1880,7 +1882,7 @@ CFGBlock *CFGBuilder::VisitDeclStmt(Decl
if (DS->isSingleDecl())
return VisitDeclSubExpr(DS);
- CFGBlock *B = 0;
+ CFGBlock *B = nullptr;
// Build an individual DeclStmt for each decl.
for (DeclStmt::reverse_decl_iterator I = DS->decl_rbegin(),
@@ -1921,16 +1923,16 @@ CFGBlock *CFGBuilder::VisitDeclSubExpr(D
bool HasTemporaries = false;
// Guard static initializers under a branch.
- CFGBlock *blockAfterStaticInit = 0;
+ CFGBlock *blockAfterStaticInit = nullptr;
if (BuildOpts.AddStaticInitBranches && VD->isStaticLocal()) {
// For static variables, we need to create a branch to track
// whether or not they are initialized.
if (Block) {
Succ = Block;
- Block = 0;
+ Block = nullptr;
if (badCFG)
- return 0;
+ return nullptr;
}
blockAfterStaticInit = Succ;
}
@@ -1973,7 +1975,7 @@ CFGBlock *CFGBuilder::VisitDeclSubExpr(D
// If the type of VD is a VLA, then we must process its size expressions.
for (const VariableArrayType* VA = FindVA(VD->getType().getTypePtr());
- VA != 0; VA = FindVA(VA->getElementType().getTypePtr())) {
+ VA != nullptr; VA = FindVA(VA->getElementType().getTypePtr())) {
if (CFGBlock *newBlock = addStmt(VA->getSizeExpr()))
LastBlock = newBlock;
}
@@ -2020,7 +2022,7 @@ CFGBlock *CFGBuilder::VisitIfStmt(IfStmt
if (Block) {
Succ = Block;
if (badCFG)
- return 0;
+ return nullptr;
}
// Process the false branch.
@@ -2031,7 +2033,7 @@ CFGBlock *CFGBuilder::VisitIfStmt(IfStmt
// NULL out Block so that the recursive call to Visit will
// create a new basic block.
- Block = NULL;
+ Block = nullptr;
// If branch is not a compound statement create implicit scope
// and add destructors.
@@ -2044,7 +2046,7 @@ CFGBlock *CFGBuilder::VisitIfStmt(IfStmt
ElseBlock = sv.get();
else if (Block) {
if (badCFG)
- return 0;
+ return nullptr;
}
}
@@ -2054,7 +2056,7 @@ CFGBlock *CFGBuilder::VisitIfStmt(IfStmt
Stmt *Then = I->getThen();
assert(Then);
SaveAndRestore<CFGBlock*> sv(Succ);
- Block = NULL;
+ Block = nullptr;
// If branch is not a compound statement create implicit scope
// and add destructors.
@@ -2071,7 +2073,7 @@ CFGBlock *CFGBuilder::VisitIfStmt(IfStmt
addSuccessor(ThenBlock, sv.get());
} else if (Block) {
if (badCFG)
- return 0;
+ return nullptr;
}
}
@@ -2159,10 +2161,10 @@ CFGBlock *CFGBuilder::VisitLabelStmt(Lab
// about.
LabelBlock->setLabel(L);
if (badCFG)
- return 0;
+ return nullptr;
// We set Block to NULL to allow lazy creation of a new block (if necessary);
- Block = NULL;
+ Block = nullptr;
// This block is now the implicit successor of other blocks.
Succ = LabelBlock;
@@ -2176,7 +2178,7 @@ CFGBlock *CFGBuilder::VisitLambdaExpr(La
et = E->capture_init_end(); it != et; ++it) {
if (Expr *Init = *it) {
CFGBlock *Tmp = Visit(Init);
- if (Tmp != 0)
+ if (Tmp)
LastBlock = Tmp;
}
}
@@ -2206,7 +2208,7 @@ CFGBlock *CFGBuilder::VisitGotoStmt(Goto
}
CFGBlock *CFGBuilder::VisitForStmt(ForStmt *F) {
- CFGBlock *LoopSuccessor = NULL;
+ CFGBlock *LoopSuccessor = nullptr;
// Save local scope position because in case of condition variable ScopePos
// won't be restored when traversing AST.
@@ -2229,7 +2231,7 @@ CFGBlock *CFGBuilder::VisitForStmt(ForSt
// block.
if (Block) {
if (badCFG)
- return 0;
+ return nullptr;
LoopSuccessor = Block;
} else
LoopSuccessor = Succ;
@@ -2239,7 +2241,7 @@ CFGBlock *CFGBuilder::VisitForStmt(ForSt
SaveAndRestore<JumpTarget> save_break(BreakJumpTarget);
BreakJumpTarget = JumpTarget(LoopSuccessor, ScopePos);
- CFGBlock *BodyBlock = 0, *TransitionBlock = 0;
+ CFGBlock *BodyBlock = nullptr, *TransitionBlock = nullptr;
// Now create the loop body.
{
@@ -2265,8 +2267,8 @@ CFGBlock *CFGBuilder::VisitForStmt(ForSt
if (Block) {
assert(Block == Succ);
if (badCFG)
- return 0;
- Block = 0;
+ return nullptr;
+ Block = nullptr;
}
// The starting block for the loop increment is the block that should
@@ -2292,13 +2294,13 @@ CFGBlock *CFGBuilder::VisitForStmt(ForSt
BodyBlock = ContinueJumpTarget.block;
}
else if (badCFG)
- return 0;
+ return nullptr;
}
// Because of short-circuit evaluation, the condition of the loop can span
// multiple basic blocks. Thus we need the "Entry" and "Exit" blocks that
// evaluate the condition.
- CFGBlock *EntryConditionBlock = 0, *ExitConditionBlock = 0;
+ CFGBlock *EntryConditionBlock = nullptr, *ExitConditionBlock = nullptr;
do {
Expr *C = F->getCond();
@@ -2306,7 +2308,7 @@ CFGBlock *CFGBuilder::VisitForStmt(ForSt
// Specially handle logical operators, which have a slightly
// more optimal CFG representation.
if (BinaryOperator *Cond =
- dyn_cast_or_null<BinaryOperator>(C ? C->IgnoreParens() : 0))
+ dyn_cast_or_null<BinaryOperator>(C ? C->IgnoreParens() : nullptr))
if (Cond->isLogicalOp()) {
std::tie(EntryConditionBlock, ExitConditionBlock) =
VisitLogicalOperator(Cond, F, BodyBlock, LoopSuccessor);
@@ -2339,16 +2341,17 @@ CFGBlock *CFGBuilder::VisitForStmt(ForSt
}
if (Block && badCFG)
- return 0;
+ return nullptr;
KnownVal = tryEvaluateBool(C);
}
// Add the loop body entry as a successor to the condition.
- addSuccessor(ExitConditionBlock, KnownVal.isFalse() ? NULL : BodyBlock);
+ addSuccessor(ExitConditionBlock, KnownVal.isFalse() ? nullptr : BodyBlock);
// Link up the condition block with the code that follows the loop. (the
// false branch).
- addSuccessor(ExitConditionBlock, KnownVal.isTrue() ? NULL : LoopSuccessor);
+ addSuccessor(ExitConditionBlock,
+ KnownVal.isTrue() ? nullptr : LoopSuccessor);
} while (false);
@@ -2367,7 +2370,7 @@ CFGBlock *CFGBuilder::VisitForStmt(ForSt
// There is no loop initialization. We are thus basically a while loop.
// NULL out Block to force lazy block construction.
- Block = NULL;
+ Block = nullptr;
Succ = EntryConditionBlock;
return EntryConditionBlock;
}
@@ -2413,13 +2416,13 @@ CFGBlock *CFGBuilder::VisitObjCForCollec
// a DeclStmt and the other returns a DeclRefExpr.
//
- CFGBlock *LoopSuccessor = 0;
+ CFGBlock *LoopSuccessor = nullptr;
if (Block) {
if (badCFG)
- return 0;
+ return nullptr;
LoopSuccessor = Block;
- Block = 0;
+ Block = nullptr;
} else
LoopSuccessor = Succ;
@@ -2442,8 +2445,8 @@ CFGBlock *CFGBuilder::VisitObjCForCollec
AddStmtChoice::NotAlwaysAdd);
if (Block) {
if (badCFG)
- return 0;
- Block = 0;
+ return nullptr;
+ Block = nullptr;
}
// The condition block is the implicit successor for the loop body as well as
@@ -2460,7 +2463,7 @@ CFGBlock *CFGBuilder::VisitObjCForCollec
// Add an intermediate block between the BodyBlock and the
// EntryConditionBlock to represent the "loop back" transition, for looping
// back to the head of the loop.
- CFGBlock *LoopBackBlock = 0;
+ CFGBlock *LoopBackBlock = nullptr;
Succ = LoopBackBlock = createBlock();
LoopBackBlock->setLoopTarget(S);
@@ -2473,7 +2476,7 @@ CFGBlock *CFGBuilder::VisitObjCForCollec
BodyBlock = ContinueJumpTarget.block; // can happen for "for (X in Y) ;"
else if (Block) {
if (badCFG)
- return 0;
+ return nullptr;
}
// This new body block is a successor to our "exit" condition block.
@@ -2505,9 +2508,9 @@ CFGBlock *CFGBuilder::VisitObjCAtSynchro
// for diagnostic clients.
if (SyncBlock) {
if (badCFG)
- return 0;
+ return nullptr;
- Block = 0;
+ Block = nullptr;
Succ = SyncBlock;
}
@@ -2550,7 +2553,7 @@ CFGBlock *CFGBuilder::VisitPseudoObjectE
}
CFGBlock *CFGBuilder::VisitWhileStmt(WhileStmt *W) {
- CFGBlock *LoopSuccessor = NULL;
+ CFGBlock *LoopSuccessor = nullptr;
// Save local scope position because in case of condition variable ScopePos
// won't be restored when traversing AST.
@@ -2568,14 +2571,14 @@ CFGBlock *CFGBuilder::VisitWhileStmt(Whi
// block.
if (Block) {
if (badCFG)
- return 0;
+ return nullptr;
LoopSuccessor = Block;
- Block = 0;
+ Block = nullptr;
} else {
LoopSuccessor = Succ;
}
- CFGBlock *BodyBlock = 0, *TransitionBlock = 0;
+ CFGBlock *BodyBlock = nullptr, *TransitionBlock = nullptr;
// Process the loop body.
{
@@ -2609,13 +2612,13 @@ CFGBlock *CFGBuilder::VisitWhileStmt(Whi
if (!BodyBlock)
BodyBlock = ContinueJumpTarget.block; // can happen for "while(...) ;"
else if (Block && badCFG)
- return 0;
+ return nullptr;
}
// Because of short-circuit evaluation, the condition of the loop can span
// multiple basic blocks. Thus we need the "Entry" and "Exit" blocks that
// evaluate the condition.
- CFGBlock *EntryConditionBlock = 0, *ExitConditionBlock = 0;
+ CFGBlock *EntryConditionBlock = nullptr, *ExitConditionBlock = nullptr;
do {
Expr *C = W->getCond();
@@ -2651,16 +2654,17 @@ CFGBlock *CFGBuilder::VisitWhileStmt(Whi
}
if (Block && badCFG)
- return 0;
+ return nullptr;
// See if this is a known constant.
const TryResult& KnownVal = tryEvaluateBool(C);
// Add the loop body entry as a successor to the condition.
- addSuccessor(ExitConditionBlock, KnownVal.isFalse() ? NULL : BodyBlock);
+ addSuccessor(ExitConditionBlock, KnownVal.isFalse() ? nullptr : BodyBlock);
// Link up the condition block with the code that follows the loop. (the
// false branch).
- addSuccessor(ExitConditionBlock, KnownVal.isTrue() ? NULL : LoopSuccessor);
+ addSuccessor(ExitConditionBlock,
+ KnownVal.isTrue() ? nullptr : LoopSuccessor);
} while(false);
@@ -2669,7 +2673,7 @@ CFGBlock *CFGBuilder::VisitWhileStmt(Whi
// There can be no more statements in the condition block since we loop back
// to this block. NULL out Block to force lazy creation of another block.
- Block = NULL;
+ Block = nullptr;
// Return the condition block, which is the dominating block for the loop.
Succ = EntryConditionBlock;
@@ -2689,7 +2693,7 @@ CFGBlock *CFGBuilder::VisitObjCAtThrowSt
// If we were in the middle of a block we stop processing that block.
if (badCFG)
- return 0;
+ return nullptr;
// Create the new block.
Block = createBlock(false);
@@ -2705,7 +2709,7 @@ CFGBlock *CFGBuilder::VisitObjCAtThrowSt
CFGBlock *CFGBuilder::VisitCXXThrowExpr(CXXThrowExpr *T) {
// If we were in the middle of a block we stop processing that block.
if (badCFG)
- return 0;
+ return nullptr;
// Create the new block.
Block = createBlock(false);
@@ -2723,13 +2727,13 @@ CFGBlock *CFGBuilder::VisitCXXThrowExpr(
}
CFGBlock *CFGBuilder::VisitDoStmt(DoStmt *D) {
- CFGBlock *LoopSuccessor = NULL;
+ CFGBlock *LoopSuccessor = nullptr;
// "do...while" is a control-flow statement. Thus we stop processing the
// current block.
if (Block) {
if (badCFG)
- return 0;
+ return nullptr;
LoopSuccessor = Block;
} else
LoopSuccessor = Succ;
@@ -2750,7 +2754,7 @@ CFGBlock *CFGBuilder::VisitDoStmt(DoStmt
EntryConditionBlock = addStmt(C);
if (Block) {
if (badCFG)
- return 0;
+ return nullptr;
}
}
@@ -2761,7 +2765,7 @@ CFGBlock *CFGBuilder::VisitDoStmt(DoStmt
const TryResult &KnownVal = tryEvaluateBool(D->getCond());
// Process the loop body.
- CFGBlock *BodyBlock = NULL;
+ CFGBlock *BodyBlock = nullptr;
{
assert(D->getBody());
@@ -2777,7 +2781,7 @@ CFGBlock *CFGBuilder::VisitDoStmt(DoStmt
BreakJumpTarget = JumpTarget(LoopSuccessor, ScopePos);
// NULL out Block to force lazy instantiation of blocks for the body.
- Block = NULL;
+ Block = nullptr;
// If body is not a compound statement create implicit scope
// and add destructors.
@@ -2791,7 +2795,7 @@ CFGBlock *CFGBuilder::VisitDoStmt(DoStmt
BodyBlock = EntryConditionBlock; // can happen for "do ; while(...)"
else if (Block) {
if (badCFG)
- return 0;
+ return nullptr;
}
if (!KnownVal.isFalse()) {
@@ -2800,7 +2804,7 @@ CFGBlock *CFGBuilder::VisitDoStmt(DoStmt
// empty block to represent the transition block for looping back to the
// head of the loop.
// FIXME: Can we do this more efficiently without adding another block?
- Block = NULL;
+ Block = nullptr;
Succ = BodyBlock;
CFGBlock *LoopBackBlock = createBlock();
LoopBackBlock->setLoopTarget(D);
@@ -2809,16 +2813,16 @@ CFGBlock *CFGBuilder::VisitDoStmt(DoStmt
addSuccessor(ExitConditionBlock, LoopBackBlock);
}
else
- addSuccessor(ExitConditionBlock, NULL);
+ addSuccessor(ExitConditionBlock, nullptr);
}
// Link up the condition block with the code that follows the loop.
// (the false branch).
- addSuccessor(ExitConditionBlock, KnownVal.isTrue() ? NULL : LoopSuccessor);
+ addSuccessor(ExitConditionBlock, KnownVal.isTrue() ? nullptr : LoopSuccessor);
// There can be no more statements in the body block(s) since we loop back to
// the body. NULL out Block to force lazy creation of another block.
- Block = NULL;
+ Block = nullptr;
// Return the loop body, which is the dominating block for the loop.
Succ = BodyBlock;
@@ -2829,7 +2833,7 @@ CFGBlock *CFGBuilder::VisitContinueStmt(
// "continue" is a control-flow statement. Thus we stop processing the
// current block.
if (badCFG)
- return 0;
+ return nullptr;
// Now create a new block that ends with the continue statement.
Block = createBlock(false);
@@ -2859,7 +2863,7 @@ CFGBlock *CFGBuilder::VisitUnaryExprOrTy
if (E->isArgumentType()) {
for (const VariableArrayType *VA =FindVA(E->getArgumentType().getTypePtr());
- VA != 0; VA = FindVA(VA->getElementType().getTypePtr()))
+ VA != nullptr; VA = FindVA(VA->getElementType().getTypePtr()))
lastBlock = addStmt(VA->getSizeExpr());
}
return lastBlock;
@@ -2878,7 +2882,7 @@ CFGBlock *CFGBuilder::VisitStmtExpr(Stmt
CFGBlock *CFGBuilder::VisitSwitchStmt(SwitchStmt *Terminator) {
// "switch" is a control-flow statement. Thus we stop processing the current
// block.
- CFGBlock *SwitchSuccessor = NULL;
+ CFGBlock *SwitchSuccessor = nullptr;
// Save local scope position because in case of condition variable ScopePos
// won't be restored when traversing AST.
@@ -2894,7 +2898,7 @@ CFGBlock *CFGBuilder::VisitSwitchStmt(Sw
if (Block) {
if (badCFG)
- return 0;
+ return nullptr;
SwitchSuccessor = Block;
} else SwitchSuccessor = Succ;
@@ -2920,7 +2924,7 @@ CFGBlock *CFGBuilder::VisitSwitchStmt(Sw
// up to the switch. We also don't keep a pointer to the body, since all
// control-flow from the switch goes to case/default statements.
assert(Terminator->getBody() && "switch must contain a non-NULL body");
- Block = NULL;
+ Block = nullptr;
// For pruning unreachable case statements, save the current state
// for tracking the condition value.
@@ -2932,7 +2936,7 @@ CFGBlock *CFGBuilder::VisitSwitchStmt(Sw
Expr::EvalResult result;
bool b = tryEvaluate(Terminator->getCond(), result);
SaveAndRestore<Expr::EvalResult*> save_switchCond(switchCond,
- b ? &result : 0);
+ b ? &result : nullptr);
// If body is not a compound statement create implicit scope
// and add destructors.
@@ -2942,7 +2946,7 @@ CFGBlock *CFGBuilder::VisitSwitchStmt(Sw
addStmt(Terminator->getBody());
if (Block) {
if (badCFG)
- return 0;
+ return nullptr;
}
// If we have no "default:" case, the default transition is to the code
@@ -3015,7 +3019,7 @@ static bool shouldAddCase(bool &switchEx
CFGBlock *CFGBuilder::VisitCaseStmt(CaseStmt *CS) {
// CaseStmts are essentially labels, so they are the first statement in a
// block.
- CFGBlock *TopBlock = 0, *LastBlock = 0;
+ CFGBlock *TopBlock = nullptr, *LastBlock = nullptr;
if (Stmt *Sub = CS->getSubStmt()) {
// For deeply nested chains of CaseStmts, instead of doing a recursion
@@ -3033,7 +3037,7 @@ CFGBlock *CFGBuilder::VisitCaseStmt(Case
addSuccessor(SwitchTerminatedBlock,
shouldAddCase(switchExclusivelyCovered, switchCond,
CS, *Context)
- ? currentBlock : 0);
+ ? currentBlock : nullptr);
LastBlock = currentBlock;
CS = cast<CaseStmt>(Sub);
@@ -3052,7 +3056,7 @@ CFGBlock *CFGBuilder::VisitCaseStmt(Case
CaseBlock->setLabel(CS);
if (badCFG)
- return 0;
+ return nullptr;
// Add this block to the list of successors for the block with the switch
// statement.
@@ -3062,7 +3066,7 @@ CFGBlock *CFGBuilder::VisitCaseStmt(Case
CS, *Context));
// We set Block to NULL to allow lazy creation of a new block (if necessary)
- Block = NULL;
+ Block = nullptr;
if (TopBlock) {
addSuccessor(LastBlock, CaseBlock);
@@ -3089,7 +3093,7 @@ CFGBlock *CFGBuilder::VisitDefaultStmt(D
DefaultCaseBlock->setLabel(Terminator);
if (badCFG)
- return 0;
+ return nullptr;
// Unlike case statements, we don't add the default block to the successors
// for the switch statement immediately. This is done when we finish
@@ -3098,7 +3102,7 @@ CFGBlock *CFGBuilder::VisitDefaultStmt(D
// be the last successor of a switch-terminated block.
// We set Block to NULL to allow lazy creation of a new block (if necessary)
- Block = NULL;
+ Block = nullptr;
// This block is now the implicit successor of other blocks.
Succ = DefaultCaseBlock;
@@ -3109,11 +3113,11 @@ CFGBlock *CFGBuilder::VisitDefaultStmt(D
CFGBlock *CFGBuilder::VisitCXXTryStmt(CXXTryStmt *Terminator) {
// "try"/"catch" is a control-flow statement. Thus we stop processing the
// current block.
- CFGBlock *TrySuccessor = NULL;
+ CFGBlock *TrySuccessor = nullptr;
if (Block) {
if (badCFG)
- return 0;
+ return nullptr;
TrySuccessor = Block;
} else TrySuccessor = Succ;
@@ -3129,13 +3133,13 @@ CFGBlock *CFGBuilder::VisitCXXTryStmt(CX
// The code after the try is the implicit successor.
Succ = TrySuccessor;
CXXCatchStmt *CS = Terminator->getHandler(h);
- if (CS->getExceptionDecl() == 0) {
+ if (CS->getExceptionDecl() == nullptr) {
HasCatchAll = true;
}
- Block = NULL;
+ Block = nullptr;
CFGBlock *CatchBlock = VisitCXXCatchStmt(CS);
- if (CatchBlock == 0)
- return 0;
+ if (!CatchBlock)
+ return nullptr;
// Add this block to the list of successors for the block with the try
// statement.
addSuccessor(NewTryTerminatedBlock, CatchBlock);
@@ -3155,7 +3159,7 @@ CFGBlock *CFGBuilder::VisitCXXTryStmt(CX
cfg->addTryDispatchBlock(TryTerminatedBlock);
assert(Terminator->getTryBlock() && "try must contain a non-NULL body");
- Block = NULL;
+ Block = nullptr;
return addStmt(Terminator->getTryBlock());
}
@@ -3194,10 +3198,10 @@ CFGBlock *CFGBuilder::VisitCXXCatchStmt(
// Bail out if the CFG is bad.
if (badCFG)
- return 0;
+ return nullptr;
// We set Block to NULL to allow lazy creation of a new block (if necessary)
- Block = NULL;
+ Block = nullptr;
return CatchBlock;
}
@@ -3230,10 +3234,10 @@ CFGBlock *CFGBuilder::VisitCXXForRangeSt
// "for" is a control-flow statement. Thus we stop processing the current
// block.
- CFGBlock *LoopSuccessor = NULL;
+ CFGBlock *LoopSuccessor = nullptr;
if (Block) {
if (badCFG)
- return 0;
+ return nullptr;
LoopSuccessor = Block;
} else
LoopSuccessor = Succ;
@@ -3252,7 +3256,7 @@ CFGBlock *CFGBuilder::VisitCXXForRangeSt
Block = ConditionBlock;
CFGBlock *BeginConditionBlock = addStmt(C);
if (badCFG)
- return 0;
+ return nullptr;
assert(BeginConditionBlock == ConditionBlock &&
"condition block in for-range was unexpectedly complex");
(void)BeginConditionBlock;
@@ -3278,7 +3282,7 @@ CFGBlock *CFGBuilder::VisitCXXForRangeSt
// Generate increment code in its own basic block. This is the target of
// continue statements.
- Block = 0;
+ Block = nullptr;
Succ = addStmt(S->getInc());
ContinueJumpTarget = JumpTarget(Succ, ContinueScopePos);
@@ -3289,9 +3293,8 @@ CFGBlock *CFGBuilder::VisitCXXForRangeSt
// Finish up the increment block and prepare to start the loop body.
assert(Block);
if (badCFG)
- return 0;
- Block = 0;
-
+ return nullptr;
+ Block = nullptr;
// Add implicit scope and dtors for loop variable.
addLocalScopeAndDtors(S->getLoopVarStmt());
@@ -3299,18 +3302,19 @@ CFGBlock *CFGBuilder::VisitCXXForRangeSt
// Populate a new block to contain the loop body and loop variable.
addStmt(S->getBody());
if (badCFG)
- return 0;
+ return nullptr;
CFGBlock *LoopVarStmtBlock = addStmt(S->getLoopVarStmt());
if (badCFG)
- return 0;
-
+ return nullptr;
+
// This new body block is a successor to our condition block.
- addSuccessor(ConditionBlock, KnownVal.isFalse() ? 0 : LoopVarStmtBlock);
+ addSuccessor(ConditionBlock,
+ KnownVal.isFalse() ? nullptr : LoopVarStmtBlock);
}
// Link up the condition block with the code that follows the loop (the
// false branch).
- addSuccessor(ConditionBlock, KnownVal.isTrue() ? 0 : LoopSuccessor);
+ addSuccessor(ConditionBlock, KnownVal.isTrue() ? nullptr : LoopSuccessor);
// Add the initialization statements.
Block = createBlock();
@@ -3424,7 +3428,7 @@ CFGBlock *CFGBuilder::VisitIndirectGotoS
// IndirectGoto is a control-flow statement. Thus we stop processing the
// current block and create a new one.
if (badCFG)
- return 0;
+ return nullptr;
Block = createBlock(false);
Block->setTerminator(I);
@@ -3438,7 +3442,7 @@ CFGBlock *CFGBuilder::VisitForTemporaryD
tryAgain:
if (!E) {
badCFG = true;
- return NULL;
+ return nullptr;
}
switch (E->getStmtClass()) {
default:
@@ -3493,15 +3497,15 @@ CFGBlock *CFGBuilder::VisitBinaryOperato
autoCreateBlock();
CFGBlock *ConfluenceBlock = VisitForTemporaryDtors(E->getLHS());
if (badCFG)
- return NULL;
+ return nullptr;
Succ = ConfluenceBlock;
- Block = NULL;
+ Block = nullptr;
CFGBlock *RHSBlock = VisitForTemporaryDtors(E->getRHS());
if (RHSBlock) {
if (badCFG)
- return NULL;
+ return nullptr;
// If RHS expression did produce destructors we need to connect created
// blocks to CFG in same manner as for binary operator itself.
@@ -3521,12 +3525,12 @@ CFGBlock *CFGBuilder::VisitBinaryOperato
// Link LHSBlock with RHSBlock exactly the same way as for binary operator
// itself.
if (E->getOpcode() == BO_LOr) {
- addSuccessor(LHSBlock, KnownVal.isTrue() ? NULL : ConfluenceBlock);
- addSuccessor(LHSBlock, KnownVal.isFalse() ? NULL : RHSBlock);
+ addSuccessor(LHSBlock, KnownVal.isTrue() ? nullptr : ConfluenceBlock);
+ addSuccessor(LHSBlock, KnownVal.isFalse() ? nullptr : RHSBlock);
} else {
assert (E->getOpcode() == BO_LAnd);
- addSuccessor(LHSBlock, KnownVal.isFalse() ? NULL : RHSBlock);
- addSuccessor(LHSBlock, KnownVal.isTrue() ? NULL : ConfluenceBlock);
+ addSuccessor(LHSBlock, KnownVal.isFalse() ? nullptr : RHSBlock);
+ addSuccessor(LHSBlock, KnownVal.isTrue() ? nullptr : ConfluenceBlock);
}
Block = LHSBlock;
@@ -3586,29 +3590,29 @@ CFGBlock *CFGBuilder::VisitConditionalOp
autoCreateBlock();
CFGBlock *ConfluenceBlock = VisitForTemporaryDtors(E->getCond());
if (badCFG)
- return NULL;
+ return nullptr;
if (BinaryConditionalOperator *BCO
= dyn_cast<BinaryConditionalOperator>(E)) {
ConfluenceBlock = VisitForTemporaryDtors(BCO->getCommon());
if (badCFG)
- return NULL;
+ return nullptr;
}
// Try to add block with destructors for LHS expression.
- CFGBlock *LHSBlock = NULL;
+ CFGBlock *LHSBlock = nullptr;
Succ = ConfluenceBlock;
- Block = NULL;
+ Block = nullptr;
LHSBlock = VisitForTemporaryDtors(E->getTrueExpr(), BindToTemporary);
if (badCFG)
- return NULL;
+ return nullptr;
// Try to add block with destructors for RHS expression;
Succ = ConfluenceBlock;
- Block = NULL;
+ Block = nullptr;
CFGBlock *RHSBlock = VisitForTemporaryDtors(E->getFalseExpr(),
BindToTemporary);
if (badCFG)
- return NULL;
+ return nullptr;
if (!RHSBlock && !LHSBlock) {
// If neither LHS nor RHS expression had temporaries to destroy don't create
@@ -3627,7 +3631,7 @@ CFGBlock *CFGBuilder::VisitConditionalOp
if (LHSBlock) {
addSuccessor(Block, LHSBlock, !KnownVal.isFalse());
} else if (KnownVal.isFalse()) {
- addSuccessor(Block, NULL);
+ addSuccessor(Block, nullptr);
} else {
addSuccessor(Block, ConfluenceBlock);
std::reverse(ConfluenceBlock->pred_begin(), ConfluenceBlock->pred_end());
@@ -3708,7 +3712,7 @@ CFGImplicitDtor::getDestructorDecl(ASTCo
case CFGElement::MemberDtor:
// Not yet supported.
- return 0;
+ return nullptr;
}
llvm_unreachable("getKind() returned bogus value");
}
@@ -3724,13 +3728,13 @@ bool CFGImplicitDtor::isNoReturn(ASTCont
//===----------------------------------------------------------------------===//
CFGBlock::AdjacentBlock::AdjacentBlock(CFGBlock *B, bool IsReachable)
- : ReachableBlock(IsReachable ? B : 0),
- UnreachableBlock(!IsReachable ? B : 0,
+ : ReachableBlock(IsReachable ? B : nullptr),
+ UnreachableBlock(!IsReachable ? B : nullptr,
B && IsReachable ? AB_Normal : AB_Unreachable) {}
CFGBlock::AdjacentBlock::AdjacentBlock(CFGBlock *B, CFGBlock *AlternateBlock)
: ReachableBlock(B),
- UnreachableBlock(B == AlternateBlock ? 0 : AlternateBlock,
+ UnreachableBlock(B == AlternateBlock ? nullptr : AlternateBlock,
B == AlternateBlock ? AB_Alternate : AB_Normal) {}
void CFGBlock::addSuccessor(AdjacentBlock Succ,
@@ -4330,16 +4334,16 @@ void CFGBlock::print(raw_ostream &OS, co
/// printTerminator - A simple pretty printer of the terminator of a CFGBlock.
void CFGBlock::printTerminator(raw_ostream &OS,
const LangOptions &LO) const {
- CFGBlockTerminatorPrint TPrinter(OS, NULL, PrintingPolicy(LO));
+ CFGBlockTerminatorPrint TPrinter(OS, nullptr, PrintingPolicy(LO));
TPrinter.print(getTerminator());
}
Stmt *CFGBlock::getTerminatorCondition(bool StripParens) {
Stmt *Terminator = this->Terminator;
if (!Terminator)
- return NULL;
+ return nullptr;
- Expr *E = NULL;
+ Expr *E = nullptr;
switch (Terminator->getStmtClass()) {
default:
@@ -4396,7 +4400,7 @@ Stmt *CFGBlock::getTerminatorCondition(b
if (!StripParens)
return E;
- return E ? E->IgnoreParens() : NULL;
+ return E ? E->IgnoreParens() : nullptr;
}
//===----------------------------------------------------------------------===//
@@ -4413,7 +4417,7 @@ void CFG::viewCFG(const LangOptions &LO)
StmtPrinterHelper H(this, LO);
GraphHelper = &H;
llvm::ViewGraph(this,"CFG");
- GraphHelper = NULL;
+ GraphHelper = nullptr;
#endif
}
Modified: cfe/trunk/lib/Analysis/CFGStmtMap.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFGStmtMap.cpp?rev=209191&r1=209190&r2=209191&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFGStmtMap.cpp (original)
+++ cfe/trunk/lib/Analysis/CFGStmtMap.cpp Mon May 19 23:30:07 2014
@@ -42,8 +42,8 @@ CFGBlock *CFGStmtMap::getBlock(Stmt *S)
X = PM->getParentIgnoreParens(X);
}
-
- return 0;
+
+ return nullptr;
}
static void Accumulate(SMap &SM, CFGBlock *B) {
@@ -77,7 +77,7 @@ static void Accumulate(SMap &SM, CFGBloc
CFGStmtMap *CFGStmtMap::Build(CFG *C, ParentMap *PM) {
if (!C || !PM)
- return 0;
+ return nullptr;
SMap *SM = new SMap();
Modified: cfe/trunk/lib/Analysis/CallGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CallGraph.cpp?rev=209191&r1=209190&r2=209191&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CallGraph.cpp (original)
+++ cfe/trunk/lib/Analysis/CallGraph.cpp Mon May 19 23:30:07 2014
@@ -49,7 +49,7 @@ public:
return Block->getBlockDecl();
}
- return 0;
+ return nullptr;
}
void addCalledDecl(Decl *D) {
@@ -70,7 +70,7 @@ public:
Selector Sel = ME->getSelector();
// Find the callee definition within the same translation unit.
- Decl *D = 0;
+ Decl *D = nullptr;
if (ME->isInstanceMessage())
D = IDecl->lookupPrivateMethod(Sel);
else
@@ -101,7 +101,7 @@ void CallGraph::addNodesForBlocks(DeclCo
}
CallGraph::CallGraph() {
- Root = getOrInsertNode(0);
+ Root = getOrInsertNode(nullptr);
}
CallGraph::~CallGraph() {
@@ -147,7 +147,7 @@ void CallGraph::addNodeForDecl(Decl* D,
CallGraphNode *CallGraph::getNode(const Decl *F) const {
FunctionMapTy::const_iterator I = FunctionMap.find(F);
- if (I == FunctionMap.end()) return 0;
+ if (I == FunctionMap.end()) return nullptr;
return I->second;
}
@@ -158,7 +158,7 @@ CallGraphNode *CallGraph::getOrInsertNod
Node = new CallGraphNode(F);
// Make Root node a parent of all functions to make sure all are reachable.
- if (F != 0)
+ if (F)
Root->addCallee(Node, this);
return Node;
}
Modified: cfe/trunk/lib/Analysis/Consumed.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/Consumed.cpp?rev=209191&r1=209190&r2=209191&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/Consumed.cpp (original)
+++ cfe/trunk/lib/Analysis/Consumed.cpp Mon May 19 23:30:07 2014
@@ -710,7 +710,7 @@ void ConsumedStmtVisitor::VisitBinaryOpe
LTest = LEntry->second.getVarTest();
} else {
- LTest.Var = NULL;
+ LTest.Var = nullptr;
LTest.TestsFor = CS_None;
}
@@ -718,11 +718,11 @@ void ConsumedStmtVisitor::VisitBinaryOpe
RTest = REntry->second.getVarTest();
} else {
- RTest.Var = NULL;
+ RTest.Var = nullptr;
RTest.TestsFor = CS_None;
}
-
- if (!(LTest.Var == NULL && RTest.Var == NULL))
+
+ if (!(LTest.Var == nullptr && RTest.Var == nullptr))
PropagationMap.insert(PairType(BinOp, PropagationInfo(BinOp,
static_cast<EffectiveOp>(BinOp->getOpcode() == BO_LOr), LTest, RTest)));
@@ -763,7 +763,7 @@ void ConsumedStmtVisitor::VisitCallExpr(
return;
}
- handleCall(Call, 0, FunDecl);
+ handleCall(Call, nullptr, FunDecl);
propagateReturnType(Call, FunDecl);
}
@@ -1072,9 +1072,9 @@ void ConsumedBlockInfo::addInfo(const CF
void ConsumedBlockInfo::addInfo(const CFGBlock *Block,
ConsumedStateMap *StateMap) {
-
- assert(Block != NULL && "Block pointer must not be NULL");
-
+
+ assert(Block && "Block pointer must not be NULL");
+
ConsumedStateMap *Entry = StateMapsArray[Block->getBlockID()];
if (Entry) {
@@ -1096,7 +1096,7 @@ ConsumedStateMap* ConsumedBlockInfo::bor
void ConsumedBlockInfo::discardInfo(const CFGBlock *Block) {
unsigned int BlockID = Block->getBlockID();
delete StateMapsArray[BlockID];
- StateMapsArray[BlockID] = NULL;
+ StateMapsArray[BlockID] = nullptr;
}
ConsumedStateMap* ConsumedBlockInfo::getInfo(const CFGBlock *Block) {
@@ -1106,7 +1106,7 @@ ConsumedStateMap* ConsumedBlockInfo::get
if (isBackEdgeTarget(Block)) {
return new ConsumedStateMap(*StateMap);
} else {
- StateMapsArray[Block->getBlockID()] = NULL;
+ StateMapsArray[Block->getBlockID()] = nullptr;
return StateMap;
}
}
@@ -1119,8 +1119,8 @@ bool ConsumedBlockInfo::isBackEdge(const
}
bool ConsumedBlockInfo::isBackEdgeTarget(const CFGBlock *Block) {
- assert(Block != NULL && "Block pointer must not be NULL");
-
+ assert(Block && "Block pointer must not be NULL");
+
// Anything with less than two predecessors can't be the target of a back
// edge.
if (Block->pred_size() < 2)
@@ -1356,7 +1356,7 @@ bool ConsumedAnalyzer::splitState(const
if (*++SI)
BlockInfo.addInfo(*SI, FalseStates.release());
- CurrStates = NULL;
+ CurrStates = nullptr;
return true;
}
@@ -1385,7 +1385,7 @@ void ConsumedAnalyzer::run(AnalysisDeclC
// Visit all of the function's basic blocks.
for (const auto *CurrBlock : *SortedGraph) {
- if (CurrStates == NULL)
+ if (!CurrStates)
CurrStates = BlockInfo.getInfo(CurrBlock);
if (!CurrStates) {
@@ -1393,7 +1393,7 @@ void ConsumedAnalyzer::run(AnalysisDeclC
} else if (!CurrStates->isReachable()) {
delete CurrStates;
- CurrStates = NULL;
+ CurrStates = nullptr;
continue;
}
@@ -1436,8 +1436,8 @@ void ConsumedAnalyzer::run(AnalysisDeclC
// TODO: Handle other forms of branching with precision, including while-
// and for-loops. (Deferred)
if (!splitState(CurrBlock, Visitor)) {
- CurrStates->setSource(NULL);
-
+ CurrStates->setSource(nullptr);
+
if (CurrBlock->succ_size() > 1 ||
(CurrBlock->succ_size() == 1 &&
(*CurrBlock->succ_begin())->pred_size() > 1)) {
@@ -1446,9 +1446,9 @@ void ConsumedAnalyzer::run(AnalysisDeclC
for (CFGBlock::const_succ_iterator SI = CurrBlock->succ_begin(),
SE = CurrBlock->succ_end(); SI != SE; ++SI) {
-
- if (*SI == NULL) continue;
-
+
+ if (*SI == nullptr) continue;
+
if (BlockInfo.isBackEdge(CurrBlock, *SI)) {
BlockInfo.borrowInfo(*SI)->intersectAtLoopHead(*SI, CurrBlock,
CurrStates,
@@ -1463,8 +1463,8 @@ void ConsumedAnalyzer::run(AnalysisDeclC
if (!OwnershipTaken)
delete CurrStates;
-
- CurrStates = NULL;
+
+ CurrStates = nullptr;
}
}
Modified: cfe/trunk/lib/Analysis/FormatString.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/FormatString.cpp?rev=209191&r1=209190&r2=209191&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/FormatString.cpp (original)
+++ cfe/trunk/lib/Analysis/FormatString.cpp Mon May 19 23:30:07 2014
@@ -507,7 +507,7 @@ analyze_format_string::LengthModifier::t
case None:
return "";
}
- return NULL;
+ return nullptr;
}
//===----------------------------------------------------------------------===//
@@ -539,7 +539,7 @@ const char *ConversionSpecifier::toStrin
case nArg: return "n";
case PercentArg: return "%";
case ScanListArg: return "[";
- case InvalidSpecifier: return NULL;
+ case InvalidSpecifier: return nullptr;
// POSIX unicode extensions.
case CArg: return "C";
@@ -551,7 +551,7 @@ const char *ConversionSpecifier::toStrin
// GlibC specific specifiers.
case PrintErrno: return "m";
}
- return NULL;
+ return nullptr;
}
Optional<ConversionSpecifier>
Modified: cfe/trunk/lib/Analysis/FormatStringParsing.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/FormatStringParsing.h?rev=209191&r1=209190&r2=209191&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/FormatStringParsing.h (original)
+++ cfe/trunk/lib/Analysis/FormatStringParsing.h Mon May 19 23:30:07 2014
@@ -53,14 +53,14 @@ template <typename T> class SpecifierRes
bool Stop;
public:
SpecifierResult(bool stop = false)
- : Start(0), Stop(stop) {}
+ : Start(nullptr), Stop(stop) {}
SpecifierResult(const char *start,
const T &fs)
: FS(fs), Start(start), Stop(false) {}
const char *getStart() const { return Start; }
bool shouldStop() const { return Stop; }
- bool hasValue() const { return Start != 0; }
+ bool hasValue() const { return Start != nullptr; }
const T &getValue() const {
assert(hasValue());
return FS;
Modified: cfe/trunk/lib/Analysis/LiveVariables.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/LiveVariables.cpp?rev=209191&r1=209190&r2=209191&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/LiveVariables.cpp (original)
+++ cfe/trunk/lib/Analysis/LiveVariables.cpp Mon May 19 23:30:07 2014
@@ -72,7 +72,7 @@ void DataflowWorklist::sortWorklist() {
const CFGBlock *DataflowWorklist::dequeue() {
if (worklist.empty())
- return 0;
+ return nullptr;
const CFGBlock *b = worklist.pop_back_val();
enqueuedBlocks[b->getBlockID()] = false;
return b;
@@ -94,10 +94,10 @@ public:
LiveVariables::LivenessValues
merge(LiveVariables::LivenessValues valsA,
LiveVariables::LivenessValues valsB);
-
- LiveVariables::LivenessValues runOnBlock(const CFGBlock *block,
- LiveVariables::LivenessValues val,
- LiveVariables::Observer *obs = 0);
+
+ LiveVariables::LivenessValues
+ runOnBlock(const CFGBlock *block, LiveVariables::LivenessValues val,
+ LiveVariables::Observer *obs = nullptr);
void dumpBlockLiveness(const SourceManager& M);
@@ -224,8 +224,8 @@ static const VariableArrayType *FindVA(Q
ty = VT->getElementType().getTypePtr();
}
-
- return 0;
+
+ return nullptr;
}
static const Stmt *LookThroughStmt(const Stmt *S) {
@@ -291,7 +291,7 @@ void TransferFunctions::Visit(Stmt *S) {
const DeclStmt *DS = cast<DeclStmt>(S);
if (const VarDecl *VD = dyn_cast<VarDecl>(DS->getSingleDecl())) {
for (const VariableArrayType* VA = FindVA(VD->getType());
- VA != 0; VA = FindVA(VA->getElementType())) {
+ VA != nullptr; VA = FindVA(VA->getElementType())) {
AddLiveStmt(val.liveStmts, LV.SSetFact, VA->getSizeExpr());
}
}
@@ -384,8 +384,8 @@ void TransferFunctions::VisitDeclStmt(De
void TransferFunctions::VisitObjCForCollectionStmt(ObjCForCollectionStmt *OS) {
// Kill the iteration variable.
- DeclRefExpr *DR = 0;
- const VarDecl *VD = 0;
+ DeclRefExpr *DR = nullptr;
+ const VarDecl *VD = nullptr;
Stmt *element = OS->getElement();
if (DeclStmt *DS = dyn_cast<DeclStmt>(element)) {
@@ -493,12 +493,12 @@ LiveVariables::computeLiveness(AnalysisD
// No CFG? Bail out.
CFG *cfg = AC.getCFG();
if (!cfg)
- return 0;
+ return nullptr;
// The analysis currently has scalability issues for very large CFGs.
// Bail out if it looks too large.
if (cfg->getNumBlockIDs() > 300000)
- return 0;
+ return nullptr;
LiveVariablesImpl *LV = new LiveVariablesImpl(AC, killAtAssign);
Modified: cfe/trunk/lib/Analysis/PostOrderCFGView.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/PostOrderCFGView.cpp?rev=209191&r1=209190&r2=209191&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/PostOrderCFGView.cpp (original)
+++ cfe/trunk/lib/Analysis/PostOrderCFGView.cpp Mon May 19 23:30:07 2014
@@ -31,7 +31,7 @@ PostOrderCFGView::PostOrderCFGView(const
PostOrderCFGView *PostOrderCFGView::create(AnalysisDeclContext &ctx) {
const CFG *cfg = ctx.getCFG();
if (!cfg)
- return 0;
+ return nullptr;
return new PostOrderCFGView(cfg);
}
Modified: cfe/trunk/lib/Analysis/PrintfFormatString.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/PrintfFormatString.cpp?rev=209191&r1=209190&r2=209191&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/PrintfFormatString.cpp (original)
+++ cfe/trunk/lib/Analysis/PrintfFormatString.cpp Mon May 19 23:30:07 2014
@@ -60,7 +60,7 @@ static PrintfSpecifierResult ParsePrintf
using namespace clang::analyze_printf;
const char *I = Beg;
- const char *Start = 0;
+ const char *Start = nullptr;
UpdateOnReturn <const char*> UpdateBeg(Beg, I);
// Look for a '%' character that indicates the start of a format specifier.
@@ -124,7 +124,7 @@ static PrintfSpecifierResult ParsePrintf
// Look for the field width (if any).
if (ParseFieldWidth(H, FS, Start, I, E,
- FS.usesPositionalArg() ? 0 : &argIndex))
+ FS.usesPositionalArg() ? nullptr : &argIndex))
return true;
if (I == E) {
@@ -142,7 +142,7 @@ static PrintfSpecifierResult ParsePrintf
}
if (ParsePrecision(H, FS, Start, I, E,
- FS.usesPositionalArg() ? 0 : &argIndex))
+ FS.usesPositionalArg() ? nullptr : &argIndex))
return true;
if (I == E) {
Modified: cfe/trunk/lib/Analysis/PseudoConstantAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/PseudoConstantAnalysis.cpp?rev=209191&r1=209190&r2=209191&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/PseudoConstantAnalysis.cpp (original)
+++ cfe/trunk/lib/Analysis/PseudoConstantAnalysis.cpp Mon May 19 23:30:07 2014
@@ -70,7 +70,7 @@ const Decl *PseudoConstantAnalysis::getD
if (const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(E))
return DR->getDecl();
else
- return 0;
+ return nullptr;
}
void PseudoConstantAnalysis::RunAnalysis() {
Modified: cfe/trunk/lib/Analysis/ReachableCode.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/ReachableCode.cpp?rev=209191&r1=209190&r2=209191&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/ReachableCode.cpp (original)
+++ cfe/trunk/lib/Analysis/ReachableCode.cpp Mon May 19 23:30:07 2014
@@ -402,7 +402,7 @@ const Stmt *DeadCodeScan::findDeadCode(c
}
}
- return 0;
+ return nullptr;
}
static int SrcCmp(const std::pair<const CFGBlock *, const Stmt *> *p1,
@@ -606,7 +606,7 @@ void Callback::anchor() { }
unsigned ScanReachableFromBlock(const CFGBlock *Start,
llvm::BitVector &Reachable) {
- return scanFromBlock(Start, Reachable, /* SourceManager* */ 0, false);
+ return scanFromBlock(Start, Reachable, /* SourceManager* */ nullptr, false);
}
void FindUnreachableCode(AnalysisDeclContext &AC, Preprocessor &PP,
Modified: cfe/trunk/lib/Analysis/ScanfFormatString.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/ScanfFormatString.cpp?rev=209191&r1=209190&r2=209191&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/ScanfFormatString.cpp (original)
+++ cfe/trunk/lib/Analysis/ScanfFormatString.cpp Mon May 19 23:30:07 2014
@@ -82,7 +82,7 @@ static ScanfSpecifierResult ParseScanfSp
using namespace clang::analyze_scanf;
const char *I = Beg;
- const char *Start = 0;
+ const char *Start = nullptr;
UpdateOnReturn <const char*> UpdateBeg(Beg, I);
// Look for a '%' character that indicates the start of a format specifier.
Modified: cfe/trunk/lib/Analysis/ThreadSafety.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/ThreadSafety.cpp?rev=209191&r1=209190&r2=209191&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/ThreadSafety.cpp (original)
+++ cfe/trunk/lib/Analysis/ThreadSafety.cpp Mon May 19 23:30:07 2014
@@ -177,8 +177,8 @@ private:
CallingContext* PrevCtx; // The previous context; or 0 if none.
CallingContext(const NamedDecl *D)
- : AttrDecl(D), SelfArg(0), SelfArrow(false), NumArgs(0), FunArgs(0),
- PrevCtx(0) {}
+ : AttrDecl(D), SelfArg(nullptr), SelfArrow(false), NumArgs(0),
+ FunArgs(nullptr), PrevCtx(nullptr) {}
};
typedef SmallVector<SExprNode, 4> NodeVector;
@@ -189,7 +189,7 @@ private:
NodeVector NodeVec;
private:
- unsigned make(ExprOp O, unsigned F = 0, const void *D = 0) {
+ unsigned make(ExprOp O, unsigned F = 0, const void *D = nullptr) {
NodeVec.push_back(SExprNode(O, F, D));
return NodeVec.size() - 1;
}
@@ -236,7 +236,7 @@ private:
return D; // Method does not override anything
D = *I; // FIXME: this does not work with multiple inheritance.
}
- return 0;
+ return nullptr;
}
unsigned makeMCall(unsigned NumArgs, const CXXMethodDecl *D) {
@@ -272,8 +272,8 @@ private:
/// NDeref returns the number of Derefence and AddressOf operations
/// preceding the Expr; this is used to decide whether to pretty-print
/// SExprs with . or ->.
- unsigned buildSExpr(const Expr *Exp, CallingContext* CallCtx,
- int* NDeref = 0) {
+ unsigned buildSExpr(const Expr *Exp, CallingContext *CallCtx,
+ int *NDeref = nullptr) {
if (!Exp)
return 0;
@@ -370,7 +370,7 @@ private:
}
}
unsigned NumCallArgs = CE->getNumArgs();
- unsigned Root = makeCall(NumCallArgs, 0);
+ unsigned Root = makeCall(NumCallArgs, nullptr);
unsigned Sz = buildSExpr(CE->getCallee(), CallCtx);
const Expr* const* CallArgs = CE->getArgs();
for (unsigned i = 0; i < NumCallArgs; ++i) {
@@ -463,7 +463,7 @@ private:
/// occurs.
/// \param D The declaration to which the lock/unlock attribute is attached.
void buildSExprFromExpr(const Expr *MutexExp, const Expr *DeclExp,
- const NamedDecl *D, VarDecl *SelfDecl = 0) {
+ const NamedDecl *D, VarDecl *SelfDecl = nullptr) {
CallingContext CallCtx(D);
if (MutexExp) {
@@ -480,8 +480,8 @@ private:
}
// If we are processing a raw attribute expression, with no substitutions.
- if (DeclExp == 0) {
- buildSExpr(MutexExp, 0);
+ if (!DeclExp) {
+ buildSExpr(MutexExp, nullptr);
return;
}
@@ -501,7 +501,7 @@ private:
CallCtx.FunArgs = CE->getArgs();
} else if (const CXXConstructExpr *CE =
dyn_cast<CXXConstructExpr>(DeclExp)) {
- CallCtx.SelfArg = 0; // Will be set below
+ CallCtx.SelfArg = nullptr; // Will be set below
CallCtx.NumArgs = CE->getNumArgs();
CallCtx.FunArgs = CE->getArgs();
} else if (D && isa<CXXDestructorDecl>(D)) {
@@ -517,16 +517,16 @@ private:
CallCtx.SelfArg = &SelfDRE;
// If the attribute has no arguments, then assume the argument is "this".
- if (MutexExp == 0)
- buildSExpr(CallCtx.SelfArg, 0);
+ if (!MutexExp)
+ buildSExpr(CallCtx.SelfArg, nullptr);
else // For most attributes.
buildSExpr(MutexExp, &CallCtx);
return;
}
// If the attribute has no arguments, then assume the argument is "this".
- if (MutexExp == 0)
- buildSExpr(CallCtx.SelfArg, 0);
+ if (!MutexExp)
+ buildSExpr(CallCtx.SelfArg, nullptr);
else // For most attributes.
buildSExpr(MutexExp, &CallCtx);
}
@@ -544,8 +544,8 @@ public:
/// occurs.
/// \param D The declaration to which the lock/unlock attribute is attached.
/// Caller must check isValid() after construction.
- SExpr(const Expr* MutexExp, const Expr *DeclExp, const NamedDecl* D,
- VarDecl *SelfDecl=0) {
+ SExpr(const Expr *MutexExp, const Expr *DeclExp, const NamedDecl *D,
+ VarDecl *SelfDecl = nullptr) {
buildSExprFromExpr(MutexExp, DeclExp, D, SelfDecl);
}
@@ -962,7 +962,7 @@ public:
// Create reference to previous definition
VarDefinition(const NamedDecl *D, unsigned R, Context C)
- : Dec(D), Exp(0), Ref(R), Ctx(C)
+ : Dec(D), Exp(nullptr), Ref(R), Ctx(C)
{ }
};
@@ -975,14 +975,14 @@ private:
public:
LocalVariableMap() {
// index 0 is a placeholder for undefined variables (aka phi-nodes).
- VarDefinitions.push_back(VarDefinition(0, 0u, getEmptyContext()));
+ VarDefinitions.push_back(VarDefinition(nullptr, 0u, getEmptyContext()));
}
/// Look up a definition, within the given context.
const VarDefinition* lookup(const NamedDecl *D, Context Ctx) {
const unsigned *i = Ctx.lookup(D);
if (!i)
- return 0;
+ return nullptr;
assert(*i < VarDefinitions.size());
return &VarDefinitions[*i];
}
@@ -993,7 +993,7 @@ public:
const Expr* lookupExpr(const NamedDecl *D, Context &Ctx) {
const unsigned *P = Ctx.lookup(D);
if (!P)
- return 0;
+ return nullptr;
unsigned i = *P;
while (i > 0) {
@@ -1003,7 +1003,7 @@ public:
}
i = VarDefinitions[i].Ref;
}
- return 0;
+ return nullptr;
}
Context getEmptyContext() { return ContextFactory.getEmptyMap(); }
@@ -1296,7 +1296,7 @@ void LocalVariableMap::traverseCFG(CFG *
for (CFGBlock::const_pred_iterator PI = CurrBlock->pred_begin(),
PE = CurrBlock->pred_end(); PI != PE; ++PI) {
// if *PI -> CurrBlock is a back edge, so skip it
- if (*PI == 0 || !VisitedBlocks.alreadySet(*PI)) {
+ if (*PI == nullptr || !VisitedBlocks.alreadySet(*PI)) {
HasBackEdges = true;
continue;
}
@@ -1322,7 +1322,7 @@ void LocalVariableMap::traverseCFG(CFG *
createReferenceContext(CurrBlockInfo->EntryContext);
// Create a starting context index for the current block
- saveContext(0, CurrBlockInfo->EntryContext);
+ saveContext(nullptr, CurrBlockInfo->EntryContext);
CurrBlockInfo->EntryIndex = getContextIndex();
// Visit all the statements in the basic block.
@@ -1345,7 +1345,7 @@ void LocalVariableMap::traverseCFG(CFG *
for (CFGBlock::const_succ_iterator SI = CurrBlock->succ_begin(),
SE = CurrBlock->succ_end(); SI != SE; ++SI) {
// if CurrBlock -> *SI is *not* a back edge
- if (*SI == 0 || !VisitedBlocks.alreadySet(*SI))
+ if (*SI == nullptr || !VisitedBlocks.alreadySet(*SI))
continue;
CFGBlock *FirstLoopBlock = *SI;
@@ -1357,7 +1357,7 @@ void LocalVariableMap::traverseCFG(CFG *
// Put an extra entry at the end of the indexed context array
unsigned exitID = CFGraph->getExit().getBlockID();
- saveContext(0, BlockInfo[exitID].ExitContext);
+ saveContext(nullptr, BlockInfo[exitID].ExitContext);
}
/// Find the appropriate source locations to use when producing diagnostics for
@@ -1423,7 +1423,7 @@ public:
template <typename AttrType>
void getMutexIDs(MutexIDList &Mtxs, AttrType *Attr, Expr *Exp,
- const NamedDecl *D, VarDecl *SelfDecl=0);
+ const NamedDecl *D, VarDecl *SelfDecl = nullptr);
template <class AttrType>
void getMutexIDs(MutexIDList &Mtxs, AttrType *Attr, Expr *Exp,
@@ -1603,9 +1603,10 @@ void ThreadSafetyAnalyzer::getMutexIDs(M
VarDecl *SelfDecl) {
if (Attr->args_size() == 0) {
// The mutex held is the "this" object.
- SExpr Mu(0, Exp, D, SelfDecl);
+ SExpr Mu(nullptr, Exp, D, SelfDecl);
if (!Mu.isValid())
- SExpr::warnInvalidLock(Handler, 0, Exp, D, ClassifyDiagnostic(Attr));
+ SExpr::warnInvalidLock(Handler, nullptr, Exp, D,
+ ClassifyDiagnostic(Attr));
else
Mtxs.push_back_nodup(Mu);
return;
@@ -1675,7 +1676,7 @@ const CallExpr* ThreadSafetyAnalyzer::ge
LocalVarContext C,
bool &Negate) {
if (!Cond)
- return 0;
+ return nullptr;
if (const CallExpr *CallExp = dyn_cast<CallExpr>(Cond)) {
return CallExp;
@@ -1698,7 +1699,7 @@ const CallExpr* ThreadSafetyAnalyzer::ge
Negate = !Negate;
return getTrylockCallExpr(UOP->getSubExpr(), C, Negate);
}
- return 0;
+ return nullptr;
}
else if (const BinaryOperator *BOP = dyn_cast<BinaryOperator>(Cond)) {
if (BOP->getOpcode() == BO_EQ || BOP->getOpcode() == BO_NE) {
@@ -1715,7 +1716,7 @@ const CallExpr* ThreadSafetyAnalyzer::ge
if (!TCond) Negate = !Negate;
return getTrylockCallExpr(BOP->getRHS(), C, Negate);
}
- return 0;
+ return nullptr;
}
if (BOP->getOpcode() == BO_LAnd) {
// LHS must have been evaluated in a different block.
@@ -1724,9 +1725,9 @@ const CallExpr* ThreadSafetyAnalyzer::ge
if (BOP->getOpcode() == BO_LOr) {
return getTrylockCallExpr(BOP->getRHS(), C, Negate);
}
- return 0;
+ return nullptr;
}
- return 0;
+ return nullptr;
}
@@ -1817,7 +1818,7 @@ class BuildLockset : public StmtVisitor<
void checkAccess(const Expr *Exp, AccessKind AK);
void checkPtAccess(const Expr *Exp, AccessKind AK);
- void handleCall(Expr *Exp, const NamedDecl *D, VarDecl *VD = 0);
+ void handleCall(Expr *Exp, const NamedDecl *D, VarDecl *VD = nullptr);
public:
BuildLockset(ThreadSafetyAnalyzer *Anlzr, CFGBlockInfo &Info)
@@ -2084,7 +2085,7 @@ void BuildLockset::handleCall(Expr *Exp,
if (isScopedVar) {
SourceLocation MLoc = VD->getLocation();
DeclRefExpr DRE(VD, false, VD->getType(), VK_LValue, VD->getLocation());
- SExpr SMutex(&DRE, 0, 0);
+ SExpr SMutex(&DRE, nullptr, nullptr);
for (const auto &M : ExclusiveLocksToAdd)
Analyzer->addLock(FSet, SMutex, LockData(MLoc, LK_Exclusive, M),
@@ -2399,7 +2400,7 @@ void ThreadSafetyAnalyzer::runAnalysis(A
Loc = Attr->getLocation();
if (const auto *A = dyn_cast<RequiresCapabilityAttr>(Attr)) {
getMutexIDs(A->isShared() ? SharedLocksToAdd : ExclusiveLocksToAdd, A,
- 0, D);
+ nullptr, D);
CapDiagKind = ClassifyDiagnostic(A);
} else if (const auto *A = dyn_cast<ReleaseCapabilityAttr>(Attr)) {
// UNLOCK_FUNCTION() is used to hide the underlying lock implementation.
@@ -2573,7 +2574,7 @@ void ThreadSafetyAnalyzer::runAnalysis(A
SE = CurrBlock->succ_end(); SI != SE; ++SI) {
// if CurrBlock -> *SI is *not* a back edge
- if (*SI == 0 || !VisitedBlocks.alreadySet(*SI))
+ if (*SI == nullptr || !VisitedBlocks.alreadySet(*SI))
continue;
CFGBlock *FirstLoopBlock = *SI;
Modified: cfe/trunk/lib/Analysis/UninitializedValues.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/UninitializedValues.cpp?rev=209191&r1=209190&r2=209191&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/UninitializedValues.cpp (original)
+++ cfe/trunk/lib/Analysis/UninitializedValues.cpp Mon May 19 23:30:07 2014
@@ -236,7 +236,7 @@ void DataflowWorklist::enqueueSuccessors
}
const CFGBlock *DataflowWorklist::dequeue() {
- const CFGBlock *B = 0;
+ const CFGBlock *B = nullptr;
// First dequeue from the worklist. This can represent
// updates along backedges that we want propagated as quickly as possible.
@@ -250,7 +250,7 @@ const CFGBlock *DataflowWorklist::dequeu
++PO_I;
}
else {
- return 0;
+ return nullptr;
}
assert(enqueuedBlocks[B->getBlockID()] == true);
@@ -295,7 +295,7 @@ static FindVarResult findVar(const Expr
if (const VarDecl *VD = dyn_cast<VarDecl>(DRE->getDecl()))
if (isTrackedVar(VD, DC))
return FindVarResult(VD, DRE);
- return FindVarResult(0, 0);
+ return FindVarResult(nullptr, nullptr);
}
/// \brief Classify each DeclRefExpr as an initialization or a use. Any
@@ -353,7 +353,7 @@ static const DeclRefExpr *getSelfInitExp
if (DRE && DRE->getDecl() == VD)
return DRE;
}
- return 0;
+ return nullptr;
}
void ClassifyRefs::classify(const Expr *E, Class C) {
@@ -542,7 +542,7 @@ public:
// This block initializes the variable.
continue;
if (AtPredExit == MayUninitialized &&
- vals.getValue(B, 0, vd) == Uninitialized) {
+ vals.getValue(B, nullptr, vd) == Uninitialized) {
// This block declares the variable (uninitialized), and is reachable
// from a block that initializes the variable. We can't guarantee to
// give an earlier location for the diagnostic (and it appears that
More information about the cfe-commits
mailing list