Skip to content

Commit

Permalink
[lldb][NFC] Use StringRef in CreateRecordType and CreateObjCClass
Browse files Browse the repository at this point in the history
  • Loading branch information
Teemperor committed Dec 17, 2019
1 parent b1d8576 commit 268f37d
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 18 deletions.
10 changes: 6 additions & 4 deletions lldb/include/lldb/Symbol/ClangASTContext.h
Expand Up @@ -263,8 +263,9 @@ class ClangASTContext : public TypeSystem {
bool omit_empty_base_classes);

CompilerType CreateRecordType(clang::DeclContext *decl_ctx,
lldb::AccessType access_type, const char *name,
int kind, lldb::LanguageType language,
lldb::AccessType access_type,
llvm::StringRef name, int kind,
lldb::LanguageType language,
ClangASTMetadata *metadata = nullptr,
bool exports_symbols = false);

Expand Down Expand Up @@ -322,8 +323,9 @@ class ClangASTContext : public TypeSystem {

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

CompilerType CreateObjCClass(const char *name, clang::DeclContext *decl_ctx,
bool isForwardDecl, bool isInternal,
CompilerType CreateObjCClass(llvm::StringRef name,
clang::DeclContext *decl_ctx, bool isForwardDecl,
bool isInternal,
ClangASTMetadata *metadata = nullptr);

bool SetTagTypeKind(clang::QualType type, int kind) const;
Expand Down
Expand Up @@ -128,7 +128,7 @@ clang::QualType AppleObjCTypeEncodingParser::BuildAggregate(
if (!lldb_ctx)
return clang::QualType();
CompilerType union_type(lldb_ctx->CreateRecordType(
nullptr, lldb::eAccessPublic, name.c_str(), kind, lldb::eLanguageTypeC));
nullptr, lldb::eAccessPublic, name, kind, lldb::eLanguageTypeC));
if (union_type) {
ClangASTContext::StartTagDeclarationDefinition(union_type);

Expand Down
5 changes: 2 additions & 3 deletions lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
Expand Up @@ -778,9 +778,8 @@ clang::QualType PdbAstBuilder::CreateRecordType(PdbTypeSymId id,
metadata.SetUserID(toOpaqueUid(id));
metadata.SetIsDynamicCXXType(false);

CompilerType ct =
m_clang.CreateRecordType(context, access, uname.c_str(), ttk,
lldb::eLanguageTypeC_plus_plus, &metadata);
CompilerType ct = m_clang.CreateRecordType(
context, access, uname, ttk, lldb::eLanguageTypeC_plus_plus, &metadata);

lldbassert(ct.IsValid());

Expand Down
6 changes: 3 additions & 3 deletions lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
Expand Up @@ -417,9 +417,9 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
metadata.SetUserID(type.getSymIndexId());
metadata.SetIsDynamicCXXType(false);

clang_type = m_ast.CreateRecordType(
decl_context, access, name.c_str(), tag_type_kind,
lldb::eLanguageTypeC_plus_plus, &metadata);
clang_type =
m_ast.CreateRecordType(decl_context, access, name, tag_type_kind,
lldb::eLanguageTypeC_plus_plus, &metadata);
assert(clang_type.IsValid());

auto record_decl =
Expand Down
15 changes: 9 additions & 6 deletions lldb/source/Symbol/ClangASTContext.cpp
Expand Up @@ -1285,9 +1285,12 @@ CompilerType ClangASTContext::GetTypeForDecl(ObjCInterfaceDecl *decl) {

#pragma mark Structure, Unions, Classes

CompilerType ClangASTContext::CreateRecordType(
DeclContext *decl_ctx, AccessType access_type, const char *name, int kind,
LanguageType language, ClangASTMetadata *metadata, bool exports_symbols) {
CompilerType ClangASTContext::CreateRecordType(DeclContext *decl_ctx,
AccessType access_type,
llvm::StringRef name, int kind,
LanguageType language,
ClangASTMetadata *metadata,
bool exports_symbols) {
ASTContext *ast = getASTContext();
assert(ast != nullptr);

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

bool has_name = name && name[0];
bool has_name = !name.empty();

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

#pragma mark Objective-C Classes

CompilerType ClangASTContext::CreateObjCClass(const char *name,
CompilerType ClangASTContext::CreateObjCClass(llvm::StringRef name,
DeclContext *decl_ctx,
bool isForwardDecl,
bool isInternal,
ClangASTMetadata *metadata) {
ASTContext *ast = getASTContext();
assert(ast != nullptr);
assert(name && name[0]);
assert(!name.empty());
if (decl_ctx == nullptr)
decl_ctx = ast->getTranslationUnitDecl();

Expand Down
2 changes: 1 addition & 1 deletion lldb/unittests/Symbol/TestClangASTImporter.cpp
Expand Up @@ -38,7 +38,7 @@ class TestClangASTImporter : public testing::Test {
return std::make_unique<ClangASTContext>(HostInfo::GetTargetTriple());
}

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

0 comments on commit 268f37d

Please sign in to comment.