[PATCH] D55662: [Sema] If CheckPlaceholderExpr rewrites a placeholder expression when the type of an auto variable is being deduced, use the rewritten expression when performing initialization of the variable.
Akira Hatanaka via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 10 12:16:27 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL350887: [Sema] Call CheckPlaceholderExpr to resolve typeof or decltype (authored by ahatanak, committed by ).
Herald added a subscriber: llvm-commits.
Changed prior to commit:
https://reviews.llvm.org/D55662?vs=180993&id=181129#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D55662/new/
https://reviews.llvm.org/D55662
Files:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaExprObjC.cpp
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/SemaObjC/arc-repeated-weak.mm
Index: cfe/trunk/lib/Sema/SemaType.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp
+++ cfe/trunk/lib/Sema/SemaType.cpp
@@ -8055,9 +8055,7 @@
}
QualType Sema::BuildTypeofExprType(Expr *E, SourceLocation Loc) {
- ExprResult ER = CheckPlaceholderExpr(E);
- if (ER.isInvalid()) return QualType();
- E = ER.get();
+ assert(!E->hasPlaceholderType() && "unexpected placeholder");
if (!getLangOpts().CPlusPlus && E->refersToBitField())
Diag(E->getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield) << 2;
@@ -8142,9 +8140,7 @@
QualType Sema::BuildDecltypeType(Expr *E, SourceLocation Loc,
bool AsUnevaluated) {
- ExprResult ER = CheckPlaceholderExpr(E);
- if (ER.isInvalid()) return QualType();
- E = ER.get();
+ assert(!E->hasPlaceholderType() && "unexpected placeholder");
if (AsUnevaluated && CodeSynthesisContexts.empty() &&
E->HasSideEffects(Context, false)) {
Index: cfe/trunk/lib/Sema/SemaExpr.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp
+++ cfe/trunk/lib/Sema/SemaExpr.cpp
@@ -14557,6 +14557,10 @@
}
ExprResult Sema::HandleExprEvaluationContextForTypeof(Expr *E) {
+ ExprResult Result = CheckPlaceholderExpr(E);
+ if (Result.isInvalid())
+ return ExprError();
+ E = Result.get();
if (!E->getType()->isVariablyModifiedType())
return E;
return TransformToPotentiallyEvaluated(E);
Index: cfe/trunk/lib/Sema/SemaExprObjC.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp
@@ -3161,7 +3161,7 @@
Prop->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_weak;
if (!IsWeak && Sel.isUnarySelector())
IsWeak = ReturnType.getObjCLifetime() & Qualifiers::OCL_Weak;
- if (IsWeak &&
+ if (IsWeak && !isUnevaluatedContext() &&
!Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, LBracLoc))
getCurFunction()->recordUseOfWeak(Result, Prop);
}
Index: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
@@ -4429,6 +4429,10 @@
return DAR_FailedAlreadyDiagnosed;
}
+ ExprResult ER = CheckPlaceholderExpr(Init);
+ if (ER.isInvalid())
+ return DAR_FailedAlreadyDiagnosed;
+ Init = ER.get();
QualType Deduced = BuildDecltypeType(Init, Init->getBeginLoc(), false);
if (Deduced.isNull())
return DAR_FailedAlreadyDiagnosed;
Index: cfe/trunk/lib/Sema/SemaExprCXX.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp
@@ -6543,6 +6543,11 @@
ExpressionEvaluationContextRecord::EK_Decltype &&
"not in a decltype expression");
+ ExprResult Result = CheckPlaceholderExpr(E);
+ if (Result.isInvalid())
+ return ExprError();
+ E = Result.get();
+
// C++11 [expr.call]p11:
// If a function call is a prvalue of object type,
// -- if the function call is either
Index: cfe/trunk/test/SemaObjC/arc-repeated-weak.mm
===================================================================
--- cfe/trunk/test/SemaObjC/arc-repeated-weak.mm
+++ cfe/trunk/test/SemaObjC/arc-repeated-weak.mm
@@ -462,6 +462,9 @@
NSString * t2 = NSBundle.foo2.prop;
use(NSBundle.foo2.weakProp); // expected-warning{{weak property 'weakProp' may be accessed multiple times}}
use(NSBundle2.foo2.weakProp); // expected-note{{also accessed here}}
+ decltype([NSBundle2.foo2 weakProp]) t3;
+ decltype(NSBundle2.foo2.weakProp) t4;
+ __typeof__(NSBundle2.foo2.weakProp) t5;
}
// This used to crash in the constructor of WeakObjectProfileTy when a
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55662.181129.patch
Type: text/x-patch
Size: 3948 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190110/b4508789/attachment.bin>
More information about the cfe-commits
mailing list