[cfe-commits] r65569 - in /cfe/trunk: include/clang/AST/Type.h lib/AST/ExprConstant.cpp lib/CodeGen/CGCall.cpp lib/CodeGen/CodeGenFunction.cpp lib/CodeGen/CodeGenFunction.h

Daniel Dunbar daniel at zuster.org
Thu Feb 26 12:52:23 PST 2009


Author: ddunbar
Date: Thu Feb 26 14:52:22 2009
New Revision: 65569

URL: http://llvm.org/viewvc/llvm-project?rev=65569&view=rev
Log:
Add Type::hasPointerRepresentation predicate.
 - For types whose native representation is a pointer.

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

Modified:
    cfe/trunk/include/clang/AST/Type.h
    cfe/trunk/lib/AST/ExprConstant.cpp
    cfe/trunk/lib/CodeGen/CGCall.cpp
    cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
    cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=65569&r1=65568&r2=65569&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Thu Feb 26 14:52:22 2009
@@ -390,6 +390,12 @@
   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 @@
   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,

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=65569&r1=65568&r2=65569&view=diff

==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Thu Feb 26 14:52:22 2009
@@ -279,14 +279,8 @@
 };
 } // 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 @@
   } 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()) {

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=65569&r1=65568&r2=65569&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Thu Feb 26 14:52:22 2009
@@ -525,9 +525,7 @@
   } 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);

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=65569&r1=65568&r2=65569&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Thu Feb 26 14:52:22 2009
@@ -73,17 +73,11 @@
   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();
 }
 

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=65569&r1=65568&r2=65569&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Thu Feb 26 14:52:22 2009
@@ -366,10 +366,6 @@
   /// 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);





More information about the cfe-commits mailing list