Fix Clang-tidy modernize-use-nullptr warnings in source directories; other minor cleanups
Patch by Eugene Zelenko! Differential Revision: http://reviews.llvm.org/D13406 llvm-svn: 249484
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
//===- ThreadSafetyCommon.cpp ----------------------------------*- C++ --*-===//
|
||||
//===- ThreadSafetyCommon.cpp -----------------------------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <algorithm>
|
||||
#include <climits>
|
||||
#include <vector>
|
||||
|
||||
using namespace clang;
|
||||
using namespace threadSafety;
|
||||
|
||||
@@ -66,7 +67,6 @@ static bool isIncompletePhi(const til::SExpr *E) {
|
||||
|
||||
typedef SExprBuilder::CallingContext CallingContext;
|
||||
|
||||
|
||||
til::SExpr *SExprBuilder::lookupStmt(const Stmt *S) {
|
||||
auto It = SMap.find(S);
|
||||
if (It != SMap.end())
|
||||
@@ -74,7 +74,6 @@ til::SExpr *SExprBuilder::lookupStmt(const Stmt *S) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
til::SCFG *SExprBuilder::buildCFG(CFGWalker &Walker) {
|
||||
Walker.walk(*this);
|
||||
return Scfg;
|
||||
@@ -85,7 +84,6 @@ static bool isCalleeArrow(const Expr *E) {
|
||||
return ME ? ME->isArrow() : false;
|
||||
}
|
||||
|
||||
|
||||
/// \brief Translate a clang expression in an attribute to a til::SExpr.
|
||||
/// Constructs the context from D, DeclExp, and SelfDecl.
|
||||
///
|
||||
@@ -148,7 +146,6 @@ CapabilityExpr SExprBuilder::translateAttrExpr(const Expr *AttrExp,
|
||||
return translateAttrExpr(AttrExp, &Ctx);
|
||||
}
|
||||
|
||||
|
||||
/// \brief Translate a clang expression in an attribute to a til::SExpr.
|
||||
// This assumes a CallingContext has already been created.
|
||||
CapabilityExpr SExprBuilder::translateAttrExpr(const Expr *AttrExp,
|
||||
@@ -195,8 +192,6 @@ CapabilityExpr SExprBuilder::translateAttrExpr(const Expr *AttrExp,
|
||||
return CapabilityExpr(E, Neg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Translate a clang statement or expression to a TIL expression.
|
||||
// Also performs substitution of variables; Ctx provides the context.
|
||||
// Dispatches on the type of S.
|
||||
@@ -268,8 +263,6 @@ til::SExpr *SExprBuilder::translate(const Stmt *S, CallingContext *Ctx) {
|
||||
return new (Arena) til::Undefined(S);
|
||||
}
|
||||
|
||||
|
||||
|
||||
til::SExpr *SExprBuilder::translateDeclRefExpr(const DeclRefExpr *DRE,
|
||||
CallingContext *Ctx) {
|
||||
const ValueDecl *VD = cast<ValueDecl>(DRE->getDecl()->getCanonicalDecl());
|
||||
@@ -294,7 +287,6 @@ til::SExpr *SExprBuilder::translateDeclRefExpr(const DeclRefExpr *DRE,
|
||||
return new (Arena) til::LiteralPtr(VD);
|
||||
}
|
||||
|
||||
|
||||
til::SExpr *SExprBuilder::translateCXXThisExpr(const CXXThisExpr *TE,
|
||||
CallingContext *Ctx) {
|
||||
// Substitute for 'this'
|
||||
@@ -313,7 +305,7 @@ static const ValueDecl *getValueDeclFromSExpr(const til::SExpr *E) {
|
||||
return P->clangDecl();
|
||||
if (auto *L = dyn_cast<til::LiteralPtr>(E))
|
||||
return L->clangDecl();
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static bool hasCppPointerType(const til::SExpr *E) {
|
||||
@@ -355,7 +347,6 @@ til::SExpr *SExprBuilder::translateMemberExpr(const MemberExpr *ME,
|
||||
return P;
|
||||
}
|
||||
|
||||
|
||||
til::SExpr *SExprBuilder::translateCallExpr(const CallExpr *CE,
|
||||
CallingContext *Ctx,
|
||||
const Expr *SelfE) {
|
||||
@@ -381,7 +372,6 @@ til::SExpr *SExprBuilder::translateCallExpr(const CallExpr *CE,
|
||||
return new (Arena) til::Call(E, CE);
|
||||
}
|
||||
|
||||
|
||||
til::SExpr *SExprBuilder::translateCXXMemberCallExpr(
|
||||
const CXXMemberCallExpr *ME, CallingContext *Ctx) {
|
||||
if (CapabilityExprMode) {
|
||||
@@ -397,7 +387,6 @@ til::SExpr *SExprBuilder::translateCXXMemberCallExpr(
|
||||
ME->getImplicitObjectArgument());
|
||||
}
|
||||
|
||||
|
||||
til::SExpr *SExprBuilder::translateCXXOperatorCallExpr(
|
||||
const CXXOperatorCallExpr *OCE, CallingContext *Ctx) {
|
||||
if (CapabilityExprMode) {
|
||||
@@ -412,7 +401,6 @@ til::SExpr *SExprBuilder::translateCXXOperatorCallExpr(
|
||||
return translateCallExpr(cast<CallExpr>(OCE), Ctx);
|
||||
}
|
||||
|
||||
|
||||
til::SExpr *SExprBuilder::translateUnaryOperator(const UnaryOperator *UO,
|
||||
CallingContext *Ctx) {
|
||||
switch (UO->getOpcode()) {
|
||||
@@ -462,7 +450,6 @@ til::SExpr *SExprBuilder::translateUnaryOperator(const UnaryOperator *UO,
|
||||
return new (Arena) til::Undefined(UO);
|
||||
}
|
||||
|
||||
|
||||
til::SExpr *SExprBuilder::translateBinOp(til::TIL_BinaryOpcode Op,
|
||||
const BinaryOperator *BO,
|
||||
CallingContext *Ctx, bool Reverse) {
|
||||
@@ -474,7 +461,6 @@ til::SExpr *SExprBuilder::translateBinOp(til::TIL_BinaryOpcode Op,
|
||||
return new (Arena) til::BinaryOp(Op, E0, E1);
|
||||
}
|
||||
|
||||
|
||||
til::SExpr *SExprBuilder::translateBinAssign(til::TIL_BinaryOpcode Op,
|
||||
const BinaryOperator *BO,
|
||||
CallingContext *Ctx,
|
||||
@@ -501,7 +487,6 @@ til::SExpr *SExprBuilder::translateBinAssign(til::TIL_BinaryOpcode Op,
|
||||
return new (Arena) til::Store(E0, E1);
|
||||
}
|
||||
|
||||
|
||||
til::SExpr *SExprBuilder::translateBinaryOperator(const BinaryOperator *BO,
|
||||
CallingContext *Ctx) {
|
||||
switch (BO->getOpcode()) {
|
||||
@@ -547,7 +532,6 @@ til::SExpr *SExprBuilder::translateBinaryOperator(const BinaryOperator *BO,
|
||||
return new (Arena) til::Undefined(BO);
|
||||
}
|
||||
|
||||
|
||||
til::SExpr *SExprBuilder::translateCastExpr(const CastExpr *CE,
|
||||
CallingContext *Ctx) {
|
||||
clang::CastKind K = CE->getCastKind();
|
||||
@@ -581,7 +565,6 @@ til::SExpr *SExprBuilder::translateCastExpr(const CastExpr *CE,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
til::SExpr *
|
||||
SExprBuilder::translateArraySubscriptExpr(const ArraySubscriptExpr *E,
|
||||
CallingContext *Ctx) {
|
||||
@@ -590,7 +573,6 @@ SExprBuilder::translateArraySubscriptExpr(const ArraySubscriptExpr *E,
|
||||
return new (Arena) til::ArrayIndex(E0, E1);
|
||||
}
|
||||
|
||||
|
||||
til::SExpr *
|
||||
SExprBuilder::translateAbstractConditionalOperator(
|
||||
const AbstractConditionalOperator *CO, CallingContext *Ctx) {
|
||||
@@ -600,7 +582,6 @@ SExprBuilder::translateAbstractConditionalOperator(
|
||||
return new (Arena) til::IfThenElse(C, T, E);
|
||||
}
|
||||
|
||||
|
||||
til::SExpr *
|
||||
SExprBuilder::translateDeclStmt(const DeclStmt *S, CallingContext *Ctx) {
|
||||
DeclGroupRef DGrp = S->getDeclGroup();
|
||||
@@ -622,8 +603,6 @@ SExprBuilder::translateDeclStmt(const DeclStmt *S, CallingContext *Ctx) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// If (E) is non-trivial, then add it to the current basic block, and
|
||||
// update the statement map so that S refers to E. Returns a new variable
|
||||
// that refers to E.
|
||||
@@ -640,7 +619,6 @@ til::SExpr *SExprBuilder::addStatement(til::SExpr* E, const Stmt *S,
|
||||
return E;
|
||||
}
|
||||
|
||||
|
||||
// Returns the current value of VD, if known, and nullptr otherwise.
|
||||
til::SExpr *SExprBuilder::lookupVarDecl(const ValueDecl *VD) {
|
||||
auto It = LVarIdxMap.find(VD);
|
||||
@@ -651,7 +629,6 @@ til::SExpr *SExprBuilder::lookupVarDecl(const ValueDecl *VD) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
// if E is a til::Variable, update its clangDecl.
|
||||
static void maybeUpdateVD(til::SExpr *E, const ValueDecl *VD) {
|
||||
if (!E)
|
||||
@@ -671,7 +648,6 @@ til::SExpr *SExprBuilder::addVarDecl(const ValueDecl *VD, til::SExpr *E) {
|
||||
return E;
|
||||
}
|
||||
|
||||
|
||||
// Updates a current variable declaration. (E.g. by assignment)
|
||||
til::SExpr *SExprBuilder::updateVarDecl(const ValueDecl *VD, til::SExpr *E) {
|
||||
maybeUpdateVD(E, VD);
|
||||
@@ -686,7 +662,6 @@ til::SExpr *SExprBuilder::updateVarDecl(const ValueDecl *VD, til::SExpr *E) {
|
||||
return E;
|
||||
}
|
||||
|
||||
|
||||
// Make a Phi node in the current block for the i^th variable in CurrentVarMap.
|
||||
// If E != null, sets Phi[CurrentBlockInfo->ArgIndex] = E.
|
||||
// If E == null, this is a backedge and will be set later.
|
||||
@@ -729,7 +704,6 @@ void SExprBuilder::makePhiNodeVar(unsigned i, unsigned NPreds, til::SExpr *E) {
|
||||
CurrentLVarMap.elem(i).second = Ph;
|
||||
}
|
||||
|
||||
|
||||
// Merge values from Map into the current variable map.
|
||||
// This will construct Phi nodes in the current basic block as necessary.
|
||||
void SExprBuilder::mergeEntryMap(LVarDefinitionMap Map) {
|
||||
@@ -764,7 +738,6 @@ void SExprBuilder::mergeEntryMap(LVarDefinitionMap Map) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Merge a back edge into the current variable map.
|
||||
// This will create phi nodes for all variables in the variable map.
|
||||
void SExprBuilder::mergeEntryMapBackEdge() {
|
||||
@@ -791,7 +764,6 @@ void SExprBuilder::mergeEntryMapBackEdge() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Update the phi nodes that were initially created for a back edge
|
||||
// once the variable definitions have been computed.
|
||||
// I.e., merge the current variable map into the phi nodes for Blk.
|
||||
@@ -844,7 +816,6 @@ void SExprBuilder::enterCFG(CFG *Cfg, const NamedDecl *D,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SExprBuilder::enterCFGBlock(const CFGBlock *B) {
|
||||
// Intialize TIL basic block and add it to the CFG.
|
||||
CurrentBB = lookupBlock(B);
|
||||
@@ -858,7 +829,6 @@ void SExprBuilder::enterCFGBlock(const CFGBlock *B) {
|
||||
// assert(!CurrentLVarMap.valid() && "CurrentLVarMap already initialized.");
|
||||
}
|
||||
|
||||
|
||||
void SExprBuilder::handlePredecessor(const CFGBlock *Pred) {
|
||||
// Compute CurrentLVarMap on entry from ExitMaps of predecessors
|
||||
|
||||
@@ -874,12 +844,10 @@ void SExprBuilder::handlePredecessor(const CFGBlock *Pred) {
|
||||
++CurrentBlockInfo->ProcessedPredecessors;
|
||||
}
|
||||
|
||||
|
||||
void SExprBuilder::handlePredecessorBackEdge(const CFGBlock *Pred) {
|
||||
mergeEntryMapBackEdge();
|
||||
}
|
||||
|
||||
|
||||
void SExprBuilder::enterCFGBlockBody(const CFGBlock *B) {
|
||||
// The merge*() methods have created arguments.
|
||||
// Push those arguments onto the basic block.
|
||||
@@ -889,13 +857,11 @@ void SExprBuilder::enterCFGBlockBody(const CFGBlock *B) {
|
||||
CurrentBB->addArgument(A);
|
||||
}
|
||||
|
||||
|
||||
void SExprBuilder::handleStatement(const Stmt *S) {
|
||||
til::SExpr *E = translate(S, nullptr);
|
||||
addStatement(E, S);
|
||||
}
|
||||
|
||||
|
||||
void SExprBuilder::handleDestructorCall(const VarDecl *VD,
|
||||
const CXXDestructorDecl *DD) {
|
||||
til::SExpr *Sf = new (Arena) til::LiteralPtr(VD);
|
||||
@@ -905,8 +871,6 @@ void SExprBuilder::handleDestructorCall(const VarDecl *VD,
|
||||
addStatement(E, nullptr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SExprBuilder::exitCFGBlockBody(const CFGBlock *B) {
|
||||
CurrentBB->instructions().reserve(
|
||||
static_cast<unsigned>(CurrentInstructions.size()), Arena);
|
||||
@@ -934,18 +898,15 @@ void SExprBuilder::exitCFGBlockBody(const CFGBlock *B) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SExprBuilder::handleSuccessor(const CFGBlock *Succ) {
|
||||
++CurrentBlockInfo->UnprocessedSuccessors;
|
||||
}
|
||||
|
||||
|
||||
void SExprBuilder::handleSuccessorBackEdge(const CFGBlock *Succ) {
|
||||
mergePhiNodesBackEdge(Succ);
|
||||
++BBInfo[Succ->getBlockID()].ProcessedPredecessors;
|
||||
}
|
||||
|
||||
|
||||
void SExprBuilder::exitCFGBlock(const CFGBlock *B) {
|
||||
CurrentArguments.clear();
|
||||
CurrentInstructions.clear();
|
||||
@@ -954,7 +915,6 @@ void SExprBuilder::exitCFGBlock(const CFGBlock *B) {
|
||||
CurrentBlockInfo = nullptr;
|
||||
}
|
||||
|
||||
|
||||
void SExprBuilder::exitCFG(const CFGBlock *Last) {
|
||||
for (auto *Ph : IncompleteArgs) {
|
||||
if (Ph->status() == til::Phi::PH_Incomplete)
|
||||
@@ -966,7 +926,6 @@ void SExprBuilder::exitCFG(const CFGBlock *Last) {
|
||||
IncompleteArgs.clear();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
void printSCFG(CFGWalker &Walker) {
|
||||
llvm::BumpPtrAllocator Bpa;
|
||||
|
||||
Reference in New Issue
Block a user