Author: NagyDonat Date: 2024-01-25T17:03:09+01:00 New Revision: 9b71393569ae4508d78b8a21993c21530bfdccc5
URL: https://github.com/llvm/llvm-project/commit/9b71393569ae4508d78b8a21993c21530bfdccc5 DIFF: https://github.com/llvm/llvm-project/commit/9b71393569ae4508d78b8a21993c21530bfdccc5.diff LOG: [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 <benicsbal...@gmail.com> Added: Modified: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp Removed: ################################################################################ diff --git a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp index 25d066c4652f2b..2d8498e3601556 100644 --- a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp +++ b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp @@ -3270,6 +3270,10 @@ void RangeConstraintManager::printJson(raw_ostream &Out, ProgramStateRef State, void RangeConstraintManager::printValue(raw_ostream &Out, ProgramStateRef State, SymbolRef Sym) { const RangeSet RS = getRange(State, Sym); + if (RS.isEmpty()) { + Out << "<empty rangeset>"; + return; + } Out << RS.getBitWidth() << (RS.isUnsigned() ? "u:" : "s:"); RS.dump(Out); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits