From: Richard Smith Date: Fri, 25 Mar 2016 00:08:53 +0000 (+0000) Subject: Fix nondeterminism in computation of builtin operator overload sets. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=04ef11f7ddbf05932ce586ca70ff0a85990fc02d;p=clang Fix nondeterminism in computation of builtin operator overload sets. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@264363 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index cf7fb557a7..e9154bc12a 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -6818,7 +6818,8 @@ namespace { /// enumeration types. class BuiltinCandidateTypeSet { /// TypeSet - A set of types. - typedef llvm::SmallPtrSet TypeSet; + typedef llvm::SetVector, + llvm::SmallPtrSet> TypeSet; /// PointerTypes - The set of pointer types that will be used in the /// built-in candidates. @@ -6917,7 +6918,7 @@ BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants(QualType Ty, const Qualifiers &VisibleQuals) { // Insert this type. - if (!PointerTypes.insert(Ty).second) + if (!PointerTypes.insert(Ty)) return false; QualType PointeeTy; @@ -6985,7 +6986,7 @@ bool BuiltinCandidateTypeSet::AddMemberPointerWithMoreQualifiedTypeVariants( QualType Ty) { // Insert this type. - if (!MemberPointerTypes.insert(Ty).second) + if (!MemberPointerTypes.insert(Ty)) return false; const MemberPointerType *PointerTy = Ty->getAs(); diff --git a/test/SemaCXX/diagnostic-order.cpp b/test/SemaCXX/diagnostic-order.cpp index f0899018f7..b3b270bfc9 100644 --- a/test/SemaCXX/diagnostic-order.cpp +++ b/test/SemaCXX/diagnostic-order.cpp @@ -3,9 +3,9 @@ // Ensure that the diagnostics we produce for this situation appear in a // deterministic order. This requires ADL to provide lookup results in a // deterministic order. -template struct Error { typedef typename T::error error; }; -struct X { template friend typename Error::error f(X, T); }; -struct Y { template friend typename Error::error f(T, Y); }; +template struct Error { typedef typename T::error error; }; +struct X { template friend typename Error::error f(X, T); }; +struct Y { template friend typename Error::error f(T, Y); }; void g() { f(X(), Y()); @@ -15,6 +15,43 @@ void g() { // order below is source order, which seems best). The crucial fact is that // there is one single order that is stable across multiple runs of clang. // -// CHECK: no type named 'error' in 'Y' // CHECK: no type named 'error' in 'X' +// CHECK: no type named 'error' in 'Y' // CHECK: no matching function for call to 'f' + + +struct Oper { + template::error> operator T(); + + operator int*(); + operator float*(); + operator X*(); + operator Y*(); + + operator int(*[1])(); + operator int(*[2])(); + operator int(*[3])(); + operator int(*[4])(); + operator int(*[5])(); + operator int(*[6])(); + operator int(*[7])(); + operator int(*[8])(); + operator float(*[1])(); + operator float(*[2])(); + operator float(*[3])(); + operator float(*[4])(); + operator float(*[5])(); + operator float(*[6])(); + operator float(*[7])(); + operator float(*[8])(); +}; +int *p = Oper() + 0; + +// CHECK: no type named 'error' in 'Oper' +// CHECK: in instantiation of template class 'Error' +// CHECK: no type named 'error' in 'Oper' +// CHECK: in instantiation of template class 'Error' +// CHECK: no type named 'error' in 'Oper' +// CHECK: in instantiation of template class 'Error' +// CHECK: no type named 'error' in 'Oper' +// CHECK: in instantiation of template class 'Error'