[PATCH] D43798: [analyzer] UndefinedAssignment: Fix warning message on implicit copy/move constructors.

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 26 17:47:03 PST 2018


NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet.
Herald added subscribers: cfe-commits, rnkovacs.

When a class forgets to initialize a field in the constructor, and then gets copied around, a warning is emitted that the value assigned to a specific field is undefined. When the copy/move constructor is implicit (not written out in the code) but not trivial (is not a trivial memory copy, eg. because members have an explicit copy constructor), the body of such constructor is auto-generated in the AST. In this case the checker's warning message is squeezed at the top of the class declaration, and it gets hard to guess which field is at fault.

Fix the warning message to include the name of the field.

Such warnings have become fairly popular in our temporary constructor evaluation.

This warning should probably be extended to the trivial copy case, but that's a separate story.


Repository:
  rC Clang

https://reviews.llvm.org/D43798

Files:
  lib/StaticAnalyzer/Checkers/UndefinedAssignmentChecker.cpp
  test/Analysis/implicit-ctor-undef-value.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43798.136014.patch
Type: text/x-patch
Size: 3554 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180227/7f0320d4/attachment.bin>


More information about the cfe-commits mailing list