[cfe-commits] r80165 - in /cfe/trunk/lib/Sema: Sema.cpp Sema.h SemaType.cpp

Anders Carlsson andersca at mac.com
Wed Aug 26 15:33:56 PDT 2009


Author: andersca
Date: Wed Aug 26 17:33:56 2009
New Revision: 80165

URL: http://llvm.org/viewvc/llvm-project?rev=80165&view=rev
Log:
Add a RequireCompleteType variant that takes a PartialDiagnostic. The old RequireCompleteType now creates a PartialDiagnostic and calls the new function.

Modified:
    cfe/trunk/lib/Sema/Sema.cpp
    cfe/trunk/lib/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaType.cpp

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

==============================================================================
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Wed Aug 26 17:33:56 2009
@@ -19,6 +19,7 @@
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/Expr.h"
 #include "clang/Lex/Preprocessor.h"
+#include "clang/Basic/PartialDiagnostic.h"
 #include "clang/Basic/TargetInfo.h"
 using namespace clang;
 
@@ -362,6 +363,15 @@
   }
 }
 
+Sema::SemaDiagnosticBuilder
+Sema::Diag(SourceLocation Loc, const PartialDiagnostic& PD) {
+  SemaDiagnosticBuilder Builder(Diag(Loc, PD.getDiagID()));
+  PD.Emit(Builder);
+  
+  return Builder;
+}
+
 void Sema::ActOnComment(SourceRange Comment) {
   Context.Comments.push_back(Comment);
 }
+

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

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Wed Aug 26 17:33:56 2009
@@ -401,6 +401,9 @@
     return SemaDiagnosticBuilder(DB, *this, DiagID);
   }
 
+  /// \brief Emit a partial diagnostic.
+  SemaDiagnosticBuilder Diag(SourceLocation Loc, const PartialDiagnostic& PD);
+
   virtual void DeleteExpr(ExprTy *E);
   virtual void DeleteStmt(StmtTy *S);
 
@@ -484,7 +487,9 @@
                               SourceRange Range1 = SourceRange(),
                               SourceRange Range2 = SourceRange(),
                               QualType PrintType = QualType());
-
+  bool RequireCompleteType(SourceLocation Loc, QualType T,
+                           const PartialDiagnostic &PD);
+  
   QualType getQualifiedNameType(const CXXScopeSpec &SS, QualType T);
 
   QualType BuildTypeofExprType(Expr *E);

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Wed Aug 26 17:33:56 2009
@@ -18,6 +18,7 @@
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/TypeLoc.h"
 #include "clang/AST/Expr.h"
+#include "clang/Basic/PartialDiagnostic.h"
 #include "clang/Parse/DeclSpec.h"
 #include "llvm/ADT/SmallPtrSet.h"
 using namespace clang;
@@ -1772,6 +1773,18 @@
 bool Sema::RequireCompleteType(SourceLocation Loc, QualType T, unsigned diag,
                                SourceRange Range1, SourceRange Range2,
                                QualType PrintType) {
+  if (!PrintType.isNull())
+    return RequireCompleteType(Loc, T, 
+                               PDiag(diag) << Range1 << Range2 << PrintType);
+  
+  return RequireCompleteType(Loc, T, 
+                             PDiag(diag) << Range1 << Range2);
+}
+
+bool Sema::RequireCompleteType(SourceLocation Loc, QualType T,
+                               const PartialDiagnostic &PD) {
+  unsigned diag = PD.getDiagID();
+  
   // FIXME: Add this assertion to help us flush out problems with
   // checking for dependent types and type-dependent expressions.
   //
@@ -1816,11 +1829,8 @@
   if (diag == 0)
     return true;
   
-  if (PrintType.isNull())
-    PrintType = T;
-
   // We have an incomplete type. Produce a diagnostic.
-  Diag(Loc, diag) << PrintType << Range1 << Range2;
+  Diag(Loc, PD) << T;
 
   // If the type was a forward declaration of a class/struct/union
   // type, produce 





More information about the cfe-commits mailing list