From b738a69ab8e3da2d48fdf41aa1fa5a5673a7d3a1 Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Thu, 4 Nov 2021 11:20:29 +0100 Subject: [PATCH] [lldb][NFC] StringRef-ify the name parameter in CreateEnumerationType Reviewed By: labath Differential Revision: https://reviews.llvm.org/D113176 --- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp | 3 ++- lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp | 2 +- lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp | 2 +- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 4 ++-- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index b6b99d2..4ac6e16 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -843,7 +843,8 @@ TypeSP DWARFASTParserClang::ParseEnum(const SymbolContext &sc, } clang_type = m_ast.CreateEnumerationType( - attrs.name.GetCString(), GetClangDeclContextContainingDIE(die, nullptr), + attrs.name.GetStringRef(), + GetClangDeclContextContainingDIE(die, nullptr), GetOwningClangModule(die), attrs.decl, enumerator_clang_type, attrs.is_scoped_enum); } else { diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp index 8856c7e..c29fc22 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp @@ -1105,7 +1105,7 @@ clang::QualType PdbAstBuilder::CreateEnumType(PdbTypeSymId id, Declaration declaration; CompilerType enum_ct = m_clang.CreateEnumerationType( - uname.c_str(), decl_context, OptionalClangModuleID(), declaration, + uname, decl_context, OptionalClangModuleID(), declaration, ToCompilerType(underlying_type), er.isScoped()); TypeSystemClang::StartTagDeclarationDefinition(enum_ct); diff --git a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp index 78a0d09..f45287f 100644 --- a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp +++ b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp @@ -497,7 +497,7 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) { // Class). Set it false for now. bool isScoped = false; - ast_enum = m_ast.CreateEnumerationType(name.c_str(), decl_context, + ast_enum = m_ast.CreateEnumerationType(name, decl_context, OptionalClangModuleID(), decl, builtin_type, isScoped); diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index 72b47d0..bb57d53 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -2288,7 +2288,7 @@ CompilerType TypeSystemClang::GetOrCreateStructForIdentifier( #pragma mark Enumeration Types CompilerType TypeSystemClang::CreateEnumerationType( - const char *name, clang::DeclContext *decl_ctx, + llvm::StringRef name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, const Declaration &decl, const CompilerType &integer_clang_type, bool is_scoped) { // TODO: Do something intelligent with the Declaration object passed in @@ -2299,7 +2299,7 @@ CompilerType TypeSystemClang::CreateEnumerationType( // const bool IsFixed = false; EnumDecl *enum_decl = EnumDecl::CreateDeserialized(ast, 0); enum_decl->setDeclContext(decl_ctx); - if (name && name[0]) + if (!name.empty()) enum_decl->setDeclName(&ast.Idents.get(name)); enum_decl->setScoped(is_scoped); enum_decl->setScopedUsingClassTag(is_scoped); diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h index e542e6f..e450b56 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h @@ -417,7 +417,7 @@ public: size_t element_count, bool is_vector); // Enumeration Types - CompilerType CreateEnumerationType(const char *name, + CompilerType CreateEnumerationType(llvm::StringRef name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, const Declaration &decl, -- 2.7.4