Skip to content

Commit 9b71393

Browse files
NagyDonatsteakhal
andauthored
[analyzer] Avoid a crash in a debug printout function (#79446)
Previously the function `RangeConstraintManager::printValue()` crashed when it encountered an empty rangeset (because `RangeSet::getBitwidth()` and `RangeSet::isUnsigned()` assert that the rangeset is not empty). This commit adds a special case that avoids this behavior. As `printValue()` is only used by the checker debug.ExprInspection (and during manual debugging), the impacts of this commit are very limited. --------- Co-authored-by: Balazs Benics <[email protected]>
1 parent f1b1611 commit 9b71393

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3270,6 +3270,10 @@ void RangeConstraintManager::printJson(raw_ostream &Out, ProgramStateRef State,
32703270
void RangeConstraintManager::printValue(raw_ostream &Out, ProgramStateRef State,
32713271
SymbolRef Sym) {
32723272
const RangeSet RS = getRange(State, Sym);
3273+
if (RS.isEmpty()) {
3274+
Out << "<empty rangeset>";
3275+
return;
3276+
}
32733277
Out << RS.getBitWidth() << (RS.isUnsigned() ? "u:" : "s:");
32743278
RS.dump(Out);
32753279
}

0 commit comments

Comments
 (0)