[cfe-dev] Static Analysis Warning?

Tom Care tcare at apple.com
Fri Aug 27 16:38:43 PDT 2010


This probably wouldn't be too hard to do in the IdempotentOperationChecker. At the moment we only look at BinaryOperators and don't handle ternary statements explicitly. I think this falls under the 'pointless operation' category.

Tom

On Aug 27, 2010, at 3:52 PM, Bill Wendling wrote:

> On Aug 27, 2010, at 3:46 PM, Jordy Rose wrote:
> 
>> On Fri, 27 Aug 2010 17:39:12 -0500, Michael Price - Dev
>> <michael.b.price.dev at gmail.com> wrote:
>>> Consider:
>>> 
>>> #define FLOOR 1
>>> #define CEILING 1
>>> 
>>> int main (int argc, const char * argc[])
>>> {
>>>    printf("Hello, World! %d\n", useFloor() ? FLOOR : CEILING);
>>> 
>>>    return 0;
>>> }
>>> 
>>> where useFloor() returns a bool.
>>> 
>>> I would NOT want that flagged with a warning.
>> 
>> Good point, Michael. I think this would be more useful as a Sema warning
>> about identical expressions for both results of a ?:, not a value-sensitive
>> analyzer report. (Taking macros into account, of course; only warn if
>> neither expression involves a macro or both use identical macros.)
> 
> I agree that it's a good point. I don't thinks that this would make a good compiler warning, but would be limited to the static analyzer. The analyzer has information about whether something comes from a macro, enum, inlined function, etc. I would vote for it emitting a warning for the same enums coming from the same enum type.
> 
> -bw
> 
> 
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev





More information about the cfe-dev mailing list