[PATCH] D14203: [analyzer] Improve pointer arithmetic checker.

Gábor Horváth via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 24 04:23:58 PST 2015

xazax.hun added inline comments.

Comment at: lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp:150
@@ +149,3 @@
+    return getArrayRegion(Region, Polymorphic, AKind, C);
+  default:
+    break;
xazax.hun wrote:
> dcoughlin wrote:
> > In general, I think it is better to avoid default in cases like these so that when an enum case is added the compiler issues a warning and thus forces the person adding the change to think about what the behavior of the new case should be.
> I will enumerate the rest of the kinds here.
I checked and there are more kinds than what I think is worth enumerating. 

Comment at: lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp:28
@@ -24,1 +27,3 @@
 namespace {
+enum class AllocKind {
+  SingleObject,
In case, there is a pointer to the stack allocated variable, nothing will be stored in the GDM.
The result of a new is a symbolic region, but there are other ways to get a symbolic region, e.g. a pointer as an argument to a top level function. In order to distinguish these cases I think I need to store something to the GDM. But I will think a bit more, whether there is a way to reduce the GDM usage. 


More information about the cfe-commits mailing list