lldb::AccessType access =
TranslateMemberAccess(static_data_member.getAccess());
ClangASTContext::AddVariableToRecordType(
- m_derived_ct, static_data_member.Name.str().c_str(), complete_member_type,
- access);
+ m_derived_ct, static_data_member.Name, complete_member_type, access);
// FIXME: Add a PdbSymUid namespace for field list members and update
// the m_uid_to_decl map with this decl.
lldb::AccessType access = TranslateMemberAccess(data_member.getAccess());
clang::FieldDecl *decl = ClangASTContext::AddFieldToRecordType(
- m_derived_ct, data_member.Name.str().c_str(), complete_member_type,
- access, 0);
+ m_derived_ct, data_member.Name, complete_member_type, access, 0);
// FIXME: Add a PdbSymUid namespace for field list members and update
// the m_uid_to_decl map with this decl.
}
clang::FieldDecl *ClangASTContext::AddFieldToRecordType(
- const CompilerType &type, const char *name,
+ const CompilerType &type, llvm::StringRef name,
const CompilerType &field_clang_type, AccessType access,
uint32_t bitfield_bit_size) {
if (!type.IsValid() || !field_clang_type.IsValid())
if (!ast)
return nullptr;
clang::ASTContext *clang_ast = ast->getASTContext();
+ clang::IdentifierInfo *ident = nullptr;
+ if (!name.empty())
+ ident = &clang_ast->Idents.get(name);
clang::FieldDecl *field = nullptr;
field = clang::FieldDecl::Create(
*clang_ast, record_decl, clang::SourceLocation(),
clang::SourceLocation(),
- name ? &clang_ast->Idents.get(name) : nullptr, // Identifier
- ClangUtil::GetQualType(field_clang_type), // Field type
- nullptr, // TInfo *
- bit_width, // BitWidth
- false, // Mutable
- clang::ICIS_NoInit); // HasInit
-
- if (!name) {
+ ident, // Identifier
+ ClangUtil::GetQualType(field_clang_type), // Field type
+ nullptr, // TInfo *
+ bit_width, // BitWidth
+ false, // Mutable
+ clang::ICIS_NoInit); // HasInit
+
+ if (name.empty()) {
// Determine whether this field corresponds to an anonymous struct or
// union.
if (const clang::TagType *TagT =
field = clang::ObjCIvarDecl::Create(
*clang_ast, class_interface_decl, clang::SourceLocation(),
clang::SourceLocation(),
- name ? &clang_ast->Idents.get(name) : nullptr, // Identifier
- ClangUtil::GetQualType(field_clang_type), // Field type
- nullptr, // TypeSourceInfo *
+ ident, // Identifier
+ ClangUtil::GetQualType(field_clang_type), // Field type
+ nullptr, // TypeSourceInfo *
ConvertAccessTypeToObjCIvarAccessControl(access), bit_width,
is_synthesized);
}
clang::VarDecl *ClangASTContext::AddVariableToRecordType(
- const CompilerType &type, const char *name, const CompilerType &var_type,
- AccessType access) {
- clang::VarDecl *var_decl = nullptr;
-
+ const CompilerType &type, llvm::StringRef name,
+ const CompilerType &var_type, AccessType access) {
if (!type.IsValid() || !var_type.IsValid())
return nullptr;
+
ClangASTContext *ast = llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
if (!ast)
return nullptr;
clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
- if (record_decl) {
- var_decl = clang::VarDecl::Create(
- *ast->getASTContext(), // ASTContext &
- record_decl, // DeclContext *
- clang::SourceLocation(), // clang::SourceLocation StartLoc
- clang::SourceLocation(), // clang::SourceLocation IdLoc
- name ? &ast->getASTContext()->Idents.get(name)
- : nullptr, // clang::IdentifierInfo *
- ClangUtil::GetQualType(var_type), // Variable clang::QualType
- nullptr, // TypeSourceInfo *
- clang::SC_Static); // StorageClass
- if (var_decl) {
- var_decl->setAccess(
- ClangASTContext::ConvertAccessTypeToAccessSpecifier(access));
- record_decl->addDecl(var_decl);
+ if (!record_decl)
+ return nullptr;
+
+ clang::VarDecl *var_decl = nullptr;
+ clang::IdentifierInfo *ident = nullptr;
+ if (!name.empty())
+ ident = &ast->getASTContext()->Idents.get(name);
+
+ var_decl = clang::VarDecl::Create(
+ *ast->getASTContext(), // ASTContext &
+ record_decl, // DeclContext *
+ clang::SourceLocation(), // clang::SourceLocation StartLoc
+ clang::SourceLocation(), // clang::SourceLocation IdLoc
+ ident, // clang::IdentifierInfo *
+ ClangUtil::GetQualType(var_type), // Variable clang::QualType
+ nullptr, // TypeSourceInfo *
+ clang::SC_Static); // StorageClass
+ if (!var_decl)
+ return nullptr;
+
+ var_decl->setAccess(
+ ClangASTContext::ConvertAccessTypeToAccessSpecifier(access));
+ record_decl->addDecl(var_decl);
#ifdef LLDB_CONFIGURATION_DEBUG
- VerifyDecl(var_decl);
+ VerifyDecl(var_decl);
#endif
- }
- }
+
return var_decl;
}