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 | d5c98ae69523846a921813559533f0175e680f9a (patch) | |
| tree | 2fb27896c7b91c619a542fed39d4c7cea9750a6b /clang/lib/Sema | |
| parent | 9957e8b7895406301d4545fb2f5749f486020a94 (diff) | |
| download | bcm5719-llvm-d5c98ae69523846a921813559533f0175e680f9a.tar.gz bcm5719-llvm-d5c98ae69523846a921813559533f0175e680f9a.zip | |
Resolve placeholder expressions before trying to deduce
'auto'. Introduce a convenience method to make this a bit
easier, and use it elsewhere.
llvm-svn: 144605
Diffstat (limited to 'clang/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 5 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaInit.cpp | 15 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaPseudoObject.cpp | 10 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaTemplateDeduction.cpp | 8 |
4 files changed, 18 insertions, 20 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 4f2f8c4eafd..cfa5feabb39 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/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/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index c24f8aa5e21..3f91bb53e88 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/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/clang/lib/Sema/SemaPseudoObject.cpp b/clang/lib/Sema/SemaPseudoObject.cpp index b70c4ca811c..3bd671d10cd 100644 --- a/clang/lib/Sema/SemaPseudoObject.cpp +++ b/clang/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/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp index 93ea89d6285..17987da16ad 100644 --- a/clang/lib/Sema/SemaTemplateDeduction.cpp +++ b/clang/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; |

