[cfe-commits] [PATCH] review request - strcmp checker

Ted Kremenek kremenek at apple.com
Fri Apr 8 16:37:08 PDT 2011


Hi Lenny,

I understand the intent is to model comparing raw string literals, but I think the use of getCStringLiteral() discards too much information.  For example, I don't think the following will be handled correctly:

  const char *s1 = "foobar";
  const char *s2 = "bar";
  return strcmp(&s1[3], s2);

In order to model strcmp() properly, you will also need to take into account the offset within the string literal.

Also, could you add a FIXME indicating that this logic only handles comparing string literals (albeit, it handles flow analysis)?  Conceptually, we could enhance this to also handle non-literals as well in a variety of ways.

On Apr 8, 2011, at 1:51 PM, Lenny Maiorani wrote:

> On 04/08/2011 10:28 AM, Lenny Maiorani wrote:
>> This patch adds modeling of strcmp() to the CString checker. Validates inputs are not NULL and are real C strings, then does the comparison and binds the proper return value. Unit tests included.
>> 
>> -Lenny
>> 
>> 
> Oops. Empty patch. Thanks Joerg.
> 
> -Lenny
> 
> <strcmp-checker.diff>_______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list