[BUG] Support for W[no-]unused-but-set-{variable, parameter}

Hi,

These warnings are included by default with -Wall in GCC 4.6 [1], and
Clang should support them instead of throwing
-Wunknown-warning-option.

I'd like some pointers so we can fix this bug now.

[1]: http://gcc.gnu.org/gcc-4.6/porting_to.html

Thanks.

The -variable one is http://llvm.org/bugs/show_bug.cgi?id=9824 , I didn’t find a bug for -parameter. The bug has some discussion (and not one but two rdar numbers :-P).

Nico Weber wrote:

The -variable one is http://llvm.org/bugs/show_bug.cgi?id=9824 , I didn't
find a bug for -parameter. The bug has some discussion (and not one but two
rdar numbers :-P).

I added one a few days ago: http://llvm.org/bugs/show_bug.cgi?id=16589

From what I understand, the bug still hasn't been fixed; and I would

love for it to be fixed now. From the discussion, it seems that I
just have to hook into the static analyzer's dead-store check? Can you
give me some pointers on where I should be looking? (I'm currently
looking at Sema::DiagnoseUnusedParameters).

Thanks.

Nico Weber wrote:

The -variable one is http://llvm.org/bugs/show_bug.cgi?id=9824 , I didn’t
find a bug for -parameter. The bug has some discussion (and not one but two
rdar numbers :-P).

I added one a few days ago: http://llvm.org/bugs/show_bug.cgi?id=16589

From what I understand, the bug still hasn’t been fixed; and I would
love for it to be fixed now. From the discussion, it seems that I
just have to hook into the static analyzer’s dead-store check?

I expect its not /quite/ that simple, but don’t know for sure. I personally would start by looking at the implementation of -Wsometimes-uninitialized & use a similar (but different) cfg/use/def walk.

Can you
give me some pointers on where I should be looking? (I’m currently
looking at Sema::DiagnoseUnusedParameters).

I suppose that’s an interesting if place to look, but I doubt we store the necessary bits for this warning (to differentiate a variable that only written to from one that has reads and writes)