Skip to content

Commit 5d4d5ea

Browse files
committed
Added comments
1 parent 058bd2b commit 5d4d5ea

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

clang/lib/CConv/AVarBoundsInfo.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,9 @@ AvarBoundsInference::convergeInferredBounds() {
682682
return FoundSome;
683683
}
684684

685+
// This function finds all the BoundsKeys (i.e., variables) in
686+
// scope `DstScope` that are reachable from `FromVarK` in the
687+
// graph `BKGraph`. All the reachable bounds key will be stored in `PotK`.
685688
bool AvarBoundsInference::getReachableBoundKeys(const ProgramVarScope *DstScope,
686689
BoundsKey FromVarK,
687690
std::set<BoundsKey> &PotK,
@@ -1198,6 +1201,19 @@ void AVarBoundsInfo::getBoundsNeededArrPointers(const std::set<BoundsKey> &ArrPt
11981201
std::inserter(AB, AB.end()));
11991202
}
12001203

1204+
// We first propagate all the bounds information from explicit
1205+
// declarations and mallocs.
1206+
// For other variables that do not have any choice of bounds,
1207+
// we use potential bounds choices (FromPB), these are the variables
1208+
// that are upper bounds to an index variable used in an array indexing
1209+
// operation.
1210+
// For example:
1211+
// if (i < n) {
1212+
// ...arr[i]...
1213+
// }
1214+
// In the above case, we use n as a potential count bounds for arr.
1215+
// Note: we only use potential bounds for a variable when none of its
1216+
// predecessors have bounds.
12011217
bool AVarBoundsInfo::performFlowAnalysis(ProgramInfo *PI) {
12021218
bool RetVal = false;
12031219
AvarBoundsInference ABI(this);

0 commit comments

Comments
 (0)