diff options
author | John McCall <rjmccall@apple.com> | 2011-11-15 01:35:18 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2011-11-15 01:35:18 +0000 |
commit | 32509f1e60451d86e9fbc473b6e853ba10b5fd1e (patch) | |
tree | fb5508ad78d02b807ee47b267d03ec278ad4cead /lib | |
parent | 02ae32ae110eeb1ef785bf5ad9cdce1c001a5fa1 (diff) |
Resolve placeholder expressions before trying to deduce
'auto'. Introduce a convenience method to make this a bit
easier, and use it elsewhere.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144605 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 5 | ||||
-rw-r--r-- | lib/Sema/SemaInit.cpp | 15 | ||||
-rw-r--r-- | lib/Sema/SemaPseudoObject.cpp | 10 | ||||
-rw-r--r-- | lib/Sema/SemaTemplateDeduction.cpp | 8 |
4 files changed, 18 insertions, 20 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 4f2f8c4eaf..cfa5feabb3 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -3976,10 +3976,7 @@ Sema::ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, // Immediately handle non-overload placeholders. Overloads can be // resolved contextually, but everything else here can't. for (unsigned I = 0; I != NumInit; ++I) { - if (const BuiltinType *pty - = InitList[I]->getType()->getAsPlaceholderType()) { - if (pty->getKind() == BuiltinType::Overload) continue; - + if (InitList[I]->getType()->isNonOverloadPlaceholderType()) { ExprResult result = CheckPlaceholderExpr(InitList[I]); // Ignore failures; dropping the entire initializer list because diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index c24f8aa5e2..3f91bb53e8 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -3795,17 +3795,14 @@ InitializationSequence::InitializationSequence(Sema &S, setSequenceKind(NormalSequence); for (unsigned I = 0; I != NumArgs; ++I) - if (const BuiltinType *PlaceholderTy - = Args[I]->getType()->getAsPlaceholderType()) { + if (Args[I]->getType()->isNonOverloadPlaceholderType()) { // FIXME: should we be doing this here? - if (PlaceholderTy->getKind() != BuiltinType::Overload) { - ExprResult result = S.CheckPlaceholderExpr(Args[I]); - if (result.isInvalid()) { - SetFailed(FK_PlaceholderType); - return; - } - Args[I] = result.take(); + ExprResult result = S.CheckPlaceholderExpr(Args[I]); + if (result.isInvalid()) { + SetFailed(FK_PlaceholderType); + return; } + Args[I] = result.take(); } diff --git a/lib/Sema/SemaPseudoObject.cpp b/lib/Sema/SemaPseudoObject.cpp index b70c4ca811..3bd671d10c 100644 --- a/lib/Sema/SemaPseudoObject.cpp +++ b/lib/Sema/SemaPseudoObject.cpp @@ -775,12 +775,10 @@ ExprResult Sema::checkPseudoObjectAssignment(Scope *S, SourceLocation opcLoc, VK_RValue, OK_Ordinary, opcLoc); // Filter out non-overload placeholder types in the RHS. - if (const BuiltinType *PTy = RHS->getType()->getAsPlaceholderType()) { - if (PTy->getKind() != BuiltinType::Overload) { - ExprResult result = CheckPlaceholderExpr(RHS); - if (result.isInvalid()) return ExprError(); - RHS = result.take(); - } + if (RHS->getType()->isNonOverloadPlaceholderType()) { + ExprResult result = CheckPlaceholderExpr(RHS); + if (result.isInvalid()) return ExprError(); + RHS = result.take(); } Expr *opaqueRef = LHS->IgnoreParens(); diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp index 93ea89d628..17987da16a 100644 --- a/lib/Sema/SemaTemplateDeduction.cpp +++ b/lib/Sema/SemaTemplateDeduction.cpp @@ -3342,8 +3342,14 @@ namespace { /// /// \returns true if deduction succeeded, false if it failed. bool -Sema::DeduceAutoType(TypeSourceInfo *Type, Expr *Init, +Sema::DeduceAutoType(TypeSourceInfo *Type, Expr *&Init, TypeSourceInfo *&Result) { + if (Init->getType()->isNonOverloadPlaceholderType()) { + ExprResult result = CheckPlaceholderExpr(Init); + if (result.isInvalid()) return false; + Init = result.take(); + } + if (Init->isTypeDependent()) { Result = Type; return true; |