diff options
author | Anders Carlsson <andersca@mac.com> | 2010-05-14 19:41:56 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2010-05-14 19:41:56 +0000 |
commit | 3e5af908ebf4c56b657c488bb2ca22f418e0868b (patch) | |
tree | 0f4e8ebe9b7a55cfef9d92448443911fe58831cf /lib/CodeGen/CodeGenTypes.cpp | |
parent | 509d477ae5a24282719320fe92038ccf57358840 (diff) |
Move ContainsPointerToDataMember to CodeGenTypes. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103792 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenTypes.cpp')
-rw-r--r-- | lib/CodeGen/CodeGenTypes.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp index f53dd83d70..291cd7fbde 100644 --- a/lib/CodeGen/CodeGenTypes.cpp +++ b/lib/CodeGen/CodeGenTypes.cpp @@ -467,3 +467,27 @@ CodeGenTypes::getCGRecordLayout(const RecordDecl *TD) const { assert(Layout && "Unable to find record layout information for type"); return *Layout; } + +bool CodeGenTypes::ContainsPointerToDataMember(QualType T) { + // No need to check for member pointers when not compiling C++. + if (!Context.getLangOptions().CPlusPlus) + return false; + + T = Context.getBaseElementType(T); + + if (const RecordType *RT = T->getAs<RecordType>()) { + const CXXRecordDecl *RD = cast<CXXRecordDecl>(RT->getDecl()); + + // FIXME: It would be better if there was a way to explicitly compute the + // record layout instead of converting to a type. + ConvertTagDeclType(RD); + + const CGRecordLayout &Layout = getCGRecordLayout(RD); + return Layout.containsPointerToDataMember(); + } + + if (const MemberPointerType *MPT = T->getAs<MemberPointerType>()) + return !MPT->getPointeeType()->isFunctionType(); + + return false; +} |