Add the ability for a ClangASTType to be marked as 'packed' when constructed

llvm-svn: 220891
diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp
index 8347444..c795e4e 100644
--- a/lldb/source/Symbol/ClangASTContext.cpp
+++ b/lldb/source/Symbol/ClangASTContext.cpp
@@ -1857,7 +1857,8 @@
 
 ClangASTType
 ClangASTContext::GetOrCreateStructForIdentifier (const ConstString &type_name,
-                                                 const std::initializer_list< std::pair < const char *, ClangASTType > >& type_fields)
+                                                 const std::initializer_list< std::pair < const char *, ClangASTType > >& type_fields,
+                                                 bool packed)
 {
     ClangASTType type;
     if ((type = GetTypeForIdentifier<clang::CXXRecordDecl>(type_name)).IsValid())
@@ -1866,6 +1867,8 @@
     type.StartTagDeclarationDefinition();
     for (const auto& field : type_fields)
         type.AddFieldToRecordType(field.first, field.second, lldb::eAccessPublic, 0);
+    if (packed)
+        type.SetIsPacked();
     type.CompleteTagDeclarationDefinition();
     return type;
 }
diff --git a/lldb/source/Symbol/ClangASTType.cpp b/lldb/source/Symbol/ClangASTType.cpp
index 06de2ad..8b672fa 100644
--- a/lldb/source/Symbol/ClangASTType.cpp
+++ b/lldb/source/Symbol/ClangASTType.cpp
@@ -4946,6 +4946,17 @@
     }
 }
 
+void
+ClangASTType::SetIsPacked ()
+{
+    clang::RecordDecl *record_decl = GetAsRecordDecl();
+    
+    if (!record_decl)
+        return;
+    
+    record_decl->addAttr(clang::PackedAttr::CreateImplicit(*m_ast));
+}
+
 clang::VarDecl *
 ClangASTType::AddVariableToRecordType (const char *name,
                                        const ClangASTType &var_type,