Skip to content

Commit 268f37d

Browse files
committed
[lldb][NFC] Use StringRef in CreateRecordType and CreateObjCClass
1 parent b1d8576 commit 268f37d

File tree

6 files changed

+22
-18
lines changed

6 files changed

+22
-18
lines changed

lldb/include/lldb/Symbol/ClangASTContext.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,9 @@ class ClangASTContext : public TypeSystem {
263263
bool omit_empty_base_classes);
264264

265265
CompilerType CreateRecordType(clang::DeclContext *decl_ctx,
266-
lldb::AccessType access_type, const char *name,
267-
int kind, lldb::LanguageType language,
266+
lldb::AccessType access_type,
267+
llvm::StringRef name, int kind,
268+
lldb::LanguageType language,
268269
ClangASTMetadata *metadata = nullptr,
269270
bool exports_symbols = false);
270271

@@ -322,8 +323,9 @@ class ClangASTContext : public TypeSystem {
322323

323324
static bool RecordHasFields(const clang::RecordDecl *record_decl);
324325

325-
CompilerType CreateObjCClass(const char *name, clang::DeclContext *decl_ctx,
326-
bool isForwardDecl, bool isInternal,
326+
CompilerType CreateObjCClass(llvm::StringRef name,
327+
clang::DeclContext *decl_ctx, bool isForwardDecl,
328+
bool isInternal,
327329
ClangASTMetadata *metadata = nullptr);
328330

329331
bool SetTagTypeKind(clang::QualType type, int kind) const;

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ clang::QualType AppleObjCTypeEncodingParser::BuildAggregate(
128128
if (!lldb_ctx)
129129
return clang::QualType();
130130
CompilerType union_type(lldb_ctx->CreateRecordType(
131-
nullptr, lldb::eAccessPublic, name.c_str(), kind, lldb::eLanguageTypeC));
131+
nullptr, lldb::eAccessPublic, name, kind, lldb::eLanguageTypeC));
132132
if (union_type) {
133133
ClangASTContext::StartTagDeclarationDefinition(union_type);
134134

lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -778,9 +778,8 @@ clang::QualType PdbAstBuilder::CreateRecordType(PdbTypeSymId id,
778778
metadata.SetUserID(toOpaqueUid(id));
779779
metadata.SetIsDynamicCXXType(false);
780780

781-
CompilerType ct =
782-
m_clang.CreateRecordType(context, access, uname.c_str(), ttk,
783-
lldb::eLanguageTypeC_plus_plus, &metadata);
781+
CompilerType ct = m_clang.CreateRecordType(
782+
context, access, uname, ttk, lldb::eLanguageTypeC_plus_plus, &metadata);
784783

785784
lldbassert(ct.IsValid());
786785

lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,9 +417,9 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
417417
metadata.SetUserID(type.getSymIndexId());
418418
metadata.SetIsDynamicCXXType(false);
419419

420-
clang_type = m_ast.CreateRecordType(
421-
decl_context, access, name.c_str(), tag_type_kind,
422-
lldb::eLanguageTypeC_plus_plus, &metadata);
420+
clang_type =
421+
m_ast.CreateRecordType(decl_context, access, name, tag_type_kind,
422+
lldb::eLanguageTypeC_plus_plus, &metadata);
423423
assert(clang_type.IsValid());
424424

425425
auto record_decl =

lldb/source/Symbol/ClangASTContext.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,9 +1285,12 @@ CompilerType ClangASTContext::GetTypeForDecl(ObjCInterfaceDecl *decl) {
12851285

12861286
#pragma mark Structure, Unions, Classes
12871287

1288-
CompilerType ClangASTContext::CreateRecordType(
1289-
DeclContext *decl_ctx, AccessType access_type, const char *name, int kind,
1290-
LanguageType language, ClangASTMetadata *metadata, bool exports_symbols) {
1288+
CompilerType ClangASTContext::CreateRecordType(DeclContext *decl_ctx,
1289+
AccessType access_type,
1290+
llvm::StringRef name, int kind,
1291+
LanguageType language,
1292+
ClangASTMetadata *metadata,
1293+
bool exports_symbols) {
12911294
ASTContext *ast = getASTContext();
12921295
assert(ast != nullptr);
12931296

@@ -1307,7 +1310,7 @@ CompilerType ClangASTContext::CreateRecordType(
13071310
// something is struct or a class, so we default to always use the more
13081311
// complete definition just in case.
13091312

1310-
bool has_name = name && name[0];
1313+
bool has_name = !name.empty();
13111314

13121315
CXXRecordDecl *decl = CXXRecordDecl::Create(
13131316
*ast, (TagDecl::TagKind)kind, decl_ctx, SourceLocation(),
@@ -1683,14 +1686,14 @@ bool ClangASTContext::RecordHasFields(const RecordDecl *record_decl) {
16831686

16841687
#pragma mark Objective-C Classes
16851688

1686-
CompilerType ClangASTContext::CreateObjCClass(const char *name,
1689+
CompilerType ClangASTContext::CreateObjCClass(llvm::StringRef name,
16871690
DeclContext *decl_ctx,
16881691
bool isForwardDecl,
16891692
bool isInternal,
16901693
ClangASTMetadata *metadata) {
16911694
ASTContext *ast = getASTContext();
16921695
assert(ast != nullptr);
1693-
assert(name && name[0]);
1696+
assert(!name.empty());
16941697
if (decl_ctx == nullptr)
16951698
decl_ctx = ast->getTranslationUnitDecl();
16961699

lldb/unittests/Symbol/TestClangASTImporter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class TestClangASTImporter : public testing::Test {
3838
return std::make_unique<ClangASTContext>(HostInfo::GetTargetTriple());
3939
}
4040

41-
CompilerType createRecord(ClangASTContext &ast, const char *name) {
41+
CompilerType createRecord(ClangASTContext &ast, llvm::StringRef name) {
4242
return ast.CreateRecordType(ast.getASTContext()->getTranslationUnitDecl(),
4343
lldb::AccessType::eAccessPublic, name, 0,
4444
lldb::LanguageType::eLanguageTypeC);

0 commit comments

Comments
 (0)