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.cpp95
1 files changed, 0 insertions, 95 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index dd490ec51fc..66dc8e13ae1 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -4444,101 +4444,6 @@ Sema::ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc, StmtTy *body,
return new (Context) BlockExpr(BSI->TheDecl, BlockTy);
}
-/// ExprsMatchFnType - return true if the Exprs in array Args have
-/// QualTypes that match the QualTypes of the arguments of the FnType.
-/// The number of arguments has already been validated to match the number of
-/// arguments in FnType.
-static bool ExprsMatchFnType(Expr **Args, const FunctionTypeProto *FnType,
- ASTContext &Context) {
- unsigned NumParams = FnType->getNumArgs();
- for (unsigned i = 0; i != NumParams; ++i) {
- QualType ExprTy = Context.getCanonicalType(Args[i]->getType());
- QualType ParmTy = Context.getCanonicalType(FnType->getArgType(i));
-
- if (ExprTy.getUnqualifiedType() != ParmTy.getUnqualifiedType())
- return false;
- }
- return true;
-}
-
-Sema::ExprResult Sema::ActOnOverloadExpr(ExprTy **args, unsigned NumArgs,
- SourceLocation *CommaLocs,
- SourceLocation BuiltinLoc,
- SourceLocation RParenLoc) {
- // __builtin_overload requires at least 2 arguments
- if (NumArgs < 2)
- return Diag(RParenLoc, diag::err_typecheck_call_too_few_args)
- << SourceRange(BuiltinLoc, RParenLoc);
-
- // The first argument is required to be a constant expression. It tells us
- // the number of arguments to pass to each of the functions to be overloaded.
- Expr **Args = reinterpret_cast<Expr**>(args);
- Expr *NParamsExpr = Args[0];
- llvm::APSInt constEval(32);
- SourceLocation ExpLoc;
- if (!NParamsExpr->isIntegerConstantExpr(constEval, Context, &ExpLoc))
- return Diag(ExpLoc, diag::err_overload_expr_requires_non_zero_constant)
- << NParamsExpr->getSourceRange();
-
- // Verify that the number of parameters is > 0
- unsigned NumParams = constEval.getZExtValue();
- if (NumParams == 0)
- return Diag(ExpLoc, diag::err_overload_expr_requires_non_zero_constant)
- << NParamsExpr->getSourceRange();
- // Verify that we have at least 1 + NumParams arguments to the builtin.
- if ((NumParams + 1) > NumArgs)
- return Diag(RParenLoc, diag::err_typecheck_call_too_few_args)
- << SourceRange(BuiltinLoc, RParenLoc);
-
- // Figure out the return type, by matching the args to one of the functions
- // listed after the parameters.
- OverloadExpr *OE = 0;
- for (unsigned i = NumParams + 1; i < NumArgs; ++i) {
- // UsualUnaryConversions will convert the function DeclRefExpr into a
- // pointer to function.
- Expr *Fn = UsualUnaryConversions(Args[i]);
- const FunctionTypeProto *FnType = 0;
- if (const PointerType *PT = Fn->getType()->getAsPointerType())
- FnType = PT->getPointeeType()->getAsFunctionTypeProto();
-
- // The Expr type must be FunctionTypeProto, since FunctionTypeProto has no
- // parameters, and the number of parameters must match the value passed to
- // the builtin.
- if (!FnType || (FnType->getNumArgs() != NumParams))
- return Diag(Fn->getExprLoc(), diag::err_overload_incorrect_fntype)
- << Fn->getSourceRange();
-
- // Scan the parameter list for the FunctionType, checking the QualType of
- // each parameter against the QualTypes of the arguments to the builtin.
- // If they match, return a new OverloadExpr.
- if (ExprsMatchFnType(Args+1, FnType, Context)) {
- if (OE)
- return Diag(Fn->getExprLoc(), diag::err_overload_multiple_match)
- << OE->getFn()->getSourceRange();
- // Remember our match, and continue processing the remaining arguments
- // to catch any errors.
- OE = new (Context) OverloadExpr(Context, Args, NumArgs, i,
- FnType->getResultType().getNonReferenceType(),
- BuiltinLoc, RParenLoc);
- }
- }
- // Return the newly created OverloadExpr node, if we succeded in matching
- // exactly one of the candidate functions.
- if (OE)
- return OE;
-
- // If we didn't find a matching function Expr in the __builtin_overload list
- // the return an error.
- std::string typeNames;
- for (unsigned i = 0; i != NumParams; ++i) {
- if (i != 0) typeNames += ", ";
- typeNames += Args[i+1]->getType().getAsString();
- }
-
- return Diag(BuiltinLoc, diag::err_overload_no_match)
- << typeNames << SourceRange(BuiltinLoc, RParenLoc);
-}
-
Sema::ExprResult Sema::ActOnVAArg(SourceLocation BuiltinLoc,
ExprTy *expr, TypeTy *type,
SourceLocation RPLoc) {
OpenPOWER on IntegriCloud