From a449e8642fdac1d28c82b168b0435311f12fe6fe Mon Sep 17 00:00:00 2001 From: Enrico Granata Date: Thu, 30 Oct 2014 00:53:28 +0000 Subject: [PATCH] Add the ability for a ClangASTType to be marked as 'packed' when constructed llvm-svn: 220891 --- lldb/include/lldb/Symbol/ClangASTContext.h | 3 ++- lldb/include/lldb/Symbol/ClangASTType.h | 3 +++ lldb/source/Symbol/ClangASTContext.cpp | 5 ++++- lldb/source/Symbol/ClangASTType.cpp | 11 +++++++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h index 2c49a43..331bc6e 100644 --- a/lldb/include/lldb/Symbol/ClangASTContext.h +++ b/lldb/include/lldb/Symbol/ClangASTContext.h @@ -248,7 +248,8 @@ public: ClangASTType 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 = false); //------------------------------------------------------------------ // Structure, Unions, Classes diff --git a/lldb/include/lldb/Symbol/ClangASTType.h b/lldb/include/lldb/Symbol/ClangASTType.h index 51c2344..ef23a8b 100644 --- a/lldb/include/lldb/Symbol/ClangASTType.h +++ b/lldb/include/lldb/Symbol/ClangASTType.h @@ -455,6 +455,9 @@ public: void BuildIndirectFields (); + void + SetIsPacked (); + clang::VarDecl * AddVariableToRecordType (const char *name, const ClangASTType &var_type, 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 @@ ClangASTContext::CreateArrayType (const ClangASTType &element_type, 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(type_name)).IsValid()) @@ -1866,6 +1867,8 @@ ClangASTContext::GetOrCreateStructForIdentifier (const ConstString &type_name, 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 @@ ClangASTType::BuildIndirectFields () } } +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, -- 2.7.4