diff options
Diffstat (limited to 'lldb/source/Symbol/ClangASTContext.cpp')
| -rw-r--r-- | lldb/source/Symbol/ClangASTContext.cpp | 78 |
1 files changed, 45 insertions, 33 deletions
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 |

