зеркало из https://github.com/microsoft/clang-1.git
Bye-bye old RequireCompleteType.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80182 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
63bb7c2b28
Коммит
b790661a15
|
@ -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);
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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>()) {
|
||||
|
|
|
@ -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();
|
||||
|
|
Загрузка…
Ссылка в новой задаче