]> granicus.if.org Git - clang/commitdiff
Make CodeGenTypes::getCGRecordLayout compute the layout lazily if it doesn't exist...
authorAnders Carlsson <andersca@mac.com>
Wed, 24 Nov 2010 19:51:04 +0000 (19:51 +0000)
committerAnders Carlsson <andersca@mac.com>
Wed, 24 Nov 2010 19:51:04 +0000 (19:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120107 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CodeGenTypes.cpp
lib/CodeGen/CodeGenTypes.h

index 84c1ceb1ffe30d13ddac2e960af6a72c3570e54c..5ff9da4c48cc4c222956db2c9bc1fc4894236a43 100644 (file)
@@ -488,6 +488,14 @@ const CGRecordLayout &
 CodeGenTypes::getCGRecordLayout(const RecordDecl *TD) const {
   const Type *Key = Context.getTagDeclType(TD).getTypePtr();
   const CGRecordLayout *Layout = CGRecordLayouts.lookup(Key);
+  if (!Layout) {
+    // Compute the type information.
+    ConvertTagDeclType(TD);
+
+    // Now try again.
+    Layout = CGRecordLayouts.lookup(Key);
+  }
+
   assert(Layout && "Unable to find record layout information for type");
   return *Layout;
 }
index 36acd72ec4182bad4c9ef6ba7c7c777f586e15c8..c2b0b75878f4f1a2762dcb01361742fe52c662a3 100644 (file)
@@ -143,7 +143,7 @@ public:
   /// and/or incomplete argument types, this will return the opaque type.
   const llvm::Type *GetFunctionTypeForVTable(GlobalDecl GD);
 
-  const CGRecordLayout &getCGRecordLayout(const RecordDecl*) const;
+  const CGRecordLayout &getCGRecordLayout(const RecordDecl*);
 
   /// UpdateCompletedType - When we find the full definition for a TagDecl,
   /// replace the 'opaque' type we previously made for it if applicable.