summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index bf4abfcb746..58c212b62f9 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -11850,6 +11850,22 @@ ExprResult Sema::forceUnknownAnyToType(Expr *E, QualType ToType) {
return RebuildUnknownAnyExpr(*this, ToType).Visit(E);
}
+QualType Sema::checkUnknownAnyArg(Expr *&arg) {
+ // Filter out placeholders.
+ ExprResult argR = CheckPlaceholderExpr(arg);
+ if (argR.isInvalid()) return QualType();
+ arg = argR.take();
+
+ // If the argument is an explicit cast, use that exact type as the
+ // effective parameter type.
+ if (ExplicitCastExpr *castArg = dyn_cast<ExplicitCastExpr>(arg)) {
+ return castArg->getTypeAsWritten();
+ }
+
+ // Otherwise, try to pass by value.
+ return arg->getType().getUnqualifiedType();
+}
+
static ExprResult diagnoseUnknownAnyExpr(Sema &S, Expr *E) {
Expr *orig = E;
unsigned diagID = diag::err_uncasted_use_of_unknown_any;
OpenPOWER on IntegriCloud