Vendor import of clang trunk r291015:

https://llvm.org/svn/llvm-project/cfe/trunk@291015
This commit is contained in:
Dimitry Andric 2017-01-04 22:25:26 +00:00
parent 0c75eea8f6
commit d5dc75c5cf
6 changed files with 17 additions and 59 deletions

View File

@ -3375,9 +3375,6 @@ def err_addrof_function_disabled_by_enable_if_attr : Error<
"non-tautological enable_if conditions">; "non-tautological enable_if conditions">;
def note_addrof_ovl_candidate_disabled_by_enable_if_attr : Note< def note_addrof_ovl_candidate_disabled_by_enable_if_attr : Note<
"candidate function made ineligible by enable_if">; "candidate function made ineligible by enable_if">;
def note_ovl_candidate_failed_overload_resolution : Note<
"candidate template ignored: couldn't resolve reference to overloaded "
"function %0">;
def note_ovl_candidate_deduced_mismatch : Note< def note_ovl_candidate_deduced_mismatch : Note<
"candidate template ignored: deduced type " "candidate template ignored: deduced type "
"%diff{$ of %ordinal0 parameter does not match adjusted type $ of argument" "%diff{$ of %ordinal0 parameter does not match adjusted type $ of argument"

View File

@ -6576,9 +6576,6 @@ class Sema {
/// \brief The explicitly-specified template arguments were not valid /// \brief The explicitly-specified template arguments were not valid
/// template arguments for the given template. /// template arguments for the given template.
TDK_InvalidExplicitArguments, TDK_InvalidExplicitArguments,
/// \brief The arguments included an overloaded function name that could
/// not be resolved to a suitable function.
TDK_FailedOverloadResolution,
/// \brief Deduction failed; that's all we know. /// \brief Deduction failed; that's all we know.
TDK_MiscellaneousDeductionFailure, TDK_MiscellaneousDeductionFailure,
/// \brief CUDA Target attributes do not match. /// \brief CUDA Target attributes do not match.

View File

@ -53,7 +53,7 @@ class TemplateDeductionInfo {
public: public:
TemplateDeductionInfo(SourceLocation Loc, unsigned DeducedDepth = 0) TemplateDeductionInfo(SourceLocation Loc, unsigned DeducedDepth = 0)
: Deduced(nullptr), Loc(Loc), HasSFINAEDiagnostic(false), : Deduced(nullptr), Loc(Loc), HasSFINAEDiagnostic(false),
DeducedDepth(DeducedDepth), Expression(nullptr) {} DeducedDepth(DeducedDepth), CallArgIndex(0) {}
/// \brief Returns the location at which template argument is /// \brief Returns the location at which template argument is
/// occurring. /// occurring.
@ -175,21 +175,12 @@ class TemplateDeductionInfo {
/// FIXME: Finish documenting this. /// FIXME: Finish documenting this.
TemplateArgument SecondArg; TemplateArgument SecondArg;
union { /// \brief The index of the function argument that caused a deduction
/// \brief The expression which caused a deduction failure. /// failure.
/// ///
/// TDK_FailedOverloadResolution: this argument is the reference to /// TDK_DeducedMismatch: this is the index of the argument that had a
/// an overloaded function which could not be resolved to a specific /// different argument type from its substituted parameter type.
/// function. unsigned CallArgIndex;
Expr *Expression;
/// \brief The index of the function argument that caused a deduction
/// failure.
///
/// TDK_DeducedMismatch: this is the index of the argument that had a
/// different argument type from its substituted parameter type.
unsigned CallArgIndex;
};
/// \brief Information on packs that we're currently expanding. /// \brief Information on packs that we're currently expanding.
/// ///
@ -235,10 +226,6 @@ struct DeductionFailureInfo {
/// refers to, if any. /// refers to, if any.
const TemplateArgument *getSecondArg(); const TemplateArgument *getSecondArg();
/// \brief Return the expression this deduction failure refers to,
/// if any.
Expr *getExpr();
/// \brief Return the index of the call argument that this deduction /// \brief Return the index of the call argument that this deduction
/// failure refers to, if any. /// failure refers to, if any.
llvm::Optional<unsigned> getCallArgIndex(); llvm::Optional<unsigned> getCallArgIndex();

View File

@ -644,10 +644,6 @@ clang::MakeDeductionFailureInfo(ASTContext &Context,
Result.HasDiagnostic = true; Result.HasDiagnostic = true;
} }
break; break;
case Sema::TDK_FailedOverloadResolution:
Result.Data = Info.Expression;
break;
} }
return Result; return Result;
@ -662,7 +658,6 @@ void DeductionFailureInfo::Destroy() {
case Sema::TDK_TooManyArguments: case Sema::TDK_TooManyArguments:
case Sema::TDK_TooFewArguments: case Sema::TDK_TooFewArguments:
case Sema::TDK_InvalidExplicitArguments: case Sema::TDK_InvalidExplicitArguments:
case Sema::TDK_FailedOverloadResolution:
case Sema::TDK_CUDATargetMismatch: case Sema::TDK_CUDATargetMismatch:
break; break;
@ -705,7 +700,6 @@ TemplateParameter DeductionFailureInfo::getTemplateParameter() {
case Sema::TDK_SubstitutionFailure: case Sema::TDK_SubstitutionFailure:
case Sema::TDK_DeducedMismatch: case Sema::TDK_DeducedMismatch:
case Sema::TDK_NonDeducedMismatch: case Sema::TDK_NonDeducedMismatch:
case Sema::TDK_FailedOverloadResolution:
case Sema::TDK_CUDATargetMismatch: case Sema::TDK_CUDATargetMismatch:
return TemplateParameter(); return TemplateParameter();
@ -737,7 +731,6 @@ TemplateArgumentList *DeductionFailureInfo::getTemplateArgumentList() {
case Sema::TDK_Inconsistent: case Sema::TDK_Inconsistent:
case Sema::TDK_Underqualified: case Sema::TDK_Underqualified:
case Sema::TDK_NonDeducedMismatch: case Sema::TDK_NonDeducedMismatch:
case Sema::TDK_FailedOverloadResolution:
case Sema::TDK_CUDATargetMismatch: case Sema::TDK_CUDATargetMismatch:
return nullptr; return nullptr;
@ -765,7 +758,6 @@ const TemplateArgument *DeductionFailureInfo::getFirstArg() {
case Sema::TDK_TooFewArguments: case Sema::TDK_TooFewArguments:
case Sema::TDK_InvalidExplicitArguments: case Sema::TDK_InvalidExplicitArguments:
case Sema::TDK_SubstitutionFailure: case Sema::TDK_SubstitutionFailure:
case Sema::TDK_FailedOverloadResolution:
case Sema::TDK_CUDATargetMismatch: case Sema::TDK_CUDATargetMismatch:
return nullptr; return nullptr;
@ -793,7 +785,6 @@ const TemplateArgument *DeductionFailureInfo::getSecondArg() {
case Sema::TDK_TooFewArguments: case Sema::TDK_TooFewArguments:
case Sema::TDK_InvalidExplicitArguments: case Sema::TDK_InvalidExplicitArguments:
case Sema::TDK_SubstitutionFailure: case Sema::TDK_SubstitutionFailure:
case Sema::TDK_FailedOverloadResolution:
case Sema::TDK_CUDATargetMismatch: case Sema::TDK_CUDATargetMismatch:
return nullptr; return nullptr;
@ -811,14 +802,6 @@ const TemplateArgument *DeductionFailureInfo::getSecondArg() {
return nullptr; return nullptr;
} }
Expr *DeductionFailureInfo::getExpr() {
if (static_cast<Sema::TemplateDeductionResult>(Result) ==
Sema::TDK_FailedOverloadResolution)
return static_cast<Expr*>(Data);
return nullptr;
}
llvm::Optional<unsigned> DeductionFailureInfo::getCallArgIndex() { llvm::Optional<unsigned> DeductionFailureInfo::getCallArgIndex() {
if (static_cast<Sema::TemplateDeductionResult>(Result) == if (static_cast<Sema::TemplateDeductionResult>(Result) ==
Sema::TDK_DeducedMismatch) Sema::TDK_DeducedMismatch)
@ -9699,14 +9682,6 @@ static void DiagnoseBadDeduction(Sema &S, NamedDecl *Found, Decl *Templated,
return; return;
} }
case Sema::TDK_FailedOverloadResolution: {
OverloadExpr::FindResult R = OverloadExpr::find(DeductionFailure.getExpr());
S.Diag(Templated->getLocation(),
diag::note_ovl_candidate_failed_overload_resolution)
<< R.Expression->getName();
return;
}
case Sema::TDK_DeducedMismatch: { case Sema::TDK_DeducedMismatch: {
// Format the template argument list into the argument string. // Format the template argument list into the argument string.
SmallString<128> TemplateArgString; SmallString<128> TemplateArgString;
@ -10043,7 +10018,6 @@ static unsigned RankDeductionFailure(const DeductionFailureInfo &DFI) {
return 3; return 3;
case Sema::TDK_InstantiationDepth: case Sema::TDK_InstantiationDepth:
case Sema::TDK_FailedOverloadResolution:
return 4; return 4;
case Sema::TDK_InvalidExplicitArguments: case Sema::TDK_InvalidExplicitArguments:

View File

@ -3279,10 +3279,9 @@ DeduceTemplateArgumentByListElement(Sema &S,
// For all other cases, just match by type. // For all other cases, just match by type.
QualType ArgType = Arg->getType(); QualType ArgType = Arg->getType();
if (AdjustFunctionParmAndArgTypesForDeduction(S, TemplateParams, ParamType, if (AdjustFunctionParmAndArgTypesForDeduction(S, TemplateParams, ParamType,
ArgType, Arg, TDF)) { ArgType, Arg, TDF))
Info.Expression = Arg; return Sema::TDK_Success;
return Sema::TDK_FailedOverloadResolution;
}
return DeduceTemplateArgumentsByTypeMatch(S, TemplateParams, ParamType, return DeduceTemplateArgumentsByTypeMatch(S, TemplateParams, ParamType,
ArgType, Info, Deduced, TDF); ArgType, Info, Deduced, TDF);
} }

View File

@ -220,10 +220,14 @@ namespace initlist_of_array {
namespace init_list_deduction_failure { namespace init_list_deduction_failure {
void f(); void f();
void f(int); void f(int);
// FIXME: It'd be nice to track that 'T' became a non-deduced context due to
// overload resolution failure for 'f'.
template<typename T> void g(std::initializer_list<T>); template<typename T> void g(std::initializer_list<T>);
// expected-note@-1 {{candidate template ignored: couldn't resolve reference to overloaded function 'f'}} // expected-note@-1 {{candidate template ignored: couldn't infer template argument 'T'}}
void h() { g({f}); } void h() {
// expected-error@-1 {{no matching function for call to 'g'}} g({f}); // expected-error {{no matching function for call to 'g'}}
g({f, h}); // ok
}
} }
namespace deleted_copy { namespace deleted_copy {