[Lldb-commits] [lldb] 268f37d - [lldb][NFC] Use StringRef in CreateRecordType and CreateObjCClass
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Tue Dec 17 07:11:14 PST 2019
Author: Raphael Isemann
Date: 2019-12-17T16:10:34+01:00
New Revision: 268f37df6e45c4b0603bd4d964483a0d84da44c1
URL: https://github.com/llvm/llvm-project/commit/268f37df6e45c4b0603bd4d964483a0d84da44c1
DIFF: https://github.com/llvm/llvm-project/commit/268f37df6e45c4b0603bd4d964483a0d84da44c1.diff
LOG: [lldb][NFC] Use StringRef in CreateRecordType and CreateObjCClass
Added:
Modified:
lldb/include/lldb/Symbol/ClangASTContext.h
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
lldb/source/Symbol/ClangASTContext.cpp
lldb/unittests/Symbol/TestClangASTImporter.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h
index 9c37b94219f0..6cebd6f3b62a 100644
--- a/lldb/include/lldb/Symbol/ClangASTContext.h
+++ b/lldb/include/lldb/Symbol/ClangASTContext.h
@@ -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);
@@ -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;
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
index 6402e80d6f98..76375e22ad6a 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
@@ -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);
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
index 1f7366f5e184..b58550beb04a 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
@@ -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());
diff --git a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
index 7bf94c64aa4f..740b39016862 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
+++ b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
@@ -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 =
diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp
index da29750215aa..2e66b9a06c64 100644
--- a/lldb/source/Symbol/ClangASTContext.cpp
+++ b/lldb/source/Symbol/ClangASTContext.cpp
@@ -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);
@@ -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(),
@@ -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();
diff --git a/lldb/unittests/Symbol/TestClangASTImporter.cpp b/lldb/unittests/Symbol/TestClangASTImporter.cpp
index f82fa4a69e42..2a5900c8da55 100644
--- a/lldb/unittests/Symbol/TestClangASTImporter.cpp
+++ b/lldb/unittests/Symbol/TestClangASTImporter.cpp
@@ -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);
More information about the lldb-commits
mailing list