[PATCH] D69726: [analyzer] DynamicSize: Store the dynamic size

Csaba Dabis via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 1 14:15:06 PDT 2019


Charusso added inline comments.


================
Comment at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h:29-31
+/// \returns The stored dynamic size expression for the region \p MR.
+const Expr *getDynamicSizeExpr(ProgramStateRef State, const MemRegion *MR);
+
----------------
NoQ wrote:
> Why do we need this?
I think as the checkers are growing and we push more-and-more allocation modeling so that at some point the Git's 8-parameter allocator's size expression could be retrieved so easily. This is the full arsenal of my buffer-overflow checker's needs, so I have pushed it here. Also it made a meaning to have a helper-class with two fields (one would be lame).


================
Comment at: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:1416
+                           SizeInBytes.castAs<DefinedOrUnknownSVal>(),
+                           NE->getArraySize().getValueOr(nullptr));
   }
----------------
My problem was only that. It partially repeats the `ExprEngine::bindReturnValue()`, which is a wonky design. I will look into that later.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp:180
-  // Assume should not fail at this point.
-  assert(state);
 
----------------
NoQ wrote:
> This gets rid of the assertion failure in https://bugs.llvm.org/show_bug.cgi?id=28450 by implementing my suggestion (2). Yay.
Cool!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69726/new/

https://reviews.llvm.org/D69726





More information about the cfe-commits mailing list