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

Balázs Benics via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 10 09:26:47 PST 2021


steakhal added a comment.

Very solid patch!



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


================
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)) {
----------------
For me at least, a name like `IsSameRegionType()` would imply a function with two parameters.


================
Comment at: clang/lib/StaticAnalyzer/Core/Store.cpp:115
+  // Handle casts from compatible types.
+  if (R->isBoundable() && IsSameRegionType(R))
+    return R;
----------------
BTW do you know what `isBoundable()` is? I'm just curious.


================
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.
----------------



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