Get rid of isObjectType; when C++ says "object type", it generally

just means "not a function type", not "not a function type or void". This
changes behavior slightly, but generally in a way which accepts more code.

llvm-svn: 110303
This commit is contained in:
Eli Friedman 2010-08-05 02:49:48 +00:00
parent fc21c3aa32
commit a170cd6257
7 changed files with 10 additions and 25 deletions

View File

@ -823,14 +823,6 @@ public:
/// Types are partitioned into 3 broad categories (C99 6.2.5p1):
/// object types, function types, and incomplete types.
/// \brief Determines whether the type describes an object in memory.
///
/// Note that this definition of object type corresponds to the C++
/// definition of object type, which includes incomplete types, as
/// opposed to the C definition (which does not include incomplete
/// types).
bool isObjectType() const;
/// isIncompleteType - Return true if this is an incomplete type.
/// A type that can describe objects, but which lacks information needed to
/// determine its size (e.g. void, or a fwd declared struct). Clients of this

View File

@ -1106,7 +1106,7 @@ bool IntExprEvaluator::TryEvaluateBuiltinObjectSize(CallExpr *E) {
QualType T = GetObjectType(LVBase);
if (T.isNull() ||
T->isIncompleteType() ||
!T->isObjectType() ||
T->isFunctionType() ||
T->isVariablyModifiedType() ||
T->isDependentType())
return false;

View File

@ -166,13 +166,6 @@ bool Type::isVoidType() const {
return false;
}
bool Type::isObjectType() const {
if (isa<FunctionType>(CanonicalType) || isa<ReferenceType>(CanonicalType) ||
isVoidType())
return false;
return true;
}
bool Type::isDerivedType() const {
switch (CanonicalType->getTypeClass()) {
case Pointer:

View File

@ -1397,7 +1397,7 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal,
QualType ConvType = Conv->getConversionType().getNonReferenceType();
if (const PointerType *ConvPtrType = ConvType->getAs<PointerType>())
if (ConvPtrType->getPointeeType()->isObjectType())
if (ConvPtrType->getPointeeType()->isIncompleteOrObjectType())
ObjectPtrConversions.push_back(Conv);
}
if (ObjectPtrConversions.size() == 1) {

View File

@ -1400,7 +1400,8 @@ bool Sema::IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
// An rvalue of type "pointer to cv T," where T is an object type,
// can be converted to an rvalue of type "pointer to cv void" (C++
// 4.10p2).
if (FromPointeeType->isObjectType() && ToPointeeType->isVoidType()) {
if (FromPointeeType->isIncompleteOrObjectType() &&
ToPointeeType->isVoidType()) {
ConvertedType = BuildSimilarlyQualifiedPointerType(FromTypePtr,
ToPointeeType,
ToType, Context);
@ -4481,7 +4482,7 @@ Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
for (BuiltinCandidateTypeSet::iterator Ptr = CandidateTypes.pointer_begin();
Ptr != CandidateTypes.pointer_end(); ++Ptr) {
// Skip pointer types that aren't pointers to object types.
if (!(*Ptr)->getAs<PointerType>()->getPointeeType()->isObjectType())
if (!(*Ptr)->getPointeeType()->isIncompleteOrObjectType())
continue;
QualType ParamTypes[2] = {

View File

@ -542,9 +542,7 @@ Sema::CheckNonTypeTemplateParameterType(QualType T, SourceLocation Loc) {
// -- integral or enumeration type,
if (T->isIntegralOrEnumerationType() ||
// -- pointer to object or pointer to function,
(T->isPointerType() &&
(T->getAs<PointerType>()->getPointeeType()->isObjectType() ||
T->getAs<PointerType>()->getPointeeType()->isFunctionType())) ||
T->isPointerType() ||
// -- reference to object or reference to function,
T->isReferenceType() ||
// -- pointer to member.
@ -2923,7 +2921,7 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
// object, qualification conversions (4.4) and the
// array-to-pointer conversion (4.2) are applied.
// C++0x also allows a value of std::nullptr_t.
assert(ParamType->getAs<PointerType>()->getPointeeType()->isObjectType() &&
assert(ParamType->getPointeeType()->isIncompleteOrObjectType() &&
"Only object pointers allowed here");
return CheckTemplateArgumentAddressOfObjectOrFunction(*this, Param,
@ -2938,7 +2936,7 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
// identical) type of the template-argument. The
// template-parameter is bound directly to the
// template-argument, which must be an lvalue.
assert(ParamRefType->getPointeeType()->isObjectType() &&
assert(ParamRefType->getPointeeType()->isIncompleteOrObjectType() &&
"Only object references allowed here");
if (Arg->getType() == Context.OverloadTy) {

View File

@ -17,4 +17,5 @@ template<typename T, T x> struct A10;
template<float f> struct A11; // expected-error{{a non-type template parameter cannot have type 'float'}}
template<void *Ptr> struct A12; // expected-error{{a non-type template parameter cannot have type 'void *'}}
template<void *Ptr> struct A12;
template<int (*IncompleteArrayPtr)[]> struct A13;