[PATCH] D35972: Add warning to clang-reorder-fields when reordering breaks member init list dependencies

Sam Conrad via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 27 19:16:26 PDT 2017


sameconrad created this revision.
sameconrad added a project: clang-tools-extra.

This adds a warning emitted by clang-reorder-fields when the reordering fields breaks dependencies in the initializer list (such that -Wuninitialized would warn when compiling).  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.


https://reviews.llvm.org/D35972

Files:
  clang-reorder-fields/ReorderFieldsAction.cpp
  test/clang-reorder-fields/FieldDependencyWarning.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35972.108570.patch
Type: text/x-patch
Size: 4623 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170728/15a2cfe1/attachment.bin>


More information about the cfe-commits mailing list