]> granicus.if.org Git - clang/commit
[analyzer] UndefinedAssignmentChecker: Better warning message in implicit ctors.
authorArtem Dergachev <artem.dergachev@gmail.com>
Tue, 27 Feb 2018 22:05:55 +0000 (22:05 +0000)
committerArtem Dergachev <artem.dergachev@gmail.com>
Tue, 27 Feb 2018 22:05:55 +0000 (22:05 +0000)
commita953b9005947e1b593b5842bb6950cc7ea971780
tree91f36633fd63723d6be2bab5d3fb01177af25fad
parent0eb6dd76bf34ad3b27fe953afa499cd8f22fd750
[analyzer] UndefinedAssignmentChecker: Better warning message in implicit ctors.

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.

Differential Revision: https://reviews.llvm.org/D43798

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326258 91177308-0d34-0410-b5e6-96231b3b80d8
lib/StaticAnalyzer/Checkers/UndefinedAssignmentChecker.cpp
test/Analysis/implicit-ctor-undef-value.cpp [new file with mode: 0644]