Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Add a checker to detected unmodified variables #16889

Open Quuxplusone opened 11 years ago

Quuxplusone commented 11 years ago
Bugzilla Link PR16890
Status NEW
Importance P enhancement
Reported by michael.morrell@intel.com
Reported on 2013-08-14 17:16:28 -0700
Last modified on 2013-08-15 19:23:52 -0700
Version unspecified
Hardware Macintosh MacOS X
CC jrose@belkadan.com, llvm-bugs@lists.llvm.org, michael.morrell@intel.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
I think if it would be nice if the following reported some kind of error:

  int foo()
  {
     int i = 0;

     return i;
  }

where a variable is never modified (to me, this indicates that some code that
modified the variable is missing).   If the variable is really not supposed to
change, the user can declare it as "const" (or use a #define).
Quuxplusone commented 11 years ago

This is /definitely/ a style checker, since in LLVM at least we often use temporary variables just to break up large expressions. Marking local variable const could certainly be considered good practice, but it's not something people do often, especially not for pointers.

Quuxplusone commented 11 years ago

I'm not sure what you mean by a "style checker".

This is a check that many people might not want and so should be disabled by default, but I think it would be valuable to have as an option.

Quuxplusone commented 11 years ago

That's mostly what I meant. It's a checker whose usefulness is strongly dependent on the conventions and style guidelines of a particular codebase. I'll add it to the potential checkers list.