diff options
author | Anders Carlsson <andersca@mac.com> | 2009-08-26 23:45:07 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-08-26 23:45:07 +0000 |
commit | b790661a15d93941d2c33a0ea328254277b3d7e3 (patch) | |
tree | 3d517a27cfc2311423829859a4e43449fcf5a1eb | |
parent | 63bb7c2b281c62a30233b1638ecd8fb4048a38c4 (diff) |
Bye-bye old RequireCompleteType.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80182 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/Sema.h | 2 | ||||
-rw-r--r-- | lib/Sema/SemaCXXCast.cpp | 9 | ||||
-rw-r--r-- | lib/Sema/SemaCXXScopeSpec.cpp | 5 | ||||
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 3 | ||||
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 6 | ||||
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 34 | ||||
-rw-r--r-- | lib/Sema/SemaExprCXX.cpp | 11 | ||||
-rw-r--r-- | lib/Sema/SemaOverload.cpp | 6 | ||||
-rw-r--r-- | lib/Sema/SemaType.cpp | 24 |
9 files changed, 44 insertions, 56 deletions
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h index 924a861012..16913c5869 100644 --- a/lib/Sema/Sema.h +++ b/lib/Sema/Sema.h @@ -483,8 +483,6 @@ public: virtual TypeResult ActOnTypeName(Scope *S, Declarator &D); - bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned diag, - SourceRange Range1 = SourceRange()); bool RequireCompleteType(SourceLocation Loc, QualType T, const PartialDiagnostic &PD); diff --git a/lib/Sema/SemaCXXCast.cpp b/lib/Sema/SemaCXXCast.cpp index 66767ad1ba..17fe940136 100644 --- a/lib/Sema/SemaCXXCast.cpp +++ b/lib/Sema/SemaCXXCast.cpp @@ -15,6 +15,7 @@ #include "SemaInherit.h" #include "clang/AST/ExprCXX.h" #include "clang/AST/ASTContext.h" +#include "clang/Basic/PartialDiagnostic.h" #include "llvm/ADT/SmallVector.h" #include <set> using namespace clang; @@ -227,8 +228,8 @@ CheckDynamicCast(Sema &Self, Expr *&SrcExpr, QualType DestType, assert(DestPointer && "Reference to void is not possible"); } else if (DestRecord) { if (Self.RequireCompleteType(OpRange.getBegin(), DestPointee, - diag::err_bad_dynamic_cast_incomplete, - DestRange)) + PDiag(diag::err_bad_dynamic_cast_incomplete) + << DestRange)) return; } else { Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_not_class) @@ -265,8 +266,8 @@ CheckDynamicCast(Sema &Self, Expr *&SrcExpr, QualType DestType, const RecordType *SrcRecord = SrcPointee->getAs<RecordType>(); if (SrcRecord) { if (Self.RequireCompleteType(OpRange.getBegin(), SrcPointee, - diag::err_bad_dynamic_cast_incomplete, - SrcExpr->getSourceRange())) + PDiag(diag::err_bad_dynamic_cast_incomplete) + << SrcExpr->getSourceRange())) return; } else { Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_not_class) diff --git a/lib/Sema/SemaCXXScopeSpec.cpp b/lib/Sema/SemaCXXScopeSpec.cpp index 3dac5d7297..2d89cfa072 100644 --- a/lib/Sema/SemaCXXScopeSpec.cpp +++ b/lib/Sema/SemaCXXScopeSpec.cpp @@ -16,6 +16,7 @@ #include "clang/AST/DeclTemplate.h" #include "clang/AST/ExprCXX.h" #include "clang/AST/NestedNameSpecifier.h" +#include "clang/Basic/PartialDiagnostic.h" #include "clang/Parse/DeclSpec.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/raw_ostream.h" @@ -229,8 +230,8 @@ bool Sema::RequireCompleteDeclContext(const CXXScopeSpec &SS) { // The type must be complete. return RequireCompleteType(SS.getRange().getBegin(), Context.getTypeDeclType(Tag), - diag::err_incomplete_nested_name_spec, - SS.getRange()); + PDiag(diag::err_incomplete_nested_name_spec) + << SS.getRange()); } return false; diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index c0e4921f69..5f834dc500 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -23,8 +23,9 @@ #include "clang/AST/StmtCXX.h" #include "clang/AST/StmtObjC.h" #include "clang/Parse/DeclSpec.h" -#include "clang/Basic/TargetInfo.h" +#include "clang/Basic/PartialDiagnostic.h" #include "clang/Basic/SourceManager.h" +#include "clang/Basic/TargetInfo.h" // FIXME: layering (ideally, Sema shouldn't be dependent on Lex API's) #include "clang/Lex/Preprocessor.h" #include "clang/Lex/HeaderSearch.h" diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 41a7fe653d..4cd4300bcd 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -18,6 +18,7 @@ #include "clang/AST/DeclVisitor.h" #include "clang/AST/TypeOrdering.h" #include "clang/AST/StmtVisitor.h" +#include "clang/Basic/PartialDiagnostic.h" #include "clang/Lex/Preprocessor.h" #include "clang/Parse/DeclSpec.h" #include "llvm/ADT/STLExtras.h" @@ -390,8 +391,9 @@ Sema::CheckBaseSpecifier(CXXRecordDecl *Class, // C++ [class.derived]p2: // The class-name in a base-specifier shall not be an incompletely // defined class. - if (RequireCompleteType(BaseLoc, BaseType, diag::err_incomplete_base_class, - SpecifierRange)) + if (RequireCompleteType(BaseLoc, BaseType, + PDiag(diag::err_incomplete_base_class) + << SpecifierRange)) return 0; // If the base class is polymorphic or isn't empty, the new one is/isn't, too. diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index ef924fee42..44c5a3a1b7 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -1347,8 +1347,8 @@ bool Sema::CheckSizeOfAlignOfOperand(QualType exprType, if (RequireCompleteType(OpLoc, exprType, isSizeof ? diag::err_sizeof_incomplete_type : - diag::err_alignof_incomplete_type, - ExprRange)) + PDiag(diag::err_alignof_incomplete_type) + << ExprRange)) return true; // Reject sizeof(interface) and sizeof(interface<proto>) in 64-bit mode. @@ -1799,8 +1799,9 @@ Sema::ActOnArraySubscriptExpr(Scope *S, ExprArg Base, SourceLocation LLoc, } if (!ResultType->isDependentType() && - RequireCompleteType(LLoc, ResultType, diag::err_subscript_incomplete_type, - BaseExpr->getSourceRange())) + RequireCompleteType(LLoc, ResultType, + PDiag(diag::err_subscript_incomplete_type) + << BaseExpr->getSourceRange())) return ExprError(); // Diagnose bad cases where we step over interface counts. @@ -2047,8 +2048,8 @@ Sema::BuildMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc, if (const RecordType *RTy = BaseType->getAs<RecordType>()) { RecordDecl *RDecl = RTy->getDecl(); if (RequireCompleteType(OpLoc, BaseType, - diag::err_typecheck_incomplete_tag, - BaseExpr->getSourceRange())) + PDiag(diag::err_typecheck_incomplete_tag) + << BaseExpr->getSourceRange())) return ExprError(); DeclContext *DC = RDecl; @@ -2564,8 +2565,8 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, if (RequireCompleteType(Arg->getSourceRange().getBegin(), ProtoArgType, - diag::err_call_incomplete_argument, - Arg->getSourceRange())) + PDiag(diag::err_call_incomplete_argument) + << Arg->getSourceRange())) return true; // Pass the argument. @@ -2801,8 +2802,8 @@ Sema::ActOnCallExpr(Scope *S, ExprArg fn, SourceLocation LParenLoc, if (!FuncT->getResultType()->isVoidType() && RequireCompleteType(Fn->getSourceRange().getBegin(), FuncT->getResultType(), - diag::err_call_incomplete_return, - TheCall->getSourceRange())) + PDiag(diag::err_call_incomplete_return) + << TheCall->getSourceRange())) return ExprError(); // We know the result type of the call, set it. @@ -2835,8 +2836,8 @@ Sema::ActOnCallExpr(Scope *S, ExprArg fn, SourceLocation LParenLoc, DefaultArgumentPromotion(Arg); if (RequireCompleteType(Arg->getSourceRange().getBegin(), Arg->getType(), - diag::err_call_incomplete_argument, - Arg->getSourceRange())) + PDiag(diag::err_call_incomplete_argument) + << Arg->getSourceRange())) return ExprError(); TheCall->setArg(i, Arg); } @@ -2882,8 +2883,9 @@ Sema::ActOnCompoundLiteral(SourceLocation LParenLoc, TypeTy *Ty, << SourceRange(LParenLoc, literalExpr->getSourceRange().getEnd())); } else if (!literalType->isDependentType() && RequireCompleteType(LParenLoc, literalType, - diag::err_typecheck_decl_incomplete_type, - SourceRange(LParenLoc, literalExpr->getSourceRange().getEnd()))) + PDiag(diag::err_typecheck_decl_incomplete_type) + << SourceRange(LParenLoc, + literalExpr->getSourceRange().getEnd()))) return ExprError(); if (CheckInitializerTypes(literalExpr, literalType, LParenLoc, @@ -4626,8 +4628,8 @@ static bool CheckForModifiableLvalue(Expr *E, SourceLocation Loc, Sema &S) { case Expr::MLV_IncompleteType: case Expr::MLV_IncompleteVoidType: return S.RequireCompleteType(Loc, E->getType(), - diag::err_typecheck_incomplete_type_not_modifiable_lvalue, - E->getSourceRange()); + PDiag(diag::err_typecheck_incomplete_type_not_modifiable_lvalue) + << E->getSourceRange()); case Expr::MLV_DuplicateVectorComponents: Diag = diag::err_typecheck_duplicate_vector_components_not_mlvalue; break; diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index a8eb2cbc7e..22d01ec0c8 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -272,7 +272,8 @@ Sema::ActOnCXXTypeConstructExpr(SourceRange TypeRange, TypeTy *TypeRep, diag::err_value_init_for_array_type) << FullRange); if (!Ty->isDependentType() && !Ty->isVoidType() && RequireCompleteType(TyBeginLoc, Ty, - diag::err_invalid_incomplete_type_use, FullRange)) + PDiag(diag::err_invalid_incomplete_type_use) + << FullRange)) return ExprError(); if (RequireNonAbstractType(TyBeginLoc, Ty, @@ -486,8 +487,8 @@ bool Sema::CheckAllocatedType(QualType AllocType, SourceLocation Loc, << AllocType << 1 << R; else if (!AllocType->isDependentType() && RequireCompleteType(Loc, AllocType, - diag::err_new_incomplete_type, - R)) + PDiag(diag::err_new_incomplete_type) + << R)) return true; else if (RequireNonAbstractType(Loc, AllocType, diag::err_allocation_of_abstract_type)) @@ -727,8 +728,8 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, << Type << Ex->getSourceRange()); else if (!Pointee->isDependentType() && RequireCompleteType(StartLoc, Pointee, - diag::warn_delete_incomplete, - Ex->getSourceRange())) + PDiag(diag::warn_delete_incomplete) + << Ex->getSourceRange())) return ExprError(); // FIXME: This should be shared with the code for finding the delete diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 25af89fd45..dde5c28723 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -19,6 +19,7 @@ #include "clang/AST/Expr.h" #include "clang/AST/ExprCXX.h" #include "clang/AST/TypeOrdering.h" +#include "clang/Basic/PartialDiagnostic.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/Compiler.h" @@ -1392,8 +1393,9 @@ bool Sema::IsUserDefinedConversion(Expr *From, QualType ToType, if (!AllowConversionFunctions) { // Don't allow any conversion functions to enter the overload set. - } else if (RequireCompleteType(From->getLocStart(), From->getType(), 0, - From->getSourceRange())) { + } else if (RequireCompleteType(From->getLocStart(), From->getType(), + PDiag(0) + << From->getSourceRange())) { // No conversion functions from incomplete types. } else if (const RecordType *FromRecordType = From->getType()->getAs<RecordType>()) { diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 9ca38e4ad7..7837952353 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -1751,31 +1751,11 @@ void Sema::ProcessTypeAttributeList(QualType &Result, const AttributeList *AL) { /// /// @param T The type that this routine is examining for completeness. /// -/// @param diag The diagnostic value (e.g., -/// @c diag::err_typecheck_decl_incomplete_type) that will be used -/// for the error message if @p T is incomplete. If 0, no diagnostic will be -/// emitted. -/// -/// @param Range1 An optional range in the source code that will be a -/// part of the "incomplete type" error message. -/// -/// @param Range2 An optional range in the source code that will be a -/// part of the "incomplete type" error message. -/// -/// @param PrintType If non-NULL, the type that should be printed -/// instead of @p T. This parameter should be used when the type that -/// we're checking for incompleteness isn't the type that should be -/// displayed to the user, e.g., when T is a type and PrintType is a -/// pointer to T. +/// @param PD The partial diagnostic that will be printed out if T is not a +/// complete type. /// /// @returns @c true if @p T is incomplete and a diagnostic was emitted, /// @c false otherwise. -bool Sema::RequireCompleteType(SourceLocation Loc, QualType T, unsigned diag, - SourceRange Range1) { - return RequireCompleteType(Loc, T, - PDiag(diag) << Range1); -} - bool Sema::RequireCompleteType(SourceLocation Loc, QualType T, const PartialDiagnostic &PD) { unsigned diag = PD.getDiagID(); |