Index: clang-tools-extra/clang-query/tool/ClangQuery.cpp =================================================================== --- clang-tools-extra/clang-query/tool/ClangQuery.cpp +++ clang-tools-extra/clang-query/tool/ClangQuery.cpp @@ -80,7 +80,7 @@ for (cl::list::iterator I = Commands.begin(), E = Commands.end(); I != E; ++I) { - QueryRef Q = QueryParser::parse(StringRef(I->c_str()), QS); + QueryRef Q = QueryParser::parse(*I, QS); if (!Q->run(llvm::outs(), QS)) return 1; } @@ -97,7 +97,7 @@ std::string Line; std::getline(Input, Line); - QueryRef Q = QueryParser::parse(StringRef(Line.c_str()), QS); + QueryRef Q = QueryParser::parse(Line, QS); if (!Q->run(llvm::outs(), QS)) return 1; } Index: clang/lib/CodeGen/CGObjCGNU.cpp =================================================================== --- clang/lib/CodeGen/CGObjCGNU.cpp +++ clang/lib/CodeGen/CGObjCGNU.cpp @@ -2646,7 +2646,7 @@ for (std::vector::iterator iter = ClassAliases.begin(); iter != ClassAliases.end(); ++iter) { llvm::Constant *TheClass = TheModule.getGlobalVariable( - llvm::StringRef(("_OBJC_CLASS_" + iter->first).c_str()), true); + ("_OBJC_CLASS_" + iter->first), true); if (TheClass) { TheClass = llvm::ConstantExpr::getBitCast(TheClass, PtrTy); Builder.CreateCall(RegisterAlias, Index: clang/lib/CodeGen/TargetInfo.cpp =================================================================== --- clang/lib/CodeGen/TargetInfo.cpp +++ clang/lib/CodeGen/TargetInfo.cpp @@ -7456,7 +7456,7 @@ std::string Enc; public: FieldEncoding(bool b, SmallStringEnc &e) : HasName(b), Enc(e.c_str()) {} - StringRef str() { return llvm::StringRef(Enc.c_str()); } + StringRef str() { return Enc; } bool operator<(const FieldEncoding &rhs) const { if (HasName != rhs.HasName) return HasName; return Enc < rhs.Enc; @@ -7622,7 +7622,7 @@ E.State = IncompleteUsed; ++IncompleteUsedCount; } - return llvm::StringRef(E.Str.c_str()); + return E.Str; } /// The XCore ABI includes a type information section that communicates symbol Index: clang/lib/Driver/Driver.cpp =================================================================== --- clang/lib/Driver/Driver.cpp +++ clang/lib/Driver/Driver.cpp @@ -870,8 +870,8 @@ if (!ShowHidden) ExcludedFlagsBitmask |= HelpHidden; - getOpts().PrintHelp(llvm::outs(), llvm::StringRef(Name.c_str()), - llvm::StringRef(DriverTitle.c_str()), + getOpts().PrintHelp(llvm::outs(), Name, + DriverTitle, IncludedFlagsBitmask, ExcludedFlagsBitmask); } Index: clang/lib/Driver/Job.cpp =================================================================== --- clang/lib/Driver/Job.cpp +++ clang/lib/Driver/Job.cpp @@ -180,7 +180,7 @@ // Replace the input file name with the crashinfo's file name. OS << ' '; StringRef ShortName = llvm::sys::path::filename(CrashInfo->Filename); - printArg(OS, llvm::StringRef(ShortName.str().c_str()), Quote); + printArg(OS, ShortName.str(), Quote); continue; } } @@ -193,7 +193,7 @@ OS << ' '; printArg(OS, "-ivfsoverlay", Quote); OS << ' '; - printArg(OS, llvm::StringRef(CrashInfo->VFSPath.str().c_str()), Quote); + printArg(OS, CrashInfo->VFSPath.str(), Quote); // Insert -fmodules-cache-path and use the relative module directory // .cache/vfs/modules where we already dumped the modules. @@ -205,7 +205,7 @@ ModCachePath.append(RelModCacheDir.c_str()); OS << ' '; - printArg(OS, llvm::StringRef(ModCachePath.c_str()), Quote); + printArg(OS, ModCachePath, Quote); } if (!ResponseFile.empty()) { Index: clang/lib/Driver/ToolChain.cpp =================================================================== --- clang/lib/Driver/ToolChain.cpp +++ clang/lib/Driver/ToolChain.cpp @@ -360,7 +360,7 @@ LinkerName.append(UseLinker); std::string LinkerPath( - GetProgramPath(StringRef(LinkerName.c_str()))); + GetProgramPath(LinkerName)); if (llvm::sys::fs::exists(LinkerPath)) return LinkerPath; } Index: clang/lib/Driver/Tools.cpp =================================================================== --- clang/lib/Driver/Tools.cpp +++ clang/lib/Driver/Tools.cpp @@ -4833,7 +4833,7 @@ // Pass the path to compiler resource files. CmdArgs.push_back("-resource-dir"); - CmdArgs.push_back(llvm::StringRef(D.ResourceDir.c_str())); + CmdArgs.push_back(D.ResourceDir); Args.AddLastArg(CmdArgs, options::OPT_working_directory); @@ -7156,7 +7156,7 @@ } auto Exec = - Args.MakeArgString(HTC.GetProgramPath(llvm::StringRef(AsName.c_str()))); + Args.MakeArgString(HTC.GetProgramPath(AsName)); C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs)); } @@ -7204,7 +7204,7 @@ CmdArgs.push_back("-r"); for (const auto &Opt : HTC.ExtraOpts) - CmdArgs.push_back(llvm::StringRef(Opt.c_str())); + CmdArgs.push_back(Opt); CmdArgs.push_back("-march=hexagon"); std::string CpuVer = @@ -9694,7 +9694,7 @@ arm::appendEBLinkFlags(Args, CmdArgs, Triple); for (const auto &Opt : ToolChain.ExtraOpts) - CmdArgs.push_back(llvm::StringRef(Opt.c_str())); + CmdArgs.push_back(Opt); if (!Args.hasArg(options::OPT_static)) { CmdArgs.push_back("--eh-frame-hdr"); @@ -10579,7 +10579,7 @@ } else { linkPath = Linker; llvm::sys::path::replace_extension(linkPath, "exe"); - linkPath = TC.GetProgramPath(llvm::StringRef(linkPath.c_str())); + linkPath = TC.GetProgramPath(linkPath); } StringRef Exec = Args.MakeArgString(linkPath); Index: clang/lib/Frontend/CompilerInstance.cpp =================================================================== --- clang/lib/Frontend/CompilerInstance.cpp +++ clang/lib/Frontend/CompilerInstance.cpp @@ -1317,7 +1317,7 @@ ModuleManager = new ASTReader( getPreprocessor(), getASTContext(), getPCHContainerReader(), getFrontendOpts().ModuleFileExtensions, - llvm::StringRef(Sysroot.empty() ? "" : Sysroot.c_str()), + Sysroot.empty() ? "" : Sysroot, PPOpts.DisablePCHValidation, /*AllowASTWithCompilerErrors=*/false, /*AllowConfigurationMismatch=*/false, Index: clang/lib/Frontend/CompilerInvocation.cpp =================================================================== --- clang/lib/Frontend/CompilerInvocation.cpp +++ clang/lib/Frontend/CompilerInvocation.cpp @@ -1455,7 +1455,7 @@ Path = Buffer.str(); } - Opts.AddPath(llvm::StringRef(Path.c_str()), Group, IsFramework, + Opts.AddPath(Path, Group, IsFramework, /*IgnoreSysroot*/ true); IsIndexHeaderMap = false; } Index: clang/lib/Frontend/FrontendActions.cpp =================================================================== --- clang/lib/Frontend/FrontendActions.cpp +++ clang/lib/Frontend/FrontendActions.cpp @@ -455,7 +455,7 @@ std::unique_ptr Reader(new ASTReader( CI.getPreprocessor(), CI.getASTContext(), CI.getPCHContainerReader(), CI.getFrontendOpts().ModuleFileExtensions, - llvm::StringRef(Sysroot.empty() ? "" : Sysroot.c_str()), + Sysroot.empty() ? "" : Sysroot, /*DisableValidation*/ false, /*AllowPCHWithCompilerErrors*/ false, /*AllowConfigurationMismatch*/ true, Index: clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp =================================================================== --- clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp +++ clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp @@ -865,7 +865,7 @@ RecName += "_IMPL"; RecordDecl *RD = RecordDecl::Create( *Context, TTK_Struct, TUDecl, SourceLocation(), SourceLocation(), - &Context->Idents.get(llvm::StringRef(RecName.c_str()))); + &Context->Idents.get(RecName)); QualType PtrStructIMPL = Context->getPointerType(Context->getTagDeclType(RD)); unsigned UnsignedIntSize = static_cast(Context->getTypeSize(Context->UnsignedIntTy)); @@ -5303,7 +5303,7 @@ VarDecl *NewVD = VarDecl::Create(*Context, TUDecl, SourceLocation(), SourceLocation(), - &Context->Idents.get(llvm::StringRef(DescData.c_str())), + &Context->Idents.get(DescData), Context->VoidPtrTy, nullptr, SC_Static); UnaryOperator *DescRefExpr = new (Context) UnaryOperator(new (Context) DeclRefExpr(NewVD, false, @@ -7523,7 +7523,7 @@ RecName += "_IMPL"; RecordDecl *RD = RecordDecl::Create( *Context, TTK_Struct, TUDecl, SourceLocation(), SourceLocation(), - &Context->Idents.get(llvm::StringRef(RecName.c_str()))); + &Context->Idents.get(RecName)); QualType PtrStructIMPL = Context->getPointerType(Context->getTagDeclType(RD)); unsigned UnsignedIntSize = static_cast(Context->getTypeSize(Context->UnsignedIntTy)); Index: clang/lib/Frontend/Rewrite/RewriteObjC.cpp =================================================================== --- clang/lib/Frontend/Rewrite/RewriteObjC.cpp +++ clang/lib/Frontend/Rewrite/RewriteObjC.cpp @@ -4428,7 +4428,7 @@ VarDecl *NewVD = VarDecl::Create(*Context, TUDecl, SourceLocation(), SourceLocation(), - &Context->Idents.get(llvm::StringRef(DescData.c_str())), + &Context->Idents.get(DescData), Context->VoidPtrTy, nullptr, SC_Static); UnaryOperator *DescRefExpr = new (Context) UnaryOperator(new (Context) DeclRefExpr(NewVD, false, @@ -5650,12 +5650,12 @@ } RewriteObjCMethodsMetaData(InstanceMethods.begin(), InstanceMethods.end(), true, "CATEGORY_", - llvm::StringRef(FullCategoryName.c_str()), Result); + FullCategoryName, Result); // Build _objc_method_list for class's class methods if needed RewriteObjCMethodsMetaData(IDecl->classmeth_begin(), IDecl->classmeth_end(), false, "CATEGORY_", - llvm::StringRef(FullCategoryName.c_str()), Result); + FullCategoryName, Result); // Protocols referenced in class declaration? // Null CDecl is case of a category implementation with no category interface Index: clang/lib/Lex/PPDirectives.cpp =================================================================== --- clang/lib/Lex/PPDirectives.cpp +++ clang/lib/Lex/PPDirectives.cpp @@ -1801,7 +1801,7 @@ } const FileEntry *File = LookupFile( FilenameLoc, - LangOpts.MSVCCompat ? StringRef(NormalizedPath.c_str()) : Filename, + LangOpts.MSVCCompat ? StringRef(NormalizedPath) : Filename, isAngled, LookupFrom, LookupFromFile, CurDir, Callbacks ? &SearchPath : nullptr, Callbacks ? &RelativePath : nullptr, &SuggestedModule); @@ -1819,7 +1819,7 @@ // Try the lookup again, skipping the cache. File = LookupFile(FilenameLoc, - LangOpts.MSVCCompat ? StringRef(NormalizedPath.c_str()) + LangOpts.MSVCCompat ? StringRef(NormalizedPath) : Filename, isAngled, LookupFrom, LookupFromFile, CurDir, nullptr, nullptr, &SuggestedModule, /*SkipCache*/ true); @@ -1834,7 +1834,7 @@ if (isAngled) { File = LookupFile( FilenameLoc, - LangOpts.MSVCCompat ? StringRef(NormalizedPath.c_str()) : Filename, + LangOpts.MSVCCompat ? StringRef(NormalizedPath) : Filename, false, LookupFrom, LookupFromFile, CurDir, Callbacks ? &SearchPath : nullptr, Callbacks ? &RelativePath : nullptr, &SuggestedModule); @@ -1945,7 +1945,7 @@ // Notify the callback object that we've seen an inclusion directive. Callbacks->InclusionDirective( HashLoc, IncludeTok, - LangOpts.MSVCCompat ? StringRef(NormalizedPath.c_str()) : Filename, + LangOpts.MSVCCompat ? StringRef(NormalizedPath) : Filename, isAngled, FilenameRange, File, SearchPath, RelativePath, ShouldEnter ? nullptr : SuggestedModule.getModule()); } @@ -1969,7 +1969,7 @@ File && !File->tryGetRealPathName().empty(); if (CheckIncludePathPortability) { - StringRef Name = LangOpts.MSVCCompat ? NormalizedPath.str() : Filename; + StringRef Name = LangOpts.MSVCCompat ? StringRef(NormalizedPath) : Filename; StringRef RealPathName = File->tryGetRealPathName(); SmallVector Components(llvm::sys::path::begin(Name), llvm::sys::path::end(Name)); Index: clang/lib/Parse/ParseDeclCXX.cpp =================================================================== --- clang/lib/Parse/ParseDeclCXX.cpp +++ clang/lib/Parse/ParseDeclCXX.cpp @@ -2238,7 +2238,7 @@ std::string Name(FixItName); Name += " "; Insertion = FixItHint::CreateInsertion( - VS.getFirstLocation(), llvm::StringRef(Name.c_str())); + VS.getFirstLocation(), Name); Function.TypeQuals |= TypeQual; *QualifierLoc = SpecLoc.getRawEncoding(); } Index: clang/lib/StaticAnalyzer/Checkers/ValistChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/ValistChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/ValistChecker.cpp @@ -149,7 +149,7 @@ SmallString<80> Errmsg("Function '"); Errmsg += FuncInfo.Func.getFunctionName(); Errmsg += "' is called with an uninitialized va_list argument"; - reportUninitializedAccess(VAList, llvm::StringRef(Errmsg.c_str()), C); + reportUninitializedAccess(VAList, Errmsg, C); break; } } Index: clang/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp =================================================================== --- clang/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp +++ clang/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp @@ -107,7 +107,7 @@ for (unsigned i = 0, e = opts.CheckersControlList.size(); i != e; ++i) { const std::pair &opt = opts.CheckersControlList[i]; checkerOpts.push_back( - CheckerOptInfo(llvm::StringRef(opt.first.c_str()), opt.second)); + CheckerOptInfo(opt.first, opt.second)); } return checkerOpts; } Index: clang/unittests/AST/ASTImporterTest.cpp =================================================================== --- clang/unittests/AST/ASTImporterTest.cpp +++ clang/unittests/AST/ASTImporterTest.cpp @@ -72,7 +72,7 @@ vfs::InMemoryFileSystem *MFS = static_cast( OFS->overlays_begin()->get()); MFS->addFile(InputFileName, 0, llvm::MemoryBuffer::getMemBuffer( - llvm::StringRef(FromCode.c_str()))); + FromCode)); ASTImporter Importer(ToCtx, ToAST->getFileManager(), FromCtx, FromAST->getFileManager(), false); Index: lldb/source/API/SBHostOS.cpp =================================================================== --- lldb/source/API/SBHostOS.cpp +++ lldb/source/API/SBHostOS.cpp @@ -51,7 +51,7 @@ llvm::SmallString<64> home_dir_path; llvm::sys::path::home_directory(home_dir_path); - FileSpec homedir(llvm::StringRef(home_dir_path.c_str()), true); + FileSpec homedir(home_dir_path, true); sb_fspec.SetFileSpec(homedir); return sb_fspec; Index: lldb/source/Breakpoint/BreakpointResolverAddress.cpp =================================================================== --- lldb/source/Breakpoint/BreakpointResolverAddress.cpp +++ lldb/source/Breakpoint/BreakpointResolverAddress.cpp @@ -67,7 +67,7 @@ error.SetErrorString("BRA::CFSD: Couldn't read module name entry."); return nullptr; } - module_filespec.SetFile(llvm::StringRef(module_name.c_str()), false); + module_filespec.SetFile(module_name, false); } return new BreakpointResolverAddress(bkpt, address, module_filespec); } Index: lldb/source/Breakpoint/BreakpointResolverFileLine.cpp =================================================================== --- lldb/source/Breakpoint/BreakpointResolverFileLine.cpp +++ lldb/source/Breakpoint/BreakpointResolverFileLine.cpp @@ -83,7 +83,7 @@ return nullptr; } - FileSpec file_spec(llvm::StringRef(filename.c_str()), false); + FileSpec file_spec(filename, false); return new BreakpointResolverFileLine(bkpt, file_spec, line_no, offset, check_inlines, skip_prologue, Index: lldb/source/Commands/CommandCompletions.cpp =================================================================== --- lldb/source/Commands/CommandCompletions.cpp +++ lldb/source/Commands/CommandCompletions.cpp @@ -273,7 +273,7 @@ parameters.end_ptr = end_ptr; parameters.baselen = baselen; - FileSpec::EnumerateDirectory(llvm::StringRef(containing_part.c_str()), true, + FileSpec::EnumerateDirectory(containing_part, true, true, true, DiskFilesOrDirectoriesCallback, ¶meters); @@ -415,7 +415,7 @@ match_start_point, max_return_elements, matches), m_include_support_files(include_support_files), m_matching_files() { - FileSpec partial_spec(llvm::StringRef(m_completion_str.c_str()), false); + FileSpec partial_spec(m_completion_str, false); m_file_name = partial_spec.GetFilename().GetCString(); m_dir_name = partial_spec.GetDirectory().GetCString(); } @@ -561,7 +561,7 @@ : CommandCompletions::Completer(interpreter, completion_str, match_start_point, max_return_elements, matches) { - FileSpec partial_spec(llvm::StringRef(m_completion_str.c_str()), false); + FileSpec partial_spec(m_completion_str, false); m_file_name = partial_spec.GetFilename().GetCString(); m_dir_name = partial_spec.GetDirectory().GetCString(); } Index: lldb/source/Commands/CommandObjectBreakpoint.cpp =================================================================== --- lldb/source/Commands/CommandObjectBreakpoint.cpp +++ lldb/source/Commands/CommandObjectBreakpoint.cpp @@ -2306,7 +2306,7 @@ } } Error error = target->SerializeBreakpointsToFile( - FileSpec(llvm::StringRef(m_options.m_filename.c_str()), true), + FileSpec(m_options.m_filename, true), valid_bp_ids, m_options.m_append); if (!error.Success()) { result.AppendErrorWithFormat("error serializing breakpoints: %s.", Index: lldb/source/Commands/CommandObjectCommands.cpp =================================================================== --- lldb/source/Commands/CommandObjectCommands.cpp +++ lldb/source/Commands/CommandObjectCommands.cpp @@ -635,7 +635,7 @@ } // Verify that the command is alias-able. - if (m_interpreter.CommandExists(llvm::StringRef(alias_command.c_str()))) { + if (m_interpreter.CommandExists(alias_command)) { result.AppendErrorWithFormat( "'%s' is a permanent debugger command and cannot be redefined.\n", alias_command.c_str()); @@ -728,7 +728,7 @@ // Verify that the command is alias'able, and get the appropriate command // object. - if (m_interpreter.CommandExists(llvm::StringRef(alias_command.c_str()))) { + if (m_interpreter.CommandExists(alias_command)) { result.AppendErrorWithFormat( "'%s' is a permanent debugger command and cannot be redefined.\n", alias_command.c_str()); @@ -780,18 +780,18 @@ args.GetCommandString(args_string); } - if (m_interpreter.AliasExists(llvm::StringRef(alias_command.c_str())) || + if (m_interpreter.AliasExists(alias_command) || m_interpreter.UserCommandExists( - llvm::StringRef(alias_command.c_str()))) { + alias_command)) { result.AppendWarningWithFormat( "Overwriting existing definition for '%s'.\n", alias_command.c_str()); } if (CommandAlias *alias = m_interpreter.AddAlias( - llvm::StringRef(alias_command.c_str()), + alias_command, use_subcommand ? subcommand_obj_sp : command_obj_sp, - llvm::StringRef(args_string.c_str()))) { + args_string)) { if (m_command_options.m_help.OptionWasSet()) alias->SetHelp(m_command_options.m_help.GetCurrentValue()); if (m_command_options.m_long_help.OptionWasSet()) Index: lldb/source/Commands/CommandObjectFrame.cpp =================================================================== --- lldb/source/Commands/CommandObjectFrame.cpp +++ lldb/source/Commands/CommandObjectFrame.cpp @@ -695,7 +695,7 @@ continue; if (!scope_string.empty()) - s.PutCString(llvm::StringRef(scope_string.c_str())); + s.PutCString(scope_string); if (m_option_variable.show_decl && var_sp->GetDeclaration().GetFile()) { Index: lldb/source/Commands/CommandObjectPlatform.cpp =================================================================== --- lldb/source/Commands/CommandObjectPlatform.cpp +++ lldb/source/Commands/CommandObjectPlatform.cpp @@ -550,7 +550,7 @@ perms = lldb::eFilePermissionsUserRW | lldb::eFilePermissionsGroupRW | lldb::eFilePermissionsWorldRead; lldb::user_id_t fd = platform_sp->OpenFile( - FileSpec(llvm::StringRef(cmd_line.c_str()), false), + FileSpec(cmd_line, false), File::eOpenOptionRead | File::eOpenOptionWrite | File::eOpenOptionAppend | File::eOpenOptionCanCreate, perms, error); @@ -958,7 +958,7 @@ if (platform_sp) { std::string remote_file_path(args.GetArgumentAtIndex(0)); user_id_t size = platform_sp->GetFileSize( - FileSpec(llvm::StringRef(remote_file_path.c_str()), false)); + FileSpec(remote_file_path, false)); if (size != UINT64_MAX) { result.AppendMessageWithFormat("File size of %s (remote): %" PRIu64 "\n", @@ -1796,7 +1796,7 @@ error = (platform_sp->RunShellCommand(expr, working_dir, &status, &signo, &output, m_options.timeout)); if (!output.empty()) - result.GetOutputStream().PutCString(llvm::StringRef(output.c_str())); + result.GetOutputStream().PutCString(output); if (status > 0) { if (signo > 0) { const char *signo_cstr = Host::GetSignalAsCString(signo); Index: lldb/source/Commands/CommandObjectSource.cpp =================================================================== --- lldb/source/Commands/CommandObjectSource.cpp +++ lldb/source/Commands/CommandObjectSource.cpp @@ -609,7 +609,7 @@ m_module_list.Clear(); if (!m_options.modules.empty()) { for (size_t i = 0, e = m_options.modules.size(); i < e; ++i) { - FileSpec module_file_spec(llvm::StringRef(m_options.modules[i].c_str()), + FileSpec module_file_spec(m_options.modules[i], false); if (module_file_spec) { ModuleSpec module_spec(module_file_spec); @@ -945,7 +945,7 @@ if (num_modules > 0) { ModuleList matching_modules; for (size_t i = 0; i < num_modules; ++i) { - FileSpec module_file_spec(llvm::StringRef(m_options.modules[i].c_str()), + FileSpec module_file_spec(m_options.modules[i], false); if (module_file_spec) { ModuleSpec module_spec(module_file_spec); @@ -971,7 +971,7 @@ if (num_modules > 0) { ModuleList matching_modules; for (size_t i = 0; i < num_modules; ++i) { - FileSpec module_file_spec(llvm::StringRef(m_options.modules[i].c_str()), + FileSpec module_file_spec(m_options.modules[i], false); if (module_file_spec) { ModuleSpec module_spec(module_file_spec); @@ -1232,7 +1232,7 @@ ModuleList matching_modules; for (size_t i = 0, e = m_options.modules.size(); i < e; ++i) { FileSpec module_file_spec( - llvm::StringRef(m_options.modules[i].c_str()), false); + m_options.modules[i], false); if (module_file_spec) { ModuleSpec module_spec(module_file_spec); matching_modules.Clear(); Index: lldb/source/Commands/CommandObjectTarget.cpp =================================================================== --- lldb/source/Commands/CommandObjectTarget.cpp +++ lldb/source/Commands/CommandObjectTarget.cpp @@ -1280,7 +1280,7 @@ if (width) strm.Printf("%-*s", width, arch_str.c_str()); else - strm.PutCString(llvm::StringRef(arch_str.c_str())); + strm.PutCString(arch_str); } } Index: lldb/source/Core/Broadcaster.cpp =================================================================== --- lldb/source/Core/Broadcaster.cpp +++ lldb/source/Core/Broadcaster.cpp @@ -99,7 +99,7 @@ s.PutCString(llvm::StringRef(GetBroadcasterName())); s.PutChar('.'); } - s.PutCString(llvm::StringRef(pos->second.c_str())); + s.PutCString(pos->second); ++num_names_added; } } Index: lldb/source/Core/Debugger.cpp =================================================================== --- lldb/source/Core/Debugger.cpp +++ lldb/source/Core/Debugger.cpp @@ -280,7 +280,7 @@ std::string str = lldb_utility::ansi::FormatAnsiTerminalCodes( new_prompt, GetUseColor()); if (str.length()) - new_prompt = llvm::StringRef(str.c_str()); + new_prompt = str; GetCommandInterpreter().UpdatePrompt(new_prompt); EventSP prompt_change_event_sp( new Event(CommandInterpreter::eBroadcastBitResetPrompt, @@ -350,7 +350,7 @@ std::string str = lldb_utility::ansi::FormatAnsiTerminalCodes(new_prompt, GetUseColor()); if (str.length()) - new_prompt = llvm::StringRef(str.c_str()); + new_prompt = str; GetCommandInterpreter().UpdatePrompt(new_prompt); } @@ -1430,7 +1430,7 @@ // Print it. output_stream_sp->PutCString( - llvm::StringRef(content_stream.GetString().c_str())); + content_stream.GetString()); } } else { error_stream_sp->Printf("Failed to print structured " Index: lldb/source/Core/Disassembler.cpp =================================================================== --- lldb/source/Core/Disassembler.cpp +++ lldb/source/Core/Disassembler.cpp @@ -725,15 +725,15 @@ opcode_column_width = m_opcode_name.length() + 1; } - ss.PutCString(llvm::StringRef(m_opcode_name.c_str())); + ss.PutCString(m_opcode_name); ss.FillLastLineToColumn(opcode_pos + opcode_column_width, ' '); - ss.PutCString(llvm::StringRef(m_mnemonics.c_str())); + ss.PutCString(m_mnemonics); if (!m_comment.empty()) { ss.FillLastLineToColumn( opcode_pos + opcode_column_width + operand_column_width, ' '); ss.PutCString(" ; "); - ss.PutCString(llvm::StringRef(m_comment.c_str())); + ss.PutCString(m_comment); } s->Write(ss.GetData(), ss.GetSize()); } Index: lldb/source/Core/FormatEntity.cpp =================================================================== --- lldb/source/Core/FormatEntity.cpp +++ lldb/source/Core/FormatEntity.cpp @@ -1106,7 +1106,7 @@ return true; // Only return true if all items succeeded case Entry::Type::String: - s.PutCString(llvm::StringRef(entry.string.c_str())); + s.PutCString(entry.string); return true; case Entry::Type::Scope: { Index: lldb/source/Core/Log.cpp =================================================================== --- lldb/source/Core/Log.cpp +++ lldb/source/Core/Log.cpp @@ -106,16 +106,16 @@ llvm::raw_string_ostream stream(back_trace); llvm::sys::PrintStackTrace(stream); stream.flush(); - header.PutCString(llvm::StringRef(back_trace.c_str())); + header.PutCString(back_trace); } if (m_options.Test(LLDB_LOG_OPTION_THREADSAFE)) { static std::recursive_mutex g_LogThreadedMutex; std::lock_guard guard(g_LogThreadedMutex); - stream_sp->PutCString(llvm::StringRef(header.GetString().c_str())); + stream_sp->PutCString(header.GetString()); stream_sp->Flush(); } else { - stream_sp->PutCString(llvm::StringRef(header.GetString().c_str())); + stream_sp->PutCString(header.GetString()); stream_sp->Flush(); } } Index: lldb/source/Core/Module.cpp =================================================================== --- lldb/source/Core/Module.cpp +++ lldb/source/Core/Module.cpp @@ -1219,7 +1219,7 @@ std::string back_trace; llvm::raw_string_ostream stream(back_trace); llvm::sys::PrintStackTrace(stream); - log_message.PutCString(llvm::StringRef(back_trace.c_str())); + log_message.PutCString(back_trace); } log->PutCString(log_message.GetString().c_str()); } Index: lldb/source/Core/Scalar.cpp =================================================================== --- lldb/source/Core/Scalar.cpp +++ lldb/source/Core/Scalar.cpp @@ -289,14 +289,14 @@ case e_slonglong: case e_sint128: case e_sint256: - s->PutCString(llvm::StringRef(m_integer.toString(10, true).c_str())); + s->PutCString(m_integer.toString(10, true)); break; case e_uint: case e_ulong: case e_ulonglong: case e_uint128: case e_uint256: - s->PutCString(llvm::StringRef(m_integer.toString(10, false).c_str())); + s->PutCString(m_integer.toString(10, false)); break; case e_float: case e_double: Index: lldb/source/Core/SearchFilter.cpp =================================================================== --- lldb/source/Core/SearchFilter.cpp +++ lldb/source/Core/SearchFilter.cpp @@ -480,7 +480,7 @@ error.SetErrorString("SFBM::CFSD: filter module item not a string."); return nullptr; } - FileSpec module_spec(llvm::StringRef(module.c_str()), false); + FileSpec module_spec(module, false); return SearchFilterSP( new SearchFilterByModule(target.shared_from_this(), module_spec)); @@ -650,7 +650,7 @@ "SFBM::CFSD: filter module item %zu not a string.", i); return nullptr; } - modules.Append(FileSpec(llvm::StringRef(module.c_str()), false)); + modules.Append(FileSpec(module, false)); } } @@ -715,7 +715,7 @@ "SFBM::CFSD: filter module item %zu not a string.", i); return result_sp; } - modules.Append(FileSpec(llvm::StringRef(module.c_str()), false)); + modules.Append(FileSpec(module, false)); } } @@ -737,7 +737,7 @@ "SFBM::CFSD: filter cu item %zu not a string.", i); return nullptr; } - cus.Append(FileSpec(llvm::StringRef(cu.c_str()), false)); + cus.Append(FileSpec(cu, false)); } return SearchFilterSP(new SearchFilterByModuleListAndCU( Index: lldb/source/Core/StructuredData.cpp =================================================================== --- lldb/source/Core/StructuredData.cpp +++ lldb/source/Core/StructuredData.cpp @@ -182,7 +182,7 @@ std::pair match = path.split('.'); std::string key = match.first.str(); ObjectSP value = - this->GetAsDictionary()->GetValueForKey(llvm::StringRef(key.c_str())); + this->GetAsDictionary()->GetValueForKey(key); if (value.get()) { // Do we have additional words to descend? If not, return the // value we're at right now. Index: lldb/source/Core/ValueObject.cpp =================================================================== --- lldb/source/Core/ValueObject.cpp +++ lldb/source/Core/ValueObject.cpp @@ -2034,7 +2034,7 @@ if (this_had_base_class) { if (parent_had_base_class) s.PutCString("::"); - s.PutCString(llvm::StringRef(cxx_class_name.c_str())); + s.PutCString(cxx_class_name); } return parent_had_base_class || this_had_base_class; } Index: lldb/source/DataFormatters/TypeSummary.cpp =================================================================== --- lldb/source/DataFormatters/TypeSummary.cpp +++ lldb/source/DataFormatters/TypeSummary.cpp @@ -207,10 +207,10 @@ if (m_function_name.empty()) { sstr.PutCString("no backing script"); } else { - sstr.PutCString(llvm::StringRef(m_function_name.c_str())); + sstr.PutCString(m_function_name); } } else { - sstr.PutCString(llvm::StringRef(m_python_script.c_str())); + sstr.PutCString(m_python_script); } return sstr.GetString(); } Index: lldb/source/Expression/IRDynamicChecks.cpp =================================================================== --- lldb/source/Expression/IRDynamicChecks.cpp +++ lldb/source/Expression/IRDynamicChecks.cpp @@ -562,7 +562,7 @@ bool IRDynamicChecks::runOnModule(llvm::Module &M) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); - llvm::Function *function = M.getFunction(StringRef(m_func_name.c_str())); + llvm::Function *function = M.getFunction(m_func_name); if (!function) { if (log) Index: lldb/source/Expression/REPL.cpp =================================================================== --- lldb/source/Expression/REPL.cpp +++ lldb/source/Expression/REPL.cpp @@ -434,7 +434,7 @@ // Now set the default file and line to the REPL source file m_target.GetSourceManager().SetDefaultFileAndLine( - FileSpec(llvm::StringRef(m_repl_source_path.c_str()), false), + FileSpec(m_repl_source_path, false), new_default_line); } static_cast(io_handler) Index: lldb/source/Host/common/FileSpec.cpp =================================================================== --- lldb/source/Host/common/FileSpec.cpp +++ lldb/source/Host/common/FileSpec.cpp @@ -658,7 +658,7 @@ void FileSpec::Dump(Stream *s) const { if (s) { std::string path{GetPath(true)}; - s->PutCString(llvm::StringRef(path.c_str())); + s->PutCString(path); char path_separator = GetPreferredPathSeparator(m_syntax); if (!m_filename && !path.empty() && path.back() != path_separator) s->PutChar(path_separator); Index: lldb/source/Host/common/Host.cpp =================================================================== --- lldb/source/Host/common/Host.cpp +++ lldb/source/Host/common/Host.cpp @@ -548,7 +548,7 @@ } } - FileSpec output_file_spec{llvm::StringRef(output_file_path.c_str()), false}; + FileSpec output_file_spec{output_file_path, false}; launch_info.AppendSuppressFileAction(STDIN_FILENO, true, false); if (output_file_spec) { Index: lldb/source/Host/common/HostNativeThreadBase.cpp =================================================================== --- lldb/source/Host/common/HostNativeThreadBase.cpp +++ lldb/source/Host/common/HostNativeThreadBase.cpp @@ -52,7 +52,7 @@ HostNativeThreadBase::ThreadCreateTrampoline(lldb::thread_arg_t arg) { ThreadLauncher::HostThreadCreateInfo *info = (ThreadLauncher::HostThreadCreateInfo *)arg; - ThisThread::SetName(llvm::StringRef(info->thread_name.c_str()), + ThisThread::SetName(info->thread_name, HostInfo::GetMaxThreadNameLength()); thread_func_t thread_fptr = info->thread_fptr; Index: lldb/source/Host/common/Symbols.cpp =================================================================== --- lldb/source/Host/common/Symbols.cpp +++ lldb/source/Host/common/Symbols.cpp @@ -246,7 +246,7 @@ const uint32_t num_files = files.size(); for (size_t idx_file = 0; idx_file < num_files; ++idx_file) { const std::string &filename = files[idx_file]; - FileSpec file_spec(llvm::StringRef(filename.c_str()), true); + FileSpec file_spec(filename, true); if (llvm::sys::fs::equivalent(file_spec.GetPath(), module_spec.GetFileSpec().GetPath())) Index: lldb/source/Host/common/ThisThread.cpp =================================================================== --- lldb/source/Host/common/ThisThread.cpp +++ lldb/source/Host/common/ThisThread.cpp @@ -46,5 +46,5 @@ truncated_name = truncated_name.substr(begin, count); } - SetName(llvm::StringRef(truncated_name.c_str())); + SetName(truncated_name); } Index: lldb/source/Host/macosx/Host.mm =================================================================== --- lldb/source/Host/macosx/Host.mm +++ lldb/source/Host/macosx/Host.mm @@ -1380,7 +1380,7 @@ continue; launch_info.GetArguments().AppendArgument( - llvm::StringRef(str_sp->GetValue().c_str())); + str_sp->GetValue()); } } Index: lldb/source/Host/macosx/HostInfoMacOSX.mm =================================================================== --- lldb/source/Host/macosx/HostInfoMacOSX.mm +++ lldb/source/Host/macosx/HostInfoMacOSX.mm @@ -239,7 +239,7 @@ raw_path.resize(framework_pos); raw_path.append("/Resources/Clang"); } - file_spec.SetFile(llvm::StringRef(raw_path.c_str()), true); + file_spec.SetFile(raw_path, true); return true; } Index: lldb/source/Host/macosx/Symbols.cpp =================================================================== --- lldb/source/Host/macosx/Symbols.cpp +++ lldb/source/Host/macosx/Symbols.cpp @@ -294,7 +294,7 @@ (CFDictionaryRef)uuid_dict, CFSTR("DBGSymbolRichExecutable")); if (cf_str && CFGetTypeID(cf_str) == CFStringGetTypeID()) { if (CFCString::FileSystemRepresentation(cf_str, str)) { - module_spec.GetFileSpec().SetFile(llvm::StringRef(str.c_str()), true); + module_spec.GetFileSpec().SetFile(str, true); if (log) { log->Printf( "From dsymForUUID plist: Symbol rich executable is at '%s'", @@ -307,7 +307,7 @@ CFSTR("DBGDSYMPath")); if (cf_str && CFGetTypeID(cf_str) == CFStringGetTypeID()) { if (CFCString::FileSystemRepresentation(cf_str, str)) { - module_spec.GetSymbolFileSpec().SetFile(llvm::StringRef(str.c_str()), + module_spec.GetSymbolFileSpec().SetFile(str, true); success = true; if (log) { @@ -340,7 +340,7 @@ if (!DBGBuildSourcePath.empty() && !DBGSourcePath.empty()) { if (DBGSourcePath[0] == '~') { - FileSpec resolved_source_path(llvm::StringRef(DBGSourcePath.c_str()), + FileSpec resolved_source_path(DBGSourcePath, true); DBGSourcePath = resolved_source_path.GetPath(); } @@ -394,7 +394,7 @@ } if (DBGSourcePath[0] == '~') { FileSpec resolved_source_path( - llvm::StringRef(DBGSourcePath.c_str()), true); + DBGSourcePath, true); DBGSourcePath = resolved_source_path.GetPath(); } module_spec.GetSourceMappingList().Append( @@ -479,7 +479,7 @@ std::string dsymforuuid_path(tilde_rc->pw_dir); dsymforuuid_path += "/bin/dsymForUUID"; dsym_for_uuid_exe_spec.SetFile( - llvm::StringRef(dsymforuuid_path.c_str()), false); + dsymforuuid_path, false); g_dsym_for_uuid_exe_exists = dsym_for_uuid_exe_spec.Exists(); } } Index: lldb/source/Host/posix/PipePosix.cpp =================================================================== --- lldb/source/Host/posix/PipePosix.cpp +++ lldb/source/Host/posix/PipePosix.cpp @@ -131,10 +131,10 @@ FileSpec tmpdir_file_spec; tmpdir_file_spec.Clear(); if (HostInfo::GetLLDBPath(ePathTypeLLDBTempSystemDir, tmpdir_file_spec)) { - tmpdir_file_spec.AppendPathComponent(llvm::StringRef(pipe_spec.c_str())); + tmpdir_file_spec.AppendPathComponent(pipe_spec); } else { tmpdir_file_spec.AppendPathComponent("/tmp"); - tmpdir_file_spec.AppendPathComponent(llvm::StringRef(pipe_spec.c_str())); + tmpdir_file_spec.AppendPathComponent(pipe_spec); } // It's possible that another process creates the target path after we've Index: lldb/source/Interpreter/CommandInterpreter.cpp =================================================================== --- lldb/source/Interpreter/CommandInterpreter.cpp +++ lldb/source/Interpreter/CommandInterpreter.cpp @@ -2099,7 +2099,7 @@ FileSpec dot_lldb(".lldbinit", true); llvm::SmallString<64> home_dir_path; llvm::sys::path::home_directory(home_dir_path); - FileSpec homedir_dot_lldb(llvm::StringRef(home_dir_path.c_str()), + FileSpec homedir_dot_lldb(home_dir_path, false); homedir_dot_lldb.AppendPathComponent(".lldbinit"); homedir_dot_lldb.ResolvePath(); @@ -2133,7 +2133,7 @@ // load the init files. llvm::SmallString<64> home_dir_path; llvm::sys::path::home_directory(home_dir_path); - FileSpec profilePath(llvm::StringRef(home_dir_path.c_str()), false); + FileSpec profilePath(home_dir_path, false); profilePath.AppendPathComponent(".lldbinit"); std::string init_file_path = profilePath.GetPath(); @@ -2152,7 +2152,7 @@ } if (!init_file && !m_skip_lldbinit_files) - init_file.SetFile(llvm::StringRef(init_file_path.c_str()), false); + init_file.SetFile(init_file_path, false); } // If the file exists, tell HandleCommand to 'source' it; this will do the @@ -2939,7 +2939,7 @@ if (cmd_obj == nullptr) { std::string full_name; bool is_alias = - GetAliasFullName(llvm::StringRef(next_word.c_str()), full_name); + GetAliasFullName(next_word, full_name); cmd_obj = GetCommandObject(next_word, &matches); bool is_real_command = (is_alias == false) || @@ -2947,7 +2947,7 @@ if (!is_real_command) { matches.Clear(); std::string alias_result; - cmd_obj = BuildAliasResult(llvm::StringRef(full_name.c_str()), + cmd_obj = BuildAliasResult(full_name, scratch_command, alias_result, result); revised_command_line.Printf("%s", alias_result.c_str()); if (cmd_obj) { Index: lldb/source/Interpreter/OptionValueArray.cpp =================================================================== --- lldb/source/Interpreter/OptionValueArray.cpp +++ lldb/source/Interpreter/OptionValueArray.cpp @@ -72,7 +72,7 @@ Error OptionValueArray::SetValueFromString(llvm::StringRef value, VarSetOperationType op) { - Args args(llvm::StringRef(value.str().c_str())); + Args args(value.str()); Error error = SetArgs(args, op); if (error.Success()) NotifyValueChanged(); Index: lldb/source/Interpreter/OptionValueDictionary.cpp =================================================================== --- lldb/source/Interpreter/OptionValueDictionary.cpp +++ lldb/source/Interpreter/OptionValueDictionary.cpp @@ -198,7 +198,7 @@ Error OptionValueDictionary::SetValueFromString(llvm::StringRef value, VarSetOperationType op) { - Args args(llvm::StringRef(value.str().c_str())); + Args args(value.str()); Error error = SetArgs(args, op); if (error.Success()) NotifyValueChanged(); Index: lldb/source/Interpreter/OptionValueFileSpec.cpp =================================================================== --- lldb/source/Interpreter/OptionValueFileSpec.cpp +++ lldb/source/Interpreter/OptionValueFileSpec.cpp @@ -80,7 +80,7 @@ // or whitespace. value = value.trim("\"' \t"); m_value_was_set = true; - m_current_value.SetFile(llvm::StringRef(value.str().c_str()), m_resolve); + m_current_value.SetFile(value.str(), m_resolve); m_data_sp.reset(); m_data_mod_time.Clear(); NotifyValueChanged(); Index: lldb/source/Interpreter/OptionValueFileSpecLIst.cpp =================================================================== --- lldb/source/Interpreter/OptionValueFileSpecLIst.cpp +++ lldb/source/Interpreter/OptionValueFileSpecLIst.cpp @@ -41,7 +41,7 @@ Error OptionValueFileSpecList::SetValueFromString(llvm::StringRef value, VarSetOperationType op) { Error error; - Args args(llvm::StringRef(value.str().c_str())); + Args args(value.str()); const size_t argc = args.GetArgumentCount(); switch (op) { Index: lldb/source/Interpreter/OptionValuePathMappings.cpp =================================================================== --- lldb/source/Interpreter/OptionValuePathMappings.cpp +++ lldb/source/Interpreter/OptionValuePathMappings.cpp @@ -43,7 +43,7 @@ Error OptionValuePathMappings::SetValueFromString(llvm::StringRef value, VarSetOperationType op) { Error error; - Args args(llvm::StringRef(value.str().c_str())); + Args args(value.str()); const size_t argc = args.GetArgumentCount(); switch (op) { Index: lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp =================================================================== --- lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp +++ lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp @@ -736,7 +736,7 @@ if (op.m_negative) { s.PutCString("-"); } - s.PutCString(llvm::StringRef(llvm::to_string(op.m_immediate).c_str())); + s.PutCString(llvm::to_string(op.m_immediate)); break; case Operand::Type::Invalid: s.PutCString("Invalid"); @@ -1049,7 +1049,7 @@ thumb_arch_name = "thumbv8.2a"; } thumb_arch.GetTriple().setArchName( - llvm::StringRef(thumb_arch_name.c_str())); + thumb_arch_name); } // If no sub architecture specified then use the most recent arm architecture Index: lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp =================================================================== --- lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp +++ lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp @@ -608,7 +608,7 @@ return false; FileSpec file_spec; - file_spec.SetFile(llvm::StringRef(m_name.c_str()), false); + file_spec.SetFile(m_name, false); ModuleSP memory_module_sp = process->ReadModuleFromMemory(file_spec, m_load_address); @@ -764,7 +764,7 @@ PlatformDarwinKernel::GetPluginNameStatic()); if (platform_name == g_platform_name) { ModuleSpec kext_bundle_module_spec(module_spec); - FileSpec kext_filespec(llvm::StringRef(m_name.c_str()), false); + FileSpec kext_filespec(m_name, false); kext_bundle_module_spec.GetFileSpec() = kext_filespec; platform_sp->GetSharedModule( kext_bundle_module_spec, process, m_module_sp, Index: lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp =================================================================== --- lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp +++ lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp @@ -369,7 +369,7 @@ E = m_rendezvous.loaded_end(); for (I = m_rendezvous.loaded_begin(); I != E; ++I) { - FileSpec file(llvm::StringRef(I->path.c_str()), true); + FileSpec file(I->path, true); ModuleSP module_sp = LoadModuleAtAddress(file, I->link_addr, I->base_addr, true); if (module_sp.get()) { @@ -393,7 +393,7 @@ E = m_rendezvous.unloaded_end(); for (I = m_rendezvous.unloaded_begin(); I != E; ++I) { - FileSpec file(llvm::StringRef(I->path.c_str()), true); + FileSpec file(I->path, true); ModuleSpec module_spec(file); ModuleSP module_sp = loaded_modules.FindFirstModule(module_spec); Index: lldb/source/Plugins/ExpressionParser/Clang/ASTDumper.cpp =================================================================== --- lldb/source/Plugins/ExpressionParser/Clang/ASTDumper.cpp +++ lldb/source/Plugins/ExpressionParser/Clang/ASTDumper.cpp @@ -107,5 +107,5 @@ } void ASTDumper::ToStream(lldb::StreamSP &stream) { - stream->PutCString(llvm::StringRef(m_dump.c_str())); + stream->PutCString(m_dump); } Index: lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp =================================================================== --- lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp +++ lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp @@ -922,7 +922,7 @@ std::string decl_name_string_without_colon(decl_name_string.c_str(), decl_name_string.length() - 1); IdentifierInfo *ident = &original_ctx->Idents.get( - llvm::StringRef(decl_name_string_without_colon.c_str())); + decl_name_string_without_colon); original_selector = original_ctx->Selectors.getSelector(1, &ident); } else { SmallVector idents; Index: lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp =================================================================== --- lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp +++ lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp @@ -131,7 +131,7 @@ for (IDAndDiagnostic &diag : m_diagnostics) { switch (diag.first) { default: - error_stream.PutCString(llvm::StringRef(diag.second.c_str())); + error_stream.PutCString(diag.second); error_stream.PutChar('\n'); break; case clang::DiagnosticsEngine::Level::Ignored: Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp =================================================================== --- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -972,7 +972,7 @@ FileSpecList file_spec_list; if (!m_gnu_debuglink_file.empty()) { - FileSpec file_spec(llvm::StringRef(m_gnu_debuglink_file.c_str()), false); + FileSpec file_spec(m_gnu_debuglink_file, false); file_spec_list.Append(file_spec); } return file_spec_list; Index: lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp =================================================================== --- lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp +++ lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp @@ -345,7 +345,7 @@ log->Printf("Failed to remove temp directory: %s", error.AsCString()); }); - FileSpec symfile_platform_filespec(llvm::StringRef(tmpdir.c_str()), false); + FileSpec symfile_platform_filespec(tmpdir, false); symfile_platform_filespec.AppendPathComponent("symbolized.oat"); // Execute oatdump on the remote device to generate a file with symtab Index: lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp =================================================================== --- lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp +++ lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp @@ -374,7 +374,7 @@ if (!cache_path.empty()) { std::string module_path(module_spec.GetFileSpec().GetPath()); cache_path.append(module_path); - FileSpec module_cache_spec(llvm::StringRef(cache_path.c_str()), false); + FileSpec module_cache_spec(cache_path, false); // if rsync is supported, always bring in the file - rsync will be very // efficient @@ -1295,7 +1295,7 @@ if (xcode_select_prefix_dir) xcode_dir_path.append(xcode_select_prefix_dir); xcode_dir_path.append("/usr/share/xcode-select/xcode_dir_path"); - temp_file_spec.SetFile(llvm::StringRef(xcode_dir_path.c_str()), false); + temp_file_spec.SetFile(xcode_dir_path, false); size_t bytes_read = temp_file_spec.ReadFileContents( 0, developer_dir_path, sizeof(developer_dir_path), NULL); if (bytes_read > 0) { @@ -1437,7 +1437,7 @@ size_t pos = path_to_shlib.rfind(substr); if (pos != std::string::npos) { path_to_shlib.erase(pos + strlen(substr)); - FileSpec ret(llvm::StringRef(path_to_shlib.c_str()), false); + FileSpec ret(path_to_shlib, false); FileSpec xcode_binary_path = ret; xcode_binary_path.AppendPathComponent("MacOS"); @@ -1505,7 +1505,7 @@ output.append("/.."); g_xcode_filespec = CheckPathForXcode( - FileSpec(llvm::StringRef(output.c_str()), false)); + FileSpec(output, false)); } } } @@ -1606,7 +1606,7 @@ enumerator_info.sdk_type = sdk_type; - FileSpec::EnumerateDirectory(llvm::StringRef(sdks_spec.GetPath().c_str()), + FileSpec::EnumerateDirectory(sdks_spec.GetPath(), find_directories, find_files, find_other, DirectoryEnumerator, &enumerator_info); @@ -1657,7 +1657,7 @@ StreamString native_sdk_name; native_sdk_name.Printf("MacOSX%u.%u.sdk", major, minor); native_sdk_spec.AppendPathComponent( - llvm::StringRef(native_sdk_name.GetString().c_str())); + native_sdk_name.GetString()); if (native_sdk_spec.Exists()) { return native_sdk_spec; Index: lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp =================================================================== --- lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp +++ lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp @@ -427,7 +427,7 @@ const bool find_directories = true; const bool find_files = false; const bool find_other = false; - FileSpec::EnumerateDirectory(llvm::StringRef(dir.c_str()), find_directories, + FileSpec::EnumerateDirectory(dir, find_directories, find_files, find_other, FindKDKandSDKDirectoriesInDirectory, this); } @@ -459,7 +459,7 @@ const bool find_files = true; const bool find_other = true; // I think eFileTypeSymbolicLink are "other"s. FileSpec::EnumerateDirectory( - llvm::StringRef(dir.GetPath().c_str()), find_directories, find_files, + dir.GetPath(), find_directories, find_files, find_other, GetKernelsAndKextsInDirectoryWithRecursion, this); } const uint32_t num_dirs_no_recurse = m_search_directories_no_recursing.size(); @@ -469,7 +469,7 @@ const bool find_files = true; const bool find_other = true; // I think eFileTypeSymbolicLink are "other"s. FileSpec::EnumerateDirectory( - llvm::StringRef(dir.GetPath().c_str()), find_directories, find_files, + dir.GetPath(), find_directories, find_files, find_other, GetKernelsAndKextsInDirectoryNoRecursion, this); } } @@ -544,7 +544,7 @@ const bool find_files = false; const bool find_other = false; FileSpec::EnumerateDirectory( - llvm::StringRef(search_here_too.c_str()), find_directories, + search_here_too, find_directories, find_files, find_other, recurse ? GetKernelsAndKextsInDirectoryWithRecursion : GetKernelsAndKextsInDirectoryNoRecursion, Index: lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp =================================================================== --- lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp +++ lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp @@ -220,13 +220,13 @@ "SDKs/MacOSX%u.%u.sdk", xcode_contents_path.c_str(), versions[0], versions[1]); - fspec.SetFile(llvm::StringRef(sdk_path.GetString().c_str()), false); + fspec.SetFile(sdk_path.GetString(), false); if (fspec.Exists()) return ConstString(sdk_path.GetString().c_str()); } if (!default_xcode_sdk.empty()) { - fspec.SetFile(llvm::StringRef(default_xcode_sdk.c_str()), false); + fspec.SetFile(default_xcode_sdk, false); if (fspec.Exists()) return ConstString(default_xcode_sdk.c_str()); } @@ -270,7 +270,7 @@ std::string cache_path(GetLocalCacheDirectory()); std::string module_path(platform_file.GetPath()); cache_path.append(module_path); - FileSpec module_cache_spec(llvm::StringRef(cache_path.c_str()), false); + FileSpec module_cache_spec(cache_path, false); if (module_cache_spec.Exists()) { local_file = module_cache_spec; return Error(); Index: lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp =================================================================== --- lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp +++ lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp @@ -272,7 +272,7 @@ SDKDirectoryInfoCollection builtin_sdk_directory_infos; FileSpec::EnumerateDirectory( - llvm::StringRef(m_device_support_directory.c_str()), find_directories, + m_device_support_directory, find_directories, find_files, find_other, GetContainedFilesIntoVectorOfStringsCallback, &builtin_sdk_directory_infos); @@ -530,7 +530,7 @@ const char *paths_to_try[] = {"Symbols", "", "Symbols.Internal", nullptr}; for (size_t i = 0; paths_to_try[i] != nullptr; i++) { - local_file.SetFile(llvm::StringRef(sdkroot_path.c_str()), false); + local_file.SetFile(sdkroot_path, false); if (paths_to_try[i][0] != '\0') local_file.AppendPathComponent(llvm::StringRef(paths_to_try[i])); local_file.AppendPathComponent(llvm::StringRef(platform_file_path)); Index: lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp =================================================================== --- lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp +++ lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp @@ -282,7 +282,7 @@ SDKDirectoryInfoCollection builtin_sdk_directory_infos; FileSpec::EnumerateDirectory( - llvm::StringRef(m_device_support_directory.c_str()), find_directories, + m_device_support_directory, find_directories, find_files, find_other, GetContainedFilesIntoVectorOfStringsCallback, &builtin_sdk_directory_infos); @@ -453,13 +453,13 @@ m_device_support_directory.append( "/Platforms/watchOS.platform/DeviceSupport"); FileSpec platform_device_support_dir( - llvm::StringRef(m_device_support_directory.c_str()), true); + m_device_support_directory, true); if (!platform_device_support_dir.Exists()) { std::string alt_platform_dirname = device_support_dir; alt_platform_dirname.append( "/Platforms/WatchOS.platform/DeviceSupport"); FileSpec alt_platform_device_support_dir( - llvm::StringRef(m_device_support_directory.c_str()), true); + m_device_support_directory, true); if (alt_platform_device_support_dir.Exists()) { m_device_support_directory = alt_platform_dirname; } @@ -545,7 +545,7 @@ const char *paths_to_try[] = {"Symbols", "", "Symbols.Internal", nullptr}; for (size_t i = 0; paths_to_try[i] != nullptr; i++) { - local_file.SetFile(llvm::StringRef(sdkroot_path.c_str()), false); + local_file.SetFile(sdkroot_path, false); if (paths_to_try[i][0] != '\0') local_file.AppendPathComponent(llvm::StringRef(paths_to_try[i])); local_file.AppendPathComponent(llvm::StringRef(platform_file_path)); Index: lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp =================================================================== --- lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp +++ lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp @@ -290,7 +290,7 @@ SDKDirectoryInfoCollection builtin_sdk_directory_infos; FileSpec::EnumerateDirectory( - llvm::StringRef(m_device_support_directory.c_str()), find_directories, + m_device_support_directory, find_directories, find_files, find_other, GetContainedFilesIntoVectorOfStringsCallback, &builtin_sdk_directory_infos); @@ -517,7 +517,7 @@ const char *paths_to_try[] = {"Symbols", "", "Symbols.Internal", nullptr}; for (size_t i = 0; paths_to_try[i] != nullptr; i++) { - local_file.SetFile(llvm::StringRef(sdkroot_path.c_str()), false); + local_file.SetFile(sdkroot_path, false); if (paths_to_try[i][0] != '\0') local_file.AppendPathComponent(llvm::StringRef(paths_to_try[i])); local_file.AppendPathComponent(llvm::StringRef(platform_file_path)); Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp =================================================================== --- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp +++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp @@ -359,7 +359,7 @@ std::string file; extractor.GetHexByteString(file); match_info.GetProcessInfo().GetExecutableFile().SetFile( - llvm::StringRef(file.c_str()), false); + file, false); } else if (key.equals("name_match")) { NameMatchType name_match = llvm::StringSwitch(value) @@ -645,7 +645,7 @@ packet.GetHexByteString(path); if (!path.empty()) { lldb::user_id_t retcode = - FileSystem::GetFileSize(FileSpec(llvm::StringRef(path.c_str()), false)); + FileSystem::GetFileSize(FileSpec(path, false)); StreamString response; response.PutChar('F'); response.PutHex64(retcode); @@ -685,7 +685,7 @@ packet.GetHexByteString(path); if (!path.empty()) { bool retcode = FileSystem::GetFileExists( - FileSpec(llvm::StringRef(path.c_str()), false)); + FileSpec(path, false)); StreamString response; response.PutChar('F'); response.PutChar(','); @@ -778,7 +778,7 @@ uint64_t a, b; StreamGDBRemote response; if (!FileSystem::CalculateMD5( - FileSpec(llvm::StringRef(path.c_str()), false), a, b)) { + FileSpec(path, false), a, b)) { response.PutCString("F,"); response.PutCString("x"); } else { @@ -1035,7 +1035,7 @@ if (success) { if (arg_idx == 0) m_process_launch_info.GetExecutableFile().SetFile( - llvm::StringRef(arg.c_str()), false); + arg, false); m_process_launch_info.GetArguments().AppendArgument(arg); if (log) log->Printf("LLGSPacketHandler::%s added arg %d: \"%s\"", @@ -1279,7 +1279,7 @@ #ifdef __ANDROID__ return HostInfoAndroid::ResolveLibraryPath(module_path, arch); #else - return FileSpec(llvm::StringRef(module_path.c_str()), true); + return FileSpec(module_path, true); #endif } @@ -1287,7 +1287,7 @@ const std::string &module_path, const std::string &triple) { ArchSpec arch(triple.c_str()); - const FileSpec req_module_path_spec(llvm::StringRef(module_path.c_str()), + const FileSpec req_module_path_spec(module_path, true); const FileSpec module_path_spec = FindModuleFile(req_module_path_spec.GetPath(), arch); Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp =================================================================== --- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp +++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp @@ -553,10 +553,10 @@ (llvm::StringRef(prefix) + ".%%%%%%").str()); FileSpec socket_path_spec(GetDomainSocketDir()); - socket_path_spec.AppendPathComponent(llvm::StringRef(socket_name.c_str())); + socket_path_spec.AppendPathComponent(socket_name); llvm::sys::fs::createUniqueFile(socket_path_spec.GetCString(), socket_path); - return FileSpec(llvm::StringRef(socket_path.c_str()), false); + return FileSpec(socket_path, false); } void GDBRemoteCommunicationServerPlatform::SetPortOffset(uint16_t port_offset) { Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp =================================================================== --- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -4581,7 +4581,7 @@ if (!modInfo.get_link_map(link_map)) link_map = LLDB_INVALID_ADDRESS; - FileSpec file(llvm::StringRef(mod_name.c_str()), true); + FileSpec file(mod_name, true); lldb::ModuleSP module_sp = LoadModuleAtAddress(file, link_map, mod_base, mod_base_is_offset); Index: lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp =================================================================== --- lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp +++ lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp @@ -1021,7 +1021,7 @@ if (mode.empty()) return 0; - return llvm::StringSwitch(llvm::StringRef(mode.str().c_str())) + return llvm::StringSwitch(mode.str()) .Case("r", File::eOpenOptionRead) .Case("w", File::eOpenOptionWrite) .Case("a", File::eOpenOptionWrite | File::eOpenOptionAppend | Index: lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp =================================================================== --- lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp +++ lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp @@ -1818,7 +1818,7 @@ // Display the activity chain, from parent-most to child-most // activity, separated by a colon (:). stream.PutCString("activity-chain="); - stream.PutCString(llvm::StringRef(activity_chain.c_str())); + stream.PutCString(activity_chain); #else if (GetGlobalProperties()->GetDisplayActivityChain()) { // Display the activity chain, from parent-most to child-most @@ -1850,7 +1850,7 @@ if (header_count > 0) stream.PutChar(','); stream.PutCString("subsystem="); - stream.PutCString(llvm::StringRef(subsystem.c_str())); + stream.PutCString(subsystem); ++header_count; } } @@ -1862,14 +1862,14 @@ if (header_count > 0) stream.PutChar(','); stream.PutCString("category="); - stream.PutCString(llvm::StringRef(category.c_str())); + stream.PutCString(category); ++header_count; } } stream.PutCString("] "); auto &result = stream.GetString(); - output_stream.PutCString(llvm::StringRef(result.c_str())); + output_stream.PutCString(result); return result.size(); } Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnamesSet.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnamesSet.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnamesSet.cpp @@ -140,7 +140,7 @@ DescriptorConstIter pos; DescriptorConstIter end = m_descriptors.end(); for (pos = m_descriptors.begin(); pos != end; ++pos) { - if (regex.Execute(llvm::StringRef(pos->name.c_str()))) + if (regex.Execute(pos->name)) die_offset_coll.push_back(m_header.die_offset + pos->offset); } } Index: lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp +++ lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp @@ -471,7 +471,7 @@ auto global = m_session_up->getGlobalScope(); std::unique_ptr results; results = - global->findChildren(PDB_SymType::None, llvm::StringRef(name.c_str()), + global->findChildren(PDB_SymType::None, name, PDB_NameSearchFlags::NS_Default); uint32_t matches = 0; Index: lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp =================================================================== --- lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp +++ lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp @@ -183,7 +183,7 @@ !DBGSourcePath.empty()) { if (DBGSourcePath[0] == '~') { FileSpec resolved_source_path( - llvm::StringRef(DBGSourcePath.c_str()), true); + DBGSourcePath, true); DBGSourcePath = resolved_source_path.GetPath(); } module_sp->GetSourceMappingList().Append( @@ -246,7 +246,7 @@ } if (DBGSourcePath[0] == '~') { FileSpec resolved_source_path( - llvm::StringRef(DBGSourcePath.c_str()), + DBGSourcePath, true); DBGSourcePath = resolved_source_path.GetPath(); Index: lldb/source/Symbol/ClangASTContext.cpp =================================================================== --- lldb/source/Symbol/ClangASTContext.cpp +++ lldb/source/Symbol/ClangASTContext.cpp @@ -8212,14 +8212,14 @@ std::string property_setter_no_colon( property_setter_name, strlen(property_setter_name) - 1); clang::IdentifierInfo *setter_ident = &clang_ast->Idents.get( - StringRef(property_setter_no_colon.c_str())); + property_setter_no_colon); setter_sel = clang_ast->Selectors.getSelector(1, &setter_ident); } else if (!(property_attributes & DW_APPLE_PROPERTY_readonly)) { std::string setter_sel_string("set"); setter_sel_string.push_back(::toupper(property_name[0])); setter_sel_string.append(&property_name[1]); clang::IdentifierInfo *setter_ident = &clang_ast->Idents.get( - StringRef(setter_sel_string.c_str())); + setter_sel_string); setter_sel = clang_ast->Selectors.getSelector(1, &setter_ident); } property_decl->setSetterName(setter_sel); @@ -9262,7 +9262,7 @@ enum_pos != enum_end_pos; ++enum_pos) { if (enum_pos->getInitVal().getSExtValue() == enum_svalue) { s->PutCString( - StringRef(enum_pos->getNameAsString().c_str())); + enum_pos->getNameAsString()); return true; } } @@ -9277,7 +9277,7 @@ enum_pos != enum_end_pos; ++enum_pos) { if (enum_pos->getInitVal().getZExtValue() == enum_uvalue) { s->PutCString( - StringRef(enum_pos->getNameAsString().c_str())); + enum_pos->getNameAsString()); return true; } } @@ -9447,7 +9447,7 @@ typedef_decl->getQualifiedNameAsString()); if (!clang_typedef_name.empty()) { s->PutCString("typedef "); - s->PutCString(StringRef(clang_typedef_name.c_str())); + s->PutCString(clang_typedef_name); } } } break; @@ -9497,7 +9497,7 @@ } else { std::string clang_type_name(qual_type.getAsString()); if (!clang_type_name.empty()) - s->PutCString(StringRef(clang_type_name.c_str())); + s->PutCString(clang_type_name); } } } Index: lldb/source/Symbol/ObjectFile.cpp =================================================================== --- lldb/source/Symbol/ObjectFile.cpp +++ lldb/source/Symbol/ObjectFile.cpp @@ -582,7 +582,7 @@ std::string obj; if (regex_match.GetMatchAtIndex(path_with_object, 1, path) && regex_match.GetMatchAtIndex(path_with_object, 2, obj)) { - archive_file.SetFile(llvm::StringRef(path.c_str()), false); + archive_file.SetFile(path, false); archive_object.SetCString(obj.c_str()); if (must_exist && !archive_file.Exists()) return false; Index: lldb/source/Symbol/SymbolContext.cpp =================================================================== --- lldb/source/Symbol/SymbolContext.cpp +++ lldb/source/Symbol/SymbolContext.cpp @@ -913,7 +913,7 @@ if (m_module_sp.get() != sc.module_sp.get()) return false; } else { - FileSpec module_file_spec(llvm::StringRef(m_module_spec.c_str()), + FileSpec module_file_spec(m_module_spec, false); if (!FileSpec::Equal(module_file_spec, sc.module_sp->GetFileSpec(), false)) Index: lldb/source/Target/Platform.cpp =================================================================== --- lldb/source/Target/Platform.cpp +++ lldb/source/Target/Platform.cpp @@ -92,7 +92,7 @@ if (!llvm::sys::path::home_directory(user_home_dir)) return; - module_cache_dir = FileSpec(llvm::StringRef(user_home_dir.c_str()), false); + module_cache_dir = FileSpec(user_home_dir, false); module_cache_dir.AppendPathComponent(".lldb"); module_cache_dir.AppendPathComponent("module_cache"); SetModuleCacheDirectory(module_cache_dir); @@ -573,7 +573,7 @@ FileSpec recurse_dst; recurse_dst.GetDirectory().SetCString(dst_dir.GetPath().c_str()); RecurseCopyBaton rc_baton2 = {recurse_dst, rc_baton->platform_ptr, Error()}; - FileSpec::EnumerateDirectory(llvm::StringRef(src_dir_path.c_str()), true, + FileSpec::EnumerateDirectory(src_dir_path, true, true, true, RecurseCopy_Callback, &rc_baton2); if (rc_baton2.error.Fail()) { rc_baton->error.SetErrorString(rc_baton2.error.AsCString()); @@ -708,7 +708,7 @@ recurse_dst.GetDirectory().SetCString(fixed_dst.GetCString()); std::string src_dir_path(src.GetPath()); RecurseCopyBaton baton = {recurse_dst, this, Error()}; - FileSpec::EnumerateDirectory(llvm::StringRef(src_dir_path.c_str()), + FileSpec::EnumerateDirectory(src_dir_path, true, true, true, RecurseCopy_Callback, &baton); return baton.error; Index: lldb/source/Target/ProcessLaunchInfo.cpp =================================================================== --- lldb/source/Target/ProcessLaunchInfo.cpp +++ lldb/source/Target/ProcessLaunchInfo.cpp @@ -385,7 +385,7 @@ new_path += curr_path; } new_path += "\" "; - shell_command.PutCString(llvm::StringRef(new_path.c_str())); + shell_command.PutCString(new_path); } if (triple.getOS() != llvm::Triple::Win32 || Index: lldb/source/Target/TargetList.cpp =================================================================== --- lldb/source/Target/TargetList.cpp +++ lldb/source/Target/TargetList.cpp @@ -353,7 +353,7 @@ if (unglobbed_path.empty()) file = FileSpec(llvm::StringRef(user_exe_path), false); else - file = FileSpec(llvm::StringRef(unglobbed_path.c_str()), false); + file = FileSpec(unglobbed_path, false); } bool user_exe_path_is_bundle = false; @@ -373,7 +373,7 @@ std::string cwd_user_exe_path(cwd); cwd_user_exe_path += '/'; cwd_user_exe_path += user_exe_path; - FileSpec cwd_file(llvm::StringRef(cwd_user_exe_path.c_str()), false); + FileSpec cwd_file(cwd_user_exe_path, false); if (cwd_file.Exists()) file = cwd_file; } Index: lldb/source/Utility/ModuleCache.cpp =================================================================== --- lldb/source/Utility/ModuleCache.cpp +++ lldb/source/Utility/ModuleCache.cpp @@ -81,7 +81,7 @@ FileSpec GetSymbolFileSpec(const FileSpec &module_file_spec) { return FileSpec( - llvm::StringRef((module_file_spec.GetPath() + kSymFileExtension).c_str()), + (module_file_spec.GetPath() + kSymFileExtension), false); } Index: lldb/tools/lldb-server/Acceptor.cpp =================================================================== --- lldb/tools/lldb-server/Acceptor.cpp +++ lldb/tools/lldb-server/Acceptor.cpp @@ -58,13 +58,13 @@ } Error Acceptor::Listen(int backlog) { - return m_listener_socket_up->Listen(StringRef(m_name.c_str()), backlog); + return m_listener_socket_up->Listen(m_name, backlog); } Error Acceptor::Accept(const bool child_processes_inherit, Connection *&conn) { Socket *conn_socket = nullptr; auto error = m_listener_socket_up->Accept( - StringRef(m_name.c_str()), child_processes_inherit, conn_socket); + m_name, child_processes_inherit, conn_socket); if (error.Success()) conn = new ConnectionFileDescriptor(conn_socket); Index: lldb/unittests/Host/SocketTest.cpp =================================================================== --- lldb/unittests/Host/SocketTest.cpp +++ lldb/unittests/Host/SocketTest.cpp @@ -80,7 +80,7 @@ new SocketType(child_processes_inherit, error)); EXPECT_FALSE(error.Fail()); error = connect_socket_up->Connect( - llvm::StringRef(connect_remote_address.c_str())); + connect_remote_address); EXPECT_FALSE(error.Fail()); EXPECT_TRUE(connect_socket_up->IsValid()); Index: lldb/unittests/Process/minidump/MinidumpParserTest.cpp =================================================================== --- lldb/unittests/Process/minidump/MinidumpParserTest.cpp +++ lldb/unittests/Process/minidump/MinidumpParserTest.cpp @@ -47,7 +47,7 @@ void SetUpData(const char *minidump_filename, size_t load_size = SIZE_MAX) { llvm::SmallString<128> filename = inputs_folder; llvm::sys::path::append(filename, minidump_filename); - FileSpec minidump_file(llvm::StringRef(filename.c_str()), false); + FileSpec minidump_file(filename, false); lldb::DataBufferSP data_sp( minidump_file.MemoryMapFileContents(0, load_size)); llvm::Optional optional_parser = Index: lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp =================================================================== --- lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp +++ lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp @@ -163,7 +163,7 @@ TEST_F(SymbolFilePDBTests, TestAbilitiesForDWARF) { // Test that when we have Dwarf debug info, SymbolFileDWARF is used. - FileSpec fspec(llvm::StringRef(m_dwarf_test_exe.c_str()), false); + FileSpec fspec(m_dwarf_test_exe, false); ArchSpec aspec("i686-pc-windows"); lldb::ModuleSP module = std::make_shared(fspec, aspec); @@ -179,7 +179,7 @@ TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestAbilitiesForPDB)) { // Test that when we have PDB debug info, SymbolFilePDB is used. - FileSpec fspec(llvm::StringRef(m_pdb_test_exe.c_str()), false); + FileSpec fspec(m_pdb_test_exe, false); ArchSpec aspec("i686-pc-windows"); lldb::ModuleSP module = std::make_shared(fspec, aspec); @@ -198,7 +198,7 @@ // Test that attempting to call ResolveSymbolContext with only a basename // finds all full paths // with the same basename - FileSpec fspec(llvm::StringRef(m_pdb_test_exe.c_str()), false); + FileSpec fspec(m_pdb_test_exe, false); ArchSpec aspec("i686-pc-windows"); lldb::ModuleSP module = std::make_shared(fspec, aspec); @@ -218,7 +218,7 @@ // Test that attempting to call ResolveSymbolContext with a full path only // finds the one source // file that matches the full path. - FileSpec fspec(llvm::StringRef(m_pdb_test_exe.c_str()), false); + FileSpec fspec(m_pdb_test_exe, false); ArchSpec aspec("i686-pc-windows"); lldb::ModuleSP module = std::make_shared(fspec, aspec); @@ -243,7 +243,7 @@ // compiled, but only contributes to the combined code of other source files), // a SymbolContext is returned // for each compiland which has line contributions from the requested header. - FileSpec fspec(llvm::StringRef(m_pdb_test_exe.c_str()), false); + FileSpec fspec(m_pdb_test_exe, false); ArchSpec aspec("i686-pc-windows"); lldb::ModuleSP module = std::make_shared(fspec, aspec); @@ -272,7 +272,7 @@ // compiled, but only contributes to the combined code of other source files), // that if check_inlines // is false, no SymbolContexts are returned. - FileSpec fspec(llvm::StringRef(m_pdb_test_exe.c_str()), false); + FileSpec fspec(m_pdb_test_exe, false); ArchSpec aspec("i686-pc-windows"); lldb::ModuleSP module = std::make_shared(fspec, aspec); @@ -294,7 +294,7 @@ // Test that when calling ResolveSymbolContext with a line number of 0, all // line entries from // the specified files are returned. - FileSpec fspec(llvm::StringRef(m_pdb_test_exe.c_str()), false); + FileSpec fspec(m_pdb_test_exe, false); ArchSpec aspec("i686-pc-windows"); lldb::ModuleSP module = std::make_shared(fspec, aspec); @@ -343,7 +343,7 @@ // Test that when calling ResolveSymbolContext with a specific line number, // only line entries // which match the requested line are returned. - FileSpec fspec(llvm::StringRef(m_pdb_test_exe.c_str()), false); + FileSpec fspec(m_pdb_test_exe, false); ArchSpec aspec("i686-pc-windows"); lldb::ModuleSP module = std::make_shared(fspec, aspec); @@ -392,7 +392,7 @@ } TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestSimpleClassTypes)) { - FileSpec fspec(llvm::StringRef(m_types_test_exe.c_str()), false); + FileSpec fspec(m_types_test_exe, false); ArchSpec aspec("i686-pc-windows"); lldb::ModuleSP module = std::make_shared(fspec, aspec); @@ -415,7 +415,7 @@ } TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestNestedClassTypes)) { - FileSpec fspec(llvm::StringRef(m_types_test_exe.c_str()), false); + FileSpec fspec(m_types_test_exe, false); ArchSpec aspec("i686-pc-windows"); lldb::ModuleSP module = std::make_shared(fspec, aspec); @@ -438,7 +438,7 @@ } TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestClassInNamespace)) { - FileSpec fspec(llvm::StringRef(m_types_test_exe.c_str()), false); + FileSpec fspec(m_types_test_exe, false); ArchSpec aspec("i686-pc-windows"); lldb::ModuleSP module = std::make_shared(fspec, aspec); @@ -461,7 +461,7 @@ } TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestEnumTypes)) { - FileSpec fspec(llvm::StringRef(m_types_test_exe.c_str()), false); + FileSpec fspec(m_types_test_exe, false); ArchSpec aspec("i686-pc-windows"); lldb::ModuleSP module = std::make_shared(fspec, aspec); @@ -489,7 +489,7 @@ std::string sizeof_var = "sizeof_"; sizeof_var.append(Enum); EXPECT_EQ( - GetGlobalConstantInteger(session, llvm::StringRef(sizeof_var.c_str())), + GetGlobalConstantInteger(session, sizeof_var), enum_type->GetByteSize()); } } @@ -509,7 +509,7 @@ } TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestTypedefs)) { - FileSpec fspec(llvm::StringRef(m_types_test_exe.c_str()), false); + FileSpec fspec(m_types_test_exe, false); ArchSpec aspec("i686-pc-windows"); lldb::ModuleSP module = std::make_shared(fspec, aspec); @@ -543,7 +543,7 @@ } TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestRegexNameMatch)) { - FileSpec fspec(llvm::StringRef(m_types_test_exe.c_str()), false); + FileSpec fspec(m_types_test_exe, false); ArchSpec aspec("i686-pc-windows"); lldb::ModuleSP module = std::make_shared(fspec, aspec); @@ -560,7 +560,7 @@ } TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestMaxMatches)) { - FileSpec fspec(llvm::StringRef(m_types_test_exe.c_str()), false); + FileSpec fspec(m_types_test_exe, false); ArchSpec aspec("i686-pc-windows"); lldb::ModuleSP module = std::make_shared(fspec, aspec); @@ -587,7 +587,7 @@ } TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestNullName)) { - FileSpec fspec(llvm::StringRef(m_types_test_exe.c_str()), false); + FileSpec fspec(m_types_test_exe, false); ArchSpec aspec("i686-pc-windows"); lldb::ModuleSP module = std::make_shared(fspec, aspec); Index: llvm/lib/MC/ELFObjectWriter.cpp =================================================================== --- llvm/lib/MC/ELFObjectWriter.cpp +++ llvm/lib/MC/ELFObjectWriter.cpp @@ -866,7 +866,7 @@ Buf += Name.substr(0, Pos); unsigned Skip = MSD.SectionIndex == ELF::SHN_UNDEF ? 2 : 1; Buf += Name.substr(Pos + Skip); - Name = StringRef(VersionSymSaver.save(StringRef(Buf.c_str()))); + Name = VersionSymSaver.save(StringRef(Buf)); } } Index: llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp =================================================================== --- llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp +++ llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp @@ -226,7 +226,7 @@ std::string *SymNamePtr = nvTM.getManagedStrPool()->getManagedString(Sym); MCOp = GetSymbolRef(OutContext.getOrCreateSymbol( - StringRef(SymNamePtr->c_str()))); + *SymNamePtr)); } void NVPTXAsmPrinter::lowerToMCInst(const MachineInstr *MI, MCInst &OutMI) { Index: llvm/tools/lto/lto.cpp =================================================================== --- llvm/tools/lto/lto.cpp +++ llvm/tools/lto/lto.cpp @@ -153,7 +153,7 @@ attrs.append(MAttrs[i]); } - CG->setAttr(StringRef(attrs.c_str())); + CG->setAttr(attrs); } if (OptLevel < '0' || OptLevel > '3')