[cfe-commits] PATCH: Adds -Wself-assign to Clang, but defaults it to off

Chandler Carruth chandlerc at google.com
Wed Dec 29 14:05:55 PST 2010


This adds a warning to Clang for self-assignment of the form:

int a = 42;
> a = a;


Code with this often is merely trying to mark a variable used, but there is
a more idiomatic way of doing that:

(void)a;


The warning is mostly a stylistic issue to help catch unintended
self-assignments which result from typos in a codebase which strictly
enforces that it shouldn't be used intentionally. As such, it is ignored by
default, but can be turned on with -Wself-assign.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20101229/dd98da91/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-add-self-assignment-warning-to-Clang.patch
Type: application/octet-stream
Size: 4595 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20101229/dd98da91/attachment.obj>


More information about the cfe-commits mailing list