summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclCXX.cpp
diff options
context:
space:
mode:
authorNicolas Lesser <blitzrakete@gmail.com>2019-01-27 19:19:59 +0000
committerNicolas Lesser <blitzrakete@gmail.com>2019-01-27 19:19:59 +0000
commit0276d12426c03f493afa4958136ffc8add7c40f3 (patch)
tree7413b3e4b50268a9aacd89e4886eea25669b1afc /clang/lib/Sema/SemaDeclCXX.cpp
parent1dc4e01cbfbdc612203a98b6d2a6ffe37bbd3c90 (diff)
downloadbcm5719-llvm-0276d12426c03f493afa4958136ffc8add7c40f3.tar.gz
bcm5719-llvm-0276d12426c03f493afa4958136ffc8add7c40f3.zip
[SemaCXX] Fix ICE with structure bindings to members of template
Summary: Trying to use structure binding with a structure that doesn't implement std::tuple_size, should unpack the data members. When the struct is a template though, clang might hit an assertion (if the type has not been completed before), because CXXRecordDecl::DefinitionData is nullptr. This commit fixes the problem by completing the type while trying to decompose the structured binding. The ICE happens in real world code, for example, when trying to iterate a protobuf generated map with a range-based for loop and structure bindings (because google::protobuf::MapPair is a template and doesn't support std::tuple_size). Reported-by: nicholas.sun@nlsun.com Patch by Daniele Di Proietto Reviewers: #clang, rsmith Reviewed By: #clang, rsmith Subscribers: cpplearner, Rakete1111, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D56974 llvm-svn: 352323
Diffstat (limited to 'clang/lib/Sema/SemaDeclCXX.cpp')
-rw-r--r--clang/lib/Sema/SemaDeclCXX.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index fe845224e02..9ca2e87df44 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -1300,6 +1300,10 @@ static DeclAccessPair findDecomposableBaseClass(Sema &S, SourceLocation Loc,
static bool checkMemberDecomposition(Sema &S, ArrayRef<BindingDecl*> Bindings,
ValueDecl *Src, QualType DecompType,
const CXXRecordDecl *OrigRD) {
+ if (S.RequireCompleteType(Src->getLocation(), DecompType,
+ diag::err_incomplete_type))
+ return true;
+
CXXCastPath BasePath;
DeclAccessPair BasePair =
findDecomposableBaseClass(S, Src->getLocation(), OrigRD, BasePath);
OpenPOWER on IntegriCloud