[cfe-commits] [PATCH] review request: mempcpy() checker implementation for Static Analyzer

Ted Kremenek kremenek at apple.com
Wed Mar 30 14:29:01 PDT 2011


On Mar 30, 2011, at 12:06 PM, Lenny Maiorani wrote:

> Please review attached implementation of mempcpy() checker (and commit if acceptable).
> 
> -Lenny
> 
> <mempcpy-checker.diff>_______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Hi Lenny,

Minor nits:

(1) You must use spaces instead of tabs.

(2) For comments:

+	// get the length to copy

please style them as follows to follow LLVM conventions:

       // Get the length to copy.

Other than that, the main logic point I don't understand is the following code:

+  // get the value of the Dest
+  SVal destVal = state->getSVal(Dest);
+
+  // ensure the destination is not null
+  state = checkNonNull(C, state, Dest, destVal);
+  if (!state)
+    return;
+
+  // get the value of the Src
+  SVal srcVal = state->getSVal(Source);
+
+  // ensure the source is not null
+  state = checkNonNull(C, state, Source, srcVal);
+  if (!state)
+    return;
+

If either the 'Src' or 'Dest' is null, what are the right semantics?  Does mempcpy do nothing?  Is the return value null?  We should probably model that.

Cheers,
Ted






More information about the cfe-commits mailing list