@@ -647,13 +647,12 @@ namespace {
647
647
// that are currently known to be valid for the variable.
648
648
using BoundsContextTy = llvm::DenseMap<const VarDecl *, BoundsExpr *>;
649
649
650
- // EqualExprTy denotes a set of expressions that produce the same value
651
- // as an expression e.
652
- using EqualExprTy = SmallVector<Expr *, 4 >;
650
+ // ExprSetTy denotes a set of expressions.
651
+ using ExprSetTy = SmallVector<Expr *, 4 >;
653
652
654
653
// ExprEqualMapTy denotes a map of an expression e to the set of
655
654
// expressions that produce the same value as e.
656
- using ExprEqualMapTy = llvm::DenseMap<Expr *, EqualExprTy >;
655
+ using ExprEqualMapTy = llvm::DenseMap<Expr *, ExprSetTy >;
657
656
658
657
// CheckingState stores the outputs of bounds checking methods.
659
658
// These members represent the state during bounds checking
@@ -686,7 +685,7 @@ namespace {
686
685
// expression e once checking of e is complete.
687
686
//
688
687
// SameValue is named G in the Checked C spec.
689
- EqualExprTy SameValue;
688
+ ExprSetTy SameValue;
690
689
691
690
// LostVariables maps a variable declaration V whose observed bounds
692
691
// are unknown to a pair <B, W>, where the initial observed bounds B
@@ -932,7 +931,7 @@ namespace {
932
931
}
933
932
}
934
933
935
- void DumpExprsSet (raw_ostream &OS, EqualExprTy Exprs) {
934
+ void DumpExprsSet (raw_ostream &OS, ExprSetTy Exprs) {
936
935
if (Exprs.size () == 0 )
937
936
OS << " { }\n " ;
938
937
else {
@@ -4270,7 +4269,7 @@ namespace {
4270
4269
// Adjust EquivExprs to account for any uses of V in PrevState.EquivExprs.
4271
4270
State.EquivExprs .clear ();
4272
4271
for (auto I = PrevState.EquivExprs .begin (); I != PrevState.EquivExprs .end (); ++I) {
4273
- EqualExprTy ExprList;
4272
+ ExprSetTy ExprList;
4274
4273
for (auto InnerList = (*I).begin (); InnerList != (*I).end (); ++InnerList) {
4275
4274
Expr *E = *InnerList;
4276
4275
Expr *AdjustedE = ReplaceVariableReferences (S, E, V, OriginalValue, CSS);
@@ -4387,8 +4386,8 @@ namespace {
4387
4386
// Val is an optional expression that may be contained in the updated
4388
4387
// SameValue set. If Val is not provided, e is used instead. If Val
4389
4388
// and e are null, SameValue is not updated.
4390
- void UpdateSameValue (Expr *E, const EqualExprTy SubExprSameValue,
4391
- EqualExprTy &SameValue, Expr *Val = nullptr ) {
4389
+ void UpdateSameValue (Expr *E, const ExprSetTy SubExprSameValue,
4390
+ ExprSetTy &SameValue, Expr *Val = nullptr ) {
4392
4391
Expr *SubExpr = dyn_cast<Expr>(*(E->child_begin ()));
4393
4392
assert (SubExpr);
4394
4393
ExprEqualMapTy SubExprSameValueSets;
@@ -4412,7 +4411,7 @@ namespace {
4412
4411
// SameValue set. If Val is not provided, e is used instead. If Val
4413
4412
// and e are null, SameValue is not updated.
4414
4413
void UpdateSameValue (Expr *E, ExprEqualMapTy SubExprSameValueSets,
4415
- EqualExprTy &SameValue, Expr *Val = nullptr ) {
4414
+ ExprSetTy &SameValue, Expr *Val = nullptr ) {
4416
4415
SameValue.clear ();
4417
4416
4418
4417
if (!Val) Val = E;
@@ -4438,13 +4437,13 @@ namespace {
4438
4437
// the same value as Val.
4439
4438
else {
4440
4439
Expr *ValPrime = nullptr ;
4441
- for (llvm::detail::DenseMapPair<Expr *, EqualExprTy > Pair : SubExprSameValueSets) {
4440
+ for (llvm::detail::DenseMapPair<Expr *, ExprSetTy > Pair : SubExprSameValueSets) {
4442
4441
Expr *SubExpr_i = Pair.first ;
4443
4442
// For any modifying subexpression SubExpr_i of e, try to set
4444
4443
// ValPrime to a nonmodifying expression from the set SameValue_i
4445
4444
// of expressions that produce the same value as SubExpr_i.
4446
4445
if (!CheckIsNonModifying (SubExpr_i)) {
4447
- EqualExprTy SameValue_i = Pair.second ;
4446
+ ExprSetTy SameValue_i = Pair.second ;
4448
4447
for (auto I = SameValue_i.begin (); I != SameValue_i.end (); ++I) {
4449
4448
Expr *E_i = *I;
4450
4449
if (CheckIsNonModifying (E_i)) {
@@ -4500,7 +4499,7 @@ namespace {
4500
4499
4501
4500
// Check EQ for a variable w != v that produces the same value as v.
4502
4501
Expr *ValuePreservingV = nullptr ;
4503
- EqualExprTy F = GetEqualExprSetContainingExpr (Target, EQ, ValuePreservingV);
4502
+ ExprSetTy F = GetEqualExprSetContainingExpr (Target, EQ, ValuePreservingV);
4504
4503
for (auto I = F.begin (); I != F.end (); ++I) {
4505
4504
// Account for value-preserving operations on w when searching for
4506
4505
// a variable w in F. For example, if F contains (T)LValueToRValue(w),
@@ -4922,10 +4921,10 @@ namespace {
4922
4921
const EquivExprSets EQ2) {
4923
4922
EquivExprSets IntersectedEQ;
4924
4923
for (auto I1 = EQ1.begin (); I1 != EQ1.end (); ++I1) {
4925
- EqualExprTy Set1 = *I1;
4924
+ ExprSetTy Set1 = *I1;
4926
4925
for (auto I2 = EQ2.begin (); I2 != EQ2.end (); ++I2) {
4927
- EqualExprTy Set2 = *I2;
4928
- EqualExprTy IntersectedExprSet = IntersectExprSets (Set1, Set2);
4926
+ ExprSetTy Set2 = *I2;
4927
+ ExprSetTy IntersectedExprSet = IntersectExprSets (Set1, Set2);
4929
4928
if (IntersectedExprSet.size () > 1 )
4930
4929
IntersectedEQ.push_back (IntersectedExprSet);
4931
4930
}
@@ -4934,9 +4933,8 @@ namespace {
4934
4933
}
4935
4934
4936
4935
// IntersectExprSets returns the intersection of two sets of expressions.
4937
- EqualExprTy IntersectExprSets (const EqualExprTy Set1,
4938
- const EqualExprTy Set2) {
4939
- EqualExprTy IntersectedSet;
4936
+ ExprSetTy IntersectExprSets (const ExprSetTy Set1, const ExprSetTy Set2) {
4937
+ ExprSetTy IntersectedSet;
4940
4938
for (auto I = Set1.begin (); I != Set1.end (); ++I) {
4941
4939
Expr *E1 = *I;
4942
4940
if (EqualExprsContainsExpr (Set2, E1 ))
@@ -4965,11 +4963,11 @@ namespace {
4965
4963
// e1 may include value-preserving operations. For example, if a set F
4966
4964
// in EQ contains (T)e, where (T) is a value-preserving cast,
4967
4965
// ValuePreservingE will be set to (T)e.
4968
- EqualExprTy GetEqualExprSetContainingExpr (Expr *E, EquivExprSets EQ,
4969
- Expr *&ValuePreservingE) {
4966
+ ExprSetTy GetEqualExprSetContainingExpr (Expr *E, EquivExprSets EQ,
4967
+ Expr *&ValuePreservingE) {
4970
4968
ValuePreservingE = nullptr ;
4971
4969
for (auto OuterList = EQ.begin (); OuterList != EQ.end (); ++OuterList) {
4972
- EqualExprTy F = *OuterList;
4970
+ ExprSetTy F = *OuterList;
4973
4971
for (auto InnerList = F.begin (); InnerList != F.end (); ++InnerList) {
4974
4972
Expr *E1 = *InnerList;
4975
4973
if (EqualValue (S.Context , E, E1 , nullptr )) {
@@ -4983,18 +4981,17 @@ namespace {
4983
4981
4984
4982
// If e appears in a set F in EQ, GetEqualExprSetContainingExpr
4985
4983
// returns F. Otherwise, it returns an empty set.
4986
- EqualExprTy GetEqualExprSetContainingExpr (Expr *E, EquivExprSets EQ) {
4984
+ ExprSetTy GetEqualExprSetContainingExpr (Expr *E, EquivExprSets EQ) {
4987
4985
for (auto OuterList = EQ.begin (); OuterList != EQ.end (); ++OuterList) {
4988
- EqualExprTy F = *OuterList;
4986
+ ExprSetTy F = *OuterList;
4989
4987
if (EqualExprsContainsExpr (F, E))
4990
4988
return F;
4991
4989
}
4992
4990
return { };
4993
4991
}
4994
4992
4995
4993
// IsEqualExprsSubset returns true if Exprs1 is a subset of Exprs2.
4996
- bool IsEqualExprsSubset (const EqualExprTy Exprs1,
4997
- const EqualExprTy Exprs2) {
4994
+ bool IsEqualExprsSubset (const ExprSetTy Exprs1, const ExprSetTy Exprs2) {
4998
4995
for (auto I = Exprs1.begin (); I != Exprs1.end (); ++I) {
4999
4996
Expr *E = *I;
5000
4997
if (!EqualExprsContainsExpr (Exprs2, E))
@@ -5005,8 +5002,7 @@ namespace {
5005
5002
5006
5003
// DoExprSetsIntersect returns true if the intersection of Exprs1 and
5007
5004
// Exprs2 is nonempty.
5008
- bool DoExprSetsIntersect (const EqualExprTy Exprs1,
5009
- const EqualExprTy Exprs2) {
5005
+ bool DoExprSetsIntersect (const ExprSetTy Exprs1, const ExprSetTy Exprs2) {
5010
5006
for (auto I = Exprs1.begin (); I != Exprs1.end (); ++I) {
5011
5007
Expr *E = *I;
5012
5008
if (EqualExprsContainsExpr (Exprs2, E))
@@ -5016,7 +5012,7 @@ namespace {
5016
5012
}
5017
5013
5018
5014
// EqualExprsContainsExpr returns true if the set Exprs contains E.
5019
- bool EqualExprsContainsExpr (const EqualExprTy Exprs, Expr *E) {
5015
+ bool EqualExprsContainsExpr (const ExprSetTy Exprs, Expr *E) {
5020
5016
for (auto I = Exprs.begin (); I != Exprs.end (); ++I) {
5021
5017
if (EqualValue (S.Context , E, *I, nullptr ))
5022
5018
return true ;
0 commit comments