[Lldb-commits] [lldb] r345055 - Change two methods from const char* to StringRef [NFC].
Zachary Turner via lldb-commits
lldb-commits at lists.llvm.org
Tue Oct 23 10:22:02 PDT 2018
Author: zturner
Date: Tue Oct 23 10:22:02 2018
New Revision: 345055
URL: http://llvm.org/viewvc/llvm-project?rev=345055&view=rev
Log:
Change two methods from const char* to StringRef [NFC].
Modified:
lldb/trunk/include/lldb/Symbol/ClangASTContext.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/trunk/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp
lldb/trunk/source/Symbol/ClangASTContext.cpp
Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=345055&r1=345054&r2=345055&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Tue Oct 23 10:22:02 2018
@@ -833,7 +833,7 @@ public:
// Modifying RecordType
//----------------------------------------------------------------------
static clang::FieldDecl *AddFieldToRecordType(const CompilerType &type,
- const char *name,
+ llvm::StringRef name,
const CompilerType &field_type,
lldb::AccessType access,
uint32_t bitfield_bit_size);
@@ -843,7 +843,7 @@ public:
static void SetIsPacked(const CompilerType &type);
static clang::VarDecl *AddVariableToRecordType(const CompilerType &type,
- const char *name,
+ llvm::StringRef name,
const CompilerType &var_type,
lldb::AccessType access);
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp?rev=345055&r1=345054&r2=345055&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Tue Oct 23 10:22:02 2018
@@ -3029,7 +3029,7 @@ bool DWARFASTParserClang::ParseChildMemb
if (anon_field_info.IsValid()) {
clang::FieldDecl *unnamed_bitfield_decl =
ClangASTContext::AddFieldToRecordType(
- class_clang_type, NULL,
+ class_clang_type, llvm::StringRef(),
m_ast.GetBuiltinTypeForEncodingAndBitSize(
eEncodingSint, word_width),
accessibility, anon_field_info.bit_size);
Modified: lldb/trunk/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp?rev=345055&r1=345054&r2=345055&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp Tue Oct 23 10:22:02 2018
@@ -108,8 +108,7 @@ Error UdtRecordCompleter::visitKnownMemb
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.
@@ -130,8 +129,7 @@ Error UdtRecordCompleter::visitKnownMemb
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.
Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=345055&r1=345054&r2=345055&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Tue Oct 23 10:22:02 2018
@@ -7778,7 +7778,7 @@ ClangASTContext::GetAsObjCInterfaceDecl(
}
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())
@@ -7788,6 +7788,9 @@ clang::FieldDecl *ClangASTContext::AddFi
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;
@@ -7805,14 +7808,14 @@ clang::FieldDecl *ClangASTContext::AddFi
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
+ ident, // Identifier
+ ClangUtil::GetQualType(field_clang_type), // Field type
+ nullptr, // TInfo *
+ bit_width, // BitWidth
+ false, // Mutable
+ clang::ICIS_NoInit); // HasInit
- if (!name) {
+ if (name.empty()) {
// Determine whether this field corresponds to an anonymous struct or
// union.
if (const clang::TagType *TagT =
@@ -7848,9 +7851,9 @@ clang::FieldDecl *ClangASTContext::AddFi
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);
@@ -7989,38 +7992,44 @@ void ClangASTContext::SetIsPacked(const
}
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;
}
More information about the lldb-commits
mailing list