[cfe-commits] r84105 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/Sema.h lib/Sema/SemaExceptionSpec.cpp

Sebastian Redl sebastian.redl at getdesigned.at
Wed Oct 14 09:09:30 PDT 2009


Author: cornedbee
Date: Wed Oct 14 11:09:29 2009
New Revision: 84105

URL: http://llvm.org/viewvc/llvm-project?rev=84105&view=rev
Log:
Have the exception specification checkers take partial diagnostics. Use this to merge two diagnostics.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaExceptionSpec.cpp

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

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Oct 14 11:09:29 2009
@@ -365,10 +365,8 @@
   "base version">;
 def err_incompatible_exception_specs : Error<
   "target exception specification is not superset of source">;
-def err_return_type_specs_differ : Error<
-  "exception specifications of return types differ">;
-def err_arg_type_specs_differ : Error<
-  "exception specifications of argument types differ">;
+def err_deep_exception_specs_differ : Error<
+  "exception specifications of %select{return|argument}0 types differ">;
 
 // C++ access checking
 def err_class_redeclared_with_different_access : Error<

Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=84105&r1=84104&r2=84105&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Wed Oct 14 11:09:29 2009
@@ -482,13 +482,15 @@
   bool CheckEquivalentExceptionSpec(
       const FunctionProtoType *Old, SourceLocation OldLoc,
       const FunctionProtoType *New, SourceLocation NewLoc);
-  bool CheckEquivalentExceptionSpec(unsigned DiagID, unsigned NoteID,
+  bool CheckEquivalentExceptionSpec(
+      const PartialDiagnostic &DiagID, const PartialDiagnostic & NoteID,
       const FunctionProtoType *Old, SourceLocation OldLoc,
       const FunctionProtoType *New, SourceLocation NewLoc);
-  bool CheckExceptionSpecSubset(unsigned DiagID, unsigned NoteID,
+  bool CheckExceptionSpecSubset(
+      const PartialDiagnostic &DiagID, const PartialDiagnostic & NoteID,
       const FunctionProtoType *Superset, SourceLocation SuperLoc,
       const FunctionProtoType *Subset, SourceLocation SubLoc);
-  bool CheckParamExceptionSpec(unsigned NoteID,
+  bool CheckParamExceptionSpec(const PartialDiagnostic & NoteID,
       const FunctionProtoType *Target, SourceLocation TargetLoc,
       const FunctionProtoType *Source, SourceLocation SourceLoc);
 

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaExceptionSpec.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExceptionSpec.cpp Wed Oct 14 11:09:29 2009
@@ -100,7 +100,7 @@
 /// they allow exactly the same set of exception types. It does not matter how
 /// that is achieved. See C++ [except.spec]p2.
 bool Sema::CheckEquivalentExceptionSpec(
-    unsigned DiagID, unsigned NoteID,
+    const PartialDiagnostic &DiagID, const PartialDiagnostic & NoteID,
     const FunctionProtoType *Old, SourceLocation OldLoc,
     const FunctionProtoType *New, SourceLocation NewLoc) {
   bool OldAny = !Old->hasExceptionSpec() || Old->hasAnyExceptionSpec();
@@ -109,7 +109,7 @@
     return false;
   if (OldAny || NewAny) {
     Diag(NewLoc, DiagID);
-    if (NoteID != 0)
+    if (NoteID.getDiagID() != 0)
       Diag(OldLoc, NoteID);
     return true;
   }
@@ -137,7 +137,7 @@
     return false;
   }
   Diag(NewLoc, DiagID);
-  if (NoteID != 0)
+  if (NoteID.getDiagID() != 0)
     Diag(OldLoc, NoteID);
   return true;
 }
@@ -145,7 +145,8 @@
 /// CheckExceptionSpecSubset - Check whether the second function type's
 /// exception specification is a subset (or equivalent) of the first function
 /// type. This is used by override and pointer assignment checks.
-bool Sema::CheckExceptionSpecSubset(unsigned DiagID, unsigned NoteID,
+bool Sema::CheckExceptionSpecSubset(
+    const PartialDiagnostic &DiagID, const PartialDiagnostic & NoteID,
     const FunctionProtoType *Superset, SourceLocation SuperLoc,
     const FunctionProtoType *Subset, SourceLocation SubLoc) {
   // FIXME: As usual, we could be more specific in our error messages, but
@@ -161,7 +162,7 @@
   // It does not. If the subset contains everything, we've failed.
   if (!Subset->hasExceptionSpec() || Subset->hasAnyExceptionSpec()) {
     Diag(SubLoc, DiagID);
-    if (NoteID != 0)
+    if (NoteID.getDiagID() != 0)
       Diag(SuperLoc, NoteID);
     return true;
   }
@@ -230,7 +231,7 @@
     }
     if (!Contained) {
       Diag(SubLoc, DiagID);
-      if (NoteID != 0)
+      if (NoteID.getDiagID() != 0)
         Diag(SuperLoc, NoteID);
       return true;
     }
@@ -240,7 +241,7 @@
 }
 
 static bool CheckSpecForTypesEquivalent(Sema &S,
-    unsigned DiagID, unsigned NoteID,
+    const PartialDiagnostic &DiagID, const PartialDiagnostic & NoteID,
     QualType Target, SourceLocation TargetLoc,
     QualType Source, SourceLocation SourceLoc)
 {
@@ -260,21 +261,23 @@
 /// assignment and override compatibility check. We do not check the parameters
 /// of parameter function pointers recursively, as no sane programmer would
 /// even be able to write such a function type.
-bool Sema::CheckParamExceptionSpec(unsigned NoteID,
+bool Sema::CheckParamExceptionSpec(const PartialDiagnostic & NoteID,
     const FunctionProtoType *Target, SourceLocation TargetLoc,
     const FunctionProtoType *Source, SourceLocation SourceLoc)
 {
-  if (CheckSpecForTypesEquivalent(*this, diag::err_return_type_specs_differ, 0,
+  if (CheckSpecForTypesEquivalent(*this,
+                           PDiag(diag::err_deep_exception_specs_differ) << 0, 0,
                                   Target->getResultType(), TargetLoc,
                                   Source->getResultType(), SourceLoc))
     return true;
 
-  // We shouldn't even testing this unless the arguments are otherwise
+  // We shouldn't even be testing this unless the arguments are otherwise
   // compatible.
   assert(Target->getNumArgs() == Source->getNumArgs() &&
          "Functions have different argument counts.");
   for (unsigned i = 0, E = Target->getNumArgs(); i != E; ++i) {
-    if (CheckSpecForTypesEquivalent(*this, diag::err_arg_type_specs_differ, 0,
+    if (CheckSpecForTypesEquivalent(*this,
+                           PDiag(diag::err_deep_exception_specs_differ) << 1, 0,
                                     Target->getArgType(i), TargetLoc,
                                     Source->getArgType(i), SourceLoc))
       return true;





More information about the cfe-commits mailing list