From 27984e67f7958c83e69aa15859d29867c46097a9 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 26 Jan 2012 00:06:44 +0000 Subject: [PATCH] add StructType helpers too. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149000 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Type.h | 5 ++++- lib/VMCore/Type.cpp | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/include/llvm/Type.h b/include/llvm/Type.h index d3b2f1383fb..185258d8ff2 100644 --- a/include/llvm/Type.h +++ b/include/llvm/Type.h @@ -26,6 +26,7 @@ class raw_ostream; class Module; class LLVMContext; class LLVMContextImpl; +class StringRef; template struct GraphTraits; /// The instances of the Type class are immutable: once they are created, @@ -327,7 +328,9 @@ public: unsigned getFunctionNumParams() const; bool isFunctionVarArg() const; - // TODO: StructType + StringRef getStructName() const; + unsigned getStructNumElements() const; + Type *getStructElementType(unsigned N) const; Type *getSequentialElementType() const; diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp index 627f6452c66..f5c88ccd38a 100644 --- a/lib/VMCore/Type.cpp +++ b/lib/VMCore/Type.cpp @@ -217,6 +217,20 @@ unsigned Type::getFunctionNumParams() const { return cast(this)->getNumParams(); } +StringRef Type::getStructName() const { + return cast(this)->getName(); +} + +unsigned Type::getStructNumElements() const { + return cast(this)->getNumElements(); +} + +Type *Type::getStructElementType(unsigned N) const { + return cast(this)->getElementType(N); +} + + + Type *Type::getSequentialElementType() const { return cast(this)->getElementType(); }