From: Eli Friedman Date: Thu, 5 Aug 2010 02:49:48 +0000 (+0000) Subject: Get rid of isObjectType; when C++ says "object type", it generally X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1357869bc5983cdfbc986db1f3d18265bb34cb0e;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110303 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index f1e7dfe3e9..1b8412488f 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -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 diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index b74b327c9c..30234f5a78 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -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; diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index 8ae138a2ac..31af6fb661 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -166,13 +166,6 @@ bool Type::isVoidType() const { return false; } -bool Type::isObjectType() const { - if (isa(CanonicalType) || isa(CanonicalType) || - isVoidType()) - return false; - return true; -} - bool Type::isDerivedType() const { switch (CanonicalType->getTypeClass()) { case Pointer: diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 6d28dbdc12..1e5735d6f8 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -1397,7 +1397,7 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, QualType ConvType = Conv->getConversionType().getNonReferenceType(); if (const PointerType *ConvPtrType = ConvType->getAs()) - if (ConvPtrType->getPointeeType()->isObjectType()) + if (ConvPtrType->getPointeeType()->isIncompleteOrObjectType()) ObjectPtrConversions.push_back(Conv); } if (ObjectPtrConversions.size() == 1) { diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 1a22e2876b..14761b6e50 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -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()->getPointeeType()->isObjectType()) + if (!(*Ptr)->getPointeeType()->isIncompleteOrObjectType()) continue; QualType ParamTypes[2] = { diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index d6672df3f4..175ddf639c 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -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()->getPointeeType()->isObjectType() || - T->getAs()->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()->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) { diff --git a/test/CXX/temp/temp.param/p4.cpp b/test/CXX/temp/temp.param/p4.cpp index 5ec402a45b..809fb20b4a 100644 --- a/test/CXX/temp/temp.param/p4.cpp +++ b/test/CXX/temp/temp.param/p4.cpp @@ -17,4 +17,5 @@ template struct A10; template struct A11; // expected-error{{a non-type template parameter cannot have type 'float'}} -template struct A12; // expected-error{{a non-type template parameter cannot have type 'void *'}} +template struct A12; +template struct A13;