diff options
| author | Shafik Yaghmour <syaghmour@apple.com> | 2018-11-08 18:42:00 +0000 |
|---|---|---|
| committer | Shafik Yaghmour <syaghmour@apple.com> | 2018-11-08 18:42:00 +0000 |
| commit | 8c5ec1ff4653ff4011c5228f8fbdc800ebe35456 (patch) | |
| tree | bfce6fb0f380e8553093573b1ea12d363425af0d /lldb/source | |
| parent | 7a44fe956a249585187cd5f82a0683dc117e0ae8 (diff) | |
| download | bcm5719-llvm-8c5ec1ff4653ff4011c5228f8fbdc800ebe35456.tar.gz bcm5719-llvm-8c5ec1ff4653ff4011c5228f8fbdc800ebe35456.zip | |
Refactor ClangASTContext::AddEnumerationValueToEnumerationType() to remove redundant parameter which can be calculated from other parameter.
rdar://problem/43822994
Differential Revision: https://reviews.llvm.org/D54003
llvm-svn: 346428
Diffstat (limited to 'lldb/source')
4 files changed, 49 insertions, 44 deletions
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index ee3942a83b7..9981aec5a29 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -2500,9 +2500,7 @@ size_t DWARFASTParserClang::ParseChildEnumerators( if (name && name[0] && got_value) { m_ast.AddEnumerationValueToEnumerationType( - clang_type.GetOpaqueQualType(), - m_ast.GetEnumerationIntegerType(clang_type.GetOpaqueQualType()), - decl, name, enum_value, enumerator_byte_size * 8); + clang_type, decl, name, enum_value, enumerator_byte_size * 8); ++enumerators_added; } } diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp index 88848a63902..432ba9ecea7 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp @@ -159,13 +159,9 @@ Error UdtRecordCompleter::visitKnownMember(CVMemberRecord &cvr, TypeSP underlying_type = m_symbol_file.GetOrCreateType(m_cvr.er.getUnderlyingType()); - lldb::opaque_compiler_type_t enum_qt = m_derived_ct.GetOpaqueQualType(); - - CompilerType enumerator_type = clang.GetEnumerationIntegerType(enum_qt); uint64_t byte_size = underlying_type->GetByteSize(); clang.AddEnumerationValueToEnumerationType( - m_derived_ct.GetOpaqueQualType(), enumerator_type, decl, - name.str().c_str(), enumerator.Value.getSExtValue(), + m_derived_ct, decl, name.str().c_str(), enumerator.Value.getSExtValue(), byte_size * 8); return Error::success(); } @@ -182,4 +178,4 @@ void UdtRecordCompleter::complete() { if (auto *record_decl = llvm::dyn_cast<clang::CXXRecordDecl>(&m_tag_decl)) { m_symbol_file.GetASTImporter().InsertRecordDecl(record_decl, m_layout); } -}
\ No newline at end of file +} diff --git a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp index b2f6a296557..145587ac5be 100644 --- a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp +++ b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp @@ -1122,8 +1122,7 @@ bool PDBASTParser::AddEnumValue(CompilerType enum_type, uint32_t byte_size = m_ast.getASTContext()->getTypeSize( ClangUtil::GetQualType(underlying_type)); auto enum_constant_decl = m_ast.AddEnumerationValueToEnumerationType( - enum_type.GetOpaqueQualType(), underlying_type, decl, name.c_str(), - raw_value, byte_size * 8); + enum_type, decl, name.c_str(), raw_value, byte_size * 8); if (!enum_constant_decl) return false; diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp index f98135216a5..560a18f6191 100644 --- a/lldb/source/Symbol/ClangASTContext.cpp +++ b/lldb/source/Symbol/ClangASTContext.cpp @@ -8876,43 +8876,55 @@ bool ClangASTContext::CompleteTagDeclarationDefinition( } clang::EnumConstantDecl *ClangASTContext::AddEnumerationValueToEnumerationType( - lldb::opaque_compiler_type_t type, - const CompilerType &enumerator_clang_type, const Declaration &decl, - const char *name, int64_t enum_value, uint32_t enum_value_bit_size) { - if (type && enumerator_clang_type.IsValid() && name && name[0]) { - clang::QualType enum_qual_type(GetCanonicalQualType(type)); - - bool is_signed = false; - enumerator_clang_type.IsIntegerType(is_signed); - const clang::Type *clang_type = enum_qual_type.getTypePtr(); - if (clang_type) { - const clang::EnumType *enutype = - llvm::dyn_cast<clang::EnumType>(clang_type); - - if (enutype) { - llvm::APSInt enum_llvm_apsint(enum_value_bit_size, is_signed); - enum_llvm_apsint = enum_value; - clang::EnumConstantDecl *enumerator_decl = - clang::EnumConstantDecl::Create( - *getASTContext(), enutype->getDecl(), clang::SourceLocation(), - name ? &getASTContext()->Idents.get(name) - : nullptr, // Identifier - ClangUtil::GetQualType(enumerator_clang_type), - nullptr, enum_llvm_apsint); - - if (enumerator_decl) { - enutype->getDecl()->addDecl(enumerator_decl); + const CompilerType &enum_type, const Declaration &decl, const char *name, + int64_t enum_value, uint32_t enum_value_bit_size) { + + if (!enum_type || ConstString(name).IsEmpty()) + return nullptr; + + lldbassert(enum_type.GetTypeSystem() == static_cast<TypeSystem *>(this)); + + lldb::opaque_compiler_type_t enum_opaque_compiler_type = + enum_type.GetOpaqueQualType(); + + if (!enum_opaque_compiler_type) + return nullptr; + + CompilerType underlying_type = + GetEnumerationIntegerType(enum_type.GetOpaqueQualType()); + + clang::QualType enum_qual_type( + GetCanonicalQualType(enum_opaque_compiler_type)); + + bool is_signed = false; + underlying_type.IsIntegerType(is_signed); + const clang::Type *clang_type = enum_qual_type.getTypePtr(); + + if (!clang_type) + return nullptr; + + const clang::EnumType *enutype = llvm::dyn_cast<clang::EnumType>(clang_type); + + if (!enutype) + return nullptr; + + llvm::APSInt enum_llvm_apsint(enum_value_bit_size, is_signed); + enum_llvm_apsint = enum_value; + clang::EnumConstantDecl *enumerator_decl = clang::EnumConstantDecl::Create( + *getASTContext(), enutype->getDecl(), clang::SourceLocation(), + name ? &getASTContext()->Idents.get(name) : nullptr, // Identifier + clang::QualType(enutype, 0), nullptr, enum_llvm_apsint); + + if (!enumerator_decl) + return nullptr; + + enutype->getDecl()->addDecl(enumerator_decl); #ifdef LLDB_CONFIGURATION_DEBUG - VerifyDecl(enumerator_decl); + VerifyDecl(enumerator_decl); #endif - return enumerator_decl; - } - } - } - } - return nullptr; + return enumerator_decl; } CompilerType |

