summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@apple.com>2019-01-11 04:57:34 +0000
committerAkira Hatanaka <ahatanaka@apple.com>2019-01-11 04:57:34 +0000
commitd458ceda24fde3bc0f2f910b80e3bd9f990af2fa (patch)
tree76a3709db53d61060dd18ebd5c56fe196d432b34 /clang/lib/Sema/SemaDecl.cpp
parenteb139def3d9b06b9c477148a74d5cc7dedecc3f5 (diff)
downloadbcm5719-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/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index f77aeb64b36..0fb4ba60bf8 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -10812,7 +10812,7 @@ QualType Sema::deduceVarTypeFromInitializer(VarDecl *VDecl,
DeclarationName Name, QualType Type,
TypeSourceInfo *TSI,
SourceRange Range, bool DirectInit,
- Expr *Init) {
+ Expr *&Init) {
bool IsInitCapture = !VDecl;
assert((!VDecl || !VDecl->isInitCapture()) &&
"init captures are expected to be deduced prior to initialization");
@@ -10928,7 +10928,8 @@ QualType Sema::deduceVarTypeFromInitializer(VarDecl *VDecl,
<< (DeduceInit->getType().isNull() ? TSI->getType()
: DeduceInit->getType())
<< DeduceInit->getSourceRange();
- }
+ } else
+ Init = DeduceInit;
// Warn if we deduced 'id'. 'auto' usually implies type-safety, but using
// 'id' instead of a specific object type prevents most of our usual
@@ -10945,7 +10946,7 @@ QualType Sema::deduceVarTypeFromInitializer(VarDecl *VDecl,
}
bool Sema::DeduceVariableDeclarationType(VarDecl *VDecl, bool DirectInit,
- Expr *Init) {
+ Expr *&Init) {
QualType DeducedType = deduceVarTypeFromInitializer(
VDecl, VDecl->getDeclName(), VDecl->getType(), VDecl->getTypeSourceInfo(),
VDecl->getSourceRange(), DirectInit, Init);
@@ -11451,8 +11452,9 @@ void Sema::ActOnUninitializedDecl(Decl *RealDecl) {
return;
}
+ Expr *TmpInit = nullptr;
if (Type->isUndeducedType() &&
- DeduceVariableDeclarationType(Var, false, nullptr))
+ DeduceVariableDeclarationType(Var, false, TmpInit))
return;
// C++11 [class.static.data]p3: A static data member can be declared with
OpenPOWER on IntegriCloud