[clang] [analyzer] Avoid a crash in a debug printout function (PR #79446)
Balazs Benics via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 25 07:23:07 PST 2024
================
@@ -3270,8 +3270,12 @@ void RangeConstraintManager::printJson(raw_ostream &Out, ProgramStateRef State,
void RangeConstraintManager::printValue(raw_ostream &Out, ProgramStateRef State,
SymbolRef Sym) {
const RangeSet RS = getRange(State, Sym);
- Out << RS.getBitWidth() << (RS.isUnsigned() ? "u:" : "s:");
- RS.dump(Out);
+ if (RS.isEmpty()) {
+ Out << "<empty rangeset>";
+ } else {
+ Out << RS.getBitWidth() << (RS.isUnsigned() ? "u:" : "s:");
+ RS.dump(Out);
+ }
----------------
steakhal wrote:
```suggestion
if (RS.isEmpty()) {
Out << "<empty rangeset>";
return;
}
Out << RS.getBitWidth() << (RS.isUnsigned() ? "u:" : "s:");
RS.dump(Out);
```
https://github.com/llvm/llvm-project/pull/79446
More information about the cfe-commits
mailing list