aboutsummaryrefslogtreecommitdiff
path: root/clang-tidy/utils
diff options
context:
space:
mode:
authorMatthias Gehre <M.Gehre@gmx.de>2016-09-28 20:06:18 +0000
committerMatthias Gehre <M.Gehre@gmx.de>2016-09-28 20:06:18 +0000
commit14b005f84deeb221a2f26b58a52ae66bfb06051a (patch)
tree41abebe48dde26120e59ab1625accf09534b980f /clang-tidy/utils
parentb186741fbbcb39b30a28b7e15508f2506f97cc6e (diff)
[clang-tidy] fix false-positive for cppcoreguidelines-pro-type-member-init with in-class initializers
Summary: This fixes https://llvm.org/bugs/show_bug.cgi?id=30487 where ``` warning: uninitialized record type: 's' [cppcoreguidelines-pro-type-member-init] ``` is emitted on ``` struct MyStruct { int a = 5; int b = 7; }; int main() { MyStruct s; } ``` Reviewers: alexfh, aaron.ballman Subscribers: nemanjai, cfe-commits Differential Revision: https://reviews.llvm.org/D24848 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@282625 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'clang-tidy/utils')
-rw-r--r--clang-tidy/utils/TypeTraits.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/clang-tidy/utils/TypeTraits.cpp b/clang-tidy/utils/TypeTraits.cpp
index ea379f6e..a0e40fe7 100644
--- a/clang-tidy/utils/TypeTraits.cpp
+++ b/clang-tidy/utils/TypeTraits.cpp
@@ -62,8 +62,10 @@ bool recordIsTriviallyDefaultConstructible(const RecordDecl &RecordDecl,
if (ClassDecl->hasTrivialDefaultConstructor())
return true;
- // If all its fields are trivially constructible.
+ // If all its fields are trivially constructible and have no default initializers.
for (const FieldDecl *Field : ClassDecl->fields()) {
+ if (Field->hasInClassInitializer())
+ return false;
if (!isTriviallyDefaultConstructible(Field->getType(), Context))
return false;
}