[PATCH] D113480: [analyzer] Fix region cast between the same types with different qualifiers.

Denys Petrov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 10 09:47:52 PST 2021


ASDenysPetrov added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Core/Store.cpp:98
   QualType PointeeTy = CastToTy->getPointeeType();
   QualType CanonPointeeTy = Ctx.getCanonicalType(PointeeTy);
 
----------------
steakhal wrote:
> You only use `CanonPointeeTy.getLocalUnqualifiedType()` all the places. Spell it once and reuse it everywhere.
Make sense!


================
Comment at: clang/lib/StaticAnalyzer/Core/Store.cpp:104
 
-  // Handle casts from compatible types.
-  if (R->isBoundable())
+  const auto IsSameRegionType = [&Ctx, CanonPointeeTy](const MemRegion *R) {
     if (const auto *TR = dyn_cast<TypedValueRegion>(R)) {
----------------
steakhal wrote:
> For me at least, a name like `IsSameRegionType()` would imply a function with two parameters.
I'll carry `CanonPointeeTy` out.


================
Comment at: clang/lib/StaticAnalyzer/Core/Store.cpp:115
+  // Handle casts from compatible types.
+  if (R->isBoundable() && IsSameRegionType(R))
+    return R;
----------------
steakhal wrote:
> BTW do you know what `isBoundable()` is? I'm just curious.
I've looked for information about it. It's poor, I'd say there is nothing of it. I'm curious as well.


================
Comment at: clang/lib/StaticAnalyzer/Core/Store.cpp:184
+        // Edge case: we are at 0 bytes off the beginning of baseR. We
         // check to see if type we are casting to is the same as the base
+        // region. If so, just return the base region.
----------------
steakhal wrote:
> 
+1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113480



More information about the cfe-commits mailing list