Index: include/llvm/Support/CommandLine.h =================================================================== --- include/llvm/Support/CommandLine.h +++ include/llvm/Support/CommandLine.h @@ -1234,20 +1234,35 @@ // object in all cases that it is used. // template -class opt_storage : public DataType { +class opt_storage { public: + DataType Value; OptionValue Default; + opt_storage() : Value(DataType()), Default(DataType()) {} + template void setValue(const T &V, bool initial = false) { - DataType::operator=(V); + Value = V; if (initial) Default = V; } - DataType &getValue() { return *this; } - const DataType &getValue() const { return *this; } + DataType &getValue() { return Value; } + const DataType &getValue() const { return Value; } const OptionValue &getDefault() const { return Default; } + + operator DataType() const { return getValue(); } + + DataType &operator*() { return getValue(); } + DataType *operator->() { return &getValue(); } + const DataType *operator->() const { return &getValue(); } + const DataType &operator*() const { return getValue(); } + operator DataType&() { return getValue(); } + operator const DataType&() const { return getValue(); } + + operator StringRef() const { return StringRef(getValue()); } + bool empty() { return getValue().empty(); } }; // Define a partial specialization to handle things we cannot inherit from. In Index: lib/CodeGen/MachineBlockPlacement.cpp =================================================================== --- lib/CodeGen/MachineBlockPlacement.cpp +++ lib/CodeGen/MachineBlockPlacement.cpp @@ -2829,7 +2829,7 @@ } } if (ViewBlockLayoutWithBFI != GVDT_None && - (ViewBlockFreqFuncName.empty() || + (ViewBlockFreqFuncName->empty() || F->getFunction().getName().equals(ViewBlockFreqFuncName))) { MBFI->view("MBP." + MF.getName(), false); } Index: lib/TableGen/Main.cpp =================================================================== --- lib/TableGen/Main.cpp +++ lib/TableGen/Main.cpp @@ -65,7 +65,7 @@ if (EC) return reportError(argv0, "error opening " + DependFilename + ":" + EC.message() + "\n"); - DepOut.os() << OutputFilename << ":"; + DepOut.os() << *OutputFilename << ":"; for (const auto &Dep : Parser.getDependencies()) { DepOut.os() << ' ' << Dep.first; } @@ -79,7 +79,7 @@ // Parse the input file. ErrorOr> FileOrErr = - MemoryBuffer::getFileOrSTDIN(InputFilename); + MemoryBuffer::getFileOrSTDIN(*InputFilename); if (std::error_code EC = FileOrErr.getError()) return reportError(argv0, "Could not open input file '" + InputFilename + "': " + EC.message() + "\n"); @@ -101,7 +101,7 @@ if (EC) return reportError(argv0, "error opening " + OutputFilename + ":" + EC.message() + "\n"); - if (!DependFilename.empty()) { + if (!DependFilename->empty()) { if (int Ret = createDependencyFile(Parser, argv0)) return Ret; } Index: lib/Target/Mips/MipsOs16.cpp =================================================================== --- lib/Target/Mips/MipsOs16.cpp +++ lib/Target/Mips/MipsOs16.cpp @@ -108,13 +108,13 @@ bool MipsOs16::runOnModule(Module &M) { - bool usingMask = Mips32FunctionMask.length() > 0; + bool usingMask = Mips32FunctionMask->length() > 0; bool doneUsingMask = false; // this will make it stop repeating LLVM_DEBUG(dbgs() << "Run on Module MipsOs16 \n" - << Mips32FunctionMask << "\n"); + << *Mips32FunctionMask << "\n"); if (usingMask) - LLVM_DEBUG(dbgs() << "using mask \n" << Mips32FunctionMask << "\n"); + LLVM_DEBUG(dbgs() << "using mask \n" << *Mips32FunctionMask << "\n"); unsigned int functionIndex = 0; bool modified = false; @@ -126,9 +126,9 @@ LLVM_DEBUG(dbgs() << "Working on " << F.getName() << "\n"); if (usingMask) { if (!doneUsingMask) { - if (functionIndex == Mips32FunctionMask.length()) + if (functionIndex == Mips32FunctionMask->length()) functionIndex = 0; - switch (Mips32FunctionMask[functionIndex]) { + switch ((*Mips32FunctionMask)[functionIndex]) { case '1': LLVM_DEBUG(dbgs() << "mask forced mips32: " << F.getName() << "\n"); F.addFnAttr("nomips16"); Index: lib/Transforms/IPO/BlockExtractor.cpp =================================================================== --- lib/Transforms/IPO/BlockExtractor.cpp +++ lib/Transforms/IPO/BlockExtractor.cpp @@ -73,7 +73,7 @@ /// Gets all of the blocks specified in the input file. void BlockExtractor::loadFile() { - auto ErrOrBuf = MemoryBuffer::getFile(BlockExtractorFile); + auto ErrOrBuf = MemoryBuffer::getFile(*BlockExtractorFile); if (ErrOrBuf.getError()) report_fatal_error("BlockExtractor couldn't load the file."); // Read the file. Index: lib/Transforms/IPO/LowerTypeTests.cpp =================================================================== --- lib/Transforms/IPO/LowerTypeTests.cpp +++ lib/Transforms/IPO/LowerTypeTests.cpp @@ -1598,10 +1598,10 @@ // Handle the command-line summary arguments. This code is for testing // purposes only, so we handle errors directly. if (!ClReadSummary.empty()) { - ExitOnError ExitOnErr("-lowertypetests-read-summary: " + ClReadSummary + + ExitOnError ExitOnErr("-lowertypetests-read-summary: " + *ClReadSummary + ": "); auto ReadSummaryFile = - ExitOnErr(errorOrToExpected(MemoryBuffer::getFile(ClReadSummary))); + ExitOnErr(errorOrToExpected(MemoryBuffer::getFile(*ClReadSummary))); yaml::Input In(ReadSummaryFile->getBuffer()); In >> Summary; @@ -1615,7 +1615,7 @@ .lower(); if (!ClWriteSummary.empty()) { - ExitOnError ExitOnErr("-lowertypetests-write-summary: " + ClWriteSummary + + ExitOnError ExitOnErr("-lowertypetests-write-summary: " + *ClWriteSummary + ": "); std::error_code EC; raw_fd_ostream OS(ClWriteSummary, EC, sys::fs::F_Text); Index: lib/Transforms/IPO/WholeProgramDevirt.cpp =================================================================== --- lib/Transforms/IPO/WholeProgramDevirt.cpp +++ lib/Transforms/IPO/WholeProgramDevirt.cpp @@ -642,10 +642,10 @@ // Handle the command-line summary arguments. This code is for testing // purposes only, so we handle errors directly. if (!ClReadSummary.empty()) { - ExitOnError ExitOnErr("-wholeprogramdevirt-read-summary: " + ClReadSummary + + ExitOnError ExitOnErr("-wholeprogramdevirt-read-summary: " + *ClReadSummary + ": "); auto ReadSummaryFile = - ExitOnErr(errorOrToExpected(MemoryBuffer::getFile(ClReadSummary))); + ExitOnErr(errorOrToExpected(MemoryBuffer::getFile(*ClReadSummary))); yaml::Input In(ReadSummaryFile->getBuffer()); In >> Summary; @@ -661,7 +661,7 @@ if (!ClWriteSummary.empty()) { ExitOnError ExitOnErr( - "-wholeprogramdevirt-write-summary: " + ClWriteSummary + ": "); + "-wholeprogramdevirt-write-summary: " + *ClWriteSummary + ": "); std::error_code EC; raw_fd_ostream OS(ClWriteSummary, EC, sys::fs::F_Text); ExitOnErr(errorCodeToError(EC)); Index: lib/Transforms/Instrumentation/AddressSanitizer.cpp =================================================================== --- lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -2340,7 +2340,7 @@ AsanMemoryAccessCallbackSized[AccessIsWrite][Exp] = checkSanitizerInterfaceFunction(M.getOrInsertFunction( - ClMemoryAccessCallbackPrefix + ExpStr + TypeStr + "N" + EndingStr, + *ClMemoryAccessCallbackPrefix + ExpStr + TypeStr + "N" + EndingStr, FunctionType::get(IRB.getVoidTy(), Args2, false))); for (size_t AccessSizeIndex = 0; AccessSizeIndex < kNumberOfAccessSizes; @@ -2353,7 +2353,7 @@ AsanMemoryAccessCallback[AccessIsWrite][Exp][AccessSizeIndex] = checkSanitizerInterfaceFunction(M.getOrInsertFunction( - ClMemoryAccessCallbackPrefix + ExpStr + Suffix + EndingStr, + *ClMemoryAccessCallbackPrefix + ExpStr + Suffix + EndingStr, FunctionType::get(IRB.getVoidTy(), Args1, false))); } } Index: lib/Transforms/Instrumentation/ControlHeightReduction.cpp =================================================================== --- lib/Transforms/Instrumentation/ControlHeightReduction.cpp +++ lib/Transforms/Instrumentation/ControlHeightReduction.cpp @@ -68,9 +68,9 @@ static void parseCHRFilterFiles() { if (!CHRModuleList.empty()) { - auto FileOrErr = MemoryBuffer::getFile(CHRModuleList); + auto FileOrErr = MemoryBuffer::getFile(*CHRModuleList); if (!FileOrErr) { - errs() << "Error: Couldn't read the chr-module-list file " << CHRModuleList << "\n"; + errs() << "Error: Couldn't read the chr-module-list file " << *CHRModuleList << "\n"; std::exit(1); } StringRef Buf = FileOrErr->get()->getBuffer(); @@ -83,9 +83,9 @@ } } if (!CHRFunctionList.empty()) { - auto FileOrErr = MemoryBuffer::getFile(CHRFunctionList); + auto FileOrErr = MemoryBuffer::getFile(*CHRFunctionList); if (!FileOrErr) { - errs() << "Error: Couldn't read the chr-function-list file " << CHRFunctionList << "\n"; + errs() << "Error: Couldn't read the chr-function-list file " << *CHRFunctionList << "\n"; std::exit(1); } StringRef Buf = FileOrErr->get()->getBuffer(); Index: lib/Transforms/Instrumentation/GCOVProfiling.cpp =================================================================== --- lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -63,11 +63,11 @@ Options.FunctionNamesInData = true; Options.ExitBlockBeforeBody = DefaultExitBlockBeforeBody; - if (DefaultGCOVVersion.size() != 4) { + if (DefaultGCOVVersion->size() != 4) { llvm::report_fatal_error(std::string("Invalid -default-gcov-version: ") + - DefaultGCOVVersion); + *DefaultGCOVVersion); } - memcpy(Options.Version, DefaultGCOVVersion.c_str(), 4); + memcpy(Options.Version, DefaultGCOVVersion->c_str(), 4); return Options; } Index: lib/Transforms/Instrumentation/HWAddressSanitizer.cpp =================================================================== --- lib/Transforms/Instrumentation/HWAddressSanitizer.cpp +++ lib/Transforms/Instrumentation/HWAddressSanitizer.cpp @@ -302,14 +302,14 @@ HwasanMemoryAccessCallbackSized[AccessIsWrite] = checkSanitizerInterfaceFunction(M.getOrInsertFunction( - ClMemoryAccessCallbackPrefix + TypeStr + "N" + EndingStr, + *ClMemoryAccessCallbackPrefix + TypeStr + "N" + EndingStr, FunctionType::get(IRB.getVoidTy(), {IntptrTy, IntptrTy}, false))); for (size_t AccessSizeIndex = 0; AccessSizeIndex < kNumberOfAccessSizes; AccessSizeIndex++) { HwasanMemoryAccessCallback[AccessIsWrite][AccessSizeIndex] = checkSanitizerInterfaceFunction(M.getOrInsertFunction( - ClMemoryAccessCallbackPrefix + TypeStr + + *ClMemoryAccessCallbackPrefix + TypeStr + itostr(1ULL << AccessSizeIndex) + EndingStr, FunctionType::get(IRB.getVoidTy(), {IntptrTy}, false))); } Index: tools/bugpoint/ExecutionDriver.cpp =================================================================== --- tools/bugpoint/ExecutionDriver.cpp +++ tools/bugpoint/ExecutionDriver.cpp @@ -326,7 +326,7 @@ FileRemover BitcodeFileRemover(BitcodePath, CreatedBitcode && !SaveTemps); if (OutputFile.empty()) - OutputFile = OutputPrefix + "-execution-output-%%%%%%%"; + OutputFile = *OutputPrefix + "-execution-output-%%%%%%%"; // Check to see if this is a valid output filename... SmallString<128> UniqueFile; Index: tools/bugpoint/Miscompilation.cpp =================================================================== --- tools/bugpoint/Miscompilation.cpp +++ tools/bugpoint/Miscompilation.cpp @@ -353,14 +353,14 @@ << " Please report a bug!\n"; errs() << " Continuing on with un-loop-extracted version.\n"; - BD.writeProgramToFile(OutputPrefix + "-loop-extract-fail-tno.bc", + BD.writeProgramToFile(*OutputPrefix + "-loop-extract-fail-tno.bc", *ToNotOptimize); - BD.writeProgramToFile(OutputPrefix + "-loop-extract-fail-to.bc", + BD.writeProgramToFile(*OutputPrefix + "-loop-extract-fail-to.bc", *ToOptimize); - BD.writeProgramToFile(OutputPrefix + "-loop-extract-fail-to-le.bc", + BD.writeProgramToFile(*OutputPrefix + "-loop-extract-fail-to-le.bc", *ToOptimizeLoopExtracted); - errs() << "Please submit the " << OutputPrefix + errs() << "Please submit the " << *OutputPrefix << "-loop-extract-fail-*.bc files.\n"; return MadeChange; } Index: tools/bugpoint/OptimizerDriver.cpp =================================================================== --- tools/bugpoint/OptimizerDriver.cpp +++ tools/bugpoint/OptimizerDriver.cpp @@ -92,7 +92,7 @@ // Output the input to the current pass to a bitcode file, emit a message // telling the user how to reproduce it: opt -foo blah.bc // - std::string Filename = OutputPrefix + "-" + ID + ".bc"; + std::string Filename = *OutputPrefix + "-" + ID + ".bc"; if (writeProgramToFile(Filename, M)) { errs() << "Error opening file '" << Filename << "' for writing!\n"; return; Index: tools/bugpoint/ToolRunner.cpp =================================================================== --- tools/bugpoint/ToolRunner.cpp +++ tools/bugpoint/ToolRunner.cpp @@ -868,7 +868,7 @@ if (!RemoteClient.empty()) { auto Path = sys::findProgramByName(RemoteClient); if (!Path) { - Message = "Cannot find `" + RemoteClient + "' in PATH: " + + Message = "Cannot find `" + *RemoteClient + "' in PATH: " + Path.getError().message() + "\n"; return nullptr; } Index: tools/llc/llc.cpp =================================================================== --- tools/llc/llc.cpp +++ tools/llc/llc.cpp @@ -397,7 +397,7 @@ // If user just wants to list available options, skip module loading if (!SkipModule) { if (InputLanguage == "mir" || - (InputLanguage == "" && StringRef(InputFilename).endswith(".mir"))) { + (InputLanguage == "" && StringRef(*InputFilename).endswith(".mir"))) { MIR = createMIRParserFromFile(InputFilename, Err, Context); if (MIR) M = MIR->parseIRModule(); @@ -505,7 +505,7 @@ // called on any passes. if (!NoVerify && verifyModule(*M, &errs())) { std::string Prefix = - (Twine(argv[0]) + Twine(": ") + Twine(InputFilename)).str(); + (Twine(argv[0]) + Twine(": ") + Twine(*InputFilename)).str(); WithColor::error(errs(), Prefix) << "input module is broken!\n"; return 1; } Index: tools/lli/lli.cpp =================================================================== --- tools/lli/lli.cpp +++ tools/lli/lli.cpp @@ -548,8 +548,8 @@ } else { // Otherwise, if there is a .bc suffix on the executable strip it off, it // might confuse the program. - if (StringRef(InputFile).endswith(".bc")) - InputFile.erase(InputFile.length() - 3); + if (StringRef(*InputFile).endswith(".bc")) + InputFile->erase(InputFile->length() - 3); } // Add the module's name to the start of the vector of arguments to main(). @@ -563,7 +563,7 @@ Function *EntryFn = Mod->getFunction(EntryFunc); if (!EntryFn) { WithColor::error(errs(), argv[0]) - << '\'' << EntryFunc << "\' function not found in module.\n"; + << '\'' << *EntryFunc << "\' function not found in module.\n"; return -1; } @@ -585,9 +585,9 @@ WithColor::error(errs(), argv[0]) << "-remote-mcjit requires -mcjit-remote-process.\n"; exit(1); - } else if (!sys::fs::can_execute(ChildExecPath)) { + } else if (!sys::fs::can_execute(*ChildExecPath)) { WithColor::error(errs(), argv[0]) - << "unable to find usable child executable: '" << ChildExecPath + << "unable to find usable child executable: '" << *ChildExecPath << "'\n"; return -1; } @@ -904,9 +904,9 @@ // Execute the child process. std::unique_ptr ChildPath, ChildIn, ChildOut; { - ChildPath.reset(new char[ChildExecPath.size() + 1]); - std::copy(ChildExecPath.begin(), ChildExecPath.end(), &ChildPath[0]); - ChildPath[ChildExecPath.size()] = '\0'; + ChildPath.reset(new char[ChildExecPath->size() + 1]); + std::copy(ChildExecPath->begin(), ChildExecPath->end(), &ChildPath[0]); + ChildPath[ChildExecPath->size()] = '\0'; std::string ChildInStr = utostr(PipeFD[0][0]); ChildIn.reset(new char[ChildInStr.size() + 1]); std::copy(ChildInStr.begin(), ChildInStr.end(), &ChildIn[0]); @@ -918,7 +918,7 @@ } char * const args[] = { &ChildPath[0], &ChildIn[0], &ChildOut[0], nullptr }; - int rc = execv(ChildExecPath.c_str(), args); + int rc = execv(ChildExecPath->c_str(), args); if (rc != 0) perror("Error executing child process: "); llvm_unreachable("Error executing child process"); Index: tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp =================================================================== --- tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp +++ tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp @@ -888,7 +888,7 @@ uint64_t BufferSizeBits = Stream.getBitcodeBytes().size() * CHAR_BIT; // Print a summary of the read file. - outs() << "Summary of " << InputFilename << ":\n"; + outs() << "Summary of " << *InputFilename << ":\n"; outs() << " Total size: "; PrintSize(BufferSizeBits); outs() << "\n"; Index: tools/llvm-cat/llvm-cat.cpp =================================================================== --- tools/llvm-cat/llvm-cat.cpp +++ tools/llvm-cat/llvm-cat.cpp @@ -82,7 +82,7 @@ std::error_code EC; raw_fd_ostream OS(OutputFilename, EC, sys::fs::OpenFlags::F_None); if (EC) { - errs() << argv[0] << ": cannot open " << OutputFilename << " for writing: " + errs() << argv[0] << ": cannot open " << *OutputFilename << " for writing: " << EC.message(); return 1; } Index: tools/llvm-cfi-verify/llvm-cfi-verify.cpp =================================================================== --- tools/llvm-cfi-verify/llvm-cfi-verify.cpp +++ tools/llvm-cfi-verify/llvm-cfi-verify.cpp @@ -100,7 +100,7 @@ void printInstructionStatus(unsigned BlameLine, bool CFIProtected, const DILineInfo &LineInfo) { if (BlameLine) { - outs() << "Blacklist Match: " << BlacklistFilename << ":" << BlameLine + outs() << "Blacklist Match: " << *BlacklistFilename << ":" << BlameLine << "\n"; if (CFIProtected) outs() << "====> Unexpected Protected\n"; @@ -155,7 +155,7 @@ auto InliningInfo = Analysis.symbolizeInlinedCode(Address); if (!InliningInfo || InliningInfo->getNumberOfFrames() == 0) { errs() << "Failed to symbolise " << format_hex(Address, 2) - << " with line tables from " << InputFilename << "\n"; + << " with line tables from " << *InputFilename << "\n"; exit(EXIT_FAILURE); } @@ -238,7 +238,7 @@ outs() << "\nBlacklist Results:\n"; for (const auto &KV : BlameCounter) { - outs() << " " << BlacklistFilename << ":" << KV.first << " affects " + outs() << " " << *BlacklistFilename << ":" << KV.first << " affects " << KV.second << " indirect CF instructions.\n"; } } Index: tools/llvm-cov/CodeCoverage.cpp =================================================================== --- tools/llvm-cov/CodeCoverage.cpp +++ tools/llvm-cov/CodeCoverage.cpp @@ -654,7 +654,7 @@ ViewOpts.Debug = DebugDump; if (!CovFilename.empty()) - ObjectFilenames.emplace_back(CovFilename); + ObjectFilenames.emplace_back(*CovFilename); for (const std::string &Filename : CovFilenames) ObjectFilenames.emplace_back(Filename); if (ObjectFilenames.empty()) { @@ -678,7 +678,7 @@ // If path-equivalence was given and is a comma seperated pair then set // PathRemapping. - auto EquivPair = StringRef(PathRemap).split(','); + auto EquivPair = StringRef(*PathRemap).split(','); if (!(EquivPair.first.empty() && EquivPair.second.empty())) PathRemapping = EquivPair; Index: tools/llvm-cov/TestingSupport.cpp =================================================================== --- tools/llvm-cov/TestingSupport.cpp +++ tools/llvm-cov/TestingSupport.cpp @@ -75,7 +75,7 @@ return 1; int FD; - if (auto Err = sys::fs::openFileForWrite(OutputFilename, FD)) { + if (auto Err = sys::fs::openFileForWrite(*OutputFilename, FD)) { errs() << "error: " << Err.message() << "\n"; return 1; } Index: tools/llvm-cxxmap/llvm-cxxmap.cpp =================================================================== --- tools/llvm-cxxmap/llvm-cxxmap.cpp +++ tools/llvm-cxxmap/llvm-cxxmap.cpp @@ -133,20 +133,20 @@ cl::ParseCommandLineOptions(argc, argv, "LLVM C++ mangled name remapper\n"); - auto OldSymbolBufOrError = MemoryBuffer::getFileOrSTDIN(OldSymbolFile); + auto OldSymbolBufOrError = MemoryBuffer::getFileOrSTDIN(*OldSymbolFile); if (!OldSymbolBufOrError) exitWithErrorCode(OldSymbolBufOrError.getError(), OldSymbolFile); - auto NewSymbolBufOrError = MemoryBuffer::getFileOrSTDIN(NewSymbolFile); + auto NewSymbolBufOrError = MemoryBuffer::getFileOrSTDIN(*NewSymbolFile); if (!NewSymbolBufOrError) exitWithErrorCode(NewSymbolBufOrError.getError(), NewSymbolFile); - auto RemappingBufOrError = MemoryBuffer::getFileOrSTDIN(RemappingFile); + auto RemappingBufOrError = MemoryBuffer::getFileOrSTDIN(*RemappingFile); if (!RemappingBufOrError) exitWithErrorCode(RemappingBufOrError.getError(), RemappingFile); std::error_code EC; - raw_fd_ostream OS(OutputFilename.data(), EC, sys::fs::F_Text); + raw_fd_ostream OS(OutputFilename->data(), EC, sys::fs::F_Text); if (EC) exitWithErrorCode(EC, OutputFilename); Index: tools/llvm-dis/llvm-dis.cpp =================================================================== --- tools/llvm-dis/llvm-dis.cpp +++ tools/llvm-dis/llvm-dis.cpp @@ -158,7 +158,7 @@ cl::ParseCommandLineOptions(argc, argv, "llvm .bc -> .ll disassembler\n"); std::unique_ptr MB = - ExitOnErr(errorOrToExpected(MemoryBuffer::getFileOrSTDIN(InputFilename))); + ExitOnErr(errorOrToExpected(MemoryBuffer::getFileOrSTDIN(*InputFilename))); std::unique_ptr M = ExitOnErr(getLazyBitcodeModule( *MB, Context, /*ShouldLazyLoadMetadata=*/true, SetImporting)); if (MaterializeMetadata) Index: tools/llvm-dwarfdump/llvm-dwarfdump.cpp =================================================================== --- tools/llvm-dwarfdump/llvm-dwarfdump.cpp +++ tools/llvm-dwarfdump/llvm-dwarfdump.cpp @@ -563,7 +563,7 @@ std::error_code EC; OutputFile = llvm::make_unique(OutputFilename, EC, sys::fs::F_None); - error("Unable to open output file" + OutputFilename, EC); + error("Unable to open output file" + *OutputFilename, EC); // Don't remove output file if we exit with an error. OutputFile->keep(); } @@ -574,10 +574,10 @@ // Defaults to dumping all sections, unless brief mode is specified in which // case only the .debug_info section in dumped. #define HANDLE_DWARF_SECTION(ENUM_NAME, ELF_NAME, CMDLINE_NAME) \ - if (Dump##ENUM_NAME.IsRequested) { \ + if (Dump##ENUM_NAME->IsRequested) { \ DumpType |= DIDT_##ENUM_NAME; \ - if (Dump##ENUM_NAME.HasValue) { \ - DumpOffsets[DIDT_ID_##ENUM_NAME] = Dump##ENUM_NAME.Val; \ + if (Dump##ENUM_NAME->HasValue) { \ + DumpOffsets[DIDT_ID_##ENUM_NAME] = Dump##ENUM_NAME->Val; \ OffsetRequested = true; \ } \ } Index: tools/llvm-dwp/llvm-dwp.cpp =================================================================== --- tools/llvm-dwp/llvm-dwp.cpp +++ tools/llvm-dwp/llvm-dwp.cpp @@ -700,7 +700,7 @@ Optional BOS; raw_pwrite_stream *OS; if (EC) - return error(Twine(OutputFilename) + ": " + EC.message(), Context); + return error(Twine(*OutputFilename) + ": " + EC.message(), Context); if (OutFile.supportsSeeking()) { OS = &OutFile; } else { Index: tools/llvm-exegesis/llvm-exegesis.cpp =================================================================== --- tools/llvm-exegesis/llvm-exegesis.cpp +++ tools/llvm-exegesis/llvm-exegesis.cpp @@ -118,7 +118,7 @@ for (unsigned I = 0, E = MCInstrInfo.getNumOpcodes(); I < E; ++I) if (MCInstrInfo.getName(I) == OpcodeName) return I; - llvm::report_fatal_error(llvm::Twine("unknown opcode ").concat(OpcodeName)); + llvm::report_fatal_error(llvm::Twine("unknown opcode ").concat(*OpcodeName)); } // Generates code snippets for opcode `Opcode`. Index: tools/llvm-lto/llvm-lto.cpp =================================================================== --- tools/llvm-lto/llvm-lto.cpp +++ tools/llvm-lto/llvm-lto.cpp @@ -388,7 +388,7 @@ } std::error_code EC; assert(!OutputFilename.empty()); - raw_fd_ostream OS(OutputFilename + ".thinlto.bc", EC, + raw_fd_ostream OS(*OutputFilename + ".thinlto.bc", EC, sys::fs::OpenFlags::F_None); error(EC, "error opening the file '" + OutputFilename + ".thinlto.bc'"); WriteIndexToFile(CombinedIndex, OS); @@ -399,8 +399,8 @@ /// \p NewPrefix strings, if it was specified. static void getThinLTOOldAndNewPrefix(std::string &OldPrefix, std::string &NewPrefix) { - assert(ThinLTOPrefixReplace.empty() || - ThinLTOPrefixReplace.find(";") != StringRef::npos); + assert(ThinLTOPrefixReplace->empty() || + ThinLTOPrefixReplace->find(";") != StringRef::npos); StringRef PrefixReplace = ThinLTOPrefixReplace; std::pair Split = PrefixReplace.split(";"); OldPrefix = Split.first.str(); @@ -445,7 +445,7 @@ std::unique_ptr loadCombinedIndex() { if (ThinLTOIndex.empty()) report_fatal_error("Missing -thinlto-index for ThinLTO promotion stage"); - ExitOnError ExitOnErr("llvm-lto: error loading file '" + ThinLTOIndex + + ExitOnError ExitOnErr("llvm-lto: error loading file '" + *ThinLTOIndex + "': "); return ExitOnErr(getModuleSummaryIndexForFile(ThinLTOIndex)); } @@ -917,7 +917,7 @@ CodeGen.addMustPreserveSymbol(KeptDSOSyms[i]); // Set cpu and attrs strings for the default target/subtarget. - CodeGen.setCpu(MCPU.c_str()); + CodeGen.setCpu(MCPU->c_str()); CodeGen.setOptLevel(OptLevel - '0'); Index: tools/llvm-lto2/llvm-lto2.cpp =================================================================== --- tools/llvm-lto2/llvm-lto2.cpp +++ tools/llvm-lto2/llvm-lto2.cpp @@ -206,7 +206,7 @@ Conf.DebugPassManager = DebugPassManager; if (SaveTemps) - check(Conf.addSaveTemps(OutputFilename + "."), + check(Conf.addSaveTemps(*OutputFilename + "."), "Config::addSaveTemps failed"); // Optimization remarks. @@ -297,7 +297,7 @@ auto AddStream = [&](size_t Task) -> std::unique_ptr { - std::string Path = OutputFilename + "." + utostr(Task); + std::string Path = *OutputFilename + "." + utostr(Task); std::error_code EC; auto S = llvm::make_unique(Path, EC, sys::fs::F_None); Index: tools/llvm-mc/llvm-mc.cpp =================================================================== --- tools/llvm-mc/llvm-mc.cpp +++ tools/llvm-mc/llvm-mc.cpp @@ -323,13 +323,13 @@ return 1; // Now that GetTarget() has (potentially) replaced TripleName, it's safe to // construct the Triple object. - Triple TheTriple(TripleName); + Triple TheTriple(*TripleName); ErrorOr> BufferPtr = - MemoryBuffer::getFileOrSTDIN(InputFilename); + MemoryBuffer::getFileOrSTDIN(*InputFilename); if (std::error_code EC = BufferPtr.getError()) { WithColor::error(errs(), ProgName) - << InputFilename << ": " << EC.message() << '\n'; + << *InputFilename << ": " << EC.message() << '\n'; return 1; } MemoryBuffer *Buffer = BufferPtr->get(); @@ -444,7 +444,7 @@ MCInstPrinter *IP = nullptr; if (FileType == OFT_AssemblyFile) { - IP = TheTarget->createMCInstPrinter(Triple(TripleName), OutputAsmVariant, + IP = TheTarget->createMCInstPrinter(Triple(*TripleName), OutputAsmVariant, *MAI, *MCII, *MRI); if (!IP) { Index: tools/llvm-mca/llvm-mca.cpp =================================================================== --- tools/llvm-mca/llvm-mca.cpp +++ tools/llvm-mca/llvm-mca.cpp @@ -183,7 +183,7 @@ const Target *getTarget(const char *ProgName) { if (TripleName.empty()) TripleName = Triple::normalize(sys::getDefaultTargetTriple()); - Triple TheTriple(TripleName); + Triple TheTriple(*TripleName); // Get the target specific parser. std::string Error; @@ -354,12 +354,12 @@ // GetTarget() may replaced TripleName with a default triple. // For safety, reconstruct the Triple object. - Triple TheTriple(TripleName); + Triple TheTriple(*TripleName); ErrorOr> BufferPtr = - MemoryBuffer::getFileOrSTDIN(InputFilename); + MemoryBuffer::getFileOrSTDIN(*InputFilename); if (std::error_code EC = BufferPtr.getError()) { - WithColor::error() << InputFilename << ": " << EC.message() << '\n'; + WithColor::error() << *InputFilename << ": " << EC.message() << '\n'; return 1; } @@ -391,7 +391,7 @@ std::unique_ptr MCIA( TheTarget->createMCInstrAnalysis(MCII.get())); - if (!MCPU.compare("native")) + if (!MCPU->compare("native")) MCPU = llvm::sys::getHostCPUName(); std::unique_ptr STI( @@ -400,7 +400,7 @@ return 1; if (!PrintInstructionTables && !STI->getSchedModel().isOutOfOrder()) { - WithColor::error() << "please specify an out-of-order cpu. '" << MCPU + WithColor::error() << "please specify an out-of-order cpu. '" << *MCPU << "' is an in-order cpu.\n"; return 1; } @@ -408,12 +408,12 @@ if (!STI->getSchedModel().hasInstrSchedModel()) { WithColor::error() << "unable to find instruction-level scheduling information for" - << " target triple '" << TheTriple.normalize() << "' and cpu '" << MCPU + << " target triple '" << TheTriple.normalize() << "' and cpu '" << *MCPU << "'.\n"; if (STI->getSchedModel().InstrItineraries) WithColor::note() - << "cpu '" << MCPU << "' provides itineraries. However, " + << "cpu '" << *MCPU << "' provides itineraries. However, " << "instruction itineraries are currently unsupported.\n"; return 1; } @@ -442,7 +442,7 @@ if (OutputAsmVariant >= 0) AssemblerDialect = static_cast(OutputAsmVariant); std::unique_ptr IP(TheTarget->createMCInstPrinter( - Triple(TripleName), AssemblerDialect, *MAI, *MCII, *MRI)); + Triple(*TripleName), AssemblerDialect, *MAI, *MCII, *MRI)); if (!IP) { WithColor::error() << "unable to create instruction printer for target triple '" Index: tools/llvm-modextract/llvm-modextract.cpp =================================================================== --- tools/llvm-modextract/llvm-modextract.cpp +++ tools/llvm-modextract/llvm-modextract.cpp @@ -42,7 +42,7 @@ ExitOnError ExitOnErr("llvm-modextract: error: "); std::unique_ptr MB = - ExitOnErr(errorOrToExpected(MemoryBuffer::getFileOrSTDIN(InputFilename))); + ExitOnErr(errorOrToExpected(MemoryBuffer::getFileOrSTDIN(*InputFilename))); std::vector Ms = ExitOnErr(getBitcodeModuleList(*MB)); LLVMContext Context; Index: tools/llvm-objdump/MachODump.cpp =================================================================== --- tools/llvm-objdump/MachODump.cpp +++ tools/llvm-objdump/MachODump.cpp @@ -141,7 +141,7 @@ const char **McpuDefault, const Target **ThumbTarget) { // Figure out the target triple. - llvm::Triple TT(TripleName); + llvm::Triple TT(*TripleName); if (TripleName.empty()) { TT = MachOObj->getArchTriple(McpuDefault); TripleName = TT.str(); @@ -168,7 +168,7 @@ errs() << "llvm-objdump: error: unable to get target for '"; if (!TheTarget) - errs() << TripleName; + errs() << *TripleName; else errs() << ThumbTripleName; errs() << "', see --version and --triple.\n"; @@ -6846,7 +6846,7 @@ } int AsmPrinterVariant = AsmInfo->getAssemblerDialect(); std::unique_ptr IP(TheTarget->createMCInstPrinter( - Triple(TripleName), AsmPrinterVariant, *AsmInfo, *InstrInfo, *MRI)); + Triple(*TripleName), AsmPrinterVariant, *AsmInfo, *InstrInfo, *MRI)); // Set the display preference for hex vs. decimal immediates. IP->setPrintImmHex(PrintImmHex); // Comment stream and backing vector. @@ -6861,7 +6861,7 @@ if (!AsmInfo || !STI || !DisAsm || !IP) { errs() << "error: couldn't initialize disassembler for target " - << TripleName << '\n'; + << *TripleName << '\n'; return; } @@ -6954,7 +6954,7 @@ // get the sections and supply it to the section name parsing machinery. if (!DSYMFile.empty()) { ErrorOr> BufOrErr = - MemoryBuffer::getFileOrSTDIN(DSYMFile); + MemoryBuffer::getFileOrSTDIN(*DSYMFile); if (std::error_code EC = BufOrErr.getError()) { errs() << "llvm-objdump: " << Filename << ": " << EC.message() << '\n'; return; @@ -7017,7 +7017,7 @@ } } if (!DisSymName.empty() && !DisSymNameFound) { - outs() << "Can't find -dis-symname: " << DisSymName << "\n"; + outs() << "Can't find -dis-symname: " << *DisSymName << "\n"; return; } // Set up the block of info used by the Symbolizer call backs. @@ -7063,7 +7063,7 @@ bool containsSym = Sections[SectIdx].containsSymbol(Symbols[SymIdx]); if (!containsSym) { if (!DisSymName.empty() && DisSymName == SymName) { - outs() << "-dis-symname: " << DisSymName << " not in the section\n"; + outs() << "-dis-symname: " << *DisSymName << " not in the section\n"; return; } continue; Index: tools/llvm-objdump/llvm-objdump.cpp =================================================================== --- tools/llvm-objdump/llvm-objdump.cpp +++ tools/llvm-objdump/llvm-objdump.cpp @@ -1304,25 +1304,25 @@ MCObjectFileInfo MOFI; MCContext Ctx(AsmInfo.get(), MRI.get(), &MOFI); // FIXME: for now initialize MCObjectFileInfo with default values - MOFI.InitMCObjectFileInfo(Triple(TripleName), false, Ctx); + MOFI.InitMCObjectFileInfo(Triple(*TripleName), false, Ctx); std::unique_ptr DisAsm( TheTarget->createMCDisassembler(*STI, Ctx)); if (!DisAsm) report_error(Obj->getFileName(), "no disassembler for target " + - TripleName); + *TripleName); std::unique_ptr MIA( TheTarget->createMCInstrAnalysis(MII.get())); int AsmPrinterVariant = AsmInfo->getAssemblerDialect(); std::unique_ptr IP(TheTarget->createMCInstPrinter( - Triple(TripleName), AsmPrinterVariant, *AsmInfo, *MII, *MRI)); + Triple(*TripleName), AsmPrinterVariant, *AsmInfo, *MII, *MRI)); if (!IP) report_error(Obj->getFileName(), "no instruction printer for target " + TripleName); IP->setPrintImmHex(PrintImmHex); - PrettyPrinter &PIP = selectPrettyPrinter(Triple(TripleName)); + PrettyPrinter &PIP = selectPrettyPrinter(Triple(*TripleName)); StringRef Fmt = Obj->getBytesInAddress() > 4 ? "\t\t%016" PRIx64 ": " : "\t\t\t%08" PRIx64 ": "; Index: tools/llvm-opt-report/OptReport.cpp =================================================================== --- tools/llvm-opt-report/OptReport.cpp +++ tools/llvm-opt-report/OptReport.cpp @@ -272,9 +272,9 @@ static bool readLocationInfo(LocationInfoTy &LocationInfo) { ErrorOr> Buf = - MemoryBuffer::getFileOrSTDIN(InputFileName); + MemoryBuffer::getFileOrSTDIN(*InputFileName); if (std::error_code EC = Buf.getError()) { - WithColor::error() << "Can't open file " << InputFileName << ": " + WithColor::error() << "Can't open file " << *InputFileName << ": " << EC.message() << "\n"; return false; } @@ -291,7 +291,7 @@ llvm::raw_fd_ostream OS(OutputFileName, EC, llvm::sys::fs::F_Text); if (EC) { - WithColor::error() << "Can't open file " << OutputFileName << ": " + WithColor::error() << "Can't open file " << *OutputFileName << ": " << EC.message() << "\n"; return false; } @@ -300,7 +300,7 @@ for (auto &FI : LocationInfo) { SmallString<128> FileName(FI.first); if (!InputRelDir.empty()) { - if (std::error_code EC = sys::fs::make_absolute(InputRelDir, FileName)) { + if (std::error_code EC = sys::fs::make_absolute(*InputRelDir, FileName)) { WithColor::error() << "Can't resolve file path to " << FileName << ": " << EC.message() << "\n"; return false; Index: tools/llvm-pdbutil/llvm-pdbutil.cpp =================================================================== --- tools/llvm-pdbutil/llvm-pdbutil.cpp +++ tools/llvm-pdbutil/llvm-pdbutil.cpp @@ -1390,7 +1390,7 @@ if (!Success) { InfoStream &IS = cantFail(File.getPDBInfoStream()); Index = ExitOnErr(IS.getNamedStreamIndex(opts::exportstream::Stream)); - outs() << "Dumping contents of stream '" << opts::exportstream::Stream + outs() << "Dumping contents of stream '" << *opts::exportstream::Stream << "' (index " << Index << ") to file " << OutFileName << ".\n"; } @@ -1444,14 +1444,14 @@ if (opts::BytesSubcommand) { if (!parseRange(opts::bytes::DumpBlockRangeOpt, opts::bytes::DumpBlockRange)) { - errs() << "Argument '" << opts::bytes::DumpBlockRangeOpt + errs() << "Argument '" << *opts::bytes::DumpBlockRangeOpt << "' invalid format.\n"; errs().flush(); exit(1); } if (!parseRange(opts::bytes::DumpByteRangeOpt, opts::bytes::DumpByteRange)) { - errs() << "Argument '" << opts::bytes::DumpByteRangeOpt + errs() << "Argument '" << *opts::bytes::DumpByteRangeOpt << "' invalid format.\n"; errs().flush(); exit(1); Index: tools/llvm-profdata/llvm-profdata.cpp =================================================================== --- tools/llvm-profdata/llvm-profdata.cpp +++ tools/llvm-profdata/llvm-profdata.cpp @@ -889,7 +889,7 @@ OutputFilename = "-"; std::error_code EC; - raw_fd_ostream OS(OutputFilename.data(), EC, sys::fs::F_Text); + raw_fd_ostream OS(OutputFilename->data(), EC, sys::fs::F_Text); if (EC) exitWithErrorCode(EC, OutputFilename); Index: tools/llvm-rtdyld/llvm-rtdyld.cpp =================================================================== --- tools/llvm-rtdyld/llvm-rtdyld.cpp +++ tools/llvm-rtdyld/llvm-rtdyld.cpp @@ -469,7 +469,7 @@ } // Dispatch to _main(). - errs() << "loaded '" << EntryPoint << "' at: " << (void*)MainAddress << "\n"; + errs() << "loaded '" << *EntryPoint << "' at: " << (void*)MainAddress << "\n"; int (*Main)(int, const char**) = (int(*)(int,const char**)) uintptr_t(MainAddress); @@ -671,7 +671,7 @@ std::unique_ptr MII(TheTarget->createMCInstrInfo()); std::unique_ptr InstPrinter( - TheTarget->createMCInstPrinter(Triple(TripleName), 0, *MAI, *MII, *MRI)); + TheTarget->createMCInstPrinter(Triple(*TripleName), 0, *MAI, *MII, *MRI)); // Load any dylibs requested on the command line. loadDylibs(); Index: tools/llvm-split/llvm-split.cpp =================================================================== --- tools/llvm-split/llvm-split.cpp +++ tools/llvm-split/llvm-split.cpp @@ -56,7 +56,7 @@ SplitModule(std::move(M), NumOutputs, [&](std::unique_ptr MPart) { std::error_code EC; std::unique_ptr Out( - new ToolOutputFile(OutputFilename + utostr(I++), EC, sys::fs::F_None)); + new ToolOutputFile(*OutputFilename + utostr(I++), EC, sys::fs::F_None)); if (EC) { errs() << EC.message() << '\n'; exit(1); Index: tools/llvm-xray/xray-account.cpp =================================================================== --- tools/llvm-xray/xray-account.cpp +++ tools/llvm-xray/xray-account.cpp @@ -442,7 +442,7 @@ if (!InstrumentationMapOrError) return joinErrors(make_error( Twine("Cannot open instrumentation map '") + - AccountInstrMap + "'", + *AccountInstrMap + "'", std::make_error_code(std::errc::invalid_argument)), InstrumentationMapOrError.takeError()); Map = std::move(*InstrumentationMapOrError); @@ -452,7 +452,7 @@ raw_fd_ostream OS(AccountOutput, EC, sys::fs::OpenFlags::F_Text); if (EC) return make_error( - Twine("Cannot open file '") + AccountOutput + "' for writing.", EC); + Twine("Cannot open file '") + *AccountOutput + "' for writing.", EC); const auto &FunctionAddresses = Map.getFunctionAddresses(); symbolize::LLVMSymbolizer::Options Opts( @@ -465,7 +465,7 @@ if (!TraceOrErr) return joinErrors( make_error( - Twine("Failed loading input file '") + AccountInput + "'", + Twine("Failed loading input file '") + *AccountInput + "'", std::make_error_code(std::errc::executable_format_error)), TraceOrErr.takeError()); @@ -493,7 +493,7 @@ } if (!AccountKeepGoing) return make_error( - Twine("Failed accounting function calls in file '") + AccountInput + + Twine("Failed accounting function calls in file '") + *AccountInput + "'.", std::make_error_code(std::errc::executable_format_error)); } Index: tools/llvm-xray/xray-converter.cpp =================================================================== --- tools/llvm-xray/xray-converter.cpp +++ tools/llvm-xray/xray-converter.cpp @@ -350,7 +350,7 @@ if (!InstrumentationMapOrError) return joinErrors(make_error( Twine("Cannot open instrumentation map '") + - ConvertInstrMap + "'", + *ConvertInstrMap + "'", std::make_error_code(std::errc::invalid_argument)), InstrumentationMapOrError.takeError()); Map = std::move(*InstrumentationMapOrError); @@ -370,13 +370,13 @@ : sys::fs::OpenFlags::F_Text); if (EC) return make_error( - Twine("Cannot open file '") + ConvertOutput + "' for writing.", EC); + Twine("Cannot open file '") + *ConvertOutput + "' for writing.", EC); auto TraceOrErr = loadTraceFile(ConvertInput, ConvertSortInput); if (!TraceOrErr) return joinErrors( make_error( - Twine("Failed loading input file '") + ConvertInput + "'.", + Twine("Failed loading input file '") + *ConvertInput + "'.", std::make_error_code(std::errc::executable_format_error)), TraceOrErr.takeError()); Index: tools/llvm-xray/xray-extract.cpp =================================================================== --- tools/llvm-xray/xray-extract.cpp +++ tools/llvm-xray/xray-extract.cpp @@ -76,7 +76,7 @@ if (!InstrumentationMapOrError) return joinErrors(make_error( Twine("Cannot extract instrumentation map from '") + - ExtractInput + "'.", + *ExtractInput + "'.", std::make_error_code(std::errc::invalid_argument)), InstrumentationMapOrError.takeError()); @@ -84,7 +84,7 @@ raw_fd_ostream OS(ExtractOutput, EC, sys::fs::OpenFlags::F_Text); if (EC) return make_error( - Twine("Cannot open file '") + ExtractOutput + "' for writing.", EC); + Twine("Cannot open file '") + *ExtractOutput + "' for writing.", EC); const auto &FunctionAddresses = InstrumentationMapOrError->getFunctionAddresses(); symbolize::LLVMSymbolizer::Options Opts( Index: tools/llvm-xray/xray-fdr-dump.cpp =================================================================== --- tools/llvm-xray/xray-fdr-dump.cpp +++ tools/llvm-xray/xray-fdr-dump.cpp @@ -37,14 +37,14 @@ static CommandRegistration Unused(&Dump, []() -> Error { // Open the file provided. int Fd; - if (auto EC = sys::fs::openFileForRead(DumpInput, Fd)) + if (auto EC = sys::fs::openFileForRead(*DumpInput, Fd)) return createStringError(EC, "Cannot open file '%s' for read.", - DumpInput.c_str()); + DumpInput->c_str()); uint64_t FileSize; - if (auto EC = sys::fs::file_size(DumpInput, FileSize)) + if (auto EC = sys::fs::file_size(*DumpInput, FileSize)) return createStringError(EC, "Failed to get file size for '%s'.", - DumpInput.c_str()); + DumpInput->c_str()); std::error_code EC; sys::fs::mapped_file_region MappedFile( Index: tools/llvm-xray/xray-graph-diff.cpp =================================================================== --- tools/llvm-xray/xray-graph-diff.cpp +++ tools/llvm-xray/xray-graph-diff.cpp @@ -474,7 +474,7 @@ raw_fd_ostream OS(GraphDiffOutput, EC, sys::fs::OpenFlags::F_Text); if (EC) return make_error( - Twine("Cannot open file '") + GraphDiffOutput + "' for writing.", EC); + Twine("Cannot open file '") + *GraphDiffOutput + "' for writing.", EC); GDR.exportGraphAsDOT(OS, GraphDiffEdgeLabel, GraphDiffEdgeColor, GraphDiffVertexLabel, GraphDiffVertexColor, Index: tools/llvm-xray/xray-graph.cpp =================================================================== --- tools/llvm-xray/xray-graph.cpp +++ tools/llvm-xray/xray-graph.cpp @@ -425,7 +425,7 @@ if (!InstrumentationMapOrError) return joinErrors( make_error( - Twine("Cannot open instrumentation map '") + GraphInstrMap + "'", + Twine("Cannot open instrumentation map '") + *GraphInstrMap + "'", std::make_error_code(std::errc::invalid_argument)), InstrumentationMapOrError.takeError()); Map = std::move(*InstrumentationMapOrError); @@ -495,7 +495,7 @@ if (!TraceOrErr) return make_error( - Twine("Failed loading input file '") + GraphInput + "'", + Twine("Failed loading input file '") + *GraphInput + "'", make_error_code(llvm::errc::invalid_argument)); F.Trace = std::move(*TraceOrErr); @@ -508,7 +508,7 @@ raw_fd_ostream OS(GraphOutput, EC, sys::fs::OpenFlags::F_Text); if (EC) return make_error( - Twine("Cannot open file '") + GraphOutput + "' for writing.", EC); + Twine("Cannot open file '") + *GraphOutput + "' for writing.", EC); GR.exportGraphAsDOT(OS, GraphEdgeLabel, GraphEdgeColorType, GraphVertexLabel, GraphVertexColorType); Index: tools/llvm-xray/xray-stacks.cpp =================================================================== --- tools/llvm-xray/xray-stacks.cpp +++ tools/llvm-xray/xray-stacks.cpp @@ -695,7 +695,7 @@ if (!InstrumentationMapOrError) return joinErrors( make_error( - Twine("Cannot open instrumentation map: ") + StacksInstrMap, + Twine("Cannot open instrumentation map: ") + *StacksInstrMap, std::make_error_code(std::errc::invalid_argument)), InstrumentationMapOrError.takeError()); Map = std::move(*InstrumentationMapOrError); Index: tools/opt/opt.cpp =================================================================== --- tools/opt/opt.cpp +++ tools/opt/opt.cpp @@ -537,7 +537,7 @@ // pass pipelines. Otherwise we can crash on broken code during // doInitialization(). if (!NoVerify && verifyModule(*M, &errs())) { - errs() << argv[0] << ": " << InputFilename + errs() << argv[0] << ": " << *InputFilename << ": error: input module is broken!\n"; return 1; } Index: tools/sancov/sancov.cpp =================================================================== --- tools/sancov/sancov.cpp +++ tools/sancov/sancov.cpp @@ -551,7 +551,7 @@ size_t Pos = Path.find(ClStripPathPrefix); if (Pos == std::string::npos) return Path; - return Path.substr(Pos + ClStripPathPrefix.size()); + return Path.substr(Pos + ClStripPathPrefix->size()); } static std::unique_ptr createSymbolizer() { Index: tools/sanstats/sanstats.cpp =================================================================== --- tools/sanstats/sanstats.cpp +++ tools/sanstats/sanstats.cpp @@ -117,23 +117,23 @@ "Sanitizer Statistics Processing Tool"); ErrorOr> MBOrErr = - MemoryBuffer::getFile(ClInputFile, -1, false); + MemoryBuffer::getFile(*ClInputFile, -1, false); if (!MBOrErr) { - errs() << argv[0] << ": " << ClInputFile << ": " + errs() << argv[0] << ": " << *ClInputFile << ": " << MBOrErr.getError().message() << '\n'; return 1; } std::unique_ptr MB = std::move(MBOrErr.get()); const char *Begin = MB->getBufferStart(), *End = MB->getBufferEnd(); if (Begin == End) { - errs() << argv[0] << ": " << ClInputFile << ": short read\n"; + errs() << argv[0] << ": " << *ClInputFile << ": short read\n"; return 1; } char SizeofPtr = *Begin++; while (Begin != End) { Begin = ReadModule(SizeofPtr, Begin, End); if (Begin == nullptr) { - errs() << argv[0] << ": " << ClInputFile << ": short read\n"; + errs() << argv[0] << ": " << *ClInputFile << ": short read\n"; return 1; } assert(Begin <= End); Index: tools/verify-uselistorder/verify-uselistorder.cpp =================================================================== --- tools/verify-uselistorder/verify-uselistorder.cpp +++ tools/verify-uselistorder/verify-uselistorder.cpp @@ -545,7 +545,7 @@ return 1; } if (verifyModule(*M, &errs())) { - errs() << argv[0] << ": " << InputFilename + errs() << argv[0] << ": " << *InputFilename << ": error: input module is broken!\n"; return 1; } Index: tools/yaml2obj/yaml2obj.cpp =================================================================== --- tools/yaml2obj/yaml2obj.cpp +++ tools/yaml2obj/yaml2obj.cpp @@ -78,10 +78,10 @@ std::unique_ptr Out( new ToolOutputFile(OutputFilename, EC, sys::fs::F_None)); if (EC) - error("yaml2obj: Error opening '" + OutputFilename + "': " + EC.message()); + error("yaml2obj: Error opening '" + *OutputFilename + "': " + EC.message()); ErrorOr> Buf = - MemoryBuffer::getFileOrSTDIN(Input); + MemoryBuffer::getFileOrSTDIN(*Input); if (!Buf) return 1; Index: unittests/Support/CommandLineTest.cpp =================================================================== --- unittests/Support/CommandLineTest.cpp +++ unittests/Support/CommandLineTest.cpp @@ -125,9 +125,9 @@ cl::opt EnvironmentTestOption("env-test-opt"); TEST(CommandLineTest, ParseEnvironment) { TempEnvVar TEV(test_env_var, "-env-test-opt=hello"); - EXPECT_EQ("", EnvironmentTestOption); + EXPECT_EQ("", *EnvironmentTestOption); cl::ParseEnvironmentOptions("CommandLineTest", test_env_var); - EXPECT_EQ("hello", EnvironmentTestOption); + EXPECT_EQ("hello", *EnvironmentTestOption); } // This test used to make valgrind complain @@ -142,9 +142,9 @@ // Put cl::opt on stack to check for proper initialization of fields. StackOption EnvironmentTestOptionLocal("env-test-opt-local"); TempEnvVar TEV(test_env_var, "-env-test-opt-local=hello-local"); - EXPECT_EQ("", EnvironmentTestOptionLocal); + EXPECT_EQ("", *EnvironmentTestOptionLocal); cl::ParseEnvironmentOptions("CommandLineTest", test_env_var); - EXPECT_EQ("hello-local", EnvironmentTestOptionLocal); + EXPECT_EQ("hello-local", *EnvironmentTestOptionLocal); } #endif // SKIP_ENVIRONMENT_TESTS @@ -290,7 +290,7 @@ cl::alias Alias("alias", llvm::cl::aliasopt(Actual)); cl::ParseCommandLineOptions(ARGC, Inputs[i]); - EXPECT_EQ("x", Actual); + EXPECT_EQ("x", *Actual); EXPECT_EQ(0, Input.getNumOccurrences()); Alias.removeArgument(); @@ -302,7 +302,7 @@ cl::alias Alias("o", llvm::cl::aliasopt(Option)); cl::ParseCommandLineOptions(argc, argv); - EXPECT_EQ("x", Option); + EXPECT_EQ("x", *Option); EXPECT_EQ(1, Option.getNumOccurrences()); Alias.removeArgument(); Index: utils/FileCheck/FileCheck.cpp =================================================================== --- utils/FileCheck/FileCheck.cpp +++ utils/FileCheck/FileCheck.cpp @@ -156,9 +156,9 @@ // Read the expected strings from the check file. ErrorOr> CheckFileOrErr = - MemoryBuffer::getFileOrSTDIN(CheckFilename); + MemoryBuffer::getFileOrSTDIN(*CheckFilename); if (std::error_code EC = CheckFileOrErr.getError()) { - errs() << "Could not open check file '" << CheckFilename + errs() << "Could not open check file '" << *CheckFilename << "': " << EC.message() << '\n'; return 2; } @@ -177,16 +177,16 @@ // Open the file to check and add it to SourceMgr. ErrorOr> InputFileOrErr = - MemoryBuffer::getFileOrSTDIN(InputFilename); + MemoryBuffer::getFileOrSTDIN(*InputFilename); if (std::error_code EC = InputFileOrErr.getError()) { - errs() << "Could not open input file '" << InputFilename + errs() << "Could not open input file '" << *InputFilename << "': " << EC.message() << '\n'; return 2; } MemoryBuffer &InputFile = *InputFileOrErr.get(); if (InputFile.getBufferSize() == 0 && !AllowEmptyInput) { - errs() << "FileCheck error: '" << InputFilename << "' is empty.\n"; + errs() << "FileCheck error: '" << *InputFilename << "' is empty.\n"; DumpCommandLine(argc, argv); return 2; } Index: utils/TableGen/AsmMatcherEmitter.cpp =================================================================== --- utils/TableGen/AsmMatcherEmitter.cpp +++ utils/TableGen/AsmMatcherEmitter.cpp @@ -2791,7 +2791,7 @@ static bool emitMnemonicAliases(raw_ostream &OS, const AsmMatcherInfo &Info, CodeGenTarget &Target) { // Ignore aliases when match-prefix is set. - if (!MatchPrefix.empty()) + if (!MatchPrefix->empty()) return false; std::vector Aliases = Index: utils/TableGen/GlobalISelEmitter.cpp =================================================================== --- utils/TableGen/GlobalISelEmitter.cpp +++ utils/TableGen/GlobalISelEmitter.cpp @@ -4227,9 +4227,9 @@ } void GlobalISelEmitter::run(raw_ostream &OS) { - if (!UseCoverageFile.empty()) { + if (!UseCoverageFile->empty()) { RuleCoverage = CodeGenCoverage(); - auto RuleCoverageBufOrErr = MemoryBuffer::getFile(UseCoverageFile); + auto RuleCoverageBufOrErr = MemoryBuffer::getFile(*UseCoverageFile); if (!RuleCoverageBufOrErr) { PrintWarning(SMLoc(), "Missing rule coverage data"); RuleCoverage = None; Index: utils/yaml-bench/YAMLBench.cpp =================================================================== --- utils/yaml-bench/YAMLBench.cpp +++ utils/yaml-bench/YAMLBench.cpp @@ -201,7 +201,7 @@ : UseColor == cl::BOU_TRUE; if (Input.getNumOccurrences()) { ErrorOr> BufOrErr = - MemoryBuffer::getFileOrSTDIN(Input); + MemoryBuffer::getFileOrSTDIN(*Input); if (!BufOrErr) return 1; MemoryBuffer &Buf = *BufOrErr.get();