[PATCH] Add warning to clang-reorder-fields when dependencies of init-list exprs are violated

Sam Conrad via cfe-commits cfe-commits at lists.llvm.org
Sun Jul 9 14:11:12 PDT 2017


This adds a warning emitted by clang-reorder-fields when the reordering
fields breaks dependencies in the initializer list (such that
-Wuninitialized would warn).  For example, given:
Foo::Foo(int x)
  : a(x)
  , b(a) {}

Reordering fields to [b,a] gives:
Foo::Foo(int x)
  : b(a)
  , a(x) {}

Emits the warning:
2: Warning: reordering field a after b makes a uninitialized when used in
init expression.

The patch also reformats a few lines that were over 80 columns wide.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170709/0d0929f2/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: reorder_fields_init_list_warn.patch
Type: text/x-patch
Size: 6918 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170709/0d0929f2/attachment.bin>


More information about the cfe-commits mailing list