Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 66c486f

Browse files
committed
Rename 'currentX' to 'currX' throughout analyzer and libAnalysis.
Also rename 'getCurrentBlockCounter()' to 'blockCount()'. This ripples a bunch of code simplifications; mostly aesthetic, but makes the code a bit tighter. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162349 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 3b1df8b commit 66c486f

File tree

14 files changed

+115
-126
lines changed

14 files changed

+115
-126
lines changed

include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ class CheckerContext {
7676

7777
/// \brief Returns the number of times the current block has been visited
7878
/// along the analyzed path.
79-
unsigned getCurrentBlockCount() const {
80-
return NB.getContext().getCurrentBlockCount();
79+
unsigned blockCount() const {
80+
return NB.getContext().blockCount();
8181
}
8282

8383
ASTContext &getASTContext() {

include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ struct NodeBuilderContext {
196196

197197
/// \brief Returns the number of times the current basic block has been
198198
/// visited on the exploded graph path.
199-
unsigned getCurrentBlockCount() const {
199+
unsigned blockCount() const {
200200
return Eng.WList->getBlockCounter().getNumVisited(
201201
Pred->getLocationContext()->getCurrentStackFrame(),
202202
Block->getBlockID());

include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ class ExprEngine : public SubEngine {
7070
/// variables and symbols (as determined by a liveness analysis).
7171
ProgramStateRef CleanedState;
7272

73-
/// currentStmt - The current block-level statement.
74-
const Stmt *currentStmt;
75-
unsigned int currentStmtIdx;
76-
const NodeBuilderContext *currentBuilderContext;
73+
/// currStmt - The current block-level statement.
74+
const Stmt *currStmt;
75+
unsigned int currStmtIdx;
76+
const NodeBuilderContext *currBldrCtx;
7777

7878
/// Obj-C Class Identifiers.
7979
IdentifierInfo* NSExceptionII;
@@ -126,8 +126,8 @@ class ExprEngine : public SubEngine {
126126
BugReporter& getBugReporter() { return BR; }
127127

128128
const NodeBuilderContext &getBuilderContext() {
129-
assert(currentBuilderContext);
130-
return *currentBuilderContext;
129+
assert(currBldrCtx);
130+
return *currBldrCtx;
131131
}
132132

133133
bool isObjCGCEnabled() { return ObjCGCEnabled; }

lib/Analysis/CFG.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3449,12 +3449,12 @@ class StmtPrinterHelper : public PrinterHelper {
34493449
StmtMapTy StmtMap;
34503450
DeclMapTy DeclMap;
34513451
signed currentBlock;
3452-
unsigned currentStmt;
3452+
unsigned currStmt;
34533453
const LangOptions &LangOpts;
34543454
public:
34553455

34563456
StmtPrinterHelper(const CFG* cfg, const LangOptions &LO)
3457-
: currentBlock(0), currentStmt(0), LangOpts(LO)
3457+
: currentBlock(0), currStmt(0), LangOpts(LO)
34583458
{
34593459
for (CFG::const_iterator I = cfg->begin(), E = cfg->end(); I != E; ++I ) {
34603460
unsigned j = 1;
@@ -3515,7 +3515,7 @@ class StmtPrinterHelper : public PrinterHelper {
35153515

35163516
const LangOptions &getLangOpts() const { return LangOpts; }
35173517
void setBlockID(signed i) { currentBlock = i; }
3518-
void setStmtID(unsigned i) { currentStmt = i; }
3518+
void setStmtID(unsigned i) { currStmt = i; }
35193519

35203520
virtual bool handledStmt(Stmt *S, raw_ostream &OS) {
35213521
StmtMapTy::iterator I = StmtMap.find(S);
@@ -3524,7 +3524,7 @@ class StmtPrinterHelper : public PrinterHelper {
35243524
return false;
35253525

35263526
if (currentBlock >= 0 && I->second.first == (unsigned) currentBlock
3527-
&& I->second.second == currentStmt) {
3527+
&& I->second.second == currStmt) {
35283528
return false;
35293529
}
35303530

@@ -3539,7 +3539,7 @@ class StmtPrinterHelper : public PrinterHelper {
35393539
return false;
35403540

35413541
if (currentBlock >= 0 && I->second.first == (unsigned) currentBlock
3542-
&& I->second.second == currentStmt) {
3542+
&& I->second.second == currStmt) {
35433543
return false;
35443544
}
35453545

lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ bool BuiltinFunctionChecker::evalCall(const CallExpr *CE,
5555
// FIXME: Refactor into StoreManager itself?
5656
MemRegionManager& RM = C.getStoreManager().getRegionManager();
5757
const AllocaRegion* R =
58-
RM.getAllocaRegion(CE, C.getCurrentBlockCount(), C.getLocationContext());
58+
RM.getAllocaRegion(CE, C.blockCount(), C.getLocationContext());
5959

6060
// Set the extent of the region in bytes. This enables us to use the
6161
// SVal of the argument directly. If we save the extent in bits, we

lib/StaticAnalyzer/Checkers/CStringChecker.cpp

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -673,11 +673,11 @@ SVal CStringChecker::getCStringLengthForRegion(CheckerContext &C,
673673
}
674674

675675
// Otherwise, get a new symbol and update the state.
676-
unsigned Count = C.getCurrentBlockCount();
677676
SValBuilder &svalBuilder = C.getSValBuilder();
678677
QualType sizeTy = svalBuilder.getContext().getSizeType();
679678
SVal strLength = svalBuilder.getMetadataSymbolVal(CStringChecker::getTag(),
680-
MR, Ex, sizeTy, Count);
679+
MR, Ex, sizeTy,
680+
C.blockCount());
681681

682682
if (!hypothetical)
683683
state = state->set<CStringLength>(MR, strLength);
@@ -826,9 +826,8 @@ ProgramStateRef CStringChecker::InvalidateBuffer(CheckerContext &C,
826826
}
827827

828828
// Invalidate this region.
829-
unsigned Count = C.getCurrentBlockCount();
830829
const LocationContext *LCtx = C.getPredecessor()->getLocationContext();
831-
return state->invalidateRegions(R, E, Count, LCtx);
830+
return state->invalidateRegions(R, E, C.blockCount(), LCtx);
832831
}
833832

834833
// If we have a non-region value by chance, just remove the binding.
@@ -957,8 +956,8 @@ void CStringChecker::evalCopyCommon(CheckerContext &C,
957956
} else {
958957
// If we don't know how much we copied, we can at least
959958
// conjure a return value for later.
960-
unsigned Count = C.getCurrentBlockCount();
961-
SVal result = C.getSValBuilder().conjureSymbolVal(0, CE, LCtx, Count);
959+
SVal result = C.getSValBuilder().conjureSymbolVal(0, CE, LCtx,
960+
C.blockCount());
962961
state = state->BindExpr(CE, LCtx, result);
963962
}
964963

@@ -1092,8 +1091,7 @@ void CStringChecker::evalMemcmp(CheckerContext &C, const CallExpr *CE) const {
10921091
state = CheckBufferAccess(C, state, Size, Left, Right);
10931092
if (state) {
10941093
// The return value is the comparison result, which we don't know.
1095-
unsigned Count = C.getCurrentBlockCount();
1096-
SVal CmpV = svalBuilder.conjureSymbolVal(0, CE, LCtx, Count);
1094+
SVal CmpV = svalBuilder.conjureSymbolVal(0, CE, LCtx, C.blockCount());
10971095
state = state->BindExpr(CE, LCtx, CmpV);
10981096
C.addTransition(state);
10991097
}
@@ -1205,8 +1203,7 @@ void CStringChecker::evalstrLengthCommon(CheckerContext &C, const CallExpr *CE,
12051203
// no guarantee the full string length will actually be returned.
12061204
// All we know is the return value is the min of the string length
12071205
// and the limit. This is better than nothing.
1208-
unsigned Count = C.getCurrentBlockCount();
1209-
result = C.getSValBuilder().conjureSymbolVal(0, CE, LCtx, Count);
1206+
result = C.getSValBuilder().conjureSymbolVal(0, CE, LCtx, C.blockCount());
12101207
NonLoc *resultNL = cast<NonLoc>(&result);
12111208

12121209
if (strLengthNL) {
@@ -1233,8 +1230,7 @@ void CStringChecker::evalstrLengthCommon(CheckerContext &C, const CallExpr *CE,
12331230
// If we don't know the length of the string, conjure a return
12341231
// value, so it can be used in constraints, at least.
12351232
if (result.isUnknown()) {
1236-
unsigned Count = C.getCurrentBlockCount();
1237-
result = C.getSValBuilder().conjureSymbolVal(0, CE, LCtx, Count);
1233+
result = C.getSValBuilder().conjureSymbolVal(0, CE, LCtx, C.blockCount());
12381234
}
12391235
}
12401236

@@ -1611,8 +1607,7 @@ void CStringChecker::evalStrcpyCommon(CheckerContext &C, const CallExpr *CE,
16111607
// If this is a stpcpy-style copy, but we were unable to check for a buffer
16121608
// overflow, we still need a result. Conjure a return value.
16131609
if (returnEnd && Result.isUnknown()) {
1614-
unsigned Count = C.getCurrentBlockCount();
1615-
Result = svalBuilder.conjureSymbolVal(0, CE, LCtx, Count);
1610+
Result = svalBuilder.conjureSymbolVal(0, CE, LCtx, C.blockCount());
16161611
}
16171612

16181613
// Set the return value.
@@ -1769,8 +1764,7 @@ void CStringChecker::evalStrcmpCommon(CheckerContext &C, const CallExpr *CE,
17691764

17701765
if (!canComputeResult) {
17711766
// Conjure a symbolic value. It's the best we can do.
1772-
unsigned Count = C.getCurrentBlockCount();
1773-
SVal resultVal = svalBuilder.conjureSymbolVal(0, CE, LCtx, Count);
1767+
SVal resultVal = svalBuilder.conjureSymbolVal(0, CE, LCtx, C.blockCount());
17741768
state = state->BindExpr(CE, LCtx, resultVal);
17751769
}
17761770

lib/StaticAnalyzer/Checkers/MallocChecker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ ProgramStateRef MallocChecker::MallocMemAux(CheckerContext &C,
526526
// Bind the return value to the symbolic value from the heap region.
527527
// TODO: We could rewrite post visit to eval call; 'malloc' does not have
528528
// side effects other than what we model here.
529-
unsigned Count = C.getCurrentBlockCount();
529+
unsigned Count = C.blockCount();
530530
SValBuilder &svalBuilder = C.getSValBuilder();
531531
const LocationContext *LCtx = C.getPredecessor()->getLocationContext();
532532
DefinedSVal RetVal =

lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3071,8 +3071,7 @@ bool RetainCountChecker::evalCall(const CallExpr *CE, CheckerContext &C) const {
30713071
if (RetVal.isUnknown()) {
30723072
// If the receiver is unknown, conjure a return value.
30733073
SValBuilder &SVB = C.getSValBuilder();
3074-
unsigned Count = C.getCurrentBlockCount();
3075-
RetVal = SVB.conjureSymbolVal(0, CE, LCtx, ResultTy, Count);
3074+
RetVal = SVB.conjureSymbolVal(0, CE, LCtx, ResultTy, C.blockCount());
30763075
}
30773076
state = state->BindExpr(CE, LCtx, RetVal, false);
30783077

@@ -3086,8 +3085,7 @@ bool RetainCountChecker::evalCall(const CallExpr *CE, CheckerContext &C) const {
30863085
Binding = getRefBinding(state, Sym);
30873086

30883087
// Invalidate the argument region.
3089-
unsigned Count = C.getCurrentBlockCount();
3090-
state = state->invalidateRegions(ArgRegion, CE, Count, LCtx);
3088+
state = state->invalidateRegions(ArgRegion, CE, C.blockCount(), LCtx);
30913089

30923090
// Restore the refcount status of the argument.
30933091
if (Binding)

lib/StaticAnalyzer/Checkers/StreamChecker.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,11 @@ void StreamChecker::Tmpfile(CheckerContext &C, const CallExpr *CE) const {
219219

220220
void StreamChecker::OpenFileAux(CheckerContext &C, const CallExpr *CE) const {
221221
ProgramStateRef state = C.getState();
222-
unsigned Count = C.getCurrentBlockCount();
223222
SValBuilder &svalBuilder = C.getSValBuilder();
224223
const LocationContext *LCtx = C.getPredecessor()->getLocationContext();
225224
DefinedSVal RetVal =
226-
cast<DefinedSVal>(svalBuilder.conjureSymbolVal(0, CE, LCtx, Count));
225+
cast<DefinedSVal>(svalBuilder.conjureSymbolVal(0, CE, LCtx,
226+
C.blockCount()));
227227
state = state->BindExpr(CE, C.getLocationContext(), RetVal);
228228

229229
ConstraintManager &CM = C.getConstraintManager();

0 commit comments

Comments
 (0)