aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-07-02 23:20:17 +0000
committerChris Lattner <sabre@nondot.org>2004-07-02 23:20:17 +0000
commitc5f143b6e7d287d0dc3e5c55b3c83a2670ca99f8 (patch)
tree4332b0a9fe8235e481e27f12170a19cb75770c41 /lib/VMCore
parentcf27afb64e3387a747a467072536df8259488213 (diff)
downloadexternal_llvm-c5f143b6e7d287d0dc3e5c55b3c83a2670ca99f8.zip
external_llvm-c5f143b6e7d287d0dc3e5c55b3c83a2670ca99f8.tar.gz
external_llvm-c5f143b6e7d287d0dc3e5c55b3c83a2670ca99f8.tar.bz2
Fix Type::isSized() to realize that "{ opaque }" is not sized
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14585 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/Type.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp
index 7798489..eefcee9 100644
--- a/lib/VMCore/Type.cpp
+++ b/lib/VMCore/Type.cpp
@@ -159,6 +159,21 @@ unsigned Type::getPrimitiveSize() const {
}
}
+/// isSizedDerivedType - Derived types like structures and arrays are sized
+/// iff all of the members of the type are sized as well. Since asking for
+/// their size is relatively uncommon, move this operation out of line.
+bool Type::isSizedDerivedType() const {
+ if (const ArrayType *ATy = dyn_cast<ArrayType>(this))
+ return ATy->getElementType()->isSized();
+
+ if (!isa<StructType>(this)) return false;
+
+ // Okay, our struct is sized if all of the elements are...
+ for (subtype_iterator I = subtype_begin(), E = subtype_end(); I != E; ++I)
+ if (!(*I)->isSized()) return false;
+
+ return true;
+}
/// getForwardedTypeInternal - This method is used to implement the union-find
/// algorithm for when a type is being forwarded to another type.