Index: lldb/include/lldb/Expression/FunctionCaller.h =================================================================== --- lldb/include/lldb/Expression/FunctionCaller.h +++ lldb/include/lldb/Expression/FunctionCaller.h @@ -80,7 +80,7 @@ FunctionCaller(ExecutionContextScope &exe_scope, const CompilerType &return_type, const Address &function_address, - const ValueList &arg_value_list, const char *name); + const ValueList &arg_value_list, llvm::StringRef name); /// Destructor ~FunctionCaller() override; Index: lldb/include/lldb/Symbol/CompilerType.h =================================================================== --- lldb/include/lldb/Symbol/CompilerType.h +++ lldb/include/lldb/Symbol/CompilerType.h @@ -325,7 +325,7 @@ /// Lookup a child given a name. This function will match base class names and /// member member names in "clang_type" only, not descendants. - uint32_t GetIndexOfChildWithName(const char *name, + uint32_t GetIndexOfChildWithName(llvm::StringRef name, bool omit_empty_base_classes) const; /// Lookup a child member given a name. This function will match member names @@ -335,7 +335,8 @@ /// vector> /// so we catch all names that match a given child name, not just the first. size_t - GetIndexOfChildMemberWithName(const char *name, bool omit_empty_base_classes, + GetIndexOfChildMemberWithName(llvm::StringRef name, + bool omit_empty_base_classes, std::vector &child_indexes) const; size_t GetNumTemplateArguments() const; Index: lldb/include/lldb/Symbol/TypeSystem.h =================================================================== --- lldb/include/lldb/Symbol/TypeSystem.h +++ lldb/include/lldb/Symbol/TypeSystem.h @@ -267,7 +267,7 @@ /// \param opaque_payload The m_payload field of Type, which may /// carry TypeSystem-specific extra information. virtual CompilerType CreateTypedef(lldb::opaque_compiler_type_t type, - const char *name, + llvm::StringRef name, const CompilerDeclContext &decl_ctx, uint32_t opaque_payload); @@ -333,7 +333,7 @@ // Lookup a child given a name. This function will match base class names and // member member names in "clang_type" only, not descendants. virtual uint32_t GetIndexOfChildWithName(lldb::opaque_compiler_type_t type, - const char *name, + llvm::StringRef name, bool omit_empty_base_classes) = 0; // Lookup a child member given a name. This function will match member names @@ -342,10 +342,9 @@ // TODO: Return all matches for a given name by returning a // vector> // so we catch all names that match a given child name, not just the first. - virtual size_t - GetIndexOfChildMemberWithName(lldb::opaque_compiler_type_t type, - const char *name, bool omit_empty_base_classes, - std::vector &child_indexes) = 0; + virtual size_t GetIndexOfChildMemberWithName( + lldb::opaque_compiler_type_t type, llvm::StringRef name, + bool omit_empty_base_classes, std::vector &child_indexes) = 0; virtual size_t GetNumTemplateArguments(lldb::opaque_compiler_type_t type); @@ -465,7 +464,7 @@ virtual FunctionCaller *GetFunctionCaller(const CompilerType &return_type, const Address &function_address, const ValueList &arg_value_list, - const char *name) { + llvm::StringRef name) { return nullptr; } Index: lldb/source/Expression/FunctionCaller.cpp =================================================================== --- lldb/source/Expression/FunctionCaller.cpp +++ lldb/source/Expression/FunctionCaller.cpp @@ -36,9 +36,9 @@ const CompilerType &return_type, const Address &functionAddress, const ValueList &arg_value_list, - const char *name) + llvm::StringRef name) : Expression(exe_scope), m_execution_unit_sp(), m_parser(), - m_jit_module_wp(), m_name(name ? name : ""), + m_jit_module_wp(), m_name(name.empty() ? "" : name), m_function_ptr(nullptr), m_function_addr(functionAddress), m_function_return_type(return_type), m_wrapper_function_name("__lldb_caller_function"), Index: lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.h =================================================================== --- lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.h +++ lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.h @@ -113,7 +113,7 @@ ClangFunctionCaller(ExecutionContextScope &exe_scope, const CompilerType &return_type, const Address &function_address, - const ValueList &arg_value_list, const char *name); + const ValueList &arg_value_list, llvm::StringRef name); ~ClangFunctionCaller() override; Index: lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp =================================================================== --- lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp +++ lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp @@ -49,7 +49,7 @@ const CompilerType &return_type, const Address &functionAddress, const ValueList &arg_value_list, - const char *name) + llvm::StringRef name) : FunctionCaller(exe_scope, return_type, functionAddress, arg_value_list, name), m_type_system_helper(*this) { Index: lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp +++ lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp @@ -962,7 +962,7 @@ continue; clang::ParmVarDecl *param = m_ast.CreateParameterDeclaration( - decl, OptionalClangModuleID(), nullptr, + decl, OptionalClangModuleID(), /*name=*/llvm::StringRef(), arg_type->GetForwardCompilerType(), clang::SC_None, true); if (param) params.push_back(param); Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h =================================================================== --- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h +++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h @@ -414,11 +414,10 @@ type_quals, clang::CC_C); } - clang::ParmVarDecl * - CreateParameterDeclaration(clang::DeclContext *decl_ctx, - OptionalClangModuleID owning_module, - const char *name, const CompilerType ¶m_type, - int storage, bool add_decl = false); + clang::ParmVarDecl *CreateParameterDeclaration( + clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, + llvm::StringRef name, const CompilerType ¶m_type, int storage, + bool add_decl = false); void SetFunctionParameters(clang::FunctionDecl *function_decl, clang::ParmVarDecl **params, unsigned num_params); @@ -431,7 +430,7 @@ 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, @@ -721,7 +720,7 @@ /// "typedef_name" as the name and "decl_ctx" as the decl context. /// \param opaque_payload is an opaque TypePayloadClang. CompilerType CreateTypedef(lldb::opaque_compiler_type_t type, - const char *name, + llvm::StringRef name, const CompilerDeclContext &decl_ctx, uint32_t opaque_payload) override; @@ -807,7 +806,7 @@ // Lookup a child given a name. This function will match base class names and // member member names in "clang_type" only, not descendants. uint32_t GetIndexOfChildWithName(lldb::opaque_compiler_type_t type, - const char *name, + llvm::StringRef name, bool omit_empty_base_classes) override; // Lookup a child member given a name. This function will match member names @@ -818,7 +817,8 @@ // so we catch all names that match a given child name, not just the first. size_t GetIndexOfChildMemberWithName(lldb::opaque_compiler_type_t type, - const char *name, bool omit_empty_base_classes, + llvm::StringRef name, + bool omit_empty_base_classes, std::vector &child_indexes) override; size_t GetNumTemplateArguments(lldb::opaque_compiler_type_t type) override; @@ -924,11 +924,11 @@ // Modifying Enumeration types clang::EnumConstantDecl *AddEnumerationValueToEnumerationType( - const CompilerType &enum_type, const Declaration &decl, const char *name, - int64_t enum_value, uint32_t enum_value_bit_size); + const CompilerType &enum_type, const Declaration &decl, + llvm::StringRef name, int64_t enum_value, uint32_t enum_value_bit_size); clang::EnumConstantDecl *AddEnumerationValueToEnumerationType( - const CompilerType &enum_type, const Declaration &decl, const char *name, - const llvm::APSInt &value); + const CompilerType &enum_type, const Declaration &decl, + llvm::StringRef name, const llvm::APSInt &value); /// Returns the underlying integer type for an enum type. If the given type /// is invalid or not an enum-type, the function returns an invalid @@ -1020,7 +1020,7 @@ clang::VarDecl *CreateVariableDeclaration(clang::DeclContext *decl_context, OptionalClangModuleID owning_module, - const char *name, + llvm::StringRef name, clang::QualType type); static lldb::opaque_compiler_type_t @@ -1184,7 +1184,7 @@ FunctionCaller *GetFunctionCaller(const CompilerType &return_type, const Address &function_address, const ValueList &arg_value_list, - const char *name) override; + llvm::StringRef name) override; std::unique_ptr CreateUtilityFunction(std::string text, std::string name) override; Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp =================================================================== --- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -1879,12 +1879,12 @@ clang::VarDecl *TypeSystemClang::CreateVariableDeclaration( clang::DeclContext *decl_context, OptionalClangModuleID owning_module, - const char *name, clang::QualType type) { + llvm::StringRef name, clang::QualType type) { if (decl_context) { clang::VarDecl *var_decl = clang::VarDecl::CreateDeserialized(getASTContext(), 0); var_decl->setDeclContext(decl_context); - if (name && name[0]) + if (!name.empty()) var_decl->setDeclName(&getASTContext().Idents.getOwn(name)); var_decl->setType(type); SetOwningModule(var_decl, owning_module); @@ -2099,12 +2099,12 @@ ParmVarDecl *TypeSystemClang::CreateParameterDeclaration( clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, - const char *name, const CompilerType ¶m_type, int storage, + llvm::StringRef name, const CompilerType ¶m_type, int storage, bool add_decl) { ASTContext &ast = getASTContext(); auto *decl = ParmVarDecl::CreateDeserialized(ast, 0); decl->setDeclContext(decl_ctx); - if (name && name[0]) + if (!name.empty()) decl->setDeclName(&ast.Idents.get(name)); decl->setType(ClangUtil::GetQualType(param_type)); decl->setStorageClass(static_cast(storage)); @@ -2198,7 +2198,7 @@ #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 @@ -2209,7 +2209,7 @@ // 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); @@ -4503,9 +4503,9 @@ } CompilerType TypeSystemClang::CreateTypedef( - lldb::opaque_compiler_type_t type, const char *typedef_name, + lldb::opaque_compiler_type_t type, llvm::StringRef typedef_name, const CompilerDeclContext &compiler_decl_ctx, uint32_t payload) { - if (type && typedef_name && typedef_name[0]) { + if (type && !typedef_name.empty()) { clang::ASTContext &clang_ast = getASTContext(); clang::QualType qual_type(GetQualType(type)); @@ -6552,9 +6552,9 @@ // index 1 is the child index for "m_b" within class A size_t TypeSystemClang::GetIndexOfChildMemberWithName( - lldb::opaque_compiler_type_t type, const char *name, + lldb::opaque_compiler_type_t type, llvm::StringRef name, bool omit_empty_base_classes, std::vector &child_indexes) { - if (type && name && name[0]) { + if (type && !name.empty()) { clang::QualType qual_type = RemoveWrappingTypes(GetCanonicalQualType(type)); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { @@ -6572,7 +6572,6 @@ // Try and find a field that matches NAME clang::RecordDecl::field_iterator field, field_end; - llvm::StringRef name_sref(name); for (field = record_decl->field_begin(), field_end = record_decl->field_end(); field != field_end; ++field, ++child_idx) { @@ -6585,7 +6584,7 @@ return child_indexes.size(); child_indexes.pop_back(); - } else if (field_name.equals(name_sref)) { + } else if (field_name.equals(name)) { // We have to add on the number of base classes to this index! child_indexes.push_back( child_idx + TypeSystemClang::GetNumBaseClasses( @@ -6598,8 +6597,7 @@ const clang::RecordDecl *parent_record_decl = cxx_record_decl; // Didn't find things easily, lets let clang do its thang... - clang::IdentifierInfo &ident_ref = - getASTContext().Idents.get(name_sref); + clang::IdentifierInfo &ident_ref = getASTContext().Idents.get(name); clang::DeclarationName decl_name(&ident_ref); clang::CXXBasePaths paths; @@ -6654,7 +6652,6 @@ case clang::Type::ObjCObject: case clang::Type::ObjCInterface: if (GetCompleteType(type)) { - llvm::StringRef name_sref(name); const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast(qual_type.getTypePtr()); assert(objc_class_type); @@ -6673,7 +6670,7 @@ ivar_pos != ivar_end; ++ivar_pos, ++child_idx) { const clang::ObjCIvarDecl *ivar_decl = *ivar_pos; - if (ivar_decl->getName().equals(name_sref)) { + if (ivar_decl->getName().equals(name)) { if ((!omit_empty_base_classes && superclass_interface_decl) || (omit_empty_base_classes && ObjCDeclHasIVars(superclass_interface_decl, true))) @@ -6792,9 +6789,9 @@ uint32_t TypeSystemClang::GetIndexOfChildWithName(lldb::opaque_compiler_type_t type, - const char *name, + llvm::StringRef name, bool omit_empty_base_classes) { - if (type && name && name[0]) { + if (type && !name.empty()) { clang::QualType qual_type = RemoveWrappingTypes(GetCanonicalQualType(type)); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); @@ -6852,7 +6849,6 @@ case clang::Type::ObjCObject: case clang::Type::ObjCInterface: if (GetCompleteType(type)) { - llvm::StringRef name_sref(name); const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast(qual_type.getTypePtr()); assert(objc_class_type); @@ -6871,7 +6867,7 @@ ivar_pos != ivar_end; ++ivar_pos, ++child_idx) { const clang::ObjCIvarDecl *ivar_decl = *ivar_pos; - if (ivar_decl->getName().equals(name_sref)) { + if (ivar_decl->getName().equals(name)) { if ((!omit_empty_base_classes && superclass_interface_decl) || (omit_empty_base_classes && ObjCDeclHasIVars(superclass_interface_decl, true))) @@ -6882,7 +6878,7 @@ } if (superclass_interface_decl) { - if (superclass_interface_decl->getName().equals(name_sref)) + if (superclass_interface_decl->getName().equals(name)) return 0; } } @@ -8202,10 +8198,10 @@ } clang::EnumConstantDecl *TypeSystemClang::AddEnumerationValueToEnumerationType( - const CompilerType &enum_type, const Declaration &decl, const char *name, - const llvm::APSInt &value) { + const CompilerType &enum_type, const Declaration &decl, + llvm::StringRef name, const llvm::APSInt &value) { - if (!enum_type || ConstString(name).IsEmpty()) + if (!enum_type || name.empty()) return nullptr; lldbassert(enum_type.GetTypeSystem() == static_cast(this)); @@ -8232,8 +8228,7 @@ clang::EnumConstantDecl *enumerator_decl = clang::EnumConstantDecl::CreateDeserialized(getASTContext(), 0); enumerator_decl->setDeclContext(enutype->getDecl()); - if (name && name[0]) - enumerator_decl->setDeclName(&getASTContext().Idents.get(name)); + enumerator_decl->setDeclName(&getASTContext().Idents.get(name)); enumerator_decl->setType(clang::QualType(enutype, 0)); enumerator_decl->setInitVal(value); SetMemberOwningModule(enumerator_decl, enutype->getDecl()); @@ -8248,8 +8243,8 @@ } clang::EnumConstantDecl *TypeSystemClang::AddEnumerationValueToEnumerationType( - const CompilerType &enum_type, const Declaration &decl, const char *name, - int64_t enum_value, uint32_t enum_value_bit_size) { + const CompilerType &enum_type, const Declaration &decl, + llvm::StringRef name, int64_t enum_value, uint32_t enum_value_bit_size) { CompilerType underlying_type = GetEnumerationIntegerType(enum_type); bool is_signed = false; underlying_type.IsIntegerType(is_signed); @@ -9700,7 +9695,7 @@ FunctionCaller *ScratchTypeSystemClang::GetFunctionCaller( const CompilerType &return_type, const Address &function_address, - const ValueList &arg_value_list, const char *name) { + const ValueList &arg_value_list, llvm::StringRef name) { TargetSP target_sp = m_target_wp.lock(); if (!target_sp) return nullptr; Index: lldb/source/Symbol/CompilerType.cpp =================================================================== --- lldb/source/Symbol/CompilerType.cpp +++ lldb/source/Symbol/CompilerType.cpp @@ -650,9 +650,9 @@ // index 1 is the child index for "m_b" within class A size_t CompilerType::GetIndexOfChildMemberWithName( - const char *name, bool omit_empty_base_classes, + llvm::StringRef name, bool omit_empty_base_classes, std::vector &child_indexes) const { - if (IsValid() && name && name[0]) { + if (IsValid() && !name.empty()) { return m_type_system->GetIndexOfChildMemberWithName( m_type, name, omit_empty_base_classes, child_indexes); } @@ -709,9 +709,9 @@ // matches can include base class names. uint32_t -CompilerType::GetIndexOfChildWithName(const char *name, +CompilerType::GetIndexOfChildWithName(llvm::StringRef name, bool omit_empty_base_classes) const { - if (IsValid() && name && name[0]) { + if (IsValid() && !name.empty()) { return m_type_system->GetIndexOfChildWithName(m_type, name, omit_empty_base_classes); } Index: lldb/source/Symbol/TypeSystem.cpp =================================================================== --- lldb/source/Symbol/TypeSystem.cpp +++ lldb/source/Symbol/TypeSystem.cpp @@ -104,7 +104,7 @@ } CompilerType TypeSystem::CreateTypedef(lldb::opaque_compiler_type_t type, - const char *name, + llvm::StringRef name, const CompilerDeclContext &decl_ctx, uint32_t opaque_payload) { return CompilerType();