From: Richard Smith Date: Wed, 23 Jul 2014 20:07:08 +0000 (+0000) Subject: PR20228: don't retain a pointer to a vector element after the container has been... X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a507bfc6b99ae8e187c1b5b952ac48c0fa7f00ef;p=platform%2Fupstream%2Fllvm.git PR20228: don't retain a pointer to a vector element after the container has been resized. llvm-svn: 213790 --- diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 7fe5e7a..2745a8c 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -3651,12 +3651,13 @@ static bool evaluateTypeTrait(Sema &S, TypeTrait Kind, SourceLocation KWLoc, if (T->isObjectType() || T->isFunctionType()) T = S.Context.getRValueReferenceType(T); OpaqueArgExprs.push_back( - OpaqueValueExpr(Args[I]->getTypeLoc().getLocStart(), + OpaqueValueExpr(Args[I]->getTypeLoc().getLocStart(), T.getNonLValueExprType(S.Context), Expr::getValueKindForType(T))); - ArgExprs.push_back(&OpaqueArgExprs.back()); } - + for (Expr &E : OpaqueArgExprs) + ArgExprs.push_back(&E); + // Perform the initialization in an unevaluated context within a SFINAE // trap at translation unit scope. EnterExpressionEvaluationContext Unevaluated(S, Sema::Unevaluated); diff --git a/clang/test/SemaCXX/type-traits.cpp b/clang/test/SemaCXX/type-traits.cpp index 3b94ef09..4833c14 100644 --- a/clang/test/SemaCXX/type-traits.cpp +++ b/clang/test/SemaCXX/type-traits.cpp @@ -146,6 +146,10 @@ struct ThreeArgCtor { ThreeArgCtor(int*, char*, int); }; +struct VariadicCtor { + template VariadicCtor(T...); +}; + void is_pod() { { int arr[T(__is_pod(int))]; } @@ -1968,6 +1972,10 @@ void constructible_checks() { // PR19178 { int arr[F(__is_constructible(Abstract))]; } { int arr[F(__is_nothrow_constructible(Abstract))]; } + + // PR20228 + { int arr[T(__is_constructible(VariadicCtor, + int, int, int, int, int, int, int, int, int))]; } } // Instantiation of __is_trivially_constructible