[cfe-commits] r84289 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaOverload.cpp test/SemaCXX/ambiguous-builtin-unary-operator.cpp test/SemaCXX/builtin-ptrtomember-ambig.cpp

Fariborz Jahanian fjahanian at apple.com
Fri Oct 16 16:25:03 PDT 2009


Author: fjahanian
Date: Fri Oct 16 18:25:02 2009
New Revision: 84289

URL: http://llvm.org/viewvc/llvm-project?rev=84289&view=rev
Log:
Patch to clean up and improve visual display of
builtin function ambiguity.


Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/SemaOverload.cpp
    cfe/trunk/test/SemaCXX/ambiguous-builtin-unary-operator.cpp
    cfe/trunk/test/SemaCXX/builtin-ptrtomember-ambig.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=84289&r1=84288&r2=84289&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Oct 16 18:25:02 2009
@@ -785,9 +785,9 @@
 def err_ovl_candidate_deleted : Note<
   "candidate function has been explicitly %select{made unavailable|deleted}0">;
 def err_ovl_builtin_binary_candidate : Note<
-    "built-in candidate operator %0 (%1, %2)">;
+    "built-in candidate %0">;
 def err_ovl_builtin_unary_candidate : Note<
-    "built-in candidate operator %0 (%1)">;
+    "built-in candidate %0">;
 def err_ovl_no_viable_function_in_init : Error<
   "no matching constructor for initialization of %0">;
 def err_ovl_ambiguous_init : Error<"call to constructor of %0 is ambiguous">;

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=84289&r1=84288&r2=84289&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Fri Oct 16 18:25:02 2009
@@ -4148,13 +4148,20 @@
       } else if (OnlyViable) {
         assert(Cand->Conversions.size() <= 2 && 
                "builtin-binary-operator-not-binary");
-        if (Cand->Conversions.size() == 1)
-          Diag(OpLoc, diag::err_ovl_builtin_unary_candidate)
-                << Opc << Cand->BuiltinTypes.ParamTypes[0];
-        else
-          Diag(OpLoc, diag::err_ovl_builtin_binary_candidate)
-                << Opc << Cand->BuiltinTypes.ParamTypes[0]
-                << Cand->BuiltinTypes.ParamTypes[1];
+        std::string TypeStr("operator");
+        TypeStr += Opc;
+        TypeStr += "(";
+        TypeStr += Cand->BuiltinTypes.ParamTypes[0].getAsString();
+        if (Cand->Conversions.size() == 1) {
+          TypeStr += ")";
+          Diag(OpLoc, diag::err_ovl_builtin_unary_candidate) << TypeStr;
+        }
+        else {
+          TypeStr += ", ";
+          TypeStr += Cand->BuiltinTypes.ParamTypes[1].getAsString();
+          TypeStr += ")";
+          Diag(OpLoc, diag::err_ovl_builtin_binary_candidate) << TypeStr;
+        }
       }
       else if (!Cand->Viable && !Reported) {
         // Non-viability might be due to ambiguous user-defined conversions,

Modified: cfe/trunk/test/SemaCXX/ambiguous-builtin-unary-operator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ambiguous-builtin-unary-operator.cpp?rev=84289&r1=84288&r2=84289&view=diff

==============================================================================
--- cfe/trunk/test/SemaCXX/ambiguous-builtin-unary-operator.cpp (original)
+++ cfe/trunk/test/SemaCXX/ambiguous-builtin-unary-operator.cpp Fri Oct 16 18:25:02 2009
@@ -14,10 +14,10 @@
 
 void test(C c) {
   ++c; // expected-error {{use of overloaded operator '++' is ambiguous}}\
-       // expected-note {{built-in candidate operator ++ ('int &')}} \
-       // expected-note {{built-in candidate operator ++ ('long &')}} \
-       // expected-note {{built-in candidate operator ++ ('long *&')}} \
-       // expected-note {{built-in candidate operator ++ ('int *&')}}
+       // expected-note {{built-in candidate operator++(int &)}} \
+       // expected-note {{built-in candidate operator++(long &)}} \
+       // expected-note {{built-in candidate operator++(long *&)}} \
+       // expected-note {{built-in candidate operator++(int *&)}}
 }
 
 struct A1 { operator volatile int&(); };
@@ -28,7 +28,7 @@
 
 void test(C1 c) {
   ++c;	// expected-error {{use of overloaded operator '++' is ambiguous}} \
-	// expected-note {{built-in candidate operator ++ ('int volatile &')}} \
-	// expected-note {{built-in candidate operator ++ ('long volatile &')}}
+	// expected-note {{built-in candidate operator++(int volatile &)}} \
+	// expected-note {{built-in candidate operator++(long volatile &)}}
 }
 

Modified: cfe/trunk/test/SemaCXX/builtin-ptrtomember-ambig.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/builtin-ptrtomember-ambig.cpp?rev=84289&r1=84288&r2=84289&view=diff

==============================================================================
--- cfe/trunk/test/SemaCXX/builtin-ptrtomember-ambig.cpp (original)
+++ cfe/trunk/test/SemaCXX/builtin-ptrtomember-ambig.cpp Fri Oct 16 18:25:02 2009
@@ -19,9 +19,9 @@
 void foo(C c, int A::* pmf) {
        				// FIXME. Why so many built-in candidates?
 	int i = c->*pmf; 	// expected-error {{use of overloaded operator '->*' is ambiguous}} \
-				// expected-note {{built-in candidate operator ->* ('struct A const *', 'int const struct A::*')}} \
-				// expected-note {{built-in candidate operator ->* ('struct A const *', 'int struct A::*')}} \
-				// expected-note {{built-in candidate operator ->* ('struct A *', 'int const struct A::*')}} \
-				// expected-note {{built-in candidate operator ->* ('struct A *', 'int struct A::*')}}
+				// expected-note {{built-in candidate operator->*(struct A const *, int const struct A::*)}} \
+				// expected-note {{built-in candidate operator->*(struct A const *, int struct A::*)}} \
+				// expected-note {{built-in candidate operator->*(struct A *, int const struct A::*)}} \
+				// expected-note {{built-in candidate operator->*(struct A *, int struct A::*)}}
 }
 





More information about the cfe-commits mailing list