Skip to content

Commit 96eff3a

Browse files
refactoing: cleanup some dead code
1 parent c74690f commit 96eff3a

File tree

5 files changed

+16
-40
lines changed

5 files changed

+16
-40
lines changed

clang/include/clang/3C/AVarBoundsInfo.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -229,19 +229,17 @@ class AVarBoundsInfo {
229229
// Generate a random bounds key to be used for inference.
230230
BoundsKey getRandomBKey();
231231

232-
// Add Assignments between variables. These methods will add edges between
233-
// corresponding BoundsKeys
234-
bool addAssignment(clang::Decl *L, clang::Decl *R);
235-
bool addAssignment(clang::DeclRefExpr *L, clang::DeclRefExpr *R);
236-
bool addAssignment(BoundsKey L, BoundsKey R);
237-
bool handlePointerAssignment(clang::Expr *L, clang::Expr *R, ASTContext *C,
232+
// Add Assignments between variables. This method will add edges between the
233+
// BoundsKeys.
234+
void addAssignment(BoundsKey L, BoundsKey R);
235+
void handlePointerAssignment(clang::Expr *L, clang::Expr *R,
238236
ConstraintResolver *CR);
239-
bool handleAssignment(clang::Expr *L, const CVarSet &LCVars,
237+
void handleAssignment(clang::Expr *L, const CVarSet &LCVars,
240238
const std::set<BoundsKey> &CSLKeys, clang::Expr *R,
241239
const CVarSet &RCVars,
242240
const std::set<BoundsKey> &CSRKeys, ASTContext *C,
243241
ConstraintResolver *CR);
244-
bool handleAssignment(clang::Decl *L, CVarOption LCVar, clang::Expr *R,
242+
void handleAssignment(clang::Decl *L, CVarOption LCVar, clang::Expr *R,
245243
const CVarSet &RCVars,
246244
const std::set<BoundsKey> &CSRKeys, ASTContext *C,
247245
ConstraintResolver *CR);

clang/include/clang/3C/CtxSensAVarBounds.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class CtxSensitiveBoundsKeyHandler {
6767
BoundsKey getCtxSensCEBoundsKey(const PersistentSourceLoc &PSL, BoundsKey BK);
6868

6969
// Handle context sensitive assignment (from R to L) to a variable.
70-
bool handleContextSensitiveAssignment(const PersistentSourceLoc &PSL,
70+
void handleContextSensitiveAssignment(const PersistentSourceLoc &PSL,
7171
clang::Decl *L,
7272
ConstraintVariable *LCVar,
7373
clang::Expr *R, CVarSet &RCVars,

clang/lib/3C/AVarBoundsInfo.cpp

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -888,25 +888,11 @@ BoundsKey AVarBoundsInfo::getRandomBKey() {
888888
return Ret;
889889
}
890890

891-
bool AVarBoundsInfo::addAssignment(clang::Decl *L, clang::Decl *R) {
892-
BoundsKey BL, BR;
893-
if (tryGetVariable(L, BL) && tryGetVariable(R, BR)) {
894-
return addAssignment(BL, BR);
895-
}
896-
return false;
897-
}
898-
899-
bool AVarBoundsInfo::addAssignment(clang::DeclRefExpr *L,
900-
clang::DeclRefExpr *R) {
901-
return addAssignment(L->getDecl(), R->getDecl());
902-
}
903-
904-
bool AVarBoundsInfo::handleAssignment(clang::Expr *L, const CVarSet &LCVars,
891+
void AVarBoundsInfo::handleAssignment(clang::Expr *L, const CVarSet &LCVars,
905892
const std::set<BoundsKey> &CSLKeys,
906893
clang::Expr *R, const CVarSet &RCVars,
907894
const std::set<BoundsKey> &CSRKeys,
908895
ASTContext *C, ConstraintResolver *CR) {
909-
bool Ret = false;
910896
BoundsKey TmpK;
911897
std::set<BoundsKey> AllLKeys = CSLKeys;
912898
std::set<BoundsKey> AllRKeys = CSRKeys;
@@ -921,32 +907,29 @@ bool AVarBoundsInfo::handleAssignment(clang::Expr *L, const CVarSet &LCVars,
921907

922908
for (auto LK : AllLKeys) {
923909
for (auto RK : AllRKeys) {
924-
Ret = addAssignment(LK, RK) || Ret;
910+
addAssignment(LK, RK);
925911
}
926912
}
927-
return Ret;
928913
}
929914

930-
bool AVarBoundsInfo::handleAssignment(clang::Decl *L, CVarOption LCVars,
915+
void AVarBoundsInfo::handleAssignment(clang::Decl *L, CVarOption LCVars,
931916
clang::Expr *R, const CVarSet &RCVars,
932917
const std::set<BoundsKey> &CSRKeys,
933918
ASTContext *C, ConstraintResolver *CR) {
934919
BoundsKey LKey, RKey;
935-
bool Ret = false;
936920
if (CR->resolveBoundsKey(LCVars, LKey) || tryGetVariable(L, LKey)) {
937921
std::set<BoundsKey> AllRKeys = CSRKeys;
938922
if (AllRKeys.empty() &&
939923
(CR->resolveBoundsKey(RCVars, RKey) || tryGetVariable(R, *C, RKey))) {
940924
AllRKeys.insert(RKey);
941925
}
942926
for (auto RK : AllRKeys) {
943-
Ret = addAssignment(LKey, RK) || Ret;
927+
addAssignment(LKey, RK);
944928
}
945929
}
946-
return Ret;
947930
}
948931

949-
bool AVarBoundsInfo::addAssignment(BoundsKey L, BoundsKey R) {
932+
void AVarBoundsInfo::addAssignment(BoundsKey L, BoundsKey R) {
950933
// Before adding an edge from L to R or R to L, first verify that the source
951934
// BoundsKey for the edge is not computed by pointer arithmetic. The pointer
952935
// arithmetic invalidates the bounds on the pointer, so bounds should not
@@ -975,15 +958,12 @@ bool AVarBoundsInfo::addAssignment(BoundsKey L, BoundsKey R) {
975958
if (!(PV && PV->isNumConstant()))
976959
AddEdgeUnlessPointerArithmetic(L, R);
977960
}
978-
return true;
979961
}
980962

981-
bool AVarBoundsInfo::handlePointerAssignment(clang::Expr *L, clang::Expr *R,
982-
ASTContext *C,
963+
void AVarBoundsInfo::handlePointerAssignment(clang::Expr *L, clang::Expr *R,
983964
ConstraintResolver *CR) {
984965
if (isAssignmentPointerArithmetic(L ,R))
985966
recordArithmeticOperation(L, CR);
986-
return true;
987967
}
988968

989969
void AVarBoundsInfo::mergeBoundsKey(BoundsKey To, BoundsKey From) {

clang/lib/3C/ConstraintResolver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ void ConstraintResolver::constrainLocalAssign(Stmt *TSt, Expr *LHS, Expr *RHS,
709709

710710
// Handle pointer arithmetic.
711711
auto &ABI = Info.getABoundsInfo();
712-
ABI.handlePointerAssignment(LHS, RHS, Context, this);
712+
ABI.handlePointerAssignment(LHS, RHS, this);
713713

714714
// Only if all types are enabled and these are not pointers, then track
715715
// the assignment.

clang/lib/3C/CtxSensAVarBounds.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,11 +294,10 @@ bool CtxSensitiveBoundsKeyHandler::deriveBoundsKeys(
294294
return Ret;
295295
}
296296

297-
bool CtxSensitiveBoundsKeyHandler::handleContextSensitiveAssignment(
297+
void CtxSensitiveBoundsKeyHandler::handleContextSensitiveAssignment(
298298
const PersistentSourceLoc &PSL, clang::Decl *L, ConstraintVariable *LCVar,
299299
clang::Expr *R, CVarSet &RCVars, const std::set<BoundsKey> &CSRKeys,
300300
ASTContext *C, ConstraintResolver *CR) {
301-
bool Ret = false;
302301
std::set<BoundsKey> AllRBKeys, AllLBKeys, TmpBKeys;
303302
AllRBKeys = CSRKeys;
304303

@@ -318,10 +317,9 @@ bool CtxSensitiveBoundsKeyHandler::handleContextSensitiveAssignment(
318317
// Add assignment between context sensitive bounds keys.
319318
for (auto LK : AllLBKeys) {
320319
for (auto RK : AllRBKeys) {
321-
Ret = ABI->addAssignment(LK, RK) || Ret;
320+
ABI->addAssignment(LK, RK);
322321
}
323322
}
324-
return Ret;
325323
}
326324

327325
bool ContextSensitiveBoundsKeyVisitor::VisitCallExpr(CallExpr *CE) {

0 commit comments

Comments
 (0)