summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/cppcoreguidelines
diff options
context:
space:
mode:
authorAaron Ballman <aaron@aaronballman.com>2016-03-22 13:37:44 +0000
committerAaron Ballman <aaron@aaronballman.com>2016-03-22 13:37:44 +0000
commit73a7bd3616d8ae6788256ce8fe8c5dcc351e9ecc (patch)
tree7db0564a94ad5485d7964b8c9beaecd3e406c766 /clang-tools-extra/clang-tidy/cppcoreguidelines
parent26d239c293400a783cfb07a2aa85a9d3e7f78c2b (diff)
downloadbcm5719-llvm-73a7bd3616d8ae6788256ce8fe8c5dcc351e9ecc.tar.gz
bcm5719-llvm-73a7bd3616d8ae6788256ce8fe8c5dcc351e9ecc.zip
Fix crashes from delayed template parsing code that assumed getBody() would return non-null.
Patch by Etienne Bergeron. llvm-svn: 264049
Diffstat (limited to 'clang-tools-extra/clang-tidy/cppcoreguidelines')
-rw-r--r--clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
index 6e5896a9f49..672d222e595 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -179,6 +179,11 @@ void ProTypeMemberInitCheck::check(const MatchFinder::MatchResult &Result) {
const auto *Ctor = Result.Nodes.getNodeAs<CXXConstructorDecl>("ctor");
const auto &MemberFields = Ctor->getParent()->fields();
+ // Skip declarations delayed by late template parsing without a body.
+ const Stmt *Body = Ctor->getBody();
+ if (!Body)
+ return;
+
SmallPtrSet<const FieldDecl *, 16> FieldsToInit;
fieldsRequiringInit(MemberFields, FieldsToInit);
if (FieldsToInit.empty())
@@ -193,8 +198,8 @@ void ProTypeMemberInitCheck::check(const MatchFinder::MatchResult &Result) {
continue;
FieldsToInit.erase(Init->getMember());
}
- removeFieldsInitializedInBody(*Ctor->getBody(), *Result.Context,
- FieldsToInit);
+ removeFieldsInitializedInBody(*Body, *Result.Context, FieldsToInit);
+
if (FieldsToInit.empty())
return;
OpenPOWER on IntegriCloud