From d53e19228608242b25ec00d0b1fbc31801b89978 Mon Sep 17 00:00:00 2001 From: Philippe Canal Date: Mon, 12 Aug 2013 12:32:16 -0500 Subject: [PATCH] Re-add IsOverload() and FuncArgTypesMatch() we need them after all. See b706579ac554e3e5f6e6cc031a21b40f158f1f82 --- lib/Interpreter/LookupHelper.cpp | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/lib/Interpreter/LookupHelper.cpp b/lib/Interpreter/LookupHelper.cpp index c7e119ca..16ce42a6 100644 --- a/lib/Interpreter/LookupHelper.cpp +++ b/lib/Interpreter/LookupHelper.cpp @@ -398,6 +398,40 @@ namespace cling { return foundDC; } + static bool FuncArgTypesMatch(const ASTContext& C, + const llvm::SmallVector& GivenArgTypes, + const FunctionProtoType* FPT) { + // FIXME: What if FTP->arg_size() != GivenArgTypes.size()? + FunctionProtoType::arg_type_iterator ATI = FPT->arg_type_begin(); + FunctionProtoType::arg_type_iterator E = FPT->arg_type_end(); + llvm::SmallVector::const_iterator GAI = GivenArgTypes.begin(); + for (; ATI && (ATI != E); ++ATI, ++GAI) { + if (!C.hasSameType(*ATI, *GAI)) { + return false; + } + } + return true; + } + + static bool IsOverload(const ASTContext& C, + const TemplateArgumentListInfo* FuncTemplateArgs, + const llvm::SmallVector& GivenArgTypes, + FunctionDecl* FD, bool UseUsingDeclRules) { + //FunctionTemplateDecl* FTD = FD->getDescribedFunctionTemplate(); + QualType FQT = C.getCanonicalType(FD->getType()); + if (llvm::isa(FQT.getTypePtr())) { + // A K&R-style function (no prototype), is considered to match the args. + return false; + } + const FunctionProtoType* FPT = llvm::cast(FQT); + if ((GivenArgTypes.size() != FPT->getNumArgs()) || + //(GivenArgsAreEllipsis != FPT->isVariadic()) || + !FuncArgTypesMatch(C, GivenArgTypes, FPT)) { + return true; + } + return false; + } + static const FunctionDecl* overloadFunctionSelector(DeclContext* foundDC, bool objectIsConst,