diff options
| author | Raphael Isemann <teemperor@gmail.com> | 2019-12-17 16:00:51 +0100 |
|---|---|---|
| committer | Raphael Isemann <teemperor@gmail.com> | 2019-12-17 16:10:34 +0100 |
| commit | 268f37df6e45c4b0603bd4d964483a0d84da44c1 (patch) | |
| tree | 11c24e6c9aee6c148b58494c603e33279657d0fb | |
| parent | b1d8576b0a9fa1f6a1173c0b5c2f379389e01e3f (diff) | |
| download | bcm5719-llvm-268f37df6e45c4b0603bd4d964483a0d84da44c1.tar.gz bcm5719-llvm-268f37df6e45c4b0603bd4d964483a0d84da44c1.zip | |
[lldb][NFC] Use StringRef in CreateRecordType and CreateObjCClass
6 files changed, 22 insertions, 18 deletions
diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h index 9c37b94219f..6cebd6f3b62 100644 --- a/lldb/include/lldb/Symbol/ClangASTContext.h +++ b/lldb/include/lldb/Symbol/ClangASTContext.h @@ -263,8 +263,9 @@ public: 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 @@ public: 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 6402e80d6f9..76375e22ad6 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 1f7366f5e18..b58550beb04 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 7bf94c64aa4..740b3901686 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 da29750215a..2e66b9a06c6 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 f82fa4a69e4..2a5900c8da5 100644 --- a/lldb/unittests/Symbol/TestClangASTImporter.cpp +++ b/lldb/unittests/Symbol/TestClangASTImporter.cpp @@ -38,7 +38,7 @@ protected: 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); |

