[Lldb-commits] [lldb] r220891 - Add the ability for a ClangASTType to be marked as 'packed' when constructed
Enrico Granata
egranata at apple.com
Wed Oct 29 17:53:29 PDT 2014
Author: enrico
Date: Wed Oct 29 19:53:28 2014
New Revision: 220891
URL: http://llvm.org/viewvc/llvm-project?rev=220891&view=rev
Log:
Add the ability for a ClangASTType to be marked as 'packed' when constructed
Modified:
lldb/trunk/include/lldb/Symbol/ClangASTContext.h
lldb/trunk/include/lldb/Symbol/ClangASTType.h
lldb/trunk/source/Symbol/ClangASTContext.cpp
lldb/trunk/source/Symbol/ClangASTType.cpp
Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=220891&r1=220890&r2=220891&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Wed Oct 29 19:53:28 2014
@@ -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
Modified: lldb/trunk/include/lldb/Symbol/ClangASTType.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTType.h?rev=220891&r1=220890&r2=220891&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ClangASTType.h (original)
+++ lldb/trunk/include/lldb/Symbol/ClangASTType.h Wed Oct 29 19:53:28 2014
@@ -455,6 +455,9 @@ public:
void
BuildIndirectFields ();
+ void
+ SetIsPacked ();
+
clang::VarDecl *
AddVariableToRecordType (const char *name,
const ClangASTType &var_type,
Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=220891&r1=220890&r2=220891&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Wed Oct 29 19:53:28 2014
@@ -1857,7 +1857,8 @@ ClangASTContext::CreateArrayType (const
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 @@ ClangASTContext::GetOrCreateStructForIde
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;
}
Modified: lldb/trunk/source/Symbol/ClangASTType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=220891&r1=220890&r2=220891&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTType.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTType.cpp Wed Oct 29 19:53:28 2014
@@ -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,
More information about the lldb-commits
mailing list