]> granicus.if.org Git - clang/commitdiff
New RequireNonAbstractType function.
authorAnders Carlsson <andersca@mac.com>
Thu, 27 Aug 2009 00:13:57 +0000 (00:13 +0000)
committerAnders Carlsson <andersca@mac.com>
Thu, 27 Aug 2009 00:13:57 +0000 (00:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80183 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.td
include/clang/Basic/PartialDiagnostic.h
lib/Sema/Sema.h
lib/Sema/SemaDeclCXX.cpp

index 670a0d048a6c4fb84f1724c8c5d49ef025a12806..b76b75ea46d62ff46a20cf2525c91dc1260bd018 100644 (file)
@@ -315,7 +315,7 @@ def err_introducing_special_friend : Error<
   "destructor|conversion operator}0 as a friend">;
 
 def err_abstract_type_in_decl : Error<
-  "%select{return|parameter|variable|field}1 type %0 is an abstract class">;
+  "%select{return|parameter|variable|field}0 type %1 is an abstract class">;
 def err_allocation_of_abstract_type : Error<
   "allocation of an object of abstract type %0">;
   
index 6a6e6128ff807a21e520638e0ba187b530116055..b4ba793e7ee18404df4d1706c636c71d4208a5a2 100644 (file)
@@ -115,18 +115,23 @@ public:
   }
   
   friend const PartialDiagnostic &operator<<(const PartialDiagnostic &PD,
-                                                    QualType T) {
+                                             QualType T) {
     PD.AddTaggedVal(reinterpret_cast<intptr_t>(T.getAsOpaquePtr()),
                     Diagnostic::ak_qualtype);
     return PD;
   }
 
+  friend const PartialDiagnostic &operator<<(const PartialDiagnostic &PD,
+                                             unsigned I) {
+    PD.AddTaggedVal(I, Diagnostic::ak_uint);
+    return PD;
+  }
+  
   friend inline const PartialDiagnostic &operator<<(const PartialDiagnostic &PD,
                                                     const SourceRange &R) {
     PD.AddSourceRange(R);
     return PD;
   }
-  
 };
 
 inline PartialDiagnostic PDiag(unsigned DiagID) {
index 16913c5869152cc056950e75310272ae5c7c0475..52aa1a010b0159a23e0c0a8b288ae970546ece98 100644 (file)
@@ -2211,6 +2211,10 @@ public:
     AbstractFieldType
   };
   
+  bool RequireNonAbstractType(SourceLocation Loc, QualType T,
+                              const PartialDiagnostic &PD,
+                              const CXXRecordDecl *CurrentRD = 0);
+  
   bool RequireNonAbstractType(SourceLocation Loc, QualType T, unsigned DiagID, 
                               AbstractDiagSelID SelID = AbstractNone,
                               const CXXRecordDecl *CurrentRD = 0);
index 4cd4300bcd67531aa9f1aa95ceedf426bb852f86..e93624af15441e265df22d314cf6b872ff684447 100644 (file)
@@ -1149,15 +1149,26 @@ namespace {
   }
 }
 
+
 bool Sema::RequireNonAbstractType(SourceLocation Loc, QualType T, 
                                   unsigned DiagID, AbstractDiagSelID SelID,
                                   const CXXRecordDecl *CurrentRD) {
+  if (SelID == -1)
+    return RequireNonAbstractType(Loc, T,
+                                  PDiag(DiagID), CurrentRD);
+  else
+    return RequireNonAbstractType(Loc, T,
+                                  PDiag(DiagID) << SelID, CurrentRD);
+}  
   
+bool Sema::RequireNonAbstractType(SourceLocation Loc, QualType T,
+                                  const PartialDiagnostic &PD,
+                                  const CXXRecordDecl *CurrentRD) {
   if (!getLangOptions().CPlusPlus)
     return false;
   
   if (const ArrayType *AT = Context.getAsArrayType(T))
-    return RequireNonAbstractType(Loc, AT->getElementType(), DiagID, SelID,
+    return RequireNonAbstractType(Loc, AT->getElementType(), PD,
                                   CurrentRD);
   
   if (const PointerType *PT = T->getAs<PointerType>()) {
@@ -1166,8 +1177,7 @@ bool Sema::RequireNonAbstractType(SourceLocation Loc, QualType T,
       PT = T;
     
     if (const ArrayType *AT = Context.getAsArrayType(PT->getPointeeType()))
-      return RequireNonAbstractType(Loc, AT->getElementType(), DiagID, SelID,
-                                    CurrentRD);
+      return RequireNonAbstractType(Loc, AT->getElementType(), PD, CurrentRD);
   }
   
   const RecordType *RT = T->getAs<RecordType>();
@@ -1184,7 +1194,7 @@ bool Sema::RequireNonAbstractType(SourceLocation Loc, QualType T,
   if (!RD->isAbstract())
     return false;
   
-  Diag(Loc, DiagID) << RD->getDeclName() << SelID;
+  Diag(Loc, PD) << RD->getDeclName();
   
   // Check if we've already emitted the list of pure virtual functions for this
   // class.