[lldb][NFC] Use StringRef in CreateFunctionDeclaration/GetDeclarationName

CreateFunctionDeclaration should just take a StringRef. GetDeclarationName is
(only) used by CreateFunctionDeclaration so that's why now also takes a
StringRef.
This commit is contained in:
Raphael Isemann 2020-08-17 13:35:12 +02:00
parent bc902191d3
commit cfb773c676
5 changed files with 12 additions and 16 deletions

View File

@ -1215,7 +1215,7 @@ TypeSP DWARFASTParserClang::ParseSubroutine(const DWARFDIE &die,
}
if (!function_decl) {
const char *name = attrs.name.GetCString();
llvm::StringRef name = attrs.name.GetStringRef();
// We currently generate function templates with template parameters in
// their name. In order to get closer to the AST that clang generates
@ -1239,7 +1239,7 @@ TypeSP DWARFASTParserClang::ParseSubroutine(const DWARFDIE &die,
template_function_decl = m_ast.CreateFunctionDeclaration(
ignore_containing_context ? m_ast.GetTranslationUnitDecl()
: containing_decl_ctx,
GetOwningClangModule(die), attrs.name.GetCString(), clang_type,
GetOwningClangModule(die), attrs.name.GetStringRef(), clang_type,
attrs.storage, attrs.is_inline);
clang::FunctionTemplateDecl *func_template_decl =
m_ast.CreateFunctionTemplateDecl(

View File

@ -1015,8 +1015,7 @@ PdbAstBuilder::GetOrCreateFunctionDecl(PdbCompilandSymId func_id) {
proc_name.consume_front("::");
clang::FunctionDecl *function_decl = m_clang.CreateFunctionDeclaration(
parent, OptionalClangModuleID(), proc_name.str().c_str(), func_ct,
storage, false);
parent, OptionalClangModuleID(), proc_name, func_ct, storage, false);
lldbassert(m_uid_to_decl.count(toOpaqueUid(func_id)) == 0);
m_uid_to_decl[toOpaqueUid(func_id)] = function_decl;

View File

@ -928,7 +928,7 @@ PDBASTParser::GetDeclForSymbol(const llvm::pdb::PDBSymbol &symbol) {
: clang::StorageClass::SC_None;
auto decl = m_ast.CreateFunctionDeclaration(
decl_context, OptionalClangModuleID(), name.c_str(),
decl_context, OptionalClangModuleID(), name,
type->GetForwardCompilerType(), storage, func->hasInlineAttribute());
std::vector<clang::ParmVarDecl *> params;

View File

@ -1965,11 +1965,8 @@ TypeSystemClang::GetOpaqueCompilerType(clang::ASTContext *ast,
#pragma mark Function Types
clang::DeclarationName
TypeSystemClang::GetDeclarationName(const char *name,
TypeSystemClang::GetDeclarationName(llvm::StringRef name,
const CompilerType &function_clang_type) {
if (!name || !name[0])
return clang::DeclarationName();
clang::OverloadedOperatorKind op_kind = clang::NUM_OVERLOADED_OPERATORS;
if (!IsOperator(name, op_kind) || op_kind == clang::NUM_OVERLOADED_OPERATORS)
return DeclarationName(&getASTContext().Idents.get(
@ -1996,7 +1993,7 @@ TypeSystemClang::GetDeclarationName(const char *name,
FunctionDecl *TypeSystemClang::CreateFunctionDeclaration(
clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module,
const char *name, const CompilerType &function_clang_type,
llvm::StringRef name, const CompilerType &function_clang_type,
clang::StorageClass storage, bool is_inline) {
FunctionDecl *func_decl = nullptr;
ASTContext &ast = getASTContext();

View File

@ -408,11 +408,10 @@ public:
// Function Types
clang::FunctionDecl *
CreateFunctionDeclaration(clang::DeclContext *decl_ctx,
OptionalClangModuleID owning_module,
const char *name, const CompilerType &function_Type,
clang::StorageClass storage, bool is_inline);
clang::FunctionDecl *CreateFunctionDeclaration(
clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module,
llvm::StringRef name, const CompilerType &function_Type,
clang::StorageClass storage, bool is_inline);
CompilerType CreateFunctionType(const CompilerType &result_type,
const CompilerType *args, unsigned num_args,
@ -1053,7 +1052,8 @@ public:
}
clang::DeclarationName
GetDeclarationName(const char *name, const CompilerType &function_clang_type);
GetDeclarationName(llvm::StringRef name,
const CompilerType &function_clang_type);
clang::LangOptions *GetLangOpts() const {
return m_language_options_up.get();