]> granicus.if.org Git - clang/commitdiff
Add Type::hasPointerRepresentation predicate.
authorDaniel Dunbar <daniel@zuster.org>
Thu, 26 Feb 2009 20:52:22 +0000 (20:52 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Thu, 26 Feb 2009 20:52:22 +0000 (20:52 +0000)
 - For types whose native representation is a pointer.

 - Use to replace ExprConstant.cpp:HasPointerEvalType,
   CodeGenFunction::isObjCPointerType.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65569 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Type.h
lib/AST/ExprConstant.cpp
lib/CodeGen/CGCall.cpp
lib/CodeGen/CodeGenFunction.cpp
lib/CodeGen/CodeGenFunction.h

index f05185b339bf1f42cf9df1ed1a8e9f79c64a8dcd..f5bd5f19f0ffd46d98fe6f14ba22b10e94caa745 100644 (file)
@@ -390,6 +390,12 @@ public:
   bool isDependentType() const { return Dependent; }
   bool isOverloadType() const;                  // C++ overloaded function
 
+  /// hasPointerRepresentation - Whether this type is represented
+  /// natively as a pointer; this includes pointers, references, block
+  /// pointers, and Objective-C interface, qualified id, and qualified
+  /// interface types.
+  bool hasPointerRepresentation() const;
+
   // Type Checking Functions: Check to see if this type is structurally the
   // specified type, ignoring typedefs and qualifiers, and return a pointer to
   // the best type we can.
@@ -1936,6 +1942,12 @@ inline bool Type::isOverloadType() const {
   return isSpecificBuiltinType(BuiltinType::Overload);
 }
 
+inline bool Type::hasPointerRepresentation() const {
+  return (isPointerType() || isReferenceType() || isBlockPointerType() ||
+          isObjCInterfaceType() || isObjCQualifiedIdType() || 
+          isObjCQualifiedInterfaceType());
+}
+
 /// Insertion operator for diagnostics.  This allows sending QualType's into a
 /// diagnostic with <<.
 inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
index 6899b617036387c0ab82f200b0df82987340af7d..5cfc6e6ab31ef1153f04863480c563f8c89a81ac 100644 (file)
@@ -279,14 +279,8 @@ public:
 };
 } // end anonymous namespace
 
-static bool HasPointerEvalType(const Expr* E) {
-  return E->getType()->isPointerType()
-         || E->getType()->isBlockPointerType()
-         || E->getType()->isObjCQualifiedIdType();
-}
-
 static bool EvaluatePointer(const Expr* E, APValue& Result, EvalInfo &Info) {
-  if (!HasPointerEvalType(E))
+  if (!E->getType()->hasPointerRepresentation())
     return false;
   Result = PointerExprEvaluator(Info).Visit(const_cast<Expr*>(E));
   return Result.isLValue();
@@ -1570,7 +1564,7 @@ bool Expr::Evaluate(EvalResult &Result, ASTContext &Ctx) const {
   } else if (getType()->isIntegerType()) {
     if (!IntExprEvaluator(Info, Result.Val).Visit(const_cast<Expr*>(this)))
       return false;
-  } else if (HasPointerEvalType(this)) {
+  } else if (getType()->hasPointerRepresentation()) {
     if (!EvaluatePointer(this, Result.Val, Info))
       return false;
   } else if (getType()->isRealFloatingType()) {
index e560bfd82f1b51c3a9c009fcbda87b4e87459e85..7a98b0c1c6b6da168b0e88f0f5731a5ceda3e52e 100644 (file)
@@ -525,9 +525,7 @@ void X86_64ABIInfo::classify(QualType Ty,
   } else if (const EnumType *ET = Ty->getAsEnumType()) {
     // Classify the underlying integer type.
     classify(ET->getDecl()->getIntegerType(), Context, OffsetBase, Lo, Hi);
-  } else if (Ty->isPointerType() || Ty->isReferenceType() || 
-             Ty->isBlockPointerType() || Ty->isObjCQualifiedIdType() ||
-             Ty->isObjCQualifiedInterfaceType()) {
+  } else if (Ty->hasPointerRepresentation()) {
     Current = Integer;
   } else if (const VectorType *VT = Ty->getAsVectorType()) {
     uint64_t Size = Context.getTypeSize(VT);
index 2f0973466657ee9f9f5de374d4b3f4a681a8fca2..81fd3871d61a9400b19a153c9f614b0b78b371c3 100644 (file)
@@ -73,17 +73,11 @@ const llvm::Type *CodeGenFunction::ConvertType(QualType T) {
   return CGM.getTypes().ConvertType(T);
 }
 
-bool CodeGenFunction::isObjCPointerType(QualType T) {
-  // All Objective-C types are pointers.
-  return T->isObjCInterfaceType() ||
-    T->isObjCQualifiedInterfaceType() || T->isObjCQualifiedIdType();
-}
-
 bool CodeGenFunction::hasAggregateLLVMType(QualType T) {
   // FIXME: Use positive checks instead of negative ones to be more
   // robust in the face of extension.
-  return !isObjCPointerType(T) &&!T->isRealType() && !T->isPointerType() &&
-    !T->isReferenceType() && !T->isVoidType() && !T->isVectorType() && !T->isFunctionType() && 
+  return !T->hasPointerRepresentation() &&!T->isRealType() &&
+    !T->isVoidType() && !T->isVectorType() && !T->isFunctionType() && 
     !T->isBlockPointerType();
 }
 
index 8b5986c4713609a5fc1d336131b65961428de5b1..918646f95591186bd170a3592d72d18f83a74a9d 100644 (file)
@@ -366,10 +366,6 @@ public:
   /// TypeOfSelfObject - Return type of object that this self represents.
   QualType TypeOfSelfObject();
 
-  /// isObjCPointerType - Return true if the specificed AST type will map onto
-  /// some Objective-C pointer type.
-  static bool isObjCPointerType(QualType T);
-
   /// hasAggregateLLVMType - Return true if the specified AST type will map into
   /// an aggregate LLVM type or is void.
   static bool hasAggregateLLVMType(QualType T);