diff options
author | Akira Hatanaka <ahatanaka@apple.com> | 2019-01-11 04:57:34 +0000 |
---|---|---|
committer | Akira Hatanaka <ahatanaka@apple.com> | 2019-01-11 04:57:34 +0000 |
commit | d458ceda24fde3bc0f2f910b80e3bd9f990af2fa (patch) | |
tree | 76a3709db53d61060dd18ebd5c56fe196d432b34 /clang/lib/Sema/SemaLambda.cpp | |
parent | eb139def3d9b06b9c477148a74d5cc7dedecc3f5 (diff) | |
download | bcm5719-llvm-d458ceda24fde3bc0f2f910b80e3bd9f990af2fa.tar.gz bcm5719-llvm-d458ceda24fde3bc0f2f910b80e3bd9f990af2fa.zip |
[Sema] If CheckPlaceholderExpr rewrites the initializer of an auto
variable during auto type deduction, use the rewritten initializer when
performing initialization of the variable.
This silences spurious -Warc-repeated-use-of-weak warnings that are
issued when the initializer uses a weak ObjC pointer.
Differential Revision: https://reviews.llvm.org/D55662
llvm-svn: 350917
Diffstat (limited to 'clang/lib/Sema/SemaLambda.cpp')
-rw-r--r-- | clang/lib/Sema/SemaLambda.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp index 10f5e7b7bcf..af233b96d69 100644 --- a/clang/lib/Sema/SemaLambda.cpp +++ b/clang/lib/Sema/SemaLambda.cpp @@ -759,14 +759,15 @@ QualType Sema::buildLambdaInitCaptureInitialization(SourceLocation Loc, TypeSourceInfo *TSI = TLB.getTypeSourceInfo(Context, DeductType); // Deduce the type of the init capture. + Expr *DeduceInit = Init; QualType DeducedType = deduceVarTypeFromInitializer( /*VarDecl*/nullptr, DeclarationName(Id), DeductType, TSI, - SourceRange(Loc, Loc), IsDirectInit, Init); + SourceRange(Loc, Loc), IsDirectInit, DeduceInit); if (DeducedType.isNull()) return QualType(); // Are we a non-list direct initialization? - ParenListExpr *CXXDirectInit = dyn_cast<ParenListExpr>(Init); + bool CXXDirectInit = isa<ParenListExpr>(Init); // Perform initialization analysis and ensure any implicit conversions // (such as lvalue-to-rvalue) are enforced. @@ -779,10 +780,7 @@ QualType Sema::buildLambdaInitCaptureInitialization(SourceLocation Loc, : InitializationKind::CreateDirectList(Loc)) : InitializationKind::CreateCopy(Loc, Init->getBeginLoc()); - MultiExprArg Args = Init; - if (CXXDirectInit) - Args = - MultiExprArg(CXXDirectInit->getExprs(), CXXDirectInit->getNumExprs()); + MultiExprArg Args = DeduceInit; QualType DclT; InitializationSequence InitSeq(*this, Entity, Kind, Args); ExprResult Result = InitSeq.Perform(*this, Entity, Kind, Args, &DclT); |