[Lldb-commits] [lldb] b852b3c - [lldb][NFC] Rename ClangASTImporter::InsertRecordDecl to SetRecordLayout and document it
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Tue Dec 17 06:56:26 PST 2019
Author: Raphael Isemann
Date: 2019-12-17T15:56:07+01:00
New Revision: b852b3c982d2e8ad3f13c626b3e3655e5b3c399e
URL: https://github.com/llvm/llvm-project/commit/b852b3c982d2e8ad3f13c626b3e3655e5b3c399e
DIFF: https://github.com/llvm/llvm-project/commit/b852b3c982d2e8ad3f13c626b3e3655e5b3c399e.diff
LOG: [lldb][NFC] Rename ClangASTImporter::InsertRecordDecl to SetRecordLayout and document it
This function is just setting the layout for the given RecordDecl so
the current name is not very descriptive. Also add some documentation for it.
Added:
Modified:
lldb/include/lldb/Symbol/ClangASTImporter.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp
lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
lldb/source/Symbol/ClangASTImporter.cpp
lldb/unittests/Symbol/TestClangASTImporter.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Symbol/ClangASTImporter.h b/lldb/include/lldb/Symbol/ClangASTImporter.h
index 58e068658ad8..e0448249eba8 100644
--- a/lldb/include/lldb/Symbol/ClangASTImporter.h
+++ b/lldb/include/lldb/Symbol/ClangASTImporter.h
@@ -58,7 +58,14 @@ class ClangASTImporter {
clang::Decl *DeportDecl(clang::ASTContext *dst_ctx,
clang::ASTContext *src_ctx, clang::Decl *decl);
- void InsertRecordDecl(clang::RecordDecl *decl, const LayoutInfo &layout);
+ /// Sets the layout for the given RecordDecl. The layout will later be
+ /// used by Clang's during code generation. Not calling this function for
+ /// a RecordDecl will cause that Clang's codegen tries to layout the
+ /// record by itself.
+ ///
+ /// \param decl The RecordDecl to set the layout for.
+ /// \param layout The layout for the record.
+ void SetRecordLayout(clang::RecordDecl *decl, const LayoutInfo &layout);
bool LayoutRecordType(
const clang::RecordDecl *record_decl, uint64_t &bit_size,
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index d7b216c99feb..136027ee4d55 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -1720,7 +1720,7 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc,
ClangASTContext::GetAsRecordDecl(clang_type);
if (record_decl) {
- GetClangASTImporter().InsertRecordDecl(
+ GetClangASTImporter().SetRecordLayout(
record_decl, ClangASTImporter::LayoutInfo());
}
}
@@ -2134,7 +2134,7 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die,
clang::CXXRecordDecl *record_decl =
m_ast.GetAsCXXRecordDecl(clang_type.GetOpaqueQualType());
if (record_decl)
- GetClangASTImporter().InsertRecordDecl(record_decl, layout_info);
+ GetClangASTImporter().SetRecordLayout(record_decl, layout_info);
}
return (bool)clang_type;
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp
index 3c494dc83986..7221144407c1 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp
@@ -231,6 +231,6 @@ void UdtRecordCompleter::complete() {
ClangASTContext::CompleteTagDeclarationDefinition(m_derived_ct);
if (auto *record_decl = llvm::dyn_cast<clang::CXXRecordDecl>(&m_tag_decl)) {
- m_ast_builder.importer().InsertRecordDecl(record_decl, m_layout);
+ m_ast_builder.importer().SetRecordLayout(record_decl, m_layout);
}
}
diff --git a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
index 245d99c8c05b..7bf94c64aa4f 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
+++ b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
@@ -1207,7 +1207,7 @@ bool PDBASTParser::CompleteTypeFromUDT(
if (!record_decl)
return static_cast<bool>(compiler_type);
- GetClangASTImporter().InsertRecordDecl(record_decl, layout_info);
+ GetClangASTImporter().SetRecordLayout(record_decl, layout_info);
return static_cast<bool>(compiler_type);
}
diff --git a/lldb/source/Symbol/ClangASTImporter.cpp b/lldb/source/Symbol/ClangASTImporter.cpp
index 3c11c3250af9..de5448d4317d 100644
--- a/lldb/source/Symbol/ClangASTImporter.cpp
+++ b/lldb/source/Symbol/ClangASTImporter.cpp
@@ -547,7 +547,7 @@ bool ClangASTImporter::LayoutRecordType(
return success;
}
-void ClangASTImporter::InsertRecordDecl(clang::RecordDecl *decl,
+void ClangASTImporter::SetRecordLayout(clang::RecordDecl *decl,
const LayoutInfo &layout) {
m_record_decl_to_layout_map.insert(std::make_pair(decl, layout));
}
diff --git a/lldb/unittests/Symbol/TestClangASTImporter.cpp b/lldb/unittests/Symbol/TestClangASTImporter.cpp
index 17a0dfb6a348..f82fa4a69e42 100644
--- a/lldb/unittests/Symbol/TestClangASTImporter.cpp
+++ b/lldb/unittests/Symbol/TestClangASTImporter.cpp
@@ -201,7 +201,7 @@ TEST_F(TestClangASTImporter, RecordLayout) {
layout_info.bit_size = 15;
layout_info.alignment = 2;
layout_info.field_offsets[field] = 1;
- importer.InsertRecordDecl(source_record, layout_info);
+ importer.SetRecordLayout(source_record, layout_info);
uint64_t bit_size;
uint64_t alignment;
More information about the lldb-commits
mailing list