[PATCH] D85424: [Analyzer] Crash fix for alpha.cplusplus.IteratorRange

Balogh, Ádám via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 6 04:45:12 PDT 2020


baloghadamsoftware created this revision.
baloghadamsoftware added reviewers: NoQ, Szelethus, gamesh411.
baloghadamsoftware added a project: clang.
Herald added subscribers: ASDenysPetrov, martong, steakhal, Charusso, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, xazax.hun, whisperity.
baloghadamsoftware requested review of this revision.

If the non-iterator side of an iterator operation `+`, `+=`, `-` or `-=` is `UndefinedVal` an assertions happens. This small fix prevents this.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85424

Files:
  clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp


Index: clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
@@ -228,7 +228,7 @@
     Value = State->getRawSVal(*ValAsLoc);
   }
 
-  if (Value.isUnknown())
+  if (Value.isUnknownOrUndef())
     return;
 
   // Incremention or decremention by 0 is never a bug.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85424.283569.patch
Type: text/x-patch
Size: 460 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200806/c692ff72/attachment.bin>


More information about the cfe-commits mailing list