[cfe-commits] r66421 - in /cfe/trunk/lib/Sema: Sema.h SemaDecl.cpp SemaDeclCXX.cpp SemaExpr.cpp SemaExprCXX.cpp SemaNamedCast.cpp SemaType.cpp

Douglas Gregor dgregor at apple.com
Mon Mar 9 09:13:41 PDT 2009


Author: dgregor
Date: Mon Mar  9 11:13:40 2009
New Revision: 66421

URL: http://llvm.org/viewvc/llvm-project?rev=66421&view=rev
Log:
Rename DiagnoseIncompleteType to RequireCompleteType, and update the documentation to reflect the fact that we can instantiate templates here

Modified:
    cfe/trunk/lib/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/lib/Sema/SemaExprCXX.cpp
    cfe/trunk/lib/Sema/SemaNamedCast.cpp
    cfe/trunk/lib/Sema/SemaType.cpp

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

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Mon Mar  9 11:13:40 2009
@@ -283,7 +283,7 @@
 
   virtual TypeResult ActOnTypeName(Scope *S, Declarator &D);
 
-  bool DiagnoseIncompleteType(SourceLocation Loc, QualType T, unsigned diag,
+  bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned diag,
                               SourceRange Range1 = SourceRange(),
                               SourceRange Range2 = SourceRange(),
                               QualType PrintType = QualType());

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Mar  9 11:13:40 2009
@@ -893,7 +893,7 @@
     // function declarator that is part of a function definition of
     // that function shall not have incomplete type.
     if (!Param->isInvalidDecl() &&
-        DiagnoseIncompleteType(Param->getLocation(), Param->getType(),
+        RequireCompleteType(Param->getLocation(), Param->getType(),
                                diag::err_typecheck_decl_incomplete_type)) {
       Param->setInvalidDecl();
       HasInvalidParm = true;
@@ -2255,7 +2255,7 @@
           Var->getStorageClass() != VarDecl::PrivateExtern &&
           InitType->isRecordType()) {
         const CXXConstructorDecl *Constructor = 0;
-        if (!DiagnoseIncompleteType(Var->getLocation(), InitType, 
+        if (!RequireCompleteType(Var->getLocation(), InitType, 
                                     diag::err_invalid_incomplete_type_use))
           Constructor
             = PerformInitializationByConstructor(InitType, 0, 0, 
@@ -2333,7 +2333,7 @@
     if (IDecl->isBlockVarDecl() && 
         IDecl->getStorageClass() != VarDecl::Extern) {
       if (!IDecl->isInvalidDecl() &&
-          DiagnoseIncompleteType(IDecl->getLocation(), T, 
+          RequireCompleteType(IDecl->getLocation(), T, 
                                  diag::err_typecheck_decl_incomplete_type))
         IDecl->setInvalidDecl();
     }
@@ -2347,7 +2347,7 @@
         // C99 6.9.2 (p2, p5): Implicit initialization causes an incomplete
         // array to be completed. Don't issue a diagnostic.
       } else if (!IDecl->isInvalidDecl() &&
-                 DiagnoseIncompleteType(IDecl->getLocation(), T,
+                 RequireCompleteType(IDecl->getLocation(), T,
                                         diag::err_typecheck_decl_incomplete_type))
         // C99 6.9.2p3: If the declaration of an identifier for an object is
         // a tentative definition and has internal linkage (C99 6.2.2p3), the  
@@ -3488,7 +3488,7 @@
     // C99 6.7.2.1p2 - A field may not be an incomplete type except...
     if (FDTy->isIncompleteType()) {
       if (!Record) {  // Incomplete ivar type is always an error.
-        DiagnoseIncompleteType(FD->getLocation(), FD->getType(), 
+        RequireCompleteType(FD->getLocation(), FD->getType(), 
                                diag::err_field_incomplete);
         FD->setInvalidDecl();
         EnclosingDecl->setInvalidDecl();
@@ -3497,7 +3497,7 @@
       if (i != NumFields-1 ||                   // ... that the last member ...
           !Record->isStruct() ||  // ... of a structure ...
           !FDTy->isArrayType()) {         //... may have incomplete array type.
-        DiagnoseIncompleteType(FD->getLocation(), FD->getType(), 
+        RequireCompleteType(FD->getLocation(), FD->getType(), 
                                diag::err_field_incomplete);
         FD->setInvalidDecl();
         EnclosingDecl->setInvalidDecl();

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Mar  9 11:13:40 2009
@@ -350,7 +350,7 @@
   // C++ [class.derived]p2:
   //   The class-name in a base-specifier shall not be an incompletely
   //   defined class.
-  if (DiagnoseIncompleteType(BaseLoc, BaseType, diag::err_incomplete_base_class,
+  if (RequireCompleteType(BaseLoc, BaseType, diag::err_incomplete_base_class,
                              SpecifierRange))
     return 0;
 
@@ -2270,7 +2270,7 @@
     DK = diag::err_catch_incomplete_ref;
   }
   if ((Mode == 0 || !BaseType->isVoidType()) && 
-      DiagnoseIncompleteType(Begin, BaseType, DK))
+      RequireCompleteType(Begin, BaseType, DK))
     Invalid = true;
 
   // FIXME: Need to test for ability to copy-construct and destroy the

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Mar  9 11:13:40 2009
@@ -1189,7 +1189,7 @@
     return false;
   }
 
-  return DiagnoseIncompleteType(OpLoc, exprType,
+  return RequireCompleteType(OpLoc, exprType,
                                 isSizeof ? diag::err_sizeof_incomplete_type : 
                                            diag::err_alignof_incomplete_type,
                                 ExprRange);
@@ -1703,7 +1703,7 @@
   // of the ObjC 'id' struct.
   if (const RecordType *RTy = BaseType->getAsRecordType()) {
     RecordDecl *RDecl = RTy->getDecl();
-    if (DiagnoseIncompleteType(OpLoc, BaseType,
+    if (RequireCompleteType(OpLoc, BaseType,
                                diag::err_typecheck_incomplete_tag,
                                BaseExpr->getSourceRange()))
       return ExprError();
@@ -2257,7 +2257,7 @@
     if (literalType->isVariableArrayType())
       return ExprError(Diag(LParenLoc, diag::err_variable_object_no_init)
         << SourceRange(LParenLoc, literalExpr->getSourceRange().getEnd()));
-  } else if (DiagnoseIncompleteType(LParenLoc, literalType,
+  } else if (RequireCompleteType(LParenLoc, literalType,
                                     diag::err_typecheck_decl_incomplete_type,
                 SourceRange(LParenLoc, literalExpr->getSourceRange().getEnd())))
     return ExprError();
@@ -3017,7 +3017,7 @@
           Diag(Loc, diag::ext_gnu_ptr_func_arith)
             << lex->getType() << lex->getSourceRange();
         } else {
-          DiagnoseIncompleteType(Loc, PTy->getPointeeType(),
+          RequireCompleteType(Loc, PTy->getPointeeType(),
                                  diag::err_typecheck_arithmetic_incomplete_type,
                                  lex->getSourceRange(), SourceRange(),
                                  lex->getType());
@@ -3436,7 +3436,7 @@
     break;
   case Expr::MLV_IncompleteType:
   case Expr::MLV_IncompleteVoidType:
-    return S.DiagnoseIncompleteType(Loc, E->getType(),
+    return S.RequireCompleteType(Loc, E->getType(),
                       diag::err_typecheck_incomplete_type_not_modifiable_lvalue,
                                     E->getSourceRange());
   case Expr::MLV_DuplicateVectorComponents:
@@ -3577,7 +3577,7 @@
       Diag(OpLoc, diag::ext_gnu_ptr_func_arith)
         << ResType << Op->getSourceRange();
     } else {
-      DiagnoseIncompleteType(OpLoc, PT->getPointeeType(),
+      RequireCompleteType(OpLoc, PT->getPointeeType(),
                              diag::err_typecheck_arithmetic_incomplete_type,
                              Op->getSourceRange(), SourceRange(),
                              ResType);

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Mon Mar  9 11:13:40 2009
@@ -177,7 +177,7 @@
   if (Ty->isArrayType())
     return Diag(TyBeginLoc, diag::err_value_init_for_array_type) << FullRange;
   if (!Ty->isDependentType() && !Ty->isVoidType() &&
-      DiagnoseIncompleteType(TyBeginLoc, Ty, 
+      RequireCompleteType(TyBeginLoc, Ty, 
                              diag::err_invalid_incomplete_type_use, FullRange))
     return true;
 
@@ -595,7 +595,7 @@
 
     QualType Pointee = Type->getAsPointerType()->getPointeeType();
     if (!Pointee->isVoidType() && 
-        DiagnoseIncompleteType(StartLoc, Pointee, diag::warn_delete_incomplete,
+        RequireCompleteType(StartLoc, Pointee, diag::warn_delete_incomplete,
                                Ex->getSourceRange()))
       return true;
     else if (!Pointee->isObjectType()) {

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaNamedCast.cpp (original)
+++ cfe/trunk/lib/Sema/SemaNamedCast.cpp Mon Mar  9 11:13:40 2009
@@ -776,7 +776,7 @@
   if (DestPointee->isVoidType()) {
     assert(DestPointer && "Reference to void is not possible");
   } else if (DestRecord) {
-    if (Self.DiagnoseIncompleteType(OpRange.getBegin(), DestPointee, 
+    if (Self.RequireCompleteType(OpRange.getBegin(), DestPointee, 
                                     diag::err_bad_dynamic_cast_incomplete,
                                     DestRange))
       return;
@@ -810,7 +810,7 @@
 
   const RecordType *SrcRecord = SrcPointee->getAsRecordType();
   if (SrcRecord) {
-    if (Self.DiagnoseIncompleteType(OpRange.getBegin(), SrcPointee,
+    if (Self.RequireCompleteType(OpRange.getBegin(), SrcPointee,
                                     diag::err_bad_dynamic_cast_incomplete,
                                     SrcExpr->getSourceRange()))
       return;

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Mon Mar  9 11:13:40 2009
@@ -395,7 +395,7 @@
                               SourceLocation Loc, DeclarationName Entity) {
   // C99 6.7.5.2p1: If the element type is an incomplete or function type, 
   // reject it (e.g. void ary[7], struct foo ary[7], void ary[7]())
-  if (DiagnoseIncompleteType(Loc, T, 
+  if (RequireCompleteType(Loc, T, 
                              diag::err_illegal_decl_array_incomplete_type))
     return QualType();
 
@@ -992,13 +992,15 @@
   }
 }
 
-/// @brief If the type T is incomplete and cannot be completed,
-/// produce a suitable diagnostic.
+/// @brief Ensure that the type T is a complete type. 
 ///
 /// This routine checks whether the type @p T is complete in any
 /// context where a complete type is required. If @p T is a complete
-/// type, returns false. If @p T is incomplete, issues the diagnostic
-/// @p diag (giving it the type @p T) and returns true.
+/// type, returns false. If @p T is a class template specialization,
+/// this routine then attempts to perform class template
+/// instantiation. If instantiation fails, or if @p T is incomplete
+/// and cannot be completed, issues the diagnostic @p diag (giving it
+/// the type @p T) and returns true.
 ///
 /// @param Loc  The location in the source that the incomplete type
 /// diagnostic should refer to.
@@ -1023,11 +1025,7 @@
 ///
 /// @returns @c true if @p T is incomplete and a diagnostic was emitted,
 /// @c false otherwise.
-///
-/// @todo When Clang gets proper support for C++ templates, this
-/// routine will also be able perform template instantiation when @p T
-/// is a class template specialization.
-bool Sema::DiagnoseIncompleteType(SourceLocation Loc, QualType T, unsigned diag,
+bool Sema::RequireCompleteType(SourceLocation Loc, QualType T, unsigned diag,
                                   SourceRange Range1, SourceRange Range2,
                                   QualType PrintType) {
   // If we have a complete type, we're done.





More information about the cfe-commits mailing list