[PATCH] D76590: [Analyzer] Model `empty()` member function of containers

Balogh, Ádám via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 23 00:31:05 PDT 2020


baloghadamsoftware created this revision.
baloghadamsoftware added reviewers: NoQ, Szelethus.
baloghadamsoftware added a project: clang.
Herald added subscribers: ASDenysPetrov, martong, steakhal, Charusso, gamesh411, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, xazax.hun, whisperity.
baloghadamsoftware added a comment.
baloghadamsoftware marked 3 inline comments as done.

Supersedes D62688 <https://reviews.llvm.org/D62688>.



================
Comment at: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp:359
     State = State->BindExpr(CE, LCtx, RetVal);
   }
 
----------------
Maybe I should move these lines into a separate function in the library to avoid repetition.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp:377
+      C.addTransition(StateNonEqual);
   }
+
----------------
This is way longer than the previously used `processComparison()` but I am reluctant to pass `CheckerContext` to a non-member function. (And especially add transitions there. Even worse, to a function in a common library.)


Modeling the `empty()` method of containers both improves iterator range checking and enables the possibility to create new checkers for containers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76590

Files:
  clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/Iterator.cpp
  clang/lib/StaticAnalyzer/Checkers/Iterator.h
  clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
  clang/test/Analysis/Inputs/system-header-simulator-cxx.h
  clang/test/Analysis/container-modeling.cpp
  clang/test/Analysis/diagnostics/explicit-suppression.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76590.251953.patch
Type: text/x-patch
Size: 25883 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200323/11a7b3f5/attachment-0001.bin>


More information about the cfe-commits mailing list