Index: include/llvm/ADT/StringRef.h =================================================================== --- include/llvm/ADT/StringRef.h +++ include/llvm/ADT/StringRef.h @@ -83,12 +83,9 @@ : Data(Str), Length(Str ? ::strlen(Str) : 0) {} /// Construct a string ref from a pointer and length. - LLVM_ATTRIBUTE_ALWAYS_INLINE - /*implicit*/ StringRef(const char *data, size_t length) - : Data(data), Length(length) { - assert((data || length == 0) && - "StringRef cannot be built from a NULL argument with non-null length"); - } + constexpr LLVM_ATTRIBUTE_ALWAYS_INLINE + /*implicit*/ StringRef(const char *data, size_t length) + : Data(data), Length(data ? length : 0) {} /// Construct a string ref from an std::string. LLVM_ATTRIBUTE_ALWAYS_INLINE @@ -881,6 +878,14 @@ // StringRefs can be treated like a POD type. template struct isPodLike; template <> struct isPodLike { static const bool value = true; }; -} + + inline namespace operators { + /// User defined literal + /// Create a StringRef from a literal string. + constexpr llvm::StringRef operator"" _sr(const char *S, size_t Length) { + return llvm::StringRef(S, Length); + } + } // end namespace operators + } // end namespace llvm #endif Index: include/llvm/Support/CommandLine.h =================================================================== --- include/llvm/Support/CommandLine.h +++ include/llvm/Support/CommandLine.h @@ -163,7 +163,7 @@ public: OptionCategory(StringRef const Name, - StringRef const Description = "") + StringRef const Description = StringRef()) : Name(Name), Description(Description) { registerCategory(); } @@ -179,8 +179,8 @@ // class SubCommand { private: - StringRef Name = ""; - StringRef Description = ""; + StringRef Name; + StringRef Description; protected: void registerSubCommand(); @@ -304,8 +304,8 @@ enum OptionHidden Hidden) : NumOccurrences(0), Occurrences(OccurrencesFlag), Value(0), HiddenFlag(Hidden), Formatting(NormalFormatting), Misc(0), Position(0), - AdditionalVals(0), ArgStr(""), HelpStr(""), ValueStr(""), - Category(&GeneralCategory), FullyInitialized(false) {} + AdditionalVals(0), Category(&GeneralCategory), FullyInitialized(false) { + } inline void setNumAdditionalVals(unsigned n) { AdditionalVals = n; } @@ -565,9 +565,9 @@ }; #define clEnumVal(ENUMVAL, DESC) \ - llvm::cl::OptionEnumValue { #ENUMVAL, int(ENUMVAL), DESC } + llvm::cl::OptionEnumValue { #ENUMVAL##_sr, int(ENUMVAL), DESC##_sr } #define clEnumValN(ENUMVAL, FLAGNAME, DESC) \ - llvm::cl::OptionEnumValue { FLAGNAME, int(ENUMVAL), DESC } + llvm::cl::OptionEnumValue { FLAGNAME##_sr, int(ENUMVAL), DESC##_sr } // values - For custom data types, allow specifying a group of values together // as the values that go into the mapping that the option handler uses. Index: lib/IR/DiagnosticInfo.cpp =================================================================== --- lib/IR/DiagnosticInfo.cpp +++ lib/IR/DiagnosticInfo.cpp @@ -59,32 +59,32 @@ // -pass-remarks // Command line flag to enable emitOptimizationRemark() -static cl::opt> -PassRemarks("pass-remarks", cl::value_desc("pattern"), - cl::desc("Enable optimization remarks from passes whose name match " - "the given regular expression"), - cl::Hidden, cl::location(PassRemarksOptLoc), cl::ValueRequired, - cl::ZeroOrMore); +static cl::opt> PassRemarks( + "pass-remarks"_sr, cl::value_desc("pattern"_sr), + cl::desc("Enable optimization remarks from passes whose name match " + "the given regular expression"_sr), + cl::Hidden, cl::location(PassRemarksOptLoc), cl::ValueRequired, + cl::ZeroOrMore); // -pass-remarks-missed // Command line flag to enable emitOptimizationRemarkMissed() static cl::opt> PassRemarksMissed( - "pass-remarks-missed", cl::value_desc("pattern"), + "pass-remarks-missed"_sr, cl::value_desc("pattern"_sr), cl::desc("Enable missed optimization remarks from passes whose name match " - "the given regular expression"), + "the given regular expression"_sr), cl::Hidden, cl::location(PassRemarksMissedOptLoc), cl::ValueRequired, cl::ZeroOrMore); // -pass-remarks-analysis // Command line flag to enable emitOptimizationRemarkAnalysis() static cl::opt> -PassRemarksAnalysis( - "pass-remarks-analysis", cl::value_desc("pattern"), - cl::desc( - "Enable optimization analysis remarks from passes whose name match " - "the given regular expression"), - cl::Hidden, cl::location(PassRemarksAnalysisOptLoc), cl::ValueRequired, - cl::ZeroOrMore); + PassRemarksAnalysis( + "pass-remarks-analysis"_sr, cl::value_desc("pattern"_sr), + cl::desc( + "Enable optimization analysis remarks from passes whose name match " + "the given regular expression"_sr), + cl::Hidden, cl::location(PassRemarksAnalysisOptLoc), cl::ValueRequired, + cl::ZeroOrMore); } int llvm::getNextAvailablePluginDiagnosticKind() { Index: lib/IR/Dominators.cpp =================================================================== --- lib/IR/Dominators.cpp +++ lib/IR/Dominators.cpp @@ -33,9 +33,9 @@ #else static bool VerifyDomInfo = false; #endif -static cl::opt -VerifyDomInfoX("verify-dom-info", cl::location(VerifyDomInfo), - cl::desc("Verify dominator info (time consuming)")); +static cl::opt + VerifyDomInfoX("verify-dom-info"_sr, cl::location(VerifyDomInfo), + cl::desc("Verify dominator info (time consuming)"_sr)); bool BasicBlockEdge::isSingleEdge() const { const TerminatorInst *TI = Start->getTerminator(); Index: lib/IR/LegacyPassManager.cpp =================================================================== --- lib/IR/LegacyPassManager.cpp +++ lib/IR/LegacyPassManager.cpp @@ -48,15 +48,14 @@ }; } -static cl::opt -PassDebugging("debug-pass", cl::Hidden, - cl::desc("Print PassManager debugging information"), - cl::values( - clEnumVal(Disabled , "disable debug output"), - clEnumVal(Arguments , "print pass arguments to pass to 'opt'"), - clEnumVal(Structure , "print pass structure before run()"), - clEnumVal(Executions, "print pass name before it is executed"), - clEnumVal(Details , "print pass details when it is executed"))); +static cl::opt PassDebugging( + "debug-pass"_sr, cl::Hidden, + cl::desc("Print PassManager debugging information"_sr), + cl::values(clEnumVal(Disabled, "disable debug output"), + clEnumVal(Arguments, "print pass arguments to pass to 'opt'"), + clEnumVal(Structure, "print pass structure before run()"), + clEnumVal(Executions, "print pass name before it is executed"), + clEnumVal(Details, "print pass details when it is executed"))); namespace { typedef llvm::cl::list @@ -65,29 +64,29 @@ // Print IR out before/after specified passes. static PassOptionList -PrintBefore("print-before", - llvm::cl::desc("Print IR before specified passes"), - cl::Hidden); + PrintBefore("print-before"_sr, + llvm::cl::desc("Print IR before specified passes"_sr), + cl::Hidden); static PassOptionList -PrintAfter("print-after", - llvm::cl::desc("Print IR after specified passes"), - cl::Hidden); + PrintAfter("print-after"_sr, + llvm::cl::desc("Print IR after specified passes"_sr), + cl::Hidden); static cl::opt -PrintBeforeAll("print-before-all", - llvm::cl::desc("Print IR before each pass"), - cl::init(false)); + PrintBeforeAll("print-before-all"_sr, + llvm::cl::desc("Print IR before each pass"_sr), + cl::init(false)); static cl::opt -PrintAfterAll("print-after-all", - llvm::cl::desc("Print IR after each pass"), - cl::init(false)); + PrintAfterAll("print-after-all"_sr, + llvm::cl::desc("Print IR after each pass"_sr), + cl::init(false)); static cl::list - PrintFuncsList("filter-print-funcs", cl::value_desc("function names"), + PrintFuncsList("filter-print-funcs"_sr, cl::value_desc("function names"_sr), cl::desc("Only print IR for functions whose name " "match this for all print-[before|after][-all] " - "options"), + "options"_sr), cl::CommaSeparated); /// This is a helper to determine whether to print IR before or @@ -1728,9 +1727,9 @@ // TimingInfo implementation bool llvm::TimePassesIsEnabled = false; -static cl::opt -EnableTiming("time-passes", cl::location(TimePassesIsEnabled), - cl::desc("Time each pass, printing elapsed time for each on exit")); +static cl::opt EnableTiming( + "time-passes"_sr, cl::location(TimePassesIsEnabled), + cl::desc("Time each pass, printing elapsed time for each on exit"_sr)); // createTheTimeInfo - This method either initializes the TheTimeInfo pointer to // a non-null value (if the -time-passes option is enabled) or it leaves it Index: lib/IR/OptBisect.cpp =================================================================== --- lib/IR/OptBisect.cpp +++ lib/IR/OptBisect.cpp @@ -24,9 +24,10 @@ using namespace llvm; -static cl::opt OptBisectLimit("opt-bisect-limit", cl::Hidden, - cl::init(INT_MAX), cl::Optional, - cl::desc("Maximum optimization to perform")); +static cl::opt + OptBisectLimit("opt-bisect-limit"_sr, cl::Hidden, cl::init(INT_MAX), + cl::Optional, + cl::desc("Maximum optimization to perform"_sr)); OptBisect::OptBisect() { BisectEnabled = OptBisectLimit != INT_MAX; Index: lib/IR/Verifier.cpp =================================================================== --- lib/IR/Verifier.cpp +++ lib/IR/Verifier.cpp @@ -115,7 +115,7 @@ using namespace llvm; -static cl::opt VerifyDebugInfo("verify-debug-info", cl::init(true)); +static cl::opt VerifyDebugInfo("verify-debug-info"_sr, cl::init(true)); namespace { Index: lib/MC/MCDwarf.cpp =================================================================== --- lib/MC/MCDwarf.cpp +++ lib/MC/MCDwarf.cpp @@ -293,7 +293,7 @@ // First the directory table. for (unsigned i = 0; i < MCDwarfDirs.size(); i++) { MCOS->EmitBytes(MCDwarfDirs[i]); // the DirectoryName - MCOS->EmitBytes(StringRef("\0", 1)); // the null term. of the string + MCOS->EmitBytes("\0"_sr); // the null term. of the string } MCOS->EmitIntValue(0, 1); // Terminate the directory list @@ -301,7 +301,7 @@ for (unsigned i = 1; i < MCDwarfFiles.size(); i++) { assert(!MCDwarfFiles[i].Name.empty()); MCOS->EmitBytes(MCDwarfFiles[i].Name); // FileName - MCOS->EmitBytes(StringRef("\0", 1)); // the null term. of the string + MCOS->EmitBytes("\0"_sr); // the null term. of the string // the Directory num MCOS->EmitULEB128IntValue(MCDwarfFiles[i].DirIndex); MCOS->EmitIntValue(0, 1); // last modification timestamp (always 0) Index: lib/MC/MCParser/AsmParser.cpp =================================================================== --- lib/MC/MCParser/AsmParser.cpp +++ lib/MC/MCParser/AsmParser.cpp @@ -2717,7 +2717,7 @@ return true; getStreamer().EmitBytes(Data); if (ZeroTerminated) - getStreamer().EmitBytes(StringRef("\0", 1)); + getStreamer().EmitBytes("\0"_sr); return false; }; Index: lib/Support/CommandLine.cpp =================================================================== --- lib/Support/CommandLine.cpp +++ lib/Support/CommandLine.cpp @@ -366,7 +366,7 @@ } // Initialise the general option category. -OptionCategory llvm::cl::GeneralCategory("General options"); +OptionCategory llvm::cl::GeneralCategory("General options"_sr); void OptionCategory::registerCategory() { GlobalParser->registerCategory(this); @@ -1956,46 +1956,48 @@ CategorizedHiddenPrinter); // Define a category for generic options that all tools should have. -static cl::OptionCategory GenericCategory("Generic Options"); +static cl::OptionCategory GenericCategory("Generic Options"_sr); // Define uncategorized help printers. // -help-list is hidden by default because if Option categories are being used // then -help behaves the same as -help-list. static cl::opt> HLOp( - "help-list", - cl::desc("Display list of available options (-help-list-hidden for more)"), + "help-list"_sr, + cl::desc( + "Display list of available options (-help-list-hidden for more)"_sr), cl::location(UncategorizedNormalPrinter), cl::Hidden, cl::ValueDisallowed, cl::cat(GenericCategory), cl::sub(*AllSubCommands)); -static cl::opt> - HLHOp("help-list-hidden", cl::desc("Display list of all available options"), - cl::location(UncategorizedHiddenPrinter), cl::Hidden, - cl::ValueDisallowed, cl::cat(GenericCategory), - cl::sub(*AllSubCommands)); +static cl::opt> HLHOp( + "help-list-hidden"_sr, cl::desc("Display list of all available options"_sr), + cl::location(UncategorizedHiddenPrinter), cl::Hidden, cl::ValueDisallowed, + cl::cat(GenericCategory), cl::sub(*AllSubCommands)); // Define uncategorized/categorized help printers. These printers change their // behaviour at runtime depending on whether one or more Option categories have // been declared. static cl::opt> - HOp("help", cl::desc("Display available options (-help-hidden for more)"), + HOp("help"_sr, + cl::desc("Display available options (-help-hidden for more)"_sr), cl::location(WrappedNormalPrinter), cl::ValueDisallowed, cl::cat(GenericCategory), cl::sub(*AllSubCommands)); static cl::opt> - HHOp("help-hidden", cl::desc("Display all available options"), + HHOp("help-hidden"_sr, cl::desc("Display all available options"_sr), cl::location(WrappedHiddenPrinter), cl::Hidden, cl::ValueDisallowed, cl::cat(GenericCategory), cl::sub(*AllSubCommands)); static cl::opt PrintOptions( - "print-options", - cl::desc("Print non-default options after command line parsing"), + "print-options"_sr, + cl::desc("Print non-default options after command line parsing"_sr), cl::Hidden, cl::init(false), cl::cat(GenericCategory), cl::sub(*AllSubCommands)); static cl::opt PrintAllOptions( - "print-all-options", - cl::desc("Print all option values after command line parsing"), cl::Hidden, - cl::init(false), cl::cat(GenericCategory), cl::sub(*AllSubCommands)); + "print-all-options"_sr, + cl::desc("Print all option values after command line parsing"_sr), + cl::Hidden, cl::init(false), cl::cat(GenericCategory), + cl::sub(*AllSubCommands)); void HelpPrinterWrapper::operator=(bool Value) { if (!Value) @@ -2096,7 +2098,7 @@ static VersionPrinter VersionPrinterInstance; static cl::opt> - VersOp("version", cl::desc("Display the version of this program"), + VersOp("version"_sr, cl::desc("Display the version of this program"_sr), cl::location(VersionPrinterInstance), cl::ValueDisallowed, cl::cat(GenericCategory)); Index: lib/Support/Debug.cpp =================================================================== --- lib/Support/Debug.cpp +++ lib/Support/Debug.cpp @@ -74,19 +74,17 @@ // -debug - Command line option to enable the DEBUG statements in the passes. // This flag may only be enabled in debug builds. -static cl::opt -Debug("debug", cl::desc("Enable debug output"), cl::Hidden, - cl::location(DebugFlag)); +static cl::opt Debug("debug"_sr, cl::desc("Enable debug output"_sr), + cl::Hidden, cl::location(DebugFlag)); // -debug-buffer-size - Buffer the last N characters of debug output //until program termination. static cl::opt -DebugBufferSize("debug-buffer-size", - cl::desc("Buffer the last N characters of debug output " - "until program termination. " - "[default 0 -- immediate print-out]"), - cl::Hidden, - cl::init(0)); + DebugBufferSize("debug-buffer-size"_sr, + cl::desc("Buffer the last N characters of debug output " + "until program termination. " + "[default 0 -- immediate print-out]"_sr), + cl::Hidden, cl::init(0)); namespace { @@ -106,10 +104,12 @@ static DebugOnlyOpt DebugOnlyOptLoc; -static cl::opt > -DebugOnly("debug-only", cl::desc("Enable a specific type of debug output (comma separated list of types)"), - cl::Hidden, cl::ZeroOrMore, cl::value_desc("debug string"), - cl::location(DebugOnlyOptLoc), cl::ValueRequired); +static cl::opt> DebugOnly( + "debug-only"_sr, + cl::desc( + "Enable a specific type of debug output (comma separated list of types)"_sr), + cl::Hidden, cl::ZeroOrMore, cl::value_desc("debug string"_sr), + cl::location(DebugOnlyOptLoc), cl::ValueRequired); // Signal handlers - dump debug output on termination. static void debug_user_sig_handler(void *Cookie) { // This is a bit sneaky. Since this is under #ifndef NDEBUG, we Index: lib/Support/RandomNumberGenerator.cpp =================================================================== --- lib/Support/RandomNumberGenerator.cpp +++ lib/Support/RandomNumberGenerator.cpp @@ -32,8 +32,8 @@ // // Do not change to cl::opt since this silently breaks argument parsing. static cl::opt -Seed("rng-seed", cl::value_desc("seed"), - cl::desc("Seed for the random number generator"), cl::init(0)); + Seed("rng-seed"_sr, cl::value_desc("seed"_sr), + cl::desc("Seed for the random number generator"_sr), cl::init(0)); RandomNumberGenerator::RandomNumberGenerator(StringRef Salt) { DEBUG( Index: lib/Support/Timer.cpp =================================================================== --- lib/Support/Timer.cpp +++ lib/Support/Timer.cpp @@ -39,15 +39,15 @@ static ManagedStatic > TimerLock; namespace { - static cl::opt - TrackSpace("track-memory", cl::desc("Enable -time-passes memory " - "tracking (this may be slow)"), - cl::Hidden); - - static cl::opt - InfoOutputFilename("info-output-file", cl::value_desc("filename"), - cl::desc("File to append -stats and -timer output to"), - cl::Hidden, cl::location(getLibSupportInfoOutputFilename())); +static cl::opt TrackSpace("track-memory"_sr, + cl::desc("Enable -time-passes memory " + "tracking (this may be slow)"_sr), + cl::Hidden); + +static cl::opt InfoOutputFilename( + "info-output-file"_sr, cl::value_desc("filename"_sr), + cl::desc("File to append -stats and -timer output to"_sr), cl::Hidden, + cl::location(getLibSupportInfoOutputFilename())); } std::unique_ptr llvm::CreateInfoOutputFile() { Index: lib/Target/AMDGPU/Utils/AMDKernelCodeTUtils.cpp =================================================================== --- lib/Target/AMDGPU/Utils/AMDKernelCodeTUtils.cpp +++ lib/Target/AMDGPU/Utils/AMDKernelCodeTUtils.cpp @@ -23,8 +23,8 @@ static ArrayRef get_amd_kernel_code_t_FldNames() { static StringRef const Table[] = { - "", // not found placeholder -#define RECORD(name, altName, print, parse) #name + ""_sr, // not found placeholder +#define RECORD(name, altName, print, parse) #name##_sr #include "AMDKernelCodeTInfo.h" #undef RECORD }; @@ -33,8 +33,8 @@ static ArrayRef get_amd_kernel_code_t_FldAltNames() { static StringRef const Table[] = { - "", // not found placeholder -#define RECORD(name, altName, print, parse) #altName + ""_sr, // not found placeholder +#define RECORD(name, altName, print, parse) #altName##_sr #include "AMDKernelCodeTInfo.h" #undef RECORD }; Index: lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp =================================================================== --- lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp +++ lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp @@ -39,28 +39,29 @@ #define GET_REGINFO_MC_DESC #include "HexagonGenRegisterInfo.inc" -cl::opt llvm::HexagonDisableCompound - ("mno-compound", - cl::desc("Disable looking for compound instructions for Hexagon")); +cl::opt llvm::HexagonDisableCompound( + "mno-compound"_sr, + cl::desc("Disable looking for compound instructions for Hexagon"_sr)); -cl::opt llvm::HexagonDisableDuplex - ("mno-pairing", - cl::desc("Disable looking for duplex instructions for Hexagon")); +cl::opt llvm::HexagonDisableDuplex( + "mno-pairing"_sr, + cl::desc("Disable looking for duplex instructions for Hexagon"_sr)); -static cl::opt HexagonV4ArchVariant("mv4", cl::Hidden, cl::init(false), - cl::desc("Build for Hexagon V4")); +static cl::opt HexagonV4ArchVariant("mv4"_sr, cl::Hidden, cl::init(false), + cl::desc("Build for Hexagon V4"_sr)); -static cl::opt HexagonV5ArchVariant("mv5", cl::Hidden, cl::init(false), - cl::desc("Build for Hexagon V5")); +static cl::opt HexagonV5ArchVariant("mv5"_sr, cl::Hidden, cl::init(false), + cl::desc("Build for Hexagon V5"_sr)); -static cl::opt HexagonV55ArchVariant("mv55", cl::Hidden, cl::init(false), - cl::desc("Build for Hexagon V55")); +static cl::opt + HexagonV55ArchVariant("mv55"_sr, cl::Hidden, cl::init(false), + cl::desc("Build for Hexagon V55"_sr)); -static cl::opt HexagonV60ArchVariant("mv60", cl::Hidden, cl::init(false), - cl::desc("Build for Hexagon V60")); +static cl::opt + HexagonV60ArchVariant("mv60"_sr, cl::Hidden, cl::init(false), + cl::desc("Build for Hexagon V60"_sr)); - -static StringRef DefaultArch = "hexagonv60"; +static StringRef DefaultArch = "hexagonv60"_sr; static StringRef HexagonGetArchVariant() { if (HexagonV4ArchVariant) Index: lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp =================================================================== --- lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp +++ lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp @@ -529,55 +529,55 @@ // Table initializing information for parsing the .insn directive. static struct InsnMatchEntry InsnMatchTable[] = { /* Format, Opcode, NumOperands, OperandKinds */ - { "e", SystemZ::InsnE, 1, + { "e"_sr, SystemZ::InsnE, 1, { MCK_U16Imm } }, - { "ri", SystemZ::InsnRI, 3, + { "ri"_sr, SystemZ::InsnRI, 3, { MCK_U32Imm, MCK_AnyReg, MCK_S16Imm } }, - { "rie", SystemZ::InsnRIE, 4, + { "rie"_sr, SystemZ::InsnRIE, 4, { MCK_U48Imm, MCK_AnyReg, MCK_AnyReg, MCK_PCRel16 } }, - { "ril", SystemZ::InsnRIL, 3, + { "ril"_sr, SystemZ::InsnRIL, 3, { MCK_U48Imm, MCK_AnyReg, MCK_PCRel32 } }, - { "rilu", SystemZ::InsnRILU, 3, + { "rilu"_sr, SystemZ::InsnRILU, 3, { MCK_U48Imm, MCK_AnyReg, MCK_U32Imm } }, - { "ris", SystemZ::InsnRIS, 5, + { "ris"_sr, SystemZ::InsnRIS, 5, { MCK_U48Imm, MCK_AnyReg, MCK_S8Imm, MCK_U4Imm, MCK_BDAddr64Disp12 } }, - { "rr", SystemZ::InsnRR, 3, + { "rr"_sr, SystemZ::InsnRR, 3, { MCK_U16Imm, MCK_AnyReg, MCK_AnyReg } }, - { "rre", SystemZ::InsnRRE, 3, + { "rre"_sr, SystemZ::InsnRRE, 3, { MCK_U32Imm, MCK_AnyReg, MCK_AnyReg } }, - { "rrf", SystemZ::InsnRRF, 5, + { "rrf"_sr, SystemZ::InsnRRF, 5, { MCK_U32Imm, MCK_AnyReg, MCK_AnyReg, MCK_AnyReg, MCK_U4Imm } }, - { "rrs", SystemZ::InsnRRS, 5, + { "rrs"_sr, SystemZ::InsnRRS, 5, { MCK_U48Imm, MCK_AnyReg, MCK_AnyReg, MCK_U4Imm, MCK_BDAddr64Disp12 } }, - { "rs", SystemZ::InsnRS, 4, + { "rs"_sr, SystemZ::InsnRS, 4, { MCK_U32Imm, MCK_AnyReg, MCK_AnyReg, MCK_BDAddr64Disp12 } }, - { "rse", SystemZ::InsnRSE, 4, + { "rse"_sr, SystemZ::InsnRSE, 4, { MCK_U48Imm, MCK_AnyReg, MCK_AnyReg, MCK_BDAddr64Disp12 } }, - { "rsi", SystemZ::InsnRSI, 4, + { "rsi"_sr, SystemZ::InsnRSI, 4, { MCK_U48Imm, MCK_AnyReg, MCK_AnyReg, MCK_PCRel16 } }, - { "rsy", SystemZ::InsnRSY, 4, + { "rsy"_sr, SystemZ::InsnRSY, 4, { MCK_U48Imm, MCK_AnyReg, MCK_AnyReg, MCK_BDAddr64Disp20 } }, - { "rx", SystemZ::InsnRX, 3, + { "rx"_sr, SystemZ::InsnRX, 3, { MCK_U32Imm, MCK_AnyReg, MCK_BDXAddr64Disp12 } }, - { "rxe", SystemZ::InsnRXE, 3, + { "rxe"_sr, SystemZ::InsnRXE, 3, { MCK_U48Imm, MCK_AnyReg, MCK_BDXAddr64Disp12 } }, - { "rxf", SystemZ::InsnRXF, 4, + { "rxf"_sr, SystemZ::InsnRXF, 4, { MCK_U48Imm, MCK_AnyReg, MCK_AnyReg, MCK_BDXAddr64Disp12 } }, - { "rxy", SystemZ::InsnRXY, 3, + { "rxy"_sr, SystemZ::InsnRXY, 3, { MCK_U48Imm, MCK_AnyReg, MCK_BDXAddr64Disp20 } }, - { "s", SystemZ::InsnS, 2, + { "s"_sr, SystemZ::InsnS, 2, { MCK_U32Imm, MCK_BDAddr64Disp12 } }, - { "si", SystemZ::InsnSI, 3, + { "si"_sr, SystemZ::InsnSI, 3, { MCK_U32Imm, MCK_BDAddr64Disp12, MCK_S8Imm } }, - { "sil", SystemZ::InsnSIL, 3, + { "sil"_sr, SystemZ::InsnSIL, 3, { MCK_U48Imm, MCK_BDAddr64Disp12, MCK_U16Imm } }, - { "siy", SystemZ::InsnSIY, 3, + { "siy"_sr, SystemZ::InsnSIY, 3, { MCK_U48Imm, MCK_BDAddr64Disp20, MCK_U8Imm } }, - { "ss", SystemZ::InsnSS, 4, + { "ss"_sr, SystemZ::InsnSS, 4, { MCK_U48Imm, MCK_BDXAddr64Disp12, MCK_BDAddr64Disp12, MCK_AnyReg } }, - { "sse", SystemZ::InsnSSE, 3, + { "sse"_sr, SystemZ::InsnSSE, 3, { MCK_U48Imm, MCK_BDAddr64Disp12, MCK_BDAddr64Disp12 } }, - { "ssf", SystemZ::InsnSSF, 4, + { "ssf"_sr, SystemZ::InsnSSF, 4, { MCK_U48Imm, MCK_BDAddr64Disp12, MCK_BDAddr64Disp12, MCK_AnyReg } } }; Index: tools/llvm-as/llvm-as.cpp =================================================================== --- tools/llvm-as/llvm-as.cpp +++ tools/llvm-as/llvm-as.cpp @@ -32,31 +32,34 @@ using namespace llvm; static cl::opt InputFilename(cl::Positional, - cl::desc(""), - cl::init("-")); + cl::desc(""_sr), + cl::init("-"_sr)); -static cl::opt OutputFilename("o", - cl::desc("Override output filename"), - cl::value_desc("filename")); +static cl::opt + OutputFilename("o"_sr, cl::desc("Override output filename"_sr), + cl::value_desc("filename"_sr)); -static cl::opt Force("f", cl::desc("Enable binary output on terminals")); +static cl::opt Force("f"_sr, + cl::desc("Enable binary output on terminals"_sr)); -static cl::opt DisableOutput("disable-output", cl::desc("Disable output"), +static cl::opt DisableOutput("disable-output"_sr, + cl::desc("Disable output"_sr), cl::init(false)); -static cl::opt EmitModuleHash("module-hash", cl::desc("Emit module hash"), +static cl::opt EmitModuleHash("module-hash"_sr, + cl::desc("Emit module hash"_sr), cl::init(false)); -static cl::opt DumpAsm("d", cl::desc("Print assembly as parsed"), +static cl::opt DumpAsm("d"_sr, cl::desc("Print assembly as parsed"_sr), cl::Hidden); -static cl::opt - DisableVerify("disable-verify", cl::Hidden, - cl::desc("Do not run verifier on input LLVM (dangerous!)")); +static cl::opt DisableVerify( + "disable-verify"_sr, cl::Hidden, + cl::desc("Do not run verifier on input LLVM (dangerous!)"_sr)); static cl::opt PreserveBitcodeUseListOrder( - "preserve-bc-uselistorder", - cl::desc("Preserve use-list order when writing LLVM bitcode."), + "preserve-bc-uselistorder"_sr, + cl::desc("Preserve use-list order when writing LLVM bitcode."_sr), cl::init(true), cl::Hidden); static void WriteOutputFile(const Module *M) { Index: unittests/ADT/APIntTest.cpp =================================================================== --- unittests/ADT/APIntTest.cpp +++ unittests/ADT/APIntTest.cpp @@ -950,7 +950,7 @@ EXPECT_DEATH(APInt(32, "-", 10), "String is only a sign, needs a value."); EXPECT_DEATH(APInt(1, "1234", 10), "Insufficient bit width"); EXPECT_DEATH(APInt(32, "\0", 10), "Invalid string length"); - EXPECT_DEATH(APInt(32, StringRef("1\02", 3), 10), "Invalid character in digit string"); + EXPECT_DEATH(APInt(32, "1\02"_sr, 10), "Invalid character in digit string"); EXPECT_DEATH(APInt(32, "1L", 10), "Invalid character in digit string"); } #endif Index: unittests/ADT/StringRefTest.cpp =================================================================== --- unittests/ADT/StringRefTest.cpp +++ unittests/ADT/StringRefTest.cpp @@ -66,6 +66,8 @@ EXPECT_EQ("hello", StringRef("hello")); EXPECT_EQ("hello", StringRef("hello world", 5)); EXPECT_EQ("hello", StringRef(std::string("hello"))); + EXPECT_EQ("", ""_sr); + EXPECT_EQ("hello", "hello"_sr); } TEST(StringRefTest, EmptyInitializerList) { Index: unittests/ADT/StringSwitchTest.cpp =================================================================== --- unittests/ADT/StringSwitchTest.cpp +++ unittests/ADT/StringSwitchTest.cpp @@ -163,7 +163,7 @@ .Default(OSType::Unknown); }; - EXPECT_EQ(OSType::Windows, Translate(llvm::StringRef("wind\0ws", 7))); + EXPECT_EQ(OSType::Windows, Translate("wind\0ws"_sr)); EXPECT_EQ(OSType::Windows, Translate("win32")); EXPECT_EQ(OSType::Windows, Translate("winnt")); @@ -189,7 +189,7 @@ .Default(OSType::Unknown); }; - EXPECT_EQ(OSType::Windows, Translate(llvm::StringRef("WIND\0WS", 7))); + EXPECT_EQ(OSType::Windows, Translate("WIND\0WS"_sr)); EXPECT_EQ(OSType::Windows, Translate("WIN32")); EXPECT_EQ(OSType::Windows, Translate("WINNT")); @@ -198,7 +198,7 @@ EXPECT_EQ(OSType::Linux, Translate("*NIX")); EXPECT_EQ(OSType::Linux, Translate("POSIX")); - EXPECT_EQ(OSType::Windows, Translate(llvm::StringRef("wind\0ws", 7))); + EXPECT_EQ(OSType::Windows, Translate("wind\0ws"_sr)); EXPECT_EQ(OSType::Linux, Translate("linux")); EXPECT_EQ(OSType::Unknown, Translate("wind")); Index: unittests/Bitcode/BitstreamWriterTest.cpp =================================================================== --- unittests/Bitcode/BitstreamWriterTest.cpp +++ unittests/Bitcode/BitstreamWriterTest.cpp @@ -20,7 +20,7 @@ SmallString<64> Buffer; BitstreamWriter W(Buffer); W.emitBlob("str", /* ShouldEmitSize */ false); - EXPECT_EQ(StringRef("str\0", 4), Buffer); + EXPECT_EQ("str\0"_sr, Buffer); } TEST(BitstreamWriterTest, emitBlobWithSize) { Index: unittests/Support/ConvertUTFTest.cpp =================================================================== --- unittests/Support/ConvertUTFTest.cpp +++ unittests/Support/ConvertUTFTest.cpp @@ -279,8 +279,7 @@ // U+0000 NULL EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars( - ConvertUTFResultContainer(conversionOK).withScalars(0x0000), - StringRef("\x00", 1))); + ConvertUTFResultContainer(conversionOK).withScalars(0x0000), "\x00"_sr)); // U+0080 PADDING CHARACTER EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars( @@ -1053,8 +1052,7 @@ // U+0000 NULL EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars( - ConvertUTFResultContainer(conversionOK).withScalars(0x0000), - StringRef("\x00", 1))); + ConvertUTFResultContainer(conversionOK).withScalars(0x0000), "\x00"_sr)); // Overlong sequences of the above. EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars( Index: utils/TableGen/IntrinsicEmitter.cpp =================================================================== --- utils/TableGen/IntrinsicEmitter.cpp +++ utils/TableGen/IntrinsicEmitter.cpp @@ -139,7 +139,7 @@ << "};\n"; OS << "static const IntrinsicTargetInfo TargetInfos[] = {\n"; for (auto Target : Ints.Targets) - OS << " {\"" << Target.Name << "\", " << Target.Offset << ", " + OS << " {\"" << Target.Name << "\"_sr, " << Target.Offset << ", " << Target.Count << "},\n"; OS << "};\n"; OS << "#endif\n\n";