diff --git a/clang-tools-extra/clang-query/QueryParser.cpp b/clang-tools-extra/clang-query/QueryParser.cpp index 1d5ec281defd4..32aece873ac7f 100644 --- a/clang-tools-extra/clang-query/QueryParser.cpp +++ b/clang-tools-extra/clang-query/QueryParser.cpp @@ -72,7 +72,7 @@ template struct QueryParser::LexOrCompleteWord { } } - LexOrCompleteWord &Case(llvm::StringLiteral CaseStr, const T &Value, + LexOrCompleteWord &Case(llvm::StringRef CaseStr, const T &Value, bool IsCompletion = true) { if (WordCompletionPos == StringRef::npos) diff --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp index 4aa9fe228ee79..8f9e504cf17be 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp @@ -202,7 +202,7 @@ std::optional ClangTidyCheck::OptionsView::getEnumInt( return std::nullopt; } -static constexpr llvm::StringLiteral ConfigWarning( +static constexpr llvm::StringRef ConfigWarning( "invalid configuration value '%0' for option '%1'%select{|; expected a " "bool|; expected an integer|; did you mean '%3'?}2"); diff --git a/clang-tools-extra/clang-tidy/NoLintDirectiveHandler.cpp b/clang-tools-extra/clang-tidy/NoLintDirectiveHandler.cpp index 45d00dc16c113..fbc89312b271f 100644 --- a/clang-tools-extra/clang-tidy/NoLintDirectiveHandler.cpp +++ b/clang-tools-extra/clang-tidy/NoLintDirectiveHandler.cpp @@ -110,7 +110,7 @@ class NoLintToken { // Consume the entire buffer and return all `NoLintToken`s that were found. static SmallVector getNoLints(StringRef Buffer) { - static constexpr llvm::StringLiteral NOLINT = "NOLINT"; + static constexpr llvm::StringRef NOLINT = "NOLINT"; SmallVector NoLints; size_t Pos = 0; diff --git a/clang-tools-extra/clang-tidy/abseil/AbseilMatcher.h b/clang-tools-extra/clang-tidy/abseil/AbseilMatcher.h index 1eef86ddc00b9..4d64b49f97018 100644 --- a/clang-tools-extra/clang-tidy/abseil/AbseilMatcher.h +++ b/clang-tools-extra/clang-tidy/abseil/AbseilMatcher.h @@ -41,7 +41,7 @@ AST_POLYMORPHIC_MATCHER( // Determine whether filepath contains "absl/[absl-library]" substring, where // [absl-library] is AbseilLibraries list entry. StringRef Path = FileEntry->getName(); - static constexpr llvm::StringLiteral AbslPrefix("absl/"); + static constexpr llvm::StringRef AbslPrefix("absl/"); size_t PrefixPosition = Path.find(AbslPrefix); if (PrefixPosition == StringRef::npos) return false; diff --git a/clang-tools-extra/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp b/clang-tools-extra/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp index 4a6f17ed5f868..713b3d57c5ed4 100644 --- a/clang-tools-extra/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp +++ b/clang-tools-extra/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp @@ -18,9 +18,9 @@ namespace clang::tidy::abseil { namespace { -AST_MATCHER(StringLiteral, lengthIsOne) { return Node.getLength() == 1; } +AST_MATCHER(StringRef, lengthIsOne) { return Node.getLength() == 1; } -std::optional makeCharacterLiteral(const StringLiteral *Literal, +std::optional makeCharacterLiteral(const StringRef *Literal, const ASTContext &Context) { assert(Literal->getLength() == 1 && "Only single character string should be matched"); @@ -29,7 +29,7 @@ std::optional makeCharacterLiteral(const StringLiteral *Literal, std::string Result = clang::tooling::fixit::getText(*Literal, Context).str(); bool IsRawStringLiteral = StringRef(Result).starts_with(R"(R")"); // Since raw string literal might contain unescaped non-printable characters, - // we normalize them using `StringLiteral::outputString`. + // we normalize them using `StringRef::outputString`. if (IsRawStringLiteral) { Result.clear(); llvm::raw_string_ostream Stream(Result); @@ -99,7 +99,7 @@ void FasterStrsplitDelimiterCheck::registerMatchers(MatchFinder *Finder) { void FasterStrsplitDelimiterCheck::check( const MatchFinder::MatchResult &Result) { - const auto *Literal = Result.Nodes.getNodeAs("Literal"); + const auto *Literal = Result.Nodes.getNodeAs("Literal"); if (Literal->getBeginLoc().isMacroID() || Literal->getEndLoc().isMacroID()) return; diff --git a/clang-tools-extra/clang-tidy/android/CloexecCheck.cpp b/clang-tools-extra/clang-tidy/android/CloexecCheck.cpp index 39a0d74f38360..1b31777ffdeb5 100644 --- a/clang-tools-extra/clang-tidy/android/CloexecCheck.cpp +++ b/clang-tools-extra/clang-tidy/android/CloexecCheck.cpp @@ -29,7 +29,7 @@ std::string buildFixMsgForStringFlag(const Expr *Arg, const SourceManager &SM, " \"" + Twine(Mode) + "\"") .str(); - StringRef SR = cast(Arg->IgnoreParenCasts())->getString(); + StringRef SR = cast(Arg->IgnoreParenCasts())->getString(); return ("\"" + SR + Twine(Mode) + "\"").str(); } } // namespace @@ -84,7 +84,7 @@ void CloexecCheck::insertStringFlag( const auto *ModeArg = MatchedCall->getArg(ArgPos); // Check if the may be in the mode string. - const auto *ModeStr = dyn_cast(ModeArg->IgnoreParenCasts()); + const auto *ModeStr = dyn_cast(ModeArg->IgnoreParenCasts()); if (!ModeStr || ModeStr->getString().contains(Mode)) return; diff --git a/clang-tools-extra/clang-tidy/android/CloexecFopenCheck.h b/clang-tools-extra/clang-tidy/android/CloexecFopenCheck.h index 96517f55a5b55..4325343cb1b36 100644 --- a/clang-tools-extra/clang-tidy/android/CloexecFopenCheck.h +++ b/clang-tools-extra/clang-tidy/android/CloexecFopenCheck.h @@ -16,7 +16,7 @@ namespace clang::tidy::android { /// fopen() is suggested to include "e" in their mode string; like "re" would be /// better than "r". /// -/// This check only works when corresponding argument is StringLiteral. No +/// This check only works when corresponding argument is StringRef. No /// constant propagation. /// /// http://clang.llvm.org/extra/clang-tidy/checks/android/cloexec-fopen.html diff --git a/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp index 8cdd5d0a56467..aa3c18888b2d9 100644 --- a/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp @@ -254,7 +254,7 @@ bool ArgumentCommentCheck::shouldAddComment(const Expr *Arg) const { (CommentFloatLiterals && isa(Arg)) || (CommentUserDefinedLiterals && isa(Arg)) || (CommentCharacterLiterals && isa(Arg)) || - (CommentStringLiterals && isa(Arg)) || + (CommentStringLiterals && isa(Arg)) || (CommentNullPtrs && isa(Arg)); } diff --git a/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp index a7e25141b3fe2..cb15981110725 100644 --- a/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp @@ -293,8 +293,8 @@ static bool isIdenticalStmt(const ASTContext &Ctx, const Stmt *Stmt1, return FloatLit1->getValue().bitwiseIsEqual(FloatLit2->getValue()); } case Stmt::StringLiteralClass: { - const auto *StringLit1 = cast(Stmt1); - const auto *StringLit2 = cast(Stmt2); + const auto *StringLit1 = cast(Stmt1); + const auto *StringLit2 = cast(Stmt2); return StringLit1->getBytes() == StringLit2->getBytes(); } case Stmt::MemberExprClass: { diff --git a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp index 10868129e76da..254340afaccb3 100644 --- a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp @@ -24,24 +24,24 @@ namespace optutils = clang::tidy::utils::options; static constexpr std::size_t DefaultMinimumLength = 2; /// The default value for ignored parameter names. -static constexpr llvm::StringLiteral DefaultIgnoredParameterNames = "\"\";" - "iterator;" - "Iterator;" - "begin;" - "Begin;" - "end;" - "End;" - "first;" - "First;" - "last;" - "Last;" - "lhs;" - "LHS;" - "rhs;" - "RHS"; +static constexpr llvm::StringRef DefaultIgnoredParameterNames = "\"\";" + "iterator;" + "Iterator;" + "begin;" + "Begin;" + "end;" + "End;" + "first;" + "First;" + "last;" + "Last;" + "lhs;" + "LHS;" + "rhs;" + "RHS"; /// The default value for ignored parameter type suffixes. -static constexpr llvm::StringLiteral DefaultIgnoredParameterTypeSuffixes = +static constexpr llvm::StringRef DefaultIgnoredParameterTypeSuffixes = "bool;" "Bool;" "_Bool;" diff --git a/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp index 977241e91b9a9..3f7c34ddc6478 100644 --- a/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp @@ -19,18 +19,18 @@ using namespace clang::ast_matchers; namespace clang::tidy::bugprone { -constexpr llvm::StringLiteral FunctionExprName = "FunctionExpr"; -constexpr llvm::StringLiteral CastExprName = "CastExpr"; -constexpr llvm::StringLiteral UnknownDestName = "UnknownDest"; -constexpr llvm::StringLiteral DestArrayTyName = "DestArrayTy"; -constexpr llvm::StringLiteral DestVarDeclName = "DestVarDecl"; -constexpr llvm::StringLiteral DestMallocExprName = "DestMalloc"; -constexpr llvm::StringLiteral DestExprName = "DestExpr"; -constexpr llvm::StringLiteral SrcVarDeclName = "SrcVarDecl"; -constexpr llvm::StringLiteral SrcExprName = "SrcExpr"; -constexpr llvm::StringLiteral LengthExprName = "LengthExpr"; -constexpr llvm::StringLiteral WrongLengthExprName = "WrongLength"; -constexpr llvm::StringLiteral UnknownLengthName = "UnknownLength"; +constexpr llvm::StringRef FunctionExprName = "FunctionExpr"; +constexpr llvm::StringRef CastExprName = "CastExpr"; +constexpr llvm::StringRef UnknownDestName = "UnknownDest"; +constexpr llvm::StringRef DestArrayTyName = "DestArrayTy"; +constexpr llvm::StringRef DestVarDeclName = "DestVarDecl"; +constexpr llvm::StringRef DestMallocExprName = "DestMalloc"; +constexpr llvm::StringRef DestExprName = "DestExpr"; +constexpr llvm::StringRef SrcVarDeclName = "SrcVarDecl"; +constexpr llvm::StringRef SrcExprName = "SrcExpr"; +constexpr llvm::StringRef LengthExprName = "LengthExpr"; +constexpr llvm::StringRef WrongLengthExprName = "WrongLength"; +constexpr llvm::StringRef UnknownLengthName = "UnknownLength"; enum class LengthHandleKind { Increase, Decrease }; @@ -57,7 +57,7 @@ static const Expr *getDestCapacityExpr(const MatchFinder::MatchResult &Result) { return nullptr; } -// Returns the length of \p E as an 'IntegerLiteral' or a 'StringLiteral' +// Returns the length of \p E as an 'IntegerLiteral' or a 'StringRef' // without the null-terminator. static unsigned getLength(const Expr *E, const MatchFinder::MatchResult &Result) { @@ -80,11 +80,10 @@ static unsigned getLength(const Expr *E, if (const auto *StrDRE = dyn_cast(E)) if (const auto *StrVD = dyn_cast(StrDRE->getDecl())) if (const Expr *StrInit = StrVD->getInit()) - if (const auto *StrSL = - dyn_cast(StrInit->IgnoreImpCasts())) + if (const auto *StrSL = dyn_cast(StrInit->IgnoreImpCasts())) return StrSL->getLength(); - if (const auto *SrcSL = dyn_cast(E)) + if (const auto *SrcSL = dyn_cast(E)) return SrcSL->getLength(); return 0; diff --git a/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp index 902490f4d33c1..fe4fbf8791ed8 100644 --- a/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp @@ -13,7 +13,7 @@ // This is the minimal set of safe functions. // https://wiki.sei.cmu.edu/confluence/display/c/SIG30-C.+Call+only+asynchronous-safe+functions+within+signal+handlers -constexpr llvm::StringLiteral MinimalConformingFunctions[] = { +constexpr llvm::StringRef MinimalConformingFunctions[] = { "signal", "abort", "_Exit", "quick_exit"}; // The POSIX-defined set of safe functions. @@ -23,199 +23,198 @@ constexpr llvm::StringLiteral MinimalConformingFunctions[] = { // in the C11 standard. // Also, we want to keep the "minimal set" a subset of the "POSIX set". // The list is repeated in bugprone-signal-handler.rst and should be kept up to date. -constexpr llvm::StringLiteral POSIXConformingFunctions[] = { - "_Exit", - "_exit", - "abort", - "accept", - "access", - "aio_error", - "aio_return", - "aio_suspend", - "alarm", - "bind", - "cfgetispeed", - "cfgetospeed", - "cfsetispeed", - "cfsetospeed", - "chdir", - "chmod", - "chown", - "clock_gettime", - "close", - "connect", - "creat", - "dup", - "dup2", - "execl", - "execle", - "execv", - "execve", - "faccessat", - "fchdir", - "fchmod", - "fchmodat", - "fchown", - "fchownat", - "fcntl", - "fdatasync", - "fexecve", - "ffs", - "fork", - "fstat", - "fstatat", - "fsync", - "ftruncate", - "futimens", - "getegid", - "geteuid", - "getgid", - "getgroups", - "getpeername", - "getpgrp", - "getpid", - "getppid", - "getsockname", - "getsockopt", - "getuid", - "htonl", - "htons", - "kill", - "link", - "linkat", - "listen", - "longjmp", - "lseek", - "lstat", - "memccpy", - "memchr", - "memcmp", - "memcpy", - "memmove", - "memset", - "mkdir", - "mkdirat", - "mkfifo", - "mkfifoat", - "mknod", - "mknodat", - "ntohl", - "ntohs", - "open", - "openat", - "pause", - "pipe", - "poll", - "posix_trace_event", - "pselect", - "pthread_kill", - "pthread_self", - "pthread_sigmask", - "quick_exit", - "raise", - "read", - "readlink", - "readlinkat", - "recv", - "recvfrom", - "recvmsg", - "rename", - "renameat", - "rmdir", - "select", - "sem_post", - "send", - "sendmsg", - "sendto", - "setgid", - "setpgid", - "setsid", - "setsockopt", - "setuid", - "shutdown", - "sigaction", - "sigaddset", - "sigdelset", - "sigemptyset", - "sigfillset", - "sigismember", - "siglongjmp", - "signal", - "sigpause", - "sigpending", - "sigprocmask", - "sigqueue", - "sigset", - "sigsuspend", - "sleep", - "sockatmark", - "socket", - "socketpair", - "stat", - "stpcpy", - "stpncpy", - "strcat", - "strchr", - "strcmp", - "strcpy", - "strcspn", - "strlen", - "strncat", - "strncmp", - "strncpy", - "strnlen", - "strpbrk", - "strrchr", - "strspn", - "strstr", - "strtok_r", - "symlink", - "symlinkat", - "tcdrain", - "tcflow", - "tcflush", - "tcgetattr", - "tcgetpgrp", - "tcsendbreak", - "tcsetattr", - "tcsetpgrp", - "time", - "timer_getoverrun", - "timer_gettime", - "timer_settime", - "times", - "umask", - "uname", - "unlink", - "unlinkat", - "utime", - "utimensat", - "utimes", - "wait", - "waitpid", - "wcpcpy", - "wcpncpy", - "wcscat", - "wcschr", - "wcscmp", - "wcscpy", - "wcscspn", - "wcslen", - "wcsncat", - "wcsncmp", - "wcsncpy", - "wcsnlen", - "wcspbrk", - "wcsrchr", - "wcsspn", - "wcsstr", - "wcstok", - "wmemchr", - "wmemcmp", - "wmemcpy", - "wmemmove", - "wmemset", - "write"}; +constexpr llvm::StringRef POSIXConformingFunctions[] = {"_Exit", + "_exit", + "abort", + "accept", + "access", + "aio_error", + "aio_return", + "aio_suspend", + "alarm", + "bind", + "cfgetispeed", + "cfgetospeed", + "cfsetispeed", + "cfsetospeed", + "chdir", + "chmod", + "chown", + "clock_gettime", + "close", + "connect", + "creat", + "dup", + "dup2", + "execl", + "execle", + "execv", + "execve", + "faccessat", + "fchdir", + "fchmod", + "fchmodat", + "fchown", + "fchownat", + "fcntl", + "fdatasync", + "fexecve", + "ffs", + "fork", + "fstat", + "fstatat", + "fsync", + "ftruncate", + "futimens", + "getegid", + "geteuid", + "getgid", + "getgroups", + "getpeername", + "getpgrp", + "getpid", + "getppid", + "getsockname", + "getsockopt", + "getuid", + "htonl", + "htons", + "kill", + "link", + "linkat", + "listen", + "longjmp", + "lseek", + "lstat", + "memccpy", + "memchr", + "memcmp", + "memcpy", + "memmove", + "memset", + "mkdir", + "mkdirat", + "mkfifo", + "mkfifoat", + "mknod", + "mknodat", + "ntohl", + "ntohs", + "open", + "openat", + "pause", + "pipe", + "poll", + "posix_trace_event", + "pselect", + "pthread_kill", + "pthread_self", + "pthread_sigmask", + "quick_exit", + "raise", + "read", + "readlink", + "readlinkat", + "recv", + "recvfrom", + "recvmsg", + "rename", + "renameat", + "rmdir", + "select", + "sem_post", + "send", + "sendmsg", + "sendto", + "setgid", + "setpgid", + "setsid", + "setsockopt", + "setuid", + "shutdown", + "sigaction", + "sigaddset", + "sigdelset", + "sigemptyset", + "sigfillset", + "sigismember", + "siglongjmp", + "signal", + "sigpause", + "sigpending", + "sigprocmask", + "sigqueue", + "sigset", + "sigsuspend", + "sleep", + "sockatmark", + "socket", + "socketpair", + "stat", + "stpcpy", + "stpncpy", + "strcat", + "strchr", + "strcmp", + "strcpy", + "strcspn", + "strlen", + "strncat", + "strncmp", + "strncpy", + "strnlen", + "strpbrk", + "strrchr", + "strspn", + "strstr", + "strtok_r", + "symlink", + "symlinkat", + "tcdrain", + "tcflow", + "tcflush", + "tcgetattr", + "tcgetpgrp", + "tcsendbreak", + "tcsetattr", + "tcsetpgrp", + "time", + "timer_getoverrun", + "timer_gettime", + "timer_settime", + "times", + "umask", + "uname", + "unlink", + "unlinkat", + "utime", + "utimensat", + "utimes", + "wait", + "waitpid", + "wcpcpy", + "wcpncpy", + "wcscat", + "wcschr", + "wcscmp", + "wcscpy", + "wcscspn", + "wcslen", + "wcsncat", + "wcsncmp", + "wcsncpy", + "wcsnlen", + "wcspbrk", + "wcsrchr", + "wcsspn", + "wcsstr", + "wcstok", + "wmemchr", + "wmemcmp", + "wmemcpy", + "wmemmove", + "wmemset", + "write"}; using namespace clang::ast_matchers; diff --git a/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp index 8ae4351ac2830..0848e2fb3dd4c 100644 --- a/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp @@ -159,7 +159,7 @@ void StringConstructorCheck::check(const MatchFinder::MatchResult &Result) { if (WarnOnLargeLength) diag(Loc, "suspicious large length parameter"); } else if (Result.Nodes.getNodeAs("literal-with-length")) { - const auto *Str = Result.Nodes.getNodeAs("str"); + const auto *Str = Result.Nodes.getNodeAs("str"); const auto *Lit = Result.Nodes.getNodeAs("int"); if (Lit->getValue().ugt(Str->getLength())) { diag(Loc, "length is bigger than string literal size"); diff --git a/clang-tools-extra/clang-tidy/bugprone/StringLiteralWithEmbeddedNulCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/StringLiteralWithEmbeddedNulCheck.cpp index 72e680d25cb84..ca2b4679251ec 100644 --- a/clang-tools-extra/clang-tidy/bugprone/StringLiteralWithEmbeddedNulCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/StringLiteralWithEmbeddedNulCheck.cpp @@ -15,7 +15,7 @@ using namespace clang::ast_matchers; namespace clang::tidy::bugprone { namespace { -AST_MATCHER(StringLiteral, containsNul) { +AST_MATCHER(StringRef, containsNul) { for (size_t I = 0; I < Node.getLength(); ++I) if (Node.getCodeUnit(I) == '\0') return true; @@ -57,7 +57,7 @@ void StringLiteralWithEmbeddedNulCheck::registerMatchers(MatchFinder *Finder) { void StringLiteralWithEmbeddedNulCheck::check( const MatchFinder::MatchResult &Result) { - if (const auto *SL = Result.Nodes.getNodeAs("strlit")) { + if (const auto *SL = Result.Nodes.getNodeAs("strlit")) { for (size_t Offset = 0, Length = SL->getLength(); Offset < Length; ++Offset) { // Find a sequence of character like "\0x12". @@ -71,7 +71,7 @@ void StringLiteralWithEmbeddedNulCheck::check( } } - if (const auto *SL = Result.Nodes.getNodeAs("truncated")) { + if (const auto *SL = Result.Nodes.getNodeAs("truncated")) { diag(SL->getBeginLoc(), "truncated string literal with embedded NUL character"); } diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousMissingCommaCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousMissingCommaCheck.cpp index 81c38d07a0c7e..35f3c4e8652ed 100644 --- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousMissingCommaCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousMissingCommaCheck.cpp @@ -16,8 +16,7 @@ namespace clang::tidy::bugprone { namespace { -bool isConcatenatedLiteralsOnPurpose(ASTContext *Ctx, - const StringLiteral *Lit) { +bool isConcatenatedLiteralsOnPurpose(ASTContext *Ctx, const StringRef *Lit) { // String literals surrounded by parentheses are assumed to be on purpose. // i.e.: const char* Array[] = { ("a" "b" "c"), "d", [...] }; @@ -58,7 +57,7 @@ bool isConcatenatedLiteralsOnPurpose(ASTContext *Ctx, return false; } -AST_MATCHER_P(StringLiteral, isConcatenatedLiteral, unsigned, +AST_MATCHER_P(StringRef, isConcatenatedLiteral, unsigned, MaxConcatenatedTokens) { return Node.getNumConcatenated() > 1 && Node.getNumConcatenated() < MaxConcatenatedTokens && @@ -95,8 +94,7 @@ void SuspiciousMissingCommaCheck::registerMatchers(MatchFinder *Finder) { void SuspiciousMissingCommaCheck::check( const MatchFinder::MatchResult &Result) { const auto *InitializerList = Result.Nodes.getNodeAs("list"); - const auto *ConcatenatedLiteral = - Result.Nodes.getNodeAs("str"); + const auto *ConcatenatedLiteral = Result.Nodes.getNodeAs("str"); assert(InitializerList && ConcatenatedLiteral); // Skip small arrays as they often generate false-positive. @@ -108,7 +106,7 @@ void SuspiciousMissingCommaCheck::check( unsigned int Count = 0; for (unsigned int I = 0; I < Size; ++I) { const Expr *Child = InitializerList->getInit(I)->IgnoreImpCasts(); - if (const auto *Literal = dyn_cast(Child)) { + if (const auto *Literal = dyn_cast(Child)) { if (Literal->getNumConcatenated() > 1) ++Count; } diff --git a/clang-tools-extra/clang-tidy/bugprone/TaggedUnionMemberCountCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/TaggedUnionMemberCountCheck.cpp index db99ef3786e5f..499015a24a7ff 100644 --- a/clang-tools-extra/clang-tidy/bugprone/TaggedUnionMemberCountCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/TaggedUnionMemberCountCheck.cpp @@ -16,24 +16,23 @@ using namespace clang::ast_matchers; namespace clang::tidy::bugprone { -static constexpr llvm::StringLiteral StrictModeOptionName = "StrictMode"; -static constexpr llvm::StringLiteral EnableCountingEnumHeuristicOptionName = +static constexpr llvm::StringRef StrictModeOptionName = "StrictMode"; +static constexpr llvm::StringRef EnableCountingEnumHeuristicOptionName = "EnableCountingEnumHeuristic"; -static constexpr llvm::StringLiteral CountingEnumPrefixesOptionName = +static constexpr llvm::StringRef CountingEnumPrefixesOptionName = "CountingEnumPrefixes"; -static constexpr llvm::StringLiteral CountingEnumSuffixesOptionName = +static constexpr llvm::StringRef CountingEnumSuffixesOptionName = "CountingEnumSuffixes"; static constexpr bool StrictModeOptionDefaultValue = false; static constexpr bool EnableCountingEnumHeuristicOptionDefaultValue = true; -static constexpr llvm::StringLiteral CountingEnumPrefixesOptionDefaultValue = - ""; -static constexpr llvm::StringLiteral CountingEnumSuffixesOptionDefaultValue = +static constexpr llvm::StringRef CountingEnumPrefixesOptionDefaultValue = ""; +static constexpr llvm::StringRef CountingEnumSuffixesOptionDefaultValue = "count"; -static constexpr llvm::StringLiteral RootMatchBindName = "root"; -static constexpr llvm::StringLiteral UnionMatchBindName = "union"; -static constexpr llvm::StringLiteral TagMatchBindName = "tags"; +static constexpr llvm::StringRef RootMatchBindName = "root"; +static constexpr llvm::StringRef UnionMatchBindName = "union"; +static constexpr llvm::StringRef TagMatchBindName = "tags"; namespace { diff --git a/clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp index a73d46f01d9b2..075b1c3aec9c0 100644 --- a/clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp @@ -14,16 +14,14 @@ using namespace clang::ast_matchers; namespace clang::tidy::bugprone { -static constexpr llvm::StringLiteral LoopName = - llvm::StringLiteral("forLoopName"); -static constexpr llvm::StringLiteral LoopVarName = - llvm::StringLiteral("loopVar"); -static constexpr llvm::StringLiteral LoopVarCastName = - llvm::StringLiteral("loopVarCast"); -static constexpr llvm::StringLiteral LoopUpperBoundName = - llvm::StringLiteral("loopUpperBound"); -static constexpr llvm::StringLiteral LoopIncrementName = - llvm::StringLiteral("loopIncrement"); +static constexpr llvm::StringRef LoopName = llvm::StringRef("forLoopName"); +static constexpr llvm::StringRef LoopVarName = llvm::StringRef("loopVar"); +static constexpr llvm::StringRef LoopVarCastName = + llvm::StringRef("loopVarCast"); +static constexpr llvm::StringRef LoopUpperBoundName = + llvm::StringRef("loopUpperBound"); +static constexpr llvm::StringRef LoopIncrementName = + llvm::StringRef("loopIncrement"); namespace { diff --git a/clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp index 0a0e212f345ed..25b858cf00b1b 100644 --- a/clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp @@ -21,7 +21,7 @@ using ast_matchers::MatchFinder; using dataflow::UncheckedOptionalAccessDiagnoser; using dataflow::UncheckedOptionalAccessModel; -static constexpr llvm::StringLiteral FuncID("fun"); +static constexpr llvm::StringRef FuncID("fun"); void UncheckedOptionalAccessCheck::registerMatchers(MatchFinder *Finder) { using namespace ast_matchers; diff --git a/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp index 604a7cac0e490..f96aba2ffb969 100644 --- a/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp @@ -19,21 +19,19 @@ using namespace llvm; namespace clang::tidy::bugprone { -static constexpr llvm::StringLiteral OptionNameCustomFunctions = - "CustomFunctions"; -static constexpr llvm::StringLiteral OptionNameReportDefaultFunctions = +static constexpr llvm::StringRef OptionNameCustomFunctions = "CustomFunctions"; +static constexpr llvm::StringRef OptionNameReportDefaultFunctions = "ReportDefaultFunctions"; -static constexpr llvm::StringLiteral OptionNameReportMoreUnsafeFunctions = +static constexpr llvm::StringRef OptionNameReportMoreUnsafeFunctions = "ReportMoreUnsafeFunctions"; -static constexpr llvm::StringLiteral FunctionNamesWithAnnexKReplacementId = +static constexpr llvm::StringRef FunctionNamesWithAnnexKReplacementId = "FunctionNamesWithAnnexKReplacement"; -static constexpr llvm::StringLiteral FunctionNamesId = "FunctionsNames"; -static constexpr llvm::StringLiteral AdditionalFunctionNamesId = +static constexpr llvm::StringRef FunctionNamesId = "FunctionsNames"; +static constexpr llvm::StringRef AdditionalFunctionNamesId = "AdditionalFunctionsNames"; -static constexpr llvm::StringLiteral CustomFunctionNamesId = - "CustomFunctionNames"; -static constexpr llvm::StringLiteral DeclRefId = "DRE"; +static constexpr llvm::StringRef CustomFunctionNamesId = "CustomFunctionNames"; +static constexpr llvm::StringRef DeclRefId = "DRE"; static std::optional getAnnexKReplacementFor(StringRef FunctionName) { diff --git a/clang-tools-extra/clang-tidy/cert/MutatingCopyCheck.cpp b/clang-tools-extra/clang-tidy/cert/MutatingCopyCheck.cpp index a97fd720df86a..2bd01a1face37 100644 --- a/clang-tools-extra/clang-tidy/cert/MutatingCopyCheck.cpp +++ b/clang-tools-extra/clang-tidy/cert/MutatingCopyCheck.cpp @@ -14,9 +14,9 @@ using namespace clang::ast_matchers; namespace clang::tidy::cert { -static constexpr llvm::StringLiteral SourceDeclName = "ChangedPVD"; -static constexpr llvm::StringLiteral MutatingOperatorName = "MutatingOp"; -static constexpr llvm::StringLiteral MutatingCallName = "MutatingCall"; +static constexpr llvm::StringRef SourceDeclName = "ChangedPVD"; +static constexpr llvm::StringRef MutatingOperatorName = "MutatingOp"; +static constexpr llvm::StringRef MutatingCallName = "MutatingCall"; void MutatingCopyCheck::registerMatchers(MatchFinder *Finder) { const auto MemberExprOrSourceObject = anyOf( diff --git a/clang-tools-extra/clang-tidy/cert/StrToNumCheck.cpp b/clang-tools-extra/clang-tidy/cert/StrToNumCheck.cpp index 3b59d2357fe29..39808ddfa476c 100644 --- a/clang-tools-extra/clang-tidy/cert/StrToNumCheck.cpp +++ b/clang-tools-extra/clang-tidy/cert/StrToNumCheck.cpp @@ -200,7 +200,7 @@ void StrToNumCheck::check(const MatchFinder::MatchResult &Result) { return; if (const Expr *Arg = Call->getArg(Idx)->IgnoreParenImpCasts()) { - if (const auto *SL = dyn_cast(Arg)) { + if (const auto *SL = dyn_cast(Arg)) { FmtStr = SL->getString(); } } diff --git a/clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.cpp b/clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.cpp index d522d6760af1d..d060cc60d1285 100644 --- a/clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.cpp +++ b/clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.cpp @@ -18,7 +18,7 @@ namespace clang::tidy::google::readability { -constexpr llvm::StringLiteral KDisabledTestPrefix = "DISABLED_"; +constexpr llvm::StringRef KDisabledTestPrefix = "DISABLED_"; // Determines whether the macro is a Googletest test macro. static bool isGoogletestTestMacro(StringRef MacroName) { diff --git a/clang-tools-extra/clang-tidy/misc/MisleadingBidirectional.cpp b/clang-tools-extra/clang-tidy/misc/MisleadingBidirectional.cpp index da7139255bfaa..3d6a262fd1615 100644 --- a/clang-tools-extra/clang-tidy/misc/MisleadingBidirectional.cpp +++ b/clang-tools-extra/clang-tidy/misc/MisleadingBidirectional.cpp @@ -124,7 +124,7 @@ void MisleadingBidirectionalCheck::registerPPCallbacks( void MisleadingBidirectionalCheck::check( const ast_matchers::MatchFinder::MatchResult &Result) { - if (const auto *SL = Result.Nodes.getNodeAs("strlit")) { + if (const auto *SL = Result.Nodes.getNodeAs("strlit")) { StringRef Literal = SL->getBytes(); if (containsMisleadingBidi(Literal, false)) diag(SL->getBeginLoc(), "string literal contains misleading " diff --git a/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp b/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp index fc35bc22c52e0..4bf1ec95337aa 100644 --- a/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp @@ -36,7 +36,7 @@ namespace clang::tidy::misc { namespace { using llvm::APSInt; -static constexpr llvm::StringLiteral KnownBannedMacroNames[] = { +static constexpr llvm::StringRef KnownBannedMacroNames[] = { "EAGAIN", "EWOULDBLOCK", "SIGCLD", @@ -99,8 +99,8 @@ static bool areEquivalentExpr(const Expr *Left, const Expr *Right) { return cast(Left)->getValue().bitwiseIsEqual( cast(Right)->getValue()); case Stmt::StringLiteralClass: - return cast(Left)->getBytes() == - cast(Right)->getBytes(); + return cast(Left)->getBytes() == + cast(Right)->getBytes(); case Stmt::CXXOperatorCallExprClass: return cast(Left)->getOperator() == cast(Right)->getOperator(); @@ -472,7 +472,7 @@ AST_MATCHER(ConditionalOperator, conditionalOperatorIsInMacro) { AST_MATCHER(Expr, isMacro) { return Node.getExprLoc().isMacroID(); } -AST_MATCHER_P(Expr, expandedByMacro, ArrayRef, Names) { +AST_MATCHER_P(Expr, expandedByMacro, ArrayRef, Names) { const SourceManager &SM = Finder->getASTContext().getSourceManager(); const LangOptions &LO = Finder->getASTContext().getLangOpts(); SourceLocation Loc = Node.getExprLoc(); diff --git a/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp b/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp index 35536b47700a6..e7b7a14e4c976 100644 --- a/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp @@ -85,7 +85,7 @@ void StaticAssertCheck::check(const MatchFinder::MatchResult &Result) { const auto *CondStmt = Result.Nodes.getNodeAs("condStmt"); const auto *Condition = Result.Nodes.getNodeAs("condition"); const auto *IsAlwaysFalse = Result.Nodes.getNodeAs("isAlwaysFalse"); - const auto *AssertMSG = Result.Nodes.getNodeAs("assertMSG"); + const auto *AssertMSG = Result.Nodes.getNodeAs("assertMSG"); const auto *AssertExprRoot = Result.Nodes.getNodeAs("assertExprRoot"); const auto *CastExpr = Result.Nodes.getNodeAs("castExpr"); diff --git a/clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp b/clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp index abe7bed9df983..1e059182d190b 100644 --- a/clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp @@ -74,7 +74,7 @@ void ThrowByValueCatchByReferenceCheck::diagnoseThrowLocations( // The code is throwing a pointer. // In case it is string literal, it is safe and we return. auto *Inner = SubExpr->IgnoreParenImpCasts(); - if (isa(Inner)) + if (isa(Inner)) return; // If it's a variable from a catch statement, we return as well. auto *DeclRef = dyn_cast(Inner); diff --git a/clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp b/clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp index 7ec62f41aec01..1073363600fd1 100644 --- a/clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp @@ -39,7 +39,7 @@ bool isRawStringLiteral(StringRef Text) { } bool containsEscapedCharacters(const MatchFinder::MatchResult &Result, - const StringLiteral *Literal, + const StringRef *Literal, const CharsBitSet &DisallowedChars) { // FIXME: Handle L"", u8"", u"" and U"" literals. if (!Literal->isOrdinary()) @@ -66,7 +66,7 @@ bool containsDelimiter(StringRef Bytes, const std::string &Delimiter) { : (")" + Delimiter + R"(")")) != StringRef::npos; } -std::string asRawStringLiteral(const StringLiteral *Literal, +std::string asRawStringLiteral(const StringRef *Literal, const std::string &DelimiterStem) { const StringRef Bytes = Literal->getBytes(); std::string Delimiter; @@ -120,7 +120,7 @@ void RawStringLiteralCheck::registerMatchers(MatchFinder *Finder) { } void RawStringLiteralCheck::check(const MatchFinder::MatchResult &Result) { - const auto *Literal = Result.Nodes.getNodeAs("lit"); + const auto *Literal = Result.Nodes.getNodeAs("lit"); if (Literal->getBeginLoc().isMacroID()) return; @@ -135,7 +135,7 @@ void RawStringLiteralCheck::check(const MatchFinder::MatchResult &Result) { } void RawStringLiteralCheck::replaceWithRawStringLiteral( - const MatchFinder::MatchResult &Result, const StringLiteral *Literal, + const MatchFinder::MatchResult &Result, const StringRef *Literal, StringRef Replacement) { CharSourceRange CharRange = Lexer::makeFileCharRange( CharSourceRange::getTokenRange(Literal->getSourceRange()), diff --git a/clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.h b/clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.h index aae58ca0e98d9..ecd0f2506d1d5 100644 --- a/clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.h +++ b/clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.h @@ -35,7 +35,7 @@ class RawStringLiteralCheck : public ClangTidyCheck { private: void replaceWithRawStringLiteral( const ast_matchers::MatchFinder::MatchResult &Result, - const StringLiteral *Literal, StringRef Replacement); + const StringRef *Literal, StringRef Replacement); std::string DelimiterStem; CharsBitSet DisallowedChars; diff --git a/clang-tools-extra/clang-tidy/modernize/UnaryStaticAssertCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UnaryStaticAssertCheck.cpp index c90d2e4f764b8..fe0d02516916e 100644 --- a/clang-tools-extra/clang-tidy/modernize/UnaryStaticAssertCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UnaryStaticAssertCheck.cpp @@ -22,7 +22,7 @@ void UnaryStaticAssertCheck::check(const MatchFinder::MatchResult &Result) { const auto *MatchedDecl = Result.Nodes.getNodeAs("static_assert"); const auto *AssertMessage = - dyn_cast_if_present(MatchedDecl->getMessage()); + dyn_cast_if_present(MatchedDecl->getMessage()); SourceLocation Loc = MatchedDecl->getLocation(); diff --git a/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp index 6c06b0af342f6..dfee51ffdb724 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp @@ -172,8 +172,7 @@ static bool sameValue(const Expr *E1, const Expr *E2) { return cast(E1)->getValue().bitwiseIsEqual( cast(E2)->getValue()); case Stmt::StringLiteralClass: - return cast(E1)->getString() == - cast(E2)->getString(); + return cast(E1)->getString() == cast(E2)->getString(); case Stmt::DeclRefExprClass: return cast(E1)->getDecl() == cast(E2)->getDecl(); default: diff --git a/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp index ab72c6796bb4c..097e76cd577c8 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp @@ -39,7 +39,7 @@ struct NotLengthExprForStringNode { : ID(std::move(ID)), Node(std::move(Node)), Context(Context) {} bool operator()(const internal::BoundNodesMap &Nodes) const { // Match a string literal and an integer size or strlen() call. - if (const auto *StringLiteralNode = Nodes.getNodeAs(ID)) { + if (const auto *StringLiteralNode = Nodes.getNodeAs(ID)) { if (const auto *IntegerLiteralSizeNode = Node.get()) { return StringLiteralNode->getLength() != IntegerLiteralSizeNode->getValue().getZExtValue(); @@ -51,7 +51,7 @@ struct NotLengthExprForStringNode { return true; } - if (const auto *StrlenArgNode = dyn_cast( + if (const auto *StrlenArgNode = dyn_cast( StrlenNode->getArg(0)->IgnoreParenImpCasts())) { return StrlenArgNode->getLength() != StringLiteralNode->getLength(); } diff --git a/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.cpp index f97b844c56496..ff156ca93cb92 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.cpp @@ -19,7 +19,7 @@ using namespace clang::ast_matchers; namespace clang::tidy::modernize { namespace { -AST_MATCHER(StringLiteral, isOrdinary) { return Node.isOrdinary(); } +AST_MATCHER(StringRef, isOrdinary) { return Node.isOrdinary(); } } // namespace UseStdFormatCheck::UseStdFormatCheck(StringRef Name, ClangTidyContext *Context) diff --git a/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp index 4f24098225074..26202bb3397db 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp @@ -19,7 +19,7 @@ using namespace clang::ast_matchers; namespace clang::tidy::modernize { namespace { -AST_MATCHER(StringLiteral, isOrdinary) { return Node.isOrdinary(); } +AST_MATCHER(StringRef, isOrdinary) { return Node.isOrdinary(); } } // namespace UseStdPrintCheck::UseStdPrintCheck(StringRef Name, ClangTidyContext *Context) diff --git a/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp index 9774e988d71e2..649416c0d63f5 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp @@ -113,7 +113,7 @@ struct UnqualNameVisitor : public RecursiveASTVisitor { }; } // namespace -constexpr llvm::StringLiteral Message = +constexpr llvm::StringRef Message = "use a trailing return type for this function"; static SourceLocation expandIfMacroId(SourceLocation Loc, diff --git a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp index 30fcba367db67..87d229b1d054e 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp @@ -26,11 +26,11 @@ AST_MATCHER(clang::LinkageSpecDecl, isExternCLinkage) { namespace clang::tidy::modernize { -static constexpr llvm::StringLiteral ExternCDeclName = "extern-c-decl"; -static constexpr llvm::StringLiteral ParentDeclName = "parent-decl"; -static constexpr llvm::StringLiteral TagDeclName = "tag-decl"; -static constexpr llvm::StringLiteral TypedefName = "typedef"; -static constexpr llvm::StringLiteral DeclStmtName = "decl-stmt"; +static constexpr llvm::StringRef ExternCDeclName = "extern-c-decl"; +static constexpr llvm::StringRef ParentDeclName = "parent-decl"; +static constexpr llvm::StringRef TagDeclName = "tag-decl"; +static constexpr llvm::StringRef TypedefName = "typedef"; +static constexpr llvm::StringRef DeclStmtName = "decl-stmt"; UseUsingCheck::UseUsingCheck(StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), diff --git a/clang-tools-extra/clang-tidy/objc/NSDateFormatterCheck.cpp b/clang-tools-extra/clang-tidy/objc/NSDateFormatterCheck.cpp index fe18958ded1fd..ea575d82ef94d 100644 --- a/clang-tools-extra/clang-tidy/objc/NSDateFormatterCheck.cpp +++ b/clang-tools-extra/clang-tidy/objc/NSDateFormatterCheck.cpp @@ -48,7 +48,7 @@ bool isValidDatePattern(StringRef Pattern) { void NSDateFormatterCheck::check(const MatchFinder::MatchResult &Result) { // Callback implementation. const auto *StrExpr = Result.Nodes.getNodeAs("str_lit"); - const StringLiteral *SL = cast(StrExpr)->getString(); + const StringRef *SL = cast(StrExpr)->getString(); StringRef SR = SL->getString(); if (!isValidDatePattern(SR)) { diff --git a/clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp b/clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp index 40ea915a33299..d5c9e0c3150e2 100644 --- a/clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp +++ b/clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp @@ -19,7 +19,7 @@ namespace clang::tidy::performance { namespace { -std::optional makeCharacterLiteral(const StringLiteral *Literal) { +std::optional makeCharacterLiteral(const StringRef *Literal) { std::string Result; { llvm::raw_string_ostream OS(Result); @@ -82,7 +82,7 @@ void FasterStringFindCheck::registerMatchers(MatchFinder *Finder) { } void FasterStringFindCheck::check(const MatchFinder::MatchResult &Result) { - const auto *Literal = Result.Nodes.getNodeAs("literal"); + const auto *Literal = Result.Nodes.getNodeAs("literal"); const auto *FindFunc = Result.Nodes.getNodeAs("func"); auto Replacement = makeCharacterLiteral(Literal); diff --git a/clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp b/clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp index a05e228520c9e..ad1a69f398472 100644 --- a/clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp @@ -17,11 +17,10 @@ using namespace clang::ast_matchers; namespace clang::tidy::readability { -constexpr llvm::StringLiteral ContainerExprName = "container-expr"; -constexpr llvm::StringLiteral DerefContainerExprName = "deref-container-expr"; -constexpr llvm::StringLiteral AddrOfContainerExprName = - "addr-of-container-expr"; -constexpr llvm::StringLiteral AddressOfName = "address-of"; +constexpr llvm::StringRef ContainerExprName = "container-expr"; +constexpr llvm::StringRef DerefContainerExprName = "deref-container-expr"; +constexpr llvm::StringRef AddrOfContainerExprName = "addr-of-container-expr"; +constexpr llvm::StringRef AddressOfName = "address-of"; void ContainerDataPointerCheck::storeOptions( ClangTidyOptions::OptionMap &Opts) { diff --git a/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp b/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp index f9fd1d903e231..938429a413b74 100644 --- a/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp @@ -154,7 +154,7 @@ StringRef getEquivalentBoolLiteralForExpr(const Expr *Expression, return (CharLit->getValue() == 0) ? "false" : "true"; } - if (isa(Expression->IgnoreCasts())) { + if (isa(Expression->IgnoreCasts())) { return "true"; } diff --git a/clang-tools-extra/clang-tidy/readability/MisplacedArrayIndexCheck.cpp b/clang-tools-extra/clang-tidy/readability/MisplacedArrayIndexCheck.cpp index 328d1896ce9f8..719a51dad66f9 100644 --- a/clang-tools-extra/clang-tidy/readability/MisplacedArrayIndexCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/MisplacedArrayIndexCheck.cpp @@ -35,7 +35,7 @@ void MisplacedArrayIndexCheck::check(const MatchFinder::MatchResult &Result) { // Only try to fixit when LHS and RHS can be swapped directly without changing // the logic. const Expr *RHSE = ArraySubscriptE->getRHS()->IgnoreParenImpCasts(); - if (!isa(RHSE) && !isa(RHSE) && + if (!isa(RHSE) && !isa(RHSE) && !isa(RHSE)) return; diff --git a/clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp b/clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp index c5eaff88e0ed3..4aadd856e2054 100644 --- a/clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp @@ -92,37 +92,37 @@ struct AllHeuristicsBoundsWellConfigured { static_assert(AllHeuristicsBoundsWellConfigured::Value); } // namespace -static constexpr llvm::StringLiteral DefaultAbbreviations = "addr=address;" - "arr=array;" - "attr=attribute;" - "buf=buffer;" - "cl=client;" - "cnt=count;" - "col=column;" - "cpy=copy;" - "dest=destination;" - "dist=distance" - "dst=distance;" - "elem=element;" - "hght=height;" - "i=index;" - "idx=index;" - "len=length;" - "ln=line;" - "lst=list;" - "nr=number;" - "num=number;" - "pos=position;" - "ptr=pointer;" - "ref=reference;" - "src=source;" - "srv=server;" - "stmt=statement;" - "str=string;" - "val=value;" - "var=variable;" - "vec=vector;" - "wdth=width"; +static constexpr llvm::StringRef DefaultAbbreviations = "addr=address;" + "arr=array;" + "attr=attribute;" + "buf=buffer;" + "cl=client;" + "cnt=count;" + "col=column;" + "cpy=copy;" + "dest=destination;" + "dist=distance" + "dst=distance;" + "elem=element;" + "hght=height;" + "i=index;" + "idx=index;" + "len=length;" + "ln=line;" + "lst=list;" + "nr=number;" + "num=number;" + "pos=position;" + "ptr=pointer;" + "ref=reference;" + "src=source;" + "srv=server;" + "stmt=statement;" + "str=string;" + "val=value;" + "var=variable;" + "vec=vector;" + "wdth=width"; static constexpr std::size_t SmallVectorSize = SuspiciousCallArgumentCheck::SmallVectorSize; diff --git a/clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp b/clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp index 66b5f3922789d..9879b42b501d6 100644 --- a/clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp @@ -23,37 +23,34 @@ namespace { struct IntegerLiteralCheck { using type = clang::IntegerLiteral; - static constexpr llvm::StringLiteral Name = llvm::StringLiteral("integer"); + static constexpr llvm::StringRef Name = llvm::StringRef("integer"); // What should be skipped before looking for the Suffixes? (Nothing here.) - static constexpr llvm::StringLiteral SkipFirst = llvm::StringLiteral(""); + static constexpr llvm::StringRef SkipFirst = llvm::StringRef(""); // Suffix can only consist of 'u' and 'l' chars, and can be a complex number // ('i', 'j'). In MS compatibility mode, suffixes like i32 are supported. - static constexpr llvm::StringLiteral Suffixes = - llvm::StringLiteral("uUlLiIjJ"); + static constexpr llvm::StringRef Suffixes = llvm::StringRef("uUlLiIjJ"); }; -constexpr llvm::StringLiteral IntegerLiteralCheck::Name; -constexpr llvm::StringLiteral IntegerLiteralCheck::SkipFirst; -constexpr llvm::StringLiteral IntegerLiteralCheck::Suffixes; +constexpr llvm::StringRef IntegerLiteralCheck::Name; +constexpr llvm::StringRef IntegerLiteralCheck::SkipFirst; +constexpr llvm::StringRef IntegerLiteralCheck::Suffixes; struct FloatingLiteralCheck { using type = clang::FloatingLiteral; - static constexpr llvm::StringLiteral Name = - llvm::StringLiteral("floating point"); + static constexpr llvm::StringRef Name = llvm::StringRef("floating point"); // C++17 introduced hexadecimal floating-point literals, and 'f' is both a // valid hexadecimal digit in a hex float literal and a valid floating-point // literal suffix. // So we can't just "skip to the chars that can be in the suffix". // Since the exponent ('p'/'P') is mandatory for hexadecimal floating-point // literals, we first skip everything before the exponent. - static constexpr llvm::StringLiteral SkipFirst = llvm::StringLiteral("pP"); + static constexpr llvm::StringRef SkipFirst = llvm::StringRef("pP"); // Suffix can only consist of 'f', 'l', "f16", 'h', 'q' chars, // and can be a complex number ('i', 'j'). - static constexpr llvm::StringLiteral Suffixes = - llvm::StringLiteral("fFlLhHqQiIjJ"); + static constexpr llvm::StringRef Suffixes = llvm::StringRef("fFlLhHqQiIjJ"); }; -constexpr llvm::StringLiteral FloatingLiteralCheck::Name; -constexpr llvm::StringLiteral FloatingLiteralCheck::SkipFirst; -constexpr llvm::StringLiteral FloatingLiteralCheck::Suffixes; +constexpr llvm::StringRef FloatingLiteralCheck::Name; +constexpr llvm::StringRef FloatingLiteralCheck::SkipFirst; +constexpr llvm::StringRef FloatingLiteralCheck::Suffixes; struct NewSuffix { SourceRange LiteralLocation; diff --git a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp index fa8887e4639b4..a0ac8994d8688 100644 --- a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp +++ b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp @@ -483,7 +483,7 @@ static StringRef closest(StringRef Value, const StringSet<> &Allowed) { return Closest; } -static constexpr StringLiteral VerifyConfigWarningEnd = " [-verify-config]\n"; +static constexpr StringRef VerifyConfigWarningEnd = " [-verify-config]\n"; static bool verifyChecks(const StringSet<> &AllChecks, StringRef CheckGlob, StringRef Source) { diff --git a/clang-tools-extra/clang-tidy/utils/FormatStringConverter.cpp b/clang-tools-extra/clang-tidy/utils/FormatStringConverter.cpp index 7f4ccca84faa5..0788f040a80e6 100644 --- a/clang-tools-extra/clang-tidy/utils/FormatStringConverter.cpp +++ b/clang-tools-extra/clang-tidy/utils/FormatStringConverter.cpp @@ -206,7 +206,7 @@ FormatStringConverter::FormatStringConverter( Args(Call->getArgs()), NumArgs(Call->getNumArgs()), ArgsOffset(FormatArgOffset + 1), LangOpts(LO) { assert(ArgsOffset <= NumArgs); - FormatExpr = llvm::dyn_cast( + FormatExpr = llvm::dyn_cast( Args[FormatArgOffset]->IgnoreImplicitAsWritten()); if (!FormatExpr || !FormatExpr->isOrdinary()) { @@ -243,7 +243,7 @@ FormatStringConverter::FormatStringConverter( std::optional FormatStringConverter::formatStringContainsUnreplaceableMacro( - const CallExpr *Call, const StringLiteral *FormatExpr, SourceManager &SM, + const CallExpr *Call, const StringRef *FormatExpr, SourceManager &SM, Preprocessor &PP) { // If a macro invocation surrounds the entire call then we don't want that to // inhibit conversion. The whole format string will appear to come from that diff --git a/clang-tools-extra/clang-tidy/utils/FormatStringConverter.h b/clang-tools-extra/clang-tidy/utils/FormatStringConverter.h index 15d1f597fe440..59e98ccc7f267 100644 --- a/clang-tools-extra/clang-tidy/utils/FormatStringConverter.h +++ b/clang-tools-extra/clang-tidy/utils/FormatStringConverter.h @@ -68,7 +68,7 @@ class FormatStringConverter std::optional StringCStrCallExprMatcher; - const StringLiteral *FormatExpr; + const StringRef *FormatExpr; std::string StandardFormatString; /// Casts to be used to wrap arguments to retain printf compatibility. @@ -113,7 +113,7 @@ class FormatStringConverter void finalizeFormatText(); static std::optional formatStringContainsUnreplaceableMacro(const CallExpr *CallExpr, - const StringLiteral *FormatExpr, + const StringRef *FormatExpr, SourceManager &SM, Preprocessor &PP); bool conversionNotPossible(std::string Reason) { ConversionNotPossibleReason = std::move(Reason); diff --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp b/clang-tools-extra/clangd/ClangdLSPServer.cpp index 1e981825c7c15..53ab80c7e4817 100644 --- a/clang-tools-extra/clangd/ClangdLSPServer.cpp +++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp @@ -73,9 +73,9 @@ std::optional decodeVersion(llvm::StringRef Encoded) { return std::nullopt; } -const llvm::StringLiteral ApplyFixCommand = "clangd.applyFix"; -const llvm::StringLiteral ApplyTweakCommand = "clangd.applyTweak"; -const llvm::StringLiteral ApplyRenameCommand = "clangd.applyRename"; +const llvm::StringRef ApplyFixCommand = "clangd.applyFix"; +const llvm::StringRef ApplyTweakCommand = "clangd.applyTweak"; +const llvm::StringRef ApplyRenameCommand = "clangd.applyRename"; CodeAction toCodeAction(const ClangdServer::CodeActionResult::Rename &R, const URIForFile &File) { diff --git a/clang-tools-extra/clangd/ClangdServer.h b/clang-tools-extra/clangd/ClangdServer.h index e030bf04122d5..e4e4a82e23f4a 100644 --- a/clang-tools-extra/clangd/ClangdServer.h +++ b/clang-tools-extra/clangd/ClangdServer.h @@ -357,7 +357,7 @@ class ClangdServer { struct TweakRef { std::string ID; /// ID to pass for applyTweak. std::string Title; /// A single-line message to show in the UI. - llvm::StringLiteral Kind; + llvm::StringRef Kind; }; // Ref to the clangd::Diag. diff --git a/clang-tools-extra/clangd/ConfigCompile.cpp b/clang-tools-extra/clangd/ConfigCompile.cpp index aa2561e081047..dec00d7e968d0 100644 --- a/clang-tools-extra/clangd/ConfigCompile.cpp +++ b/clang-tools-extra/clangd/ConfigCompile.cpp @@ -116,7 +116,7 @@ struct FragmentCompiler { } std::optional makeAbsolute(Located Path, - llvm::StringLiteral Description, + llvm::StringRef Description, llvm::sys::path::Style Style) { if (llvm::sys::path::is_absolute(*Path)) return *Path; @@ -142,14 +142,14 @@ struct FragmentCompiler { llvm::StringRef EnumName; const Located &Input; std::optional Result; - llvm::SmallVector ValidValues; + llvm::SmallVector ValidValues; public: EnumSwitch(llvm::StringRef EnumName, const Located &In, FragmentCompiler &Outer) : Outer(Outer), EnumName(EnumName), Input(In) {} - EnumSwitch &map(llvm::StringLiteral Name, T Value) { + EnumSwitch &map(llvm::StringRef Name, T Value) { assert(!llvm::is_contained(ValidValues, Name) && "Duplicate value!"); ValidValues.push_back(Name); if (!Result && *Input == Name) diff --git a/clang-tools-extra/clangd/ConfigYAML.cpp b/clang-tools-extra/clangd/ConfigYAML.cpp index 95cc5c1f9f1cf..c0e72dfda1aec 100644 --- a/clang-tools-extra/clangd/ConfigYAML.cpp +++ b/clang-tools-extra/clangd/ConfigYAML.cpp @@ -314,7 +314,7 @@ class Parser { // Parse is called when Key is encountered, and passed the associated value. // It should emit diagnostics if the value is invalid (e.g. wrong type). // If Key is seen twice, Parse runs only once and an error is reported. - void handle(llvm::StringLiteral Key, std::function Parse) { + void handle(llvm::StringRef Key, std::function Parse) { for (const auto &Entry : Keys) { (void)Entry; assert(Entry.first != Key && "duplicate key handler"); diff --git a/clang-tools-extra/clangd/Hover.cpp b/clang-tools-extra/clangd/Hover.cpp index 298fa79e3fd0b..8631f626c177f 100644 --- a/clang-tools-extra/clangd/Hover.cpp +++ b/clang-tools-extra/clangd/Hover.cpp @@ -683,7 +683,7 @@ getPredefinedExprHoverContents(const PredefinedExpr &PE, ASTContext &Ctx, HI.Name = PE.getIdentKindName(); HI.Kind = index::SymbolKind::Variable; HI.Documentation = "Name of the current function (predefined variable)"; - if (const StringLiteral *Name = PE.getFunctionName()) { + if (const StringRef *Name = PE.getFunctionName()) { HI.Value.emplace(); llvm::raw_string_ostream OS(*HI.Value); Name->outputString(OS); @@ -864,7 +864,7 @@ HoverInfo getDeducedTypeHoverContents(QualType QT, const syntax::Token &Tok, return HI; } -HoverInfo getStringLiteralContents(const StringLiteral *SL, +HoverInfo getStringLiteralContents(const StringRef *SL, const PrintingPolicy &PP) { HoverInfo HI; @@ -883,10 +883,10 @@ bool isLiteral(const Expr *E) { llvm::isa(E) || llvm::isa(E) || llvm::isa(E) || llvm::isa(E) || llvm::isa(E) || - llvm::isa(E) || llvm::isa(E); + llvm::isa(E) || llvm::isa(E); } -llvm::StringLiteral getNameForExpr(const Expr *E) { +llvm::StringRef getNameForExpr(const Expr *E) { // FIXME: Come up with names for `special` expressions. // // It's an known issue for GCC5, https://godbolt.org/z/Z_tbgi. Work around @@ -894,7 +894,7 @@ llvm::StringLiteral getNameForExpr(const Expr *E) { // // TODO: Once GCC5 is fully retired and not the minimal requirement as stated // in `GettingStarted`, please remove the explicit conversion constructor. - return llvm::StringLiteral("expression"); + return llvm::StringRef("expression"); } void maybeAddCalleeArgInfo(const SelectionTree::Node *N, HoverInfo &HI, @@ -908,7 +908,7 @@ std::optional getHoverContents(const SelectionTree::Node *N, const SymbolIndex *Index) { std::optional HI; - if (const StringLiteral *SL = dyn_cast(E)) { + if (const StringRef *SL = dyn_cast(E)) { // Print the type and the size for string literals HI = getStringLiteralContents(SL, PP); } else if (isLiteral(E)) { @@ -965,7 +965,7 @@ bool isParagraphBreak(llvm::StringRef Rest) { } bool punctuationIndicatesLineBreak(llvm::StringRef Line) { - constexpr llvm::StringLiteral Punctuation = R"txt(.:,;!?)txt"; + constexpr llvm::StringRef Punctuation = R"txt(.:,;!?)txt"; Line = Line.rtrim(); return !Line.empty() && Punctuation.contains(Line.back()); @@ -974,7 +974,7 @@ bool punctuationIndicatesLineBreak(llvm::StringRef Line) { bool isHardLineBreakIndicator(llvm::StringRef Rest) { // '-'/'*' md list, '@'/'\' documentation command, '>' md blockquote, // '#' headings, '`' code blocks - constexpr llvm::StringLiteral LinebreakIndicators = R"txt(-*@\>#`)txt"; + constexpr llvm::StringRef LinebreakIndicators = R"txt(-*@\>#`)txt"; Rest = Rest.ltrim(" \t"); if (Rest.empty()) @@ -1578,7 +1578,7 @@ std::optional getBacktickQuoteRange(llvm::StringRef Line, // The open-quote is usually preceded by whitespace. llvm::StringRef Prefix = Line.substr(0, Offset); - constexpr llvm::StringLiteral BeforeStartChars = " \t(="; + constexpr llvm::StringRef BeforeStartChars = " \t(="; if (!Prefix.empty() && !BeforeStartChars.contains(Prefix.back())) return std::nullopt; @@ -1593,7 +1593,7 @@ std::optional getBacktickQuoteRange(llvm::StringRef Line, // The close-quote is usually followed by whitespace or punctuation. llvm::StringRef Suffix = Line.substr(Next + 1); - constexpr llvm::StringLiteral AfterEndChars = " \t)=.,;:"; + constexpr llvm::StringRef AfterEndChars = " \t)=.,;:"; if (!Suffix.empty() && !AfterEndChars.contains(Suffix.front())) return std::nullopt; diff --git a/clang-tools-extra/clangd/InlayHints.cpp b/clang-tools-extra/clangd/InlayHints.cpp index fefffeb4efc1a..c68149ecc446b 100644 --- a/clang-tools-extra/clangd/InlayHints.cpp +++ b/clang-tools-extra/clangd/InlayHints.cpp @@ -161,7 +161,7 @@ std::string summarizeExpr(const Expr *E) { Result.resize(llvm::StringRef(Result).rtrim().size()); return Result; } - std::string VisitStringLiteral(const StringLiteral *E) { + std::string VisitStringLiteral(const StringRef *E) { std::string Result = "\""; if (E->containsNonAscii()) { Result += "..."; @@ -933,7 +933,7 @@ class InlayHintVisitor : public RecursiveASTVisitor { return false; // Ignore some punctuation and whitespace around comment. // In particular this allows designators to match nicely. - llvm::StringLiteral IgnoreChars = " =."; + llvm::StringRef IgnoreChars = " =."; SourcePrefix = SourcePrefix.rtrim(IgnoreChars); ParamName = ParamName.trim(IgnoreChars); // Other than that, the comment must contain exactly ParamName. diff --git a/clang-tools-extra/clangd/LSPBinder.h b/clang-tools-extra/clangd/LSPBinder.h index 8542112681375..71f9fc0cf1316 100644 --- a/clang-tools-extra/clangd/LSPBinder.h +++ b/clang-tools-extra/clangd/LSPBinder.h @@ -58,7 +58,7 @@ class LSPBinder { /// Handler should be e.g. void peek(const PeekParams&, Callback); /// PeekParams must be JSON-parseable and PeekResult must be serializable. template - void method(llvm::StringLiteral Method, ThisT *This, + void method(llvm::StringRef Method, ThisT *This, void (ThisT::*Handler)(const Param &, Callback)); /// Bind a handler for an LSP notification. @@ -66,7 +66,7 @@ class LSPBinder { /// Handler should be e.g. void poke(const PokeParams&); /// PokeParams must be JSON-parseable. template - void notification(llvm::StringLiteral Method, ThisT *This, + void notification(llvm::StringRef Method, ThisT *This, void (ThisT::*Handler)(const Param &)); /// Bind a handler for an LSP command. @@ -74,7 +74,7 @@ class LSPBinder { /// Handler should be e.g. void load(const LoadParams&, Callback); /// LoadParams must be JSON-parseable and LoadResult must be serializable. template - void command(llvm::StringLiteral Command, ThisT *This, + void command(llvm::StringRef Command, ThisT *This, void (ThisT::*Handler)(const Param &, Callback)); template @@ -84,7 +84,7 @@ class LSPBinder { /// Bind a function object to be used for outgoing method calls. /// e.g. OutgoingMethod Edit = Bind.outgoingMethod("edit"); /// EParams must be JSON-serializable, EResult must be parseable. - UntypedOutgoingMethod outgoingMethod(llvm::StringLiteral Method); + UntypedOutgoingMethod outgoingMethod(llvm::StringRef Method); template using OutgoingNotification = llvm::unique_function; @@ -93,7 +93,7 @@ class LSPBinder { /// Bind a function object to be used for outgoing notifications. /// e.g. OutgoingNotification Log = Bind.outgoingMethod("log"); /// LogParams must be JSON-serializable. - UntypedOutgoingNotification outgoingNotification(llvm::StringLiteral Method); + UntypedOutgoingNotification outgoingNotification(llvm::StringRef Method); private: // FIXME: remove usage from ClangdLSPServer and make this private. @@ -130,7 +130,7 @@ llvm::Expected LSPBinder::parse(const llvm::json::Value &Raw, } template -void LSPBinder::method(llvm::StringLiteral Method, ThisT *This, +void LSPBinder::method(llvm::StringRef Method, ThisT *This, void (ThisT::*Handler)(const Param &, Callback)) { Raw.MethodHandlers[Method] = [Method, Handler, This](JSON RawParams, @@ -143,7 +143,7 @@ void LSPBinder::method(llvm::StringLiteral Method, ThisT *This, } template -void LSPBinder::notification(llvm::StringLiteral Method, ThisT *This, +void LSPBinder::notification(llvm::StringRef Method, ThisT *This, void (ThisT::*Handler)(const Param &)) { Raw.NotificationHandlers[Method] = [Method, Handler, This](JSON RawParams) { llvm::Expected P = @@ -155,7 +155,7 @@ void LSPBinder::notification(llvm::StringLiteral Method, ThisT *This, } template -void LSPBinder::command(llvm::StringLiteral Method, ThisT *This, +void LSPBinder::command(llvm::StringRef Method, ThisT *This, void (ThisT::*Handler)(const Param &, Callback)) { Raw.CommandHandlers[Method] = [Method, Handler, This](JSON RawParams, @@ -168,12 +168,12 @@ void LSPBinder::command(llvm::StringLiteral Method, ThisT *This, } class LSPBinder::UntypedOutgoingNotification { - llvm::StringLiteral Method; + llvm::StringRef Method; RawOutgoing *Out; - UntypedOutgoingNotification(llvm::StringLiteral Method, RawOutgoing *Out) + UntypedOutgoingNotification(llvm::StringRef Method, RawOutgoing *Out) : Method(Method), Out(Out) {} friend UntypedOutgoingNotification - LSPBinder::outgoingNotification(llvm::StringLiteral); + LSPBinder::outgoingNotification(llvm::StringRef); public: template operator OutgoingNotification() && { @@ -183,16 +183,16 @@ class LSPBinder::UntypedOutgoingNotification { }; inline LSPBinder::UntypedOutgoingNotification -LSPBinder::outgoingNotification(llvm::StringLiteral Method) { +LSPBinder::outgoingNotification(llvm::StringRef Method) { return UntypedOutgoingNotification(Method, &Out); } class LSPBinder::UntypedOutgoingMethod { - llvm::StringLiteral Method; + llvm::StringRef Method; RawOutgoing *Out; - UntypedOutgoingMethod(llvm::StringLiteral Method, RawOutgoing *Out) + UntypedOutgoingMethod(llvm::StringRef Method, RawOutgoing *Out) : Method(Method), Out(Out) {} - friend UntypedOutgoingMethod LSPBinder::outgoingMethod(llvm::StringLiteral); + friend UntypedOutgoingMethod LSPBinder::outgoingMethod(llvm::StringRef); public: template @@ -213,7 +213,7 @@ class LSPBinder::UntypedOutgoingMethod { }; inline LSPBinder::UntypedOutgoingMethod -LSPBinder::outgoingMethod(llvm::StringLiteral Method) { +LSPBinder::outgoingMethod(llvm::StringRef Method) { return UntypedOutgoingMethod(Method, &Out); } diff --git a/clang-tools-extra/clangd/ParsedAST.cpp b/clang-tools-extra/clangd/ParsedAST.cpp index 725cbeb154cb8..c47eaf18bf957 100644 --- a/clang-tools-extra/clangd/ParsedAST.cpp +++ b/clang-tools-extra/clangd/ParsedAST.cpp @@ -275,7 +275,7 @@ class TidyDiagnosticGroups { public: TidyDiagnosticGroups(llvm::StringRef Checks) { - constexpr llvm::StringLiteral CDPrefix = "clang-diagnostic-"; + constexpr llvm::StringRef CDPrefix = "clang-diagnostic-"; llvm::StringRef Check; while (!Checks.empty()) { diff --git a/clang-tools-extra/clangd/Preamble.h b/clang-tools-extra/clangd/Preamble.h index be8fed4ab88cd..047d5e999a2d8 100644 --- a/clang-tools-extra/clangd/Preamble.h +++ b/clang-tools-extra/clangd/Preamble.h @@ -214,7 +214,7 @@ class PreamblePatch { /// Returns diag locations for Modified contents. llvm::ArrayRef patchedDiags() const { return PatchedDiags; } - static constexpr llvm::StringLiteral HeaderName = "__preamble_patch__.h"; + static constexpr llvm::StringRef HeaderName = "__preamble_patch__.h"; llvm::ArrayRef marks() const; const MainFileMacros &mainFileMacros() const; diff --git a/clang-tools-extra/clangd/Protocol.cpp b/clang-tools-extra/clangd/Protocol.cpp index 05c8041df7de7..a65adda29d136 100644 --- a/clang-tools-extra/clangd/Protocol.cpp +++ b/clang-tools-extra/clangd/Protocol.cpp @@ -29,8 +29,8 @@ namespace { // Helper that doesn't treat `null` and absent fields as failures. template -bool mapOptOrNull(const llvm::json::Value &Params, llvm::StringLiteral Prop, - T &Out, llvm::json::Path P) { +bool mapOptOrNull(const llvm::json::Value &Params, llvm::StringRef Prop, T &Out, + llvm::json::Path P) { auto *O = Params.getAsObject(); assert(O); auto *V = O->get(Prop); @@ -905,9 +905,9 @@ llvm::json::Value toJSON(const Command &C) { return std::move(Cmd); } -const llvm::StringLiteral CodeAction::QUICKFIX_KIND = "quickfix"; -const llvm::StringLiteral CodeAction::REFACTOR_KIND = "refactor"; -const llvm::StringLiteral CodeAction::INFO_KIND = "info"; +const llvm::StringRef CodeAction::QUICKFIX_KIND = "quickfix"; +const llvm::StringRef CodeAction::REFACTOR_KIND = "refactor"; +const llvm::StringRef CodeAction::INFO_KIND = "info"; llvm::json::Value toJSON(const CodeAction &CA) { auto CodeAction = llvm::json::Object{{"title", CA.title}}; @@ -1656,9 +1656,9 @@ bool fromJSON(const llvm::json::Value &Params, FoldingRangeParams &R, return O && O.map("textDocument", R.textDocument); } -const llvm::StringLiteral FoldingRange::REGION_KIND = "region"; -const llvm::StringLiteral FoldingRange::COMMENT_KIND = "comment"; -const llvm::StringLiteral FoldingRange::IMPORT_KIND = "import"; +const llvm::StringRef FoldingRange::REGION_KIND = "region"; +const llvm::StringRef FoldingRange::COMMENT_KIND = "comment"; +const llvm::StringRef FoldingRange::IMPORT_KIND = "import"; llvm::json::Value toJSON(const FoldingRange &Range) { llvm::json::Object Result{ diff --git a/clang-tools-extra/clangd/Protocol.h b/clang-tools-extra/clangd/Protocol.h index c7ef1a13e6e39..3f64eb309e956 100644 --- a/clang-tools-extra/clangd/Protocol.h +++ b/clang-tools-extra/clangd/Protocol.h @@ -1070,9 +1070,9 @@ struct CodeAction { /// The kind of the code action. /// Used to filter code actions. std::optional kind; - const static llvm::StringLiteral QUICKFIX_KIND; - const static llvm::StringLiteral REFACTOR_KIND; - const static llvm::StringLiteral INFO_KIND; + const static llvm::StringRef QUICKFIX_KIND; + const static llvm::StringRef REFACTOR_KIND; + const static llvm::StringRef INFO_KIND; /// The diagnostics that this code action resolves. std::optional> diagnostics; @@ -1963,9 +1963,9 @@ struct FoldingRange { unsigned endLine = 0; unsigned endCharacter; - const static llvm::StringLiteral REGION_KIND; - const static llvm::StringLiteral COMMENT_KIND; - const static llvm::StringLiteral IMPORT_KIND; + const static llvm::StringRef REGION_KIND; + const static llvm::StringRef COMMENT_KIND; + const static llvm::StringRef IMPORT_KIND; std::string kind; }; llvm::json::Value toJSON(const FoldingRange &Range); diff --git a/clang-tools-extra/clangd/Selection.cpp b/clang-tools-extra/clangd/Selection.cpp index 277cb8769a1b1..693b72b35e96b 100644 --- a/clang-tools-extra/clangd/Selection.cpp +++ b/clang-tools-extra/clangd/Selection.cpp @@ -730,7 +730,7 @@ class SelectionVisitor : public RecursiveASTVisitor { // Override child traversal for certain node types. using RecursiveASTVisitor::getStmtChildren; - // PredefinedExpr like __func__ has a StringLiteral child for its value. + // PredefinedExpr like __func__ has a StringRef child for its value. // It's not written, so don't traverse it. Stmt::child_range getStmtChildren(PredefinedExpr *) { return {StmtIterator{}, StmtIterator{}}; diff --git a/clang-tools-extra/clangd/SemanticSelection.cpp b/clang-tools-extra/clangd/SemanticSelection.cpp index dd7116e619e6d..cd728928cf51e 100644 --- a/clang-tools-extra/clangd/SemanticSelection.cpp +++ b/clang-tools-extra/clangd/SemanticSelection.cpp @@ -194,7 +194,7 @@ getFoldingRanges(const std::string &Code, bool LineFoldingOnly) { std::vector Result; auto AddFoldingRange = [&](Position Start, Position End, - llvm::StringLiteral Kind) { + llvm::StringRef Kind) { if (Start.line >= End.line) return; FoldingRange FR; diff --git a/clang-tools-extra/clangd/TUScheduler.cpp b/clang-tools-extra/clangd/TUScheduler.cpp index 035e5e63d8fbb..f8885c3dd9889 100644 --- a/clang-tools-extra/clangd/TUScheduler.cpp +++ b/clang-tools-extra/clangd/TUScheduler.cpp @@ -862,7 +862,7 @@ ASTWorker::~ASTWorker() { void ASTWorker::update(ParseInputs Inputs, WantDiagnostics WantDiags, bool ContentChanged) { - llvm::StringLiteral TaskName = "Update"; + llvm::StringRef TaskName = "Update"; auto Task = [=]() mutable { // Get the actual command as `Inputs` does not have a command. // FIXME: some build systems like Bazel will take time to preparing @@ -1106,7 +1106,7 @@ void ASTWorker::updatePreamble(std::unique_ptr CI, std::shared_ptr Preamble, std::vector CIDiags, WantDiagnostics WantDiags) { - llvm::StringLiteral TaskName = "Build AST"; + llvm::StringRef TaskName = "Build AST"; // Store preamble and build diagnostics with new preamble if requested. auto Task = [this, Preamble = std::move(Preamble), CI = std::move(CI), CIDiags = std::move(CIDiags), diff --git a/clang-tools-extra/clangd/TidyProvider.cpp b/clang-tools-extra/clangd/TidyProvider.cpp index 2ac123246a4cb..b89f708741a2d 100644 --- a/clang-tools-extra/clangd/TidyProvider.cpp +++ b/clang-tools-extra/clangd/TidyProvider.cpp @@ -195,7 +195,7 @@ TidyProvider addTidyChecks(llvm::StringRef Checks, } TidyProvider disableUnusableChecks(llvm::ArrayRef ExtraBadChecks) { - constexpr llvm::StringLiteral Separator(","); + constexpr llvm::StringRef Separator(","); static const std::string BadChecks = llvm::join_items( Separator, // We want this list to start with a separator to diff --git a/clang-tools-extra/clangd/index/StdLib.cpp b/clang-tools-extra/clangd/index/StdLib.cpp index d34838a45048d..014d6478c6e2d 100644 --- a/clang-tools-extra/clangd/index/StdLib.cpp +++ b/clang-tools-extra/clangd/index/StdLib.cpp @@ -35,7 +35,7 @@ namespace { enum Lang { C, CXX }; Lang langFromOpts(const LangOptions &LO) { return LO.CPlusPlus ? CXX : C; } -llvm::StringLiteral mandatoryHeader(Lang L) { +llvm::StringRef mandatoryHeader(Lang L) { switch (L) { case C: return "stdio.h"; @@ -67,7 +67,7 @@ LangStandard::Kind standardFromOpts(const LangOptions &LO) { return LangStandard::lang_c99; } -std::string buildUmbrella(llvm::StringLiteral Mandatory, +std::string buildUmbrella(llvm::StringRef Mandatory, llvm::ArrayRef Headers) { std::string Result; llvm::raw_string_ostream OS(Result); @@ -301,7 +301,7 @@ std::optional StdLibSet::add(const LangOptions &LO, // Check for the existence of on the search path. // We could cache this, but we only get here repeatedly when there's no // stdlib, and even then only once per preamble build. - llvm::StringLiteral ProbeHeader = mandatoryHeader(L); + llvm::StringRef ProbeHeader = mandatoryHeader(L); llvm::SmallString<256> Path; // Scratch space. llvm::SmallVector SearchPaths; auto RecordHeaderPath = [&](llvm::StringRef HeaderPath) { diff --git a/clang-tools-extra/clangd/index/remote/server/Server.cpp b/clang-tools-extra/clangd/index/remote/server/Server.cpp index 890b6c27ed928..c8c47b52826bd 100644 --- a/clang-tools-extra/clangd/index/remote/server/Server.cpp +++ b/clang-tools-extra/clangd/index/remote/server/Server.cpp @@ -366,7 +366,7 @@ class RemoteIndexServer final : public v1::SymbolIndex::Service { void logResponse(const google::protobuf::Message &M) { vlog(">>> {0}\n{1}", M.GetDescriptor()->name(), TextProto{M}); } - void logRequestSummary(llvm::StringLiteral RequestName, unsigned Sent, + void logRequestSummary(llvm::StringRef RequestName, unsigned Sent, stopwatch::time_point StartTime) { auto Duration = stopwatch::now() - StartTime; auto Millis = diff --git a/clang-tools-extra/clangd/refactor/Tweak.h b/clang-tools-extra/clangd/refactor/Tweak.h index 257f44a285f88..78d5e0ab0bd7f 100644 --- a/clang-tools-extra/clangd/refactor/Tweak.h +++ b/clang-tools-extra/clangd/refactor/Tweak.h @@ -120,7 +120,7 @@ class Tweak { virtual std::string title() const = 0; /// Describes what kind of action this is. /// EXPECTS: prepare() was called and returned true. - virtual llvm::StringLiteral kind() const = 0; + virtual llvm::StringRef kind() const = 0; /// Is this a 'hidden' tweak, which are off by default. virtual bool hidden() const { return false; } }; diff --git a/clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp b/clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp index 00c05ebdb5216..3a25bab155202 100644 --- a/clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp +++ b/clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp @@ -52,9 +52,7 @@ class AddUsing : public Tweak { bool prepare(const Selection &Inputs) override; Expected apply(const Selection &Inputs) override; std::string title() const override; - llvm::StringLiteral kind() const override { - return CodeAction::REFACTOR_KIND; - } + llvm::StringRef kind() const override { return CodeAction::REFACTOR_KIND; } private: // All of the following are set by prepare(). diff --git a/clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp b/clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp index 3a320260238b6..54e8c520e9716 100644 --- a/clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp +++ b/clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp @@ -29,9 +29,7 @@ class AnnotateHighlightings : public Tweak { Expected apply(const Selection &Inputs) override; std::string title() const override { return "Annotate highlighting tokens"; } - llvm::StringLiteral kind() const override { - return CodeAction::REFACTOR_KIND; - } + llvm::StringRef kind() const override { return CodeAction::REFACTOR_KIND; } bool hidden() const override { return true; } }; REGISTER_TWEAK(AnnotateHighlightings) diff --git a/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp b/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp index d6556bba14725..fe749c849e479 100644 --- a/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp +++ b/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp @@ -386,9 +386,7 @@ class DefineInline : public Tweak { public: const char *id() const final; - llvm::StringLiteral kind() const override { - return CodeAction::REFACTOR_KIND; - } + llvm::StringRef kind() const override { return CodeAction::REFACTOR_KIND; } std::string title() const override { return "Move function body to declaration"; } diff --git a/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp b/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp index e4eef228b6b99..ad718deb3d2af 100644 --- a/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp +++ b/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp @@ -420,9 +420,7 @@ class DefineOutline : public Tweak { const char *id() const override; bool hidden() const override { return false; } - llvm::StringLiteral kind() const override { - return CodeAction::REFACTOR_KIND; - } + llvm::StringRef kind() const override { return CodeAction::REFACTOR_KIND; } std::string title() const override { return "Move function body to out-of-line"; } diff --git a/clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp b/clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp index e126e72ef2532..4b856055bdd64 100644 --- a/clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp +++ b/clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp @@ -29,7 +29,7 @@ namespace { /// Message: /// CallExpr /// |-DeclRefExpr fcall -/// `-StringLiteral "foo" +/// `-StringRef "foo" class DumpAST : public Tweak { public: const char *id() const final; @@ -46,7 +46,7 @@ class DumpAST : public Tweak { return std::string( llvm::formatv("Dump {0} AST", Node->getNodeKind().asStringRef())); } - llvm::StringLiteral kind() const override { return CodeAction::INFO_KIND; } + llvm::StringRef kind() const override { return CodeAction::INFO_KIND; } bool hidden() const override { return true; } private: @@ -92,7 +92,7 @@ class ShowSelectionTree : public Tweak { return Effect::showMessage(llvm::to_string(Inputs.ASTSelection)); } std::string title() const override { return "Show selection tree"; } - llvm::StringLiteral kind() const override { return CodeAction::INFO_KIND; } + llvm::StringRef kind() const override { return CodeAction::INFO_KIND; } bool hidden() const override { return true; } }; REGISTER_TWEAK(ShowSelectionTree) @@ -118,7 +118,7 @@ class DumpSymbol : public Tweak { return Effect::showMessage(Out.str()); } std::string title() const override { return "Dump symbol under the cursor"; } - llvm::StringLiteral kind() const override { return CodeAction::INFO_KIND; } + llvm::StringRef kind() const override { return CodeAction::INFO_KIND; } bool hidden() const override { return true; } }; REGISTER_TWEAK(DumpSymbol) @@ -154,7 +154,7 @@ class DumpRecordLayout : public Tweak { "Show {0} layout", TypeWithKeyword::getTagTypeKindName(Record->getTagKind()))); } - llvm::StringLiteral kind() const override { return CodeAction::INFO_KIND; } + llvm::StringRef kind() const override { return CodeAction::INFO_KIND; } // FIXME: this is interesting to most users. However: // - triggering is too broad (e.g. triggers on comments within a class) // - showMessage has inconsistent UX (e.g. newlines are stripped in VSCode) diff --git a/clang-tools-extra/clangd/refactor/tweaks/ExpandDeducedType.cpp b/clang-tools-extra/clangd/refactor/tweaks/ExpandDeducedType.cpp index fec5f5797cb62..1a0a48a52f13f 100644 --- a/clang-tools-extra/clangd/refactor/tweaks/ExpandDeducedType.cpp +++ b/clang-tools-extra/clangd/refactor/tweaks/ExpandDeducedType.cpp @@ -39,9 +39,7 @@ namespace { class ExpandDeducedType : public Tweak { public: const char *id() const final; - llvm::StringLiteral kind() const override { - return CodeAction::REFACTOR_KIND; - } + llvm::StringRef kind() const override { return CodeAction::REFACTOR_KIND; } bool prepare(const Selection &Inputs) override; Expected apply(const Selection &Inputs) override; std::string title() const override; diff --git a/clang-tools-extra/clangd/refactor/tweaks/ExpandMacro.cpp b/clang-tools-extra/clangd/refactor/tweaks/ExpandMacro.cpp index 29e681c3d44f7..d2bb1f0b925ca 100644 --- a/clang-tools-extra/clangd/refactor/tweaks/ExpandMacro.cpp +++ b/clang-tools-extra/clangd/refactor/tweaks/ExpandMacro.cpp @@ -31,9 +31,7 @@ namespace { class ExpandMacro : public Tweak { public: const char *id() const final; - llvm::StringLiteral kind() const override { - return CodeAction::REFACTOR_KIND; - } + llvm::StringRef kind() const override { return CodeAction::REFACTOR_KIND; } bool prepare(const Selection &Inputs) override; Expected apply(const Selection &Inputs) override; diff --git a/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp b/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp index cd07cbf73635c..de12a3af449a5 100644 --- a/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp +++ b/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp @@ -811,9 +811,7 @@ class ExtractFunction : public Tweak { bool prepare(const Selection &Inputs) override; Expected apply(const Selection &Inputs) override; std::string title() const override { return "Extract to function"; } - llvm::StringLiteral kind() const override { - return CodeAction::REFACTOR_KIND; - } + llvm::StringRef kind() const override { return CodeAction::REFACTOR_KIND; } private: ExtractionZone ExtZone; diff --git a/clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp b/clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp index d84e501b87ce7..869cb9d55c4d1 100644 --- a/clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp +++ b/clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp @@ -578,9 +578,7 @@ class ExtractVariable : public Tweak { std::string title() const override { return "Extract subexpression to variable"; } - llvm::StringLiteral kind() const override { - return CodeAction::REFACTOR_KIND; - } + llvm::StringRef kind() const override { return CodeAction::REFACTOR_KIND; } private: // the expression to extract diff --git a/clang-tools-extra/clangd/refactor/tweaks/MemberwiseConstructor.cpp b/clang-tools-extra/clangd/refactor/tweaks/MemberwiseConstructor.cpp index 9bb8ca96a8b61..957d45829204e 100644 --- a/clang-tools-extra/clangd/refactor/tweaks/MemberwiseConstructor.cpp +++ b/clang-tools-extra/clangd/refactor/tweaks/MemberwiseConstructor.cpp @@ -33,9 +33,7 @@ namespace { class MemberwiseConstructor : public Tweak { public: const char *id() const final; - llvm::StringLiteral kind() const override { - return CodeAction::REFACTOR_KIND; - } + llvm::StringRef kind() const override { return CodeAction::REFACTOR_KIND; } std::string title() const override { return llvm::formatv("Define constructor"); } diff --git a/clang-tools-extra/clangd/refactor/tweaks/ObjCLocalizeStringLiteral.cpp b/clang-tools-extra/clangd/refactor/tweaks/ObjCLocalizeStringLiteral.cpp index c513a18d94ccb..90c1972679a04 100644 --- a/clang-tools-extra/clangd/refactor/tweaks/ObjCLocalizeStringLiteral.cpp +++ b/clang-tools-extra/clangd/refactor/tweaks/ObjCLocalizeStringLiteral.cpp @@ -30,9 +30,7 @@ namespace { class ObjCLocalizeStringLiteral : public Tweak { public: const char *id() const final; - llvm::StringLiteral kind() const override { - return CodeAction::REFACTOR_KIND; - } + llvm::StringRef kind() const override { return CodeAction::REFACTOR_KIND; } bool prepare(const Selection &Inputs) override; Expected apply(const Selection &Inputs) override; @@ -50,7 +48,7 @@ bool ObjCLocalizeStringLiteral::prepare(const Selection &Inputs) { return false; // Allow the refactoring even if the user selected only the C string part // of the expression. - if (N->ASTNode.get()) { + if (N->ASTNode.get()) { if (N->Parent) N = N->Parent; } diff --git a/clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp b/clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp index c462a69c3b225..8ac8ab4edeace 100644 --- a/clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp +++ b/clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp @@ -172,9 +172,7 @@ initializerForParams(const SmallVector &Params, class ObjCMemberwiseInitializer : public Tweak { public: const char *id() const final; - llvm::StringLiteral kind() const override { - return CodeAction::REFACTOR_KIND; - } + llvm::StringRef kind() const override { return CodeAction::REFACTOR_KIND; } bool prepare(const Selection &Inputs) override; Expected apply(const Selection &Inputs) override; diff --git a/clang-tools-extra/clangd/refactor/tweaks/PopulateSwitch.cpp b/clang-tools-extra/clangd/refactor/tweaks/PopulateSwitch.cpp index 43cfc769f7f71..de1a38da102ac 100644 --- a/clang-tools-extra/clangd/refactor/tweaks/PopulateSwitch.cpp +++ b/clang-tools-extra/clangd/refactor/tweaks/PopulateSwitch.cpp @@ -52,9 +52,7 @@ class PopulateSwitch : public Tweak { bool prepare(const Selection &Sel) override; Expected apply(const Selection &Sel) override; std::string title() const override { return "Populate switch"; } - llvm::StringLiteral kind() const override { - return CodeAction::QUICKFIX_KIND; - } + llvm::StringRef kind() const override { return CodeAction::QUICKFIX_KIND; } private: class ExpectedCase { diff --git a/clang-tools-extra/clangd/refactor/tweaks/RawStringLiteral.cpp b/clang-tools-extra/clangd/refactor/tweaks/RawStringLiteral.cpp index 5613ceacdfe1b..102820e817197 100644 --- a/clang-tools-extra/clangd/refactor/tweaks/RawStringLiteral.cpp +++ b/clang-tools-extra/clangd/refactor/tweaks/RawStringLiteral.cpp @@ -34,12 +34,10 @@ class RawStringLiteral : public Tweak { bool prepare(const Selection &Inputs) override; Expected apply(const Selection &Inputs) override; std::string title() const override { return "Convert to raw string"; } - llvm::StringLiteral kind() const override { - return CodeAction::REFACTOR_KIND; - } + llvm::StringRef kind() const override { return CodeAction::REFACTOR_KIND; } private: - const clang::StringLiteral *Str = nullptr; + const clang::StringRef *Str = nullptr; }; REGISTER_TWEAK(RawStringLiteral) @@ -50,8 +48,8 @@ static bool isFeatureAvailable(const ASTContext &Context) { return Context.getLangOpts().CPlusPlus11; } -static bool isNormalString(const StringLiteral &Str, SourceLocation Cursor, - SourceManager &SM) { +static bool isNormalString(const StringRef &Str, SourceLocation Cursor, + SourceManager &SM) { // All chunks must be normal ASCII strings, not u8"..." etc. if (!Str.isOrdinary()) return false; @@ -85,7 +83,7 @@ bool RawStringLiteral::prepare(const Selection &Inputs) { const SelectionTree::Node *N = Inputs.ASTSelection.commonAncestor(); if (!N) return false; - Str = dyn_cast_or_null(N->ASTNode.get()); + Str = dyn_cast_or_null(N->ASTNode.get()); return Str && isNormalString(*Str, Inputs.Cursor, Inputs.AST->getSourceManager()) && needsRaw(Str->getBytes()) && canBeRaw(Str->getBytes()); diff --git a/clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp b/clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp index da32e00a0ee06..12d3a0175a4a1 100644 --- a/clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp +++ b/clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp @@ -39,9 +39,7 @@ class RemoveUsingNamespace : public Tweak { std::string title() const override { return "Remove using namespace, re-qualify names instead"; } - llvm::StringLiteral kind() const override { - return CodeAction::REFACTOR_KIND; - } + llvm::StringRef kind() const override { return CodeAction::REFACTOR_KIND; } private: const UsingDirectiveDecl *TargetDirective = nullptr; diff --git a/clang-tools-extra/clangd/refactor/tweaks/ScopifyEnum.cpp b/clang-tools-extra/clangd/refactor/tweaks/ScopifyEnum.cpp index 44080802a2895..6d24a4c1db7f7 100644 --- a/clang-tools-extra/clangd/refactor/tweaks/ScopifyEnum.cpp +++ b/clang-tools-extra/clangd/refactor/tweaks/ScopifyEnum.cpp @@ -50,9 +50,7 @@ namespace { class ScopifyEnum : public Tweak { const char *id() const final; std::string title() const override { return "Convert to scoped enum"; } - llvm::StringLiteral kind() const override { - return CodeAction::REFACTOR_KIND; - } + llvm::StringRef kind() const override { return CodeAction::REFACTOR_KIND; } bool prepare(const Selection &Inputs) override; Expected apply(const Selection &Inputs) override; diff --git a/clang-tools-extra/clangd/refactor/tweaks/SpecialMembers.cpp b/clang-tools-extra/clangd/refactor/tweaks/SpecialMembers.cpp index 0b86b48422707..603d999ff0536 100644 --- a/clang-tools-extra/clangd/refactor/tweaks/SpecialMembers.cpp +++ b/clang-tools-extra/clangd/refactor/tweaks/SpecialMembers.cpp @@ -84,9 +84,7 @@ std::string buildSpecialMemberDeclarations(const CXXRecordDecl &Class) { class SpecialMembers : public Tweak { public: const char *id() const final; - llvm::StringLiteral kind() const override { - return CodeAction::REFACTOR_KIND; - } + llvm::StringRef kind() const override { return CodeAction::REFACTOR_KIND; } std::string title() const override { return llvm::formatv("Declare implicit {0} members", NeedCopy ? NeedMove ? "copy/move" : "copy" : "move"); diff --git a/clang-tools-extra/clangd/refactor/tweaks/SwapBinaryOperands.cpp b/clang-tools-extra/clangd/refactor/tweaks/SwapBinaryOperands.cpp index 9ad0089a5d035..cd293fc61f677 100644 --- a/clang-tools-extra/clangd/refactor/tweaks/SwapBinaryOperands.cpp +++ b/clang-tools-extra/clangd/refactor/tweaks/SwapBinaryOperands.cpp @@ -145,9 +145,7 @@ class SwapBinaryOperands : public Tweak { return llvm::formatv("Swap operands to {0}", Op ? Op->getOpcodeStr() : "binary operator"); } - llvm::StringLiteral kind() const override { - return CodeAction::REFACTOR_KIND; - } + llvm::StringRef kind() const override { return CodeAction::REFACTOR_KIND; } bool hidden() const override { return false; } private: diff --git a/clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp b/clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp index 7b64c4385a90b..ab6a615a28077 100644 --- a/clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp +++ b/clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp @@ -35,9 +35,7 @@ class SwapIfBranches : public Tweak { bool prepare(const Selection &Inputs) override; Expected apply(const Selection &Inputs) override; std::string title() const override { return "Swap if branches"; } - llvm::StringLiteral kind() const override { - return CodeAction::REFACTOR_KIND; - } + llvm::StringRef kind() const override { return CodeAction::REFACTOR_KIND; } bool hidden() const override { return true; } private: diff --git a/clang-tools-extra/clangd/support/MemoryTree.h b/clang-tools-extra/clangd/support/MemoryTree.h index c3fc32183cd54..cfae7b3401aa9 100644 --- a/clang-tools-extra/clangd/support/MemoryTree.h +++ b/clang-tools-extra/clangd/support/MemoryTree.h @@ -36,7 +36,7 @@ struct MemoryTree { /// No copy of the \p Name. /// Note that returned pointers are invalidated with subsequent calls to /// child/detail. - MemoryTree &child(llvm::StringLiteral Name) { return createChild(Name); } + MemoryTree &child(llvm::StringRef Name) { return createChild(Name); } MemoryTree(const MemoryTree &) = delete; MemoryTree &operator=(const MemoryTree &) = delete; diff --git a/clang-tools-extra/clangd/support/Trace.h b/clang-tools-extra/clangd/support/Trace.h index 36c3745a41e96..e5aef59fe8953 100644 --- a/clang-tools-extra/clangd/support/Trace.h +++ b/clang-tools-extra/clangd/support/Trace.h @@ -51,8 +51,8 @@ struct Metric { /// time. Distribution, }; - constexpr Metric(llvm::StringLiteral Name, MetricType Type, - llvm::StringLiteral LabelName = llvm::StringLiteral("")) + constexpr Metric(llvm::StringRef Name, MetricType Type, + llvm::StringRef LabelName = llvm::StringRef("")) : Name(Name), Type(Type), LabelName(LabelName) {} /// Records a measurement for this metric to active tracer. @@ -60,12 +60,12 @@ struct Metric { /// Uniquely identifies the metric. Should use snake_case identifiers, can use /// dots for hierarchy if needed. e.g. method_latency, foo.bar. - const llvm::StringLiteral Name; + const llvm::StringRef Name; const MetricType Type; /// Indicates what measurement labels represent, e.g. "operation_name" for a /// metric tracking latencies. If non empty all measurements must also have a /// non-empty label. - const llvm::StringLiteral LabelName; + const llvm::StringRef LabelName; }; /// A consumer of trace events and measurements. The events are produced by diff --git a/clang-tools-extra/clangd/unittests/ASTTests.cpp b/clang-tools-extra/clangd/unittests/ASTTests.cpp index 32c8e8a63a215..14bc1d5878869 100644 --- a/clang-tools-extra/clangd/unittests/ASTTests.cpp +++ b/clang-tools-extra/clangd/unittests/ASTTests.cpp @@ -258,7 +258,7 @@ TEST(GetDeducedType, KwAutoKwDecltypeExpansion) { TEST(ClangdAST, GetOnlyInstantiation) { struct { const char *Code; - llvm::StringLiteral NodeType; + llvm::StringRef NodeType; const char *Name; } Cases[] = { { diff --git a/clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp b/clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp index 2c7f50d8c9e4c..e2c33b3c48a93 100644 --- a/clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp +++ b/clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp @@ -189,7 +189,7 @@ TEST_F(LSPTest, DiagnosticsHeaderSaved) { TEST_F(LSPTest, RecordsLatencies) { trace::TestTracer Tracer; auto &Client = start(); - llvm::StringLiteral MethodName = "method_name"; + llvm::StringRef MethodName = "method_name"; EXPECT_THAT(Tracer.takeMetric("lsp_latency", MethodName), testing::SizeIs(0)); llvm::consumeError(Client.call(MethodName, {}).take().takeError()); stop(); @@ -471,7 +471,7 @@ TEST_F(LSPTest, FeatureModulesThreadingTest) { } TEST_F(LSPTest, DiagModuleTest) { - static constexpr llvm::StringLiteral DiagMsg = "DiagMsg"; + static constexpr llvm::StringRef DiagMsg = "DiagMsg"; class DiagModule final : public FeatureModule { struct DiagHooks : public ASTListener { void sawDiagnostic(const clang::Diagnostic &, clangd::Diag &D) override { diff --git a/clang-tools-extra/clangd/unittests/ClangdTests.cpp b/clang-tools-extra/clangd/unittests/ClangdTests.cpp index 643b8e9f12d75..7f34cc86b0155 100644 --- a/clang-tools-extra/clangd/unittests/ClangdTests.cpp +++ b/clang-tools-extra/clangd/unittests/ClangdTests.cpp @@ -1280,9 +1280,7 @@ TEST(ClangdServer, RespectsTweakFormatting) { return E; } std::string title() const override { return id(); } - llvm::StringLiteral kind() const override { - return llvm::StringLiteral(""); - }; + llvm::StringRef kind() const override { return llvm::StringRef(""); }; }; void contributeTweaks(std::vector> &Out) override { diff --git a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp index 9d48a6e09fc77..521f9620d8a78 100644 --- a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp +++ b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp @@ -1474,44 +1474,43 @@ TEST(SignatureHelpTest, Overloads) { } TEST(SignatureHelpTest, FunctionPointers) { - llvm::StringLiteral Tests[] = { - // Variable of function pointer type - R"cpp( + llvm::StringRef Tests[] = {// Variable of function pointer type + R"cpp( void (*foo)(int x, int y); int main() { foo(^); } )cpp", - // Wrapped in an AttributedType - R"cpp( + // Wrapped in an AttributedType + R"cpp( void (__stdcall *foo)(int x, int y); int main() { foo(^); } )cpp", - // Another syntax for an AttributedType - R"cpp( + // Another syntax for an AttributedType + R"cpp( void (__attribute__(stdcall) *foo)(int x, int y); int main() { foo(^); }, )cpp", - // Wrapped in a typedef - R"cpp( + // Wrapped in a typedef + R"cpp( typedef void (*fn)(int x, int y); fn foo; int main() { foo(^); } )cpp", - // Wrapped in both a typedef and an AttributedTyped - R"cpp( + // Wrapped in both a typedef and an AttributedTyped + R"cpp( typedef void (__stdcall *fn)(int x, int y); fn foo; int main() { foo(^); } )cpp", - // Field of function pointer type - R"cpp( + // Field of function pointer type + R"cpp( struct S { void (*foo)(int x, int y); }; S s; int main() { s.foo(^); } )cpp", - // Field of function pointer typedef type - R"cpp( + // Field of function pointer typedef type + R"cpp( typedef void (*fn)(int x, int y); struct S { fn foo; @@ -1612,7 +1611,7 @@ TEST(SignatureHelpTest, ActiveArg) { } TEST(SignatureHelpTest, OpeningParen) { - llvm::StringLiteral Tests[] = { + llvm::StringRef Tests[] = { // Recursive function call. R"cpp( int foo(int a, int b, int c); @@ -4050,8 +4049,8 @@ TEST(CompletionTest, ObjCCategoryDecls) { } TEST(CompletionTest, PreambleCodeComplete) { - llvm::StringLiteral Baseline = "\n#define MACRO 12\nint num = MACRO;"; - llvm::StringLiteral ModifiedCC = + llvm::StringRef Baseline = "\n#define MACRO 12\nint num = MACRO;"; + llvm::StringRef ModifiedCC = "#include \"header.h\"\n#define MACRO 12\nint num = MACRO; int num2 = M^"; Annotations Test(ModifiedCC); @@ -4211,7 +4210,7 @@ TEST(SignatureHelp, TemplateArguments) { } TEST(CompletionTest, DoNotCrash) { - llvm::StringLiteral Cases[] = { + llvm::StringRef Cases[] = { R"cpp( template struct Foo {}; auto a = [x(3)](Foo<^>){}; diff --git a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp index 7a47d6ebebf3b..cc5ce8354c8e7 100644 --- a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp +++ b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp @@ -2101,7 +2101,7 @@ TEST(DiagnosticsTest, IncludeCleaner) { } TEST(DiagnosticsTest, FixItFromHeader) { - llvm::StringLiteral Header(R"cpp( + llvm::StringRef Header(R"cpp( void foo(int *); void foo(int *, int);)cpp"); Annotations Source(R"cpp( diff --git a/clang-tools-extra/clangd/unittests/FeatureModulesTests.cpp b/clang-tools-extra/clangd/unittests/FeatureModulesTests.cpp index 2d89c659110b9..9975ed69b1c6a 100644 --- a/clang-tools-extra/clangd/unittests/FeatureModulesTests.cpp +++ b/clang-tools-extra/clangd/unittests/FeatureModulesTests.cpp @@ -32,9 +32,7 @@ TEST(FeatureModulesTest, ContributesTweak) { return error("not implemented"); } std::string title() const override { return id(); } - llvm::StringLiteral kind() const override { - return llvm::StringLiteral(""); - }; + llvm::StringRef kind() const override { return llvm::StringRef(""); }; }; void contributeTweaks(std::vector> &Out) override { diff --git a/clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp b/clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp index 0ee748c1ed2d0..dacd6eeab1fac 100644 --- a/clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp +++ b/clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp @@ -100,7 +100,7 @@ TEST(IncludeCleaner, StdlibUnused) { } TEST(IncludeCleaner, GetUnusedHeaders) { - llvm::StringLiteral MainFile = R"cpp( + llvm::StringRef MainFile = R"cpp( #include "a.h" #include "b.h" #include "dir/c.h" diff --git a/clang-tools-extra/clangd/unittests/InsertionPointTests.cpp b/clang-tools-extra/clangd/unittests/InsertionPointTests.cpp index 3d5365a099f0a..813e656d8ccd5 100644 --- a/clang-tools-extra/clangd/unittests/InsertionPointTests.cpp +++ b/clang-tools-extra/clangd/unittests/InsertionPointTests.cpp @@ -35,7 +35,7 @@ TEST(InsertionPointTests, Generic) { )cpp"); auto StartsWith = - [&](llvm::StringLiteral S) -> std::function { + [&](llvm::StringRef S) -> std::function { return [S](const Decl *D) { if (const auto *ND = llvm::dyn_cast(D)) return llvm::StringRef(ND->getNameAsString()).starts_with(S); @@ -47,7 +47,7 @@ TEST(InsertionPointTests, Generic) { auto &NS = cast(findDecl(AST, "ns")); // Test single anchors. - auto Point = [&](llvm::StringLiteral Prefix, Anchor::Dir Direction) { + auto Point = [&](llvm::StringRef Prefix, Anchor::Dir Direction) { auto Loc = insertionPoint(NS, {Anchor{StartsWith(Prefix), Direction}}); return sourceLocToPosition(AST.getSourceManager(), Loc); }; @@ -62,7 +62,7 @@ TEST(InsertionPointTests, Generic) { EXPECT_EQ(Point("no_match", Anchor::Below), Position{}); // Test anchor chaining. - auto Chain = [&](llvm::StringLiteral P1, llvm::StringLiteral P2) { + auto Chain = [&](llvm::StringRef P1, llvm::StringRef P2) { auto Loc = insertionPoint(NS, {Anchor{StartsWith(P1), Anchor::Above}, Anchor{StartsWith(P2), Anchor::Above}}); return sourceLocToPosition(AST.getSourceManager(), Loc); diff --git a/clang-tools-extra/clangd/unittests/ParsedASTTests.cpp b/clang-tools-extra/clangd/unittests/ParsedASTTests.cpp index 6ee641caeefe3..f98d8744d9bfb 100644 --- a/clang-tools-extra/clangd/unittests/ParsedASTTests.cpp +++ b/clang-tools-extra/clangd/unittests/ParsedASTTests.cpp @@ -351,7 +351,7 @@ TEST(ParsedASTTest, CollectsMainFileMacroExpansions) { MATCHER_P(withFileName, Inc, "") { return arg.FileName == Inc; } TEST(ParsedASTTest, PatchesAdditionalIncludes) { - llvm::StringLiteral ModifiedContents = R"cpp( + llvm::StringRef ModifiedContents = R"cpp( #include "baz.h" #include "foo.h" #include "sub/aux.h" diff --git a/clang-tools-extra/clangd/unittests/PreambleTests.cpp b/clang-tools-extra/clangd/unittests/PreambleTests.cpp index 16a2f9448b1ec..d9ddd0468771a 100644 --- a/clang-tools-extra/clangd/unittests/PreambleTests.cpp +++ b/clang-tools-extra/clangd/unittests/PreambleTests.cpp @@ -154,12 +154,12 @@ TEST(PreamblePatchTest, IncludeParsing) { } TEST(PreamblePatchTest, ContainsNewIncludes) { - constexpr llvm::StringLiteral BaselineContents = R"cpp( + constexpr llvm::StringRef BaselineContents = R"cpp( #include #include // This will be removed #include )cpp"; - constexpr llvm::StringLiteral ModifiedContents = R"cpp( + constexpr llvm::StringRef ModifiedContents = R"cpp( #include #include // This has changed a line. #include // This is a duplicate. @@ -256,11 +256,11 @@ std::string getPreamblePatch(llvm::StringRef Baseline, } TEST(PreamblePatchTest, IncludesArePreserved) { - llvm::StringLiteral Baseline = R"(//error-ok + llvm::StringRef Baseline = R"(//error-ok #include #include )"; - llvm::StringLiteral Modified = R"(//error-ok + llvm::StringRef Modified = R"(//error-ok #include #include #define FOO)"; @@ -335,14 +335,14 @@ TEST(PreamblePatchTest, Define) { } TEST(PreamblePatchTest, OrderingPreserved) { - llvm::StringLiteral Baseline = "#define BAR(X) X"; + llvm::StringRef Baseline = "#define BAR(X) X"; Annotations Modified(R"cpp( #define BAR(X, Y) X Y #define BAR(X) X [[BAR]](int y); )cpp"); - llvm::StringLiteral ExpectedPatch(R"cpp(#line 0 ".*main.cpp" + llvm::StringRef ExpectedPatch(R"cpp(#line 0 ".*main.cpp" #undef BAR #line 2 #define BAR\(X, Y\) X Y @@ -434,7 +434,7 @@ TEST(PreamblePatchTest, LocateMacroAtWorks) { TEST(PreamblePatchTest, LocateMacroAtDeletion) { { // We don't patch deleted define directives, make sure we don't crash. - llvm::StringLiteral Baseline = "#define FOO"; + llvm::StringRef Baseline = "#define FOO"; llvm::Annotations Modified("^FOO"); auto AST = createPatchedAST(Baseline, Modified.code()); @@ -457,7 +457,7 @@ TEST(PreamblePatchTest, LocateMacroAtDeletion) { { // Offset is valid, but underlying text is different. - llvm::StringLiteral Baseline = "#define FOO"; + llvm::StringRef Baseline = "#define FOO"; Annotations Modified(R"cpp(#define BAR ^FOO")cpp"); @@ -593,15 +593,15 @@ TEST(PreamblePatch, ModifiedBounds) { } TEST(PreamblePatch, MacroLoc) { - llvm::StringLiteral Baseline = "\n#define MACRO 12\nint num = MACRO;"; - llvm::StringLiteral Modified = " \n#define MACRO 12\nint num = MACRO;"; + llvm::StringRef Baseline = "\n#define MACRO 12\nint num = MACRO;"; + llvm::StringRef Modified = " \n#define MACRO 12\nint num = MACRO;"; auto AST = createPatchedAST(Baseline, Modified); ASSERT_TRUE(AST); } TEST(PreamblePatch, NoopWhenNotRequested) { - llvm::StringLiteral Baseline = "#define M\nint num = M;"; - llvm::StringLiteral Modified = "#define M\n#include \nint num = M;"; + llvm::StringRef Baseline = "#define M\nint num = M;"; + llvm::StringRef Modified = "#define M\n#include \nint num = M;"; auto TU = TestTU::withCode(Baseline); auto BaselinePreamble = TU.preamble(); ASSERT_TRUE(BaselinePreamble); diff --git a/clang-tools-extra/clangd/unittests/PrerequisiteModulesTest.cpp b/clang-tools-extra/clangd/unittests/PrerequisiteModulesTest.cpp index 1bb8e19cce23e..2f48bb3d14ab4 100644 --- a/clang-tools-extra/clangd/unittests/PrerequisiteModulesTest.cpp +++ b/clang-tools-extra/clangd/unittests/PrerequisiteModulesTest.cpp @@ -411,7 +411,7 @@ export module A; export void printA(); )cpp"); - llvm::StringLiteral UserContents = R"cpp( + llvm::StringRef UserContents = R"cpp( import A; void func() { print^ @@ -450,7 +450,7 @@ export module A; export void printA(int a); )cpp"); - llvm::StringLiteral UserContents = R"cpp( + llvm::StringRef UserContents = R"cpp( import A; void func() { printA(^); diff --git a/clang-tools-extra/clangd/unittests/ReplayPeambleTests.cpp b/clang-tools-extra/clangd/unittests/ReplayPeambleTests.cpp index 32942e6bbfdc8..e326c34d8ff57 100644 --- a/clang-tools-extra/clangd/unittests/ReplayPeambleTests.cpp +++ b/clang-tools-extra/clangd/unittests/ReplayPeambleTests.cpp @@ -94,7 +94,7 @@ struct ReplayPreambleCheck : public tidy::ClangTidyCheck { PP->addPPCallbacks(::std::make_unique(SM)); } }; -llvm::StringLiteral CheckName = "replay-preamble-check"; +llvm::StringRef CheckName = "replay-preamble-check"; struct ReplayPreambleModule : public tidy::ClangTidyModule { void addCheckFactories(tidy::ClangTidyCheckFactories &CheckFactories) override { diff --git a/clang-tools-extra/clangd/unittests/SelectionTests.cpp b/clang-tools-extra/clangd/unittests/SelectionTests.cpp index aaaf758e72236..3b2dbd96bb6ba 100644 --- a/clang-tools-extra/clangd/unittests/SelectionTests.cpp +++ b/clang-tools-extra/clangd/unittests/SelectionTests.cpp @@ -270,7 +270,7 @@ TEST(SelectionTest, CommonAncestor) { auto lambda = [](const char*){ return 0; }; int x = lambda([["y^"]]); )cpp", - "StringLiteral", // Not DeclRefExpr to operator()! + "StringRef", // Not DeclRefExpr to operator()! }, { R"cpp( @@ -804,7 +804,7 @@ TEST(SelectionTest, Implicit) { auto T = makeSelectionTree(Test, AST); const SelectionTree::Node *Str = T.commonAncestor(); - EXPECT_EQ("StringLiteral", nodeKind(Str)) << "Implicit selected?"; + EXPECT_EQ("StringRef", nodeKind(Str)) << "Implicit selected?"; EXPECT_EQ("ImplicitCastExpr", nodeKind(Str->Parent)); EXPECT_EQ("CXXConstructExpr", nodeKind(Str->Parent->Parent)); const SelectionTree::Node *ICE = Str->Parent->Parent->Parent; diff --git a/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp b/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp index 43f38e39c8952..9e0b4459a4a16 100644 --- a/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp +++ b/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp @@ -591,11 +591,11 @@ TEST_F(TUSchedulerTests, EvictedAST) { trace::TestTracer Tracer; TUScheduler S(CDB, Opts); - llvm::StringLiteral SourceContents = R"cpp( + llvm::StringRef SourceContents = R"cpp( int* a; double* b = a; )cpp"; - llvm::StringLiteral OtherSourceContents = R"cpp( + llvm::StringRef OtherSourceContents = R"cpp( int* a; double* b = a + 0; )cpp"; @@ -1146,8 +1146,8 @@ TEST_F(TUSchedulerTests, AsyncPreambleThread) { Notification &N; }; - static constexpr llvm::StringLiteral InputsV0 = "v0"; - static constexpr llvm::StringLiteral InputsV1 = "v1"; + static constexpr llvm::StringRef InputsV0 = "v0"; + static constexpr llvm::StringRef InputsV1 = "v1"; Notification Ready; TUScheduler S(CDB, optsForTest(), std::make_unique(InputsV1, Ready)); diff --git a/clang-tools-extra/clangd/unittests/TestTU.cpp b/clang-tools-extra/clangd/unittests/TestTU.cpp index 3f8990c86f714..f3d12664d31f1 100644 --- a/clang-tools-extra/clangd/unittests/TestTU.cpp +++ b/clang-tools-extra/clangd/unittests/TestTU.cpp @@ -137,7 +137,7 @@ ParsedAST TestTU::build() const { // error-ok is awfully primitive - using clang -verify would be nicer. // Ownership and layering makes it pretty hard. bool ErrorOk = [&, this] { - llvm::StringLiteral Marker = "error-ok"; + llvm::StringRef Marker = "error-ok"; if (llvm::StringRef(Code).contains(Marker) || llvm::StringRef(HeaderCode).contains(Marker)) return true; diff --git a/clang-tools-extra/clangd/unittests/XRefsTests.cpp b/clang-tools-extra/clangd/unittests/XRefsTests.cpp index 7d824d659ad2c..fb7edfb0ac97b 100644 --- a/clang-tools-extra/clangd/unittests/XRefsTests.cpp +++ b/clang-tools-extra/clangd/unittests/XRefsTests.cpp @@ -2194,7 +2194,7 @@ TEST(FindReferences, WithinAST) { } TEST(FindReferences, ConceptsWithinAST) { - constexpr llvm::StringLiteral Code = R"cpp( + constexpr llvm::StringRef Code = R"cpp( template concept $def[[IsSmal^l]] = sizeof(T) <= 8; @@ -2213,7 +2213,7 @@ TEST(FindReferences, ConceptsWithinAST) { } TEST(FindReferences, ConceptReq) { - constexpr llvm::StringLiteral Code = R"cpp( + constexpr llvm::StringRef Code = R"cpp( template concept $def[[IsSmal^l]] = sizeof(T) <= 8; @@ -2226,7 +2226,7 @@ TEST(FindReferences, ConceptReq) { } TEST(FindReferences, RequiresExprParameters) { - constexpr llvm::StringLiteral Code = R"cpp( + constexpr llvm::StringRef Code = R"cpp( template concept IsSmall = sizeof(T) <= 8; diff --git a/clang-tools-extra/clangd/unittests/support/MemoryTreeTests.cpp b/clang-tools-extra/clangd/unittests/support/MemoryTreeTests.cpp index 7d3d29a9e1ddf..ebd46fd1b126b 100644 --- a/clang-tools-extra/clangd/unittests/support/MemoryTreeTests.cpp +++ b/clang-tools-extra/clangd/unittests/support/MemoryTreeTests.cpp @@ -79,7 +79,7 @@ TEST(MemoryTree, DetailedNodesWithDetails) { TEST(MemoryTree, Record) { trace::TestTracer Tracer; - static constexpr llvm::StringLiteral MetricName = "memory_usage"; + static constexpr llvm::StringRef MetricName = "memory_usage"; static constexpr trace::Metric OutMetric(MetricName, trace::Metric::Value, "component_name"); auto AddNodes = [](MemoryTree Root) { diff --git a/clang-tools-extra/clangd/unittests/support/TraceTests.cpp b/clang-tools-extra/clangd/unittests/support/TraceTests.cpp index b73c7108ddde6..870189a57f434 100644 --- a/clang-tools-extra/clangd/unittests/support/TraceTests.cpp +++ b/clang-tools-extra/clangd/unittests/support/TraceTests.cpp @@ -130,8 +130,8 @@ TEST(TraceTest, SmokeTest) { TEST(MetricsTracer, LatencyTest) { trace::TestTracer Tracer; - constexpr llvm::StringLiteral MetricName = "span_latency"; - constexpr llvm::StringLiteral OpName = "op_name"; + constexpr llvm::StringRef MetricName = "span_latency"; + constexpr llvm::StringRef OpName = "op_name"; { // A span should record latencies to span_latency by default. trace::Span SpanWithLat(OpName); diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst index 0cf51e3961a05..b396bfde2c28d 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst @@ -29,7 +29,7 @@ with `-std=c++23` or later. Macros starting with ``PRI`` and ``__PRI`` from `` are expanded, escaping is handled and adjacent strings are concatenated to form -a single ``StringLiteral`` before the format string is converted. Use of +a single ``StringRef`` before the format string is converted. Use of any other macros in the format string will cause a warning message to be emitted and no conversion will be performed. The converted format string will always be a single string literal. @@ -41,7 +41,7 @@ The check doesn't do a bad job, but it's not perfect. In particular: possible. - At the point that the check runs, the AST contains a single - ``StringLiteral`` for the format string where escapes have been expanded. + ``StringRef`` for the format string where escapes have been expanded. The check tries to reconstruct escape sequences, they may not be the same as they were written (e.g. ``"\x41\x0a"`` will become ``"A\n"`` and ``"ab" "cd"`` will become ``"abcd"``.) diff --git a/clang-tools-extra/include-cleaner/lib/HTMLReport.cpp b/clang-tools-extra/include-cleaner/lib/HTMLReport.cpp index bbe8bc230c6e2..30ee1d68436ca 100644 --- a/clang-tools-extra/include-cleaner/lib/HTMLReport.cpp +++ b/clang-tools-extra/include-cleaner/lib/HTMLReport.cpp @@ -29,7 +29,7 @@ namespace clang::include_cleaner { namespace { -constexpr llvm::StringLiteral CSS = R"css( +constexpr llvm::StringRef CSS = R"css( body { margin: 0; } pre { line-height: 1.5em; counter-reset: line; margin: 0; } pre .line:not(.added) { counter-increment: line; } @@ -68,7 +68,7 @@ constexpr llvm::StringLiteral CSS = R"css( .ref:not(.missing) #hover .insert { font-style: italic; } )css"; -constexpr llvm::StringLiteral JS = R"js( +constexpr llvm::StringRef JS = R"js( // Recreate the #hover div inside whichever target .sel element was clicked. function select(event) { var target = event.target.closest('.sel'); diff --git a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp index f85dbc0e0c31f..a6d012cc3a922 100644 --- a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp +++ b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp @@ -34,7 +34,7 @@ namespace include_cleaner { namespace { namespace cl = llvm::cl; -llvm::StringRef Overview = llvm::StringLiteral(R"( +llvm::StringRef Overview = llvm::StringRef(R"( clang-include-cleaner analyzes the #include directives in source code. It suggests removing headers that the code is not using. diff --git a/clang-tools-extra/include-cleaner/unittests/LocateSymbolTest.cpp b/clang-tools-extra/include-cleaner/unittests/LocateSymbolTest.cpp index 756757cfd0f09..2ae763d6d9738 100644 --- a/clang-tools-extra/include-cleaner/unittests/LocateSymbolTest.cpp +++ b/clang-tools-extra/include-cleaner/unittests/LocateSymbolTest.cpp @@ -101,7 +101,7 @@ struct LocateExample { TEST(LocateSymbol, Decl) { // Looks for decl with name 'foo' and performs locateSymbol on it. // Expects all the locations in the case to be returned as a location. - const llvm::StringLiteral Cases[] = { + const llvm::StringRef Cases[] = { "struct ^foo; struct ^foo {};", "namespace ns { void ^foo(); void ^foo() {} }", "enum class ^foo; enum class ^foo {};", @@ -157,7 +157,7 @@ TEST(LocateSymbol, CompleteSymbolHint) { } { // Completeness is only absent in cases that matters. - const llvm::StringLiteral Cases[] = { + const llvm::StringRef Cases[] = { "struct ^foo; struct ^foo {};", "template struct ^foo; template struct ^foo {};", "template void ^foo(); template void ^foo() {};", @@ -174,7 +174,7 @@ TEST(LocateSymbol, CompleteSymbolHint) { { // All declarations should be marked as complete in cases that a definition // is not usually needed. - const llvm::StringLiteral Cases[] = { + const llvm::StringRef Cases[] = { "void foo(); void foo() {}", "extern int foo; int foo;", }; diff --git a/clang-tools-extra/include-cleaner/unittests/RecordTest.cpp b/clang-tools-extra/include-cleaner/unittests/RecordTest.cpp index b1bbb2eb82414..76b58a7452bc3 100644 --- a/clang-tools-extra/include-cleaner/unittests/RecordTest.cpp +++ b/clang-tools-extra/include-cleaner/unittests/RecordTest.cpp @@ -601,7 +601,7 @@ TEST_F(PragmaIncludeTest, AlwaysKeep) { } TEST_F(PragmaIncludeTest, ExportInUnnamedBuffer) { - llvm::StringLiteral Filename = "test.cpp"; + llvm::StringRef Filename = "test.cpp"; auto Code = R"cpp(#include "exporter.h")cpp"; Inputs.ExtraFiles["exporter.h"] = R"cpp( #pragma once diff --git a/clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp b/clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp index 278d435c01ab7..a9bce285964e4 100644 --- a/clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp +++ b/clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp @@ -40,7 +40,7 @@ runHeaderGuardCheck(StringRef Code, const Twine &Filename, static std::string runIncludeOrderCheck(StringRef Code, const Twine &Filename, std::optional ExpectedWarning, - llvm::ArrayRef Includes) { + llvm::ArrayRef Includes) { std::map PathsToContent; for (auto Include : Includes) PathsToContent.emplace(Include, ""); diff --git a/clang/docs/LibASTMatchersReference.html b/clang/docs/LibASTMatchersReference.html index 48dfd9cac0033..f8d270a67d04e 100644 --- a/clang/docs/LibASTMatchersReference.html +++ b/clang/docs/LibASTMatchersReference.html @@ -2235,7 +2235,7 @@

Node Matchers

-Matcher<Stmt>stringLiteralMatcher<StringLiteral>... +Matcher<Stmt>stringLiteralMatcher<StringRef>...
Matches string literals (also matches wide string literals).
 
 Example matches "abcd", L"abcd"
@@ -5647,7 +5647,7 @@ 

Narrowing Matchers

-Matcher<StringLiteral>hasSizeunsigned N +Matcher<StringRef>hasSizeunsigned N
Matches nodes that have the specified size.
 
 Given
diff --git a/clang/examples/Attribute/Attribute.cpp b/clang/examples/Attribute/Attribute.cpp
index 3b90724ad2220..f315c1260bc03 100644
--- a/clang/examples/Attribute/Attribute.cpp
+++ b/clang/examples/Attribute/Attribute.cpp
@@ -72,8 +72,7 @@ struct ExampleAttrInfo : public ParsedAttrInfo {
     // If there are arguments, the first argument should be a string literal.
     if (Attr.getNumArgs() > 0) {
       auto *Arg0 = Attr.getArgAsExpr(0);
-      StringLiteral *Literal =
-          dyn_cast(Arg0->IgnoreParenCasts());
+      StringRef *Literal = dyn_cast(Arg0->IgnoreParenCasts());
       if (!Literal) {
         unsigned ID = S.getDiagnostics().getCustomDiagID(
             DiagnosticsEngine::Error, "first argument to the 'example' "
@@ -121,8 +120,7 @@ struct ExampleAttrInfo : public ParsedAttrInfo {
     // If there are arguments, the first argument should be a string literal.
     if (Attr.getNumArgs() > 0) {
       auto *Arg0 = Attr.getArgAsExpr(0);
-      StringLiteral *Literal =
-          dyn_cast(Arg0->IgnoreParenCasts());
+      StringRef *Literal = dyn_cast(Arg0->IgnoreParenCasts());
       if (!Literal) {
         unsigned ID = S.getDiagnostics().getCustomDiagID(
             DiagnosticsEngine::Error, "first argument to the 'example' "
diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h
index 1e89a6805ce9c..1d0a51667b2b9 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -323,11 +323,11 @@ class ASTContext : public RefCountedBase {
   /// Mapping from APValues to the corresponding TemplateParamObjects.
   mutable llvm::FoldingSet TemplateParamObjectDecls;
 
-  /// A cache mapping a string value to a StringLiteral object with the same
+  /// A cache mapping a string value to a StringRef object with the same
   /// value.
   ///
   /// This is lazily created.  This is intentionally not serialized.
-  mutable llvm::StringMap StringLiteralCache;
+  mutable llvm::StringMap StringLiteralCache;
 
   /// The next string literal "version" to allocate during constant evaluation.
   /// This is used to distinguish between repeated evaluations of the same
@@ -3323,7 +3323,7 @@ class ASTContext : public RefCountedBase {
   /// Return a string representing the human readable name for the specified
   /// function declaration or file name. Used by SourceLocExpr and
   /// PredefinedExpr to cache evaluated results.
-  StringLiteral *getPredefinedStringLiteralFromCache(StringRef Key) const;
+  StringRef *getPredefinedStringLiteralFromCache(StringRef Key) const;
 
   /// Return the next version number to be used for a string literal evaluated
   /// as part of constant evaluation.
diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index 16fc98aa1a57f..633a0aab81560 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -68,7 +68,7 @@ class NamespaceDecl;
 class ParmVarDecl;
 class RecordDecl;
 class Stmt;
-class StringLiteral;
+class StringRef;
 class TagDecl;
 class TemplateArgumentList;
 class TemplateArgumentListInfo;
@@ -1960,7 +1960,7 @@ class FunctionDecl : public DeclaratorDecl,
   /// Stashed information about a defaulted/deleted function body.
   class DefaultedOrDeletedFunctionInfo final
       : llvm::TrailingObjects {
+                              StringRef *> {
     friend TrailingObjects;
     unsigned NumLookups;
     bool HasDeletedMessage;
@@ -1972,7 +1972,7 @@ class FunctionDecl : public DeclaratorDecl,
   public:
     static DefaultedOrDeletedFunctionInfo *
     Create(ASTContext &Context, ArrayRef Lookups,
-           StringLiteral *DeletedMessage = nullptr);
+           StringRef *DeletedMessage = nullptr);
 
     /// Get the unqualified lookup results that should be used in this
     /// defaulted function definition.
@@ -1980,12 +1980,11 @@ class FunctionDecl : public DeclaratorDecl,
       return {getTrailingObjects(), NumLookups};
     }
 
-    StringLiteral *getDeletedMessage() const {
-      return HasDeletedMessage ? *getTrailingObjects()
-                               : nullptr;
+    StringRef *getDeletedMessage() const {
+      return HasDeletedMessage ? *getTrailingObjects() : nullptr;
     }
 
-    void setDeletedMessage(StringLiteral *Message);
+    void setDeletedMessage(StringRef *Message);
   };
 
 private:
@@ -2473,7 +2472,7 @@ class FunctionDecl : public DeclaratorDecl,
     return FunctionDeclBits.IsDeleted && !isDefaulted();
   }
 
-  void setDeletedAsWritten(bool D = true, StringLiteral *Message = nullptr);
+  void setDeletedAsWritten(bool D = true, StringRef *Message = nullptr);
 
   /// Determines whether this function is "main", which is the
   /// entry point into an executable program.
@@ -2630,7 +2629,7 @@ class FunctionDecl : public DeclaratorDecl,
   }
 
   /// Get the message that indicates why this function was deleted.
-  StringLiteral *getDeletedMessage() const {
+  StringRef *getDeletedMessage() const {
     return FunctionDeclBits.HasDefaultedOrDeletedInfo
                ? DefaultedOrDeletedInfo->getDeletedMessage()
                : nullptr;
@@ -4410,18 +4409,18 @@ class RecordDecl : public TagDecl {
 };
 
 class FileScopeAsmDecl : public Decl {
-  StringLiteral *AsmString;
+  StringRef *AsmString;
   SourceLocation RParenLoc;
 
-  FileScopeAsmDecl(DeclContext *DC, StringLiteral *asmstring,
-                   SourceLocation StartL, SourceLocation EndL)
-    : Decl(FileScopeAsm, DC, StartL), AsmString(asmstring), RParenLoc(EndL) {}
+  FileScopeAsmDecl(DeclContext *DC, StringRef *asmstring, SourceLocation StartL,
+                   SourceLocation EndL)
+      : Decl(FileScopeAsm, DC, StartL), AsmString(asmstring), RParenLoc(EndL) {}
 
   virtual void anchor();
 
 public:
   static FileScopeAsmDecl *Create(ASTContext &C, DeclContext *DC,
-                                  StringLiteral *Str, SourceLocation AsmLoc,
+                                  StringRef *Str, SourceLocation AsmLoc,
                                   SourceLocation RParenLoc);
 
   static FileScopeAsmDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID);
@@ -4433,9 +4432,9 @@ class FileScopeAsmDecl : public Decl {
     return SourceRange(getAsmLoc(), getRParenLoc());
   }
 
-  const StringLiteral *getAsmString() const { return AsmString; }
-  StringLiteral *getAsmString() { return AsmString; }
-  void setAsmString(StringLiteral *Asm) { AsmString = Asm; }
+  const StringRef *getAsmString() const { return AsmString; }
+  StringRef *getAsmString() { return AsmString; }
+  void setAsmString(StringRef *Asm) { AsmString = Asm; }
 
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
   static bool classofKind(Kind K) { return K == FileScopeAsm; }
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 708c8656decbe..c4e8fadf25e3c 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -54,7 +54,7 @@ namespace clang {
   class ObjCPropertyRefExpr;
   class OpaqueValueExpr;
   class ParmVarDecl;
-  class StringLiteral;
+  class StringRef;
   class TargetInfo;
   class ValueDecl;
 
@@ -1755,7 +1755,7 @@ enum class StringLiteralKind {
   Unevaluated
 };
 
-/// StringLiteral - This represents a string literal expression, e.g. "foo"
+/// StringRef - This represents a string literal expression, e.g. "foo"
 /// or L"bar" (wide strings). The actual string data can be obtained with
 /// getBytes() and is NOT null-terminated. The length of the string data is
 /// determined by calling getByteLength().
@@ -1772,21 +1772,20 @@ enum class StringLiteralKind {
 ///   char X[2] = "foobar";
 /// In this case, getByteLength() will return 6, but the string literal will
 /// have type "char[2]".
-class StringLiteral final
+class StringRef final
     : public Expr,
-      private llvm::TrailingObjects {
+      private llvm::TrailingObjects {
   friend class ASTStmtReader;
   friend TrailingObjects;
 
-  /// StringLiteral is followed by several trailing objects. They are in order:
+  /// StringRef is followed by several trailing objects. They are in order:
   ///
   /// * A single unsigned storing the length in characters of this string. The
   ///   length in bytes is this length times the width of a single character.
   ///   Always present and stored as a trailing objects because storing it in
-  ///   StringLiteral would increase the size of StringLiteral by sizeof(void *)
-  ///   due to alignment requirements. If you add some data to StringLiteral,
-  ///   consider moving it inside StringLiteral.
+  ///   StringRef would increase the size of StringRef by sizeof(void *)
+  ///   due to alignment requirements. If you add some data to StringRef,
+  ///   consider moving it inside StringRef.
   ///
   /// * An array of getNumConcatenated() SourceLocation, one for each of the
   ///   token this string is made of.
@@ -1814,13 +1813,13 @@ class StringLiteral final
   }
 
   /// Build a string literal.
-  StringLiteral(const ASTContext &Ctx, StringRef Str, StringLiteralKind Kind,
-                bool Pascal, QualType Ty, const SourceLocation *Loc,
-                unsigned NumConcatenated);
+  StringRef(const ASTContext &Ctx, StringRef Str, StringLiteralKind Kind,
+            bool Pascal, QualType Ty, const SourceLocation *Loc,
+            unsigned NumConcatenated);
 
   /// Build an empty string literal.
-  StringLiteral(EmptyShell Empty, unsigned NumConcatenated, unsigned Length,
-                unsigned CharByteWidth);
+  StringRef(EmptyShell Empty, unsigned NumConcatenated, unsigned Length,
+            unsigned CharByteWidth);
 
   /// Map a target and string kind to the appropriate character width.
   static unsigned mapCharByteWidth(TargetInfo const &Target,
@@ -1835,22 +1834,20 @@ class StringLiteral final
 public:
   /// This is the "fully general" constructor that allows representation of
   /// strings formed from multiple concatenated tokens.
-  static StringLiteral *Create(const ASTContext &Ctx, StringRef Str,
-                               StringLiteralKind Kind, bool Pascal, QualType Ty,
-                               const SourceLocation *Loc,
-                               unsigned NumConcatenated);
+  static StringRef *Create(const ASTContext &Ctx, StringRef Str,
+                           StringLiteralKind Kind, bool Pascal, QualType Ty,
+                           const SourceLocation *Loc, unsigned NumConcatenated);
 
   /// Simple constructor for string literals made from one token.
-  static StringLiteral *Create(const ASTContext &Ctx, StringRef Str,
-                               StringLiteralKind Kind, bool Pascal, QualType Ty,
-                               SourceLocation Loc) {
+  static StringRef *Create(const ASTContext &Ctx, StringRef Str,
+                           StringLiteralKind Kind, bool Pascal, QualType Ty,
+                           SourceLocation Loc) {
     return Create(Ctx, Str, Kind, Pascal, Ty, &Loc, 1);
   }
 
   /// Construct an empty string literal.
-  static StringLiteral *CreateEmpty(const ASTContext &Ctx,
-                                    unsigned NumConcatenated, unsigned Length,
-                                    unsigned CharByteWidth);
+  static StringRef *CreateEmpty(const ASTContext &Ctx, unsigned NumConcatenated,
+                                unsigned Length, unsigned CharByteWidth);
 
   StringRef getString() const {
     assert((isUnevaluated() || getCharByteWidth() == 1) &&
@@ -1994,17 +1991,17 @@ class PredefinedExpr final
 
   // PredefinedExpr is optionally followed by a single trailing
   // "Stmt *" for the predefined identifier. It is present if and only if
-  // hasFunctionName() is true and is always a "StringLiteral *".
+  // hasFunctionName() is true and is always a "StringRef *".
 
   PredefinedExpr(SourceLocation L, QualType FNTy, PredefinedIdentKind IK,
-                 bool IsTransparent, StringLiteral *SL);
+                 bool IsTransparent, StringRef *SL);
 
   explicit PredefinedExpr(EmptyShell Empty, bool HasFunctionName);
 
   /// True if this PredefinedExpr has storage for a function name.
   bool hasFunctionName() const { return PredefinedExprBits.HasFunctionName; }
 
-  void setFunctionName(StringLiteral *SL) {
+  void setFunctionName(StringRef *SL) {
     assert(hasFunctionName() &&
            "This PredefinedExpr has no storage for a function name!");
     *getTrailingObjects() = SL;
@@ -2014,10 +2011,10 @@ class PredefinedExpr final
   /// Create a PredefinedExpr.
   ///
   /// If IsTransparent, the PredefinedExpr is transparently handled as a
-  /// StringLiteral.
+  /// StringRef.
   static PredefinedExpr *Create(const ASTContext &Ctx, SourceLocation L,
                                 QualType FNTy, PredefinedIdentKind IK,
-                                bool IsTransparent, StringLiteral *SL);
+                                bool IsTransparent, StringRef *SL);
 
   /// Create an empty PredefinedExpr.
   static PredefinedExpr *CreateEmpty(const ASTContext &Ctx,
@@ -2032,15 +2029,15 @@ class PredefinedExpr final
   SourceLocation getLocation() const { return PredefinedExprBits.Loc; }
   void setLocation(SourceLocation L) { PredefinedExprBits.Loc = L; }
 
-  StringLiteral *getFunctionName() {
+  StringRef *getFunctionName() {
     return hasFunctionName()
-               ? static_cast(*getTrailingObjects())
+               ? static_cast(*getTrailingObjects())
                : nullptr;
   }
 
-  const StringLiteral *getFunctionName() const {
+  const StringRef *getFunctionName() const {
     return hasFunctionName()
-               ? static_cast(*getTrailingObjects())
+               ? static_cast(*getTrailingObjects())
                : nullptr;
   }
 
@@ -4884,7 +4881,7 @@ class SourceLocExpr final : public Expr {
 
 /// Stores data related to a single #embed directive.
 struct EmbedDataStorage {
-  StringLiteral *BinaryData;
+  StringRef *BinaryData;
   size_t getDataElementCount() const { return BinaryData->getByteLength(); }
 };
 
@@ -4930,7 +4927,7 @@ class EmbedExpr final : public Expr {
   SourceLocation getBeginLoc() const { return EmbedKeywordLoc; }
   SourceLocation getEndLoc() const { return EmbedKeywordLoc; }
 
-  StringLiteral *getDataStringLiteral() const { return Data->BinaryData; }
+  StringRef *getDataStringLiteral() const { return Data->BinaryData; }
   EmbedDataStorage *getData() const { return Data; }
 
   unsigned getStartingElementPos() const { return Begin; }
diff --git a/clang/include/clang/AST/ExprObjC.h b/clang/include/clang/AST/ExprObjC.h
index 1fccc26069582..3e0298ab4c927 100644
--- a/clang/include/clang/AST/ExprObjC.h
+++ b/clang/include/clang/AST/ExprObjC.h
@@ -53,7 +53,7 @@ class ObjCStringLiteral : public Expr {
   SourceLocation AtLoc;
 
 public:
-  ObjCStringLiteral(StringLiteral *SL, QualType T, SourceLocation L)
+  ObjCStringLiteral(StringRef *SL, QualType T, SourceLocation L)
       : Expr(ObjCStringLiteralClass, T, VK_PRValue, OK_Ordinary), String(SL),
         AtLoc(L) {
     setDependence(ExprDependence::None);
@@ -61,9 +61,9 @@ class ObjCStringLiteral : public Expr {
   explicit ObjCStringLiteral(EmptyShell Empty)
       : Expr(ObjCStringLiteralClass, Empty) {}
 
-  StringLiteral *getString() { return cast(String); }
-  const StringLiteral *getString() const { return cast(String); }
-  void setString(StringLiteral *S) { String = S; }
+  StringRef *getString() { return cast(String); }
+  const StringRef *getString() const { return cast(String); }
+  void setString(StringRef *S) { String = S; }
 
   SourceLocation getAtLoc() const { return AtLoc; }
   void setAtLoc(SourceLocation L) { AtLoc = L; }
@@ -405,7 +405,7 @@ class ObjCDictionaryLiteral final
 };
 
 /// ObjCEncodeExpr, used for \@encode in Objective-C.  \@encode has the same
-/// type and behavior as StringLiteral except that the string initializer is
+/// type and behavior as StringRef except that the string initializer is
 /// obtained from ASTContext with the encoding type as an argument.
 class ObjCEncodeExpr : public Expr {
   TypeSourceInfo *EncodedType;
diff --git a/clang/include/clang/AST/JSONNodeDumper.h b/clang/include/clang/AST/JSONNodeDumper.h
index 9422c8fceccfb..7efb1e38044f9 100644
--- a/clang/include/clang/AST/JSONNodeDumper.h
+++ b/clang/include/clang/AST/JSONNodeDumper.h
@@ -328,7 +328,7 @@ class JSONNodeDumper
   void VisitCharacterLiteral(const CharacterLiteral *CL);
   void VisitFixedPointLiteral(const FixedPointLiteral *FPL);
   void VisitFloatingLiteral(const FloatingLiteral *FL);
-  void VisitStringLiteral(const StringLiteral *SL);
+  void VisitStringLiteral(const StringRef *SL);
   void VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *BLE);
 
   void VisitIfStmt(const IfStmt *IS);
diff --git a/clang/include/clang/AST/Mangle.h b/clang/include/clang/AST/Mangle.h
index d5f6c0f6cc67d..335650251d66d 100644
--- a/clang/include/clang/AST/Mangle.h
+++ b/clang/include/clang/AST/Mangle.h
@@ -35,7 +35,7 @@ namespace clang {
   struct MethodVFTableLocation;
   class NamedDecl;
   class ObjCMethodDecl;
-  class StringLiteral;
+  class StringRef;
   struct ThisAdjustment;
   struct ThunkInfo;
   class VarDecl;
@@ -119,7 +119,7 @@ class MangleContext {
 
   bool shouldMangleDeclName(const NamedDecl *D);
   virtual bool shouldMangleCXXName(const NamedDecl *D) = 0;
-  virtual bool shouldMangleStringLiteral(const StringLiteral *SL) = 0;
+  virtual bool shouldMangleStringLiteral(const StringRef *SL) = 0;
 
   virtual bool isUniqueInternalLinkageDecl(const NamedDecl *ND) {
     return false;
@@ -142,7 +142,7 @@ class MangleContext {
   virtual void mangleCXXRTTI(QualType T, raw_ostream &) = 0;
   virtual void mangleCXXRTTIName(QualType T, raw_ostream &,
                                  bool NormalizeIntegers = false) = 0;
-  virtual void mangleStringLiteral(const StringLiteral *SL, raw_ostream &) = 0;
+  virtual void mangleStringLiteral(const StringRef *SL, raw_ostream &) = 0;
   virtual void mangleMSGuidDecl(const MSGuidDecl *GD, raw_ostream&);
 
   void mangleGlobalBlock(const BlockDecl *BD,
diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h b/clang/include/clang/AST/RecursiveASTVisitor.h
index d500f4eadef75..c1d8ca0b84662 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -2996,7 +2996,7 @@ DEF_TRAVERSE_STMT(FixedPointLiteral, {})
 DEF_TRAVERSE_STMT(CharacterLiteral, {})
 DEF_TRAVERSE_STMT(FloatingLiteral, {})
 DEF_TRAVERSE_STMT(ImaginaryLiteral, {})
-DEF_TRAVERSE_STMT(StringLiteral, {})
+DEF_TRAVERSE_STMT(StringRef, {})
 DEF_TRAVERSE_STMT(ObjCStringLiteral, {})
 DEF_TRAVERSE_STMT(ObjCBoxedExpr, {})
 DEF_TRAVERSE_STMT(ObjCArrayLiteral, {})
diff --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h
index 405c6166adb15..a71f81c568628 100644
--- a/clang/include/clang/AST/Stmt.h
+++ b/clang/include/clang/AST/Stmt.h
@@ -64,7 +64,7 @@ class PrinterHelper;
 struct PrintingPolicy;
 class RecordDecl;
 class SourceManager;
-class StringLiteral;
+class StringRef;
 class Token;
 class VarDecl;
 enum class CharacterLiteralKind;
@@ -411,12 +411,12 @@ class alignas(void *) Stmt {
     LLVM_PREFERRED_TYPE(PredefinedIdentKind)
     unsigned Kind : 4;
 
-    /// True if this PredefinedExpr has a trailing "StringLiteral *"
+    /// True if this PredefinedExpr has a trailing "StringRef *"
     /// for the predefined identifier.
     LLVM_PREFERRED_TYPE(bool)
     unsigned HasFunctionName : 1;
 
-    /// True if this PredefinedExpr should be treated as a StringLiteral (for
+    /// True if this PredefinedExpr should be treated as a StringRef (for
     /// MSVC compatibility).
     LLVM_PREFERRED_TYPE(bool)
     unsigned IsTransparent : 1;
@@ -471,18 +471,18 @@ class alignas(void *) Stmt {
 
   class StringLiteralBitfields {
     friend class ASTStmtReader;
-    friend class StringLiteral;
+    friend class StringRef;
 
     LLVM_PREFERRED_TYPE(ExprBitfields)
     unsigned : NumExprBits;
 
     /// The kind of this string literal.
-    /// One of the enumeration values of StringLiteral::StringKind.
+    /// One of the enumeration values of StringRef::StringKind.
     LLVM_PREFERRED_TYPE(StringLiteralKind)
     unsigned Kind : 3;
 
     /// The width of a single character in bytes. Only values of 1, 2,
-    /// and 4 bytes are supported. StringLiteral::mapCharByteWidth maps
+    /// and 4 bytes are supported. StringRef::mapCharByteWidth maps
     /// the target + string kind to the appropriate CharByteWidth.
     unsigned CharByteWidth : 3;
 
@@ -3287,21 +3287,20 @@ class GCCAsmStmt : public AsmStmt {
   friend class ASTStmtReader;
 
   SourceLocation RParenLoc;
-  StringLiteral *AsmStr;
+  StringRef *AsmStr;
 
   // FIXME: If we wanted to, we could allocate all of these in one big array.
-  StringLiteral **Constraints = nullptr;
-  StringLiteral **Clobbers = nullptr;
+  StringRef **Constraints = nullptr;
+  StringRef **Clobbers = nullptr;
   IdentifierInfo **Names = nullptr;
   unsigned NumLabels = 0;
 
 public:
   GCCAsmStmt(const ASTContext &C, SourceLocation asmloc, bool issimple,
              bool isvolatile, unsigned numoutputs, unsigned numinputs,
-             IdentifierInfo **names, StringLiteral **constraints, Expr **exprs,
-             StringLiteral *asmstr, unsigned numclobbers,
-             StringLiteral **clobbers, unsigned numlabels,
-             SourceLocation rparenloc);
+             IdentifierInfo **names, StringRef **constraints, Expr **exprs,
+             StringRef *asmstr, unsigned numclobbers, StringRef **clobbers,
+             unsigned numlabels, SourceLocation rparenloc);
 
   /// Build an empty inline-assembly statement.
   explicit GCCAsmStmt(EmptyShell Empty) : AsmStmt(GCCAsmStmtClass, Empty) {}
@@ -3311,9 +3310,9 @@ class GCCAsmStmt : public AsmStmt {
 
   //===--- Asm String Analysis ---===//
 
-  const StringLiteral *getAsmString() const { return AsmStr; }
-  StringLiteral *getAsmString() { return AsmStr; }
-  void setAsmString(StringLiteral *E) { AsmStr = E; }
+  const StringRef *getAsmString() const { return AsmStr; }
+  StringRef *getAsmString() { return AsmStr; }
+  void setAsmString(StringRef *E) { AsmStr = E; }
 
   /// AsmStringPiece - this is part of a decomposed asm string specification
   /// (for use with the AnalyzeAsmString function below).  An asm string is
@@ -3384,12 +3383,10 @@ class GCCAsmStmt : public AsmStmt {
 
   StringRef getOutputConstraint(unsigned i) const;
 
-  const StringLiteral *getOutputConstraintLiteral(unsigned i) const {
-    return Constraints[i];
-  }
-  StringLiteral *getOutputConstraintLiteral(unsigned i) {
+  const StringRef *getOutputConstraintLiteral(unsigned i) const {
     return Constraints[i];
   }
+  StringRef *getOutputConstraintLiteral(unsigned i) { return Constraints[i]; }
 
   Expr *getOutputExpr(unsigned i);
 
@@ -3412,10 +3409,10 @@ class GCCAsmStmt : public AsmStmt {
 
   StringRef getInputConstraint(unsigned i) const;
 
-  const StringLiteral *getInputConstraintLiteral(unsigned i) const {
+  const StringRef *getInputConstraintLiteral(unsigned i) const {
     return Constraints[i + NumOutputs];
   }
-  StringLiteral *getInputConstraintLiteral(unsigned i) {
+  StringRef *getInputConstraintLiteral(unsigned i) {
     return Constraints[i + NumOutputs];
   }
 
@@ -3474,12 +3471,9 @@ class GCCAsmStmt : public AsmStmt {
 private:
   void setOutputsAndInputsAndClobbers(const ASTContext &C,
                                       IdentifierInfo **Names,
-                                      StringLiteral **Constraints,
-                                      Stmt **Exprs,
-                                      unsigned NumOutputs,
-                                      unsigned NumInputs,
-                                      unsigned NumLabels,
-                                      StringLiteral **Clobbers,
+                                      StringRef **Constraints, Stmt **Exprs,
+                                      unsigned NumOutputs, unsigned NumInputs,
+                                      unsigned NumLabels, StringRef **Clobbers,
                                       unsigned NumClobbers);
 
 public:
@@ -3492,8 +3486,8 @@ class GCCAsmStmt : public AsmStmt {
 
   StringRef getClobber(unsigned i) const;
 
-  StringLiteral *getClobberStringLiteral(unsigned i) { return Clobbers[i]; }
-  const StringLiteral *getClobberStringLiteral(unsigned i) const {
+  StringRef *getClobberStringLiteral(unsigned i) { return Clobbers[i]; }
+  const StringRef *getClobberStringLiteral(unsigned i) const {
     return Clobbers[i];
   }
 
diff --git a/clang/include/clang/AST/StmtDataCollectors.td b/clang/include/clang/AST/StmtDataCollectors.td
index abf4b5f34d349..1cb4d8c538160 100644
--- a/clang/include/clang/AST/StmtDataCollectors.td
+++ b/clang/include/clang/AST/StmtDataCollectors.td
@@ -86,7 +86,7 @@ class FloatingLiteral {
     addData(llvm::hash_value(S->getValue()));
   }];
 }
-class StringLiteral {
+class StringRef {
   code Code = [{
     addData(S->getString());
 }];
diff --git a/clang/include/clang/AST/TextNodeDumper.h b/clang/include/clang/AST/TextNodeDumper.h
index 4aaae48ba8b42..093bb448bbacb 100644
--- a/clang/include/clang/AST/TextNodeDumper.h
+++ b/clang/include/clang/AST/TextNodeDumper.h
@@ -277,7 +277,7 @@ class TextNodeDumper
   void VisitIntegerLiteral(const IntegerLiteral *Node);
   void VisitFixedPointLiteral(const FixedPointLiteral *Node);
   void VisitFloatingLiteral(const FloatingLiteral *Node);
-  void VisitStringLiteral(const StringLiteral *Str);
+  void VisitStringLiteral(const StringRef *Str);
   void VisitInitListExpr(const InitListExpr *ILE);
   void VisitGenericSelectionExpr(const GenericSelectionExpr *E);
   void VisitUnaryOperator(const UnaryOperator *Node);
diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h
index f32170c93bee2..5229947885b58 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -2452,7 +2452,7 @@ extern const internal::VariadicDynCastAllOfMatcher
 ///   char *s = "abcd";
 ///   wchar_t *ws = L"abcd";
 /// \endcode
-extern const internal::VariadicDynCastAllOfMatcher
+extern const internal::VariadicDynCastAllOfMatcher
     stringLiteral;
 
 /// Matches character literals (also matches wchar_t).
@@ -7156,7 +7156,7 @@ extern const AstTypeMatcher constantArrayType;
 ///   matches "abcd", L"abcd"
 AST_POLYMORPHIC_MATCHER_P(hasSize,
                           AST_POLYMORPHIC_SUPPORTED_TYPES(ConstantArrayType,
-                                                          StringLiteral),
+                                                          StringRef),
                           unsigned, N) {
   return internal::HasSizeMatcher::hasSize(Node, N);
 }
diff --git a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
index 1f7b5e7cac846..5b125c934f128 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -2185,8 +2185,8 @@ struct HasSizeMatcher {
 };
 
 template <>
-inline bool HasSizeMatcher::hasSize(
-    const StringLiteral &Node, unsigned int N) {
+inline bool HasSizeMatcher::hasSize(const StringRef &Node,
+                                               unsigned int N) {
   return Node.getLength() == N;
 }
 
diff --git a/clang/include/clang/ASTMatchers/Dynamic/Parser.h b/clang/include/clang/ASTMatchers/Dynamic/Parser.h
index 7adaef5054b5d..14811021188dd 100644
--- a/clang/include/clang/ASTMatchers/Dynamic/Parser.h
+++ b/clang/include/clang/ASTMatchers/Dynamic/Parser.h
@@ -18,14 +18,14 @@
 /// \code
 /// Grammar for the expressions supported:
 ///         :=  |  | 
-///            :=  |  |  | 
-///      := "quoted string"
+///            :=  |  |  | 
+///      := "quoted string"
 ///            := true | false
 ///             := [0-9]+.[0-9]* | [0-9]+.[0-9]*[eE][-+]?[0-9]+
 ///           := [0-9]+
 ///         := 
 ///  := () |
-///                        ().bind()
+///                        ().bind()
 ///         := [a-zA-Z]+
 ///       :=  | ,
 /// \endcode
diff --git a/clang/include/clang/Basic/Builtins.h b/clang/include/clang/Basic/Builtins.h
index 63559d977ce6b..925e1a8ad1147 100644
--- a/clang/include/clang/Basic/Builtins.h
+++ b/clang/include/clang/Basic/Builtins.h
@@ -69,7 +69,7 @@ enum ID {
 };
 
 struct Info {
-  llvm::StringLiteral Name;
+  llvm::StringRef Name;
   const char *Type, *Attributes;
   const char *Features;
   HeaderDesc Header;
diff --git a/clang/include/clang/Basic/StmtNodes.td b/clang/include/clang/Basic/StmtNodes.td
index ce2c48bd3c84e..d98a14e5a2a71 100644
--- a/clang/include/clang/Basic/StmtNodes.td
+++ b/clang/include/clang/Basic/StmtNodes.td
@@ -63,7 +63,7 @@ def IntegerLiteral : StmtNode;
 def FixedPointLiteral : StmtNode;
 def FloatingLiteral : StmtNode;
 def ImaginaryLiteral : StmtNode;
-def StringLiteral : StmtNode;
+def StringRef : StmtNode;
 def CharacterLiteral : StmtNode;
 def ParenExpr : StmtNode;
 def UnaryOperator : StmtNode;
diff --git a/clang/include/clang/ExtractAPI/DeclarationFragments.h b/clang/include/clang/ExtractAPI/DeclarationFragments.h
index 4ac744459031e..1b62cc07abc4e 100644
--- a/clang/include/clang/ExtractAPI/DeclarationFragments.h
+++ b/clang/include/clang/ExtractAPI/DeclarationFragments.h
@@ -57,7 +57,7 @@ class DeclarationFragments {
     Keyword,
     Attribute,
     NumberLiteral,
-    StringLiteral,
+    StringRef,
     Identifier,
 
     /// Identifier that refers to a type in the context.
diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h
index e99d2cf2eaa40..57a7f77fdf5c0 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -1647,7 +1647,7 @@ class Parser : public CodeCompletionHandler {
                                      const ParsedTemplateInfo &TemplateInfo,
                                      const VirtSpecifiers &VS,
                                      SourceLocation PureSpecLoc);
-  StringLiteral *ParseCXXDeletedFunctionMessage();
+  StringRef *ParseCXXDeletedFunctionMessage();
   void SkipDeletedFunctionBody();
   void ParseCXXNonStaticMemberInitializer(Decl *VarD);
   void ParseLexedAttributes(ParsingClass &Class);
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index a41f16f6dc8c9..8ae01804e2ecc 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -1652,10 +1652,10 @@ class Sema final : public SemaBase {
   };
   SmallVector AlignPackIncludeStack;
   // Segment #pragmas.
-  PragmaStack DataSegStack;
-  PragmaStack BSSSegStack;
-  PragmaStack ConstSegStack;
-  PragmaStack CodeSegStack;
+  PragmaStack DataSegStack;
+  PragmaStack BSSSegStack;
+  PragmaStack ConstSegStack;
+  PragmaStack CodeSegStack;
 
   // #pragma strict_gs_check.
   PragmaStack StrictGuardStackCheckStack;
@@ -1693,7 +1693,7 @@ class Sema final : public SemaBase {
   };
 
   /// Last section used with #pragma init_seg.
-  StringLiteral *CurInitSeg;
+  StringRef *CurInitSeg;
   SourceLocation CurInitSegLoc;
 
   /// Sections used with #pragma alloc_text.
@@ -1866,16 +1866,16 @@ class Sema final : public SemaBase {
   /// Called on well formed \#pragma bss_seg/data_seg/const_seg/code_seg.
   void ActOnPragmaMSSeg(SourceLocation PragmaLocation,
                         PragmaMsStackAction Action,
-                        llvm::StringRef StackSlotLabel,
-                        StringLiteral *SegmentName, llvm::StringRef PragmaName);
+                        llvm::StringRef StackSlotLabel, StringRef *SegmentName,
+                        llvm::StringRef PragmaName);
 
   /// Called on well formed \#pragma section().
   void ActOnPragmaMSSection(SourceLocation PragmaLocation, int SectionFlags,
-                            StringLiteral *SegmentName);
+                            StringRef *SegmentName);
 
   /// Called on well-formed \#pragma init_seg().
   void ActOnPragmaMSInitSeg(SourceLocation PragmaLocation,
-                            StringLiteral *SegmentName);
+                            StringRef *SegmentName);
 
   /// Called on well-formed \#pragma alloc_text().
   void ActOnPragmaMSAllocText(
@@ -2153,7 +2153,7 @@ class Sema final : public SemaBase {
            isConstantEvaluatedOverride;
   }
 
-  SourceLocation getLocationOfStringLiteralByte(const StringLiteral *SL,
+  SourceLocation getLocationOfStringLiteralByte(const StringRef *SL,
                                                 unsigned ByteNo) const;
 
   enum FormatArgumentPassingKind {
@@ -2200,7 +2200,7 @@ class Sema final : public SemaBase {
   };
   static FormatStringType GetFormatStringType(const FormatAttr *Format);
 
-  bool FormatStringHasSArg(const StringLiteral *FExpr);
+  bool FormatStringHasSArg(const StringRef *FExpr);
 
   /// Check for comparisons of floating-point values using == and !=. Issue a
   /// warning if the comparison is not likely to do what the programmer
@@ -4542,7 +4542,7 @@ class Sema final : public SemaBase {
   /// Check Target Version attrs
   bool checkTargetVersionAttr(SourceLocation Loc, Decl *D, StringRef Str);
   bool checkTargetClonesAttrString(
-      SourceLocation LiteralLoc, StringRef Str, const StringLiteral *Literal,
+      SourceLocation LiteralLoc, StringRef Str, const StringRef *Literal,
       Decl *D, bool &HasDefault, bool &HasCommas, bool &HasNotDefault,
       SmallVectorImpl> &StringsBuffer);
 
@@ -6002,11 +6002,11 @@ class Sema final : public SemaBase {
 
   void ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc);
   void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc,
-                      StringLiteral *Message = nullptr);
+                      StringRef *Message = nullptr);
   void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc);
 
   void SetFunctionBodyKind(Decl *D, SourceLocation Loc, FnBodyKind BodyKind,
-                           StringLiteral *DeletedMessage = nullptr);
+                           StringRef *DeletedMessage = nullptr);
   void ActOnStartTrailingRequiresClause(Scope *S, Declarator &D);
   ExprResult ActOnFinishTrailingRequiresClause(ExprResult ConstraintExpr);
   ExprResult ActOnRequiresClause(ExprResult ConstraintExpr);
@@ -7105,7 +7105,7 @@ class Sema final : public SemaBase {
 
   // #embed
   ExprResult ActOnEmbedExpr(SourceLocation EmbedKeywordLoc,
-                            StringLiteral *BinaryData);
+                            StringRef *BinaryData);
 
   // Build a potentially resolved SourceLocExpr.
   ExprResult BuildSourceLocExpr(SourceLocIdentKind Kind, QualType ResultTy,
@@ -9364,7 +9364,7 @@ class Sema final : public SemaBase {
   LookupLiteralOperator(Scope *S, LookupResult &R, ArrayRef ArgTys,
                         bool AllowRaw, bool AllowTemplate,
                         bool AllowStringTemplate, bool DiagnoseMissing,
-                        StringLiteral *StringLit = nullptr);
+                        StringRef *StringLit = nullptr);
 
   void ArgumentDependentLookup(DeclarationName Name, SourceLocation Loc,
                                ArrayRef Args, ADLResult &Functions);
diff --git a/clang/include/clang/Sema/SemaObjC.h b/clang/include/clang/Sema/SemaObjC.h
index 791a7f45b832f..b9e7ffab01a23 100644
--- a/clang/include/clang/Sema/SemaObjC.h
+++ b/clang/include/clang/Sema/SemaObjC.h
@@ -651,7 +651,7 @@ class SemaObjC : public SemaBase {
   ExprResult ParseObjCStringLiteral(SourceLocation *AtLocs,
                                     ArrayRef Strings);
 
-  ExprResult BuildObjCStringLiteral(SourceLocation AtLoc, StringLiteral *S);
+  ExprResult BuildObjCStringLiteral(SourceLocation AtLoc, StringRef *S);
 
   /// BuildObjCNumericLiteral - builds an ObjCBoxedExpr AST node for the
   /// numeric literal expression. Type of the expression will be "NSNumber *"
diff --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/include/clang/Serialization/ASTBitCodes.h
index aac165130b719..fddff869ef5bd 100644
--- a/clang/include/clang/Serialization/ASTBitCodes.h
+++ b/clang/include/clang/Serialization/ASTBitCodes.h
@@ -1612,7 +1612,7 @@ enum StmtCode {
   /// An ImaginaryLiteral record.
   EXPR_IMAGINARY_LITERAL,
 
-  /// A StringLiteral record.
+  /// A StringRef record.
   EXPR_STRING_LITERAL,
 
   /// A CharacterLiteral record.
diff --git a/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h b/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
index 2c970301879d2..fd92ab3ee8e3b 100644
--- a/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
+++ b/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
@@ -290,15 +290,15 @@ class AnalyzerOptions : public RefCountedBase {
 #undef ANALYZER_OPTION_DEPENDS_ON_USER_MODE
 
   bool isUnknownAnalyzerConfig(llvm::StringRef Name) {
-    static std::vector AnalyzerConfigCmdFlags = []() {
+    static std::vector AnalyzerConfigCmdFlags = []() {
       // Create an array of all -analyzer-config command line options.
-      std::vector AnalyzerConfigCmdFlags = {
+      std::vector AnalyzerConfigCmdFlags = {
 #define ANALYZER_OPTION_DEPENDS_ON_USER_MODE(TYPE, NAME, CMDFLAG, DESC,        \
                                              SHALLOW_VAL, DEEP_VAL)            \
   ANALYZER_OPTION(TYPE, NAME, CMDFLAG, DESC, SHALLOW_VAL)
 
 #define ANALYZER_OPTION(TYPE, NAME, CMDFLAG, DESC, DEFAULT_VAL)                \
-  llvm::StringLiteral(CMDFLAG),
+  llvm::StringRef(CMDFLAG),
 
 #include "clang/StaticAnalyzer/Core/AnalyzerOptions.def"
 #undef ANALYZER_OPTION
@@ -428,10 +428,10 @@ using AnalyzerOptionsRef = IntrusiveRefCntPtr;
 
 inline std::vector
 AnalyzerOptions::getRegisteredCheckers(bool IncludeExperimental) {
-  static constexpr llvm::StringLiteral StaticAnalyzerCheckerNames[] = {
+  static constexpr llvm::StringRef StaticAnalyzerCheckerNames[] = {
 #define GET_CHECKERS
 #define CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI, IS_HIDDEN)                 \
-  llvm::StringLiteral(FULLNAME),
+  llvm::StringRef(FULLNAME),
 #include "clang/StaticAnalyzer/Checkers/Checkers.inc"
 #undef CHECKER
 #undef GET_CHECKERS
@@ -447,9 +447,9 @@ AnalyzerOptions::getRegisteredCheckers(bool IncludeExperimental) {
 
 inline std::vector
 AnalyzerOptions::getRegisteredPackages(bool IncludeExperimental) {
-  static constexpr llvm::StringLiteral StaticAnalyzerPackageNames[] = {
+  static constexpr llvm::StringRef StaticAnalyzerPackageNames[] = {
 #define GET_PACKAGES
-#define PACKAGE(FULLNAME) llvm::StringLiteral(FULLNAME),
+#define PACKAGE(FULLNAME) llvm::StringRef(FULLNAME),
 #include "clang/StaticAnalyzer/Checkers/Checkers.inc"
 #undef PACKAGE
 #undef GET_PACKAGES
diff --git a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
index 56f7ca63d0062..6784dab10d067 100644
--- a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
+++ b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
@@ -446,9 +446,9 @@ class NilReceiverBRVisitor final : public BugReporterVisitor {
 /// Visitor that tries to report interesting diagnostics from conditions.
 class ConditionBRVisitor final : public BugReporterVisitor {
   // FIXME: constexpr initialization isn't supported by MSVC2013.
-  constexpr static llvm::StringLiteral GenericTrueMessage =
+  constexpr static llvm::StringRef GenericTrueMessage =
       "Assuming the condition is true";
-  constexpr static llvm::StringLiteral GenericFalseMessage =
+  constexpr static llvm::StringRef GenericFalseMessage =
       "Assuming the condition is false";
 
 public:
diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
index f88bf70d72398..142ca65190e38 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
@@ -825,24 +825,23 @@ class SymbolicRegion : public SubRegion {
   }
 };
 
-/// StringRegion - Region associated with a StringLiteral.
+/// StringRegion - Region associated with a StringRef.
 class StringRegion : public TypedValueRegion {
   friend class MemRegionManager;
 
-  const StringLiteral *Str;
+  const StringRef *Str;
 
-  StringRegion(const StringLiteral *str, const GlobalInternalSpaceRegion *sreg)
+  StringRegion(const StringRef *str, const GlobalInternalSpaceRegion *sreg)
       : TypedValueRegion(sreg, StringRegionKind), Str(str) {
     assert(str);
   }
 
-  static void ProfileRegion(llvm::FoldingSetNodeID &ID,
-                            const StringLiteral *Str,
+  static void ProfileRegion(llvm::FoldingSetNodeID &ID, const StringRef *Str,
                             const MemRegion *superRegion);
 
 public:
   LLVM_ATTRIBUTE_RETURNS_NONNULL
-  const StringLiteral *getStringLiteral() const { return Str; }
+  const StringRef *getStringLiteral() const { return Str; }
 
   QualType getValueType() const override { return Str->getType(); }
 
@@ -1485,7 +1484,7 @@ class MemRegionManager {
   /// Return a unique symbolic region belonging to heap memory space.
   const SymbolicRegion *getSymbolicHeapRegion(SymbolRef sym);
 
-  const StringRegion *getStringRegion(const StringLiteral *Str);
+  const StringRegion *getStringRegion(const StringRef *Str);
 
   const ObjCStringRegion *getObjCStringRegion(const ObjCStringLiteral *Str);
 
diff --git a/clang/include/clang/Tooling/Syntax/TokenBufferTokenManager.h b/clang/include/clang/Tooling/Syntax/TokenBufferTokenManager.h
index 6522af584e9ab..f8812a272837d 100644
--- a/clang/include/clang/Tooling/Syntax/TokenBufferTokenManager.h
+++ b/clang/include/clang/Tooling/Syntax/TokenBufferTokenManager.h
@@ -24,7 +24,7 @@ class TokenBufferTokenManager : public TokenManager {
       : Tokens(Tokens), LangOpts(LangOpts), SM(SourceMgr) {}
 
   static bool classof(const TokenManager *N) { return N->kind() == Kind; }
-  llvm::StringLiteral kind() const override { return Kind; }
+  llvm::StringRef kind() const override { return Kind; }
 
   llvm::StringRef getText(Key I) const override {
     const auto *Token = getToken(I);
@@ -46,7 +46,7 @@ class TokenBufferTokenManager : public TokenManager {
 
 private:
   // This manager is powered by the TokenBuffer.
-  static constexpr llvm::StringLiteral Kind = "TokenBuffer";
+  static constexpr llvm::StringRef Kind = "TokenBuffer";
 
   /// Add \p Buffer to the underlying source manager, tokenize it and store the
   /// resulting tokens. Used exclusively in `FactoryImpl` to materialize tokens
diff --git a/clang/include/clang/Tooling/Syntax/TokenManager.h b/clang/include/clang/Tooling/Syntax/TokenManager.h
index 6f0d11ce0d6b9..f782308800659 100644
--- a/clang/include/clang/Tooling/Syntax/TokenManager.h
+++ b/clang/include/clang/Tooling/Syntax/TokenManager.h
@@ -31,7 +31,7 @@ class TokenManager {
   virtual ~TokenManager() = default;
 
   /// Describes what the exact class kind of the TokenManager is.
-  virtual llvm::StringLiteral kind() const = 0;
+  virtual llvm::StringRef kind() const = 0;
 
   /// A key to identify a specific token. The token concept depends on the
   /// underlying implementation -- it can be a spelled token from the original
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index b10513f49a8d1..63307f37c603d 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -13045,14 +13045,14 @@ QualType ASTContext::getStringLiteralArrayType(QualType EltTy,
                               ArraySizeModifier::Normal, /*IndexTypeQuals*/ 0);
 }
 
-StringLiteral *
+StringRef *
 ASTContext::getPredefinedStringLiteralFromCache(StringRef Key) const {
-  StringLiteral *&Result = StringLiteralCache[Key];
+  StringRef *&Result = StringLiteralCache[Key];
   if (!Result)
-    Result = StringLiteral::Create(
-        *this, Key, StringLiteralKind::Ordinary,
-        /*Pascal*/ false, getStringLiteralArrayType(CharTy, Key.size()),
-        SourceLocation());
+    Result = StringRef::Create(*this, Key, StringLiteralKind::Ordinary,
+                               /*Pascal*/ false,
+                               getStringLiteralArrayType(CharTy, Key.size()),
+                               SourceLocation());
   return Result;
 }
 
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 26d33b0d94795..3c1365ba90077 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -621,7 +621,7 @@ namespace clang {
     ExpectedStmt VisitImaginaryLiteral(ImaginaryLiteral *E);
     ExpectedStmt VisitFixedPointLiteral(FixedPointLiteral *E);
     ExpectedStmt VisitCharacterLiteral(CharacterLiteral *E);
-    ExpectedStmt VisitStringLiteral(StringLiteral *E);
+    ExpectedStmt VisitStringLiteral(StringRef *E);
     ExpectedStmt VisitCompoundLiteralExpr(CompoundLiteralExpr *E);
     ExpectedStmt VisitAtomicExpr(AtomicExpr *E);
     ExpectedStmt VisitAddrLabelExpr(AddrLabelExpr *E);
@@ -4027,7 +4027,7 @@ ExpectedDecl ASTNodeImporter::VisitFunctionDecl(FunctionDecl *D) {
     // decl and its redeclarations may be required.
   }
 
-  StringLiteral *Msg = D->getDeletedMessage();
+  StringRef *Msg = D->getDeletedMessage();
   if (Msg) {
     auto Imported = import(Msg);
     if (!Imported)
@@ -6812,7 +6812,7 @@ ExpectedStmt ASTNodeImporter::VisitGCCAsmStmt(GCCAsmStmt *S) {
     Names.push_back(ToII);
   }
 
-  SmallVector Clobbers;
+  SmallVector Clobbers;
   for (unsigned I = 0, E = S->getNumClobbers(); I != E; I++) {
     if (auto ClobberOrErr = import(S->getClobberStringLiteral(I)))
       Clobbers.push_back(*ClobberOrErr);
@@ -6821,7 +6821,7 @@ ExpectedStmt ASTNodeImporter::VisitGCCAsmStmt(GCCAsmStmt *S) {
 
   }
 
-  SmallVector Constraints;
+  SmallVector Constraints;
   for (unsigned I = 0, E = S->getNumOutputs(); I != E; I++) {
     if (auto OutputOrErr = import(S->getOutputConstraintLiteral(I)))
       Constraints.push_back(*OutputOrErr);
@@ -7632,7 +7632,7 @@ ExpectedStmt ASTNodeImporter::VisitCharacterLiteral(CharacterLiteral *E) {
       E->getValue(), E->getKind(), *ToTypeOrErr, *ToLocationOrErr);
 }
 
-ExpectedStmt ASTNodeImporter::VisitStringLiteral(StringLiteral *E) {
+ExpectedStmt ASTNodeImporter::VisitStringLiteral(StringRef *E) {
   ExpectedType ToTypeOrErr = import(E->getType());
   if (!ToTypeOrErr)
     return ToTypeOrErr.takeError();
@@ -7642,9 +7642,9 @@ ExpectedStmt ASTNodeImporter::VisitStringLiteral(StringLiteral *E) {
       E->tokloc_begin(), E->tokloc_end(), ToLocations.begin()))
     return std::move(Err);
 
-  return StringLiteral::Create(
-      Importer.getToContext(), E->getBytes(), E->getKind(), E->isPascal(),
-      *ToTypeOrErr, ToLocations.data(), ToLocations.size());
+  return StringRef::Create(Importer.getToContext(), E->getBytes(), E->getKind(),
+                           E->isPascal(), *ToTypeOrErr, ToLocations.data(),
+                           ToLocations.size());
 }
 
 ExpectedStmt ASTNodeImporter::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
diff --git a/clang/lib/AST/ASTStructuralEquivalence.cpp b/clang/lib/AST/ASTStructuralEquivalence.cpp
index 308551c306151..2295160ba4e23 100644
--- a/clang/lib/AST/ASTStructuralEquivalence.cpp
+++ b/clang/lib/AST/ASTStructuralEquivalence.cpp
@@ -282,7 +282,7 @@ class StmtComparer {
 
   bool IsStmtEquivalent(const ObjCStringLiteral *E1,
                         const ObjCStringLiteral *E2) {
-    // Just wraps a StringLiteral child.
+    // Just wraps a StringRef child.
     return true;
   }
 
@@ -307,7 +307,7 @@ class StmtComparer {
     return E1->getTemplateDepth() == E2->getTemplateDepth();
   }
 
-  bool IsStmtEquivalent(const StringLiteral *E1, const StringLiteral *E2) {
+  bool IsStmtEquivalent(const StringRef *E1, const StringRef *E2) {
     return E1->getBytes() == E2->getBytes();
   }
 
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index 036f9608bf3ca..79cef82b00202 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -2311,7 +2311,7 @@ bool Compiler::VisitAbstractConditionalOperator(
 }
 
 template 
-bool Compiler::VisitStringLiteral(const StringLiteral *E) {
+bool Compiler::VisitStringLiteral(const StringRef *E) {
   if (DiscardResult)
     return true;
 
@@ -2379,9 +2379,9 @@ bool Compiler::VisitObjCEncodeExpr(const ObjCEncodeExpr *E) {
   auto &A = Ctx.getASTContext();
   std::string Str;
   A.getObjCEncodingForType(E->getEncodedType(), Str);
-  StringLiteral *SL =
-      StringLiteral::Create(A, Str, StringLiteralKind::Ordinary,
-                            /*Pascal=*/false, E->getType(), E->getAtLoc());
+  StringRef *SL =
+      StringRef::Create(A, Str, StringLiteralKind::Ordinary,
+                        /*Pascal=*/false, E->getType(), E->getAtLoc());
   return this->delegate(SL);
 }
 
@@ -2401,9 +2401,9 @@ bool Compiler::VisitSYCLUniqueStableNameExpr(
   QualType ArrayTy = A.getConstantArrayType(CharTy, Size, nullptr,
                                             ArraySizeModifier::Normal, 0);
 
-  StringLiteral *SL =
-      StringLiteral::Create(A, ResultStr, StringLiteralKind::Ordinary,
-                            /*Pascal=*/false, ArrayTy, E->getLocation());
+  StringRef *SL =
+      StringRef::Create(A, ResultStr, StringLiteralKind::Ordinary,
+                        /*Pascal=*/false, ArrayTy, E->getLocation());
 
   unsigned StringIndex = P.createGlobalString(SL);
   return this->emitGetPtrGlobal(StringIndex, E);
diff --git a/clang/lib/AST/ByteCode/Compiler.h b/clang/lib/AST/ByteCode/Compiler.h
index 71765b18cb1a9..fd9914c40bc3f 100644
--- a/clang/lib/AST/ByteCode/Compiler.h
+++ b/clang/lib/AST/ByteCode/Compiler.h
@@ -158,7 +158,7 @@ class Compiler : public ConstStmtVisitor, bool>,
   bool VisitArrayInitLoopExpr(const ArrayInitLoopExpr *E);
   bool VisitOpaqueValueExpr(const OpaqueValueExpr *E);
   bool VisitAbstractConditionalOperator(const AbstractConditionalOperator *E);
-  bool VisitStringLiteral(const StringLiteral *E);
+  bool VisitStringLiteral(const StringRef *E);
   bool VisitObjCStringLiteral(const ObjCStringLiteral *E);
   bool VisitObjCEncodeExpr(const ObjCEncodeExpr *E);
   bool VisitSYCLUniqueStableNameExpr(const SYCLUniqueStableNameExpr *E);
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 0d52083b06946..462e41d7f9978 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -1555,7 +1555,7 @@ static bool interp__builtin_constant_p(InterpState &S, CodePtr OpPC,
           // A null base is acceptable.
           return returnInt(true);
         } else if (const auto *E = Base.dyn_cast()) {
-          if (!isa(E))
+          if (!isa(E))
             return returnInt(false);
           return returnInt(LV.getLValueOffset().isZero());
         } else if (Base.is()) {
diff --git a/clang/lib/AST/ByteCode/Pointer.cpp b/clang/lib/AST/ByteCode/Pointer.cpp
index ec4756fe4f87d..dc0d634f99db1 100644
--- a/clang/lib/AST/ByteCode/Pointer.cpp
+++ b/clang/lib/AST/ByteCode/Pointer.cpp
@@ -497,7 +497,7 @@ bool Pointer::pointsToLiteral() const {
     return false;
 
   const Expr *E = block()->getDescriptor()->asExpr();
-  return E && !isa(E);
+  return E && !isa(E);
 }
 
 std::optional Pointer::toRValue(const Context &Ctx,
diff --git a/clang/lib/AST/ByteCode/Program.cpp b/clang/lib/AST/ByteCode/Program.cpp
index c98a3506b0a90..15300c06c4428 100644
--- a/clang/lib/AST/ByteCode/Program.cpp
+++ b/clang/lib/AST/ByteCode/Program.cpp
@@ -32,7 +32,7 @@ const void *Program::getNativePointer(unsigned Idx) {
   return NativePointers[Idx];
 }
 
-unsigned Program::createGlobalString(const StringLiteral *S, const Expr *Base) {
+unsigned Program::createGlobalString(const StringRef *S, const Expr *Base) {
   const size_t CharWidth = S->getCharByteWidth();
   const size_t BitWidth = CharWidth * Ctx.getCharBit();
 
diff --git a/clang/lib/AST/ByteCode/Program.h b/clang/lib/AST/ByteCode/Program.h
index c9c3d20f198c6..b5111b7cdb753 100644
--- a/clang/lib/AST/ByteCode/Program.h
+++ b/clang/lib/AST/ByteCode/Program.h
@@ -29,7 +29,7 @@ namespace clang {
 class RecordDecl;
 class Expr;
 class FunctionDecl;
-class StringLiteral;
+class StringRef;
 class VarDecl;
 
 namespace interp {
@@ -64,8 +64,7 @@ class Program final {
   const void *getNativePointer(unsigned Idx);
 
   /// Emits a string literal among global data.
-  unsigned createGlobalString(const StringLiteral *S,
-                              const Expr *Base = nullptr);
+  unsigned createGlobalString(const StringRef *S, const Expr *Base = nullptr);
 
   /// Returns a pointer to a global.
   Pointer getPtrGlobal(unsigned Idx) const;
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 97e23dd1aaa92..b7516c9b18b3c 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -3102,11 +3102,11 @@ bool FunctionDecl::isVariadic() const {
 FunctionDecl::DefaultedOrDeletedFunctionInfo *
 FunctionDecl::DefaultedOrDeletedFunctionInfo::Create(
     ASTContext &Context, ArrayRef Lookups,
-    StringLiteral *DeletedMessage) {
+    StringRef *DeletedMessage) {
   static constexpr size_t Alignment =
       std::max({alignof(DefaultedOrDeletedFunctionInfo),
-                alignof(DeclAccessPair), alignof(StringLiteral *)});
-  size_t Size = totalSizeToAlloc(
+                alignof(DeclAccessPair), alignof(StringRef *)});
+  size_t Size = totalSizeToAlloc(
       Lookups.size(), DeletedMessage != nullptr);
 
   DefaultedOrDeletedFunctionInfo *Info =
@@ -3117,7 +3117,7 @@ FunctionDecl::DefaultedOrDeletedFunctionInfo::Create(
   std::uninitialized_copy(Lookups.begin(), Lookups.end(),
                           Info->getTrailingObjects());
   if (DeletedMessage)
-    *Info->getTrailingObjects() = DeletedMessage;
+    *Info->getTrailingObjects() = DeletedMessage;
   return Info;
 }
 
@@ -3130,7 +3130,7 @@ void FunctionDecl::setDefaultedOrDeletedInfo(
   DefaultedOrDeletedInfo = Info;
 }
 
-void FunctionDecl::setDeletedAsWritten(bool D, StringLiteral *Message) {
+void FunctionDecl::setDeletedAsWritten(bool D, StringRef *Message) {
   FunctionDeclBits.IsDeleted = D;
 
   if (Message) {
@@ -3144,14 +3144,14 @@ void FunctionDecl::setDeletedAsWritten(bool D, StringLiteral *Message) {
 }
 
 void FunctionDecl::DefaultedOrDeletedFunctionInfo::setDeletedMessage(
-    StringLiteral *Message) {
+    StringRef *Message) {
   // We should never get here with the DefaultedOrDeletedInfo populated, but
   // no space allocated for the deleted message, since that would require
   // recreating this, but setDefaultedOrDeletedInfo() disallows overwriting
   // an already existing DefaultedOrDeletedFunctionInfo.
   assert(HasDeletedMessage &&
          "No space to store a delete message in this DefaultedOrDeletedInfo");
-  *getTrailingObjects() = Message;
+  *getTrailingObjects() = Message;
 }
 
 FunctionDecl::DefaultedOrDeletedFunctionInfo *
@@ -5602,7 +5602,7 @@ SourceRange TypeAliasDecl::getSourceRange() const {
 void FileScopeAsmDecl::anchor() {}
 
 FileScopeAsmDecl *FileScopeAsmDecl::Create(ASTContext &C, DeclContext *DC,
-                                           StringLiteral *Str,
+                                           StringRef *Str,
                                            SourceLocation AsmLoc,
                                            SourceLocation RParenLoc) {
   return new (C, DC) FileScopeAsmDecl(DC, Str, AsmLoc, RParenLoc);
diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index 0d51fdbc7e126..88031e017b202 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -827,7 +827,7 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
     Out << " = 0";
   else if (D->isDeletedAsWritten()) {
     Out << " = delete";
-    if (const StringLiteral *M = D->getDeletedMessage()) {
+    if (const StringRef *M = D->getDeletedMessage()) {
       Out << "(";
       M->outputString(Out);
       Out << ")";
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index ba66d36278567..801eae6ba5147 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -616,7 +616,7 @@ std::string SYCLUniqueStableNameExpr::ComputeName(ASTContext &Context,
 
 PredefinedExpr::PredefinedExpr(SourceLocation L, QualType FNTy,
                                PredefinedIdentKind IK, bool IsTransparent,
-                               StringLiteral *SL)
+                               StringRef *SL)
     : Expr(PredefinedExprClass, FNTy, VK_LValue, OK_Ordinary) {
   PredefinedExprBits.Kind = llvm::to_underlying(IK);
   assert((getIdentKind() == IK) &&
@@ -637,7 +637,7 @@ PredefinedExpr::PredefinedExpr(EmptyShell Empty, bool HasFunctionName)
 
 PredefinedExpr *PredefinedExpr::Create(const ASTContext &Ctx, SourceLocation L,
                                        QualType FNTy, PredefinedIdentKind IK,
-                                       bool IsTransparent, StringLiteral *SL) {
+                                       bool IsTransparent, StringRef *SL) {
   bool HasFunctionName = SL != nullptr;
   void *Mem = Ctx.Allocate(totalSizeToAlloc(HasFunctionName),
                            alignof(PredefinedExpr));
@@ -1092,8 +1092,8 @@ double FloatingLiteral::getValueAsApproximateDouble() const {
   return V.convertToDouble();
 }
 
-unsigned StringLiteral::mapCharByteWidth(TargetInfo const &Target,
-                                         StringLiteralKind SK) {
+unsigned StringRef::mapCharByteWidth(TargetInfo const &Target,
+                                     StringLiteralKind SK) {
   unsigned CharByteWidth = 0;
   switch (SK) {
   case StringLiteralKind::Ordinary:
@@ -1119,10 +1119,9 @@ unsigned StringLiteral::mapCharByteWidth(TargetInfo const &Target,
   return CharByteWidth;
 }
 
-StringLiteral::StringLiteral(const ASTContext &Ctx, StringRef Str,
-                             StringLiteralKind Kind, bool Pascal, QualType Ty,
-                             const SourceLocation *Loc,
-                             unsigned NumConcatenated)
+StringRef::StringRef(const ASTContext &Ctx, StringRef Str,
+                     StringLiteralKind Kind, bool Pascal, QualType Ty,
+                     const SourceLocation *Loc, unsigned NumConcatenated)
     : Expr(StringLiteralClass, Ty, VK_LValue, OK_Ordinary) {
 
   unsigned Length = Str.size();
@@ -1132,7 +1131,7 @@ StringLiteral::StringLiteral(const ASTContext &Ctx, StringRef Str,
 
   if (Kind != StringLiteralKind::Unevaluated) {
     assert(Ctx.getAsConstantArrayType(Ty) &&
-           "StringLiteral must be of constant array type!");
+           "StringRef must be of constant array type!");
     unsigned CharByteWidth = mapCharByteWidth(Ctx.getTargetInfo(), Kind);
     unsigned ByteLength = Str.size();
     assert((ByteLength % CharByteWidth == 0) &&
@@ -1176,37 +1175,35 @@ StringLiteral::StringLiteral(const ASTContext &Ctx, StringRef Str,
   setDependence(ExprDependence::None);
 }
 
-StringLiteral::StringLiteral(EmptyShell Empty, unsigned NumConcatenated,
-                             unsigned Length, unsigned CharByteWidth)
+StringRef::StringRef(EmptyShell Empty, unsigned NumConcatenated,
+                     unsigned Length, unsigned CharByteWidth)
     : Expr(StringLiteralClass, Empty) {
   StringLiteralBits.CharByteWidth = CharByteWidth;
   StringLiteralBits.NumConcatenated = NumConcatenated;
   *getTrailingObjects() = Length;
 }
 
-StringLiteral *StringLiteral::Create(const ASTContext &Ctx, StringRef Str,
-                                     StringLiteralKind Kind, bool Pascal,
-                                     QualType Ty, const SourceLocation *Loc,
-                                     unsigned NumConcatenated) {
+StringRef *StringRef::Create(const ASTContext &Ctx, StringRef Str,
+                             StringLiteralKind Kind, bool Pascal, QualType Ty,
+                             const SourceLocation *Loc,
+                             unsigned NumConcatenated) {
   void *Mem = Ctx.Allocate(totalSizeToAlloc(
                                1, NumConcatenated, Str.size()),
-                           alignof(StringLiteral));
-  return new (Mem)
-      StringLiteral(Ctx, Str, Kind, Pascal, Ty, Loc, NumConcatenated);
+                           alignof(StringRef));
+  return new (Mem) StringRef(Ctx, Str, Kind, Pascal, Ty, Loc, NumConcatenated);
 }
 
-StringLiteral *StringLiteral::CreateEmpty(const ASTContext &Ctx,
-                                          unsigned NumConcatenated,
-                                          unsigned Length,
-                                          unsigned CharByteWidth) {
+StringRef *StringRef::CreateEmpty(const ASTContext &Ctx,
+                                  unsigned NumConcatenated, unsigned Length,
+                                  unsigned CharByteWidth) {
   void *Mem = Ctx.Allocate(totalSizeToAlloc(
                                1, NumConcatenated, Length * CharByteWidth),
-                           alignof(StringLiteral));
+                           alignof(StringRef));
   return new (Mem)
-      StringLiteral(EmptyShell(), NumConcatenated, Length, CharByteWidth);
+      StringRef(EmptyShell(), NumConcatenated, Length, CharByteWidth);
 }
 
-void StringLiteral::outputString(raw_ostream &OS) const {
+void StringRef::outputString(raw_ostream &OS) const {
   switch (getKind()) {
   case StringLiteralKind::Unevaluated:
   case StringLiteralKind::Ordinary:
@@ -1322,10 +1319,10 @@ void StringLiteral::outputString(raw_ostream &OS) const {
 /// string.
 ///
 SourceLocation
-StringLiteral::getLocationOfByte(unsigned ByteNo, const SourceManager &SM,
-                                 const LangOptions &Features,
-                                 const TargetInfo &Target, unsigned *StartToken,
-                                 unsigned *StartTokenByteOffset) const {
+StringRef::getLocationOfByte(unsigned ByteNo, const SourceManager &SM,
+                             const LangOptions &Features,
+                             const TargetInfo &Target, unsigned *StartToken,
+                             unsigned *StartTokenByteOffset) const {
   assert((getKind() == StringLiteralKind::Ordinary ||
           getKind() == StringLiteralKind::UTF8 ||
           getKind() == StringLiteralKind::Unevaluated) &&
@@ -2309,7 +2306,7 @@ APValue SourceLocExpr::EvaluateInContext(const ASTContext &Ctx,
 
   auto MakeStringLiteral = [&](StringRef Tmp) {
     using LValuePathEntry = APValue::LValuePathEntry;
-    StringLiteral *Res = Ctx.getPredefinedStringLiteralFromCache(Tmp);
+    StringRef *Res = Ctx.getPredefinedStringLiteralFromCache(Tmp);
     // Decay the string to a pointer to the first character.
     LValuePathEntry Path[1] = {LValuePathEntry::ArrayIndex(0)};
     return APValue(Res, CharUnits::Zero(), Path, /*OnePastTheEnd=*/false);
@@ -2454,7 +2451,7 @@ bool InitListExpr::isStringLiteralInit() const {
   if (!Init)
     return false;
   Init = Init->IgnoreParenImpCasts();
-  return isa(Init) || isa(Init);
+  return isa(Init) || isa(Init);
 }
 
 bool InitListExpr::isTransparent() const {
diff --git a/clang/lib/AST/ExprClassification.cpp b/clang/lib/AST/ExprClassification.cpp
index 3f37d06cc8f3a..494878959bcaa 100644
--- a/clang/lib/AST/ExprClassification.cpp
+++ b/clang/lib/AST/ExprClassification.cpp
@@ -158,7 +158,7 @@ static Cl::Kinds ClassifyInternal(ASTContext &Ctx, const Expr *E) {
     // when they are transparent.
   case Expr::PredefinedExprClass: {
     auto *PE = cast(E);
-    const StringLiteral *SL = PE->getFunctionName();
+    const StringRef *SL = PE->getFunctionName();
     if (PE->isTransparent())
       return SL ? ClassifyInternal(Ctx, SL) : Cl::CL_LValue;
     assert(!SL || SL->isLValue());
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 5768bb12ee38e..7b8d981835131 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -2173,8 +2173,8 @@ static bool GetLValueBaseAsString(const EvalInfo &Info, const LValue &LVal,
     return true;
   }
 
-  // Otherwise, we have a StringLiteral.
-  const auto *Lit = dyn_cast(BaseExpr);
+  // Otherwise, we have a StringRef.
+  const auto *Lit = dyn_cast(BaseExpr);
   if (const auto *PE = dyn_cast(BaseExpr))
     Lit = PE->getFunctionName();
 
@@ -2340,7 +2340,7 @@ static bool CheckLValueConstantExpression(EvalInfo &Info, SourceLocation Loc,
     StringRef Ident;
     if (Base.is())
       InvalidBaseKind = 0;
-    else if (isa_and_nonnull(BaseE))
+    else if (isa_and_nonnull(BaseE))
       InvalidBaseKind = 1;
     else if (isa_and_nonnull(BaseE) ||
              isa_and_nonnull(BaseVD))
@@ -3588,7 +3588,7 @@ static unsigned getBaseIndex(const CXXRecordDecl *Derived,
 static APSInt extractStringLiteralCharacter(EvalInfo &Info, const Expr *Lit,
                                             uint64_t Index) {
   assert(!isa(Lit) &&
-         "SourceLocExpr should have already been converted to a StringLiteral");
+         "SourceLocExpr should have already been converted to a StringRef");
 
   // FIXME: Support MakeStringConstant
   if (const auto *ObjCEnc = dyn_cast(Lit)) {
@@ -3600,7 +3600,7 @@ static APSInt extractStringLiteralCharacter(EvalInfo &Info, const Expr *Lit,
 
   if (auto PE = dyn_cast(Lit))
     Lit = PE->getFunctionName();
-  const StringLiteral *S = cast(Lit);
+  const StringRef *S = cast(Lit);
   const ConstantArrayType *CAT =
       Info.Ctx.getAsConstantArrayType(S->getType());
   assert(CAT && "string literal isn't an array");
@@ -3617,7 +3617,7 @@ static APSInt extractStringLiteralCharacter(EvalInfo &Info, const Expr *Lit,
 //
 // FIXME: This is inefficient; we should probably introduce something similar
 // to the LLVM ConstantDataArray to make this cheaper.
-static void expandStringLiteral(EvalInfo &Info, const StringLiteral *S,
+static void expandStringLiteral(EvalInfo &Info, const StringRef *S,
                                 APValue &Result,
                                 QualType AllocType = QualType()) {
   const ConstantArrayType *CAT = Info.Ctx.getAsConstantArrayType(
@@ -4542,7 +4542,7 @@ handleLValueToRValueConversion(EvalInfo &Info, const Expr *Conv, QualType Type,
 
       CompleteObject LitObj(LVal.Base, &Lit, Base->getType());
       return extractSubobject(Info, Conv, LitObj, LVal.Designator, RVal, AK);
-    } else if (isa(Base) || isa(Base)) {
+    } else if (isa(Base) || isa(Base)) {
       // Special-case character extraction so we don't have to construct an
       // APValue for the whole string.
       assert(LVal.Designator.Entries.size() <= 1 &&
@@ -8648,7 +8648,7 @@ class LValueExprEvaluatorBase
 //  * FunctionDecl
 // - Literals
 //  * CompoundLiteralExpr in C (and in global scope in C++)
-//  * StringLiteral
+//  * StringRef
 //  * PredefinedExpr
 //  * ObjCStringLiteralExpr
 //  * ObjCEncodeExpr
@@ -8683,7 +8683,7 @@ class LValueExprEvaluator
   bool VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *E);
   bool VisitCompoundLiteralExpr(const CompoundLiteralExpr *E);
   bool VisitMemberExpr(const MemberExpr *E);
-  bool VisitStringLiteral(const StringLiteral *E) {
+  bool VisitStringLiteral(const StringRef *E) {
     return Success(APValue::LValueBase(
         E, 0, Info.getASTContext().getNextStringLiteralVersion()));
   }
@@ -9417,9 +9417,9 @@ class PointerExprEvaluator
     QualType ArrayTy = Info.Ctx.getConstantArrayType(
         CharTy, Size, nullptr, ArraySizeModifier::Normal, 0);
 
-    StringLiteral *SL =
-        StringLiteral::Create(Info.Ctx, ResultStr, StringLiteralKind::Ordinary,
-                              /*Pascal*/ false, ArrayTy, E->getLocation());
+    StringRef *SL =
+        StringRef::Create(Info.Ctx, ResultStr, StringLiteralKind::Ordinary,
+                          /*Pascal*/ false, ArrayTy, E->getLocation());
 
     evaluateLValue(SL, Result);
     Result.addArray(Info, E, cast(ArrayTy));
@@ -11492,7 +11492,7 @@ namespace {
     bool VisitCXXConstructExpr(const CXXConstructExpr *E,
                                const LValue &Subobject,
                                APValue *Value, QualType Type);
-    bool VisitStringLiteral(const StringLiteral *E,
+    bool VisitStringLiteral(const StringRef *E,
                             QualType AllocType = QualType()) {
       expandStringLiteral(Info, E, Result, AllocType);
       return true;
@@ -11565,7 +11565,7 @@ bool ArrayExprEvaluator::VisitInitListExpr(const InitListExpr *E,
   // C++11 [dcl.init.string]p1: A char array [...] can be initialized by [...]
   // an appropriately-typed string literal enclosed in braces.
   if (E->isStringLiteralInit()) {
-    auto *SL = dyn_cast(E->getInit(0)->IgnoreParenImpCasts());
+    auto *SL = dyn_cast(E->getInit(0)->IgnoreParenImpCasts());
     // FIXME: Support ObjCEncodeExpr here once we support it in
     // ArrayExprEvaluator generally.
     if (!SL)
@@ -11650,7 +11650,7 @@ bool ArrayExprEvaluator::VisitCXXParenListOrInitListExpr(
     if (ArrayIndex >= NumEltsToInit)
       break;
     if (auto *EmbedS = dyn_cast(Init->IgnoreParenImpCasts())) {
-      StringLiteral *SL = EmbedS->getDataStringLiteral();
+      StringRef *SL = EmbedS->getDataStringLiteral();
       for (unsigned I = EmbedS->getStartingElementPos(),
                     N = EmbedS->getDataElementCount();
            I != EmbedS->getStartingElementPos() + N; ++I) {
@@ -12305,7 +12305,7 @@ static bool EvaluateBuiltinConstantPForLValue(const APValue &LV) {
     // A null base is acceptable.
     return true;
   } else if (const Expr *E = Base.dyn_cast()) {
-    if (!isa(E))
+    if (!isa(E))
       return false;
     return LV.getLValueOffset().isZero();
   } else if (Base.is()) {
@@ -13005,8 +13005,7 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
     return Visit(E->getArg(0));
 
   case Builtin::BI__builtin_ptrauth_string_discriminator: {
-    const auto *Literal =
-        cast(E->getArg(0)->IgnoreParenImpCasts());
+    const auto *Literal = cast(E->getArg(0)->IgnoreParenImpCasts());
     uint64_t Result = getPointerAuthStableSipHash(Literal->getString());
     return Success(Result, E);
   }
@@ -15366,7 +15365,7 @@ static bool TryEvaluateBuiltinNaN(const ASTContext &Context,
                                   const Expr *Arg,
                                   bool SNaN,
                                   llvm::APFloat &Result) {
-  const StringLiteral *S = dyn_cast(Arg->IgnoreParenCasts());
+  const StringRef *S = dyn_cast(Arg->IgnoreParenCasts());
   if (!S) return false;
 
   const llvm::fltSemantics &Sem = Context.getFloatTypeSemantics(ResultTy);
@@ -17735,7 +17734,7 @@ static bool EvaluateBuiltinStrLen(const Expr *E, uint64_t &Result,
   QualType CharTy = E->getType()->getPointeeType();
 
   // Fast path: if it's a string literal, search the string value.
-  if (const StringLiteral *S = dyn_cast_or_null(
+  if (const StringRef *S = dyn_cast_or_null(
           String.getLValueBase().dyn_cast())) {
     StringRef Str = S->getBytes();
     int64_t Off = String.Offset.getQuantity();
diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 47aa9b40dab84..528a7a7fdfe43 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -87,9 +87,7 @@ class ItaniumMangleContextImpl : public ItaniumMangleContext {
   /// @{
 
   bool shouldMangleCXXName(const NamedDecl *D) override;
-  bool shouldMangleStringLiteral(const StringLiteral *) override {
-    return false;
-  }
+  bool shouldMangleStringLiteral(const StringRef *) override { return false; }
 
   bool isUniqueInternalLinkageDecl(const NamedDecl *ND) override;
   void needsUniqueInternalLinkageNames() override {
@@ -128,7 +126,7 @@ class ItaniumMangleContextImpl : public ItaniumMangleContext {
   void mangleItaniumThreadLocalWrapper(const VarDecl *D,
                                        raw_ostream &) override;
 
-  void mangleStringLiteral(const StringLiteral *, raw_ostream &) override;
+  void mangleStringLiteral(const StringRef *, raw_ostream &) override;
 
   void mangleLambdaSig(const CXXRecordDecl *Lambda, raw_ostream &) override;
 
@@ -7489,7 +7487,8 @@ void ItaniumMangleContextImpl::mangleCanonicalTypeName(
   mangleCXXRTTIName(Ty, Out, NormalizeIntegers);
 }
 
-void ItaniumMangleContextImpl::mangleStringLiteral(const StringLiteral *, raw_ostream &) {
+void ItaniumMangleContextImpl::mangleStringLiteral(const StringRef *,
+                                                   raw_ostream &) {
   llvm_unreachable("Can't mangle string literals");
 }
 
diff --git a/clang/lib/AST/JSONNodeDumper.cpp b/clang/lib/AST/JSONNodeDumper.cpp
index ddbe2136a671f..688c5d9a86c46 100644
--- a/clang/lib/AST/JSONNodeDumper.cpp
+++ b/clang/lib/AST/JSONNodeDumper.cpp
@@ -978,7 +978,7 @@ void JSONNodeDumper::VisitFunctionDecl(const FunctionDecl *FD) {
     JOS.attribute("explicitlyDefaulted",
                   FD->isDeleted() ? "deleted" : "default");
 
-  if (StringLiteral *Msg = FD->getDeletedMessage())
+  if (StringRef *Msg = FD->getDeletedMessage())
     JOS.attribute("deletedMessage", Msg->getString());
 }
 
@@ -1636,7 +1636,7 @@ void JSONNodeDumper::VisitFloatingLiteral(const FloatingLiteral *FL) {
   FL->getValue().toString(Buffer);
   JOS.attribute("value", Buffer);
 }
-void JSONNodeDumper::VisitStringLiteral(const StringLiteral *SL) {
+void JSONNodeDumper::VisitStringLiteral(const StringRef *SL) {
   std::string Buffer;
   llvm::raw_string_ostream SS(Buffer);
   SL->outputString(SS);
diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp
index edeeaeaa9ae17..0bd995a50a18b 100644
--- a/clang/lib/AST/MicrosoftMangle.cpp
+++ b/clang/lib/AST/MicrosoftMangle.cpp
@@ -151,7 +151,7 @@ class MicrosoftMangleContextImpl : public MicrosoftMangleContext {
   MicrosoftMangleContextImpl(ASTContext &Context, DiagnosticsEngine &Diags,
                              bool IsAux = false);
   bool shouldMangleCXXName(const NamedDecl *D) override;
-  bool shouldMangleStringLiteral(const StringLiteral *SL) override;
+  bool shouldMangleStringLiteral(const StringRef *SL) override;
   void mangleCXXName(GlobalDecl GD, raw_ostream &Out) override;
   void mangleVirtualMemPtrThunk(const CXXMethodDecl *MD,
                                 const MethodVFTableLocation &ML,
@@ -210,7 +210,7 @@ class MicrosoftMangleContextImpl : public MicrosoftMangleContext {
                                  raw_ostream &Out) override;
   void mangleSEHFinallyBlock(GlobalDecl EnclosingDecl,
                              raw_ostream &Out) override;
-  void mangleStringLiteral(const StringLiteral *SL, raw_ostream &Out) override;
+  void mangleStringLiteral(const StringRef *SL, raw_ostream &Out) override;
   bool getNextDiscriminator(const NamedDecl *ND, unsigned &disc) {
     const DeclContext *DC = getEffectiveDeclContext(ND);
     if (!DC->isFunctionOrMethod())
@@ -568,8 +568,8 @@ bool MicrosoftMangleContextImpl::shouldMangleCXXName(const NamedDecl *D) {
   return true;
 }
 
-bool
-MicrosoftMangleContextImpl::shouldMangleStringLiteral(const StringLiteral *SL) {
+bool MicrosoftMangleContextImpl::shouldMangleStringLiteral(
+    const StringRef *SL) {
   return true;
 }
 
@@ -4220,7 +4220,7 @@ MicrosoftMangleContextImpl::mangleDynamicAtExitDestructor(const VarDecl *D,
   mangleInitFiniStub(D, 'F', Out);
 }
 
-void MicrosoftMangleContextImpl::mangleStringLiteral(const StringLiteral *SL,
+void MicrosoftMangleContextImpl::mangleStringLiteral(const StringRef *SL,
                                                      raw_ostream &Out) {
   //  ::= 0   # char, char16_t, char32_t
   //                     # (little endian char data in mangling)
@@ -4282,7 +4282,7 @@ void MicrosoftMangleContextImpl::mangleStringLiteral(const StringLiteral *SL,
     return static_cast((CodeUnit >> (8 * OffsetInCodeUnit)) & 0xff);
   };
 
-  // CRC all the bytes of the StringLiteral.
+  // CRC all the bytes of the StringRef.
   llvm::JamCRC JC;
   for (unsigned I = 0, E = StringByteLength; I != E; ++I)
     JC.update(GetLittleEndianByte(I));
@@ -4292,7 +4292,7 @@ void MicrosoftMangleContextImpl::mangleStringLiteral(const StringLiteral *SL,
   Mangler.mangleNumber(JC.getCRC());
 
   // : The mangled name also contains the first 32 bytes
-  // (including null-terminator bytes) of the encoded StringLiteral.
+  // (including null-terminator bytes) of the encoded StringRef.
   // Each character is encoded by splitting them into bytes and then encoding
   // the constituent bytes.
   auto MangleByte = [&Mangler](char Byte) {
diff --git a/clang/lib/AST/ODRHash.cpp b/clang/lib/AST/ODRHash.cpp
index 7c5c287e6c15b..cfdc78f2f14d6 100644
--- a/clang/lib/AST/ODRHash.cpp
+++ b/clang/lib/AST/ODRHash.cpp
@@ -705,7 +705,7 @@ void ODRHash::AddFunctionDecl(const FunctionDecl *Function,
   AddBoolean(Function->isDeletedAsWritten());
   AddBoolean(Function->isExplicitlyDefaulted());
 
-  StringLiteral *DeletedMessage = Function->getDeletedMessage();
+  StringRef *DeletedMessage = Function->getDeletedMessage();
   AddBoolean(DeletedMessage);
 
   if (DeletedMessage)
diff --git a/clang/lib/AST/OSLog.cpp b/clang/lib/AST/OSLog.cpp
index b777d4d65b84d..2523aac8ecbb6 100644
--- a/clang/lib/AST/OSLog.cpp
+++ b/clang/lib/AST/OSLog.cpp
@@ -200,7 +200,7 @@ bool clang::analyze_os_log::computeOSLogBufferLayout(
     llvm_unreachable("non-os_log builtin passed to computeOSLogBufferLayout");
   }
 
-  const StringLiteral *Lit = cast(StringArg->IgnoreParenCasts());
+  const StringRef *Lit = cast(StringArg->IgnoreParenCasts());
   assert(Lit && (Lit->isOrdinary() || Lit->isUTF8()));
   StringRef Data = Lit->getString();
   OSLogFormatStringHandler H(VarArgs);
diff --git a/clang/lib/AST/OpenMPClause.cpp b/clang/lib/AST/OpenMPClause.cpp
index 4246ba95d827f..f17f5528708d9 100644
--- a/clang/lib/AST/OpenMPClause.cpp
+++ b/clang/lib/AST/OpenMPClause.cpp
@@ -1954,8 +1954,8 @@ void OMPClausePrinter::VisitOMPSeverityClause(OMPSeverityClause *Node) {
 }
 
 void OMPClausePrinter::VisitOMPMessageClause(OMPMessageClause *Node) {
-  OS << "message(\""
-     << cast(Node->getMessageString())->getString() << "\")";
+  OS << "message(\"" << cast(Node->getMessageString())->getString()
+     << "\")";
 }
 
 void OMPClausePrinter::VisitOMPScheduleClause(OMPScheduleClause *Node) {
diff --git a/clang/lib/AST/Stmt.cpp b/clang/lib/AST/Stmt.cpp
index d6a351a78c7ba..9d8bbcff6f263 100644
--- a/clang/lib/AST/Stmt.cpp
+++ b/clang/lib/AST/Stmt.cpp
@@ -546,15 +546,10 @@ StringRef GCCAsmStmt::getInputConstraint(unsigned i) const {
   return getInputConstraintLiteral(i)->getString();
 }
 
-void GCCAsmStmt::setOutputsAndInputsAndClobbers(const ASTContext &C,
-                                                IdentifierInfo **Names,
-                                                StringLiteral **Constraints,
-                                                Stmt **Exprs,
-                                                unsigned NumOutputs,
-                                                unsigned NumInputs,
-                                                unsigned NumLabels,
-                                                StringLiteral **Clobbers,
-                                                unsigned NumClobbers) {
+void GCCAsmStmt::setOutputsAndInputsAndClobbers(
+    const ASTContext &C, IdentifierInfo **Names, StringRef **Constraints,
+    Stmt **Exprs, unsigned NumOutputs, unsigned NumInputs, unsigned NumLabels,
+    StringRef **Clobbers, unsigned NumClobbers) {
   this->NumOutputs = NumOutputs;
   this->NumInputs = NumInputs;
   this->NumClobbers = NumClobbers;
@@ -572,11 +567,11 @@ void GCCAsmStmt::setOutputsAndInputsAndClobbers(const ASTContext &C,
 
   unsigned NumConstraints = NumOutputs + NumInputs;
   C.Deallocate(this->Constraints);
-  this->Constraints = new (C) StringLiteral*[NumConstraints];
+  this->Constraints = new (C) StringRef *[NumConstraints];
   std::copy(Constraints, Constraints + NumConstraints, this->Constraints);
 
   C.Deallocate(this->Clobbers);
-  this->Clobbers = new (C) StringLiteral*[NumClobbers];
+  this->Clobbers = new (C) StringRef *[NumClobbers];
   std::copy(Clobbers, Clobbers + NumClobbers, this->Clobbers);
 }
 
@@ -855,13 +850,12 @@ void MSAsmStmt::setInputExpr(unsigned i, Expr *E) {
 GCCAsmStmt::GCCAsmStmt(const ASTContext &C, SourceLocation asmloc,
                        bool issimple, bool isvolatile, unsigned numoutputs,
                        unsigned numinputs, IdentifierInfo **names,
-                       StringLiteral **constraints, Expr **exprs,
-                       StringLiteral *asmstr, unsigned numclobbers,
-                       StringLiteral **clobbers, unsigned numlabels,
-                       SourceLocation rparenloc)
+                       StringRef **constraints, Expr **exprs, StringRef *asmstr,
+                       unsigned numclobbers, StringRef **clobbers,
+                       unsigned numlabels, SourceLocation rparenloc)
     : AsmStmt(GCCAsmStmtClass, asmloc, issimple, isvolatile, numoutputs,
               numinputs, numclobbers),
-              RParenLoc(rparenloc), AsmStr(asmstr), NumLabels(numlabels) {
+      RParenLoc(rparenloc), AsmStr(asmstr), NumLabels(numlabels) {
   unsigned NumExprs = NumOutputs + NumInputs + NumLabels;
 
   Names = new (C) IdentifierInfo*[NumExprs];
@@ -871,10 +865,10 @@ GCCAsmStmt::GCCAsmStmt(const ASTContext &C, SourceLocation asmloc,
   std::copy(exprs, exprs + NumExprs, Exprs);
 
   unsigned NumConstraints = NumOutputs + NumInputs;
-  Constraints = new (C) StringLiteral*[NumConstraints];
+  Constraints = new (C) StringRef *[NumConstraints];
   std::copy(constraints, constraints + NumConstraints, Constraints);
 
-  Clobbers = new (C) StringLiteral*[NumClobbers];
+  Clobbers = new (C) StringRef *[NumClobbers];
   std::copy(clobbers, clobbers + NumClobbers, Clobbers);
 }
 
diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp
index 52bcb5135d351..11167138a9418 100644
--- a/clang/lib/AST/StmtPrinter.cpp
+++ b/clang/lib/AST/StmtPrinter.cpp
@@ -1478,9 +1478,7 @@ void StmtPrinter::VisitImaginaryLiteral(ImaginaryLiteral *Node) {
   OS << "i";
 }
 
-void StmtPrinter::VisitStringLiteral(StringLiteral *Str) {
-  Str->outputString(OS);
-}
+void StmtPrinter::VisitStringLiteral(StringRef *Str) { Str->outputString(OS); }
 
 void StmtPrinter::VisitParenExpr(ParenExpr *Node) {
   OS << "(";
@@ -2116,7 +2114,7 @@ void StmtPrinter::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *Node) {
 void StmtPrinter::VisitUserDefinedLiteral(UserDefinedLiteral *Node) {
   switch (Node->getLiteralOperatorKind()) {
   case UserDefinedLiteral::LOK_Raw:
-    OS << cast(Node->getArg(0)->IgnoreImpCasts())->getString();
+    OS << cast(Node->getArg(0)->IgnoreImpCasts())->getString();
     break;
   case UserDefinedLiteral::LOK_Template: {
     const auto *DRE = cast(Node->getCallee()->IgnoreImpCasts());
diff --git a/clang/lib/AST/StmtProfile.cpp b/clang/lib/AST/StmtProfile.cpp
index 0f1ebc68a4f76..033631c6008cb 100644
--- a/clang/lib/AST/StmtProfile.cpp
+++ b/clang/lib/AST/StmtProfile.cpp
@@ -1409,7 +1409,7 @@ void StmtProfiler::VisitImaginaryLiteral(const ImaginaryLiteral *S) {
   VisitExpr(S);
 }
 
-void StmtProfiler::VisitStringLiteral(const StringLiteral *S) {
+void StmtProfiler::VisitStringLiteral(const StringRef *S) {
   VisitExpr(S);
   ID.AddString(S->getBytes());
   ID.AddInteger(llvm::to_underlying(S->getKind()));
diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp
index 670641242cae2..348e35c34e878 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -1495,7 +1495,7 @@ void TextNodeDumper::VisitFloatingLiteral(const FloatingLiteral *Node) {
   OS << " " << Node->getValueAsApproximateDouble();
 }
 
-void TextNodeDumper::VisitStringLiteral(const StringLiteral *Str) {
+void TextNodeDumper::VisitStringLiteral(const StringRef *Str) {
   ColorScope Color(OS, ShowColors, ValueColor);
   OS << " ";
   Str->outputString(OS);
@@ -2174,7 +2174,7 @@ void TextNodeDumper::VisitFunctionDecl(const FunctionDecl *D) {
   if (D->isTrivial())
     OS << " trivial";
 
-  if (const StringLiteral *M = D->getDeletedMessage())
+  if (const StringRef *M = D->getDeletedMessage())
     AddChild("delete message", [=] { Visit(M); });
 
   if (D->isIneligibleOrNotSelected())
diff --git a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
index 9c7943a98d652..d149e6b5b2b32 100644
--- a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -955,7 +955,7 @@ const internal::VariadicDynCastAllOfMatcher nullStmt;
 const internal::VariadicDynCastAllOfMatcher asmStmt;
 const internal::VariadicDynCastAllOfMatcher
     cxxBoolLiteral;
-const internal::VariadicDynCastAllOfMatcher stringLiteral;
+const internal::VariadicDynCastAllOfMatcher stringLiteral;
 const internal::VariadicDynCastAllOfMatcher objcStringLiteral;
 const internal::VariadicDynCastAllOfMatcher
     characterLiteral;
diff --git a/clang/lib/Analysis/CalledOnceCheck.cpp b/clang/lib/Analysis/CalledOnceCheck.cpp
index 1554eab1860c1..653eae087569c 100644
--- a/clang/lib/Analysis/CalledOnceCheck.cpp
+++ b/clang/lib/Analysis/CalledOnceCheck.cpp
@@ -48,29 +48,29 @@ using ParamSizedVector = llvm::SmallVector;
 static constexpr unsigned EXPECTED_NUMBER_OF_BASIC_BLOCKS = 8;
 template 
 using CFGSizedVector = llvm::SmallVector;
-constexpr llvm::StringLiteral CONVENTIONAL_NAMES[] = {
+constexpr llvm::StringRef CONVENTIONAL_NAMES[] = {
     "completionHandler", "completion",      "withCompletionHandler",
     "withCompletion",    "completionBlock", "withCompletionBlock",
     "replyTo",           "reply",           "withReplyTo"};
-constexpr llvm::StringLiteral CONVENTIONAL_SUFFIXES[] = {
+constexpr llvm::StringRef CONVENTIONAL_SUFFIXES[] = {
     "WithCompletionHandler", "WithCompletion", "WithCompletionBlock",
     "WithReplyTo", "WithReply"};
-constexpr llvm::StringLiteral CONVENTIONAL_CONDITIONS[] = {
+constexpr llvm::StringRef CONVENTIONAL_CONDITIONS[] = {
     "error", "cancel", "shouldCall", "done", "OK", "success"};
 
 struct KnownCalledOnceParameter {
-  llvm::StringLiteral FunctionName;
+  llvm::StringRef FunctionName;
   unsigned ParamIndex;
 };
 constexpr KnownCalledOnceParameter KNOWN_CALLED_ONCE_PARAMETERS[] = {
-    {llvm::StringLiteral{"dispatch_async"}, 1},
-    {llvm::StringLiteral{"dispatch_async_and_wait"}, 1},
-    {llvm::StringLiteral{"dispatch_after"}, 2},
-    {llvm::StringLiteral{"dispatch_sync"}, 1},
-    {llvm::StringLiteral{"dispatch_once"}, 1},
-    {llvm::StringLiteral{"dispatch_barrier_async"}, 1},
-    {llvm::StringLiteral{"dispatch_barrier_async_and_wait"}, 1},
-    {llvm::StringLiteral{"dispatch_barrier_sync"}, 1}};
+    {llvm::StringRef{"dispatch_async"}, 1},
+    {llvm::StringRef{"dispatch_async_and_wait"}, 1},
+    {llvm::StringRef{"dispatch_after"}, 2},
+    {llvm::StringRef{"dispatch_sync"}, 1},
+    {llvm::StringRef{"dispatch_once"}, 1},
+    {llvm::StringRef{"dispatch_barrier_async"}, 1},
+    {llvm::StringRef{"dispatch_barrier_async_and_wait"}, 1},
+    {llvm::StringRef{"dispatch_barrier_sync"}, 1}};
 
 class ParameterStatus {
 public:
@@ -475,11 +475,11 @@ bool mentionsAnyOfConventionalNames(const Expr *E) {
   NamesCollector::NameCollection MentionedNames = NamesCollector::collect(E);
 
   return llvm::any_of(MentionedNames, [](llvm::StringRef ConditionName) {
-    return llvm::any_of(
-        CONVENTIONAL_CONDITIONS,
-        [ConditionName](const llvm::StringLiteral &Conventional) {
-          return ConditionName.contains_insensitive(Conventional);
-        });
+    return llvm::any_of(CONVENTIONAL_CONDITIONS,
+                        [ConditionName](const llvm::StringRef &Conventional) {
+                          return ConditionName.contains_insensitive(
+                              Conventional);
+                        });
   });
 }
 
diff --git a/clang/lib/Analysis/CloneDetection.cpp b/clang/lib/Analysis/CloneDetection.cpp
index 65ac4ad6a5e53..7aac714c4e486 100644
--- a/clang/lib/Analysis/CloneDetection.cpp
+++ b/clang/lib/Analysis/CloneDetection.cpp
@@ -214,7 +214,7 @@ class CloneTypeIIStmtDataCollector
   SKIP(MemberExpr)
   SKIP(IntegerLiteral)
   SKIP(FloatingLiteral)
-  SKIP(StringLiteral)
+  SKIP(StringRef)
   SKIP(CXXBoolLiteralExpr)
   SKIP(CharacterLiteral)
 #undef SKIP
diff --git a/clang/lib/Analysis/FlowSensitive/Formula.cpp b/clang/lib/Analysis/FlowSensitive/Formula.cpp
index ef7d23ff6c565..1e32fbe425dd6 100644
--- a/clang/lib/Analysis/FlowSensitive/Formula.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Formula.cpp
@@ -36,7 +36,7 @@ const Formula &Formula::create(llvm::BumpPtrAllocator &Alloc, Kind K,
   return *Result;
 }
 
-static llvm::StringLiteral sigil(Formula::Kind K) {
+static llvm::StringRef sigil(Formula::Kind K) {
   switch (K) {
   case Formula::AtomRef:
   case Formula::Literal:
diff --git a/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp b/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
index e1394e28cd49a..aaebf947d38ec 100644
--- a/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
@@ -298,7 +298,7 @@ auto isStdForwardCall() {
                   hasArgument(0, hasOptionalOrDerivedType()));
 }
 
-constexpr llvm::StringLiteral ValueOrCallID = "ValueOrCall";
+constexpr llvm::StringRef ValueOrCallID = "ValueOrCall";
 
 auto isValueOrStringEmptyCall() {
   // `opt.value_or("").empty()`
diff --git a/clang/lib/Analysis/ReachableCode.cpp b/clang/lib/Analysis/ReachableCode.cpp
index dd81c8e0a3d54..b62dac7aef325 100644
--- a/clang/lib/Analysis/ReachableCode.cpp
+++ b/clang/lib/Analysis/ReachableCode.cpp
@@ -43,10 +43,9 @@ static bool isEnumConstant(const Expr *Ex) {
 
 static bool isTrivialExpression(const Expr *Ex) {
   Ex = Ex->IgnoreParenCasts();
-  return isa(Ex) || isa(Ex) ||
+  return isa(Ex) || isa(Ex) ||
          isa(Ex) || isa(Ex) ||
-         isa(Ex) ||
-         isEnumConstant(Ex);
+         isa(Ex) || isEnumConstant(Ex);
 }
 
 static bool isTrivialDoWhile(const CFGBlock *B, const Stmt *S) {
diff --git a/clang/lib/Analysis/ThreadSafetyCommon.cpp b/clang/lib/Analysis/ThreadSafetyCommon.cpp
index 050daee1168d4..ff79a343b849e 100644
--- a/clang/lib/Analysis/ThreadSafetyCommon.cpp
+++ b/clang/lib/Analysis/ThreadSafetyCommon.cpp
@@ -44,7 +44,7 @@ std::string threadSafety::getSourceLiteralString(const Expr *CE) {
       return toString(cast(CE)->getValue(), 10, true);
     case Stmt::StringLiteralClass: {
       std::string ret("\"");
-      ret += cast(CE)->getString();
+      ret += cast(CE)->getString();
       ret += "\"";
       return ret;
     }
@@ -192,7 +192,7 @@ CapabilityExpr SExprBuilder::translateAttrExpr(const Expr *AttrExp,
   if (!AttrExp)
     return CapabilityExpr();
 
-  if (const auto* SLit = dyn_cast(AttrExp)) {
+  if (const auto *SLit = dyn_cast(AttrExp)) {
     if (SLit->getString() == "*")
       // The "*" expr is a universal lock, which essentially turns off
       // checks until it is removed from the lockset.
diff --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp b/clang/lib/Analysis/UnsafeBufferUsage.cpp
index a9aff39df6474..4df0ab51b76a5 100644
--- a/clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -446,8 +446,8 @@ AST_MATCHER(ArraySubscriptExpr, isSafeArraySubscript) {
                                           ->getType()
                                           ->getUnqualifiedDesugaredType())) {
     limit = CATy->getLimitedSize();
-  } else if (const auto *SLiteral = dyn_cast(
-                 Node.getBase()->IgnoreParenImpCasts())) {
+  } else if (const auto *SLiteral =
+                 dyn_cast(Node.getBase()->IgnoreParenImpCasts())) {
     limit = SLiteral->getLength() + 1;
   } else {
     return false;
@@ -513,7 +513,7 @@ struct LibcFunNamePrefixSuffixParser {
 // A pointer type expression is known to be null-terminated, if it has the
 // form: E.c_str(), for any expression E of `std::string` type.
 static bool isNullTermPointer(const Expr *Ptr) {
-  if (isa(Ptr->IgnoreParenImpCasts()))
+  if (isa(Ptr->IgnoreParenImpCasts()))
     return true;
   if (isa(Ptr->IgnoreParenImpCasts()))
     return true;
@@ -571,7 +571,7 @@ static bool hasUnsafeFormatOrSArg(const CallExpr *Call, const Expr *&UnsafeArg,
 
   const Expr *Fmt = Call->getArg(FmtArgIdx);
 
-  if (auto *SL = dyn_cast(Fmt->IgnoreParenImpCasts())) {
+  if (auto *SL = dyn_cast(Fmt->IgnoreParenImpCasts())) {
     StringRef FmtStr;
 
     if (SL->getCharByteWidth() == 1)
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp
index 44e982d3ee67f..b6102d28c4cbc 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -90,9 +90,9 @@ const char *ContentCache::getInvalidBOM(StringRef BufStr) {
   // http://en.wikipedia.org/wiki/Byte_order_mark for more information.
   const char *InvalidBOM =
       llvm::StringSwitch(BufStr)
-          .StartsWith(llvm::StringLiteral::withInnerNUL("\x00\x00\xFE\xFF"),
+          .StartsWith(llvm::StringRef::withInnerNUL("\x00\x00\xFE\xFF"),
                       "UTF-32 (BE)")
-          .StartsWith(llvm::StringLiteral::withInnerNUL("\xFF\xFE\x00\x00"),
+          .StartsWith(llvm::StringRef::withInnerNUL("\xFF\xFE\x00\x00"),
                       "UTF-32 (LE)")
           .StartsWith("\xFE\xFF", "UTF-16 (BE)")
           .StartsWith("\xFF\xFE", "UTF-16 (LE)")
diff --git a/clang/lib/Basic/Targets/BPF.cpp b/clang/lib/Basic/Targets/BPF.cpp
index f4684765b7ffb..81175cd32f939 100644
--- a/clang/lib/Basic/Targets/BPF.cpp
+++ b/clang/lib/Basic/Targets/BPF.cpp
@@ -70,8 +70,8 @@ void BPFTargetInfo::getTargetDefines(const LangOptions &Opts,
   }
 }
 
-static constexpr llvm::StringLiteral ValidCPUNames[] = {"generic", "v1", "v2",
-                                                        "v3", "v4", "probe"};
+static constexpr llvm::StringRef ValidCPUNames[] = {"generic", "v1", "v2",
+                                                    "v3",      "v4", "probe"};
 
 bool BPFTargetInfo::isValidCPUName(StringRef Name) const {
   return llvm::is_contained(ValidCPUNames, Name);
diff --git a/clang/lib/Basic/Targets/Hexagon.cpp b/clang/lib/Basic/Targets/Hexagon.cpp
index b5e06b679ece7..e0b3e930c62c9 100644
--- a/clang/lib/Basic/Targets/Hexagon.cpp
+++ b/clang/lib/Basic/Targets/Hexagon.cpp
@@ -230,8 +230,8 @@ bool HexagonTargetInfo::hasFeature(StringRef Feature) const {
 }
 
 struct CPUSuffix {
-  llvm::StringLiteral Name;
-  llvm::StringLiteral Suffix;
+  llvm::StringRef Name;
+  llvm::StringRef Suffix;
 };
 
 static constexpr CPUSuffix Suffixes[] = {
diff --git a/clang/lib/Basic/Targets/Mips.cpp b/clang/lib/Basic/Targets/Mips.cpp
index d56995e3ccc48..1e3e4a281ee6b 100644
--- a/clang/lib/Basic/Targets/Mips.cpp
+++ b/clang/lib/Basic/Targets/Mips.cpp
@@ -43,11 +43,11 @@ bool MipsTargetInfo::processorSupportsGPR64() const {
       .Default(false);
 }
 
-static constexpr llvm::StringLiteral ValidCPUNames[] = {
+static constexpr llvm::StringRef ValidCPUNames[] = {
     {"mips1"},  {"mips2"},    {"mips3"},    {"mips4"},    {"mips5"},
     {"mips32"}, {"mips32r2"}, {"mips32r3"}, {"mips32r5"}, {"mips32r6"},
     {"mips64"}, {"mips64r2"}, {"mips64r3"}, {"mips64r5"}, {"mips64r6"},
-    {"octeon"}, {"octeon+"}, {"p5600"}};
+    {"octeon"}, {"octeon+"},  {"p5600"}};
 
 bool MipsTargetInfo::isValidCPUName(StringRef Name) const {
   return llvm::is_contained(ValidCPUNames, Name);
diff --git a/clang/lib/Basic/Targets/Sparc.cpp b/clang/lib/Basic/Targets/Sparc.cpp
index d1a891092b0f5..3589b8a6a4260 100644
--- a/clang/lib/Basic/Targets/Sparc.cpp
+++ b/clang/lib/Basic/Targets/Sparc.cpp
@@ -59,7 +59,7 @@ bool SparcTargetInfo::hasFeature(StringRef Feature) const {
 }
 
 struct SparcCPUInfo {
-  llvm::StringLiteral Name;
+  llvm::StringRef Name;
   SparcTargetInfo::CPUKind Kind;
   SparcTargetInfo::CPUGeneration Generation;
 };
diff --git a/clang/lib/Basic/Targets/SystemZ.cpp b/clang/lib/Basic/Targets/SystemZ.cpp
index 06f08db2eadd4..a5d144908bee2 100644
--- a/clang/lib/Basic/Targets/SystemZ.cpp
+++ b/clang/lib/Basic/Targets/SystemZ.cpp
@@ -94,7 +94,7 @@ bool SystemZTargetInfo::validateAsmConstraint(
 }
 
 struct ISANameRevision {
-  llvm::StringLiteral Name;
+  llvm::StringRef Name;
   int ISARevisionID;
 };
 static constexpr ISANameRevision ISARevisions[] = {
diff --git a/clang/lib/Basic/Targets/WebAssembly.cpp b/clang/lib/Basic/Targets/WebAssembly.cpp
index 7b0fd0c841ba2..7d3f81b2bb3b4 100644
--- a/clang/lib/Basic/Targets/WebAssembly.cpp
+++ b/clang/lib/Basic/Targets/WebAssembly.cpp
@@ -30,7 +30,7 @@ static constexpr Builtin::Info BuiltinInfo[] = {
 #include "clang/Basic/BuiltinsWebAssembly.def"
 };
 
-static constexpr llvm::StringLiteral ValidCPUNames[] = {
+static constexpr llvm::StringRef ValidCPUNames[] = {
     {"mvp"}, {"bleeding-edge"}, {"generic"}, {"lime1"}};
 
 StringRef WebAssemblyTargetInfo::getABI() const { return ABI; }
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index ca03fb665d423..fa6ac363816af 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -3738,7 +3738,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
   }
   case Builtin::BI__builtin_allow_runtime_check: {
     StringRef Kind =
-        cast(E->getArg(0)->IgnoreParenCasts())->getString();
+        cast(E->getArg(0)->IgnoreParenCasts())->getString();
     LLVMContext &Ctx = CGM.getLLVMContext();
     llvm::Value *Allow = Builder.CreateCall(
         CGM.getIntrinsic(llvm::Intrinsic::allow_runtime_check),
@@ -5480,7 +5480,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
     // Re-encode each wide string to UTF8 and make an MDString.
     SmallVector Strings;
     for (const Expr *Arg : E->arguments()) {
-      const auto *Str = cast(Arg->IgnoreParenCasts());
+      const auto *Str = cast(Arg->IgnoreParenCasts());
       assert(Str->getCharByteWidth() == 2);
       StringRef WideBytes = Str->getBytes();
       std::string StrUtf8;
@@ -5508,7 +5508,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
     // Get the annotation string, go through casts. Sema requires this to be a
     // non-wide string literal, potentially casted, so the cast<> is safe.
     const Expr *AnnotationStrExpr = E->getArg(1)->IgnoreParenCasts();
-    StringRef Str = cast(AnnotationStrExpr)->getString();
+    StringRef Str = cast(AnnotationStrExpr)->getString();
     return RValue::get(
         EmitAnnotationCall(F, AnnVal, Str, E->getExprLoc(), nullptr));
   }
@@ -8973,7 +8973,7 @@ static Value *EmitSpecialRegisterBuiltin(CodeGenFunction &CGF,
 
   if (SysReg.empty()) {
     const Expr *SysRegStrExpr = E->getArg(0)->IgnoreParenCasts();
-    SysReg = cast(SysRegStrExpr)->getString();
+    SysReg = cast(SysRegStrExpr)->getString();
   }
 
   llvm::Metadata *Ops[] = { llvm::MDString::get(Context, SysReg) };
@@ -14803,7 +14803,7 @@ static Value *EmitX86SExtMask(CodeGenFunction &CGF, Value *Op,
 
 Value *CodeGenFunction::EmitX86CpuIs(const CallExpr *E) {
   const Expr *CPUExpr = E->getArg(0)->IgnoreParenCasts();
-  StringRef CPUStr = cast(CPUExpr)->getString();
+  StringRef CPUStr = cast(CPUExpr)->getString();
   return EmitX86CpuIs(CPUStr);
 }
 
@@ -14894,7 +14894,7 @@ Value *CodeGenFunction::EmitX86CpuIs(StringRef CPUStr) {
 
 Value *CodeGenFunction::EmitX86CpuSupports(const CallExpr *E) {
   const Expr *FeatureExpr = E->getArg(0)->IgnoreParenCasts();
-  StringRef FeatureStr = cast(FeatureExpr)->getString();
+  StringRef FeatureStr = cast(FeatureExpr)->getString();
   if (!getContext().getTargetInfo().validateCpuSupports(FeatureStr))
     return Builder.getFalse();
   return EmitX86CpuSupports(FeatureStr);
@@ -14991,7 +14991,7 @@ Value *CodeGenFunction::EmitX86CpuInit() {
 
 Value *CodeGenFunction::EmitAArch64CpuSupports(const CallExpr *E) {
   const Expr *ArgExpr = E->getArg(0)->IgnoreParenCasts();
-  StringRef ArgStr = cast(ArgExpr)->getString();
+  StringRef ArgStr = cast(ArgExpr)->getString();
   llvm::SmallVector Features;
   ArgStr.split(Features, "+");
   for (auto &Feature : Features) {
@@ -15033,7 +15033,7 @@ CodeGenFunction::EmitAArch64CpuSupports(ArrayRef FeaturesStrs) {
 Value *CodeGenFunction::EmitRISCVCpuSupports(const CallExpr *E) {
 
   const Expr *FeatureExpr = E->getArg(0)->IgnoreParenCasts();
-  StringRef FeatureStr = cast(FeatureExpr)->getString();
+  StringRef FeatureStr = cast(FeatureExpr)->getString();
   if (!getContext().getTargetInfo().validateCpuSupports(FeatureStr))
     return Builder.getFalse();
 
@@ -17750,7 +17750,7 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned BuiltinID,
 
   case Builtin::BI__builtin_cpu_is: {
     const Expr *CPUExpr = E->getArg(0)->IgnoreParenCasts();
-    StringRef CPUStr = cast(CPUExpr)->getString();
+    StringRef CPUStr = cast(CPUExpr)->getString();
     llvm::Triple Triple = getTarget().getTriple();
 
     unsigned LinuxSupportMethod, LinuxIDValue, AIXSupportMethod, AIXIDValue;
@@ -17790,7 +17790,7 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned BuiltinID,
   case Builtin::BI__builtin_cpu_supports: {
     llvm::Triple Triple = getTarget().getTriple();
     const Expr *CPUExpr = E->getArg(0)->IgnoreParenCasts();
-    StringRef CPUStr = cast(CPUExpr)->getString();
+    StringRef CPUStr = cast(CPUExpr)->getString();
     if (Triple.isOSAIX()) {
       unsigned SupportMethod, FieldIdx, Mask, Value;
       CmpInst::Predicate CompOp;
@@ -22986,7 +22986,7 @@ Value *CodeGenFunction::EmitHexagonBuiltinExpr(unsigned BuiltinID,
 
 Value *CodeGenFunction::EmitRISCVCpuIs(const CallExpr *E) {
   const Expr *CPUExpr = E->getArg(0)->IgnoreParenCasts();
-  StringRef CPUStr = cast(CPUExpr)->getString();
+  StringRef CPUStr = cast(CPUExpr)->getString();
   return EmitRISCVCpuIs(CPUStr);
 }
 
diff --git a/clang/lib/CodeGen/CGCoroutine.cpp b/clang/lib/CodeGen/CGCoroutine.cpp
index 0c09ff96f9d6b..499c5896154aa 100644
--- a/clang/lib/CodeGen/CGCoroutine.cpp
+++ b/clang/lib/CodeGen/CGCoroutine.cpp
@@ -24,8 +24,8 @@ using llvm::BasicBlock;
 
 namespace {
 enum class AwaitKind { Init, Normal, Yield, Final };
-static constexpr llvm::StringLiteral AwaitKindStr[] = {"init", "await", "yield",
-                                                       "final"};
+static constexpr llvm::StringRef AwaitKindStr[] = {"init", "await", "yield",
+                                                   "final"};
 }
 
 struct clang::CodeGen::CGCoroData {
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 560d4ce293365..dd12b8198ef80 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -5898,7 +5898,7 @@ void CGDebugInfo::EmitGlobalAlias(const llvm::GlobalValue *GV,
 }
 
 void CGDebugInfo::AddStringLiteralDebugInfo(llvm::GlobalVariable *GV,
-                                            const StringLiteral *S) {
+                                            const StringRef *S) {
   SourceLocation Loc = S->getStrTokenLoc(0);
   PresumedLoc PLoc = CGM.getContext().getSourceManager().getPresumedLoc(Loc);
   if (!PLoc.isValid())
diff --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h
index 38f73eca561b7..db83376bfa670 100644
--- a/clang/lib/CodeGen/CGDebugInfo.h
+++ b/clang/lib/CodeGen/CGDebugInfo.h
@@ -580,8 +580,7 @@ class CGDebugInfo {
   /// nice to be able to symbolize the line and column information. This is
   /// especially useful for sanitizers, as it allows symbolization of
   /// heap-buffer-overflows on constant strings.
-  void AddStringLiteralDebugInfo(llvm::GlobalVariable *GV,
-                                 const StringLiteral *S);
+  void AddStringLiteralDebugInfo(llvm::GlobalVariable *GV, const StringRef *S);
 
   /// Emit C++ namespace alias.
   llvm::DIImportedEntity *EmitNamespaceAlias(const NamespaceAliasDecl &NA);
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 1bad7a722da07..cfe18d6d4f7a1 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -1594,7 +1594,7 @@ LValue CodeGenFunction::EmitLValueHelper(const Expr *E,
   case Expr::PredefinedExprClass:
     return EmitPredefinedLValue(cast(E));
   case Expr::StringLiteralClass:
-    return EmitStringLiteralLValue(cast(E));
+    return EmitStringLiteralLValue(cast(E));
   case Expr::ObjCEncodeExprClass:
     return EmitObjCEncodeExprLValue(cast(E));
   case Expr::PseudoObjectExprClass:
@@ -3290,7 +3290,7 @@ LValue CodeGenFunction::EmitUnaryOpLValue(const UnaryOperator *E) {
   }
 }
 
-LValue CodeGenFunction::EmitStringLiteralLValue(const StringLiteral *E) {
+LValue CodeGenFunction::EmitStringLiteralLValue(const StringRef *E) {
   return MakeAddrLValue(CGM.GetAddrOfConstantStringFromLiteral(E),
                         E->getType(), AlignmentSource::Decl);
 }
@@ -3302,7 +3302,7 @@ LValue CodeGenFunction::EmitObjCEncodeExprLValue(const ObjCEncodeExpr *E) {
 
 LValue CodeGenFunction::EmitPredefinedLValue(const PredefinedExpr *E) {
   auto SL = E->getFunctionName();
-  assert(SL != nullptr && "No StringLiteral name in PredefinedExpr");
+  assert(SL != nullptr && "No StringRef name in PredefinedExpr");
   StringRef FnName = CurFn->getName();
   if (FnName.starts_with("\01"))
     FnName = FnName.substr(1);
diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp
index 2ad6587089f10..5a206d2258160 100644
--- a/clang/lib/CodeGen/CGExprAgg.cpp
+++ b/clang/lib/CodeGen/CGExprAgg.cpp
@@ -150,7 +150,7 @@ class AggExprEmitter : public StmtVisitor {
   void VisitDeclRefExpr(DeclRefExpr *E) { EmitAggLoadOfLValue(E); }
   void VisitMemberExpr(MemberExpr *ME) { EmitAggLoadOfLValue(ME); }
   void VisitUnaryDeref(UnaryOperator *E) { EmitAggLoadOfLValue(E); }
-  void VisitStringLiteral(StringLiteral *E) { EmitAggLoadOfLValue(E); }
+  void VisitStringLiteral(StringRef *E) { EmitAggLoadOfLValue(E); }
   void VisitCompoundLiteralExpr(CompoundLiteralExpr *E);
   void VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
     EmitAggLoadOfLValue(E);
diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp
index 648b9b9ed9806..7ca25cd809473 100644
--- a/clang/lib/CodeGen/CGExprCXX.cpp
+++ b/clang/lib/CodeGen/CGExprCXX.cpp
@@ -1049,13 +1049,13 @@ void CodeGenFunction::EmitNewArrayInitializer(
 
   const InitListExpr *ILE = dyn_cast(Init);
   const CXXParenListInitExpr *CPLIE = nullptr;
-  const StringLiteral *SL = nullptr;
+  const StringRef *SL = nullptr;
   const ObjCEncodeExpr *OCEE = nullptr;
   const Expr *IgnoreParen = nullptr;
   if (!ILE) {
     IgnoreParen = Init->IgnoreParenImpCasts();
     CPLIE = dyn_cast(IgnoreParen);
-    SL = dyn_cast(IgnoreParen);
+    SL = dyn_cast(IgnoreParen);
     OCEE = dyn_cast(IgnoreParen);
   }
 
@@ -1592,8 +1592,8 @@ llvm::Value *CodeGenFunction::EmitCXXNewExpr(const CXXNewExpr *E) {
     const InitListExpr *ILE = dyn_cast(Init);
     const CXXParenListInitExpr *CPLIE = dyn_cast(Init);
     const Expr *IgnoreParen = Init->IgnoreParenImpCasts();
-    if ((ILE && ILE->isStringLiteralInit()) ||
-        isa(IgnoreParen) || isa(IgnoreParen)) {
+    if ((ILE && ILE->isStringLiteralInit()) || isa(IgnoreParen) ||
+        isa(IgnoreParen)) {
       minElements =
           cast(Init->getType()->getAsArrayTypeUnsafe())
               ->getZExtSize();
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp
index 655fc3dc954c8..9f9605e08d516 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -1252,7 +1252,7 @@ class ConstExprEmitter
       return Visit(subExpr, destType);
 
     case CK_ArrayToPointerDecay:
-      if (const auto *S = dyn_cast(subExpr))
+      if (const auto *S = dyn_cast(subExpr))
         return CGM.GetAddrOfConstantStringFromLiteral(S).getPointer();
       return nullptr;
     case CK_NullToPointer:
@@ -1428,7 +1428,7 @@ class ConstExprEmitter
     for (unsigned i = 0; i < ILE->getNumInits(); ++i) {
       const Expr *Init = ILE->getInit(i);
       if (auto *EmbedS = dyn_cast(Init->IgnoreParenImpCasts())) {
-        StringLiteral *SL = EmbedS->getDataStringLiteral();
+        StringRef *SL = EmbedS->getDataStringLiteral();
         llvm::APSInt Value(CGM.getContext().getTypeSize(DestTy),
                            DestTy->isUnsignedIntegerType());
         llvm::Constant *C;
@@ -1536,7 +1536,7 @@ class ConstExprEmitter
     return CGM.EmitNullConstant(Ty);
   }
 
-  llvm::Constant *VisitStringLiteral(const StringLiteral *E, QualType T) {
+  llvm::Constant *VisitStringLiteral(const StringRef *E, QualType T) {
     // This is a string literal initializing an array in an initializer.
     return CGM.GetConstantArrayFromStringLiteral(E);
   }
@@ -2079,7 +2079,7 @@ class ConstantLValueEmitter : public ConstStmtVisitorisExpressibleAsConstantInitializer() &&
          "this boxed expression can't be emitted as a compile-time constant");
-  const auto *SL = cast(E->getSubExpr()->IgnoreParenCasts());
+  const auto *SL = cast(E->getSubExpr()->IgnoreParenCasts());
   return emitConstantObjCStringLiteral(SL, E->getType(), CGM);
 }
 
@@ -2317,7 +2316,7 @@ ConstantLValueEmitter::VisitCallExpr(const CallExpr *E) {
       builtin != Builtin::BI__builtin___NSStringMakeConstantString)
     return nullptr;
 
-  const auto *Literal = cast(E->getArg(0)->IgnoreParenCasts());
+  const auto *Literal = cast(E->getArg(0)->IgnoreParenCasts());
   if (builtin == Builtin::BI__builtin___NSStringMakeConstantString) {
     return CGM.getObjCRuntime().GenerateConstantString(Literal);
   } else {
diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp
index cfc92be393940..c6d2d93808faa 100644
--- a/clang/lib/CodeGen/CGObjCGNU.cpp
+++ b/clang/lib/CodeGen/CGObjCGNU.cpp
@@ -563,7 +563,7 @@ class CGObjCGNU : public CGObjCRuntime {
   CGObjCGNU(CodeGenModule &cgm, unsigned runtimeABIVersion,
       unsigned protocolClassVersion, unsigned classABI=1);
 
-  ConstantAddress GenerateConstantString(const StringLiteral *) override;
+  ConstantAddress GenerateConstantString(const StringRef *) override;
 
   RValue
   GenerateMessageSend(CodeGenFunction &CGF, ReturnValueSlot Return,
@@ -987,7 +987,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
     B.CreateCall(Fn, Args);
   }
 
-  ConstantAddress GenerateConstantString(const StringLiteral *SL) override {
+  ConstantAddress GenerateConstantString(const StringRef *SL) override {
 
     auto Str = SL->getString();
     CharUnits Align = CGM.getPointerAlign();
@@ -2599,7 +2599,7 @@ llvm::Constant *CGObjCGNUstep::GetEHType(QualType T) {
 }
 
 /// Generate an NSConstantString object.
-ConstantAddress CGObjCGNU::GenerateConstantString(const StringLiteral *SL) {
+ConstantAddress CGObjCGNU::GenerateConstantString(const StringRef *SL) {
 
   std::string Str = SL->getString().str();
   CharUnits Align = CGM.getPointerAlign();
diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp
index 7b85dcc2c7984..2424d74f7aa95 100644
--- a/clang/lib/CodeGen/CGObjCMac.cpp
+++ b/clang/lib/CodeGen/CGObjCMac.cpp
@@ -1088,8 +1088,8 @@ class CGObjCCommonMac : public CodeGen::CGObjCRuntime {
     return ObjCABI == 2;
   }
 
-  ConstantAddress GenerateConstantString(const StringLiteral *SL) override;
-  ConstantAddress GenerateConstantNSString(const StringLiteral *SL);
+  ConstantAddress GenerateConstantString(const StringRef *SL) override;
+  ConstantAddress GenerateConstantNSString(const StringRef *SL);
 
   llvm::Function *GenerateMethod(const ObjCMethodDecl *OMD,
                                  const ObjCContainerDecl *CD=nullptr) override;
@@ -1937,8 +1937,7 @@ llvm::Constant *CGObjCMac::GetEHType(QualType T) {
    };
 */
 
-ConstantAddress
-CGObjCCommonMac::GenerateConstantString(const StringLiteral *SL) {
+ConstantAddress CGObjCCommonMac::GenerateConstantString(const StringRef *SL) {
   return (!CGM.getLangOpts().NoConstantCFStrings
             ? CGM.GetAddrOfConstantCFString(SL)
             : GenerateConstantNSString(SL));
@@ -1946,7 +1945,7 @@ CGObjCCommonMac::GenerateConstantString(const StringLiteral *SL) {
 
 static llvm::StringMapEntry &
 GetConstantStringEntry(llvm::StringMap &Map,
-                       const StringLiteral *Literal, unsigned &StringLength) {
+                       const StringRef *Literal, unsigned &StringLength) {
   StringRef String = Literal->getString();
   StringLength = String.size();
   return *Map.insert(std::make_pair(String, nullptr)).first;
@@ -1981,7 +1980,7 @@ llvm::Constant *CGObjCNonFragileABIMac::getNSConstantStringClassRef() {
 }
 
 ConstantAddress
-CGObjCCommonMac::GenerateConstantNSString(const StringLiteral *Literal) {
+CGObjCCommonMac::GenerateConstantNSString(const StringRef *Literal) {
   unsigned StringLength = 0;
   llvm::StringMapEntry &Entry =
     GetConstantStringEntry(NSConstantStringMap, Literal, StringLength);
diff --git a/clang/lib/CodeGen/CGObjCRuntime.h b/clang/lib/CodeGen/CGObjCRuntime.h
index 3bd981256f475..edbc664ec1bbb 100644
--- a/clang/lib/CodeGen/CGObjCRuntime.h
+++ b/clang/lib/CodeGen/CGObjCRuntime.h
@@ -148,7 +148,7 @@ class CGObjCRuntime {
   virtual CatchTypeInfo getCatchAllTypeInfo() { return { nullptr, 0 }; }
 
   /// Generate a constant string object.
-  virtual ConstantAddress GenerateConstantString(const StringLiteral *) = 0;
+  virtual ConstantAddress GenerateConstantString(const StringRef *) = 0;
 
   /// Generate a category.  A category contains a list of methods (and
   /// accompanying metadata) and a list of protocols.
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 1868b57cea903..70a63af1e07a1 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -2375,7 +2375,7 @@ void CGOpenMPRuntime::emitBarrierCall(CodeGenFunction &CGF, SourceLocation Loc,
 void CGOpenMPRuntime::emitErrorCall(CodeGenFunction &CGF, SourceLocation Loc,
                                     Expr *ME, bool IsFatal) {
   llvm::Value *MVL =
-      ME ? CGF.EmitStringLiteralLValue(cast(ME)).getPointer(CGF)
+      ME ? CGF.EmitStringLiteralLValue(cast(ME)).getPointer(CGF)
          : llvm::ConstantPointerNull::get(CGF.VoidPtrTy);
   // Build call void __kmpc_error(ident_t *loc, int severity, const char
   // *message)
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index c87ec899798aa..a51303b9c5b2a 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -2478,7 +2478,7 @@ CodeGenFunction::EmitAsmInput(const TargetInfo::ConstraintInfo &Info,
 /// asm call instruction.  The !srcloc MDNode contains a list of constant
 /// integers which are the source locations of the start of each line in the
 /// asm.
-static llvm::MDNode *getAsmSrcLocInfo(const StringLiteral *Str,
+static llvm::MDNode *getAsmSrcLocInfo(const StringRef *Str,
                                       CodeGenFunction &CGF) {
   SmallVector Locs;
   // Add the location of the first line to the MDNode.
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index 457e1477bb2ee..44faa17a9d10a 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -4344,7 +4344,7 @@ class CodeGenFunction : public CodeGenTypeCache {
   // Note: only available for agg return types
   LValue EmitVAArgExprLValue(const VAArgExpr *E);
   LValue EmitDeclRefLValue(const DeclRefExpr *E);
-  LValue EmitStringLiteralLValue(const StringLiteral *E);
+  LValue EmitStringLiteralLValue(const StringRef *E);
   LValue EmitObjCEncodeExprLValue(const ObjCEncodeExpr *E);
   LValue EmitPredefinedLValue(const PredefinedExpr *E);
   LValue EmitUnaryOpLValue(const UnaryOperator *E);
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 7db1ed72fa5cd..764056298aec5 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -6271,7 +6271,7 @@ llvm::Function *CodeGenModule::getIntrinsic(unsigned IID,
 
 static llvm::StringMapEntry &
 GetConstantCFStringEntry(llvm::StringMap &Map,
-                         const StringLiteral *Literal, bool TargetIsLSB,
+                         const StringRef *Literal, bool TargetIsLSB,
                          bool &IsUTF16, unsigned &StringLength) {
   StringRef String = Literal->getString();
   unsigned NumBytes = String.size();
@@ -6304,7 +6304,7 @@ GetConstantCFStringEntry(llvm::StringMap &Map,
 }
 
 ConstantAddress
-CodeGenModule::GetAddrOfConstantCFString(const StringLiteral *Literal) {
+CodeGenModule::GetAddrOfConstantCFString(const StringRef *Literal) {
   unsigned StringLength = 0;
   bool isUTF16 = false;
   llvm::StringMapEntry &Entry =
@@ -6525,7 +6525,7 @@ QualType CodeGenModule::getObjCFastEnumerationStateType() {
 }
 
 llvm::Constant *
-CodeGenModule::GetConstantArrayFromStringLiteral(const StringLiteral *E) {
+CodeGenModule::GetConstantArrayFromStringLiteral(const StringRef *E) {
   assert(!E->getType()->isPointerType() && "Strings are always arrays");
 
   // Don't emit it as the address of the string, emit the string data itself
@@ -6591,7 +6591,7 @@ GenerateStringLiteral(llvm::Constant *C, llvm::GlobalValue::LinkageTypes LT,
 /// GetAddrOfConstantStringFromLiteral - Return a pointer to a
 /// constant array for the given string literal.
 ConstantAddress
-CodeGenModule::GetAddrOfConstantStringFromLiteral(const StringLiteral *S,
+CodeGenModule::GetAddrOfConstantStringFromLiteral(const StringRef *S,
                                                   StringRef Name) {
   CharUnits Alignment =
       getContext().getAlignOfGlobalVarInChars(S->getType(), /*VD=*/nullptr);
diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h
index d5ef1a710eb40..6cc2638771298 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -68,7 +68,7 @@ class CharUnits;
 class Decl;
 class Expr;
 class Stmt;
-class StringLiteral;
+class StringRef;
 class NamedDecl;
 class PointerAuthSchema;
 class ValueDecl;
@@ -1151,15 +1151,14 @@ class CodeGenModule : public CodeGenTypeCache {
   void setAddrOfGlobalBlock(const BlockExpr *BE, llvm::Constant *Addr);
 
   /// Return a pointer to a constant CFString object for the given string.
-  ConstantAddress GetAddrOfConstantCFString(const StringLiteral *Literal);
+  ConstantAddress GetAddrOfConstantCFString(const StringRef *Literal);
 
   /// Return a constant array for the given string.
-  llvm::Constant *GetConstantArrayFromStringLiteral(const StringLiteral *E);
+  llvm::Constant *GetConstantArrayFromStringLiteral(const StringRef *E);
 
   /// Return a pointer to a constant array for the given string literal.
-  ConstantAddress
-  GetAddrOfConstantStringFromLiteral(const StringLiteral *S,
-                                     StringRef Name = ".str");
+  ConstantAddress GetAddrOfConstantStringFromLiteral(const StringRef *S,
+                                                     StringRef Name = ".str");
 
   /// Return a pointer to a constant array for the given ObjCEncodeExpr node.
   ConstantAddress
diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp b/clang/lib/Driver/ToolChains/BareMetal.cpp
index eecaaa9a42930..d4b235a02bd05 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -202,7 +202,7 @@ static void findMultilibsFromYAML(const ToolChain &TC, const Driver &D,
   Result.SelectedMultilibs.clear();
 }
 
-static constexpr llvm::StringLiteral MultilibFilename = "multilib.yaml";
+static constexpr llvm::StringRef MultilibFilename = "multilib.yaml";
 
 static std::optional>
 getMultilibConfigPath(const Driver &D, const llvm::Triple &Triple,
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index c4b5374d3fff9..c28ed8946b851 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2891,8 +2891,8 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
                                        ArgStringList &CmdArgs,
                                        const JobAction &JA) {
   // List of veclibs which when used with -fveclib imply -fno-math-errno.
-  constexpr std::array VecLibImpliesNoMathErrno{llvm::StringLiteral("ArmPL"),
-                                                llvm::StringLiteral("SLEEF")};
+  constexpr std::array VecLibImpliesNoMathErrno{llvm::StringRef("ArmPL"),
+                                                llvm::StringRef("SLEEF")};
   bool NoMathErrnoWasImpliedByVecLib = false;
   const Arg *VecLibArg = nullptr;
   // Track the arg (if any) that enabled errno after -fveclib for diagnostics.
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index f8967890f722c..8a2b66bf7a2e4 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1308,7 +1308,7 @@ void tools::addOpenMPHostOffloadingArgs(const Compilation &C,
 
   // For all the host OpenMP offloading compile jobs we need to pass the targets
   // information using -fopenmp-targets= option.
-  constexpr llvm::StringLiteral Targets("-fopenmp-targets=");
+  constexpr llvm::StringRef Targets("-fopenmp-targets=");
 
   SmallVector Triples;
   auto TCRange = C.getOffloadToolChains();
diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp
index e5dffb11d1a5e..7a9ddd7efbbf5 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1216,8 +1216,7 @@ void DarwinClang::addClangWarningOptions(ArgStringList &CC1Args) const {
 /// `XCODE/Contents/Developer` path if it is an Xcode path, or an empty path
 /// otherwise.
 static StringRef getXcodeDeveloperPath(StringRef PathIntoXcode) {
-  static constexpr llvm::StringLiteral XcodeAppSuffix(
-      ".app/Contents/Developer");
+  static constexpr llvm::StringRef XcodeAppSuffix(".app/Contents/Developer");
   size_t Index = PathIntoXcode.find(XcodeAppSuffix);
   if (Index == StringRef::npos)
     return "";
diff --git a/clang/lib/Edit/RewriteObjCFoundationAPI.cpp b/clang/lib/Edit/RewriteObjCFoundationAPI.cpp
index 81797c8c4dc75..595ec97631c8f 100644
--- a/clang/lib/Edit/RewriteObjCFoundationAPI.cpp
+++ b/clang/lib/Edit/RewriteObjCFoundationAPI.cpp
@@ -1137,8 +1137,7 @@ static bool doRewriteToUTF8StringBoxedExpressionHelper(
   if (OrigTy->isArrayType())
     OrigTy = Ctx.getArrayDecayedType(OrigTy);
 
-  if (const StringLiteral *
-        StrE = dyn_cast(OrigArg->IgnoreParens())) {
+  if (const StringRef *StrE = dyn_cast(OrigArg->IgnoreParens())) {
     commit.replaceWithInner(Msg->getSourceRange(), StrE->getSourceRange());
     commit.insert(StrE->getBeginLoc(), "@");
     return true;
diff --git a/clang/lib/ExtractAPI/DeclarationFragments.cpp b/clang/lib/ExtractAPI/DeclarationFragments.cpp
index 66c03863293c2..7f88b77a6618b 100644
--- a/clang/lib/ExtractAPI/DeclarationFragments.cpp
+++ b/clang/lib/ExtractAPI/DeclarationFragments.cpp
@@ -112,7 +112,7 @@ StringRef DeclarationFragments::getFragmentKindString(
     return "attribute";
   case DeclarationFragments::FragmentKind::NumberLiteral:
     return "number";
-  case DeclarationFragments::FragmentKind::StringLiteral:
+  case DeclarationFragments::FragmentKind::StringRef:
     return "string";
   case DeclarationFragments::FragmentKind::Identifier:
     return "identifier";
@@ -137,7 +137,7 @@ DeclarationFragments::parseFragmentKindFromString(StringRef S) {
       .Case("keyword", DeclarationFragments::FragmentKind::Keyword)
       .Case("attribute", DeclarationFragments::FragmentKind::Attribute)
       .Case("number", DeclarationFragments::FragmentKind::NumberLiteral)
-      .Case("string", DeclarationFragments::FragmentKind::StringLiteral)
+      .Case("string", DeclarationFragments::FragmentKind::StringRef)
       .Case("identifier", DeclarationFragments::FragmentKind::Identifier)
       .Case("typeIdentifier",
             DeclarationFragments::FragmentKind::TypeIdentifier)
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index fc60c5ec5eebc..031db223fe435 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -2928,7 +2928,7 @@ class ObjCHeaderStyleGuesser : public TokenAnalyzer {
               const SmallVectorImpl &AnnotatedLines,
               const AdditionalKeywords &Keywords) {
     // Keep this array sorted, since we are binary searching over it.
-    static constexpr llvm::StringLiteral FoundationIdentifiers[] = {
+    static constexpr llvm::StringRef FoundationIdentifiers[] = {
         "CGFloat",
         "CGPoint",
         "CGPointMake",
diff --git a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
index 8cdb463e2c99f..ee75d15759dd3 100644
--- a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
+++ b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
@@ -595,12 +595,12 @@ namespace {
       return OD->getClassMethod(LoadSel) != nullptr;
     }
 
-    StringLiteral *getStringLiteral(StringRef Str) {
+    StringRef *getStringLiteral(StringRef Str) {
       QualType StrType = Context->getConstantArrayType(
           Context->CharTy, llvm::APInt(32, Str.size() + 1), nullptr,
           ArraySizeModifier::Normal, 0);
-      return StringLiteral::Create(*Context, Str, StringLiteralKind::Ordinary,
-                                   /*Pascal=*/false, StrType, SourceLocation());
+      return StringRef::Create(*Context, Str, StringLiteralKind::Ordinary,
+                               /*Pascal=*/false, StrType, SourceLocation());
     }
   };
 } // end anonymous namespace
@@ -2575,7 +2575,7 @@ Stmt *RewriteModernObjC::RewriteObjCStringLiteral(ObjCStringLiteral *Exp) {
   Preamble += "static __NSConstantStringImpl " + S;
   Preamble += " __attribute__ ((section (\"__DATA, __cfstring\"))) = {__CFConstantStringClassReference,";
   Preamble += "0x000007c8,"; // utf8_str
-  // The pretty printer for StringLiteral handles escape characters properly.
+  // The pretty printer for StringRef handles escape characters properly.
   std::string prettyBufS;
   llvm::raw_string_ostream prettyBuf(prettyBufS);
   Exp->getString()->printPretty(prettyBuf, nullptr, PrintingPolicy(LangOpts));
diff --git a/clang/lib/Frontend/Rewrite/RewriteObjC.cpp b/clang/lib/Frontend/Rewrite/RewriteObjC.cpp
index f49ccf7be68e2..204eccf6a4c63 100644
--- a/clang/lib/Frontend/Rewrite/RewriteObjC.cpp
+++ b/clang/lib/Frontend/Rewrite/RewriteObjC.cpp
@@ -494,12 +494,12 @@ namespace {
                                     SourceLocation(), SourceLocation());
     }
 
-    StringLiteral *getStringLiteral(StringRef Str) {
+    StringRef *getStringLiteral(StringRef Str) {
       QualType StrType = Context->getConstantArrayType(
           Context->CharTy, llvm::APInt(32, Str.size() + 1), nullptr,
           ArraySizeModifier::Normal, 0);
-      return StringLiteral::Create(*Context, Str, StringLiteralKind::Ordinary,
-                                   /*Pascal=*/false, StrType, SourceLocation());
+      return StringRef::Create(*Context, Str, StringLiteralKind::Ordinary,
+                               /*Pascal=*/false, StrType, SourceLocation());
     }
   };
 
@@ -2501,7 +2501,7 @@ Stmt *RewriteObjC::RewriteObjCStringLiteral(ObjCStringLiteral *Exp) {
   Preamble += "static __NSConstantStringImpl " + S;
   Preamble += " __attribute__ ((section (\"__DATA, __cfstring\"))) = {__CFConstantStringClassReference,";
   Preamble += "0x000007c8,"; // utf8_str
-  // The pretty printer for StringLiteral handles escape characters properly.
+  // The pretty printer for StringRef handles escape characters properly.
   std::string prettyBufS;
   llvm::raw_string_ostream prettyBuf(prettyBufS);
   Exp->getString()->printPretty(prettyBuf, nullptr, PrintingPolicy(LangOpts));
diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index ccf94f6345ff2..e99cdcd83d450 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -1486,7 +1486,7 @@ namespace clang {
       UseKeyword,
       RequiresKeyword,
       Star,
-      StringLiteral,
+      StringRef,
       IntegerLiteral,
       TextualKeyword,
       LBrace,
@@ -1705,18 +1705,18 @@ SourceLocation ModuleMapParser::consumeToken() {
 
     // Parse the string literal.
     LangOptions LangOpts;
-    StringLiteralParser StringLiteral(LToken, SourceMgr, LangOpts, *Target);
-    if (StringLiteral.hadError)
+    StringLiteralParser StringRef(LToken, SourceMgr, LangOpts, *Target);
+    if (StringRef.hadError)
       goto retry;
 
     // Copy the string literal into our string data allocator.
-    unsigned Length = StringLiteral.GetStringLength();
+    unsigned Length = StringRef.GetStringLength();
     char *Saved = StringData.Allocate(Length + 1);
-    memcpy(Saved, StringLiteral.GetString().data(), Length);
+    memcpy(Saved, StringRef.GetString().data(), Length);
     Saved[Length] = 0;
 
     // Form the token.
-    Tok.Kind = MMToken::StringLiteral;
+    Tok.Kind = MMToken::StringRef;
     Tok.StringData = Saved;
     Tok.StringLength = Length;
     break;
@@ -1828,7 +1828,7 @@ void ModuleMapParser::skipUntil(MMToken::TokenKind K) {
 bool ModuleMapParser::parseModuleId(ModuleId &Id) {
   Id.clear();
   do {
-    if (Tok.is(MMToken::Identifier) || Tok.is(MMToken::StringLiteral)) {
+    if (Tok.is(MMToken::Identifier) || Tok.is(MMToken::StringRef)) {
       Id.push_back(
           std::make_pair(std::string(Tok.getString()), Tok.getLocation()));
       consumeToken();
@@ -2290,7 +2290,7 @@ void ModuleMapParser::parseExternModuleDecl() {
   }
 
   // Parse the referenced module map file name.
-  if (!Tok.is(MMToken::StringLiteral)) {
+  if (!Tok.is(MMToken::StringRef)) {
     Diags.Report(Tok.getLocation(), diag::err_mmap_expected_mmap_file);
     HadError = true;
     return;
@@ -2445,7 +2445,7 @@ void ModuleMapParser::parseHeaderDecl(MMToken::TokenKind LeadingToken,
   }
 
   // Parse the header name.
-  if (!Tok.is(MMToken::StringLiteral)) {
+  if (!Tok.is(MMToken::StringRef)) {
     Diags.Report(Tok.getLocation(), diag::err_mmap_expected_header)
       << "header";
     HadError = true;
@@ -2547,7 +2547,7 @@ static bool compareModuleHeaders(const Module::Header &A,
 ///     umbrella string-literal
 void ModuleMapParser::parseUmbrellaDirDecl(SourceLocation UmbrellaLoc) {
   // Parse the directory name.
-  if (!Tok.is(MMToken::StringLiteral)) {
+  if (!Tok.is(MMToken::StringRef)) {
     Diags.Report(Tok.getLocation(), diag::err_mmap_expected_header)
       << "umbrella";
     HadError = true;
@@ -2737,7 +2737,7 @@ void ModuleMapParser::parseLinkDecl() {
   }
 
   // Parse the library name
-  if (!Tok.is(MMToken::StringLiteral)) {
+  if (!Tok.is(MMToken::StringRef)) {
     Diags.Report(Tok.getLocation(), diag::err_mmap_expected_library_name)
       << IsFramework << SourceRange(LinkLoc);
     HadError = true;
@@ -2845,7 +2845,7 @@ void ModuleMapParser::parseConflict() {
   consumeToken();
 
   // Parse the message.
-  if (!Tok.is(MMToken::StringLiteral)) {
+  if (!Tok.is(MMToken::StringRef)) {
     Diags.Report(Tok.getLocation(), diag::err_mmap_expected_conflicts_message)
       << formatModuleId(Conflict.Id);
     return;
@@ -3120,7 +3120,7 @@ bool ModuleMapParser::parseModuleMapFile() {
     case MMToken::RSquare:
     case MMToken::RequiresKeyword:
     case MMToken::Star:
-    case MMToken::StringLiteral:
+    case MMToken::StringRef:
     case MMToken::IntegerLiteral:
     case MMToken::TextualKeyword:
     case MMToken::UmbrellaKeyword:
diff --git a/clang/lib/Parse/ParseCXXInlineMethods.cpp b/clang/lib/Parse/ParseCXXInlineMethods.cpp
index 6c01af55ef3c4..ca5041d2fe634 100644
--- a/clang/lib/Parse/ParseCXXInlineMethods.cpp
+++ b/clang/lib/Parse/ParseCXXInlineMethods.cpp
@@ -21,17 +21,17 @@
 using namespace clang;
 
 /// Parse the optional ("message") part of a deleted-function-body.
-StringLiteral *Parser::ParseCXXDeletedFunctionMessage() {
+StringRef *Parser::ParseCXXDeletedFunctionMessage() {
   if (!Tok.is(tok::l_paren))
     return nullptr;
-  StringLiteral *Message = nullptr;
+  StringRef *Message = nullptr;
   BalancedDelimiterTracker BT{*this, tok::l_paren};
   BT.consumeOpen();
 
   if (isTokenStringLiteral()) {
     ExprResult Res = ParseUnevaluatedStringLiteralExpression();
     if (Res.isUsable()) {
-      Message = Res.getAs();
+      Message = Res.getAs();
       Diag(Message->getBeginLoc(), getLangOpts().CPlusPlus26
                                        ? diag::warn_cxx23_delete_with_message
                                        : diag::ext_delete_with_message)
@@ -113,7 +113,7 @@ NamedDecl *Parser::ParseCXXInlineMethodDef(
                       ? diag::warn_cxx98_compat_defaulted_deleted_function
                       : diag::ext_defaulted_deleted_function)
         << 1 /* deleted */;
-      StringLiteral *Message = ParseCXXDeletedFunctionMessage();
+      StringRef *Message = ParseCXXDeletedFunctionMessage();
       Actions.SetDeclDeleted(FnD, KWLoc, Message);
       Delete = true;
       if (auto *DeclAsFunction = dyn_cast(FnD)) {
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index fddb8a5729ee8..6dbfa2d51cbb4 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -1006,7 +1006,7 @@ static FixItHint getStaticAssertNoMessageFixIt(const Expr *AssertExpr,
                                                SourceLocation EndExprLoc) {
   if (const auto *BO = dyn_cast_or_null(AssertExpr)) {
     if (BO->getOpcode() == BO_LAnd &&
-        isa(BO->getRHS()->IgnoreImpCasts()))
+        isa(BO->getRHS()->IgnoreImpCasts()))
       return FixItHint::CreateReplacement(BO->getOperatorLoc(), ",");
   }
   return FixItHint::CreateInsertion(EndExprLoc, ", \"\"");
@@ -5194,8 +5194,8 @@ void Parser::ParseMicrosoftUuidAttributeArgs(ParsedAttributes &Attrs) {
     Toks[0].setLocation(StartLoc);
     Toks[0].setLiteralData(StrBuffer.data());
     Toks[0].setLength(StrBuffer.size());
-    StringLiteral *UuidString =
-        cast(Actions.ActOnUnevaluatedStringLiteral(Toks).get());
+    StringRef *UuidString =
+        cast(Actions.ActOnUnevaluatedStringLiteral(Toks).get());
     ArgExprs.push_back(UuidString);
   }
 
diff --git a/clang/lib/Parse/ParseInit.cpp b/clang/lib/Parse/ParseInit.cpp
index 63b1d7bd9db53..d78f26fa81dd6 100644
--- a/clang/lib/Parse/ParseInit.cpp
+++ b/clang/lib/Parse/ParseInit.cpp
@@ -445,11 +445,11 @@ ExprResult Parser::createEmbedExpr() {
           Context.MakeIntValue(Str.size(), Context.getSizeType());
       QualType ArrayTy = Context.getConstantArrayType(
           Ty, ArraySize, nullptr, ArraySizeModifier::Normal, 0);
-      return StringLiteral::Create(Context, Str, StringLiteralKind::Ordinary,
-                                   false, ArrayTy, StartLoc);
+      return StringRef::Create(Context, Str, StringLiteralKind::Ordinary, false,
+                               ArrayTy, StartLoc);
     };
 
-    StringLiteral *BinaryDataArg = CreateStringLiteralFromStringRef(
+    StringRef *BinaryDataArg = CreateStringLiteralFromStringRef(
         Data->BinaryData, Context.UnsignedCharTy);
     Res = Actions.ActOnEmbedExpr(StartLoc, BinaryDataArg);
   }
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index b4e973bc84a7b..785a06b5bda81 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -842,7 +842,7 @@ enum OMPContextLvl {
 
 static StringRef stringLiteralParser(Parser &P) {
   ExprResult Res = P.ParseStringLiteralExpression(true);
-  return Res.isUsable() ? Res.getAs()->getString() : "";
+  return Res.isUsable() ? Res.getAs()->getString() : "";
 }
 
 static StringRef getNameFromIdOrString(Parser &P, Token &Tok,
diff --git a/clang/lib/Parse/ParsePragma.cpp b/clang/lib/Parse/ParsePragma.cpp
index 21ebff1e50559..d37957d4b7044 100644
--- a/clang/lib/Parse/ParsePragma.cpp
+++ b/clang/lib/Parse/ParsePragma.cpp
@@ -1079,7 +1079,7 @@ bool Parser::HandlePragmaMSSection(StringRef PragmaName,
   ExprResult StringResult = ParseStringLiteralExpression();
   if (StringResult.isInvalid())
     return false; // Already diagnosed.
-  StringLiteral *SegmentName = cast(StringResult.get());
+  StringRef *SegmentName = cast(StringResult.get());
   if (SegmentName->getCharByteWidth() != 1) {
     PP.Diag(PragmaLocation, diag::warn_pragma_expected_non_wide_string)
         << PragmaName;
@@ -1188,7 +1188,7 @@ bool Parser::HandlePragmaMSSegment(StringRef PragmaName,
     }
   }
   // Grab the string literal for our section name.
-  StringLiteral *SegmentName = nullptr;
+  StringRef *SegmentName = nullptr;
   if (Tok.isNot(tok::r_paren)) {
     if (Tok.isNot(tok::string_literal)) {
       unsigned DiagID = Action != Sema::PSK_Reset ? !SlotLabel.empty() ?
@@ -1201,7 +1201,7 @@ bool Parser::HandlePragmaMSSegment(StringRef PragmaName,
     ExprResult StringResult = ParseStringLiteralExpression();
     if (StringResult.isInvalid())
       return false; // Already diagnosed.
-    SegmentName = cast(StringResult.get());
+    SegmentName = cast(StringResult.get());
     if (SegmentName->getCharByteWidth() != 1) {
       PP.Diag(PragmaLocation, diag::warn_pragma_expected_non_wide_string)
           << PragmaName;
@@ -1240,7 +1240,7 @@ bool Parser::HandlePragmaMSInitSeg(StringRef PragmaName,
     return false;
 
   // Parse either the known section names or the string section name.
-  StringLiteral *SegmentName = nullptr;
+  StringRef *SegmentName = nullptr;
   if (Tok.isAnyIdentifier()) {
     auto *II = Tok.getIdentifierInfo();
     StringRef Section = llvm::StringSwitch(II->getName())
@@ -1258,14 +1258,14 @@ bool Parser::HandlePragmaMSInitSeg(StringRef PragmaName,
       Toks[0].setLiteralData(Section.data());
       Toks[0].setLength(Section.size());
       SegmentName =
-          cast(Actions.ActOnStringLiteral(Toks, nullptr).get());
+          cast(Actions.ActOnStringLiteral(Toks, nullptr).get());
       PP.Lex(Tok);
     }
   } else if (Tok.is(tok::string_literal)) {
     ExprResult StringResult = ParseStringLiteralExpression();
     if (StringResult.isInvalid())
       return false;
-    SegmentName = cast(StringResult.get());
+    SegmentName = cast(StringResult.get());
     if (SegmentName->getCharByteWidth() != 1) {
       PP.Diag(PragmaLocation, diag::warn_pragma_expected_non_wide_string)
           << PragmaName;
@@ -1354,7 +1354,7 @@ bool Parser::HandlePragmaMSAllocText(StringRef PragmaName,
     ExprResult StringResult = ParseStringLiteralExpression();
     if (StringResult.isInvalid())
       return false; // Already diagnosed.
-    StringLiteral *SegmentName = cast(StringResult.get());
+    StringRef *SegmentName = cast(StringResult.get());
     if (SegmentName->getCharByteWidth() != 1) {
       PP.Diag(PragmaLocation, diag::warn_pragma_expected_non_wide_string)
           << PragmaName;
@@ -3873,7 +3873,7 @@ bool Parser::HandlePragmaMSOptimize(StringRef PragmaName,
   ExprResult StringResult = ParseStringLiteralExpression();
   if (StringResult.isInvalid())
     return false; // Already diagnosed.
-  StringLiteral *OptimizationList = cast(StringResult.get());
+  StringRef *OptimizationList = cast(StringResult.get());
   if (OptimizationList->getCharByteWidth() != 1) {
     PP.Diag(PragmaLocation, diag::warn_pragma_expected_non_wide_string)
         << PragmaName;
diff --git a/clang/lib/Parse/ParseStmtAsm.cpp b/clang/lib/Parse/ParseStmtAsm.cpp
index 04c3a8700c10c..978b98353ea6c 100644
--- a/clang/lib/Parse/ParseStmtAsm.cpp
+++ b/clang/lib/Parse/ParseStmtAsm.cpp
@@ -743,7 +743,7 @@ StmtResult Parser::ParseAsmStatement(bool &msAsm) {
   // Check if GNU-style InlineAsm is disabled.
   // Error on anything other than empty string.
   if (!(getLangOpts().GNUAsm || AsmString.isInvalid())) {
-    const auto *SL = cast(AsmString.get());
+    const auto *SL = cast(AsmString.get());
     if (!SL->getString().trim().empty())
       Diag(Loc, diag::err_gnu_inline_asm_disabled);
   }
diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp
index 0710542f5e938..6a705d22c5f05 100644
--- a/clang/lib/Parse/Parser.cpp
+++ b/clang/lib/Parse/Parser.cpp
@@ -912,7 +912,7 @@ Parser::ParseExternalDeclaration(ParsedAttributes &Attrs,
     // Empty asm string is allowed because it will not introduce
     // any assembly code.
     if (!(getLangOpts().GNUAsm || Result.isInvalid())) {
-      const auto *SL = cast(Result.get());
+      const auto *SL = cast(Result.get());
       if (!SL->getString().trim().empty())
         Diag(StartLoc, diag::err_gnu_inline_asm_disabled);
     }
@@ -1401,7 +1401,7 @@ Decl *Parser::ParseFunctionDefinition(ParsingDeclarator &D,
 
   // Parse function body eagerly if it is either '= delete;' or '= default;' as
   // ActOnStartOfFunctionDef needs to know whether the function is deleted.
-  StringLiteral *DeletedMessage = nullptr;
+  StringRef *DeletedMessage = nullptr;
   Sema::FnBodyKind BodyKind = Sema::FnBodyKind::Other;
   SourceLocation KWLoc;
   if (TryConsumeToken(tok::equal)) {
@@ -1676,7 +1676,7 @@ ExprResult Parser::ParseAsmStringLiteral(bool ForAsmLabel) {
 
   ExprResult AsmString(ParseStringLiteralExpression());
   if (!AsmString.isInvalid()) {
-    const auto *SL = cast(AsmString.get());
+    const auto *SL = cast(AsmString.get());
     if (!SL->isOrdinary()) {
       Diag(Tok, diag::err_asm_operand_wide_string_literal)
         << SL->isWide()
diff --git a/clang/lib/Sema/SemaARM.cpp b/clang/lib/Sema/SemaARM.cpp
index 411baa066f709..f6495e714abff 100644
--- a/clang/lib/Sema/SemaARM.cpp
+++ b/clang/lib/Sema/SemaARM.cpp
@@ -210,12 +210,12 @@ bool SemaARM::BuiltinARMSpecialReg(unsigned BuiltinID, CallExpr *TheCall,
     return false;
 
   // Check if the argument is a string literal.
-  if (!isa(Arg->IgnoreParenImpCasts()))
+  if (!isa(Arg->IgnoreParenImpCasts()))
     return Diag(TheCall->getBeginLoc(), diag::err_expr_not_string_literal)
            << Arg->getSourceRange();
 
   // Check the type of special register given.
-  StringRef Reg = cast(Arg->IgnoreParenImpCasts())->getString();
+  StringRef Reg = cast(Arg->IgnoreParenImpCasts())->getString();
   SmallVector Fields;
   Reg.split(Fields, ":");
 
diff --git a/clang/lib/Sema/SemaAttr.cpp b/clang/lib/Sema/SemaAttr.cpp
index 6907fa91e28c2..12e40bc57eeca 100644
--- a/clang/lib/Sema/SemaAttr.cpp
+++ b/clang/lib/Sema/SemaAttr.cpp
@@ -844,14 +844,14 @@ bool Sema::UnifySection(StringRef SectionName,
 void Sema::ActOnPragmaMSSeg(SourceLocation PragmaLocation,
                             PragmaMsStackAction Action,
                             llvm::StringRef StackSlotLabel,
-                            StringLiteral *SegmentName,
+                            StringRef *SegmentName,
                             llvm::StringRef PragmaName) {
-  PragmaStack *Stack =
-    llvm::StringSwitch *>(PragmaName)
-        .Case("data_seg", &DataSegStack)
-        .Case("bss_seg", &BSSSegStack)
-        .Case("const_seg", &ConstSegStack)
-        .Case("code_seg", &CodeSegStack);
+  PragmaStack *Stack =
+      llvm::StringSwitch *>(PragmaName)
+          .Case("data_seg", &DataSegStack)
+          .Case("bss_seg", &BSSSegStack)
+          .Case("const_seg", &ConstSegStack)
+          .Case("code_seg", &CodeSegStack);
   if (Action & PSK_Pop && Stack->Stack.empty())
     Diag(PragmaLocation, diag::warn_pragma_pop_failed) << PragmaName
         << "stack empty";
@@ -879,13 +879,13 @@ void Sema::ActOnPragmaMSStrictGuardStackCheck(SourceLocation PragmaLocation,
 }
 
 /// Called on well formed \#pragma bss_seg().
-void Sema::ActOnPragmaMSSection(SourceLocation PragmaLocation,
-                                int SectionFlags, StringLiteral *SegmentName) {
+void Sema::ActOnPragmaMSSection(SourceLocation PragmaLocation, int SectionFlags,
+                                StringRef *SegmentName) {
   UnifySection(SegmentName->getString(), SectionFlags, PragmaLocation);
 }
 
 void Sema::ActOnPragmaMSInitSeg(SourceLocation PragmaLocation,
-                                StringLiteral *SegmentName) {
+                                StringRef *SegmentName) {
   // There's no stack to maintain, so we just have a current section.  When we
   // see the default section, reset our current section back to null so we stop
   // tacking on unnecessary attributes.
diff --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp
index f98857f852b5a..57c1e4bc36b64 100644
--- a/clang/lib/Sema/SemaCast.cpp
+++ b/clang/lib/Sema/SemaCast.cpp
@@ -504,7 +504,7 @@ static bool tryDiagnoseOverloadedCast(Sema &S, CastType CT,
         candidates.BestViableFunction(S, range.getBegin(), Best);
     assert(Res == OR_Deleted && "Inconsistent overload resolution");
 
-    StringLiteral *Msg = Best->Function->getDeletedMessage();
+    StringRef *Msg = Best->Function->getDeletedMessage();
     candidates.NoteCandidates(
         PartialDiagnosticAt(range.getBegin(),
                             S.PDiag(diag::err_ovl_deleted_conversion_in_cast)
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 28dcfaac2e84f..67b8c6f460cc0 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -115,7 +115,7 @@
 using namespace clang;
 using namespace sema;
 
-SourceLocation Sema::getLocationOfStringLiteralByte(const StringLiteral *SL,
+SourceLocation Sema::getLocationOfStringLiteralByte(const StringRef *SL,
                                                     unsigned ByteNo) const {
   return SL->getLocationOfByte(ByteNo, getSourceManager(), LangOpts,
                                Context.getTargetInfo());
@@ -227,7 +227,7 @@ static bool BuiltinAnnotation(Sema &S, CallExpr *TheCall) {
 
   // Second argument should be a constant string.
   Expr *StrArg = TheCall->getArg(1)->IgnoreParenCasts();
-  StringLiteral *Literal = dyn_cast(StrArg);
+  StringRef *Literal = dyn_cast(StrArg);
   if (!Literal || !Literal->isOrdinary()) {
     S.Diag(StrArg->getBeginLoc(), diag::err_builtin_annotation_second_arg)
         << StrArg->getSourceRange();
@@ -249,7 +249,7 @@ static bool BuiltinMSVCAnnotation(Sema &S, CallExpr *TheCall) {
 
   // All arguments should be wide string literals.
   for (Expr *Arg : TheCall->arguments()) {
-    auto *Literal = dyn_cast(Arg->IgnoreParenCasts());
+    auto *Literal = dyn_cast(Arg->IgnoreParenCasts());
     if (!Literal || !Literal->isWide()) {
       S.Diag(Arg->getBeginLoc(), diag::err_msvc_annotation_wide_str)
           << Arg->getSourceRange();
@@ -1116,7 +1116,7 @@ class EstimateSizeFormatHandler
 static bool ProcessFormatStringLiteral(const Expr *FormatExpr,
                                        StringRef &FormatStrRef, size_t &StrLen,
                                        ASTContext &Context) {
-  if (const auto *Format = dyn_cast(FormatExpr);
+  if (const auto *Format = dyn_cast(FormatExpr);
       Format && (Format->isOrdinary() || Format->isUTF8())) {
     FormatStrRef = Format->getString();
     const ConstantArrayType *T =
@@ -1769,7 +1769,7 @@ static ExprResult PointerAuthStringDiscriminator(Sema &S, CallExpr *Call) {
   const Expr *Arg = Call->getArg(0)->IgnoreParenImpCasts();
 
   // Operand must be an ordinary or UTF-8 string literal.
-  const auto *Literal = dyn_cast(Arg);
+  const auto *Literal = dyn_cast(Arg);
   if (!Literal || Literal->getCharByteWidth() != 1) {
     S.Diag(Arg->getExprLoc(), diag::err_ptrauth_string_not_literal)
         << (Literal ? 1 : 0) << Arg->getSourceRange();
@@ -2021,12 +2021,12 @@ static bool BuiltinCpu(Sema &S, const TargetInfo &TI, CallExpr *TheCall,
 
   Expr *Arg = TheCall->getArg(0)->IgnoreParenImpCasts();
   // Check if the argument is a string literal.
-  if (!isa(Arg))
+  if (!isa(Arg))
     return S.Diag(TheCall->getBeginLoc(), diag::err_expr_not_string_literal)
            << Arg->getSourceRange();
 
   // Check the contents of the string.
-  StringRef Feature = cast(Arg)->getString();
+  StringRef Feature = cast(Arg)->getString();
   if (IsCPUSupports && !TheTI->validateCpuSupports(Feature)) {
     S.Diag(TheCall->getBeginLoc(), diag::warn_invalid_cpu_supports)
         << Arg->getSourceRange();
@@ -2963,7 +2963,7 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
   case Builtin::BI__builtin_allow_runtime_check: {
     Expr *Arg = TheCall->getArg(0);
     // Check if the argument is a string literal.
-    if (!isa(Arg->IgnoreParenImpCasts())) {
+    if (!isa(Arg->IgnoreParenImpCasts())) {
       Diag(TheCall->getBeginLoc(), diag::err_expr_not_string_literal)
           << Arg->getSourceRange();
       return ExprError();
@@ -4688,7 +4688,7 @@ ExprResult Sema::BuiltinNontemporalOverloaded(ExprResult TheCallResult) {
 /// and os_trace() functions is correct, and converts it to const char *.
 ExprResult Sema::CheckOSLogFormatStringArg(Expr *Arg) {
   Arg = Arg->IgnoreParenCasts();
-  auto *Literal = dyn_cast(Arg);
+  auto *Literal = dyn_cast(Arg);
   if (!Literal) {
     if (auto *ObjcLiteral = dyn_cast(Arg)) {
       Literal = ObjcLiteral->getString();
@@ -5813,23 +5813,21 @@ static void sumOffsets(llvm::APSInt &Offset, llvm::APSInt Addend,
 
 namespace {
 
-// This is a wrapper class around StringLiteral to support offsetted string
+// This is a wrapper class around StringRef to support offsetted string
 // literals as format strings. It takes the offset into account when returning
 // the string and its length or the source locations to display notes correctly.
 class FormatStringLiteral {
-  const StringLiteral *FExpr;
+  const StringRef *FExpr;
   int64_t Offset;
 
  public:
-  FormatStringLiteral(const StringLiteral *fexpr, int64_t Offset = 0)
-      : FExpr(fexpr), Offset(Offset) {}
+   FormatStringLiteral(const StringRef *fexpr, int64_t Offset = 0)
+       : FExpr(fexpr), Offset(Offset) {}
 
-  StringRef getString() const {
-    return FExpr->getString().drop_front(Offset);
-  }
+   StringRef getString() const { return FExpr->getString().drop_front(Offset); }
 
-  unsigned getByteLength() const {
-    return FExpr->getByteLength() - getCharByteWidth() * Offset;
+   unsigned getByteLength() const {
+     return FExpr->getByteLength() - getCharByteWidth() * Offset;
   }
 
   unsigned getLength() const { return FExpr->getLength() - Offset; }
@@ -6161,12 +6159,12 @@ checkFormatStringExpr(Sema &S, const Expr *E, ArrayRef Args,
   }
   case Stmt::ObjCStringLiteralClass:
   case Stmt::StringLiteralClass: {
-    const StringLiteral *StrE = nullptr;
+    const StringRef *StrE = nullptr;
 
     if (const ObjCStringLiteral *ObjCFExpr = dyn_cast(E))
       StrE = ObjCFExpr->getString();
     else
-      StrE = cast(E);
+      StrE = cast(E);
 
     if (StrE) {
       if (Offset.isNegative() || Offset > StrE->getLength()) {
@@ -6240,14 +6238,14 @@ checkFormatStringExpr(Sema &S, const Expr *E, ArrayRef Args,
 }
 
 // If this expression can be evaluated at compile-time,
-// check if the result is a StringLiteral and return it
+// check if the result is a StringRef and return it
 // otherwise return nullptr
 static const Expr *maybeConstEvalStringLiteral(ASTContext &Context,
                                                const Expr *E) {
   Expr::EvalResult Result;
   if (E->EvaluateAsRValue(Result, Context) && Result.Val.isLValue()) {
     const auto *LVE = Result.Val.getLValueBase().dyn_cast();
-    if (isa_and_nonnull(LVE))
+    if (isa_and_nonnull(LVE))
       return LVE;
   }
   return nullptr;
@@ -8115,7 +8113,7 @@ static void CheckFormatString(
   } // TODO: handle other formats
 }
 
-bool Sema::FormatStringHasSArg(const StringLiteral *FExpr) {
+bool Sema::FormatStringHasSArg(const StringRef *FExpr) {
   // Str - The format string.  NOTE: this is NOT null-terminated!
   StringRef StrRef = FExpr->getString();
   const char *Str = StrRef.data();
@@ -11077,7 +11075,7 @@ void Sema::CheckImplicitConversion(Expr *E, QualType T, SourceLocation CC,
 
   // Diagnose implicit casts to bool.
   if (Target->isSpecificBuiltinType(BuiltinType::Bool)) {
-    if (isa(E))
+    if (isa(E))
       // Warn on string literal to bool.  Checks for string literals in logical
       // and expressions, for instance, assert(0 && "error here"), are
       // prevented by a check in AnalyzeImplicitConversions().
@@ -11764,7 +11762,7 @@ static void AnalyzeImplicitConversions(
         continue;
 
     if (IsLogicalAndOperator &&
-        isa(ChildExpr->IgnoreParenImpCasts()))
+        isa(ChildExpr->IgnoreParenImpCasts()))
       // Ignore checking string literals that are in logical and operators.
       // This is a common pattern for asserts.
       continue;
@@ -11773,11 +11771,11 @@ static void AnalyzeImplicitConversions(
 
   if (BO && BO->isLogicalOp()) {
     Expr *SubExpr = BO->getLHS()->IgnoreParenImpCasts();
-    if (!IsLogicalAndOperator || !isa(SubExpr))
+    if (!IsLogicalAndOperator || !isa(SubExpr))
       ::CheckBoolLikeConversion(S, SubExpr, BO->getExprLoc());
 
     SubExpr = BO->getRHS()->IgnoreParenImpCasts();
-    if (!IsLogicalAndOperator || !isa(SubExpr))
+    if (!IsLogicalAndOperator || !isa(SubExpr))
       ::CheckBoolLikeConversion(S, SubExpr, BO->getExprLoc());
   }
 
diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp
index 1f398bb004fa3..90d3ddbe481ad 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -4946,7 +4946,7 @@ static void AddLambdaCompletion(ResultBuilder &Results,
       else
         First = false;
 
-      constexpr llvm::StringLiteral NamePlaceholder = "!#!NAME_GOES_HERE!#!";
+      constexpr llvm::StringRef NamePlaceholder = "!#!NAME_GOES_HERE!#!";
       std::string Type = std::string(NamePlaceholder);
       Parameter.getAsStringInternal(Type, PrintingPolicy(LangOpts));
       llvm::StringRef Prefix, Suffix;
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 4001c4d263f1d..5e5f245addd9d 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -7965,7 +7965,7 @@ NamedDecl *Sema::ActOnVariableDeclarator(
   // Handle GNU asm-label extension (encoded as an attribute).
   if (Expr *E = (Expr*)D.getAsmLabel()) {
     // The parser guarantees this is a string.
-    StringLiteral *SE = cast(E);
+    StringRef *SE = cast(E);
     StringRef Label = SE->getString();
     if (S->getFnParent() != nullptr) {
       switch (SC) {
@@ -10245,7 +10245,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
   // Handle GNU asm-label extension (encoded as an attribute).
   if (Expr *E = (Expr*) D.getAsmLabel()) {
     // The parser guarantees this is a string.
-    StringLiteral *SE = cast(E);
+    StringRef *SE = cast(E);
     NewFD->addAttr(AsmLabelAttr::Create(Context, SE->getString(),
                                         /*IsLiteralLabel=*/true,
                                         SE->getStrTokenLoc(0)));
@@ -12944,10 +12944,10 @@ QualType Sema::deduceVarTypeFromInitializer(VarDecl *VDecl,
 
   // Diagnose auto array declarations in C23, unless it's a supported extension.
   if (getLangOpts().C23 && Type->isArrayType() &&
-      !isa_and_present(Init)) {
-      Diag(Range.getBegin(), diag::err_auto_not_allowed)
-          << (int)Deduced->getContainedAutoType()->getKeyword()
-          << /*in array decl*/ 23 << Range;
+      !isa_and_present(Init)) {
+    Diag(Range.getBegin(), diag::err_auto_not_allowed)
+        << (int)Deduced->getContainedAutoType()->getKeyword()
+        << /*in array decl*/ 23 << Range;
     return QualType();
   }
 
@@ -14416,7 +14416,7 @@ void Sema::CheckCompleteVariableDeclaration(VarDecl *var) {
         const auto *Init = ILE->getInit(I);
         if (!Init)
           break;
-        const auto *SL = dyn_cast(Init->IgnoreImpCasts());
+        const auto *SL = dyn_cast(Init->IgnoreImpCasts());
         if (!SL)
           break;
 
@@ -14430,7 +14430,7 @@ void Sema::CheckCompleteVariableDeclaration(VarDecl *var) {
             const auto *Init = ILE->getInit(J);
             if (!Init)
               break;
-            const auto *SLJ = dyn_cast(Init->IgnoreImpCasts());
+            const auto *SLJ = dyn_cast(Init->IgnoreImpCasts());
             if (!SLJ || SLJ->getNumConcatenated() > 1) {
               OnlyOneMissingComma = false;
               break;
@@ -14548,7 +14548,7 @@ void Sema::CheckCompleteVariableDeclaration(VarDecl *var) {
   // Apply section attributes and pragmas to global variables.
   if (GlobalStorage && var->isThisDeclarationADefinition() &&
       !inTemplateInstantiation()) {
-    PragmaStack *Stack = nullptr;
+    PragmaStack *Stack = nullptr;
     int SectionFlags = ASTContext::PSF_Read;
     bool MSVCEnv =
         Context.getTargetInfo().getTriple().isWindowsMSVCEnvironment();
@@ -20259,7 +20259,7 @@ void Sema::ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange,
 Decl *Sema::ActOnFileScopeAsmDecl(Expr *expr,
                                   SourceLocation StartLoc,
                                   SourceLocation EndLoc) {
-  StringLiteral *AsmString = cast(expr);
+  StringRef *AsmString = cast(expr);
 
   FileScopeAsmDecl *New = FileScopeAsmDecl::Create(Context, CurContext,
                                                    AsmString, StartLoc,
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index bb4d33560b93b..720b40c2c0e13 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -112,7 +112,7 @@ static bool checkPositiveIntArgument(Sema &S, const AttrInfo &AI, const Expr *Ex
 bool Sema::checkStringLiteralArgumentAttr(const AttributeCommonInfo &CI,
                                           const Expr *E, StringRef &Str,
                                           SourceLocation *ArgLocation) {
-  const auto *Literal = dyn_cast(E->IgnoreParenCasts());
+  const auto *Literal = dyn_cast(E->IgnoreParenCasts());
   if (ArgLocation)
     *ArgLocation = E->getBeginLoc();
 
@@ -144,7 +144,7 @@ bool Sema::checkStringLiteralArgumentAttr(const ParsedAttr &AL, unsigned ArgNum,
 
   // Now check for an actual string literal.
   Expr *ArgExpr = AL.getArgAsExpr(ArgNum);
-  const auto *Literal = dyn_cast(ArgExpr->IgnoreParenCasts());
+  const auto *Literal = dyn_cast(ArgExpr->IgnoreParenCasts());
   if (ArgLocation)
     *ArgLocation = ArgExpr->getBeginLoc();
 
@@ -369,7 +369,7 @@ static void checkAttrArgsAreCapabilityObjs(Sema &S, Decl *D,
       continue;
     }
 
-    if (const auto *StrLit = dyn_cast(ArgExp)) {
+    if (const auto *StrLit = dyn_cast(ArgExp)) {
       if (StrLit->getLength() == 0 ||
           (StrLit->isOrdinary() && StrLit->getString() == "*")) {
         // Pass empty strings to the analyzer without warnings.
@@ -2322,11 +2322,10 @@ static void handleAvailabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
   bool IsUnavailable = AL.getUnavailableLoc().isValid();
   bool IsStrict = AL.getStrictLoc().isValid();
   StringRef Str;
-  if (const auto *SE = dyn_cast_if_present(AL.getMessageExpr()))
+  if (const auto *SE = dyn_cast_if_present(AL.getMessageExpr()))
     Str = SE->getString();
   StringRef Replacement;
-  if (const auto *SE =
-          dyn_cast_if_present(AL.getReplacementExpr()))
+  if (const auto *SE = dyn_cast_if_present(AL.getReplacementExpr()))
     Replacement = SE->getString();
 
   if (II->isStr("swift")) {
@@ -2565,14 +2564,14 @@ static void handleExternalSourceSymbolAttr(Sema &S, Decl *D,
     return;
 
   StringRef Language;
-  if (const auto *SE = dyn_cast_if_present(AL.getArgAsExpr(0)))
+  if (const auto *SE = dyn_cast_if_present(AL.getArgAsExpr(0)))
     Language = SE->getString();
   StringRef DefinedIn;
-  if (const auto *SE = dyn_cast_if_present(AL.getArgAsExpr(1)))
+  if (const auto *SE = dyn_cast_if_present(AL.getArgAsExpr(1)))
     DefinedIn = SE->getString();
   bool IsGeneratedDeclaration = AL.getArgAsIdent(2) != nullptr;
   StringRef USR;
-  if (const auto *SE = dyn_cast_if_present(AL.getArgAsExpr(3)))
+  if (const auto *SE = dyn_cast_if_present(AL.getArgAsExpr(3)))
     USR = SE->getString();
 
   D->addAttr(::new (S.Context) ExternalSourceSymbolAttr(
@@ -3159,8 +3158,8 @@ static void handleTargetAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
 }
 
 bool Sema::checkTargetClonesAttrString(
-    SourceLocation LiteralLoc, StringRef Str, const StringLiteral *Literal,
-    Decl *D, bool &HasDefault, bool &HasCommas, bool &HasNotDefault,
+    SourceLocation LiteralLoc, StringRef Str, const StringRef *Literal, Decl *D,
+    bool &HasDefault, bool &HasCommas, bool &HasNotDefault,
     SmallVectorImpl> &StringsBuffer) {
   enum FirstParam { Unsupported, Duplicate, Unknown };
   enum SecondParam { None, CPU, Tune };
@@ -3329,7 +3328,7 @@ static void handleTargetClonesAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
     if (!S.checkStringLiteralArgumentAttr(AL, I, CurStr, &LiteralLoc) ||
         S.checkTargetClonesAttrString(
             LiteralLoc, CurStr,
-            cast(AL.getArgAsExpr(I)->IgnoreParenCasts()), D,
+            cast(AL.getArgAsExpr(I)->IgnoreParenCasts()), D,
             HasDefault, HasCommas, HasNotDefault, StringsBuffer))
       return;
   }
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index c5a72cf812ebc..490c5aefd4278 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -16680,7 +16680,7 @@ bool Sema::CheckLiteralOperatorDeclaration(FunctionDecl *FnDecl) {
 Decl *Sema::ActOnStartLinkageSpecification(Scope *S, SourceLocation ExternLoc,
                                            Expr *LangStr,
                                            SourceLocation LBraceLoc) {
-  StringLiteral *Lit = cast(LangStr);
+  StringRef *Lit = cast(LangStr);
   assert(Lit->isUnevaluated() && "Unexpected string literal kind");
 
   StringRef Lang = Lit->getString();
@@ -17176,7 +17176,7 @@ bool Sema::EvaluateStaticAssertMessageAsString(Expr *Message,
   assert(!Message->isTypeDependent() && !Message->isValueDependent() &&
          "can't evaluate a dependant static assert message");
 
-  if (const auto *SL = dyn_cast(Message)) {
+  if (const auto *SL = dyn_cast(Message)) {
     assert(SL->isUnevaluated() && "expected an unevaluated string");
     Result.assign(SL->getString().begin(), SL->getString().end());
     return true;
@@ -17960,7 +17960,7 @@ NamedDecl *Sema::ActOnFriendFunctionDecl(Scope *S, Declarator &D,
 }
 
 void Sema::SetDeclDeleted(Decl *Dcl, SourceLocation DelLoc,
-                          StringLiteral *Message) {
+                          StringRef *Message) {
   AdjustDeclIfTemplate(Dcl);
 
   FunctionDecl *Fn = dyn_cast_or_null(Dcl);
@@ -18123,7 +18123,7 @@ void Sema::DiagnoseReturnInConstructorExceptionHandler(CXXTryStmt *TryBlock) {
 }
 
 void Sema::SetFunctionBodyKind(Decl *D, SourceLocation Loc, FnBodyKind BodyKind,
-                               StringLiteral *DeletedMessage) {
+                               StringRef *DeletedMessage) {
   switch (BodyKind) {
   case FnBodyKind::Delete:
     SetDeclDeleted(D, Loc, DeletedMessage);
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index ae40895980d90..abff2167f2a51 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -264,7 +264,7 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, ArrayRef Locs,
             << Ctor->getParent()
             << Ctor->getInheritedConstructor().getConstructor()->getParent();
       else {
-        StringLiteral *Msg = FD->getDeletedMessage();
+        StringRef *Msg = FD->getDeletedMessage();
         Diag(Loc, diag::err_deleted_function_use)
             << (Msg != nullptr) << (Msg ? Msg->getString() : StringRef());
       }
@@ -1981,9 +1981,9 @@ ExprResult Sema::ActOnUnevaluatedStringLiteral(ArrayRef StringToks) {
   for (const Token &Tok : StringToks)
     StringTokLocs.push_back(Tok.getLocation());
 
-  StringLiteral *Lit = StringLiteral::Create(
-      Context, Literal.GetString(), StringLiteralKind::Unevaluated, false, {},
-      &StringTokLocs[0], StringTokLocs.size());
+  StringRef *Lit = StringRef::Create(Context, Literal.GetString(),
+                                     StringLiteralKind::Unevaluated, false, {},
+                                     &StringTokLocs[0], StringTokLocs.size());
 
   if (!Literal.getUDSuffix().empty()) {
     SourceLocation UDSuffixLoc =
@@ -2117,10 +2117,9 @@ Sema::ActOnStringLiteral(ArrayRef StringToks, Scope *UDLScope) {
       Context.getStringLiteralArrayType(CharTy, Literal.GetNumStringChars());
 
   // Pass &StringTokLocs[0], StringTokLocs.size() to factory!
-  StringLiteral *Lit = StringLiteral::Create(Context, Literal.GetString(),
-                                             Kind, Literal.Pascal, StrTy,
-                                             &StringTokLocs[0],
-                                             StringTokLocs.size());
+  StringRef *Lit =
+      StringRef::Create(Context, Literal.GetString(), Kind, Literal.Pascal,
+                        StrTy, &StringTokLocs[0], StringTokLocs.size());
   if (Literal.getUDSuffix().empty())
     return Lit;
 
@@ -3492,7 +3491,7 @@ ExprResult Sema::BuildPredefinedExpr(SourceLocation Loc,
   }
 
   QualType ResTy;
-  StringLiteral *SL = nullptr;
+  StringRef *SL = nullptr;
   if (cast(currentDecl)->isDependentContext())
     ResTy = Context.DependentTy;
   else {
@@ -3515,15 +3514,15 @@ ExprResult Sema::BuildPredefinedExpr(SourceLocation Loc,
       ResTy = Context.getConstantArrayType(ResTy, LengthI, nullptr,
                                            ArraySizeModifier::Normal,
                                            /*IndexTypeQuals*/ 0);
-      SL = StringLiteral::Create(Context, RawChars, StringLiteralKind::Wide,
-                                 /*Pascal*/ false, ResTy, Loc);
+      SL = StringRef::Create(Context, RawChars, StringLiteralKind::Wide,
+                             /*Pascal*/ false, ResTy, Loc);
     } else {
       ResTy = Context.adjustStringLiteralBaseType(Context.CharTy.withConst());
       ResTy = Context.getConstantArrayType(ResTy, LengthI, nullptr,
                                            ArraySizeModifier::Normal,
                                            /*IndexTypeQuals*/ 0);
-      SL = StringLiteral::Create(Context, Str, StringLiteralKind::Ordinary,
-                                 /*Pascal*/ false, ResTy, Loc);
+      SL = StringRef::Create(Context, Str, StringLiteralKind::Ordinary,
+                             /*Pascal*/ false, ResTy, Loc);
     }
   }
 
@@ -3763,9 +3762,9 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) {
           Context.adjustStringLiteralBaseType(Context.CharTy.withConst()),
           llvm::APInt(32, Length + 1), nullptr, ArraySizeModifier::Normal, 0);
       Expr *Lit =
-          StringLiteral::Create(Context, StringRef(TokSpelling.data(), Length),
-                                StringLiteralKind::Ordinary,
-                                /*Pascal*/ false, StrTy, &TokLoc, 1);
+          StringRef::Create(Context, StringRef(TokSpelling.data(), Length),
+                            StringLiteralKind::Ordinary,
+                            /*Pascal*/ false, StrTy, &TokLoc, 1);
       return BuildLiteralOperatorCall(R, OpNameInfo, Lit, TokLoc);
     }
 
@@ -10847,10 +10846,10 @@ static bool checkArithmeticBinOpPointerOperands(Sema &S, SourceLocation Loc,
 /// literal.
 static void diagnoseStringPlusInt(Sema &Self, SourceLocation OpLoc,
                                   Expr *LHSExpr, Expr *RHSExpr) {
-  StringLiteral* StrExpr = dyn_cast(LHSExpr->IgnoreImpCasts());
+  StringRef *StrExpr = dyn_cast(LHSExpr->IgnoreImpCasts());
   Expr* IndexExpr = RHSExpr;
   if (!StrExpr) {
-    StrExpr = dyn_cast(RHSExpr->IgnoreImpCasts());
+    StrExpr = dyn_cast(RHSExpr->IgnoreImpCasts());
     IndexExpr = LHSExpr;
   }
 
@@ -11952,15 +11951,15 @@ static void diagnoseTautologicalComparison(Sema &S, SourceLocation Loc,
   // operand is null); the user probably wants string comparison function.
   Expr *LiteralString = nullptr;
   Expr *LiteralStringStripped = nullptr;
-  if ((isa(LHSStripped) || isa(LHSStripped)) &&
+  if ((isa(LHSStripped) || isa(LHSStripped)) &&
       !RHSStripped->isNullPointerConstant(S.Context,
                                           Expr::NPC_ValueDependentIsNull)) {
     LiteralString = LHS;
     LiteralStringStripped = LHSStripped;
-  } else if ((isa(RHSStripped) ||
+  } else if ((isa(RHSStripped) ||
               isa(RHSStripped)) &&
-             !LHSStripped->isNullPointerConstant(S.Context,
-                                          Expr::NPC_ValueDependentIsNull)) {
+             !LHSStripped->isNullPointerConstant(
+                 S.Context, Expr::NPC_ValueDependentIsNull)) {
     LiteralString = RHS;
     LiteralStringStripped = RHSStripped;
   }
@@ -15116,14 +15115,14 @@ static void DiagnoseLogicalAndInLogicalOrLHS(Sema &S, SourceLocation OpLoc,
     if (Bop->getOpcode() == BO_LAnd) {
       // If it's "string_literal && a || b" don't warn since the precedence
       // doesn't matter.
-      if (!isa(Bop->getLHS()->IgnoreParenImpCasts()))
+      if (!isa(Bop->getLHS()->IgnoreParenImpCasts()))
         return EmitDiagnosticForLogicalAndInLogicalOr(S, OpLoc, Bop);
     } else if (Bop->getOpcode() == BO_LOr) {
       if (BinaryOperator *RBop = dyn_cast(Bop->getRHS())) {
         // If it's "a || b && string_literal || c" we didn't warn earlier for
         // "a || b && string_literal", but warn now.
         if (RBop->getOpcode() == BO_LAnd &&
-            isa(RBop->getRHS()->IgnoreParenImpCasts()))
+            isa(RBop->getRHS()->IgnoreParenImpCasts()))
           return EmitDiagnosticForLogicalAndInLogicalOr(S, OpLoc, RBop);
       }
     }
@@ -15137,7 +15136,7 @@ static void DiagnoseLogicalAndInLogicalOrRHS(Sema &S, SourceLocation OpLoc,
     if (Bop->getOpcode() == BO_LAnd) {
       // If it's "a || b && string_literal" don't warn since the precedence
       // doesn't matter.
-      if (!isa(Bop->getRHS()->IgnoreParenImpCasts()))
+      if (!isa(Bop->getRHS()->IgnoreParenImpCasts()))
         return EmitDiagnosticForLogicalAndInLogicalOr(S, OpLoc, Bop);
     }
   }
@@ -16789,7 +16788,7 @@ ExprResult Sema::BuildSourceLocExpr(SourceLocIdentKind Kind, QualType ResultTy,
 }
 
 ExprResult Sema::ActOnEmbedExpr(SourceLocation EmbedKeywordLoc,
-                                StringLiteral *BinaryData) {
+                                StringRef *BinaryData) {
   EmbedDataStorage *Data = new (Context) EmbedDataStorage;
   Data->BinaryData = BinaryData;
   return new (Context)
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 1e39d69e8b230..30a7bd3a4a502 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -3333,7 +3333,7 @@ bool Sema::FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD,
     // FIXME: DiagnoseUseOfDecl?
     if (Operator->isDeleted()) {
       if (Diagnose) {
-        StringLiteral *Msg = Operator->getDeletedMessage();
+        StringRef *Msg = Operator->getDeletedMessage();
         Diag(StartLoc, diag::err_deleted_function_use)
             << (Msg != nullptr) << (Msg ? Msg->getString() : StringRef());
         NoteDeletedFunction(Operator);
@@ -4129,7 +4129,7 @@ Sema::IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType) {
   // be converted to an rvalue of type "pointer to char"; a wide
   // string literal can be converted to an rvalue of type "pointer
   // to wchar_t" (C++ 4.2p2).
-  if (StringLiteral *StrLit = dyn_cast(From->IgnoreParens()))
+  if (StringRef *StrLit = dyn_cast(From->IgnoreParens()))
     if (const PointerType *ToPtrType = ToType->getAs())
       if (const BuiltinType *ToPointeeType
           = ToPtrType->getPointeeType()->getAs()) {
diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp
index 18d9d38eee92f..248c665a25b06 100644
--- a/clang/lib/Sema/SemaExprObjC.cpp
+++ b/clang/lib/Sema/SemaExprObjC.cpp
@@ -40,8 +40,8 @@ ExprResult SemaObjC::ParseObjCStringLiteral(SourceLocation *AtLocs,
   // Most ObjC strings are formed out of a single piece.  However, we *can*
   // have strings formed out of multiple @ strings with multiple pptokens in
   // each one, e.g. @"foo" "bar" @"baz" "qux"   which need to be turned into one
-  // StringLiteral for ObjCStringLiteral to hold onto.
-  StringLiteral *S = cast(Strings[0]);
+  // StringRef for ObjCStringLiteral to hold onto.
+  StringRef *S = cast(Strings[0]);
 
   // If we have a multi-part string, merge it all together.
   if (Strings.size() != 1) {
@@ -50,7 +50,7 @@ ExprResult SemaObjC::ParseObjCStringLiteral(SourceLocation *AtLocs,
     SmallVector StrLocs;
 
     for (Expr *E : Strings) {
-      S = cast(E);
+      S = cast(E);
 
       // ObjC strings can't be wide or UTF.
       if (!S->isOrdinary()) {
@@ -73,16 +73,15 @@ ExprResult SemaObjC::ParseObjCStringLiteral(SourceLocation *AtLocs,
     QualType StrTy = Context.getConstantArrayType(
         CAT->getElementType(), llvm::APInt(32, StrBuf.size() + 1), nullptr,
         CAT->getSizeModifier(), CAT->getIndexTypeCVRQualifiers());
-    S = StringLiteral::Create(Context, StrBuf, StringLiteralKind::Ordinary,
-                              /*Pascal=*/false, StrTy, &StrLocs[0],
-                              StrLocs.size());
+    S = StringRef::Create(Context, StrBuf, StringLiteralKind::Ordinary,
+                          /*Pascal=*/false, StrTy, &StrLocs[0], StrLocs.size());
   }
 
   return BuildObjCStringLiteral(AtLocs[0], S);
 }
 
 ExprResult SemaObjC::BuildObjCStringLiteral(SourceLocation AtLoc,
-                                            StringLiteral *S) {
+                                            StringRef *S) {
   ASTContext &Context = getASTContext();
   // Verify that this composite string is acceptable for ObjC strings.
   if (CheckObjCString(S))
@@ -454,7 +453,7 @@ static ExprResult CheckObjCCollectionLiteralElement(Sema &S, Expr *Element,
       }
     }
     // If this is potentially an Objective-C string literal, add the '@'.
-    else if (StringLiteral *String = dyn_cast(OrigElement)) {
+    else if (StringRef *String = dyn_cast(OrigElement)) {
       if (String->isOrdinary()) {
         S.Diag(OrigElement->getBeginLoc(), diag::err_box_literal_collection)
             << 0 << OrigElement->getSourceRange()
@@ -479,7 +478,7 @@ static ExprResult CheckObjCCollectionLiteralElement(Sema &S, Expr *Element,
   if (ArrayLiteral)
     if (ObjCStringLiteral *getString =
           dyn_cast(OrigElement)) {
-      if (StringLiteral *SL = getString->getString()) {
+      if (StringRef *SL = getString->getString()) {
         unsigned numConcat = SL->getNumConcatenated();
         if (numConcat > 1) {
           // Only warn if the concatenated string doesn't come from a macro.
@@ -541,7 +540,7 @@ ExprResult SemaObjC::BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr) {
       if (auto *CE = dyn_cast(ValueExpr))
         if (CE->getCastKind() == CK_ArrayToPointerDecay)
           if (auto *SL =
-                  dyn_cast(CE->getSubExpr()->IgnoreParens())) {
+                  dyn_cast(CE->getSubExpr()->IgnoreParens())) {
             assert((SL->isOrdinary() || SL->isUTF8()) &&
                    "unexpected character encoding");
             StringRef Str = SL->getString();
@@ -939,7 +938,7 @@ CheckObjCDictionaryLiteralDuplicateKeys(Sema &S,
       SourceLocation Loc = BE->getExprLoc();
 
       // Check for @("foo").
-      if (auto *Str = dyn_cast(Boxed->IgnoreParenImpCasts())) {
+      if (auto *Str = dyn_cast(Boxed->IgnoreParenImpCasts())) {
         checkOneKey(StringKeys, Str->getBytes(), Loc);
         continue;
       }
@@ -2564,7 +2563,7 @@ DiagnoseCStringFormatDirectiveInObjCAPI(Sema &S,
   Expr *FormatExpr = Args[Idx];
   if (ObjCStringLiteral *OSL =
       dyn_cast(FormatExpr->IgnoreParenImpCasts())) {
-    StringLiteral *FormatString = OSL->getString();
+    StringRef *FormatString = OSL->getString();
     if (S.FormatStringHasSArg(FormatString)) {
       S.Diag(FormatExpr->getExprLoc(), diag::warn_objc_cdirective_format_string)
         << "%s" << 0 << 0;
@@ -5085,7 +5084,7 @@ bool SemaObjC::CheckConversionToObjCLiteral(QualType DstType, Expr *&Exp,
     if (OV->getSourceExpr())
       SrcExpr = OV->getSourceExpr()->IgnoreParenImpCasts();
 
-  if (auto *SL = dyn_cast(SrcExpr)) {
+  if (auto *SL = dyn_cast(SrcExpr)) {
     if (!PT->isObjCIdType() && !(ID && ID->getIdentifier()->isStr("NSString")))
       return false;
     if (!SL->isOrdinary())
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 0dd5f468cf60b..5ba169bcc885f 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -81,7 +81,7 @@ static StringInitFailureKind IsStringInit(Expr *Init, const ArrayType *AT,
     return SIF_None;
 
   // Otherwise we can only handle string literals.
-  StringLiteral *SL = dyn_cast(Init);
+  StringRef *SL = dyn_cast(Init);
   if (!SL)
     return SIF_Other;
 
@@ -151,7 +151,7 @@ static StringInitFailureKind IsStringInit(Expr *Init, const ArrayType *AT,
     break;
   }
 
-  llvm_unreachable("missed a StringLiteral kind?");
+  llvm_unreachable("missed a StringRef kind?");
 }
 
 static StringInitFailureKind IsStringInit(Expr *init, QualType declType,
@@ -172,7 +172,7 @@ static void updateStringLiteralType(Expr *E, QualType Ty) {
   while (true) {
     E->setType(Ty);
     E->setValueKind(VK_PRValue);
-    if (isa(E) || isa(E))
+    if (isa(E) || isa(E))
       break;
     E = IgnoreParensSingleStep(E);
   }
@@ -204,7 +204,7 @@ static bool initializingConstexprVariable(const InitializedEntity &Entity) {
   return false;
 }
 
-static void CheckC23ConstexprInitStringLiteral(const StringLiteral *SE,
+static void CheckC23ConstexprInitStringLiteral(const StringRef *SE,
                                                Sema &SemaRef, QualType &TT);
 
 static void CheckStringInit(Expr *Str, QualType &DeclT, const ArrayType *AT,
@@ -215,7 +215,7 @@ static void CheckStringInit(Expr *Str, QualType &DeclT, const ArrayType *AT,
   uint64_t StrLength = ConstantArrayTy->getZExtSize();
 
   if (CheckC23ConstexprInit)
-    if (const StringLiteral *SL = dyn_cast(Str->IgnoreParens()))
+    if (const StringRef *SL = dyn_cast(Str->IgnoreParens()))
       CheckC23ConstexprInitStringLiteral(SL, S, DeclT);
 
   if (const IncompleteArrayType *IAT = dyn_cast(AT)) {
@@ -235,7 +235,7 @@ static void CheckStringInit(Expr *Str, QualType &DeclT, const ArrayType *AT,
   // the size may be smaller or larger than the string we are initializing.
   // FIXME: Avoid truncation for 64-bit length strings.
   if (S.getLangOpts().CPlusPlus) {
-    if (StringLiteral *SL = dyn_cast(Str->IgnoreParens())) {
+    if (StringRef *SL = dyn_cast(Str->IgnoreParens())) {
       // For Pascal strings it's OK to strip off the terminating null character,
       // so the example below is valid:
       //
@@ -2030,7 +2030,7 @@ canInitializeArrayWithEmbedDataString(ArrayRef ExprList,
 
   if (InitType->isArrayType()) {
     const ArrayType *InitArrayType = InitType->getAsArrayTypeUnsafe();
-    StringLiteral *SL = EE->getDataStringLiteral();
+    StringRef *SL = EE->getDataStringLiteral();
     return IsStringInit(SL, InitArrayType, Context) == SIF_None;
   }
   return false;
@@ -3034,7 +3034,7 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity,
       }
 
       if (!hadError && !isa(DIE->getInit()) &&
-          !isa(DIE->getInit())) {
+          !isa(DIE->getInit())) {
         // The initializer is not an initializer list.
         if (!VerifyOnly) {
           SemaRef.Diag(DIE->getInit()->getBeginLoc(),
@@ -3224,7 +3224,7 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity,
       PromotedCharTy = Context.getPromotedIntegerType(CharTy);
     unsigned PromotedCharTyWidth = Context.getTypeSize(PromotedCharTy);
 
-    if (StringLiteral *SL = dyn_cast(SubExpr)) {
+    if (StringRef *SL = dyn_cast(SubExpr)) {
       // Get the length of the string.
       uint64_t StrLen = SL->getLength();
       if (cast(AT)->getSize().ult(StrLen))
@@ -8818,7 +8818,7 @@ bool InitializationSequence::Diagnose(Sema &S,
       OverloadingResult Ovl
         = FailedCandidateSet.BestViableFunction(S, Kind.getLocation(), Best);
 
-      StringLiteral *Msg = Best->Function->getDeletedMessage();
+      StringRef *Msg = Best->Function->getDeletedMessage();
       S.Diag(Kind.getLocation(), diag::err_typecheck_deleted_function)
           << OnlyArg->getType() << DestType.getNonReferenceType()
           << (Msg != nullptr) << (Msg ? Msg->getString() : StringRef())
@@ -9082,7 +9082,7 @@ bool InitializationSequence::Diagnose(Sema &S,
                      S.getSpecialMember(cast(Best->Function)))
               << DestType << ArgsRange;
         else {
-          StringLiteral *Msg = Best->Function->getDeletedMessage();
+          StringRef *Msg = Best->Function->getDeletedMessage();
           S.Diag(Kind.getLocation(), diag::err_ovl_deleted_init)
               << DestType << (Msg != nullptr)
               << (Msg ? Msg->getString() : StringRef()) << ArgsRange;
@@ -9669,7 +9669,7 @@ static void CheckC23ConstexprInitConversion(Sema &S, QualType FromType,
   llvm_unreachable("unhandled case in switch");
 }
 
-static void CheckC23ConstexprInitStringLiteral(const StringLiteral *SE,
+static void CheckC23ConstexprInitStringLiteral(const StringRef *SE,
                                                Sema &SemaRef, QualType &TT) {
   assert(SemaRef.getLangOpts().C23);
   // character that string literal contains fits into TT - target type.
@@ -9976,7 +9976,7 @@ QualType Sema::DeduceTemplateSpecializationFromInitializer(
           if (ElementTypes[I]->isArrayType()) {
             if (isa(ListInit->getInit(I)))
               ElementTypes[I] = Context.getRValueReferenceType(ElementTypes[I]);
-            else if (isa(
+            else if (isa(
                          ListInit->getInit(I)->IgnoreParenImpCasts()))
               ElementTypes[I] =
                   Context.getLValueReferenceType(ElementTypes[I].withConst());
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index e1171d4284c76..ec327ad4e8a4b 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -3603,7 +3603,7 @@ Sema::LiteralOperatorLookupResult
 Sema::LookupLiteralOperator(Scope *S, LookupResult &R,
                             ArrayRef ArgTys, bool AllowRaw,
                             bool AllowTemplate, bool AllowStringTemplatePack,
-                            bool DiagnoseMissing, StringLiteral *StringLit) {
+                            bool DiagnoseMissing, StringRef *StringLit) {
   LookupName(R, S);
   assert(R.getResultKind() != LookupResult::Ambiguous &&
          "literal operator lookup can't be ambiguous");
diff --git a/clang/lib/Sema/SemaObjC.cpp b/clang/lib/Sema/SemaObjC.cpp
index 57eda18c2d8e1..1444237099f4e 100644
--- a/clang/lib/Sema/SemaObjC.cpp
+++ b/clang/lib/Sema/SemaObjC.cpp
@@ -1217,7 +1217,7 @@ void SemaObjC::checkRetainCycles(VarDecl *Var, Expr *Init) {
 /// simplify the backend).
 bool SemaObjC::CheckObjCString(Expr *Arg) {
   Arg = Arg->IgnoreParenCasts();
-  StringLiteral *Literal = dyn_cast(Arg);
+  StringRef *Literal = dyn_cast(Arg);
 
   if (!Literal || !Literal->isOrdinary()) {
     Diag(Arg->getBeginLoc(), diag::err_cfstring_literal_not_string_constant)
@@ -1392,7 +1392,7 @@ SemaObjC::ObjCSubscriptKind SemaObjC::CheckSubscriptingKind(Expr *FromE) {
   if (!getLangOpts().CPlusPlus || !RecordTy || RecordTy->isIncompleteType()) {
     // No indexing can be done. Issue diagnostics and quit.
     const Expr *IndexExpr = FromE->IgnoreParenImpCasts();
-    if (isa(IndexExpr))
+    if (isa(IndexExpr))
       Diag(FromE->getExprLoc(), diag::err_objc_subscript_pointer)
           << T << FixItHint::CreateInsertion(FromE->getExprLoc(), "@");
     else
@@ -2289,12 +2289,12 @@ void SemaObjC::DiagnoseCStringFormatDirectiveInCFAPI(const NamedDecl *FDecl,
   const Expr *FormatExpr = Args[Idx];
   if (const CStyleCastExpr *CSCE = dyn_cast(FormatExpr))
     FormatExpr = CSCE->getSubExpr();
-  const StringLiteral *FormatString;
+  const StringRef *FormatString;
   if (const ObjCStringLiteral *OSL =
           dyn_cast(FormatExpr->IgnoreParenImpCasts()))
     FormatString = OSL->getString();
   else
-    FormatString = dyn_cast(FormatExpr->IgnoreParenImpCasts());
+    FormatString = dyn_cast(FormatExpr->IgnoreParenImpCasts());
   if (!FormatString)
     return;
   if (SemaRef.FormatStringHasSArg(FormatString)) {
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 66ff92f554fc4..457ae80ae19c5 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -11042,10 +11042,10 @@ StmtResult SemaOpenMP::ActOnOpenMPErrorDirective(ArrayRef Clauses,
   if (!AtC || AtC->getAtKind() == OMPC_AT_compilation) {
     if (SeverityC && SeverityC->getSeverityKind() == OMPC_SEVERITY_warning)
       Diag(SeverityC->getSeverityKindKwLoc(), diag::warn_diagnose_if_succeeded)
-          << (ME ? cast(ME)->getString() : "WARNING");
+          << (ME ? cast(ME)->getString() : "WARNING");
     else
       Diag(StartLoc, diag::err_diagnose_if_succeeded)
-          << (ME ? cast(ME)->getString() : "ERROR");
+          << (ME ? cast(ME)->getString() : "ERROR");
     if (!SeverityC || SeverityC->getSeverityKind() != OMPC_SEVERITY_warning)
       return StmtError();
   }
@@ -16033,7 +16033,7 @@ OMPClause *SemaOpenMP::ActOnOpenMPMessageClause(Expr *ME,
                                                 SourceLocation LParenLoc,
                                                 SourceLocation EndLoc) {
   assert(ME && "NULL expr in Message clause");
-  if (!isa(ME)) {
+  if (!isa(ME)) {
     Diag(ME->getBeginLoc(), diag::warn_clause_expected_string)
         << getOpenMPClauseName(OMPC_message);
     return nullptr;
@@ -16916,7 +16916,7 @@ OMPClause *SemaOpenMP::ActOnOpenMPInitClause(
       continue;
     if (E->isIntegerConstantExpr(getASTContext()))
       continue;
-    if (isa(E))
+    if (isa(E))
       continue;
     Diag(E->getExprLoc(), diag::err_omp_interop_prefer_type);
     return nullptr;
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 3be9ade80f1d9..4337972d3f40a 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -14490,7 +14490,7 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc,
     // is passed further and it eventually ends up compared to number of
     // function candidate parameters which never includes the object parameter,
     // so slice ArgsArray to make sure apples are compared to apples.
-    StringLiteral *Msg = Best->Function->getDeletedMessage();
+    StringRef *Msg = Best->Function->getDeletedMessage();
     CandidateSet.NoteCandidates(
         PartialDiagnosticAt(OpLoc, PDiag(diag::err_ovl_deleted_oper)
                                        << UnaryOperator::getOpcodeStr(Opc)
@@ -15020,7 +15020,7 @@ ExprResult Sema::CreateOverloadedBinOp(SourceLocation OpLoc,
         return ExprError();
       }
 
-      StringLiteral *Msg = Best->Function->getDeletedMessage();
+      StringRef *Msg = Best->Function->getDeletedMessage();
       CandidateSet.NoteCandidates(
           PartialDiagnosticAt(
               OpLoc,
@@ -15347,7 +15347,7 @@ ExprResult Sema::CreateOverloadedArraySubscriptExpr(SourceLocation LLoc,
       return ExprError();
 
     case OR_Deleted: {
-      StringLiteral *Msg = Best->Function->getDeletedMessage();
+      StringRef *Msg = Best->Function->getDeletedMessage();
       CandidateSet.NoteCandidates(
           PartialDiagnosticAt(LLoc,
                               PDiag(diag::err_ovl_deleted_oper)
@@ -15830,7 +15830,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj,
     // FIXME: Is this diagnostic here really necessary? It seems that
     //   1. we don't have any tests for this diagnostic, and
     //   2. we already issue err_deleted_function_use for this later on anyway.
-    StringLiteral *Msg = Best->Function->getDeletedMessage();
+    StringRef *Msg = Best->Function->getDeletedMessage();
     CandidateSet.NoteCandidates(
         PartialDiagnosticAt(Object.get()->getBeginLoc(),
                             PDiag(diag::err_ovl_deleted_object_call)
@@ -16035,7 +16035,7 @@ Sema::BuildOverloadedArrowExpr(Scope *S, Expr *Base, SourceLocation OpLoc,
     return ExprError();
 
   case OR_Deleted: {
-    StringLiteral *Msg = Best->Function->getDeletedMessage();
+    StringRef *Msg = Best->Function->getDeletedMessage();
     CandidateSet.NoteCandidates(
         PartialDiagnosticAt(OpLoc, PDiag(diag::err_ovl_deleted_oper)
                                        << "->" << (Msg != nullptr)
@@ -16451,7 +16451,7 @@ void Sema::DiagnoseUseOfDeletedFunction(SourceLocation Loc, SourceRange Range,
                                         OverloadCandidateSet &CandidateSet,
                                         FunctionDecl *Fn, MultiExprArg Args,
                                         bool IsMember) {
-  StringLiteral *Msg = Fn->getDeletedMessage();
+  StringRef *Msg = Fn->getDeletedMessage();
   CandidateSet.NoteCandidates(
       PartialDiagnosticAt(Loc, PDiag(diag::err_ovl_deleted_call)
                                    << IsMember << Name << (Msg != nullptr)
diff --git a/clang/lib/Sema/SemaStmtAsm.cpp b/clang/lib/Sema/SemaStmtAsm.cpp
index a0b203fbdfec2..b4c7c77a65e4d 100644
--- a/clang/lib/Sema/SemaStmtAsm.cpp
+++ b/clang/lib/Sema/SemaStmtAsm.cpp
@@ -203,10 +203,10 @@ static StringRef extractRegisterName(const Expr *Expression,
 // clobbers list. If there's a conflict, returns the location of the
 // conflicted clobber, else returns nullptr
 static SourceLocation
-getClobberConflictLocation(MultiExprArg Exprs, StringLiteral **Constraints,
-                           StringLiteral **Clobbers, int NumClobbers,
-                           unsigned NumLabels,
-                           const TargetInfo &Target, ASTContext &Cont) {
+getClobberConflictLocation(MultiExprArg Exprs, StringRef **Constraints,
+                           StringRef **Clobbers, int NumClobbers,
+                           unsigned NumLabels, const TargetInfo &Target,
+                           ASTContext &Cont) {
   llvm::StringSet<> InOutVars;
   // Collect all the input and output registers from the extended asm
   // statement in order to check for conflicts with the clobber list
@@ -241,10 +241,9 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
                                  unsigned NumLabels,
                                  SourceLocation RParenLoc) {
   unsigned NumClobbers = clobbers.size();
-  StringLiteral **Constraints =
-    reinterpret_cast(constraints.data());
-  StringLiteral *AsmString = cast(asmString);
-  StringLiteral **Clobbers = reinterpret_cast(clobbers.data());
+  StringRef **Constraints = reinterpret_cast(constraints.data());
+  StringRef *AsmString = cast(asmString);
+  StringRef **Clobbers = reinterpret_cast(clobbers.data());
 
   SmallVector OutputConstraintInfos;
 
@@ -256,7 +255,7 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
   Context.getFunctionFeatureMap(FeatureMap, FD);
 
   for (unsigned i = 0; i != NumOutputs; i++) {
-    StringLiteral *Literal = Constraints[i];
+    StringRef *Literal = Constraints[i];
     assert(Literal->isOrdinary());
 
     StringRef OutputName;
@@ -348,7 +347,7 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
   SmallVector InputConstraintInfos;
 
   for (unsigned i = NumOutputs, e = NumOutputs + NumInputs; i != e; i++) {
-    StringLiteral *Literal = Constraints[i];
+    StringRef *Literal = Constraints[i];
     assert(Literal->isOrdinary());
 
     StringRef InputName;
@@ -459,7 +458,7 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
 
   // Check that the clobbers are valid.
   for (unsigned i = 0; i != NumClobbers; i++) {
-    StringLiteral *Literal = Clobbers[i];
+    StringRef *Literal = Clobbers[i];
     assert(Literal->isOrdinary());
 
     StringRef Clobber = Literal->getString();
@@ -529,7 +528,7 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
     }
 
     // Now that we have the right indexes go ahead and check.
-    StringLiteral *Literal = Constraints[ConstraintIdx];
+    StringRef *Literal = Constraints[ConstraintIdx];
     const Type *Ty = Exprs[ConstraintIdx]->getType().getTypePtr();
     if (Ty->isDependentType() || Ty->isIncompleteType())
       continue;
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 1c1f6e30ab7b8..6e1c18b6d1fca 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -5173,7 +5173,7 @@ Sema::DeduceAutoType(TypeLoc Type, Expr *Init, QualType &Result,
   }
 
   // Make sure that we treat 'char[]' equaly as 'char*' in C23 mode.
-  auto *String = dyn_cast(Init);
+  auto *String = dyn_cast(Init);
   if (getLangOpts().C23 && String && Type.getType()->isArrayType()) {
     Diag(Type.getBeginLoc(), diag::ext_c23_auto_non_plain_identifier);
     TypeLoc TL = TypeLoc(Init->getType(), Type.getOpaqueData());
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 83464c50b4b23..a9253ae21487e 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -6547,7 +6547,7 @@ static void HandleBTFTypeTagAttribute(QualType &Type, const ParsedAttr &Attr,
   }
 
   // Ensure the argument is a string.
-  auto *StrLiteral = dyn_cast(Attr.getArgAsExpr(0));
+  auto *StrLiteral = dyn_cast(Attr.getArgAsExpr(0));
   if (!StrLiteral) {
     S.Diag(Attr.getLoc(), diag::err_attribute_argument_type)
         << Attr << AANT_ArgumentString;
@@ -7592,7 +7592,7 @@ static Attr *getCCTypeAttr(ASTContext &Ctx, ParsedAttr &Attr) {
     // but the form may not be.
     StringRef Str;
     if (Attr.isArgExpr(0))
-      Str = cast(Attr.getArgAsExpr(0))->getString();
+      Str = cast(Attr.getArgAsExpr(0))->getString();
     else
       Str = Attr.getArgAsIdent(0)->Ident->getName();
     PcsAttr::PCSType Type;
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 4a3c739ecbeab..084594af04a08 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -12722,9 +12722,8 @@ TreeTransform::TransformImaginaryLiteral(ImaginaryLiteral *E) {
   return E;
 }
 
-template
-ExprResult
-TreeTransform::TransformStringLiteral(StringLiteral *E) {
+template 
+ExprResult TreeTransform::TransformStringLiteral(StringRef *E) {
   return E;
 }
 
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp
index 8c60e85c93d70..5235887ee8423 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -1078,8 +1078,8 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
     // a DeletedMessage for the DefaultedOrDeletedInfo.
     if (auto Info = Record.readInt()) {
       bool HasMessage = Info & 2;
-      StringLiteral *DeletedMessage =
-          HasMessage ? cast(Record.readExpr()) : nullptr;
+      StringRef *DeletedMessage =
+          HasMessage ? cast(Record.readExpr()) : nullptr;
 
       unsigned NumLookups = Record.readInt();
       SmallVector Lookups;
@@ -1740,7 +1740,7 @@ void ASTDeclReader::VisitBindingDecl(BindingDecl *BD) {
 
 void ASTDeclReader::VisitFileScopeAsmDecl(FileScopeAsmDecl *AD) {
   VisitDecl(AD);
-  AD->setAsmString(cast(Record.readExpr()));
+  AD->setAsmString(cast(Record.readExpr()));
   AD->setRParenLoc(readSourceLocation());
 }
 
@@ -2732,7 +2732,7 @@ void ASTDeclReader::VisitStaticAssertDecl(StaticAssertDecl *D) {
   VisitDecl(D);
   D->AssertExprAndFailed.setPointer(Record.readExpr());
   D->AssertExprAndFailed.setInt(Record.readInt());
-  D->Message = cast_or_null(Record.readExpr());
+  D->Message = cast_or_null(Record.readExpr());
   D->RParenLoc = readSourceLocation();
 }
 
diff --git a/clang/lib/Serialization/ASTReaderStmt.cpp b/clang/lib/Serialization/ASTReaderStmt.cpp
index 4766f34e9f3a8..9c58845c15061 100644
--- a/clang/lib/Serialization/ASTReaderStmt.cpp
+++ b/clang/lib/Serialization/ASTReaderStmt.cpp
@@ -380,7 +380,7 @@ void ASTStmtReader::VisitGCCAsmStmt(GCCAsmStmt *S) {
   VisitAsmStmt(S);
   S->NumLabels = Record.readInt();
   S->setRParenLoc(readSourceLocation());
-  S->setAsmString(cast_or_null(Record.readSubStmt()));
+  S->setAsmString(cast_or_null(Record.readSubStmt()));
 
   unsigned NumOutputs = S->getNumOutputs();
   unsigned NumInputs = S->getNumInputs();
@@ -389,18 +389,18 @@ void ASTStmtReader::VisitGCCAsmStmt(GCCAsmStmt *S) {
 
   // Outputs and inputs
   SmallVector Names;
-  SmallVector Constraints;
+  SmallVector Constraints;
   SmallVector Exprs;
   for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
     Names.push_back(Record.readIdentifier());
-    Constraints.push_back(cast_or_null(Record.readSubStmt()));
+    Constraints.push_back(cast_or_null(Record.readSubStmt()));
     Exprs.push_back(Record.readSubStmt());
   }
 
   // Constraints
-  SmallVector Clobbers;
+  SmallVector Clobbers;
   for (unsigned I = 0; I != NumClobbers; ++I)
-    Clobbers.push_back(cast_or_null(Record.readSubStmt()));
+    Clobbers.push_back(cast_or_null(Record.readSubStmt()));
 
   // Labels
   for (unsigned I = 0, N = NumLabels; I != N; ++I) {
@@ -598,7 +598,7 @@ void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
   E->PredefinedExprBits.IsTransparent = Record.readInt();
   E->setLocation(readSourceLocation());
   if (HasFunctionName)
-    E->setFunctionName(cast(Record.readSubExpr()));
+    E->setFunctionName(cast(Record.readSubExpr()));
 }
 
 void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
@@ -664,7 +664,7 @@ void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
   E->setSubExpr(Record.readSubExpr());
 }
 
-void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
+void ASTStmtReader::VisitStringLiteral(StringRef *E) {
   VisitExpr(E);
 
   // NumConcatenated, Length and CharByteWidth are set by the empty
@@ -683,8 +683,8 @@ void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
   // Check that the deserialized character width is consistant with the result
   // of calling mapCharByteWidth.
   assert((CharByteWidth ==
-          StringLiteral::mapCharByteWidth(Record.getContext().getTargetInfo(),
-                                          E->getKind())) &&
+          StringRef::mapCharByteWidth(Record.getContext().getTargetInfo(),
+                                      E->getKind())) &&
          "Wrong character width!");
 
   // Deserialize the trailing array of SourceLocation.
@@ -1331,7 +1331,7 @@ void ASTStmtReader::VisitEmbedExpr(EmbedExpr *E) {
   VisitExpr(E);
   E->EmbedKeywordLoc = readSourceLocation();
   EmbedDataStorage *Data = new (Record.getContext()) EmbedDataStorage;
-  Data->BinaryData = cast(Record.readSubStmt());
+  Data->BinaryData = cast(Record.readSubStmt());
   E->Data = Data;
   E->Begin = Record.readInt();
   E->NumOfElements = Record.readInt();
@@ -1445,7 +1445,7 @@ void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
 
 void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
   VisitExpr(E);
-  E->setString(cast(Record.readSubStmt()));
+  E->setString(cast(Record.readSubStmt()));
   E->setAtLoc(readSourceLocation());
 }
 
@@ -3163,7 +3163,7 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
       break;
 
     case EXPR_STRING_LITERAL:
-      S = StringLiteral::CreateEmpty(
+      S = StringRef::CreateEmpty(
           Context,
           /* NumConcatenated=*/Record[ASTStmtReader::NumExprFields],
           /* Length=*/Record[ASTStmtReader::NumExprFields + 1],
diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp b/clang/lib/Serialization/ASTWriterDecl.cpp
index f8ed155ca389d..6eb1a7c9164a5 100644
--- a/clang/lib/Serialization/ASTWriterDecl.cpp
+++ b/clang/lib/Serialization/ASTWriterDecl.cpp
@@ -783,7 +783,7 @@ void ASTDeclWriter::VisitFunctionDecl(FunctionDecl *D) {
     if (auto *FDI = D->getDefalutedOrDeletedInfo()) {
       // Store both that there is an DefaultedOrDeletedInfo and whether it
       // contains a DeletedMessage.
-      StringLiteral *DeletedMessage = FDI->getDeletedMessage();
+      StringRef *DeletedMessage = FDI->getDeletedMessage();
       Record.push_back(1 | (DeletedMessage ? 2 : 0));
       if (DeletedMessage)
         Record.AddStmt(DeletedMessage);
diff --git a/clang/lib/Serialization/ASTWriterStmt.cpp b/clang/lib/Serialization/ASTWriterStmt.cpp
index 7eedf7da7d3fc..121fa08909a7b 100644
--- a/clang/lib/Serialization/ASTWriterStmt.cpp
+++ b/clang/lib/Serialization/ASTWriterStmt.cpp
@@ -753,10 +753,10 @@ void ASTStmtWriter::VisitImaginaryLiteral(ImaginaryLiteral *E) {
   Code = serialization::EXPR_IMAGINARY_LITERAL;
 }
 
-void ASTStmtWriter::VisitStringLiteral(StringLiteral *E) {
+void ASTStmtWriter::VisitStringLiteral(StringRef *E) {
   VisitExpr(E);
 
-  // Store the various bits of data of StringLiteral.
+  // Store the various bits of data of StringRef.
   Record.push_back(E->getNumConcatenated());
   Record.push_back(E->getLength());
   Record.push_back(E->getCharByteWidth());
diff --git a/clang/lib/StaticAnalyzer/Checkers/BitwiseShiftChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/BitwiseShiftChecker.cpp
index ed26ddea93a26..54c3c84d51d63 100644
--- a/clang/lib/StaticAnalyzer/Checkers/BitwiseShiftChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/BitwiseShiftChecker.cpp
@@ -36,8 +36,8 @@ enum class OperandSide { Left, Right };
 using BugReportPtr = std::unique_ptr;
 
 struct NoteTagTemplate {
-  llvm::StringLiteral SignInfo;
-  llvm::StringLiteral UpperBoundIntro;
+  llvm::StringRef SignInfo;
+  llvm::StringRef UpperBoundIntro;
 };
 
 constexpr NoteTagTemplate NoteTagTemplates[] = {
diff --git a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
index 1a14f38e34f0e..79f233cd34549 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -265,10 +265,8 @@ class CStringChecker : public Checker< eval::Call,
                         SVal Buf,
                         bool hypothetical = false) const;
 
-  const StringLiteral *getCStringLiteral(CheckerContext &C,
-                                         ProgramStateRef &state,
-                                         const Expr *expr,
-                                         SVal val) const;
+  const StringRef *getCStringLiteral(CheckerContext &C, ProgramStateRef &state,
+                                     const Expr *expr, SVal val) const;
 
   /// Invalidate the destination buffer determined by characters copied.
   static ProgramStateRef
@@ -1074,7 +1072,7 @@ SVal CStringChecker::getCStringLength(CheckerContext &C, ProgramStateRef &state,
     // so we can assume that the byte length is the correct C string length.
     SValBuilder &svalBuilder = C.getSValBuilder();
     QualType sizeTy = svalBuilder.getContext().getSizeType();
-    const StringLiteral *strLit = cast(MR)->getStringLiteral();
+    const StringRef *strLit = cast(MR)->getStringLiteral();
     return svalBuilder.makeIntVal(strLit->getLength(), sizeTy);
   }
   case MemRegion::NonParamVarRegionKind: {
@@ -1083,7 +1081,7 @@ SVal CStringChecker::getCStringLength(CheckerContext &C, ProgramStateRef &state,
     const VarDecl *Decl = cast(MR)->getDecl();
     if (Decl->getType().isConstQualified() && Decl->hasGlobalStorage()) {
       if (const Expr *Init = Decl->getInit()) {
-        if (auto *StrLit = dyn_cast(Init)) {
+        if (auto *StrLit = dyn_cast(Init)) {
           SValBuilder &SvalBuilder = C.getSValBuilder();
           QualType SizeTy = SvalBuilder.getContext().getSizeType();
           return SvalBuilder.makeIntVal(StrLit->getLength(), SizeTy);
@@ -1127,8 +1125,10 @@ SVal CStringChecker::getCStringLength(CheckerContext &C, ProgramStateRef &state,
   }
 }
 
-const StringLiteral *CStringChecker::getCStringLiteral(CheckerContext &C,
-  ProgramStateRef &state, const Expr *expr, SVal val) const {
+const StringRef *CStringChecker::getCStringLiteral(CheckerContext &C,
+                                                   ProgramStateRef &state,
+                                                   const Expr *expr,
+                                                   SVal val) const {
 
   // Get the memory region pointed to by the val.
   const MemRegion *bufRegion = val.getAsRegion();
@@ -2354,9 +2354,9 @@ void CStringChecker::evalStrcmpCommon(CheckerContext &C, const CallEvent &Call,
   // For now, we only do this if they're both known string literals.
 
   // Attempt to extract string literals from both expressions.
-  const StringLiteral *LeftStrLiteral =
+  const StringRef *LeftStrLiteral =
       getCStringLiteral(C, state, Left.Expression, LeftVal);
-  const StringLiteral *RightStrLiteral =
+  const StringRef *RightStrLiteral =
       getCStringLiteral(C, state, Right.Expression, RightVal);
   bool canComputeResult = false;
   SVal resultVal = svalBuilder.conjureSymbolVal(nullptr, Call.getOriginExpr(),
@@ -2740,7 +2740,7 @@ void CStringChecker::checkPreStmt(const DeclStmt *DS, CheckerContext &C) const {
     const Expr *Init = D->getInit();
     if (!Init)
       continue;
-    if (!isa(Init))
+    if (!isa(Init))
       continue;
 
     Loc VarLoc = state->getLValue(D, C.getLocationContext());
diff --git a/clang/lib/StaticAnalyzer/Checkers/CastSizeChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/CastSizeChecker.cpp
index 2cff97a591b8c..4c9be1af1992f 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CastSizeChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CastSizeChecker.cpp
@@ -131,7 +131,7 @@ void CastSizeChecker::checkPreStmt(const CastExpr *CE,CheckerContext &C) const {
     return;
 
   if (ExplodedNode *errorNode = C.generateErrorNode()) {
-    constexpr llvm::StringLiteral Msg =
+    constexpr llvm::StringRef Msg =
         "Cast a region whose size is not a multiple of the destination type "
         "size.";
     auto R = std::make_unique(BT, Msg, errorNode);
diff --git a/clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp b/clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
index 17af1aebd6d2a..50dd3951a9eff 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
@@ -608,9 +608,8 @@ void WalkAST::checkCall_mkstemp(const CallExpr *CE, const FunctionDecl *FD) {
   if ((signed) numArgs <= ArgSuffix.first)
     return;
 
-  const StringLiteral *strArg =
-    dyn_cast(CE->getArg((unsigned)ArgSuffix.first)
-                              ->IgnoreParenImpCasts());
+  const StringRef *strArg = dyn_cast(
+      CE->getArg((unsigned)ArgSuffix.first)->IgnoreParenImpCasts());
 
   // Currently we only handle string literals.  It is possible to do better,
   // either by looking at references to const variables, or by doing real
@@ -685,7 +684,7 @@ void WalkAST::checkCall_strcpy(const CallExpr *CE, const FunctionDecl *FD) {
 
   if (const auto *Array = dyn_cast(Target->getType())) {
     uint64_t ArraySize = BR.getContext().getTypeSize(Array) / 8;
-    if (const auto *String = dyn_cast(Source)) {
+    if (const auto *String = dyn_cast(Source)) {
       if (ArraySize >= String->getLength() + 1)
         return;
     }
@@ -782,7 +781,7 @@ void WalkAST::checkDeprecatedOrUnsafeBufferHandling(const CallExpr *CE,
     // better, either by looking at references to const variables, or by doing
     // real flow analysis.
     auto FormatString =
-        dyn_cast(CE->getArg(ArgIndex)->IgnoreParenImpCasts());
+        dyn_cast(CE->getArg(ArgIndex)->IgnoreParenImpCasts());
     if (FormatString && !FormatString->getString().contains("%s") &&
         !FormatString->getString().contains("%["))
       BoundsProvided = true;
diff --git a/clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
index 5534ef86a7bef..ba19db781b415 100644
--- a/clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
@@ -76,7 +76,7 @@ class ExprInspectionChecker
 } // namespace
 
 REGISTER_SET_WITH_PROGRAMSTATE(MarkedSymbols, SymbolRef)
-REGISTER_MAP_WITH_PROGRAMSTATE(DenotedSymbols, SymbolRef, const StringLiteral *)
+REGISTER_MAP_WITH_PROGRAMSTATE(DenotedSymbols, SymbolRef, const StringRef *)
 
 bool ExprInspectionChecker::evalCall(const CallEvent &Call,
                                      CheckerContext &C) const {
@@ -450,7 +450,7 @@ void ExprInspectionChecker::analyzerDenote(const CallExpr *CE,
     return;
   }
 
-  const auto *E = dyn_cast(CE->getArg(1)->IgnoreParenCasts());
+  const auto *E = dyn_cast(CE->getArg(1)->IgnoreParenCasts());
   if (!E) {
     reportBug("Not a string literal", C);
     return;
@@ -470,8 +470,8 @@ class SymbolExpressor
   SymbolExpressor(ProgramStateRef State) : State(State) {}
 
   std::optional lookup(const SymExpr *S) {
-    if (const StringLiteral *const *SLPtr = State->get(S)) {
-      const StringLiteral *SL = *SLPtr;
+    if (const StringRef *const *SLPtr = State->get(S)) {
+      const StringRef *SL = *SLPtr;
       return std::string(SL->getBytes());
     }
     return std::nullopt;
diff --git a/clang/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp
index f7fd92db7757e..85e324f042de3 100644
--- a/clang/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp
@@ -59,7 +59,7 @@ void FixedAddressChecker::checkPreStmt(const BinaryOperator *B,
 
   if (ExplodedNode *N = C.generateNonFatalErrorNode()) {
     // FIXME: improve grammar in the following strings:
-    constexpr llvm::StringLiteral Msg =
+    constexpr llvm::StringRef Msg =
         "Using a fixed address is not portable because that address will "
         "probably not be valid in all environments or platforms.";
     auto R = std::make_unique(BT, Msg, N);
diff --git a/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
index b89a6e2588c98..d883ff5b8a5de 100644
--- a/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
@@ -49,19 +49,19 @@ namespace {
 class GenericTaintChecker;
 
 /// Check for CWE-134: Uncontrolled Format String.
-constexpr llvm::StringLiteral MsgUncontrolledFormatString =
+constexpr llvm::StringRef MsgUncontrolledFormatString =
     "Untrusted data is used as a format string "
     "(CWE-134: Uncontrolled Format String)";
 
 /// Check for:
 /// CERT/STR02-C. "Sanitize data passed to complex subsystems"
 /// CWE-78, "Failure to Sanitize Data into an OS Command"
-constexpr llvm::StringLiteral MsgSanitizeSystemArgs =
+constexpr llvm::StringRef MsgSanitizeSystemArgs =
     "Untrusted data is passed to a system call "
     "(CERT/STR02-C. Sanitize data passed to complex subsystems)";
 
 /// Check if tainted data is used as a custom sink's parameter.
-constexpr llvm::StringLiteral MsgCustomSink =
+constexpr llvm::StringRef MsgCustomSink =
     "Untrusted data is passed to a user-defined sink";
 
 using ArgIdxTy = int;
diff --git a/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.h b/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.h
index 0222a2120b34f..7efbbfc160122 100644
--- a/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.h
+++ b/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.h
@@ -67,7 +67,7 @@ class MPIBugReporter {
                            BugReporter &BReporter) const;
 
 private:
-  const llvm::StringLiteral MPIError = "MPI Error";
+  const llvm::StringRef MPIError = "MPI Error";
   const BugType UnmatchedWaitBugType;
   const BugType MissingWaitBugType;
   const BugType DoubleNonblockingBugType;
diff --git a/clang/lib/StaticAnalyzer/Checkers/OSObjectCStyleCast.cpp b/clang/lib/StaticAnalyzer/Checkers/OSObjectCStyleCast.cpp
index 46690dd886b2b..ed3e19fdcaa83 100644
--- a/clang/lib/StaticAnalyzer/Checkers/OSObjectCStyleCast.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/OSObjectCStyleCast.cpp
@@ -36,7 +36,7 @@ class OSObjectCStyleCastChecker : public Checker {
 
 namespace clang {
 namespace ast_matchers {
-AST_MATCHER_P(StringLiteral, mentionsBoundType, std::string, BindingID) {
+AST_MATCHER_P(StringRef, mentionsBoundType, std::string, BindingID) {
   return Builder->removeBindings([this, &Node](const BoundNodesMap &Nodes) {
     const DynTypedNode &BN = Nodes.getNode(this->BindingID);
     if (const auto *ND = BN.get()) {
diff --git a/clang/lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp
index 1141f07428b4c..b97b3e72094db 100644
--- a/clang/lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp
@@ -168,7 +168,7 @@ void PointerArithChecker::reportPointerArithMisuse(const Expr *E,
     if (!IsPolymorphic)
       return;
     if (ExplodedNode *N = C.generateNonFatalErrorNode()) {
-      constexpr llvm::StringLiteral Msg =
+      constexpr llvm::StringRef Msg =
           "Pointer arithmetic on a pointer to base class is dangerous "
           "because derived and base class may have different size.";
       auto R = std::make_unique(BT_polyArray, Msg, N);
@@ -188,7 +188,7 @@ void PointerArithChecker::reportPointerArithMisuse(const Expr *E,
     return;
 
   if (ExplodedNode *N = C.generateNonFatalErrorNode()) {
-    constexpr llvm::StringLiteral Msg =
+    constexpr llvm::StringRef Msg =
         "Pointer arithmetic on non-array variables relies on memory layout, "
         "which is dangerous.";
     auto R = std::make_unique(BT_pointerArith, Msg, N);
diff --git a/clang/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp
index 7a85d9e207306..eceb4f9e68388 100644
--- a/clang/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp
@@ -28,7 +28,7 @@ namespace {
 class PointerSubChecker
   : public Checker< check::PreStmt > {
   const BugType BT{this, "Pointer subtraction"};
-  const llvm::StringLiteral Msg_MemRegionDifferent =
+  const llvm::StringRef Msg_MemRegionDifferent =
       "Subtraction of two pointers that do not point into the same array "
       "is undefined behavior.";
 
diff --git a/clang/lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp
index 09d82ebabd4c9..84577a7cfb223 100644
--- a/clang/lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp
@@ -78,7 +78,7 @@ void ReturnPointerRangeChecker::checkPreStmt(const ReturnStmt *RS,
     if (!N)
       return;
 
-    constexpr llvm::StringLiteral Msg =
+    constexpr llvm::StringRef Msg =
         "Returned pointer value points outside the original object "
         "(potential buffer overflow)";
 
diff --git a/clang/lib/StaticAnalyzer/Checkers/SetgidSetuidOrderChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/SetgidSetuidOrderChecker.cpp
index dbe3fd33a6b43..d2b5d38a3c8e6 100644
--- a/clang/lib/StaticAnalyzer/Checkers/SetgidSetuidOrderChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/SetgidSetuidOrderChecker.cpp
@@ -177,7 +177,7 @@ bool SetgidSetuidOrderChecker::isFunctionCalledInArg(
 void SetgidSetuidOrderChecker::emitReport(ProgramStateRef State,
                                           CheckerContext &C) const {
   if (ExplodedNode *N = C.generateNonFatalErrorNode(State)) {
-    llvm::StringLiteral Msg =
+    llvm::StringRef Msg =
         "A 'setgid(getgid())' call following a 'setuid(getuid())' "
         "call is likely to fail; probably the order of these "
         "statements is wrong";
diff --git a/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp b/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
index 321388ad857f4..bfe78da1d2c9c 100644
--- a/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
@@ -101,7 +101,7 @@ REGISTER_MAP_WITH_PROGRAMSTATE(TrackedRegionMap, const MemRegion *, SVal)
 
 // Checks if RD has name in Names and is in std namespace
 static bool hasStdClassWithName(const CXXRecordDecl *RD,
-                                ArrayRef Names) {
+                                ArrayRef Names) {
   if (!RD || !RD->getDeclContext()->isStdNamespace())
     return false;
   if (RD->getDeclName().isIdentifier())
@@ -109,8 +109,8 @@ static bool hasStdClassWithName(const CXXRecordDecl *RD,
   return false;
 }
 
-constexpr llvm::StringLiteral STD_PTR_NAMES[] = {"shared_ptr", "unique_ptr",
-                                                 "weak_ptr"};
+constexpr llvm::StringRef STD_PTR_NAMES[] = {"shared_ptr", "unique_ptr",
+                                             "weak_ptr"};
 
 static bool isStdSmartPtr(const CXXRecordDecl *RD) {
   return hasStdClassWithName(RD, STD_PTR_NAMES);
@@ -239,7 +239,7 @@ bool SmartPtrModeling::isBoolConversionMethod(const CallEvent &Call) const {
   return CD && CD->getConversionType()->isBooleanType();
 }
 
-constexpr llvm::StringLiteral BASIC_OSTREAM_NAMES[] = {"basic_ostream"};
+constexpr llvm::StringRef BASIC_OSTREAM_NAMES[] = {"basic_ostream"};
 
 static bool isStdBasicOstream(const Expr *E) {
   const auto *RD = E->getType()->getAsCXXRecordDecl();
diff --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index 356d63e3e8b80..95f488294867e 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -1811,9 +1811,9 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
   std::optional ConstFPosTPtrTy = getPointerTy(getConstTy(FPosTTy));
   std::optional FPosTPtrRestrictTy = getRestrictTy(FPosTPtrTy);
 
-  constexpr llvm::StringLiteral GenericSuccessMsg(
+  constexpr llvm::StringRef GenericSuccessMsg(
       "Assuming that '{0}' is successful");
-  constexpr llvm::StringLiteral GenericFailureMsg("Assuming that '{0}' fails");
+  constexpr llvm::StringRef GenericFailureMsg("Assuming that '{0}' fails");
 
   // We are finally ready to define specifications for all supported functions.
   //
diff --git a/clang/lib/StaticAnalyzer/Checkers/StdVariantChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/StdVariantChecker.cpp
index a026735bc107f..63415bd4d4450 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdVariantChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdVariantChecker.cpp
@@ -84,7 +84,7 @@ static bool isStdType(const Type *Type, llvm::StringRef TypeName) {
 }
 
 bool isStdVariant(const Type *Type) {
-  return isStdType(Type, llvm::StringLiteral("variant"));
+  return isStdType(Type, llvm::StringRef("variant"));
 }
 
 } // end of namespace clang::ento::tagged_union_modeling
diff --git a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
index 80969ce664530..70509e10c5ceb 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -1869,7 +1869,7 @@ class StreamClosedVisitor final : public BugReporterVisitor {
     Satisfied = true;
     PathDiagnosticLocation Pos(S, BRC.getSourceManager(),
                                N->getLocationContext());
-    llvm::StringLiteral Msg = "Stream is closed here";
+    llvm::StringRef Msg = "Stream is closed here";
     return std::make_shared(Pos, Msg);
   }
 };
diff --git a/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
index da2d16ca9b5dd..fd5d98a0f8e09 100644
--- a/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
@@ -314,10 +314,10 @@ void UnixAPIMisuseChecker::CheckOpenVariant(CheckerContext &C,
 ProgramStateRef UnixAPIMisuseChecker::EnsureGetdelimBufferAndSizeCorrect(
     SVal LinePtrPtrSVal, SVal SizePtrSVal, const Expr *LinePtrPtrExpr,
     const Expr *SizePtrExpr, CheckerContext &C, ProgramStateRef State) const {
-  static constexpr llvm::StringLiteral SizeGreaterThanBufferSize =
+  static constexpr llvm::StringRef SizeGreaterThanBufferSize =
       "The buffer from the first argument is smaller than the size "
       "specified by the second parameter";
-  static constexpr llvm::StringLiteral SizeUndef =
+  static constexpr llvm::StringRef SizeUndef =
       "The buffer from the first argument is not NULL, but the size specified "
       "by the second parameter is undefined.";
 
diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/MemoryUnsafeCastChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/MemoryUnsafeCastChecker.cpp
index eeaccf9b70524..cddcfae76b67d 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/MemoryUnsafeCastChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/MemoryUnsafeCastChecker.cpp
@@ -79,7 +79,7 @@ static void emitDiagnosticsUnrelated(const BoundNodes &Nodes, BugReporter &BR,
 
 namespace clang {
 namespace ast_matchers {
-AST_MATCHER_P(StringLiteral, mentionsBoundType, std::string, BindingID) {
+AST_MATCHER_P(StringRef, mentionsBoundType, std::string, BindingID) {
   return Builder->removeBindings([this, &Node](const BoundNodesMap &Nodes) {
     const auto &BN = Nodes.getNode(this->BindingID);
     if (const auto *ND = BN.get()) {
diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
index 5487fea1b956c..6b53ca691269c 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
@@ -628,7 +628,7 @@ class TrivialFunctionAnalysisVisitor
   bool VisitFloatingLiteral(const FloatingLiteral *E) { return true; }
   bool VisitFixedPointLiteral(const FixedPointLiteral *E) { return true; }
   bool VisitCharacterLiteral(const CharacterLiteral *E) { return true; }
-  bool VisitStringLiteral(const StringLiteral *E) { return true; }
+  bool VisitStringLiteral(const StringRef *E) { return true; }
   bool VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *E) { return true; }
 
   bool VisitConstantExpr(const ConstantExpr *CE) {
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
index 2904eab0097dc..e7974dbda5b9d 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -1118,11 +1118,11 @@ static const Stmt *getTerminatorCondition(const CFGBlock *B) {
   return S;
 }
 
-constexpr llvm::StringLiteral StrEnteringLoop = "Entering loop body";
-constexpr llvm::StringLiteral StrLoopBodyZero = "Loop body executed 0 times";
-constexpr llvm::StringLiteral StrLoopRangeEmpty =
+constexpr llvm::StringRef StrEnteringLoop = "Entering loop body";
+constexpr llvm::StringRef StrLoopBodyZero = "Loop body executed 0 times";
+constexpr llvm::StringRef StrLoopRangeEmpty =
     "Loop body skipped when range is empty";
-constexpr llvm::StringLiteral StrLoopCollectionEmpty =
+constexpr llvm::StringRef StrLoopCollectionEmpty =
     "Loop body skipped when collection is empty";
 
 static std::unique_ptr
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
index a9b4dbb39b5bd..077e2687d3feb 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -692,7 +692,7 @@ bool NoStoreFuncVisitor::wasModifiedBeforeCallExit(
       CallExitBeginN->getState()->getSVal(RegionOfInterest));
 }
 
-static llvm::StringLiteral WillBeUsedForACondition =
+static llvm::StringRef WillBeUsedForACondition =
     ", which participates in a condition later";
 
 PathDiagnosticPieceRef NoStoreFuncVisitor::maybeEmitNote(
@@ -3208,8 +3208,8 @@ bool ConditionBRVisitor::printValue(const Expr *CondVarExpr, raw_ostream &Out,
   return true;
 }
 
-constexpr llvm::StringLiteral ConditionBRVisitor::GenericTrueMessage;
-constexpr llvm::StringLiteral ConditionBRVisitor::GenericFalseMessage;
+constexpr llvm::StringRef ConditionBRVisitor::GenericTrueMessage;
+constexpr llvm::StringRef ConditionBRVisitor::GenericFalseMessage;
 
 bool ConditionBRVisitor::isPieceMessageGeneric(
     const PathDiagnosticPiece *Piece) {
diff --git a/clang/lib/StaticAnalyzer/Core/MemRegion.cpp b/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
index 559c80634c12e..89c5c4b3d5160 100644
--- a/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
+++ b/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -244,7 +244,7 @@ void StaticGlobalSpaceRegion::Profile(llvm::FoldingSetNodeID &ID) const {
 }
 
 void StringRegion::ProfileRegion(llvm::FoldingSetNodeID &ID,
-                                 const StringLiteral *Str,
+                                 const StringRef *Str,
                                  const MemRegion *superRegion) {
   ID.AddInteger(static_cast(StringRegionKind));
   ID.AddPointer(Str);
@@ -552,7 +552,7 @@ void ObjCIvarRegion::dumpToStream(raw_ostream &os) const {
 }
 
 void StringRegion::dumpToStream(raw_ostream &os) const {
-  assert(Str != nullptr && "Expecting non-null StringLiteral");
+  assert(Str != nullptr && "Expecting non-null StringRef");
   Str->printPretty(os, nullptr, PrintingPolicy(getContext().getLangOpts()));
 }
 
@@ -982,7 +982,7 @@ const CodeSpaceRegion *MemRegionManager::getCodeRegion() {
 // Constructing regions.
 //===----------------------------------------------------------------------===//
 
-const StringRegion *MemRegionManager::getStringRegion(const StringLiteral *Str){
+const StringRegion *MemRegionManager::getStringRegion(const StringRef *Str) {
   return getSubRegion(
       Str, cast(getGlobalsRegion()));
 }
diff --git a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
index ad45ab5757a5a..b1395b2b1b341 100644
--- a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -490,7 +490,7 @@ class RegionStoreManager : public StoreManager {
   getSValFromInitListExpr(const InitListExpr *ILE,
                           const SmallVector &ConcreteOffsets,
                           QualType ElemT);
-  SVal getSValFromStringLiteral(const StringLiteral *SL, uint64_t Offset,
+  SVal getSValFromStringLiteral(const StringRef *SL, uint64_t Offset,
                                 QualType ElemT);
 
 public: // Part of public interface to class.
@@ -1825,10 +1825,10 @@ std::optional RegionStoreManager::getConstantValFromConstArrayInitializer(
   if (const auto *ILE = dyn_cast(Init))
     return getSValFromInitListExpr(ILE, ConcreteOffsets, R->getElementType());
 
-  // Handle StringLiteral.
+  // Handle StringRef.
   // Example:
   //   const char arr[] = "abc";
-  if (const auto *SL = dyn_cast(Init))
+  if (const auto *SL = dyn_cast(Init))
     return getSValFromStringLiteral(SL, ConcreteOffsets.front(),
                                     R->getElementType());
 
@@ -1866,7 +1866,7 @@ std::optional RegionStoreManager::getSValFromInitListExpr(
     // Example:
     //   const char arr[] = { "abc" };
     if (ILE->isStringLiteralInit())
-      if (const auto *SL = dyn_cast(ILE->getInit(0)))
+      if (const auto *SL = dyn_cast(ILE->getInit(0)))
         return getSValFromStringLiteral(SL, Offset, ElemT);
 
     // C++20 [expr.add] 9.4.17.5 (excerpt):
@@ -1918,10 +1918,10 @@ std::optional RegionStoreManager::getSValFromInitListExpr(
 /// because in case of array we can get the Decl from VarRegion, but in case
 /// of pointer the region is a StringRegion, which doesn't contain a Decl.
 /// Possible solution could be passing an array extent along with the offset.
-SVal RegionStoreManager::getSValFromStringLiteral(const StringLiteral *SL,
+SVal RegionStoreManager::getSValFromStringLiteral(const StringRef *SL,
                                                   uint64_t Offset,
                                                   QualType ElemT) {
-  assert(SL && "StringLiteral should not be null");
+  assert(SL && "StringRef should not be null");
   // C++20 [dcl.init.string] 9.4.2.3:
   //   If there are fewer initializers than there are array elements, each
   //   element not explicitly initialized shall be zero-initialized [dcl.init].
@@ -1974,7 +1974,7 @@ SVal RegionStoreManager::getBindingForElement(RegionBindingsConstRef B,
       const llvm::APSInt &Idx = CI->getValue();
       if (Idx < 0)
         return UndefinedVal();
-      const StringLiteral *SL = StrR->getStringLiteral();
+      const StringRef *SL = StrR->getStringLiteral();
       return getSValFromStringLiteral(SL, Idx.getZExtValue(), T);
     }
   } else if (isa(superR)) {
diff --git a/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp b/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
index 2b85580186381..e0ecae1c3a6a3 100644
--- a/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ b/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -344,7 +344,7 @@ std::optional SValBuilder::getConstantVal(const Expr *E) {
   }
 
   case Stmt::StringLiteralClass: {
-    const auto *SL = cast(E);
+    const auto *SL = cast(E);
     return makeLoc(getRegionManager().getStringRegion(SL));
   }
 
diff --git a/clang/lib/Tooling/ASTDiff/ASTDiff.cpp b/clang/lib/Tooling/ASTDiff/ASTDiff.cpp
index 5f7153cd53ac2..c32854b7acc59 100644
--- a/clang/lib/Tooling/ASTDiff/ASTDiff.cpp
+++ b/clang/lib/Tooling/ASTDiff/ASTDiff.cpp
@@ -462,7 +462,7 @@ std::string SyntaxTree::Impl::getStmtValue(const Stmt *S) const {
   }
   if (auto *D = dyn_cast(S))
     return getRelativeName(D->getDecl(), getEnclosingDeclContext(AST, S));
-  if (auto *String = dyn_cast(S))
+  if (auto *String = dyn_cast(S))
     return std::string(String->getString());
   if (auto *B = dyn_cast(S))
     return B->getValue() ? "true" : "false";
diff --git a/clang/lib/Tooling/Inclusions/HeaderAnalysis.cpp b/clang/lib/Tooling/Inclusions/HeaderAnalysis.cpp
index 52b634e2e1af8..ba51c36e898f9 100644
--- a/clang/lib/Tooling/Inclusions/HeaderAnalysis.cpp
+++ b/clang/lib/Tooling/Inclusions/HeaderAnalysis.cpp
@@ -100,7 +100,7 @@ std::optional parseIWYUPragma(const char *Text) {
   Text += 2;
 
   // Per spec, direcitves are whitespace- and case-sensitive.
-  constexpr llvm::StringLiteral IWYUPragma = " IWYU pragma: ";
+  constexpr llvm::StringRef IWYUPragma = " IWYU pragma: ";
   if (strncmp(Text, IWYUPragma.data(), IWYUPragma.size()))
     return std::nullopt;
   Text += IWYUPragma.size();
diff --git a/clang/lib/Tooling/Refactoring/ASTSelection.cpp b/clang/lib/Tooling/Refactoring/ASTSelection.cpp
index 058574d8ec1a5..4ec93beb5de3a 100644
--- a/clang/lib/Tooling/Refactoring/ASTSelection.cpp
+++ b/clang/lib/Tooling/Refactoring/ASTSelection.cpp
@@ -267,7 +267,7 @@ getSelectionCanonizalizationAction(const Stmt *S, const Stmt *Parent) {
   // - The string literal in ObjC string literal is selected, e.g.:
   //     @"test"   becomes   @"test"
   //      ~~~~~~             ~~~~~~~
-  if (isa(S) && isa(Parent))
+  if (isa(S) && isa(Parent))
     return SelectParent;
   // The entire call should be selected when just the member expression
   // that refers to the method or the decl ref that refers to the function
diff --git a/clang/lib/Tooling/Syntax/BuildTree.cpp b/clang/lib/Tooling/Syntax/BuildTree.cpp
index 3e50d67f4d6ef..411069b6facb0 100644
--- a/clang/lib/Tooling/Syntax/BuildTree.cpp
+++ b/clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -1147,7 +1147,7 @@ class BuildTreeVisitor : public RecursiveASTVisitor {
     return true;
   }
 
-  bool WalkUpFromStringLiteral(StringLiteral *S) {
+  bool WalkUpFromStringLiteral(StringRef *S) {
     Builder.markChildToken(S->getBeginLoc(), syntax::NodeRole::LiteralToken);
     Builder.foldNode(Builder.getExprRange(S),
                      new (allocator()) syntax::StringLiteralExpression, S);
diff --git a/clang/lib/Tooling/Syntax/TokenBufferTokenManager.cpp b/clang/lib/Tooling/Syntax/TokenBufferTokenManager.cpp
index a06f7e2900d47..86337d4f86985 100644
--- a/clang/lib/Tooling/Syntax/TokenBufferTokenManager.cpp
+++ b/clang/lib/Tooling/Syntax/TokenBufferTokenManager.cpp
@@ -10,7 +10,7 @@
 
 namespace clang {
 namespace syntax {
-constexpr llvm::StringLiteral syntax::TokenBufferTokenManager::Kind;
+constexpr llvm::StringRef syntax::TokenBufferTokenManager::Kind;
 
 std::pair>
 syntax::TokenBufferTokenManager::lexBuffer(
diff --git a/clang/test/AST/ByteCode/records.cpp b/clang/test/AST/ByteCode/records.cpp
index 4601aface135e..baa175fe2e048 100644
--- a/clang/test/AST/ByteCode/records.cpp
+++ b/clang/test/AST/ByteCode/records.cpp
@@ -1537,12 +1537,12 @@ namespace BitSet {
 }
 
 namespace ArrayInitChain {
-  struct StringLiteral {
+  struct StringRef {
     const char *S;
   };
 
   struct CustomOperandVal {
-    StringLiteral Str;
+    StringRef Str;
     unsigned Width;
     unsigned Mask = Width + 1;
   };
diff --git a/clang/test/AST/ast-dump-cxx2c-delete-with-message.cpp b/clang/test/AST/ast-dump-cxx2c-delete-with-message.cpp
index ea16b97da23e4..4885d3efaf54f 100644
--- a/clang/test/AST/ast-dump-cxx2c-delete-with-message.cpp
+++ b/clang/test/AST/ast-dump-cxx2c-delete-with-message.cpp
@@ -7,17 +7,17 @@
 
 struct S {
   // CHECK:      CXXMethodDecl {{.*}} a 'void ()' delete
-  // CHECK-NEXT:   delete message: StringLiteral {{.*}} "foo"
+  // CHECK-NEXT:   delete message: StringRef {{.*}} "foo"
   void a() = delete("foo");
 
   // CHECK:      FunctionTemplateDecl {{.*}} b
   // CHECK-NEXT:   TemplateTypeParmDecl
   // CHECK-NEXT:   CXXMethodDecl {{.*}} b 'void ()' delete
-  // CHECK-NEXT:     delete message: StringLiteral {{.*}} "bar"
+  // CHECK-NEXT:     delete message: StringRef {{.*}} "bar"
   template 
   void b() = delete("bar");
 };
 
 // CHECK:      FunctionDecl {{.*}} c 'void ()' delete
-// CHECK-NEXT:   delete message: StringLiteral {{.*}} "baz"
+// CHECK-NEXT:   delete message: StringRef {{.*}} "baz"
 void c() = delete("baz");
diff --git a/clang/test/AST/ast-dump-decl.cpp b/clang/test/AST/ast-dump-decl.cpp
index e84241cee922f..dbfae4f8fb7f3 100644
--- a/clang/test/AST/ast-dump-decl.cpp
+++ b/clang/test/AST/ast-dump-decl.cpp
@@ -218,7 +218,7 @@ namespace TestStaticAssertDecl {
 // CHECK:      NamespaceDecl{{.*}} TestStaticAssertDecl
 // CHECK-NEXT:   StaticAssertDecl{{.*> .*$}}
 // CHECK-NEXT:     CXXBoolLiteralExpr
-// CHECK-NEXT:     StringLiteral
+// CHECK-NEXT:     StringRef
 
 namespace testFunctionTemplateDecl {
   class A { };
@@ -805,7 +805,7 @@ namespace TestFileScopeAsmDecl {
 }
 // CHECK:      NamespaceDecl{{.*}} TestFileScopeAsmDecl{{$}}
 // CHECK:        FileScopeAsmDecl{{.*> .*$}}
-// CHECK-NEXT:     StringLiteral
+// CHECK-NEXT:     StringRef
 
 namespace TestFriendDecl2 {
   void f();
diff --git a/clang/test/AST/ast-dump-expr-json.c b/clang/test/AST/ast-dump-expr-json.c
index e910864eeed65..6e83f7219f07f 100644
--- a/clang/test/AST/ast-dump-expr-json.c
+++ b/clang/test/AST/ast-dump-expr-json.c
@@ -5083,7 +5083,7 @@ void PrimaryExpressions(int a) {
 // CHECK-NEXT:      "inner": [
 // CHECK-NEXT:       {
 // CHECK-NEXT:        "id": "0x{{.*}}",
-// CHECK-NEXT:        "kind": "StringLiteral",
+// CHECK-NEXT:        "kind": "StringRef",
 // CHECK-NEXT:        "range": {
 // CHECK-NEXT:         "begin": {
 // CHECK-NEXT:          "offset": {{[0-9]+}},
@@ -5128,7 +5128,7 @@ void PrimaryExpressions(int a) {
 // CHECK-NEXT:      "inner": [
 // CHECK-NEXT:       {
 // CHECK-NEXT:        "id": "0x{{.*}}",
-// CHECK-NEXT:        "kind": "StringLiteral",
+// CHECK-NEXT:        "kind": "StringRef",
 // CHECK-NEXT:        "range": {
 // CHECK-NEXT:         "begin": {
 // CHECK-NEXT:          "offset": {{[0-9]+}},
@@ -5173,7 +5173,7 @@ void PrimaryExpressions(int a) {
 // CHECK-NEXT:      "inner": [
 // CHECK-NEXT:       {
 // CHECK-NEXT:        "id": "0x{{.*}}",
-// CHECK-NEXT:        "kind": "StringLiteral",
+// CHECK-NEXT:        "kind": "StringRef",
 // CHECK-NEXT:        "range": {
 // CHECK-NEXT:         "begin": {
 // CHECK-NEXT:          "offset": {{[0-9]+}},
@@ -5218,7 +5218,7 @@ void PrimaryExpressions(int a) {
 // CHECK-NEXT:      "inner": [
 // CHECK-NEXT:       {
 // CHECK-NEXT:        "id": "0x{{.*}}",
-// CHECK-NEXT:        "kind": "StringLiteral",
+// CHECK-NEXT:        "kind": "StringRef",
 // CHECK-NEXT:        "range": {
 // CHECK-NEXT:         "begin": {
 // CHECK-NEXT:          "offset": {{[0-9]+}},
@@ -5263,7 +5263,7 @@ void PrimaryExpressions(int a) {
 // CHECK-NEXT:      "inner": [
 // CHECK-NEXT:       {
 // CHECK-NEXT:        "id": "0x{{.*}}",
-// CHECK-NEXT:        "kind": "StringLiteral",
+// CHECK-NEXT:        "kind": "StringRef",
 // CHECK-NEXT:        "range": {
 // CHECK-NEXT:         "begin": {
 // CHECK-NEXT:          "offset": {{[0-9]+}},
diff --git a/clang/test/AST/ast-dump-expr-json.m b/clang/test/AST/ast-dump-expr-json.m
index 3c502c0496308..f48a04a0318f2 100644
--- a/clang/test/AST/ast-dump-expr-json.m
+++ b/clang/test/AST/ast-dump-expr-json.m
@@ -3462,7 +3462,7 @@ void TestObjCBoolLiteral(void) {
 // CHECK-NEXT:              "inner": [
 // CHECK-NEXT:               {
 // CHECK-NEXT:                "id": "0x{{.*}}",
-// CHECK-NEXT:                "kind": "StringLiteral",
+// CHECK-NEXT:                "kind": "StringRef",
 // CHECK-NEXT:                "range": {
 // CHECK-NEXT:                 "begin": {
 // CHECK-NEXT:                  "offset": {{[0-9]+}},
@@ -3670,7 +3670,7 @@ void TestObjCBoolLiteral(void) {
 // CHECK-NEXT:          "inner": [
 // CHECK-NEXT:           {
 // CHECK-NEXT:            "id": "0x{{.*}}",
-// CHECK-NEXT:            "kind": "StringLiteral",
+// CHECK-NEXT:            "kind": "StringRef",
 // CHECK-NEXT:            "range": {
 // CHECK-NEXT:             "begin": {
 // CHECK-NEXT:              "offset": {{[0-9]+}},
@@ -4144,7 +4144,7 @@ void TestObjCBoolLiteral(void) {
 // CHECK-NEXT:              "inner": [
 // CHECK-NEXT:               {
 // CHECK-NEXT:                "id": "0x{{.*}}",
-// CHECK-NEXT:                "kind": "StringLiteral",
+// CHECK-NEXT:                "kind": "StringRef",
 // CHECK-NEXT:                "range": {
 // CHECK-NEXT:                 "begin": {
 // CHECK-NEXT:                  "offset": {{[0-9]+}},
@@ -4383,7 +4383,7 @@ void TestObjCBoolLiteral(void) {
 // CHECK-NEXT:              "inner": [
 // CHECK-NEXT:               {
 // CHECK-NEXT:                "id": "0x{{.*}}",
-// CHECK-NEXT:                "kind": "StringLiteral",
+// CHECK-NEXT:                "kind": "StringRef",
 // CHECK-NEXT:                "range": {
 // CHECK-NEXT:                 "begin": {
 // CHECK-NEXT:                  "offset": {{[0-9]+}},
@@ -4523,7 +4523,7 @@ void TestObjCBoolLiteral(void) {
 // CHECK-NEXT:            "inner": [
 // CHECK-NEXT:             {
 // CHECK-NEXT:              "id": "0x{{.*}}",
-// CHECK-NEXT:              "kind": "StringLiteral",
+// CHECK-NEXT:              "kind": "StringRef",
 // CHECK-NEXT:              "range": {
 // CHECK-NEXT:               "begin": {
 // CHECK-NEXT:                "offset": {{[0-9]+}},
@@ -4706,7 +4706,7 @@ void TestObjCBoolLiteral(void) {
 // CHECK-NEXT:                "inner": [
 // CHECK-NEXT:                 {
 // CHECK-NEXT:                  "id": "0x{{.*}}",
-// CHECK-NEXT:                  "kind": "StringLiteral",
+// CHECK-NEXT:                  "kind": "StringRef",
 // CHECK-NEXT:                  "range": {
 // CHECK-NEXT:                   "begin": {
 // CHECK-NEXT:                    "offset": {{[0-9]+}},
diff --git a/clang/test/AST/ast-dump-expr.c b/clang/test/AST/ast-dump-expr.c
index 959d61ec9794b..2d05d57d31e8b 100644
--- a/clang/test/AST/ast-dump-expr.c
+++ b/clang/test/AST/ast-dump-expr.c
@@ -300,23 +300,23 @@ void PrimaryExpressions(int a) {
 
   "a";
   // ImplicitCastExpr
-  // CHECK: StringLiteral 0x{{[^ ]*}}  'char[2]' lvalue "a"
+  // CHECK: StringRef 0x{{[^ ]*}}  'char[2]' lvalue "a"
 
   L"a";
   // ImplicitCastExpr
-  // CHECK: StringLiteral 0x{{[^ ]*}}  'int[2]' lvalue L"a"
+  // CHECK: StringRef 0x{{[^ ]*}}  'int[2]' lvalue L"a"
 
   u8"a";
   // ImplicitCastExpr
-  // CHECK: StringLiteral 0x{{[^ ]*}}  'char[2]' lvalue u8"a"
+  // CHECK: StringRef 0x{{[^ ]*}}  'char[2]' lvalue u8"a"
 
   U"a";
   // ImplicitCastExpr
-  // CHECK: StringLiteral 0x{{[^ ]*}}  'unsigned int[2]' lvalue U"a"
+  // CHECK: StringRef 0x{{[^ ]*}}  'unsigned int[2]' lvalue U"a"
 
   u"a";
   // ImplicitCastExpr
-  // CHECK: StringLiteral 0x{{[^ ]*}}  'unsigned short[2]' lvalue u"a"
+  // CHECK: StringRef 0x{{[^ ]*}}  'unsigned short[2]' lvalue u"a"
 
   1;
   // CHECK: IntegerLiteral 0x{{[^ ]*}}  'int' 1
diff --git a/clang/test/AST/ast-dump-recovery.c b/clang/test/AST/ast-dump-recovery.c
index 68d3f182dd9f6..1acc0cd51cc44 100644
--- a/clang/test/AST/ast-dump-recovery.c
+++ b/clang/test/AST/ast-dump-recovery.c
@@ -103,7 +103,7 @@ void test3() {
 void test4() {
   enum GH62446 {
     // CHECK:      RecoveryExpr {{.*}} '' contains-errors lvalue
-    // CHECK-NEXT: |-StringLiteral {{.*}} "a"
+    // CHECK-NEXT: |-StringRef {{.*}} "a"
     // CHECK-NEXT: `-IntegerLiteral {{.*}} 2
     invalid_enum_value = "a" * 2,
     b,
diff --git a/clang/test/AST/ast-dump-recovery.cpp b/clang/test/AST/ast-dump-recovery.cpp
index b59fa3778192f..00bcad796d242 100644
--- a/clang/test/AST/ast-dump-recovery.cpp
+++ b/clang/test/AST/ast-dump-recovery.cpp
@@ -356,7 +356,7 @@ void CtorInitializer() {
     // CHECK-NEXT: |-ParmVarDecl
     // CHECK-NEXT: |-CXXCtorInitializer 'S'
     // CHECK-NEXT: | `-RecoveryExpr {{.*}} 'S'
-    // CHECK-NEXT: |   `-StringLiteral
+    // CHECK-NEXT: |   `-StringRef
 
     BaseInit(double) : S(invalid) {}
     // CHECK:      CXXConstructorDecl {{.*}} BaseInit 'void (double)'
@@ -371,7 +371,7 @@ void CtorInitializer() {
     // CHECK-NEXT: |-ParmVarDecl
     // CHECK-NEXT: |-CXXCtorInitializer 'DelegatingInit'
     // CHECK-NEXT: | `-RecoveryExpr {{.*}} 'DelegatingInit'
-    // CHECK-NEXT: |   `-StringLiteral
+    // CHECK-NEXT: |   `-StringRef
 
     DelegatingInit(double) : DelegatingInit(invalid) {}
     // CHECK:      CXXConstructorDecl {{.*}} DelegatingInit 'void (double)'
diff --git a/clang/test/AST/ast-dump-wchar.cpp b/clang/test/AST/ast-dump-wchar.cpp
index c12115b905033..32317ffdd96b0 100644
--- a/clang/test/AST/ast-dump-wchar.cpp
+++ b/clang/test/AST/ast-dump-wchar.cpp
@@ -9,13 +9,13 @@
 // RUN: | FileCheck %s
 
 char c8[] = u8"test\0\\\"\a\b\f\n\r\t\v\234";
-// CHECK: StringLiteral {{.*}} u8"test\000\\\"\a\b\f\n\r\t\v\234"
+// CHECK: StringRef {{.*}} u8"test\000\\\"\a\b\f\n\r\t\v\234"
 
 char16_t c16[] = u"test\0\\\"\t\a\b\234\u1234";
-// CHECK: StringLiteral {{.*}} u"test\000\\\"\t\a\b\234\u1234"
+// CHECK: StringRef {{.*}} u"test\000\\\"\t\a\b\234\u1234"
 
 char32_t c32[] = U"test\0\\\"\t\a\b\234\u1234\U0010ffff"; // \
-// CHECK: StringLiteral {{.*}} U"test\000\\\"\t\a\b\234\u1234\U0010FFFF"
+// CHECK: StringRef {{.*}} U"test\000\\\"\t\a\b\234\u1234\U0010FFFF"
 
 wchar_t wc[] = L"test\0\\\"\t\a\b\234\u1234\xffffffff"; // \
-// CHECK: StringLiteral {{.*}} L"test\000\\\"\t\a\b\234\x1234\xFFFFFFFF"
+// CHECK: StringRef {{.*}} L"test\000\\\"\t\a\b\234\x1234\xFFFFFFFF"
diff --git a/clang/test/AST/explicit-base-class-move-cntr.cpp b/clang/test/AST/explicit-base-class-move-cntr.cpp
index 808af2fc94336..22246c6df8bd3 100644
--- a/clang/test/AST/explicit-base-class-move-cntr.cpp
+++ b/clang/test/AST/explicit-base-class-move-cntr.cpp
@@ -85,7 +85,7 @@ Derived1 makeDerived1() {
 // CHECK-NEXT:                   "valueCategory": "prvalue",
 // CHECK-NEXT:                   "castKind": "ArrayToPointerDecay",
 
-// CHECK:                          "kind": "StringLiteral",
+// CHECK:                          "kind": "StringRef",
 // CHECK:                          "type": {
 // CHECK-NEXT:                       "qualType": "const char[10]"
 // CHECK-NEXT:                     },
@@ -158,7 +158,7 @@ Derived2 makeDerived2() {
 // CHECK-NEXT:             "valueCategory": "prvalue",
 // CHECK-NEXT:             "castKind": "ArrayToPointerDecay",
 
-// CHECK:                    "kind": "StringLiteral",
+// CHECK:                    "kind": "StringRef",
 // CHECK:                    "type": {
 // CHECK-NEXT:                 "qualType": "const char[8]"
 // CHECK-NEXT:               },
diff --git a/clang/test/Analysis/array-struct.c b/clang/test/Analysis/array-struct.c
index f0eba86fe71bf..b81a0231d499e 100644
--- a/clang/test/Analysis/array-struct.c
+++ b/clang/test/Analysis/array-struct.c
@@ -26,7 +26,7 @@ void f(void) {
   d.data_array[9] = 17;
 }
 
-// StringLiteral in lvalue context and pointer to array type.
+// StringRef in lvalue context and pointer to array type.
 // p: ElementRegion, q: StringRegion
 void f2(void) {
   char *p = "/usr/local";
diff --git a/clang/test/C/C23/n2322.c b/clang/test/C/C23/n2322.c
index c5ac788fb6ed3..f84e096cc3916 100644
--- a/clang/test/C/C23/n2322.c
+++ b/clang/test/C/C23/n2322.c
@@ -10,7 +10,7 @@ void n2322() {
    spans multiple lines \
    before terminating";
 // CHECK: ImplicitCastExpr {{.*}} 
+// CHECK-NEXT: StringRef {{.*}} 
 
   // The line number associated with a pp-directive should be the line number
   // of the line with the first # token.
@@ -24,7 +24,7 @@ void n2322() {
   1000
   "string literal";
 // CHECK: ImplicitCastExpr {{.*}} 
+// CHECK: StringRef {{.*}} 
 
   // The line number associated with a macro invocation should be the line
   // number of the first character of the macro name in the invocation.
diff --git a/clang/test/CXX/drs/cwg177x.cpp b/clang/test/CXX/drs/cwg177x.cpp
index a17fd221b51f0..fedf0864a35d3 100644
--- a/clang/test/CXX/drs/cwg177x.cpp
+++ b/clang/test/CXX/drs/cwg177x.cpp
@@ -17,7 +17,7 @@ namespace cwg1772 { // cwg1772: 14
   // CXX11: CXXMethodDecl{{.+}} operator() 'void () {{.*}}const'
   // CXX11-NEXT: CompoundStmt
   // CXX11-NEXT: PredefinedExpr{{.+}} 'const char[11]' lvalue __func__
-  // CXX11-NEXT: StringLiteral{{.+}} 'const char[11]' lvalue "operator()"
+  // CXX11-NEXT: StringRef{{.+}} 'const char[11]' lvalue "operator()"
 
   void func() {
     // CXX11: FunctionDecl{{.+}} func
@@ -28,7 +28,7 @@ namespace cwg1772 { // cwg1772: 14
   // CXX11: CXXMethodDecl{{.+}} operator() 'void () {{.*}}const'
   // CXX11-NEXT: CompoundStmt
   // CXX11-NEXT: PredefinedExpr{{.+}} 'const char[11]' lvalue __func__
-  // CXX11-NEXT: StringLiteral{{.+}} 'const char[11]' lvalue "operator()"
+  // CXX11-NEXT: StringRef{{.+}} 'const char[11]' lvalue "operator()"
   }
 #endif // __cplusplus >= 201103L
 } // namespace cwg1772
diff --git a/clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp b/clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
index 16e668e971a21..88e73edc3932e 100644
--- a/clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
+++ b/clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
@@ -139,7 +139,7 @@ void test_unexpanded_in_exprs() {
   // IntegerLiteral is uninteresting
   // FloatingLiteral is uninteresting
   // ImaginaryLiteral is uninteresting
-  // StringLiteral is uninteresting
+  // StringRef is uninteresting
   // CharacterLiteral is uninteresting
   (Values); // expected-error{{expression contains unexpanded parameter pack 'Values'}}
   // UnaryOperator
diff --git a/clang/test/Frontend/plugin-attribute.cpp b/clang/test/Frontend/plugin-attribute.cpp
index 094ce9f5cbb85..823f2561d51c6 100644
--- a/clang/test/Frontend/plugin-attribute.cpp
+++ b/clang/test/Frontend/plugin-attribute.cpp
@@ -31,20 +31,20 @@ void fn3() { template_fn<5>(); }
 // CHECK: -AnnotateAttr 0x{{[0-9a-z]+}} {{}} "example"
 // CHECK: -AttributedStmt 0x{{[0-9a-z]+}} {{}}
 // CHECK: -AnnotateAttr 0x{{[0-9a-z]+}} {{}} "example"
-// CHECK: -StringLiteral 0x{{[0-9a-z]+}} {{}} 'const char[{{[0-9]+}}]' lvalue "abc"
+// CHECK: -StringRef 0x{{[0-9a-z]+}} {{}} 'const char[{{[0-9]+}}]' lvalue "abc"
 // CHECK: -IntegerLiteral 0x{{[0-9a-z]+}} {{}} 'int' 3
 // CHECK: -FloatingLiteral 0x{{[0-9a-z]+}} {{}} 'double' 4.000000e+00
 // CHECK: -AnnotateAttr 0x{{[0-9a-z]+}} {{}} "example"
-// CHECK: -StringLiteral 0x{{[0-9a-z]+}} {{}} 'const char[{{[0-9]+}}]' lvalue "somestring"
+// CHECK: -StringRef 0x{{[0-9a-z]+}} {{}} 'const char[{{[0-9]+}}]' lvalue "somestring"
 // CHECK: -IntegerLiteral 0x{{[0-9a-z]+}} {{}} 'int' 1
 // CHECK: -FloatingLiteral 0x{{[0-9a-z]+}} {{}} 'double' 2.000000e+00
 // CHECK: -AnnotateAttr 0x{{[0-9a-z]+}} {{}} Implicit "example"
-// CHECK: -StringLiteral 0x{{[0-9a-z]+}} {{}} 'const char[{{[0-9]+}}]' lvalue "def"
+// CHECK: -StringRef 0x{{[0-9a-z]+}} {{}} 'const char[{{[0-9]+}}]' lvalue "def"
 // CHECK: -BinaryOperator 0x{{[0-9a-z]+}} {{}} 'int' '+'
 // CHECK: -IntegerLiteral 0x{{[0-9a-z]+}} {{}} 'int' 5
 // CHECK: -IntegerLiteral 0x{{[0-9a-z]+}} {{}} 'int' 1
 // CHECK: -AnnotateAttr 0x{{[0-9a-z]+}} {{}} "example"
-// CHECK: -StringLiteral 0x{{[0-9a-z]+}} {{}} 'const char[{{[0-9]+}}]' lvalue "template"
+// CHECK: -StringRef 0x{{[0-9a-z]+}} {{}} 'const char[{{[0-9]+}}]' lvalue "template"
 // CHECK: -IntegerLiteral 0x{{[0-9a-z]+}} {{}} 'int' 5
 
 //--- bad_attr.cpp
diff --git a/clang/test/Index/annotate-tokens.c b/clang/test/Index/annotate-tokens.c
index 08e7a9a02f8f2..812d12b42b04d 100644
--- a/clang/test/Index/annotate-tokens.c
+++ b/clang/test/Index/annotate-tokens.c
@@ -114,7 +114,7 @@ void test() {
 // CHECK: Punctuation: "*" [9:14 - 9:15] VarDecl=hello:9:16 (Definition)
 // CHECK: Identifier: "hello" [9:16 - 9:21] VarDecl=hello:9:16 (Definition)
 // CHECK: Punctuation: "=" [9:22 - 9:23] VarDecl=hello:9:16 (Definition)
-// CHECK: Literal: ""Hello"" [9:24 - 9:31] StringLiteral=
+// CHECK: Literal: ""Hello"" [9:24 - 9:31] StringRef=
 // CHECK: Punctuation: ";" [9:31 - 9:32] DeclStmt=
 // CHECK: Punctuation: "}" [10:1 - 10:2] CompoundStmt=
 // CHECK: Keyword: "__builtin_va_arg" [15:9 - 15:25] UnexposedExpr=
diff --git a/clang/test/Index/load-staticassert.cpp b/clang/test/Index/load-staticassert.cpp
index 99f59885eaed5..c63c4c495d8eb 100644
--- a/clang/test/Index/load-staticassert.cpp
+++ b/clang/test/Index/load-staticassert.cpp
@@ -8,4 +8,4 @@ static_assert(2 + 2 == 4, "Simple maths");
 // CHECK: load-staticassert.cpp:2:15: IntegerLiteral= Extent=[2:15 - 2:16]
 // CHECK: load-staticassert.cpp:2:19: IntegerLiteral= Extent=[2:19 - 2:20]
 // CHECK: load-staticassert.cpp:2:24: IntegerLiteral= Extent=[2:24 - 2:25]
-// CHECK: load-staticassert.cpp:2:27: StringLiteral="Simple maths" Extent=[2:27 - 2:41]
+// CHECK: load-staticassert.cpp:2:27: StringRef="Simple maths" Extent=[2:27 - 2:41]
diff --git a/clang/test/Index/recursive-cxx-member-calls.cpp b/clang/test/Index/recursive-cxx-member-calls.cpp
index 11c011a432cd4..8fcb3f378b31e 100644
--- a/clang/test/Index/recursive-cxx-member-calls.cpp
+++ b/clang/test/Index/recursive-cxx-member-calls.cpp
@@ -922,14 +922,14 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo * Name) {
 // CHECK-tokens: Punctuation: "." [102:15 - 102:16] MemberRefExpr=startswith:52:8
 // CHECK-tokens: Identifier: "startswith" [102:16 - 102:26] MemberRefExpr=startswith:52:8
 // CHECK-tokens: Punctuation: "(" [102:26 - 102:27] CallExpr=startswith:52:8
-// CHECK-tokens: Literal: ""__"" [102:27 - 102:31] StringLiteral=
+// CHECK-tokens: Literal: ""__"" [102:27 - 102:31] StringRef=
 // CHECK-tokens: Punctuation: ")" [102:31 - 102:32] CallExpr=startswith:52:8
 // CHECK-tokens: Punctuation: "&&" [102:33 - 102:35] BinaryOperator=&&
 // CHECK-tokens: Identifier: "AttrName" [102:36 - 102:44] DeclRefExpr=AttrName:101:19
 // CHECK-tokens: Punctuation: "." [102:44 - 102:45] MemberRefExpr=endswith:56:8
 // CHECK-tokens: Identifier: "endswith" [102:45 - 102:53] MemberRefExpr=endswith:56:8
 // CHECK-tokens: Punctuation: "(" [102:53 - 102:54] CallExpr=endswith:56:8
-// CHECK-tokens: Literal: ""__"" [102:54 - 102:58] StringLiteral=
+// CHECK-tokens: Literal: ""__"" [102:54 - 102:58] StringRef=
 // CHECK-tokens: Punctuation: ")" [102:58 - 102:59] CallExpr=endswith:56:8
 // CHECK-tokens: Punctuation: ")" [102:59 - 102:60] IfStmt=
 // CHECK-tokens: Identifier: "AttrName" [103:5 - 103:13] DeclRefExpr=AttrName:101:19
@@ -965,553 +965,553 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo * Name) {
 // CHECK-tokens: Punctuation: "." [106:5 - 106:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [106:6 - 106:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [106:10 - 106:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""weak"" [106:11 - 106:17] StringLiteral=
+// CHECK-tokens: Literal: ""weak"" [106:11 - 106:17] StringRef=
 // CHECK-tokens: Punctuation: "," [106:17 - 106:18] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_weak" [106:19 - 106:26] DeclRefExpr=AT_weak:29:45
 // CHECK-tokens: Punctuation: ")" [106:26 - 106:27] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [107:5 - 107:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [107:6 - 107:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [107:10 - 107:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""weakref"" [107:11 - 107:20] StringLiteral=
+// CHECK-tokens: Literal: ""weakref"" [107:11 - 107:20] StringRef=
 // CHECK-tokens: Punctuation: "," [107:20 - 107:21] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_weakref" [107:22 - 107:32] DeclRefExpr=AT_weakref:29:54
 // CHECK-tokens: Punctuation: ")" [107:32 - 107:33] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [108:5 - 108:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [108:6 - 108:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [108:10 - 108:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""pure"" [108:11 - 108:17] StringLiteral=
+// CHECK-tokens: Literal: ""pure"" [108:11 - 108:17] StringRef=
 // CHECK-tokens: Punctuation: "," [108:17 - 108:18] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_pure" [108:19 - 108:26] DeclRefExpr=AT_pure:26:49
 // CHECK-tokens: Punctuation: ")" [108:26 - 108:27] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [109:5 - 109:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [109:6 - 109:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [109:10 - 109:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""mode"" [109:11 - 109:17] StringLiteral=
+// CHECK-tokens: Literal: ""mode"" [109:11 - 109:17] StringRef=
 // CHECK-tokens: Punctuation: "," [109:17 - 109:18] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_mode" [109:19 - 109:26] DeclRefExpr=AT_mode:20:44
 // CHECK-tokens: Punctuation: ")" [109:26 - 109:27] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [110:5 - 110:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [110:6 - 110:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [110:10 - 110:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""used"" [110:11 - 110:17] StringLiteral=
+// CHECK-tokens: Literal: ""used"" [110:11 - 110:17] StringRef=
 // CHECK-tokens: Punctuation: "," [110:17 - 110:18] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_used" [110:19 - 110:26] DeclRefExpr=AT_used:28:34
 // CHECK-tokens: Punctuation: ")" [110:26 - 110:27] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [111:5 - 111:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [111:6 - 111:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [111:10 - 111:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""alias"" [111:11 - 111:18] StringLiteral=
+// CHECK-tokens: Literal: ""alias"" [111:11 - 111:18] StringRef=
 // CHECK-tokens: Punctuation: "," [111:18 - 111:19] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_alias" [111:20 - 111:28] DeclRefExpr=AT_alias:15:25
 // CHECK-tokens: Punctuation: ")" [111:28 - 111:29] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [112:5 - 112:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [112:6 - 112:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [112:10 - 112:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""align"" [112:11 - 112:18] StringLiteral=
+// CHECK-tokens: Literal: ""align"" [112:11 - 112:18] StringRef=
 // CHECK-tokens: Punctuation: "," [112:18 - 112:19] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_aligned" [112:20 - 112:30] DeclRefExpr=AT_aligned:15:35
 // CHECK-tokens: Punctuation: ")" [112:30 - 112:31] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [113:5 - 113:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [113:6 - 113:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [113:10 - 113:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""final"" [113:11 - 113:18] StringLiteral=
+// CHECK-tokens: Literal: ""final"" [113:11 - 113:18] StringRef=
 // CHECK-tokens: Punctuation: "," [113:18 - 113:19] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_final" [113:20 - 113:28] DeclRefExpr=AT_final:19:40
 // CHECK-tokens: Punctuation: ")" [113:28 - 113:29] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [114:5 - 114:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [114:6 - 114:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [114:10 - 114:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""cdecl"" [114:11 - 114:18] StringLiteral=
+// CHECK-tokens: Literal: ""cdecl"" [114:11 - 114:18] StringRef=
 // CHECK-tokens: Punctuation: "," [114:18 - 114:19] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_cdecl" [114:20 - 114:28] DeclRefExpr=AT_cdecl:17:30
 // CHECK-tokens: Punctuation: ")" [114:28 - 114:29] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [115:5 - 115:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [115:6 - 115:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [115:10 - 115:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""const"" [115:11 - 115:18] StringLiteral=
+// CHECK-tokens: Literal: ""const"" [115:11 - 115:18] StringRef=
 // CHECK-tokens: Punctuation: "," [115:18 - 115:19] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_const" [115:20 - 115:28] DeclRefExpr=AT_const:17:52
 // CHECK-tokens: Punctuation: ")" [115:28 - 115:29] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [116:5 - 116:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [116:6 - 116:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [116:10 - 116:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""__const"" [116:11 - 116:20] StringLiteral=
+// CHECK-tokens: Literal: ""__const"" [116:11 - 116:20] StringRef=
 // CHECK-tokens: Punctuation: "," [116:20 - 116:21] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_const" [116:22 - 116:30] DeclRefExpr=AT_const:17:52
 // CHECK-tokens: Punctuation: ")" [116:30 - 116:31] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [117:5 - 117:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [117:6 - 117:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [117:10 - 117:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""blocks"" [117:11 - 117:19] StringLiteral=
+// CHECK-tokens: Literal: ""blocks"" [117:11 - 117:19] StringRef=
 // CHECK-tokens: Punctuation: "," [117:19 - 117:20] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_blocks" [117:21 - 117:30] DeclRefExpr=AT_blocks:16:57
 // CHECK-tokens: Punctuation: ")" [117:30 - 117:31] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [118:5 - 118:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [118:6 - 118:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [118:10 - 118:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""format"" [118:11 - 118:19] StringLiteral=
+// CHECK-tokens: Literal: ""format"" [118:11 - 118:19] StringRef=
 // CHECK-tokens: Punctuation: "," [118:19 - 118:20] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_format" [118:21 - 118:30] DeclRefExpr=AT_format:19:50
 // CHECK-tokens: Punctuation: ")" [118:30 - 118:31] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [119:5 - 119:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [119:6 - 119:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [119:10 - 119:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""hiding"" [119:11 - 119:19] StringLiteral=
+// CHECK-tokens: Literal: ""hiding"" [119:11 - 119:19] StringRef=
 // CHECK-tokens: Punctuation: "," [119:19 - 119:20] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_hiding" [119:21 - 119:30] DeclRefExpr=AT_hiding:20:22
 // CHECK-tokens: Punctuation: ")" [119:30 - 119:31] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [120:5 - 120:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [120:6 - 120:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [120:10 - 120:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""malloc"" [120:11 - 120:19] StringLiteral=
+// CHECK-tokens: Literal: ""malloc"" [120:11 - 120:19] StringRef=
 // CHECK-tokens: Punctuation: "," [120:19 - 120:20] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_malloc" [120:21 - 120:30] DeclRefExpr=AT_malloc:20:33
 // CHECK-tokens: Punctuation: ")" [120:30 - 120:31] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [121:5 - 121:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [121:6 - 121:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [121:10 - 121:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""packed"" [121:11 - 121:19] StringLiteral=
+// CHECK-tokens: Literal: ""packed"" [121:11 - 121:19] StringRef=
 // CHECK-tokens: Punctuation: "," [121:19 - 121:20] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_packed" [121:21 - 121:30] DeclRefExpr=AT_packed:26:27
 // CHECK-tokens: Punctuation: ")" [121:30 - 121:31] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [122:5 - 122:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [122:6 - 122:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [122:10 - 122:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""unused"" [122:11 - 122:19] StringLiteral=
+// CHECK-tokens: Literal: ""unused"" [122:11 - 122:19] StringRef=
 // CHECK-tokens: Punctuation: "," [122:19 - 122:20] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_unused" [122:21 - 122:30] DeclRefExpr=AT_unused:28:23
 // CHECK-tokens: Punctuation: ")" [122:30 - 122:31] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [123:5 - 123:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [123:6 - 123:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [123:10 - 123:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""aligned"" [123:11 - 123:20] StringLiteral=
+// CHECK-tokens: Literal: ""aligned"" [123:11 - 123:20] StringRef=
 // CHECK-tokens: Punctuation: "," [123:20 - 123:21] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_aligned" [123:22 - 123:32] DeclRefExpr=AT_aligned:15:35
 // CHECK-tokens: Punctuation: ")" [123:32 - 123:33] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [124:5 - 124:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [124:6 - 124:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [124:10 - 124:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""cleanup"" [124:11 - 124:20] StringLiteral=
+// CHECK-tokens: Literal: ""cleanup"" [124:11 - 124:20] StringRef=
 // CHECK-tokens: Punctuation: "," [124:20 - 124:21] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_cleanup" [124:22 - 124:32] DeclRefExpr=AT_cleanup:17:40
 // CHECK-tokens: Punctuation: ")" [124:32 - 124:33] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [125:5 - 125:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [125:6 - 125:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [125:10 - 125:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""naked"" [125:11 - 125:18] StringLiteral=
+// CHECK-tokens: Literal: ""naked"" [125:11 - 125:18] StringRef=
 // CHECK-tokens: Punctuation: "," [125:18 - 125:19] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_naked" [125:20 - 125:28] DeclRefExpr=AT_naked:20:53
 // CHECK-tokens: Punctuation: ")" [125:28 - 125:29] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [126:5 - 126:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [126:6 - 126:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [126:10 - 126:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""nodebug"" [126:11 - 126:20] StringLiteral=
+// CHECK-tokens: Literal: ""nodebug"" [126:11 - 126:20] StringRef=
 // CHECK-tokens: Punctuation: "," [126:20 - 126:21] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_nodebug" [126:22 - 126:32] DeclRefExpr=AT_nodebug:20:63
 // CHECK-tokens: Punctuation: ")" [126:32 - 126:33] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [127:5 - 127:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [127:6 - 127:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [127:10 - 127:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""nonnull"" [127:11 - 127:20] StringLiteral=
+// CHECK-tokens: Literal: ""nonnull"" [127:11 - 127:20] StringRef=
 // CHECK-tokens: Punctuation: "," [127:20 - 127:21] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_nonnull" [127:22 - 127:32] DeclRefExpr=AT_nonnull:21:47
 // CHECK-tokens: Punctuation: ")" [127:32 - 127:33] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [128:5 - 128:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [128:6 - 128:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [128:10 - 128:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""nothrow"" [128:11 - 128:20] StringLiteral=
+// CHECK-tokens: Literal: ""nothrow"" [128:11 - 128:20] StringRef=
 // CHECK-tokens: Punctuation: "," [128:20 - 128:21] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_nothrow" [128:22 - 128:32] DeclRefExpr=AT_nothrow:22:7
 // CHECK-tokens: Punctuation: ")" [128:32 - 128:33] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [129:5 - 129:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [129:6 - 129:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [129:10 - 129:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""objc_gc"" [129:11 - 129:20] StringLiteral=
+// CHECK-tokens: Literal: ""objc_gc"" [129:11 - 129:20] StringRef=
 // CHECK-tokens: Punctuation: "," [129:20 - 129:21] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_objc_gc" [129:22 - 129:32] DeclRefExpr=AT_objc_gc:24:59
 // CHECK-tokens: Punctuation: ")" [129:32 - 129:33] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [130:5 - 130:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [130:6 - 130:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [130:10 - 130:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""regparm"" [130:11 - 130:20] StringLiteral=
+// CHECK-tokens: Literal: ""regparm"" [130:11 - 130:20] StringRef=
 // CHECK-tokens: Punctuation: "," [130:20 - 130:21] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_regparm" [130:22 - 130:32] DeclRefExpr=AT_regparm:26:58
 // CHECK-tokens: Punctuation: ")" [130:32 - 130:33] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [131:5 - 131:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [131:6 - 131:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [131:10 - 131:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""section"" [131:11 - 131:20] StringLiteral=
+// CHECK-tokens: Literal: ""section"" [131:11 - 131:20] StringRef=
 // CHECK-tokens: Punctuation: "," [131:20 - 131:21] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_section" [131:22 - 131:32] DeclRefExpr=AT_section:27:7
 // CHECK-tokens: Punctuation: ")" [131:32 - 131:33] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [132:5 - 132:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [132:6 - 132:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [132:10 - 132:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""stdcall"" [132:11 - 132:20] StringLiteral=
+// CHECK-tokens: Literal: ""stdcall"" [132:11 - 132:20] StringRef=
 // CHECK-tokens: Punctuation: "," [132:20 - 132:21] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_stdcall" [132:22 - 132:32] DeclRefExpr=AT_stdcall:27:32
 // CHECK-tokens: Punctuation: ")" [132:32 - 132:33] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [133:5 - 133:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [133:6 - 133:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [133:10 - 133:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""annotate"" [133:11 - 133:21] StringLiteral=
+// CHECK-tokens: Literal: ""annotate"" [133:11 - 133:21] StringRef=
 // CHECK-tokens: Punctuation: "," [133:21 - 133:22] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_annotate" [133:23 - 133:34] DeclRefExpr=AT_annotate:16:29
 // CHECK-tokens: Punctuation: ")" [133:34 - 133:35] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [134:5 - 134:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [134:6 - 134:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [134:10 - 134:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""fastcall"" [134:11 - 134:21] StringLiteral=
+// CHECK-tokens: Literal: ""fastcall"" [134:11 - 134:21] StringRef=
 // CHECK-tokens: Punctuation: "," [134:21 - 134:22] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_fastcall" [134:23 - 134:34] DeclRefExpr=AT_fastcall:19:27
 // CHECK-tokens: Punctuation: ")" [134:34 - 134:35] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [135:5 - 135:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [135:6 - 135:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [135:10 - 135:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""ibaction"" [135:11 - 135:21] StringLiteral=
+// CHECK-tokens: Literal: ""ibaction"" [135:11 - 135:21] StringRef=
 // CHECK-tokens: Punctuation: "," [135:21 - 135:22] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_IBAction" [135:23 - 135:34] DeclRefExpr=AT_IBAction:14:7
 // CHECK-tokens: Punctuation: ")" [135:34 - 135:35] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [136:5 - 136:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [136:6 - 136:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [136:10 - 136:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""iboutlet"" [136:11 - 136:21] StringLiteral=
+// CHECK-tokens: Literal: ""iboutlet"" [136:11 - 136:21] StringRef=
 // CHECK-tokens: Punctuation: "," [136:21 - 136:22] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_IBOutlet" [136:23 - 136:34] DeclRefExpr=AT_IBOutlet:14:20
 // CHECK-tokens: Punctuation: ")" [136:34 - 136:35] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [137:5 - 137:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [137:6 - 137:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [137:10 - 137:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""iboutletcollection"" [137:11 - 137:31] StringLiteral=
+// CHECK-tokens: Literal: ""iboutletcollection"" [137:11 - 137:31] StringRef=
 // CHECK-tokens: Punctuation: "," [137:31 - 137:32] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_IBOutletCollection" [137:33 - 137:54] DeclRefExpr=AT_IBOutletCollection:14:33
 // CHECK-tokens: Punctuation: ")" [137:54 - 137:55] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [138:5 - 138:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [138:6 - 138:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [138:10 - 138:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""noreturn"" [138:11 - 138:21] StringLiteral=
+// CHECK-tokens: Literal: ""noreturn"" [138:11 - 138:21] StringRef=
 // CHECK-tokens: Punctuation: "," [138:21 - 138:22] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_noreturn" [138:23 - 138:34] DeclRefExpr=AT_noreturn:21:59
 // CHECK-tokens: Punctuation: ")" [138:34 - 138:35] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [139:5 - 139:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [139:6 - 139:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [139:10 - 139:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""noinline"" [139:11 - 139:21] StringLiteral=
+// CHECK-tokens: Literal: ""noinline"" [139:11 - 139:21] StringRef=
 // CHECK-tokens: Punctuation: "," [139:21 - 139:22] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_noinline" [139:23 - 139:34] DeclRefExpr=AT_noinline:21:7
 // CHECK-tokens: Punctuation: ")" [139:34 - 139:35] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [140:5 - 140:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [140:6 - 140:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [140:10 - 140:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""override"" [140:11 - 140:21] StringLiteral=
+// CHECK-tokens: Literal: ""override"" [140:11 - 140:21] StringRef=
 // CHECK-tokens: Punctuation: "," [140:21 - 140:22] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_override" [140:23 - 140:34] DeclRefExpr=AT_override:22:51
 // CHECK-tokens: Punctuation: ")" [140:34 - 140:35] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [141:5 - 141:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [141:6 - 141:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [141:10 - 141:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""sentinel"" [141:11 - 141:21] StringLiteral=
+// CHECK-tokens: Literal: ""sentinel"" [141:11 - 141:21] StringRef=
 // CHECK-tokens: Punctuation: "," [141:21 - 141:22] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_sentinel" [141:23 - 141:34] DeclRefExpr=AT_sentinel:27:19
 // CHECK-tokens: Punctuation: ")" [141:34 - 141:35] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [142:5 - 142:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [142:6 - 142:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [142:10 - 142:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""NSObject"" [142:11 - 142:21] StringLiteral=
+// CHECK-tokens: Literal: ""NSObject"" [142:11 - 142:21] StringRef=
 // CHECK-tokens: Punctuation: "," [142:21 - 142:22] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_nsobject" [142:23 - 142:34] DeclRefExpr=AT_nsobject:22:19
 // CHECK-tokens: Punctuation: ")" [142:34 - 142:35] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [143:5 - 143:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [143:6 - 143:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [143:10 - 143:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""dllimport"" [143:11 - 143:22] StringLiteral=
+// CHECK-tokens: Literal: ""dllimport"" [143:11 - 143:22] StringRef=
 // CHECK-tokens: Punctuation: "," [143:22 - 143:23] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_dllimport" [143:24 - 143:36] DeclRefExpr=AT_dllimport:18:51
 // CHECK-tokens: Punctuation: ")" [143:36 - 143:37] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [144:5 - 144:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [144:6 - 144:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [144:10 - 144:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""dllexport"" [144:11 - 144:22] StringLiteral=
+// CHECK-tokens: Literal: ""dllexport"" [144:11 - 144:22] StringRef=
 // CHECK-tokens: Punctuation: "," [144:22 - 144:23] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_dllexport" [144:24 - 144:36] DeclRefExpr=AT_dllexport:18:37
 // CHECK-tokens: Punctuation: ")" [144:36 - 144:37] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [145:5 - 145:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [145:6 - 145:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [145:10 - 145:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""may_alias"" [145:11 - 145:22] StringLiteral=
+// CHECK-tokens: Literal: ""may_alias"" [145:11 - 145:22] StringRef=
 // CHECK-tokens: Punctuation: "," [145:22 - 145:23] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "IgnoredAttribute" [145:24 - 145:40] DeclRefExpr=IgnoredAttribute:31:25
 // CHECK-tokens: Punctuation: ")" [145:40 - 145:41] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [146:5 - 146:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [146:6 - 146:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [146:10 - 146:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""base_check"" [146:11 - 146:23] StringLiteral=
+// CHECK-tokens: Literal: ""base_check"" [146:11 - 146:23] StringRef=
 // CHECK-tokens: Punctuation: "," [146:23 - 146:24] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_base_check" [146:25 - 146:38] DeclRefExpr=AT_base_check:16:42
 // CHECK-tokens: Punctuation: ")" [146:38 - 146:39] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [147:5 - 147:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [147:6 - 147:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [147:10 - 147:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""deprecated"" [147:11 - 147:23] StringLiteral=
+// CHECK-tokens: Literal: ""deprecated"" [147:11 - 147:23] StringRef=
 // CHECK-tokens: Punctuation: "," [147:23 - 147:24] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_deprecated" [147:25 - 147:38] DeclRefExpr=AT_deprecated:18:7
 // CHECK-tokens: Punctuation: ")" [147:38 - 147:39] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [148:5 - 148:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [148:6 - 148:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [148:10 - 148:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""visibility"" [148:11 - 148:23] StringLiteral=
+// CHECK-tokens: Literal: ""visibility"" [148:11 - 148:23] StringRef=
 // CHECK-tokens: Punctuation: "," [148:23 - 148:24] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_visibility" [148:25 - 148:38] DeclRefExpr=AT_visibility:29:7
 // CHECK-tokens: Punctuation: ")" [148:38 - 148:39] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [149:5 - 149:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [149:6 - 149:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [149:10 - 149:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""destructor"" [149:11 - 149:23] StringLiteral=
+// CHECK-tokens: Literal: ""destructor"" [149:11 - 149:23] StringRef=
 // CHECK-tokens: Punctuation: "," [149:23 - 149:24] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_destructor" [149:25 - 149:38] DeclRefExpr=AT_destructor:18:22
 // CHECK-tokens: Punctuation: ")" [149:38 - 149:39] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [150:5 - 150:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [150:6 - 150:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [150:10 - 150:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""format_arg"" [150:11 - 150:23] StringLiteral=
+// CHECK-tokens: Literal: ""format_arg"" [150:11 - 150:23] StringRef=
 // CHECK-tokens: Punctuation: "," [150:23 - 150:24] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_format_arg" [150:25 - 150:38] DeclRefExpr=AT_format_arg:19:61
 // CHECK-tokens: Punctuation: ")" [150:38 - 150:39] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [151:5 - 151:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [151:6 - 151:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [151:10 - 151:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""gnu_inline"" [151:11 - 151:23] StringLiteral=
+// CHECK-tokens: Literal: ""gnu_inline"" [151:11 - 151:23] StringRef=
 // CHECK-tokens: Punctuation: "," [151:23 - 151:24] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_gnu_inline" [151:25 - 151:38] DeclRefExpr=AT_gnu_inline:20:7
 // CHECK-tokens: Punctuation: ")" [151:38 - 151:39] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [152:5 - 152:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [152:6 - 152:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [152:10 - 152:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""weak_import"" [152:11 - 152:24] StringLiteral=
+// CHECK-tokens: Literal: ""weak_import"" [152:11 - 152:24] StringRef=
 // CHECK-tokens: Punctuation: "," [152:24 - 152:25] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_weak_import" [152:26 - 152:40] DeclRefExpr=AT_weak_import:30:7
 // CHECK-tokens: Punctuation: ")" [152:40 - 152:41] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [153:5 - 153:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [153:6 - 153:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [153:10 - 153:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""vecreturn"" [153:11 - 153:22] StringLiteral=
+// CHECK-tokens: Literal: ""vecreturn"" [153:11 - 153:22] StringRef=
 // CHECK-tokens: Punctuation: "," [153:22 - 153:23] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_vecreturn" [153:24 - 153:36] DeclRefExpr=AT_vecreturn:28:43
 // CHECK-tokens: Punctuation: ")" [153:36 - 153:37] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [154:5 - 154:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [154:6 - 154:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [154:10 - 154:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""vector_size"" [154:11 - 154:24] StringLiteral=
+// CHECK-tokens: Literal: ""vector_size"" [154:11 - 154:24] StringRef=
 // CHECK-tokens: Punctuation: "," [154:24 - 154:25] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_vector_size" [154:26 - 154:40] DeclRefExpr=AT_vector_size:28:57
 // CHECK-tokens: Punctuation: ")" [154:40 - 154:41] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [155:5 - 155:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [155:6 - 155:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [155:10 - 155:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""constructor"" [155:11 - 155:24] StringLiteral=
+// CHECK-tokens: Literal: ""constructor"" [155:11 - 155:24] StringRef=
 // CHECK-tokens: Punctuation: "," [155:24 - 155:25] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_constructor" [155:26 - 155:40] DeclRefExpr=AT_constructor:17:62
 // CHECK-tokens: Punctuation: ")" [155:40 - 155:41] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [156:5 - 156:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [156:6 - 156:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [156:10 - 156:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""unavailable"" [156:11 - 156:24] StringLiteral=
+// CHECK-tokens: Literal: ""unavailable"" [156:11 - 156:24] StringRef=
 // CHECK-tokens: Punctuation: "," [156:24 - 156:25] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_unavailable" [156:26 - 156:40] DeclRefExpr=AT_unavailable:28:7
 // CHECK-tokens: Punctuation: ")" [156:40 - 156:41] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [157:5 - 157:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [157:6 - 157:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [157:10 - 157:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""overloadable"" [157:11 - 157:25] StringLiteral=
+// CHECK-tokens: Literal: ""overloadable"" [157:11 - 157:25] StringRef=
 // CHECK-tokens: Punctuation: "," [157:25 - 157:26] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_overloadable" [157:27 - 157:42] DeclRefExpr=AT_overloadable:25:7
 // CHECK-tokens: Punctuation: ")" [157:42 - 157:43] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [158:5 - 158:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [158:6 - 158:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [158:10 - 158:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""address_space"" [158:11 - 158:26] StringLiteral=
+// CHECK-tokens: Literal: ""address_space"" [158:11 - 158:26] StringRef=
 // CHECK-tokens: Punctuation: "," [158:26 - 158:27] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_address_space" [158:28 - 158:44] DeclRefExpr=AT_address_space:15:7
 // CHECK-tokens: Punctuation: ")" [158:44 - 158:45] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [159:5 - 159:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [159:6 - 159:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [159:10 - 159:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""always_inline"" [159:11 - 159:26] StringLiteral=
+// CHECK-tokens: Literal: ""always_inline"" [159:11 - 159:26] StringRef=
 // CHECK-tokens: Punctuation: "," [159:26 - 159:27] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_always_inline" [159:28 - 159:44] DeclRefExpr=AT_always_inline:15:47
 // CHECK-tokens: Punctuation: ")" [159:44 - 159:45] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [160:5 - 160:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [160:6 - 160:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [160:10 - 160:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""returns_twice"" [160:11 - 160:26] StringLiteral=
+// CHECK-tokens: Literal: ""returns_twice"" [160:11 - 160:26] StringRef=
 // CHECK-tokens: Punctuation: "," [160:26 - 160:27] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_returns_twice" [160:28 - 160:44] DeclRefExpr=AT_returns_twice:31:7
 // CHECK-tokens: Punctuation: ")" [160:44 - 160:45] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [161:5 - 161:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [161:6 - 161:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [161:10 - 161:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""vec_type_hint"" [161:11 - 161:26] StringLiteral=
+// CHECK-tokens: Literal: ""vec_type_hint"" [161:11 - 161:26] StringRef=
 // CHECK-tokens: Punctuation: "," [161:26 - 161:27] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "IgnoredAttribute" [161:28 - 161:44] DeclRefExpr=IgnoredAttribute:31:25
 // CHECK-tokens: Punctuation: ")" [161:44 - 161:45] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [162:5 - 162:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [162:6 - 162:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [162:10 - 162:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""objc_exception"" [162:11 - 162:27] StringLiteral=
+// CHECK-tokens: Literal: ""objc_exception"" [162:11 - 162:27] StringRef=
 // CHECK-tokens: Punctuation: "," [162:27 - 162:28] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_objc_exception" [162:29 - 162:46] DeclRefExpr=AT_objc_exception:22:32
 // CHECK-tokens: Punctuation: ")" [162:46 - 162:47] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [163:5 - 163:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [163:6 - 163:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [163:10 - 163:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""ext_vector_type"" [163:11 - 163:28] StringLiteral=
+// CHECK-tokens: Literal: ""ext_vector_type"" [163:11 - 163:28] StringRef=
 // CHECK-tokens: Punctuation: "," [163:28 - 163:29] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_ext_vector_type" [163:30 - 163:48] DeclRefExpr=AT_ext_vector_type:19:7
 // CHECK-tokens: Punctuation: ")" [163:48 - 163:49] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [164:5 - 164:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [164:6 - 164:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [164:10 - 164:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""transparent_union"" [164:11 - 164:30] StringLiteral=
+// CHECK-tokens: Literal: ""transparent_union"" [164:11 - 164:30] StringRef=
 // CHECK-tokens: Punctuation: "," [164:30 - 164:31] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_transparent_union" [164:32 - 164:52] DeclRefExpr=AT_transparent_union:27:57
 // CHECK-tokens: Punctuation: ")" [164:52 - 164:53] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [165:5 - 165:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [165:6 - 165:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [165:10 - 165:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""analyzer_noreturn"" [165:11 - 165:30] StringLiteral=
+// CHECK-tokens: Literal: ""analyzer_noreturn"" [165:11 - 165:30] StringRef=
 // CHECK-tokens: Punctuation: "," [165:30 - 165:31] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_analyzer_noreturn" [165:32 - 165:52] DeclRefExpr=AT_analyzer_noreturn:16:7
 // CHECK-tokens: Punctuation: ")" [165:52 - 165:53] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [166:5 - 166:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [166:6 - 166:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [166:10 - 166:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""warn_unused_result"" [166:11 - 166:31] StringLiteral=
+// CHECK-tokens: Literal: ""warn_unused_result"" [166:11 - 166:31] StringRef=
 // CHECK-tokens: Punctuation: "," [166:31 - 166:32] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_warn_unused_result" [166:33 - 166:54] DeclRefExpr=AT_warn_unused_result:29:22
 // CHECK-tokens: Punctuation: ")" [166:54 - 166:55] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [167:5 - 167:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [167:6 - 167:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [167:10 - 167:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""carries_dependency"" [167:11 - 167:31] StringLiteral=
+// CHECK-tokens: Literal: ""carries_dependency"" [167:11 - 167:31] StringRef=
 // CHECK-tokens: Punctuation: "," [167:31 - 167:32] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_carries_dependency" [167:33 - 167:54] DeclRefExpr=AT_carries_dependency:17:7
 // CHECK-tokens: Punctuation: ")" [167:54 - 167:55] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [168:5 - 168:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [168:6 - 168:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [168:10 - 168:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""ns_returns_not_retained"" [168:11 - 168:36] StringLiteral=
+// CHECK-tokens: Literal: ""ns_returns_not_retained"" [168:11 - 168:36] StringRef=
 // CHECK-tokens: Punctuation: "," [168:36 - 168:37] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_ns_returns_not_retained" [168:38 - 168:64] DeclRefExpr=AT_ns_returns_not_retained:24:7
 // CHECK-tokens: Punctuation: ")" [168:64 - 168:65] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [169:5 - 169:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [169:6 - 169:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [169:10 - 169:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""ns_returns_retained"" [169:11 - 169:32] StringLiteral=
+// CHECK-tokens: Literal: ""ns_returns_retained"" [169:11 - 169:32] StringRef=
 // CHECK-tokens: Punctuation: "," [169:32 - 169:33] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_ns_returns_retained" [169:34 - 169:56] DeclRefExpr=AT_ns_returns_retained:24:35
 // CHECK-tokens: Punctuation: ")" [169:56 - 169:57] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [170:5 - 170:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [170:6 - 170:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [170:10 - 170:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""cf_returns_not_retained"" [170:11 - 170:36] StringLiteral=
+// CHECK-tokens: Literal: ""cf_returns_not_retained"" [170:11 - 170:36] StringRef=
 // CHECK-tokens: Punctuation: "," [170:36 - 170:37] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_cf_returns_not_retained" [170:38 - 170:64] DeclRefExpr=AT_cf_returns_not_retained:23:7
 // CHECK-tokens: Punctuation: ")" [170:64 - 170:65] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [171:5 - 171:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [171:6 - 171:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [171:10 - 171:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""cf_returns_retained"" [171:11 - 171:32] StringLiteral=
+// CHECK-tokens: Literal: ""cf_returns_retained"" [171:11 - 171:32] StringRef=
 // CHECK-tokens: Punctuation: "," [171:32 - 171:33] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_cf_returns_retained" [171:34 - 171:56] DeclRefExpr=AT_cf_returns_retained:23:35
 // CHECK-tokens: Punctuation: ")" [171:56 - 171:57] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [172:5 - 172:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [172:6 - 172:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [172:10 - 172:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""ownership_returns"" [172:11 - 172:30] StringLiteral=
+// CHECK-tokens: Literal: ""ownership_returns"" [172:11 - 172:30] StringRef=
 // CHECK-tokens: Punctuation: "," [172:30 - 172:31] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_ownership_returns" [172:32 - 172:52] DeclRefExpr=AT_ownership_returns:25:44
 // CHECK-tokens: Punctuation: ")" [172:52 - 172:53] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [173:5 - 173:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [173:6 - 173:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [173:10 - 173:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""ownership_holds"" [173:11 - 173:28] StringLiteral=
+// CHECK-tokens: Literal: ""ownership_holds"" [173:11 - 173:28] StringRef=
 // CHECK-tokens: Punctuation: "," [173:28 - 173:29] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_ownership_holds" [173:30 - 173:48] DeclRefExpr=AT_ownership_holds:25:24
 // CHECK-tokens: Punctuation: ")" [173:48 - 173:49] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [174:5 - 174:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [174:6 - 174:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [174:10 - 174:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""ownership_takes"" [174:11 - 174:28] StringLiteral=
+// CHECK-tokens: Literal: ""ownership_takes"" [174:11 - 174:28] StringRef=
 // CHECK-tokens: Punctuation: "," [174:28 - 174:29] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_ownership_takes" [174:30 - 174:48] DeclRefExpr=AT_ownership_takes:26:7
 // CHECK-tokens: Punctuation: ")" [174:48 - 174:49] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [175:5 - 175:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [175:6 - 175:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [175:10 - 175:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""reqd_work_group_size"" [175:11 - 175:33] StringLiteral=
+// CHECK-tokens: Literal: ""reqd_work_group_size"" [175:11 - 175:33] StringRef=
 // CHECK-tokens: Punctuation: "," [175:33 - 175:34] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_reqd_wg_size" [175:35 - 175:50] DeclRefExpr=AT_reqd_wg_size:30:23
 // CHECK-tokens: Punctuation: ")" [175:50 - 175:51] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [176:5 - 176:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [176:6 - 176:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [176:10 - 176:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""init_priority"" [176:11 - 176:26] StringLiteral=
+// CHECK-tokens: Literal: ""init_priority"" [176:11 - 176:26] StringRef=
 // CHECK-tokens: Punctuation: "," [176:26 - 176:27] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_init_priority" [176:28 - 176:44] DeclRefExpr=AT_init_priority:30:40
 // CHECK-tokens: Punctuation: ")" [176:44 - 176:45] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [177:5 - 177:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [177:6 - 177:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [177:10 - 177:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""no_instrument_function"" [177:11 - 177:35] StringLiteral=
+// CHECK-tokens: Literal: ""no_instrument_function"" [177:11 - 177:35] StringRef=
 // CHECK-tokens: Punctuation: "," [177:35 - 177:36] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_no_instrument_function" [177:37 - 177:62] DeclRefExpr=AT_no_instrument_function:21:20
 // CHECK-tokens: Punctuation: ")" [177:62 - 177:63] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [178:5 - 178:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [178:6 - 178:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [178:10 - 178:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""thiscall"" [178:11 - 178:21] StringLiteral=
+// CHECK-tokens: Literal: ""thiscall"" [178:11 - 178:21] StringRef=
 // CHECK-tokens: Punctuation: "," [178:21 - 178:22] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_thiscall" [178:23 - 178:34] DeclRefExpr=AT_thiscall:27:44
 // CHECK-tokens: Punctuation: ")" [178:34 - 178:35] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [179:5 - 179:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [179:6 - 179:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [179:10 - 179:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""pascal"" [179:11 - 179:19] StringLiteral=
+// CHECK-tokens: Literal: ""pascal"" [179:11 - 179:19] StringRef=
 // CHECK-tokens: Punctuation: "," [179:19 - 179:20] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_pascal" [179:21 - 179:30] DeclRefExpr=AT_pascal:26:38
 // CHECK-tokens: Punctuation: ")" [179:30 - 179:31] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [180:5 - 180:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [180:6 - 180:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [180:10 - 180:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""__cdecl"" [180:11 - 180:20] StringLiteral=
+// CHECK-tokens: Literal: ""__cdecl"" [180:11 - 180:20] StringRef=
 // CHECK-tokens: Punctuation: "," [180:20 - 180:21] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_cdecl" [180:22 - 180:30] DeclRefExpr=AT_cdecl:17:30
 // CHECK-tokens: Punctuation: ")" [180:30 - 180:31] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [181:5 - 181:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [181:6 - 181:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [181:10 - 181:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""__stdcall"" [181:11 - 181:22] StringLiteral=
+// CHECK-tokens: Literal: ""__stdcall"" [181:11 - 181:22] StringRef=
 // CHECK-tokens: Punctuation: "," [181:22 - 181:23] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_stdcall" [181:24 - 181:34] DeclRefExpr=AT_stdcall:27:32
 // CHECK-tokens: Punctuation: ")" [181:34 - 181:35] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [182:5 - 182:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [182:6 - 182:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [182:10 - 182:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""__fastcall"" [182:11 - 182:23] StringLiteral=
+// CHECK-tokens: Literal: ""__fastcall"" [182:11 - 182:23] StringRef=
 // CHECK-tokens: Punctuation: "," [182:23 - 182:24] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_fastcall" [182:25 - 182:36] DeclRefExpr=AT_fastcall:19:27
 // CHECK-tokens: Punctuation: ")" [182:36 - 182:37] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [183:5 - 183:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [183:6 - 183:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [183:10 - 183:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""__thiscall"" [183:11 - 183:23] StringLiteral=
+// CHECK-tokens: Literal: ""__thiscall"" [183:11 - 183:23] StringRef=
 // CHECK-tokens: Punctuation: "," [183:23 - 183:24] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_thiscall" [183:25 - 183:36] DeclRefExpr=AT_thiscall:27:44
 // CHECK-tokens: Punctuation: ")" [183:36 - 183:37] CallExpr=Case:88:42
 // CHECK-tokens: Punctuation: "." [184:5 - 184:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [184:6 - 184:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [184:10 - 184:11] CallExpr=Case:88:42
-// CHECK-tokens: Literal: ""__pascal"" [184:11 - 184:21] StringLiteral=
+// CHECK-tokens: Literal: ""__pascal"" [184:11 - 184:21] StringRef=
 // CHECK-tokens: Punctuation: "," [184:21 - 184:22] CallExpr=Case:88:42
 // CHECK-tokens: Identifier: "AT_pascal" [184:23 - 184:32] DeclRefExpr=AT_pascal:26:38
 // CHECK-tokens: Punctuation: ")" [184:32 - 184:33] CallExpr=Case:88:42
@@ -1888,7 +1888,7 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo * Name) {
 // CHECK: 102:27: UnexposedExpr=StringRef:48:3 Extent=[102:27 - 102:31]
 // CHECK: 102:27: CallExpr=StringRef:48:3 Extent=[102:27 - 102:31]
 // CHECK: 102:27: UnexposedExpr= Extent=[102:27 - 102:31]
-// CHECK: 102:27: StringLiteral="__" Extent=[102:27 - 102:31]
+// CHECK: 102:27: StringRef="__" Extent=[102:27 - 102:31]
 // CHECK: 102:36: CallExpr=endswith:56:8 Extent=[102:36 - 102:59]
 // CHECK: 102:45: MemberRefExpr=endswith:56:8 SingleRefName=[102:45 - 102:53] RefName=[102:45 - 102:53] Extent=[102:36 - 102:53]
 // CHECK: 102:36: UnexposedExpr=AttrName:101:19 Extent=[102:36 - 102:44]
@@ -1898,7 +1898,7 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo * Name) {
 // CHECK: 102:54: UnexposedExpr=StringRef:48:3 Extent=[102:54 - 102:58]
 // CHECK: 102:54: CallExpr=StringRef:48:3 Extent=[102:54 - 102:58]
 // CHECK: 102:54: UnexposedExpr= Extent=[102:54 - 102:58]
-// CHECK: 102:54: StringLiteral="__" Extent=[102:54 - 102:58]
+// CHECK: 102:54: StringRef="__" Extent=[102:54 - 102:58]
 // CHECK: 103:5: CallExpr=operator=:38:7 Extent=[103:5 - 103:55]
 // CHECK: 103:5: DeclRefExpr=AttrName:101:19 Extent=[103:5 - 103:13]
 // CHECK: 103:14: UnexposedExpr=operator=:38:7
@@ -2085,158 +2085,158 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo * Name) {
 // CHECK: 105:54: CallExpr=StringRef:38:7 Extent=[105:54 - 105:62]
 // CHECK: 105:54: UnexposedExpr=AttrName:101:19 Extent=[105:54 - 105:62]
 // CHECK: 105:54: DeclRefExpr=AttrName:101:19 Extent=[105:54 - 105:62]
-// CHECK: 106:11: StringLiteral="weak" Extent=[106:11 - 106:17]
+// CHECK: 106:11: StringRef="weak" Extent=[106:11 - 106:17]
 // CHECK: 106:19: DeclRefExpr=AT_weak:29:45 Extent=[106:19 - 106:26]
-// CHECK: 107:11: StringLiteral="weakref" Extent=[107:11 - 107:20]
+// CHECK: 107:11: StringRef="weakref" Extent=[107:11 - 107:20]
 // CHECK: 107:22: DeclRefExpr=AT_weakref:29:54 Extent=[107:22 - 107:32]
-// CHECK: 108:11: StringLiteral="pure" Extent=[108:11 - 108:17]
+// CHECK: 108:11: StringRef="pure" Extent=[108:11 - 108:17]
 // CHECK: 108:19: DeclRefExpr=AT_pure:26:49 Extent=[108:19 - 108:26]
-// CHECK: 109:11: StringLiteral="mode" Extent=[109:11 - 109:17]
+// CHECK: 109:11: StringRef="mode" Extent=[109:11 - 109:17]
 // CHECK: 109:19: DeclRefExpr=AT_mode:20:44 Extent=[109:19 - 109:26]
-// CHECK: 110:11: StringLiteral="used" Extent=[110:11 - 110:17]
+// CHECK: 110:11: StringRef="used" Extent=[110:11 - 110:17]
 // CHECK: 110:19: DeclRefExpr=AT_used:28:34 Extent=[110:19 - 110:26]
-// CHECK: 111:11: StringLiteral="alias" Extent=[111:11 - 111:18]
+// CHECK: 111:11: StringRef="alias" Extent=[111:11 - 111:18]
 // CHECK: 111:20: DeclRefExpr=AT_alias:15:25 Extent=[111:20 - 111:28]
-// CHECK: 112:11: StringLiteral="align" Extent=[112:11 - 112:18]
+// CHECK: 112:11: StringRef="align" Extent=[112:11 - 112:18]
 // CHECK: 112:20: DeclRefExpr=AT_aligned:15:35 Extent=[112:20 - 112:30]
-// CHECK: 113:11: StringLiteral="final" Extent=[113:11 - 113:18]
+// CHECK: 113:11: StringRef="final" Extent=[113:11 - 113:18]
 // CHECK: 113:20: DeclRefExpr=AT_final:19:40 Extent=[113:20 - 113:28]
-// CHECK: 114:11: StringLiteral="cdecl" Extent=[114:11 - 114:18]
+// CHECK: 114:11: StringRef="cdecl" Extent=[114:11 - 114:18]
 // CHECK: 114:20: DeclRefExpr=AT_cdecl:17:30 Extent=[114:20 - 114:28]
-// CHECK: 115:11: StringLiteral="const" Extent=[115:11 - 115:18]
+// CHECK: 115:11: StringRef="const" Extent=[115:11 - 115:18]
 // CHECK: 115:20: DeclRefExpr=AT_const:17:52 Extent=[115:20 - 115:28]
-// CHECK: 116:11: StringLiteral="__const" Extent=[116:11 - 116:20]
+// CHECK: 116:11: StringRef="__const" Extent=[116:11 - 116:20]
 // CHECK: 116:22: DeclRefExpr=AT_const:17:52 Extent=[116:22 - 116:30]
-// CHECK: 117:11: StringLiteral="blocks" Extent=[117:11 - 117:19]
+// CHECK: 117:11: StringRef="blocks" Extent=[117:11 - 117:19]
 // CHECK: 117:21: DeclRefExpr=AT_blocks:16:57 Extent=[117:21 - 117:30]
-// CHECK: 118:11: StringLiteral="format" Extent=[118:11 - 118:19]
+// CHECK: 118:11: StringRef="format" Extent=[118:11 - 118:19]
 // CHECK: 118:21: DeclRefExpr=AT_format:19:50 Extent=[118:21 - 118:30]
-// CHECK: 119:11: StringLiteral="hiding" Extent=[119:11 - 119:19]
+// CHECK: 119:11: StringRef="hiding" Extent=[119:11 - 119:19]
 // CHECK: 119:21: DeclRefExpr=AT_hiding:20:22 Extent=[119:21 - 119:30]
-// CHECK: 120:11: StringLiteral="malloc" Extent=[120:11 - 120:19]
+// CHECK: 120:11: StringRef="malloc" Extent=[120:11 - 120:19]
 // CHECK: 120:21: DeclRefExpr=AT_malloc:20:33 Extent=[120:21 - 120:30]
-// CHECK: 121:11: StringLiteral="packed" Extent=[121:11 - 121:19]
+// CHECK: 121:11: StringRef="packed" Extent=[121:11 - 121:19]
 // CHECK: 121:21: DeclRefExpr=AT_packed:26:27 Extent=[121:21 - 121:30]
-// CHECK: 122:11: StringLiteral="unused" Extent=[122:11 - 122:19]
+// CHECK: 122:11: StringRef="unused" Extent=[122:11 - 122:19]
 // CHECK: 122:21: DeclRefExpr=AT_unused:28:23 Extent=[122:21 - 122:30]
-// CHECK: 123:11: StringLiteral="aligned" Extent=[123:11 - 123:20]
+// CHECK: 123:11: StringRef="aligned" Extent=[123:11 - 123:20]
 // CHECK: 123:22: DeclRefExpr=AT_aligned:15:35 Extent=[123:22 - 123:32]
-// CHECK: 124:11: StringLiteral="cleanup" Extent=[124:11 - 124:20]
+// CHECK: 124:11: StringRef="cleanup" Extent=[124:11 - 124:20]
 // CHECK: 124:22: DeclRefExpr=AT_cleanup:17:40 Extent=[124:22 - 124:32]
-// CHECK: 125:11: StringLiteral="naked" Extent=[125:11 - 125:18]
+// CHECK: 125:11: StringRef="naked" Extent=[125:11 - 125:18]
 // CHECK: 125:20: DeclRefExpr=AT_naked:20:53 Extent=[125:20 - 125:28]
-// CHECK: 126:11: StringLiteral="nodebug" Extent=[126:11 - 126:20]
+// CHECK: 126:11: StringRef="nodebug" Extent=[126:11 - 126:20]
 // CHECK: 126:22: DeclRefExpr=AT_nodebug:20:63 Extent=[126:22 - 126:32]
-// CHECK: 127:11: StringLiteral="nonnull" Extent=[127:11 - 127:20]
+// CHECK: 127:11: StringRef="nonnull" Extent=[127:11 - 127:20]
 // CHECK: 127:22: DeclRefExpr=AT_nonnull:21:47 Extent=[127:22 - 127:32]
-// CHECK: 128:11: StringLiteral="nothrow" Extent=[128:11 - 128:20]
+// CHECK: 128:11: StringRef="nothrow" Extent=[128:11 - 128:20]
 // CHECK: 128:22: DeclRefExpr=AT_nothrow:22:7 Extent=[128:22 - 128:32]
-// CHECK: 129:11: StringLiteral="objc_gc" Extent=[129:11 - 129:20]
+// CHECK: 129:11: StringRef="objc_gc" Extent=[129:11 - 129:20]
 // CHECK: 129:22: DeclRefExpr=AT_objc_gc:24:59 Extent=[129:22 - 129:32]
-// CHECK: 130:11: StringLiteral="regparm" Extent=[130:11 - 130:20]
+// CHECK: 130:11: StringRef="regparm" Extent=[130:11 - 130:20]
 // CHECK: 130:22: DeclRefExpr=AT_regparm:26:58 Extent=[130:22 - 130:32]
-// CHECK: 131:11: StringLiteral="section" Extent=[131:11 - 131:20]
+// CHECK: 131:11: StringRef="section" Extent=[131:11 - 131:20]
 // CHECK: 131:22: DeclRefExpr=AT_section:27:7 Extent=[131:22 - 131:32]
-// CHECK: 132:11: StringLiteral="stdcall" Extent=[132:11 - 132:20]
+// CHECK: 132:11: StringRef="stdcall" Extent=[132:11 - 132:20]
 // CHECK: 132:22: DeclRefExpr=AT_stdcall:27:32 Extent=[132:22 - 132:32]
-// CHECK: 133:11: StringLiteral="annotate" Extent=[133:11 - 133:21]
+// CHECK: 133:11: StringRef="annotate" Extent=[133:11 - 133:21]
 // CHECK: 133:23: DeclRefExpr=AT_annotate:16:29 Extent=[133:23 - 133:34]
-// CHECK: 134:11: StringLiteral="fastcall" Extent=[134:11 - 134:21]
+// CHECK: 134:11: StringRef="fastcall" Extent=[134:11 - 134:21]
 // CHECK: 134:23: DeclRefExpr=AT_fastcall:19:27 Extent=[134:23 - 134:34]
-// CHECK: 135:11: StringLiteral="ibaction" Extent=[135:11 - 135:21]
+// CHECK: 135:11: StringRef="ibaction" Extent=[135:11 - 135:21]
 // CHECK: 135:23: DeclRefExpr=AT_IBAction:14:7 Extent=[135:23 - 135:34]
-// CHECK: 136:11: StringLiteral="iboutlet" Extent=[136:11 - 136:21]
+// CHECK: 136:11: StringRef="iboutlet" Extent=[136:11 - 136:21]
 // CHECK: 136:23: DeclRefExpr=AT_IBOutlet:14:20 Extent=[136:23 - 136:34]
-// CHECK: 137:11: StringLiteral="iboutletcollection" Extent=[137:11 - 137:31]
+// CHECK: 137:11: StringRef="iboutletcollection" Extent=[137:11 - 137:31]
 // CHECK: 137:33: DeclRefExpr=AT_IBOutletCollection:14:33 Extent=[137:33 - 137:54]
-// CHECK: 138:11: StringLiteral="noreturn" Extent=[138:11 - 138:21]
+// CHECK: 138:11: StringRef="noreturn" Extent=[138:11 - 138:21]
 // CHECK: 138:23: DeclRefExpr=AT_noreturn:21:59 Extent=[138:23 - 138:34]
-// CHECK: 139:11: StringLiteral="noinline" Extent=[139:11 - 139:21]
+// CHECK: 139:11: StringRef="noinline" Extent=[139:11 - 139:21]
 // CHECK: 139:23: DeclRefExpr=AT_noinline:21:7 Extent=[139:23 - 139:34]
-// CHECK: 140:11: StringLiteral="override" Extent=[140:11 - 140:21]
+// CHECK: 140:11: StringRef="override" Extent=[140:11 - 140:21]
 // CHECK: 140:23: DeclRefExpr=AT_override:22:51 Extent=[140:23 - 140:34]
-// CHECK: 141:11: StringLiteral="sentinel" Extent=[141:11 - 141:21]
+// CHECK: 141:11: StringRef="sentinel" Extent=[141:11 - 141:21]
 // CHECK: 141:23: DeclRefExpr=AT_sentinel:27:19 Extent=[141:23 - 141:34]
-// CHECK: 142:11: StringLiteral="NSObject" Extent=[142:11 - 142:21]
+// CHECK: 142:11: StringRef="NSObject" Extent=[142:11 - 142:21]
 // CHECK: 142:23: DeclRefExpr=AT_nsobject:22:19 Extent=[142:23 - 142:34]
-// CHECK: 143:11: StringLiteral="dllimport" Extent=[143:11 - 143:22]
+// CHECK: 143:11: StringRef="dllimport" Extent=[143:11 - 143:22]
 // CHECK: 143:24: DeclRefExpr=AT_dllimport:18:51 Extent=[143:24 - 143:36]
-// CHECK: 144:11: StringLiteral="dllexport" Extent=[144:11 - 144:22]
+// CHECK: 144:11: StringRef="dllexport" Extent=[144:11 - 144:22]
 // CHECK: 144:24: DeclRefExpr=AT_dllexport:18:37 Extent=[144:24 - 144:36]
-// CHECK: 145:11: StringLiteral="may_alias" Extent=[145:11 - 145:22]
-// CHECK: 146:11: StringLiteral="base_check" Extent=[146:11 - 146:23]
+// CHECK: 145:11: StringRef="may_alias" Extent=[145:11 - 145:22]
+// CHECK: 146:11: StringRef="base_check" Extent=[146:11 - 146:23]
 // CHECK: 146:25: DeclRefExpr=AT_base_check:16:42 Extent=[146:25 - 146:38]
-// CHECK: 147:11: StringLiteral="deprecated" Extent=[147:11 - 147:23]
+// CHECK: 147:11: StringRef="deprecated" Extent=[147:11 - 147:23]
 // CHECK: 147:25: DeclRefExpr=AT_deprecated:18:7 Extent=[147:25 - 147:38]
-// CHECK: 148:11: StringLiteral="visibility" Extent=[148:11 - 148:23]
+// CHECK: 148:11: StringRef="visibility" Extent=[148:11 - 148:23]
 // CHECK: 148:25: DeclRefExpr=AT_visibility:29:7 Extent=[148:25 - 148:38]
-// CHECK: 149:11: StringLiteral="destructor" Extent=[149:11 - 149:23]
+// CHECK: 149:11: StringRef="destructor" Extent=[149:11 - 149:23]
 // CHECK: 149:25: DeclRefExpr=AT_destructor:18:22 Extent=[149:25 - 149:38]
-// CHECK: 150:11: StringLiteral="format_arg" Extent=[150:11 - 150:23]
+// CHECK: 150:11: StringRef="format_arg" Extent=[150:11 - 150:23]
 // CHECK: 150:25: DeclRefExpr=AT_format_arg:19:61 Extent=[150:25 - 150:38]
-// CHECK: 151:11: StringLiteral="gnu_inline" Extent=[151:11 - 151:23]
+// CHECK: 151:11: StringRef="gnu_inline" Extent=[151:11 - 151:23]
 // CHECK: 151:25: DeclRefExpr=AT_gnu_inline:20:7 Extent=[151:25 - 151:38]
-// CHECK: 152:11: StringLiteral="weak_import" Extent=[152:11 - 152:24]
+// CHECK: 152:11: StringRef="weak_import" Extent=[152:11 - 152:24]
 // CHECK: 152:26: DeclRefExpr=AT_weak_import:30:7 Extent=[152:26 - 152:40]
-// CHECK: 153:11: StringLiteral="vecreturn" Extent=[153:11 - 153:22]
+// CHECK: 153:11: StringRef="vecreturn" Extent=[153:11 - 153:22]
 // CHECK: 153:24: DeclRefExpr=AT_vecreturn:28:43 Extent=[153:24 - 153:36]
-// CHECK: 154:11: StringLiteral="vector_size" Extent=[154:11 - 154:24]
+// CHECK: 154:11: StringRef="vector_size" Extent=[154:11 - 154:24]
 // CHECK: 154:26: DeclRefExpr=AT_vector_size:28:57 Extent=[154:26 - 154:40]
-// CHECK: 155:11: StringLiteral="constructor" Extent=[155:11 - 155:24]
+// CHECK: 155:11: StringRef="constructor" Extent=[155:11 - 155:24]
 // CHECK: 155:26: DeclRefExpr=AT_constructor:17:62 Extent=[155:26 - 155:40]
-// CHECK: 156:11: StringLiteral="unavailable" Extent=[156:11 - 156:24]
+// CHECK: 156:11: StringRef="unavailable" Extent=[156:11 - 156:24]
 // CHECK: 156:26: DeclRefExpr=AT_unavailable:28:7 Extent=[156:26 - 156:40]
-// CHECK: 157:11: StringLiteral="overloadable" Extent=[157:11 - 157:25]
+// CHECK: 157:11: StringRef="overloadable" Extent=[157:11 - 157:25]
 // CHECK: 157:27: DeclRefExpr=AT_overloadable:25:7 Extent=[157:27 - 157:42]
-// CHECK: 158:11: StringLiteral="address_space" Extent=[158:11 - 158:26]
+// CHECK: 158:11: StringRef="address_space" Extent=[158:11 - 158:26]
 // CHECK: 158:28: DeclRefExpr=AT_address_space:15:7 Extent=[158:28 - 158:44]
-// CHECK: 159:11: StringLiteral="always_inline" Extent=[159:11 - 159:26]
+// CHECK: 159:11: StringRef="always_inline" Extent=[159:11 - 159:26]
 // CHECK: 159:28: DeclRefExpr=AT_always_inline:15:47 Extent=[159:28 - 159:44]
-// CHECK: 160:11: StringLiteral="returns_twice" Extent=[160:11 - 160:26]
-// CHECK: 161:11: StringLiteral="vec_type_hint" Extent=[161:11 - 161:26]
-// CHECK: 162:11: StringLiteral="objc_exception" Extent=[162:11 - 162:27]
+// CHECK: 160:11: StringRef="returns_twice" Extent=[160:11 - 160:26]
+// CHECK: 161:11: StringRef="vec_type_hint" Extent=[161:11 - 161:26]
+// CHECK: 162:11: StringRef="objc_exception" Extent=[162:11 - 162:27]
 // CHECK: 162:29: DeclRefExpr=AT_objc_exception:22:32 Extent=[162:29 - 162:46]
-// CHECK: 163:11: StringLiteral="ext_vector_type" Extent=[163:11 - 163:28]
+// CHECK: 163:11: StringRef="ext_vector_type" Extent=[163:11 - 163:28]
 // CHECK: 163:30: DeclRefExpr=AT_ext_vector_type:19:7 Extent=[163:30 - 163:48]
-// CHECK: 164:11: StringLiteral="transparent_union" Extent=[164:11 - 164:30]
+// CHECK: 164:11: StringRef="transparent_union" Extent=[164:11 - 164:30]
 // CHECK: 164:32: DeclRefExpr=AT_transparent_union:27:57 Extent=[164:32 - 164:52]
-// CHECK: 165:11: StringLiteral="analyzer_noreturn" Extent=[165:11 - 165:30]
+// CHECK: 165:11: StringRef="analyzer_noreturn" Extent=[165:11 - 165:30]
 // CHECK: 165:32: DeclRefExpr=AT_analyzer_noreturn:16:7 Extent=[165:32 - 165:52]
-// CHECK: 166:11: StringLiteral="warn_unused_result" Extent=[166:11 - 166:31]
+// CHECK: 166:11: StringRef="warn_unused_result" Extent=[166:11 - 166:31]
 // CHECK: 166:33: DeclRefExpr=AT_warn_unused_result:29:22 Extent=[166:33 - 166:54]
-// CHECK: 167:11: StringLiteral="carries_dependency" Extent=[167:11 - 167:31]
+// CHECK: 167:11: StringRef="carries_dependency" Extent=[167:11 - 167:31]
 // CHECK: 167:33: DeclRefExpr=AT_carries_dependency:17:7 Extent=[167:33 - 167:54]
-// CHECK: 168:11: StringLiteral="ns_returns_not_retained" Extent=[168:11 - 168:36]
+// CHECK: 168:11: StringRef="ns_returns_not_retained" Extent=[168:11 - 168:36]
 // CHECK: 168:38: DeclRefExpr=AT_ns_returns_not_retained:24:7 Extent=[168:38 - 168:64]
-// CHECK: 169:11: StringLiteral="ns_returns_retained" Extent=[169:11 - 169:32]
+// CHECK: 169:11: StringRef="ns_returns_retained" Extent=[169:11 - 169:32]
 // CHECK: 169:34: DeclRefExpr=AT_ns_returns_retained:24:35 Extent=[169:34 - 169:56]
-// CHECK: 170:11: StringLiteral="cf_returns_not_retained" Extent=[170:11 - 170:36]
+// CHECK: 170:11: StringRef="cf_returns_not_retained" Extent=[170:11 - 170:36]
 // CHECK: 170:38: DeclRefExpr=AT_cf_returns_not_retained:23:7 Extent=[170:38 - 170:64]
-// CHECK: 171:11: StringLiteral="cf_returns_retained" Extent=[171:11 - 171:32]
+// CHECK: 171:11: StringRef="cf_returns_retained" Extent=[171:11 - 171:32]
 // CHECK: 171:34: DeclRefExpr=AT_cf_returns_retained:23:35 Extent=[171:34 - 171:56]
-// CHECK: 172:11: StringLiteral="ownership_returns" Extent=[172:11 - 172:30]
+// CHECK: 172:11: StringRef="ownership_returns" Extent=[172:11 - 172:30]
 // CHECK: 172:32: DeclRefExpr=AT_ownership_returns:25:44 Extent=[172:32 - 172:52]
-// CHECK: 173:11: StringLiteral="ownership_holds" Extent=[173:11 - 173:28]
+// CHECK: 173:11: StringRef="ownership_holds" Extent=[173:11 - 173:28]
 // CHECK: 173:30: DeclRefExpr=AT_ownership_holds:25:24 Extent=[173:30 - 173:48]
-// CHECK: 174:11: StringLiteral="ownership_takes" Extent=[174:11 - 174:28]
+// CHECK: 174:11: StringRef="ownership_takes" Extent=[174:11 - 174:28]
 // CHECK: 174:30: DeclRefExpr=AT_ownership_takes:26:7 Extent=[174:30 - 174:48]
-// CHECK: 175:11: StringLiteral="reqd_work_group_size" Extent=[175:11 - 175:33]
+// CHECK: 175:11: StringRef="reqd_work_group_size" Extent=[175:11 - 175:33]
 // CHECK: 175:35: DeclRefExpr=AT_reqd_wg_size:30:23 Extent=[175:35 - 175:50]
-// CHECK: 176:11: StringLiteral="init_priority" Extent=[176:11 - 176:26]
+// CHECK: 176:11: StringRef="init_priority" Extent=[176:11 - 176:26]
 // CHECK: 176:28: DeclRefExpr=AT_init_priority:30:40 Extent=[176:28 - 176:44]
-// CHECK: 177:11: StringLiteral="no_instrument_function" Extent=[177:11 - 177:35]
+// CHECK: 177:11: StringRef="no_instrument_function" Extent=[177:11 - 177:35]
 // CHECK: 177:37: DeclRefExpr=AT_no_instrument_function:21:20 Extent=[177:37 - 177:62]
-// CHECK: 178:11: StringLiteral="thiscall" Extent=[178:11 - 178:21]
+// CHECK: 178:11: StringRef="thiscall" Extent=[178:11 - 178:21]
 // CHECK: 178:23: DeclRefExpr=AT_thiscall:27:44 Extent=[178:23 - 178:34]
-// CHECK: 179:11: StringLiteral="pascal" Extent=[179:11 - 179:19]
+// CHECK: 179:11: StringRef="pascal" Extent=[179:11 - 179:19]
 // CHECK: 179:21: DeclRefExpr=AT_pascal:26:38 Extent=[179:21 - 179:30]
-// CHECK: 180:11: StringLiteral="__cdecl" Extent=[180:11 - 180:20]
+// CHECK: 180:11: StringRef="__cdecl" Extent=[180:11 - 180:20]
 // CHECK: 180:22: DeclRefExpr=AT_cdecl:17:30 Extent=[180:22 - 180:30]
-// CHECK: 181:11: StringLiteral="__stdcall" Extent=[181:11 - 181:22]
+// CHECK: 181:11: StringRef="__stdcall" Extent=[181:11 - 181:22]
 // CHECK: 181:24: DeclRefExpr=AT_stdcall:27:32 Extent=[181:24 - 181:34]
-// CHECK: 182:11: StringLiteral="__fastcall" Extent=[182:11 - 182:23]
+// CHECK: 182:11: StringRef="__fastcall" Extent=[182:11 - 182:23]
 // CHECK: 182:25: DeclRefExpr=AT_fastcall:19:27 Extent=[182:25 - 182:36]
-// CHECK: 183:11: StringLiteral="__thiscall" Extent=[183:11 - 183:23]
+// CHECK: 183:11: StringRef="__thiscall" Extent=[183:11 - 183:23]
 // CHECK: 183:25: DeclRefExpr=AT_thiscall:27:44 Extent=[183:25 - 183:36]
-// CHECK: 184:11: StringLiteral="__pascal" Extent=[184:11 - 184:21]
+// CHECK: 184:11: StringRef="__pascal" Extent=[184:11 - 184:21]
 // CHECK: 184:23: DeclRefExpr=AT_pascal:26:38 Extent=[184:23 - 184:32]
diff --git a/clang/test/OpenMP/interop_ast_print.cpp b/clang/test/OpenMP/interop_ast_print.cpp
index fed6febc63085..514a08b05d654 100644
--- a/clang/test/OpenMP/interop_ast_print.cpp
+++ b/clang/test/OpenMP/interop_ast_print.cpp
@@ -179,12 +179,12 @@ void foo1(int *ap, int dev) {
   //DUMP: OMPInteropDirective
   //DUMP: OMPInitClause
   //DUMP: DeclRefExpr{{.*}}'omp_interop_t'{{.*}}Var{{.*}}'I'
-  //DUMP: StringLiteral{{.*}}"cuda"
-  //DUMP: StringLiteral{{.*}}"cuda_driver"
-  //DUMP: StringLiteral{{.*}}"opencl"
-  //DUMP: StringLiteral{{.*}}"sycl"
-  //DUMP: StringLiteral{{.*}}"hip"
-  //DUMP: StringLiteral{{.*}}"level_zero"
+  //DUMP: StringRef{{.*}}"cuda"
+  //DUMP: StringRef{{.*}}"cuda_driver"
+  //DUMP: StringRef{{.*}}"opencl"
+  //DUMP: StringRef{{.*}}"sycl"
+  //DUMP: StringRef{{.*}}"hip"
+  //DUMP: StringRef{{.*}}"level_zero"
   #pragma omp interop init( \
     prefer_type("cuda","cuda_driver","opencl","sycl","hip","level_zero"), \
     targetsync:I)
@@ -193,7 +193,7 @@ void foo1(int *ap, int dev) {
   //DUMP: OMPInteropDirective
   //DUMP: OMPInitClause
   //DUMP: DeclRefExpr{{.*}}'omp_interop_t'{{.*}}Var{{.*}}'I'
-  //DUMP: StringLiteral{{.*}}"level_zero"
+  //DUMP: StringRef{{.*}}"level_zero"
   //DUMP: IntegerLiteral{{.*}}2
   //DUMP: IntegerLiteral{{.*}}4
   #pragma omp interop init(prefer_type("level_zero",2,4),targetsync:I)
@@ -264,7 +264,7 @@ void fooTemp() {
   //DUMP: DeclRefExpr{{.*}}'omp_interop_t'{{.*}}'interop_var'
   //DUMP: DeclRefExpr{{.*}}NonTypeTemplateParm{{.*}}'I' 'int'
   //DUMP: IntegerLiteral{{.*}}'int' 4
-  //DUMP: StringLiteral{{.*}}"level_one"
+  //DUMP: StringRef{{.*}}"level_one"
 
   //PRINT: #pragma omp interop init(prefer_type(3,4,"level_one"), target : interop_var)
   //DUMP: FunctionDecl{{.*}}fooTemp
@@ -276,7 +276,7 @@ void fooTemp() {
   //DUMP: NonTypeTemplateParmDecl{{.*}}'int'{{.*}}I
   //DUMP: IntegerLiteral{{.*}}'int' 3
   //DUMP: IntegerLiteral{{.*}}'int' 4
-  //DUMP: StringLiteral{{.*}}"level_one"
+  //DUMP: StringRef{{.*}}"level_one"
   #pragma omp interop init(prefer_type(I,4,"level_one"), target: interop_var)
 }
 
@@ -291,7 +291,7 @@ void barTemp(T t) {
   //DUMP: OMPInitClause
   //DUMP: DeclRefExpr{{.*}}ParmVar{{.*}}'t' 'T'
   //DUMP: IntegerLiteral{{.*}}'int' 4
-  //DUMP: StringLiteral{{.*}}"level_one"
+  //DUMP: StringRef{{.*}}"level_one"
   #pragma omp interop init(prefer_type(4,"level_one"), target: t)
 
   //PRINT: #pragma omp interop use(t)
diff --git a/clang/test/PCH/exprs.c b/clang/test/PCH/exprs.c
index 1244b2faaf7f2..01e25b153a7f6 100644
--- a/clang/test/PCH/exprs.c
+++ b/clang/test/PCH/exprs.c
@@ -29,7 +29,7 @@ floating_literal *double_ptr = &floating;
 // ImaginaryLiteral
 imaginary_literal *cdouble_ptr = &floating_complex;
 
-// StringLiteral
+// StringRef
 const char* printHello(void) {
   return hello;
 }
diff --git a/clang/test/PCH/exprs.h b/clang/test/PCH/exprs.h
index d6735a727a538..1e35a61b72fd4 100644
--- a/clang/test/PCH/exprs.h
+++ b/clang/test/PCH/exprs.h
@@ -16,7 +16,7 @@ typedef typeof((42.5)) floating_literal;
 // ImaginaryLiteral
 typedef typeof(17.0i) imaginary_literal;
 
-// StringLiteral
+// StringRef
 const char *hello = "Hello" "PCH" "World";
 
 // CharacterLiteral
diff --git a/clang/test/SemaCXX/constant-expression-cxx11.cpp b/clang/test/SemaCXX/constant-expression-cxx11.cpp
index c990dc78deb9b..14ea6a13ae118 100644
--- a/clang/test/SemaCXX/constant-expression-cxx11.cpp
+++ b/clang/test/SemaCXX/constant-expression-cxx11.cpp
@@ -494,7 +494,7 @@ constexpr int strcmp_ce(const char *p, const char *q) {
   return (!*p || *p != *q) ? *p - *q : strcmp_ce(p+1, q+1);
 }
 
-namespace StringLiteral {
+namespace StringRef {
 
 template
 constexpr int MangleChars(const Char *p) {
diff --git a/clang/test/SemaCXX/lambda-expressions.cpp b/clang/test/SemaCXX/lambda-expressions.cpp
index f3deb6ee3f424..5da92c5bc613f 100644
--- a/clang/test/SemaCXX/lambda-expressions.cpp
+++ b/clang/test/SemaCXX/lambda-expressions.cpp
@@ -700,23 +700,23 @@ void Test() {
 namespace GH60518 {
 // Lambdas should not try to capture
 // function parameters that are used in enable_if
-struct StringLiteral {
+struct StringRef {
 template 
-StringLiteral(const char (&array)[N]) // cxx03-note {{declared here}}
+StringRef(const char (&array)[N]) // cxx03-note {{declared here}}
     __attribute__((enable_if(__builtin_strlen(array) == 2, // cxx03-error {{'enable_if' attribute expression never produces a constant expression}} cxx03-note {{read of variable}}
                               "invalid string literal")));
 };
 
 namespace cpp_attribute {
-struct StringLiteral {
+struct StringRef {
 template 
-StringLiteral(const char (&array)[N]) [[clang::annotate_type("test", array)]];
+StringRef(const char (&array)[N]) [[clang::annotate_type("test", array)]];
 };
 }
 
 void Func1() {
-  [[maybe_unused]] auto y = [&](decltype(StringLiteral("xx"))) {}; // cxx03-note {{in instantiation of function template specialization}}
-  [[maybe_unused]] auto z = [&](decltype(cpp_attribute::StringLiteral("xx"))) {};
+  [[maybe_unused]] auto y = [&](decltype(StringRef("xx"))) {}; // cxx03-note {{in instantiation of function template specialization}}
+  [[maybe_unused]] auto z = [&](decltype(cpp_attribute::StringRef("xx"))) {};
 }
 
 }
diff --git a/clang/test/SemaTemplate/instantiate-expr-basic.cpp b/clang/test/SemaTemplate/instantiate-expr-basic.cpp
index a266a6584b06e..14b8aef85edf0 100644
--- a/clang/test/SemaTemplate/instantiate-expr-basic.cpp
+++ b/clang/test/SemaTemplate/instantiate-expr-basic.cpp
@@ -7,7 +7,7 @@ struct S {
     10;       // IntegerLiteral
     10.5;     // FloatingLiteral
     'c';      // CharacterLiteral
-    "hello";  // StringLiteral
+    "hello";  // StringRef
     true;     // CXXBooleanLiteralExpr
     nullptr;  // CXXNullPtrLiteralExpr
     __null;   // GNUNullExpr
diff --git a/clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp b/clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
index ad73daa8e214c..bf2e893849204 100644
--- a/clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
+++ b/clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
@@ -264,7 +264,7 @@ namespace Temporary {
   D d; // expected-error {{pointer to temporary object}}
 }
 
-namespace StringLiteral {
+namespace StringRef {
   template struct Y {};
   Y<&"hello"> y1; // expected-error {{pointer to string literal}}
   Y<"hello"> y2; // expected-error {{reference to string literal}}
diff --git a/clang/test/Tooling/clang-diff-ast.cpp b/clang/test/Tooling/clang-diff-ast.cpp
index a8efda50a4052..4be8c9a15acd1 100644
--- a/clang/test/Tooling/clang-diff-ast.cpp
+++ b/clang/test/Tooling/clang-diff-ast.cpp
@@ -45,7 +45,7 @@ class X : Base {
   // CHECK: ParmVarDecl: i(int)(
   const char *foo(int i) {
     if (i == 0)
-      // CHECK: StringLiteral: foo(
+      // CHECK: StringRef: foo(
       return "foo";
     // CHECK-NOT: ImplicitCastExpr
     return 0;
diff --git a/clang/test/Tooling/clang-diff-basic.cpp b/clang/test/Tooling/clang-diff-basic.cpp
index a0c0163530ffa..556a7a9a42485 100644
--- a/clang/test/Tooling/clang-diff-basic.cpp
+++ b/clang/test/Tooling/clang-diff-basic.cpp
@@ -14,7 +14,7 @@ void foo() {
 // CHECK: Match DeclRefExpr: :foo{{.*}} to DeclRefExpr: :inner::foo
 void main() { inner::foo(); }
 
-// CHECK: Match StringLiteral: foo{{.*}} to StringLiteral: foo
+// CHECK: Match StringRef: foo{{.*}} to StringRef: foo
 const char *b = "f" "o" "o";
 
 // unsigned is canonicalized to unsigned int
diff --git a/clang/test/Tooling/clang-diff-html.test b/clang/test/Tooling/clang-diff-html.test
index 00d9e07d2fcf4..01f8f9ed270e4 100644
--- a/clang/test/Tooling/clang-diff-html.test
+++ b/clang/test/Tooling/clang-diff-html.test
@@ -27,7 +27,7 @@ update + move
 CHECK: 2' class='u m'>2
 
 insertion
-CHECK: "Bar"
 
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index e175aab4499ff..d752983960b4b 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -4518,12 +4518,12 @@ unsigned clang_Cursor_isFunctionInlined(CXCursor C) {
   return FD->isInlined();
 }
 
-static StringLiteral *getCFSTR_value(CallExpr *callExpr) {
+static StringRef *getCFSTR_value(CallExpr *callExpr) {
   if (callExpr->getNumArgs() != 1) {
     return nullptr;
   }
 
-  StringLiteral *S = nullptr;
+  StringRef *S = nullptr;
   auto *arg = callExpr->getArg(0);
   if (arg->getStmtClass() == Stmt::ImplicitCastExprClass) {
     ImplicitCastExpr *I = static_cast(arg);
@@ -4533,9 +4533,9 @@ static StringLiteral *getCFSTR_value(CallExpr *callExpr) {
       return nullptr;
     }
 
-    S = static_cast(I->getSubExprAsWritten());
+    S = static_cast(I->getSubExprAsWritten());
   } else if (arg->getStmtClass() == Stmt::StringLiteralClass) {
-    S = static_cast(callExpr->getArg(0));
+    S = static_cast(callExpr->getArg(0));
   } else {
     return nullptr;
   }
@@ -4663,7 +4663,7 @@ static const ExprEvalResult *evaluateExpr(Expr *expr, CXCursor C) {
     auto *subExpr = I->getSubExprAsWritten();
     if (subExpr->getStmtClass() == Stmt::StringLiteralClass ||
         subExpr->getStmtClass() == Stmt::ObjCStringLiteralClass) {
-      const StringLiteral *StrE = nullptr;
+      const StringRef *StrE = nullptr;
       const ObjCStringLiteral *ObjCExpr;
       ObjCExpr = dyn_cast(subExpr);
 
@@ -4671,7 +4671,7 @@ static const ExprEvalResult *evaluateExpr(Expr *expr, CXCursor C) {
         StrE = ObjCExpr->getString();
         result->EvalType = CXEval_ObjCStrLiteral;
       } else {
-        StrE = cast(I->getSubExprAsWritten());
+        StrE = cast(I->getSubExprAsWritten());
         result->EvalType = CXEval_StrLiteral;
       }
 
@@ -4684,7 +4684,7 @@ static const ExprEvalResult *evaluateExpr(Expr *expr, CXCursor C) {
     }
   } else if (expr->getStmtClass() == Stmt::ObjCStringLiteralClass ||
              expr->getStmtClass() == Stmt::StringLiteralClass) {
-    const StringLiteral *StrE = nullptr;
+    const StringRef *StrE = nullptr;
     const ObjCStringLiteral *ObjCExpr;
     ObjCExpr = dyn_cast(expr);
 
@@ -4692,7 +4692,7 @@ static const ExprEvalResult *evaluateExpr(Expr *expr, CXCursor C) {
       StrE = ObjCExpr->getString();
       result->EvalType = CXEval_ObjCStrLiteral;
     } else {
-      StrE = cast(expr);
+      StrE = cast(expr);
       result->EvalType = CXEval_StrLiteral;
     }
 
@@ -4711,7 +4711,7 @@ static const ExprEvalResult *evaluateExpr(Expr *expr, CXCursor C) {
         CC->getSubExpr()->getStmtClass() == Stmt::CallExprClass) {
 
       callExpr = static_cast(CC->getSubExpr());
-      StringLiteral *S = getCFSTR_value(callExpr);
+      StringRef *S = getCFSTR_value(callExpr);
       if (S) {
         std::string strLiteral(S->getString().str());
         result->EvalType = CXEval_CFStr;
@@ -4737,7 +4737,7 @@ static const ExprEvalResult *evaluateExpr(Expr *expr, CXCursor C) {
         return nullptr;
     } else if (rettype.getAsString() == "CFStringRef") {
 
-      StringLiteral *S = getCFSTR_value(callExpr);
+      StringRef *S = getCFSTR_value(callExpr);
       if (S) {
         std::string strLiteral(S->getString().str());
         result->EvalType = CXEval_CFStr;
@@ -5387,11 +5387,11 @@ CXString clang_getCursorSpelling(CXCursor C) {
 
     if (C.kind == CXCursor_ObjCStringLiteral ||
         C.kind == CXCursor_StringLiteral) {
-      const StringLiteral *SLit;
+      const StringRef *SLit;
       if (const ObjCStringLiteral *OSL = dyn_cast(E)) {
         SLit = OSL->getString();
       } else {
-        SLit = cast(E);
+        SLit = cast(E);
       }
       SmallString<256> Buf;
       llvm::raw_svector_ostream OS(Buf);
@@ -5951,7 +5951,7 @@ CXString clang_getCursorKindSpelling(enum CXCursorKind Kind) {
   case CXCursor_ImaginaryLiteral:
     return cxstring::createRef("ImaginaryLiteral");
   case CXCursor_StringLiteral:
-    return cxstring::createRef("StringLiteral");
+    return cxstring::createRef("StringRef");
   case CXCursor_CharacterLiteral:
     return cxstring::createRef("CharacterLiteral");
   case CXCursor_ParenExpr:
diff --git a/clang/unittests/AST/ASTImporterTest.cpp b/clang/unittests/AST/ASTImporterTest.cpp
index d197d30df3adf..2a513693bdecb 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -509,7 +509,7 @@ TEST_P(ImportExpr, ImportDesignatedInitExpr) {
 
 TEST_P(ImportExpr, ImportPredefinedExpr) {
   MatchVerifier Verifier;
-  // __func__ expands as StringLiteral("declToImport")
+  // __func__ expands as StringRef("declToImport")
   testImport("void declToImport() { (void)__func__; }", Lang_CXX03, "",
              Lang_CXX03, Verifier,
              functionDecl(hasDescendant(predefinedExpr(
diff --git a/clang/unittests/AST/ASTTraverserTest.cpp b/clang/unittests/AST/ASTTraverserTest.cpp
index 8b6e3e90c0ea6..a03794b56c65b 100644
--- a/clang/unittests/AST/ASTTraverserTest.cpp
+++ b/clang/unittests/AST/ASTTraverserTest.cpp
@@ -366,7 +366,7 @@ FunctionDecl 'stringConstruct'
   |         `-ImplicitCastExpr
   |           `-CXXConstructExpr
   |             |-ImplicitCastExpr
-  |             | `-StringLiteral
+  |             | `-StringRef
   |             `-CXXDefaultArgExpr
   |               `-UnaryOperator
   |                 `-IntegerLiteral
@@ -378,7 +378,7 @@ FunctionDecl 'stringConstruct'
       `-MaterializeTemporaryExpr
         `-CXXConstructExpr
           |-ImplicitCastExpr
-          | `-StringLiteral
+          | `-StringRef
           `-CXXDefaultArgExpr
             `-UnaryOperator
               `-IntegerLiteral
@@ -391,11 +391,11 @@ FunctionDecl 'stringConstruct'
 `-CompoundStmt
   |-DeclStmt
   | `-VarDecl 's'
-  |   `-StringLiteral
+  |   `-StringRef
   `-CXXOperatorCallExpr
     |-DeclRefExpr 'operator='
     |-DeclRefExpr 's'
-    `-StringLiteral
+    `-StringRef
 )cpp");
   }
 
@@ -417,7 +417,7 @@ FunctionDecl 'overloadCall'
   |         `-ImplicitCastExpr
   |           `-CXXConstructExpr
   |             |-ImplicitCastExpr
-  |             | `-StringLiteral
+  |             | `-StringRef
   |             `-CXXDefaultArgExpr
   |               `-UnaryOperator
   |                 `-IntegerLiteral
@@ -434,7 +434,7 @@ FunctionDecl 'overloadCall'
 `-CompoundStmt
   |-DeclStmt
   | `-VarDecl 's'
-  |   `-StringLiteral
+  |   `-StringRef
   `-CXXMemberCallExpr
     `-MemberExpr
       `-DeclRefExpr 's'
@@ -486,7 +486,7 @@ StaticAssertDecl
 | `-SubstNonTypeTemplateParmExpr
 |   |-NonTypeTemplateParmDecl 'alignment'
 |   `-IntegerLiteral
-`-StringLiteral
+`-StringRef
 )cpp");
 
     EXPECT_EQ(dumpASTString(TK_IgnoreUnlessSpelledInSource,
@@ -494,7 +494,7 @@ StaticAssertDecl
               R"cpp(
 StaticAssertDecl
 |-IntegerLiteral
-`-StringLiteral
+`-StringRef
 )cpp");
   }
 
diff --git a/clang/unittests/AST/AttrTest.cpp b/clang/unittests/AST/AttrTest.cpp
index 46c3f5729021e..61bde6c47d3f8 100644
--- a/clang/unittests/AST/AttrTest.cpp
+++ b/clang/unittests/AST/AttrTest.cpp
@@ -103,7 +103,7 @@ TEST(Attr, AnnotateType) {
                       &Annotate);
 
     EXPECT_EQ(Annotate->args_size(), 2u);
-    const auto *StringLit = selectFirst(
+    const auto *StringLit = selectFirst(
         "str", match(constantExpr(hasDescendant(stringLiteral().bind("str"))),
                      *Annotate->args_begin()[0], AST->getASTContext()));
     ASSERT_NE(StringLit, nullptr);
diff --git a/clang/unittests/AST/DeclPrinterTest.cpp b/clang/unittests/AST/DeclPrinterTest.cpp
index 6945dff537cae..2f2056dab2fd2 100644
--- a/clang/unittests/AST/DeclPrinterTest.cpp
+++ b/clang/unittests/AST/DeclPrinterTest.cpp
@@ -1374,8 +1374,8 @@ TEST(DeclPrinter, TestTemplateArgumentList15) {
 }
 
 TEST(DeclPrinter, TestTemplateArgumentList16) {
-  llvm::StringLiteral Code = "template struct Z {};";
+  llvm::StringRef Code = "template struct Z {};";
   ASSERT_TRUE(PrintedDeclCXX11Matches(Code, "T1", "typename T1"));
   ASSERT_TRUE(PrintedDeclCXX11Matches(Code, "T2", "typename T2 = bool"));
   ASSERT_TRUE(PrintedDeclCXX11Matches(Code, "NT1", "int NT1"));
@@ -1456,7 +1456,7 @@ TEST(DeclPrinter, TestCXXRecordDecl21) {
 }
 
 TEST(DeclPrinter, TestFunctionParamUglified) {
-  llvm::StringLiteral Code = R"cpp(
+  llvm::StringRef Code = R"cpp(
     class __c;
     void _A(__c *__param);
   )cpp";
@@ -1471,7 +1471,7 @@ TEST(DeclPrinter, TestFunctionParamUglified) {
 }
 
 TEST(DeclPrinter, TestTemplateParamUglified) {
-  llvm::StringLiteral Code = R"cpp(
+  llvm::StringRef Code = R"cpp(
     template  class _Container>
     struct _A{};
   )cpp";
diff --git a/clang/unittests/AST/StmtPrinterTest.cpp b/clang/unittests/AST/StmtPrinterTest.cpp
index 24ad5f30d9480..339b54d459bfc 100644
--- a/clang/unittests/AST/StmtPrinterTest.cpp
+++ b/clang/unittests/AST/StmtPrinterTest.cpp
@@ -298,7 +298,7 @@ TEST(StmtPrinter, TerseOutputWithLambdas) {
 }
 
 TEST(StmtPrinter, ParamsUglified) {
-  llvm::StringLiteral Code = R"cpp(
+  llvm::StringRef Code = R"cpp(
     template  class _C>
     auto foo(int __j) {
       return typename _C<_T>::_F(_I, __j);
diff --git a/clang/unittests/AST/StructuralEquivalenceTest.cpp b/clang/unittests/AST/StructuralEquivalenceTest.cpp
index 7cf52df9b14d0..db3ed8c6b5cb9 100644
--- a/clang/unittests/AST/StructuralEquivalenceTest.cpp
+++ b/clang/unittests/AST/StructuralEquivalenceTest.cpp
@@ -2324,7 +2324,7 @@ TEST_F(StructuralEquivalenceStmtTest, ObjCStringLiteralDifferentContent) {
   EXPECT_FALSE(testStructuralMatch(t));
 }
 
-TEST_F(StructuralEquivalenceStmtTest, StringLiteral) {
+TEST_F(StructuralEquivalenceStmtTest, StringRef) {
   auto t = makeWrappedStmts("\"a\"", "\"a\"", Lang_CXX03, stringLiteral());
   EXPECT_TRUE(testStructuralMatch(t));
 }
diff --git a/clang/unittests/AST/TypePrinterTest.cpp b/clang/unittests/AST/TypePrinterTest.cpp
index 494085a2ebca6..dfe5fc5429f01 100644
--- a/clang/unittests/AST/TypePrinterTest.cpp
+++ b/clang/unittests/AST/TypePrinterTest.cpp
@@ -81,7 +81,7 @@ TEST(TypePrinter, TemplateId2) {
 }
 
 TEST(TypePrinter, ParamsUglified) {
-  llvm::StringLiteral Code = R"cpp(
+  llvm::StringRef Code = R"cpp(
     template  class __f>
     const __f<_Tp&> *A = nullptr;
   )cpp";
@@ -98,7 +98,7 @@ TEST(TypePrinter, ParamsUglified) {
 }
 
 TEST(TypePrinter, SuppressElaboration) {
-  llvm::StringLiteral Code = R"cpp(
+  llvm::StringRef Code = R"cpp(
     namespace shared {
     namespace a {
     template 
diff --git a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
index 680e21840b7d3..43ae7d08661e0 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -945,7 +945,7 @@ TEST_P(ASTMatchersTest, Matcher_DefaultArgument) {
   EXPECT_TRUE(notMatches("void x(int, int = 0) { int y; x(y, 0); }", Arg));
 }
 
-TEST_P(ASTMatchersTest, StringLiteral) {
+TEST_P(ASTMatchersTest, StringRef) {
   StatementMatcher Literal = stringLiteral();
   EXPECT_TRUE(matches("const char *s = \"string\";", Literal));
   // with escaped characters
@@ -1112,7 +1112,7 @@ TEST_P(ASTMatchersTest, StmtExpr) {
 }
 
 TEST_P(ASTMatchersTest, PredefinedExpr) {
-  // __func__ expands as StringLiteral("foo")
+  // __func__ expands as StringRef("foo")
   EXPECT_TRUE(matches("void foo() { __func__; }",
                       predefinedExpr(hasType(asString("const char[4]")),
                                      has(stringLiteral()))));
diff --git a/clang/unittests/ASTMatchers/GtestMatchersTest.cpp b/clang/unittests/ASTMatchers/GtestMatchersTest.cpp
index 5ee67a9e54844..5931ebc6e5339 100644
--- a/clang/unittests/ASTMatchers/GtestMatchersTest.cpp
+++ b/clang/unittests/ASTMatchers/GtestMatchersTest.cpp
@@ -13,7 +13,7 @@
 namespace clang {
 namespace ast_matchers {
 
-constexpr llvm::StringLiteral GtestMockDecls = R"cc(
+constexpr llvm::StringRef GtestMockDecls = R"cc(
   static int testerr;
 
 #define GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
diff --git a/clang/unittests/Basic/DiagnosticTest.cpp b/clang/unittests/Basic/DiagnosticTest.cpp
index e03d9a464df7f..db5319950209a 100644
--- a/clang/unittests/Basic/DiagnosticTest.cpp
+++ b/clang/unittests/Basic/DiagnosticTest.cpp
@@ -258,7 +258,7 @@ TEST_F(SuppressionMappingTest, UnknownDiagName) {
 }
 
 TEST_F(SuppressionMappingTest, SuppressesGroup) {
-  llvm::StringLiteral SuppressionMappingFile = R"(
+  llvm::StringRef SuppressionMappingFile = R"(
   [unused]
   src:*)";
   Diags.getDiagnosticOptions().DiagnosticSuppressionMappingsFile = "foo.txt";
@@ -273,7 +273,7 @@ TEST_F(SuppressionMappingTest, SuppressesGroup) {
 }
 
 TEST_F(SuppressionMappingTest, EmitCategoryIsExcluded) {
-  llvm::StringLiteral SuppressionMappingFile = R"(
+  llvm::StringRef SuppressionMappingFile = R"(
   [unused]
   src:*
   src:*foo.cpp=emit)";
@@ -290,7 +290,7 @@ TEST_F(SuppressionMappingTest, EmitCategoryIsExcluded) {
 }
 
 TEST_F(SuppressionMappingTest, LongestMatchWins) {
-  llvm::StringLiteral SuppressionMappingFile = R"(
+  llvm::StringRef SuppressionMappingFile = R"(
   [unused]
   src:*clang/*
   src:*clang/lib/Sema/*=emit
@@ -310,7 +310,7 @@ TEST_F(SuppressionMappingTest, LongestMatchWins) {
 }
 
 TEST_F(SuppressionMappingTest, IsIgnored) {
-  llvm::StringLiteral SuppressionMappingFile = R"(
+  llvm::StringRef SuppressionMappingFile = R"(
   [unused]
   src:*clang/*)";
   Diags.getDiagnosticOptions().DiagnosticSuppressionMappingsFile = "foo.txt";
diff --git a/clang/unittests/Basic/SourceManagerTest.cpp b/clang/unittests/Basic/SourceManagerTest.cpp
index 2b3fce9128ba9..0adb878cb8ca7 100644
--- a/clang/unittests/Basic/SourceManagerTest.cpp
+++ b/clang/unittests/Basic/SourceManagerTest.cpp
@@ -374,11 +374,11 @@ TEST_F(SourceManagerTest, getInvalidBOM) {
                 "\x84\x31\x95\x33#include ")),
             "GB-18030");
   ASSERT_EQ(StringRef(SrcMgr::ContentCache::getInvalidBOM(
-                llvm::StringLiteral::withInnerNUL(
+                llvm::StringRef::withInnerNUL(
                     "\x00\x00\xFE\xFF#include "))),
             "UTF-32 (BE)");
   ASSERT_EQ(StringRef(SrcMgr::ContentCache::getInvalidBOM(
-                llvm::StringLiteral::withInnerNUL(
+                llvm::StringRef::withInnerNUL(
                     "\xFF\xFE\x00\x00#include "))),
             "UTF-32 (LE)");
 }
diff --git a/clang/unittests/Format/FormatTestVerilog.cpp b/clang/unittests/Format/FormatTestVerilog.cpp
index e4a14ff754d1a..a7ac733bd262f 100644
--- a/clang/unittests/Format/FormatTestVerilog.cpp
+++ b/clang/unittests/Format/FormatTestVerilog.cpp
@@ -1256,7 +1256,7 @@ TEST_F(FormatTestVerilog, Streaming) {
   verifyFormat("{<
-//         `-StringLiteral 'const char [7]' lvalue "foobar"
+//         `-StringRef 'const char [7]' lvalue "foobar"
 TEST(CastExprTest, GetCtorConversionFunctionThroughConstantExpr) {
   CastExprVisitor Visitor;
   Visitor.OnCast = [](CastExpr *Expr) {
diff --git a/clang/unittests/Tooling/RecursiveASTVisitorTests/MemberPointerTypeLoc.cpp b/clang/unittests/Tooling/RecursiveASTVisitorTests/MemberPointerTypeLoc.cpp
index 587a00dd27051..5056f7319ce87 100644
--- a/clang/unittests/Tooling/RecursiveASTVisitorTests/MemberPointerTypeLoc.cpp
+++ b/clang/unittests/Tooling/RecursiveASTVisitorTests/MemberPointerTypeLoc.cpp
@@ -33,7 +33,7 @@ TEST(RecursiveASTVisitor, VisitTypeLocInMemberPointerTypeLoc) {
   MemberPointerTypeLocVisitor Visitor;
   Visitor.ExpectMatch("Bar", 4, 36);
   Visitor.ExpectMatch("T", 7, 23);
-  llvm::StringLiteral Code = R"cpp(
+  llvm::StringRef Code = R"cpp(
      class Bar { void func(int); };
      class Foo {
        void bind(const char*, void(Bar::*Foo)(int)) {}
@@ -47,7 +47,7 @@ TEST(RecursiveASTVisitor, VisitTypeLocInMemberPointerTypeLoc) {
 
 TEST(RecursiveASTVisitor, NoCrash) {
   MemberPointerTypeLocVisitor Visitor;
-  llvm::StringLiteral Code = R"cpp(
+  llvm::StringRef Code = R"cpp(
      // MemberPointerTypeLoc.getClassTInfo() is null.
      class a(b(a::*)) class
   )cpp";
diff --git a/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
index a551f83ff3f9c..09003a4ace727 100644
--- a/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -1408,7 +1408,7 @@ FloatingLiteralExpression Expression
 )txt"}));
 }
 
-TEST_P(BuildSyntaxTreeTest, StringLiteral) {
+TEST_P(BuildSyntaxTreeTest, StringRef) {
   EXPECT_TRUE(treeDumpEqualOnAnnotations(
       R"cpp(
 void test() {
diff --git a/clang/unittests/Tooling/Syntax/TokensTest.cpp b/clang/unittests/Tooling/Syntax/TokensTest.cpp
index dc8a11dbc345c..6fe85c567b8c2 100644
--- a/clang/unittests/Tooling/Syntax/TokensTest.cpp
+++ b/clang/unittests/Tooling/Syntax/TokensTest.cpp
@@ -575,7 +575,7 @@ TEST_F(TokenCollectorTest, LateBoundTokens) {
 }
 
 TEST_F(TokenCollectorTest, DelayedParsing) {
-  llvm::StringLiteral Code = R"cpp(
+  llvm::StringRef Code = R"cpp(
     struct Foo {
       int method() {
         // Parser will visit method bodies and initializers multiple times, but
@@ -608,7 +608,7 @@ TEST_F(TokenCollectorTest, MultiFile) {
     int b = ADD(1, 2);
     #define MULT(X, Y) X*Y
   )cpp");
-  llvm::StringLiteral Code = R"cpp(
+  llvm::StringRef Code = R"cpp(
     #include "foo.h"
     int c = ADD(1, MULT(2,3));
   )cpp";
diff --git a/clang/utils/ClangVisualizers/clang.natvis b/clang/utils/ClangVisualizers/clang.natvis
index a7c70186bc46d..4c814ebd99062 100644
--- a/clang/utils/ClangVisualizers/clang.natvis
+++ b/clang/utils/ClangVisualizers/clang.natvis
@@ -1000,13 +1000,13 @@ For later versions of Visual Studio, no setup is required-->
     
   
   
-    {*(clang::StringLiteral *)this}
+    {*(clang::StringRef *)this}
     Expression of class {(clang::Stmt::StmtClass)StmtBits.sClass,en} and type {TR,view(cpp)}
   
-  
+  
     
-      *(unsigned *)(((clang::StringLiteral *)this)+1)
-      (const char *)(((clang::StringLiteral *)this)+1)+4+4,[*(unsigned *)(((clang::StringLiteral *)this)+1)]s8
+      *(unsigned *)(((clang::StringRef *)this)+1)
+      (const char *)(((clang::StringRef *)this)+1)+4+4,[*(unsigned *)(((clang::StringRef *)this)+1)]s8
     
   
   
diff --git a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
index 72b3468dac486..b69c6a8c9b5b7 100644
--- a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
+++ b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
@@ -994,7 +994,7 @@ Piece *DiagnosticTextBuilder::DiagText::parseDiagText(StringRef &Text,
                                                       StopAt Stop) {
   std::vector Parsed;
 
-  constexpr StringLiteral StopSets[] = {"%", "%|}", "%|}$"};
+  constexpr StringRef StopSets[] = {"%", "%|}", "%|}$"};
   StringRef StopSet = StopSets[static_cast(Stop)];
 
   while (!Text.empty()) {
diff --git a/clang/utils/TableGen/ClangOptionDocEmitter.cpp b/clang/utils/TableGen/ClangOptionDocEmitter.cpp
index e08fb11df3100..e58d6803ab3ec 100644
--- a/clang/utils/TableGen/ClangOptionDocEmitter.cpp
+++ b/clang/utils/TableGen/ClangOptionDocEmitter.cpp
@@ -252,7 +252,7 @@ void emitOptionWithArgs(StringRef Prefix, const Record *Option,
   }
 }
 
-constexpr StringLiteral DefaultMetaVarName = "";
+constexpr StringRef DefaultMetaVarName = "";
 
 void emitOptionName(StringRef Prefix, const Record *Option, raw_ostream &OS) {
   // Find the arguments to list after the option.
diff --git a/flang/include/flang/Optimizer/Dialect/FIRAttr.h b/flang/include/flang/Optimizer/Dialect/FIRAttr.h
index c427a6576b5da..8e6653b409944 100644
--- a/flang/include/flang/Optimizer/Dialect/FIRAttr.h
+++ b/flang/include/flang/Optimizer/Dialect/FIRAttr.h
@@ -38,7 +38,7 @@ class ExactTypeAttr
   using Base::Base;
   using ValueType = mlir::Type;
 
-  static constexpr llvm::StringLiteral name = "fir.type_is";
+  static constexpr llvm::StringRef name = "fir.type_is";
   static constexpr llvm::StringRef getAttrName() { return "type_is"; }
   static ExactTypeAttr get(mlir::Type value);
 
@@ -52,7 +52,7 @@ class SubclassAttr
   using Base::Base;
   using ValueType = mlir::Type;
 
-  static constexpr llvm::StringLiteral name = "fir.class_is";
+  static constexpr llvm::StringRef name = "fir.class_is";
   static constexpr llvm::StringRef getAttrName() { return "class_is"; }
   static SubclassAttr get(mlir::Type value);
 
@@ -65,7 +65,7 @@ class MustBeHeapAttr : public mlir::BoolAttr {
 public:
   using BoolAttr::BoolAttr;
 
-  static constexpr llvm::StringLiteral name = "fir.must_be_heap";
+  static constexpr llvm::StringRef name = "fir.must_be_heap";
   static constexpr llvm::StringRef getAttrName() { return "fir.must_be_heap"; }
 };
 
@@ -81,7 +81,7 @@ class ClosedIntervalAttr
 public:
   using Base::Base;
 
-  static constexpr llvm::StringLiteral name = "fir.interval";
+  static constexpr llvm::StringRef name = "fir.interval";
   static constexpr llvm::StringRef getAttrName() { return "interval"; }
   static ClosedIntervalAttr get(mlir::MLIRContext *ctxt);
 };
@@ -96,7 +96,7 @@ class UpperBoundAttr
 public:
   using Base::Base;
 
-  static constexpr llvm::StringLiteral name = "fir.upper";
+  static constexpr llvm::StringRef name = "fir.upper";
   static constexpr llvm::StringRef getAttrName() { return "upper"; }
   static UpperBoundAttr get(mlir::MLIRContext *ctxt);
 };
@@ -111,7 +111,7 @@ class LowerBoundAttr
 public:
   using Base::Base;
 
-  static constexpr llvm::StringLiteral name = "fir.lower";
+  static constexpr llvm::StringRef name = "fir.lower";
   static constexpr llvm::StringRef getAttrName() { return "lower"; }
   static LowerBoundAttr get(mlir::MLIRContext *ctxt);
 };
@@ -126,7 +126,7 @@ class PointIntervalAttr
 public:
   using Base::Base;
 
-  static constexpr llvm::StringLiteral name = "fir.point";
+  static constexpr llvm::StringRef name = "fir.point";
   static constexpr llvm::StringRef getAttrName() { return "point"; }
   static PointIntervalAttr get(mlir::MLIRContext *ctxt);
 };
@@ -142,7 +142,7 @@ class RealAttr
   using Base::Base;
   using ValueType = std::pair;
 
-  static constexpr llvm::StringLiteral name = "fir.real";
+  static constexpr llvm::StringRef name = "fir.real";
   static constexpr llvm::StringRef getAttrName() { return "real"; }
   static RealAttr get(mlir::MLIRContext *ctxt, const ValueType &key);
 
diff --git a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
index cb0af392073f2..60d5f68a44b1f 100644
--- a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
+++ b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
@@ -7474,7 +7474,7 @@ IntrinsicLibrary::genSum(mlir::Type resultType,
 
 // SYNCTHREADS
 void IntrinsicLibrary::genSyncThreads(llvm::ArrayRef args) {
-  constexpr llvm::StringLiteral funcName = "llvm.nvvm.barrier0";
+  constexpr llvm::StringRef funcName = "llvm.nvvm.barrier0";
   mlir::FunctionType funcType =
       mlir::FunctionType::get(builder.getContext(), {}, {});
   auto funcOp = builder.createFunction(loc, funcName, funcType);
@@ -7486,7 +7486,7 @@ void IntrinsicLibrary::genSyncThreads(llvm::ArrayRef args) {
 mlir::Value
 IntrinsicLibrary::genSyncThreadsAnd(mlir::Type resultType,
                                     llvm::ArrayRef args) {
-  constexpr llvm::StringLiteral funcName = "llvm.nvvm.barrier0.and";
+  constexpr llvm::StringRef funcName = "llvm.nvvm.barrier0.and";
   mlir::MLIRContext *context = builder.getContext();
   mlir::FunctionType ftype =
       mlir::FunctionType::get(context, {resultType}, {args[0].getType()});
@@ -7498,7 +7498,7 @@ IntrinsicLibrary::genSyncThreadsAnd(mlir::Type resultType,
 mlir::Value
 IntrinsicLibrary::genSyncThreadsCount(mlir::Type resultType,
                                       llvm::ArrayRef args) {
-  constexpr llvm::StringLiteral funcName = "llvm.nvvm.barrier0.popc";
+  constexpr llvm::StringRef funcName = "llvm.nvvm.barrier0.popc";
   mlir::MLIRContext *context = builder.getContext();
   mlir::FunctionType ftype =
       mlir::FunctionType::get(context, {resultType}, {args[0].getType()});
@@ -7510,7 +7510,7 @@ IntrinsicLibrary::genSyncThreadsCount(mlir::Type resultType,
 mlir::Value
 IntrinsicLibrary::genSyncThreadsOr(mlir::Type resultType,
                                    llvm::ArrayRef args) {
-  constexpr llvm::StringLiteral funcName = "llvm.nvvm.barrier0.or";
+  constexpr llvm::StringRef funcName = "llvm.nvvm.barrier0.or";
   mlir::MLIRContext *context = builder.getContext();
   mlir::FunctionType ftype =
       mlir::FunctionType::get(context, {resultType}, {args[0].getType()});
@@ -7650,7 +7650,7 @@ IntrinsicLibrary::genTranspose(mlir::Type resultType,
 
 // THREADFENCE
 void IntrinsicLibrary::genThreadFence(llvm::ArrayRef args) {
-  constexpr llvm::StringLiteral funcName = "llvm.nvvm.membar.gl";
+  constexpr llvm::StringRef funcName = "llvm.nvvm.membar.gl";
   mlir::FunctionType funcType =
       mlir::FunctionType::get(builder.getContext(), {}, {});
   auto funcOp = builder.createFunction(loc, funcName, funcType);
@@ -7661,7 +7661,7 @@ void IntrinsicLibrary::genThreadFence(llvm::ArrayRef args) {
 // THREADFENCE_BLOCK
 void IntrinsicLibrary::genThreadFenceBlock(
     llvm::ArrayRef args) {
-  constexpr llvm::StringLiteral funcName = "llvm.nvvm.membar.cta";
+  constexpr llvm::StringRef funcName = "llvm.nvvm.membar.cta";
   mlir::FunctionType funcType =
       mlir::FunctionType::get(builder.getContext(), {}, {});
   auto funcOp = builder.createFunction(loc, funcName, funcType);
@@ -7672,7 +7672,7 @@ void IntrinsicLibrary::genThreadFenceBlock(
 // THREADFENCE_SYSTEM
 void IntrinsicLibrary::genThreadFenceSystem(
     llvm::ArrayRef args) {
-  constexpr llvm::StringLiteral funcName = "llvm.nvvm.membar.sys";
+  constexpr llvm::StringRef funcName = "llvm.nvvm.membar.sys";
   mlir::FunctionType funcType =
       mlir::FunctionType::get(builder.getContext(), {}, {});
   auto funcOp = builder.createFunction(loc, funcName, funcType);
diff --git a/flang/lib/Parser/source.cpp b/flang/lib/Parser/source.cpp
index ae834dc241652..b92e394bdbd4e 100644
--- a/flang/lib/Parser/source.cpp
+++ b/flang/lib/Parser/source.cpp
@@ -45,7 +45,7 @@ void SourceFile::RecordLineStarts() {
 // Module files all have one; so can source files.
 void SourceFile::IdentifyPayload() {
   llvm::StringRef content{buf_->getBufferStart(), buf_->getBufferSize()};
-  constexpr llvm::StringLiteral UTF8_BOM{"\xef\xbb\xbf"};
+  constexpr llvm::StringRef UTF8_BOM{"\xef\xbb\xbf"};
   if (content.starts_with(UTF8_BOM)) {
     bom_end_ = UTF8_BOM.size();
     encoding_ = Encoding::UTF_8;
diff --git a/flang/unittests/Frontend/CodeGenActionTest.cpp b/flang/unittests/Frontend/CodeGenActionTest.cpp
index e9ff095973b97..228530c16758c 100644
--- a/flang/unittests/Frontend/CodeGenActionTest.cpp
+++ b/flang/unittests/Frontend/CodeGenActionTest.cpp
@@ -34,8 +34,8 @@ class DummyDialect : public ::mlir::Dialect {
 
 public:
   ~DummyDialect() override = default;
-  static constexpr ::llvm::StringLiteral getDialectNamespace() {
-    return ::llvm::StringLiteral("dummy");
+  static constexpr ::llvm::StringRef getDialectNamespace() {
+    return ::llvm::StringRef("dummy");
   }
 };
 
diff --git a/libcxxabi/src/demangle/ItaniumDemangle.h b/libcxxabi/src/demangle/ItaniumDemangle.h
index e4752bed6da8b..4aeca82a8051a 100644
--- a/libcxxabi/src/demangle/ItaniumDemangle.h
+++ b/libcxxabi/src/demangle/ItaniumDemangle.h
@@ -2385,11 +2385,11 @@ class BoolExpr : public Node {
   }
 };
 
-class StringLiteral : public Node {
+class StringRef : public Node {
   const Node *Type;
 
 public:
-  StringLiteral(const Node *Type_) : Node(KStringLiteral), Type(Type_) {}
+  StringRef(const Node *Type_) : Node(KStringLiteral), Type(Type_) {}
 
   template void match(Fn F) const { F(Type); }
 
@@ -4853,7 +4853,7 @@ Node *AbstractManglingParser::parseExprPrimary() {
       return nullptr;
     // FIXME: We need to include the string contents in the mangling.
     if (consumeIf('E'))
-      return make(T);
+      return make(T);
     return nullptr;
   }
   case 'D':
diff --git a/libcxxabi/src/demangle/ItaniumNodes.def b/libcxxabi/src/demangle/ItaniumNodes.def
index 18f5d52b47e91..ea96d95c00c75 100644
--- a/libcxxabi/src/demangle/ItaniumNodes.def
+++ b/libcxxabi/src/demangle/ItaniumNodes.def
@@ -86,7 +86,7 @@ NODE(InitListExpr)
 NODE(FoldExpr)
 NODE(ThrowExpr)
 NODE(BoolExpr)
-NODE(StringLiteral)
+NODE(StringRef)
 NODE(LambdaExpr)
 NODE(EnumLiteral)
 NODE(IntegerLiteral)
diff --git a/libcxxabi/test/test_demangle.pass.cpp b/libcxxabi/test/test_demangle.pass.cpp
index 67b9df212ff3b..69bba4a7b5a45 100644
--- a/libcxxabi/test/test_demangle.pass.cpp
+++ b/libcxxabi/test/test_demangle.pass.cpp
@@ -33,7 +33,7 @@
 // Is long double fp128?
 #define LDBL_FP128 (__LDBL_MANT_DIG__ == 113)
 
-const char *cases[][2] = {
+const char* cases[][2] = {
     // clang-format off
     {"_Z1A", "A"},
     {"_Z1Av", "A()"},
@@ -2367,7 +2367,7 @@ const char *cases[][2] = {
     {"_ZN5clang13ASTStmtReader19VisitIntegerLiteralEPNS_14IntegerLiteralE", "clang::ASTStmtReader::VisitIntegerLiteral(clang::IntegerLiteral*)"},
     {"_ZN5clang13ASTStmtReader20VisitFloatingLiteralEPNS_15FloatingLiteralE", "clang::ASTStmtReader::VisitFloatingLiteral(clang::FloatingLiteral*)"},
     {"_ZN5clang13ASTStmtReader21VisitImaginaryLiteralEPNS_16ImaginaryLiteralE", "clang::ASTStmtReader::VisitImaginaryLiteral(clang::ImaginaryLiteral*)"},
-    {"_ZN5clang13ASTStmtReader18VisitStringLiteralEPNS_13StringLiteralE", "clang::ASTStmtReader::VisitStringLiteral(clang::StringLiteral*)"},
+    {"_ZN5clang13ASTStmtReader18VisitStringLiteralEPNS_13StringLiteralE", "clang::ASTStmtReader::VisitStringLiteral(clang::StringRef*)"},
     {"_ZN5clang13ASTStmtReader21VisitCharacterLiteralEPNS_16CharacterLiteralE", "clang::ASTStmtReader::VisitCharacterLiteral(clang::CharacterLiteral*)"},
     {"_ZN5clang13ASTStmtReader14VisitParenExprEPNS_9ParenExprE", "clang::ASTStmtReader::VisitParenExpr(clang::ParenExpr*)"},
     {"_ZN5clang13ASTStmtReader18VisitParenListExprEPNS_13ParenListExprE", "clang::ASTStmtReader::VisitParenListExpr(clang::ParenListExpr*)"},
@@ -2675,7 +2675,7 @@ const char *cases[][2] = {
     {"_ZN5clang13ASTStmtWriter19VisitIntegerLiteralEPNS_14IntegerLiteralE", "clang::ASTStmtWriter::VisitIntegerLiteral(clang::IntegerLiteral*)"},
     {"_ZN5clang13ASTStmtWriter20VisitFloatingLiteralEPNS_15FloatingLiteralE", "clang::ASTStmtWriter::VisitFloatingLiteral(clang::FloatingLiteral*)"},
     {"_ZN5clang13ASTStmtWriter21VisitImaginaryLiteralEPNS_16ImaginaryLiteralE", "clang::ASTStmtWriter::VisitImaginaryLiteral(clang::ImaginaryLiteral*)"},
-    {"_ZN5clang13ASTStmtWriter18VisitStringLiteralEPNS_13StringLiteralE", "clang::ASTStmtWriter::VisitStringLiteral(clang::StringLiteral*)"},
+    {"_ZN5clang13ASTStmtWriter18VisitStringLiteralEPNS_13StringLiteralE", "clang::ASTStmtWriter::VisitStringLiteral(clang::StringRef*)"},
     {"_ZN5clang13ASTStmtWriter21VisitCharacterLiteralEPNS_16CharacterLiteralE", "clang::ASTStmtWriter::VisitCharacterLiteral(clang::CharacterLiteral*)"},
     {"_ZN5clang13ASTStmtWriter14VisitParenExprEPNS_9ParenExprE", "clang::ASTStmtWriter::VisitParenExpr(clang::ParenExpr*)"},
     {"_ZN5clang13ASTStmtWriter18VisitParenListExprEPNS_13ParenListExprE", "clang::ASTStmtWriter::VisitParenListExpr(clang::ParenListExpr*)"},
@@ -3185,7 +3185,7 @@ const char *cases[][2] = {
     {"_ZN5clang7CodeGen15CodeGenFunction19EmitVAArgExprLValueEPKNS_9VAArgExprE", "clang::CodeGen::CodeGenFunction::EmitVAArgExprLValue(clang::VAArgExpr const*)"},
     {"_ZN5clang7CodeGen15CodeGenFunction17EmitDeclRefLValueEPKNS_11DeclRefExprE", "clang::CodeGen::CodeGenFunction::EmitDeclRefLValue(clang::DeclRefExpr const*)"},
     {"_ZN5clang7CodeGen15CodeGenFunction20EmitPredefinedLValueEPKNS_14PredefinedExprE", "clang::CodeGen::CodeGenFunction::EmitPredefinedLValue(clang::PredefinedExpr const*)"},
-    {"_ZN5clang7CodeGen15CodeGenFunction23EmitStringLiteralLValueEPKNS_13StringLiteralE", "clang::CodeGen::CodeGenFunction::EmitStringLiteralLValue(clang::StringLiteral const*)"},
+    {"_ZN5clang7CodeGen15CodeGenFunction23EmitStringLiteralLValueEPKNS_13StringLiteralE", "clang::CodeGen::CodeGenFunction::EmitStringLiteralLValue(clang::StringRef const*)"},
     {"_ZN5clang7CodeGen15CodeGenFunction24EmitObjCEncodeExprLValueEPKNS_14ObjCEncodeExprE", "clang::CodeGen::CodeGenFunction::EmitObjCEncodeExprLValue(clang::ObjCEncodeExpr const*)"},
     {"_ZN5clang7CodeGen15CodeGenFunction22EmitBlockDeclRefLValueEPKNS_16BlockDeclRefExprE", "clang::CodeGen::CodeGenFunction::EmitBlockDeclRefLValue(clang::BlockDeclRefExpr const*)"},
     {"_ZN5clang7CodeGen15CodeGenFunction22EmitCXXConstructLValueEPKNS_16CXXConstructExprE", "clang::CodeGen::CodeGenFunction::EmitCXXConstructLValue(clang::CXXConstructExpr const*)"},
@@ -3396,7 +3396,7 @@ const char *cases[][2] = {
     {"_ZN12_GLOBAL__N_19CGObjCGNU11GetSelectorERN4llvm9IRBuilderILb0ENS1_14ConstantFolderENS1_24IRBuilderDefaultInserterILb0EEEEEN5clang8SelectorEb", "(anonymous namespace)::CGObjCGNU::GetSelector(llvm::IRBuilder>&, clang::Selector, bool)"},
     {"_ZN12_GLOBAL__N_19CGObjCGNU11GetSelectorERN4llvm9IRBuilderILb0ENS1_14ConstantFolderENS1_24IRBuilderDefaultInserterILb0EEEEEPKN5clang14ObjCMethodDeclE", "(anonymous namespace)::CGObjCGNU::GetSelector(llvm::IRBuilder>&, clang::ObjCMethodDecl const*)"},
     {"_ZN12_GLOBAL__N_19CGObjCGNU9GetEHTypeEN5clang8QualTypeE", "(anonymous namespace)::CGObjCGNU::GetEHType(clang::QualType)"},
-    {"_ZN12_GLOBAL__N_19CGObjCGNU22GenerateConstantStringEPKN5clang13StringLiteralE", "(anonymous namespace)::CGObjCGNU::GenerateConstantString(clang::StringLiteral const*)"},
+    {"_ZN12_GLOBAL__N_19CGObjCGNU22GenerateConstantStringEPKN5clang13StringLiteralE", "(anonymous namespace)::CGObjCGNU::GenerateConstantString(clang::StringRef const*)"},
     {"_ZN12_GLOBAL__N_19CGObjCGNU16GenerateCategoryEPKN5clang20ObjCCategoryImplDeclE", "(anonymous namespace)::CGObjCGNU::GenerateCategory(clang::ObjCCategoryImplDecl const*)"},
     {"_ZN12_GLOBAL__N_19CGObjCGNU13GenerateClassEPKN5clang22ObjCImplementationDeclE", "(anonymous namespace)::CGObjCGNU::GenerateClass(clang::ObjCImplementationDecl const*)"},
     {"_ZN12_GLOBAL__N_19CGObjCGNU19GenerateMessageSendERN5clang7CodeGen15CodeGenFunctionENS2_15ReturnValueSlotENS1_8QualTypeENS1_8SelectorEPN4llvm5ValueERKNS8_11SmallVectorISt4pairINS2_6RValueES6_ELj16EEEPKNS1_17ObjCInterfaceDeclEPKNS1_14ObjCMethodDeclE", "(anonymous namespace)::CGObjCGNU::GenerateMessageSend(clang::CodeGen::CodeGenFunction&, clang::CodeGen::ReturnValueSlot, clang::QualType, clang::Selector, llvm::Value*, llvm::SmallVector, 16u> const&, clang::ObjCInterfaceDecl const*, clang::ObjCMethodDecl const*)"},
@@ -3468,7 +3468,7 @@ const char *cases[][2] = {
     {"_ZN12_GLOBAL__N_122CGObjCNonFragileABIMac11GetSelectorERN4llvm9IRBuilderILb0ENS1_14ConstantFolderENS1_24IRBuilderDefaultInserterILb0EEEEEN5clang8SelectorEb", "(anonymous namespace)::CGObjCNonFragileABIMac::GetSelector(llvm::IRBuilder>&, clang::Selector, bool)"},
     {"_ZN12_GLOBAL__N_122CGObjCNonFragileABIMac11GetSelectorERN4llvm9IRBuilderILb0ENS1_14ConstantFolderENS1_24IRBuilderDefaultInserterILb0EEEEEPKN5clang14ObjCMethodDeclE", "(anonymous namespace)::CGObjCNonFragileABIMac::GetSelector(llvm::IRBuilder>&, clang::ObjCMethodDecl const*)"},
     {"_ZN12_GLOBAL__N_122CGObjCNonFragileABIMac9GetEHTypeEN5clang8QualTypeE", "(anonymous namespace)::CGObjCNonFragileABIMac::GetEHType(clang::QualType)"},
-    {"_ZN12_GLOBAL__N_115CGObjCCommonMac22GenerateConstantStringEPKN5clang13StringLiteralE", "(anonymous namespace)::CGObjCCommonMac::GenerateConstantString(clang::StringLiteral const*)"},
+    {"_ZN12_GLOBAL__N_115CGObjCCommonMac22GenerateConstantStringEPKN5clang13StringLiteralE", "(anonymous namespace)::CGObjCCommonMac::GenerateConstantString(clang::StringRef const*)"},
     {"_ZN12_GLOBAL__N_122CGObjCNonFragileABIMac16GenerateCategoryEPKN5clang20ObjCCategoryImplDeclE", "(anonymous namespace)::CGObjCNonFragileABIMac::GenerateCategory(clang::ObjCCategoryImplDecl const*)"},
     {"_ZN12_GLOBAL__N_122CGObjCNonFragileABIMac13GenerateClassEPKN5clang22ObjCImplementationDeclE", "(anonymous namespace)::CGObjCNonFragileABIMac::GenerateClass(clang::ObjCImplementationDecl const*)"},
     {"_ZN12_GLOBAL__N_122CGObjCNonFragileABIMac19GenerateMessageSendERN5clang7CodeGen15CodeGenFunctionENS2_15ReturnValueSlotENS1_8QualTypeENS1_8SelectorEPN4llvm5ValueERKNS8_11SmallVectorISt4pairINS2_6RValueES6_ELj16EEEPKNS1_17ObjCInterfaceDeclEPKNS1_14ObjCMethodDeclE", "(anonymous namespace)::CGObjCNonFragileABIMac::GenerateMessageSend(clang::CodeGen::CodeGenFunction&, clang::CodeGen::ReturnValueSlot, clang::QualType, clang::Selector, llvm::Value*, llvm::SmallVector, 16u> const&, clang::ObjCInterfaceDecl const*, clang::ObjCMethodDecl const*)"},
@@ -3952,11 +3952,11 @@ const char *cases[][2] = {
     {"_ZN5clang7CodeGen13CodeGenModule27GetLLVMLinkageVarDefinitionEPKNS_7VarDeclEPN4llvm14GlobalVariableE", "clang::CodeGen::CodeGenModule::GetLLVMLinkageVarDefinition(clang::VarDecl const*, llvm::GlobalVariable*)"},
     {"_ZN5clang7CodeGen13CodeGenModule21getBuiltinLibFunctionEPKNS_12FunctionDeclEj", "clang::CodeGen::CodeGenModule::getBuiltinLibFunction(clang::FunctionDecl const*, unsigned int)"},
     {"_ZN5clang7CodeGen13CodeGenModule12getIntrinsicEjPPKN4llvm4TypeEj", "clang::CodeGen::CodeGenModule::getIntrinsic(unsigned int, llvm::Type const**, unsigned int)"},
-    {"_ZN5clang7CodeGen13CodeGenModule25GetAddrOfConstantCFStringEPKNS_13StringLiteralE", "clang::CodeGen::CodeGenModule::GetAddrOfConstantCFString(clang::StringLiteral const*)"},
-    {"_Z24GetConstantCFStringEntryRN4llvm9StringMapIPNS_8ConstantENS_15MallocAllocatorEEEPKN5clang13StringLiteralEbRbRj", "GetConstantCFStringEntry(llvm::StringMap&, clang::StringLiteral const*, bool, bool&, unsigned int&)"},
-    {"_ZN5clang7CodeGen13CodeGenModule23GetAddrOfConstantStringEPKNS_13StringLiteralE", "clang::CodeGen::CodeGenModule::GetAddrOfConstantString(clang::StringLiteral const*)"},
-    {"_ZN5clang7CodeGen13CodeGenModule25GetStringForStringLiteralEPKNS_13StringLiteralE", "clang::CodeGen::CodeGenModule::GetStringForStringLiteral(clang::StringLiteral const*)"},
-    {"_ZN5clang7CodeGen13CodeGenModule34GetAddrOfConstantStringFromLiteralEPKNS_13StringLiteralE", "clang::CodeGen::CodeGenModule::GetAddrOfConstantStringFromLiteral(clang::StringLiteral const*)"},
+    {"_ZN5clang7CodeGen13CodeGenModule25GetAddrOfConstantCFStringEPKNS_13StringLiteralE", "clang::CodeGen::CodeGenModule::GetAddrOfConstantCFString(clang::StringRef const*)"},
+    {"_Z24GetConstantCFStringEntryRN4llvm9StringMapIPNS_8ConstantENS_15MallocAllocatorEEEPKN5clang13StringLiteralEbRbRj", "GetConstantCFStringEntry(llvm::StringMap&, clang::StringRef const*, bool, bool&, unsigned int&)"},
+    {"_ZN5clang7CodeGen13CodeGenModule23GetAddrOfConstantStringEPKNS_13StringLiteralE", "clang::CodeGen::CodeGenModule::GetAddrOfConstantString(clang::StringRef const*)"},
+    {"_ZN5clang7CodeGen13CodeGenModule25GetStringForStringLiteralEPKNS_13StringLiteralE", "clang::CodeGen::CodeGenModule::GetStringForStringLiteral(clang::StringRef const*)"},
+    {"_ZN5clang7CodeGen13CodeGenModule34GetAddrOfConstantStringFromLiteralEPKNS_13StringLiteralE", "clang::CodeGen::CodeGenModule::GetAddrOfConstantStringFromLiteral(clang::StringRef const*)"},
     {"_ZN5clang7CodeGen13CodeGenModule23GetAddrOfConstantStringERKSsPKc", "clang::CodeGen::CodeGenModule::GetAddrOfConstantString(std::string const&, char const*)"},
     {"_ZN5clang7CodeGen13CodeGenModule37GetAddrOfConstantStringFromObjCEncodeEPKNS_14ObjCEncodeExprE", "clang::CodeGen::CodeGenModule::GetAddrOfConstantStringFromObjCEncode(clang::ObjCEncodeExpr const*)"},
     {"_ZN5clang7CodeGen13CodeGenModule24GetAddrOfConstantCStringERKSsPKc", "clang::CodeGen::CodeGenModule::GetAddrOfConstantCString(std::string const&, char const*)"},
@@ -4775,7 +4775,7 @@ const char *cases[][2] = {
     {"_ZN5clang4Sema26ShouldEnterDeclaratorScopeEPNS_5ScopeERKNS_12CXXScopeSpecE", "clang::Sema::ShouldEnterDeclaratorScope(clang::Scope*, clang::CXXScopeSpec const&)"},
     {"_ZN5clang4Sema28ActOnCXXEnterDeclaratorScopeEPNS_5ScopeERNS_12CXXScopeSpecE", "clang::Sema::ActOnCXXEnterDeclaratorScope(clang::Scope*, clang::CXXScopeSpec&)"},
     {"_ZN5clang4Sema27ActOnCXXExitDeclaratorScopeEPNS_5ScopeERKNS_12CXXScopeSpecE", "clang::Sema::ActOnCXXExitDeclaratorScope(clang::Scope*, clang::CXXScopeSpec const&)"},
-    {"_ZNK5clang4Sema30getLocationOfStringLiteralByteEPKNS_13StringLiteralEj", "clang::Sema::getLocationOfStringLiteralByte(clang::StringLiteral const*, unsigned int) const"},
+    {"_ZNK5clang4Sema30getLocationOfStringLiteralByteEPKNS_13StringLiteralEj", "clang::Sema::getLocationOfStringLiteralByte(clang::StringRef const*, unsigned int) const"},
     {"_ZN5clang4Sema19CheckablePrintfAttrEPKNS_10FormatAttrEPNS_8CallExprE", "clang::Sema::CheckablePrintfAttr(clang::FormatAttr const*, clang::CallExpr*)"},
     {"_ZN5clang4Sema24CheckBuiltinFunctionCallEjPNS_8CallExprE", "clang::Sema::CheckBuiltinFunctionCall(unsigned int, clang::CallExpr*)"},
     {"_ZN5clang4Sema22SemaBuiltinConstantArgEPNS_8CallExprEiRN4llvm6APSIntE", "clang::Sema::SemaBuiltinConstantArg(clang::CallExpr*, int, llvm::APSInt&)"},
@@ -4794,7 +4794,7 @@ const char *cases[][2] = {
     {"_ZN5clang4Sema21CheckNonNullArgumentsEPKNS_11NonNullAttrEPKNS_8CallExprE", "clang::Sema::CheckNonNullArguments(clang::NonNullAttr const*, clang::CallExpr const*)"},
     {"_ZN5clang4Sema14CheckBlockCallEPNS_9NamedDeclEPNS_8CallExprE", "clang::Sema::CheckBlockCall(clang::NamedDecl*, clang::CallExpr*)"},
     {"_ZN5clang4Sema22SemaCheckStringLiteralEPKNS_4ExprEPKNS_8CallExprEbjjb", "clang::Sema::SemaCheckStringLiteral(clang::Expr const*, clang::CallExpr const*, bool, unsigned int, unsigned int, bool)"},
-    {"_ZN5clang4Sema17CheckFormatStringEPKNS_13StringLiteralEPKNS_4ExprEPKNS_8CallExprEbjjb", "clang::Sema::CheckFormatString(clang::StringLiteral const*, clang::Expr const*, clang::CallExpr const*, bool, unsigned int, unsigned int, bool)"},
+    {"_ZN5clang4Sema17CheckFormatStringEPKNS_13StringLiteralEPKNS_4ExprEPKNS_8CallExprEbjjb", "clang::Sema::CheckFormatString(clang::StringRef const*, clang::Expr const*, clang::CallExpr const*, bool, unsigned int, unsigned int, bool)"},
     {"_ZN12_GLOBAL__N_118CheckFormatHandler14DoneProcessingEv", "(anonymous namespace)::CheckFormatHandler::DoneProcessing()"},
     {"_ZN12_GLOBAL__N_118CheckPrintfHandlerD1Ev", "(anonymous namespace)::CheckPrintfHandler::~CheckPrintfHandler()"},
     {"_ZN12_GLOBAL__N_117CheckScanfHandlerD1Ev", "(anonymous namespace)::CheckScanfHandler::~CheckScanfHandler()"},
@@ -7076,7 +7076,7 @@ const char *cases[][2] = {
     {"_ZN12_GLOBAL__N_117BasicStoreManager12scanForIvarsEPN5clang4StmtEPKNS1_4DeclEPKNS1_4ento9MemRegionEPKv", "(anonymous namespace)::BasicStoreManager::scanForIvars(clang::Stmt*, clang::Decl const*, clang::ento::MemRegion const*, void const*)"},
     {"_ZN5clang4ento12StoreManager11BindDefaultEPKvPKNS0_9MemRegionENS0_4SValE", "clang::ento::StoreManager::BindDefault(void const*, clang::ento::MemRegion const*, clang::ento::SVal)"},
     {"_ZN5clang4ento12StoreManager12getLValueVarEPKNS_7VarDeclEPKNS_15LocationContextE", "clang::ento::StoreManager::getLValueVar(clang::VarDecl const*, clang::LocationContext const*)"},
-    {"_ZN5clang4ento12StoreManager15getLValueStringEPKNS_13StringLiteralE", "clang::ento::StoreManager::getLValueString(clang::StringLiteral const*)"},
+    {"_ZN5clang4ento12StoreManager15getLValueStringEPKNS_13StringLiteralE", "clang::ento::StoreManager::getLValueString(clang::StringRef const*)"},
     {"_ZN5clang4ento12StoreManager13getLValueIvarEPKNS_12ObjCIvarDeclENS0_4SValE", "clang::ento::StoreManager::getLValueIvar(clang::ObjCIvarDecl const*, clang::ento::SVal)"},
     {"_ZN5clang4ento12StoreManager14getLValueFieldEPKNS_9FieldDeclENS0_4SValE", "clang::ento::StoreManager::getLValueField(clang::FieldDecl const*, clang::ento::SVal)"},
     {"_ZN5clang4ento12StoreManager17getSizeInElementsEPKNS0_7GRStateEPKNS0_9MemRegionENS_8QualTypeE", "clang::ento::StoreManager::getSizeInElements(clang::ento::GRState const*, clang::ento::MemRegion const*, clang::QualType)"},
@@ -7774,7 +7774,7 @@ const char *cases[][2] = {
     {"_ZNK5clang4ento14MemSpaceRegion7ProfileERN4llvm16FoldingSetNodeIDE", "clang::ento::MemSpaceRegion::Profile(llvm::FoldingSetNodeID&) const"},
     {"_ZNK5clang4ento16StackSpaceRegion7ProfileERN4llvm16FoldingSetNodeIDE", "clang::ento::StackSpaceRegion::Profile(llvm::FoldingSetNodeID&) const"},
     {"_ZNK5clang4ento23StaticGlobalSpaceRegion7ProfileERN4llvm16FoldingSetNodeIDE", "clang::ento::StaticGlobalSpaceRegion::Profile(llvm::FoldingSetNodeID&) const"},
-    {"_ZN5clang4ento12StringRegion13ProfileRegionERN4llvm16FoldingSetNodeIDEPKNS_13StringLiteralEPKNS0_9MemRegionE", "clang::ento::StringRegion::ProfileRegion(llvm::FoldingSetNodeID&, clang::StringLiteral const*, clang::ento::MemRegion const*)"},
+    {"_ZN5clang4ento12StringRegion13ProfileRegionERN4llvm16FoldingSetNodeIDEPKNS_13StringLiteralEPKNS0_9MemRegionE", "clang::ento::StringRegion::ProfileRegion(llvm::FoldingSetNodeID&, clang::StringRef const*, clang::ento::MemRegion const*)"},
     {"_ZN5clang4ento12AllocaRegion13ProfileRegionERN4llvm16FoldingSetNodeIDEPKNS_4ExprEjPKNS0_9MemRegionE", "clang::ento::AllocaRegion::ProfileRegion(llvm::FoldingSetNodeID&, clang::Expr const*, unsigned int, clang::ento::MemRegion const*)"},
     {"_ZNK5clang4ento12AllocaRegion7ProfileERN4llvm16FoldingSetNodeIDE", "clang::ento::AllocaRegion::Profile(llvm::FoldingSetNodeID&) const"},
     {"_ZNK5clang4ento21CompoundLiteralRegion7ProfileERN4llvm16FoldingSetNodeIDE", "clang::ento::CompoundLiteralRegion::Profile(llvm::FoldingSetNodeID&) const"},
@@ -7825,7 +7825,7 @@ const char *cases[][2] = {
     {"_ZN5clang4ento16MemRegionManager13getHeapRegionEv", "clang::ento::MemRegionManager::getHeapRegion()"},
     {"_ZN5clang4ento16MemRegionManager16getUnknownRegionEv", "clang::ento::MemRegionManager::getUnknownRegion()"},
     {"_ZN5clang4ento16MemRegionManager13getCodeRegionEv", "clang::ento::MemRegionManager::getCodeRegion()"},
-    {"_ZN5clang4ento16MemRegionManager15getStringRegionEPKNS_13StringLiteralE", "clang::ento::MemRegionManager::getStringRegion(clang::StringLiteral const*)"},
+    {"_ZN5clang4ento16MemRegionManager15getStringRegionEPKNS_13StringLiteralE", "clang::ento::MemRegionManager::getStringRegion(clang::StringRef const*)"},
     {"_ZN5clang4ento16MemRegionManager12getVarRegionEPKNS_7VarDeclEPKNS_15LocationContextE", "clang::ento::MemRegionManager::getVarRegion(clang::VarDecl const*, clang::LocationContext const*)"},
     {"_ZN5clang4ento16MemRegionManager21getFunctionTextRegionEPKNS_12FunctionDeclE", "clang::ento::MemRegionManager::getFunctionTextRegion(clang::FunctionDecl const*)"},
     {"_ZN5clang4ento16MemRegionManager18getBlockTextRegionEPKNS_9BlockDeclENS_7CanQualINS_4TypeEEEPNS_15AnalysisContextE", "clang::ento::MemRegionManager::getBlockTextRegion(clang::BlockDecl const*, clang::CanQual, clang::AnalysisContext*)"},
@@ -7852,7 +7852,7 @@ const char *cases[][2] = {
     {"_ZNK5clang4ento15BlockDataRegion21referenced_vars_beginEv", "clang::ento::BlockDataRegion::referenced_vars_begin() const"},
     {"_ZNK5clang4ento15BlockDataRegion19referenced_vars_endEv", "clang::ento::BlockDataRegion::referenced_vars_end() const"},
     {"_ZN4llvm10FoldingSetIN5clang4ento9MemRegionEED1Ev", "llvm::FoldingSet::~FoldingSet()"},
-    {"_ZN5clang4ento16MemRegionManager12getSubRegionINS0_12StringRegionEPKNS_13StringLiteralEEEPT_T0_PKNS0_9MemRegionE", "clang::ento::StringRegion* clang::ento::MemRegionManager::getSubRegion(clang::StringLiteral const*, clang::ento::MemRegion const*)"},
+    {"_ZN5clang4ento16MemRegionManager12getSubRegionINS0_12StringRegionEPKNS_13StringLiteralEEEPT_T0_PKNS0_9MemRegionE", "clang::ento::StringRegion* clang::ento::MemRegionManager::getSubRegion(clang::StringRef const*, clang::ento::MemRegion const*)"},
     {"_ZN5clang4ento16MemRegionManager12getSubRegionINS0_9VarRegionEPKNS_7VarDeclEEEPT_T0_PKNS0_9MemRegionE", "clang::ento::VarRegion* clang::ento::MemRegionManager::getSubRegion(clang::VarDecl const*, clang::ento::MemRegion const*)"},
     {"_ZN5clang4ento16MemRegionManager12getSubRegionINS0_15BlockDataRegionEPKNS0_15BlockTextRegionEPKNS_15LocationContextEEEPT_T0_T1_PKNS0_9MemRegionE", "clang::ento::BlockDataRegion* clang::ento::MemRegionManager::getSubRegion(clang::ento::BlockTextRegion const*, clang::LocationContext const*, clang::ento::MemRegion const*)"},
     {"_ZN5clang4ento16MemRegionManager12getSubRegionINS0_21CompoundLiteralRegionEPKNS_19CompoundLiteralExprEEEPT_T0_PKNS0_9MemRegionE", "clang::ento::CompoundLiteralRegion* clang::ento::MemRegionManager::getSubRegion(clang::CompoundLiteralExpr const*, clang::ento::MemRegion const*)"},
@@ -9716,7 +9716,7 @@ const char *cases[][2] = {
     {"_ZN5clang17IndirectFieldDecl6CreateERNS_10ASTContextEPNS_11DeclContextENS_14SourceLocationEPNS_14IdentifierInfoENS_8QualTypeEPPNS_9NamedDeclEj", "clang::IndirectFieldDecl::Create(clang::ASTContext&, clang::DeclContext*, clang::SourceLocation, clang::IdentifierInfo*, clang::QualType, clang::NamedDecl**, unsigned int)"},
     {"_ZNK5clang16EnumConstantDecl14getSourceRangeEv", "clang::EnumConstantDecl::getSourceRange() const"},
     {"_ZN5clang11TypedefDecl6CreateERNS_10ASTContextEPNS_11DeclContextENS_14SourceLocationEPNS_14IdentifierInfoEPNS_14TypeSourceInfoE", "clang::TypedefDecl::Create(clang::ASTContext&, clang::DeclContext*, clang::SourceLocation, clang::IdentifierInfo*, clang::TypeSourceInfo*)"},
-    {"_ZN5clang16FileScopeAsmDecl6CreateERNS_10ASTContextEPNS_11DeclContextENS_14SourceLocationEPNS_13StringLiteralE", "clang::FileScopeAsmDecl::Create(clang::ASTContext&, clang::DeclContext*, clang::SourceLocation, clang::StringLiteral*)"},
+    {"_ZN5clang16FileScopeAsmDecl6CreateERNS_10ASTContextEPNS_11DeclContextENS_14SourceLocationEPNS_13StringLiteralE", "clang::FileScopeAsmDecl::Create(clang::ASTContext&, clang::DeclContext*, clang::SourceLocation, clang::StringRef*)"},
     {"_Z21GetExplicitVisibilityPKN5clang4DeclE", "GetExplicitVisibility(clang::Decl const*)"},
     {"_Z29getLVForTemplateParameterListPKN5clang21TemplateParameterListE", "getLVForTemplateParameterList(clang::TemplateParameterList const*)"},
     {"_Z28getLVForTemplateArgumentListPKN5clang16TemplateArgumentEjRN12_GLOBAL__N_17LVFlagsE", "getLVForTemplateArgumentList(clang::TemplateArgument const*, unsigned int, (anonymous namespace)::LVFlags&)"},
@@ -9946,7 +9946,7 @@ const char *cases[][2] = {
     {"_ZN5clang9UsingDecl6CreateERNS_10ASTContextEPNS_11DeclContextENS_11SourceRangeENS_14SourceLocationEPNS_19NestedNameSpecifierERKNS_19DeclarationNameInfoEb", "clang::UsingDecl::Create(clang::ASTContext&, clang::DeclContext*, clang::SourceRange, clang::SourceLocation, clang::NestedNameSpecifier*, clang::DeclarationNameInfo const&, bool)"},
     {"_ZN5clang24UnresolvedUsingValueDecl6CreateERNS_10ASTContextEPNS_11DeclContextENS_14SourceLocationENS_11SourceRangeEPNS_19NestedNameSpecifierERKNS_19DeclarationNameInfoE", "clang::UnresolvedUsingValueDecl::Create(clang::ASTContext&, clang::DeclContext*, clang::SourceLocation, clang::SourceRange, clang::NestedNameSpecifier*, clang::DeclarationNameInfo const&)"},
     {"_ZN5clang27UnresolvedUsingTypenameDecl6CreateERNS_10ASTContextEPNS_11DeclContextENS_14SourceLocationES5_NS_11SourceRangeEPNS_19NestedNameSpecifierES5_NS_15DeclarationNameE", "clang::UnresolvedUsingTypenameDecl::Create(clang::ASTContext&, clang::DeclContext*, clang::SourceLocation, clang::SourceLocation, clang::SourceRange, clang::NestedNameSpecifier*, clang::SourceLocation, clang::DeclarationName)"},
-    {"_ZN5clang16StaticAssertDecl6CreateERNS_10ASTContextEPNS_11DeclContextENS_14SourceLocationEPNS_4ExprEPNS_13StringLiteralE", "clang::StaticAssertDecl::Create(clang::ASTContext&, clang::DeclContext*, clang::SourceLocation, clang::Expr*, clang::StringLiteral*)"},
+    {"_ZN5clang16StaticAssertDecl6CreateERNS_10ASTContextEPNS_11DeclContextENS_14SourceLocationEPNS_4ExprEPNS_13StringLiteralE", "clang::StaticAssertDecl::Create(clang::ASTContext&, clang::DeclContext*, clang::SourceLocation, clang::Expr*, clang::StringRef*)"},
     {"_ZN5clanglsERKNS_17DiagnosticBuilderENS_15AccessSpecifierE", "clang::operator<<(clang::DiagnosticBuilder const&, clang::AccessSpecifier)"},
     {"_Z17GetConversionTypeRN5clang10ASTContextEPNS_9NamedDeclE", "GetConversionType(clang::ASTContext&, clang::NamedDecl*)"},
     {"_Z25CollectVisibleConversionsRN5clang10ASTContextEPNS_13CXXRecordDeclEbNS_15AccessSpecifierERKN4llvm11SmallPtrSetINS_7CanQualINS_4TypeEEELj8EEERNS_17UnresolvedSetImplESE_RNS6_IPNS_9NamedDeclELj8EEE", "CollectVisibleConversions(clang::ASTContext&, clang::CXXRecordDecl*, bool, clang::AccessSpecifier, llvm::SmallPtrSet, 8u> const&, clang::UnresolvedSetImpl&, clang::UnresolvedSetImpl&, llvm::SmallPtrSet&)"},
@@ -10272,10 +10272,10 @@ const char *cases[][2] = {
     {"_ZN5clang15FloatingLiteral6CreateERNS_10ASTContextERKN4llvm7APFloatEbNS_8QualTypeENS_14SourceLocationE", "clang::FloatingLiteral::Create(clang::ASTContext&, llvm::APFloat const&, bool, clang::QualType, clang::SourceLocation)"},
     {"_ZN5clang15FloatingLiteral6CreateERNS_10ASTContextENS_4Stmt10EmptyShellE", "clang::FloatingLiteral::Create(clang::ASTContext&, clang::Stmt::EmptyShell)"},
     {"_ZNK5clang15FloatingLiteral27getValueAsApproximateDoubleEv", "clang::FloatingLiteral::getValueAsApproximateDouble() const"},
-    {"_ZN5clang13StringLiteral6CreateERNS_10ASTContextEPKcjbNS_8QualTypeEPKNS_14SourceLocationEj", "clang::StringLiteral::Create(clang::ASTContext&, char const*, unsigned int, bool, clang::QualType, clang::SourceLocation const*, unsigned int)"},
-    {"_ZN5clang13StringLiteral11CreateEmptyERNS_10ASTContextEj", "clang::StringLiteral::CreateEmpty(clang::ASTContext&, unsigned int)"},
-    {"_ZN5clang13StringLiteral9setStringERNS_10ASTContextEN4llvm9StringRefE", "clang::StringLiteral::setString(clang::ASTContext&, llvm::StringRef)"},
-    {"_ZNK5clang13StringLiteral17getLocationOfByteEjRKNS_13SourceManagerERKNS_11LangOptionsERKNS_10TargetInfoE", "clang::StringLiteral::getLocationOfByte(unsigned int, clang::SourceManager const&, clang::LangOptions const&, clang::TargetInfo const&) const"},
+    {"_ZN5clang13StringLiteral6CreateERNS_10ASTContextEPKcjbNS_8QualTypeEPKNS_14SourceLocationEj", "clang::StringRef::Create(clang::ASTContext&, char const*, unsigned int, bool, clang::QualType, clang::SourceLocation const*, unsigned int)"},
+    {"_ZN5clang13StringLiteral11CreateEmptyERNS_10ASTContextEj", "clang::StringRef::CreateEmpty(clang::ASTContext&, unsigned int)"},
+    {"_ZN5clang13StringLiteral9setStringERNS_10ASTContextEN4llvm9StringRefE", "clang::StringRef::setString(clang::ASTContext&, llvm::StringRef)"},
+    {"_ZNK5clang13StringLiteral17getLocationOfByteEjRKNS_13SourceManagerERKNS_11LangOptionsERKNS_10TargetInfoE", "clang::StringRef::getLocationOfByte(unsigned int, clang::SourceManager const&, clang::LangOptions const&, clang::TargetInfo const&) const"},
     {"_ZN5clang13UnaryOperator12getOpcodeStrENS_17UnaryOperatorKindE", "clang::UnaryOperator::getOpcodeStr(clang::UnaryOperatorKind)"},
     {"_ZN5clang13UnaryOperator19getOverloadedOpcodeENS_22OverloadedOperatorKindEb", "clang::UnaryOperator::getOverloadedOpcode(clang::OverloadedOperatorKind, bool)"},
     {"_ZN5clang13UnaryOperator21getOverloadedOperatorENS_17UnaryOperatorKindE", "clang::UnaryOperator::getOverloadedOperator(clang::UnaryOperatorKind)"},
@@ -10744,12 +10744,12 @@ const char *cases[][2] = {
     {"_ZNK5clang7AsmStmt18getNumPlusOperandsEv", "clang::AsmStmt::getNumPlusOperands() const"},
     {"_ZN5clang7AsmStmt12getInputExprEj", "clang::AsmStmt::getInputExpr(unsigned int)"},
     {"_ZNK5clang7AsmStmt18getInputConstraintEj", "clang::AsmStmt::getInputConstraint(unsigned int) const"},
-    {"_ZN5clang7AsmStmt30setOutputsAndInputsAndClobbersERNS_10ASTContextEPPNS_14IdentifierInfoEPPNS_13StringLiteralEPPNS_4StmtEjjS8_j", "clang::AsmStmt::setOutputsAndInputsAndClobbers(clang::ASTContext&, clang::IdentifierInfo**, clang::StringLiteral**, clang::Stmt**, unsigned int, unsigned int, clang::StringLiteral**, unsigned int)"},
+    {"_ZN5clang7AsmStmt30setOutputsAndInputsAndClobbersERNS_10ASTContextEPPNS_14IdentifierInfoEPPNS_13StringLiteralEPPNS_4StmtEjjS8_j", "clang::AsmStmt::setOutputsAndInputsAndClobbers(clang::ASTContext&, clang::IdentifierInfo**, clang::StringRef**, clang::Stmt**, unsigned int, unsigned int, clang::StringRef**, unsigned int)"},
     {"_ZNK5clang7AsmStmt15getNamedOperandEN4llvm9StringRefE", "clang::AsmStmt::getNamedOperand(llvm::StringRef) const"},
     {"_ZNK5clang7AsmStmt16AnalyzeAsmStringERN4llvm15SmallVectorImplINS0_14AsmStringPieceEEERNS_10ASTContextERj", "clang::AsmStmt::AnalyzeAsmString(llvm::SmallVectorImpl&, clang::ASTContext&, unsigned int&) const"},
     {"_ZNK5clang12CXXCatchStmt13getCaughtTypeEv", "clang::CXXCatchStmt::getCaughtType() const"},
-    {"_ZN5clang7AsmStmtC1ERNS_10ASTContextENS_14SourceLocationEbbbjjPPNS_14IdentifierInfoEPPNS_13StringLiteralEPPNS_4ExprES8_jS9_S3_", "clang::AsmStmt::AsmStmt(clang::ASTContext&, clang::SourceLocation, bool, bool, bool, unsigned int, unsigned int, clang::IdentifierInfo**, clang::StringLiteral**, clang::Expr**, clang::StringLiteral*, unsigned int, clang::StringLiteral**, clang::SourceLocation)"},
-    {"_ZN5clang7AsmStmtC2ERNS_10ASTContextENS_14SourceLocationEbbbjjPPNS_14IdentifierInfoEPPNS_13StringLiteralEPPNS_4ExprES8_jS9_S3_", "clang::AsmStmt::AsmStmt(clang::ASTContext&, clang::SourceLocation, bool, bool, bool, unsigned int, unsigned int, clang::IdentifierInfo**, clang::StringLiteral**, clang::Expr**, clang::StringLiteral*, unsigned int, clang::StringLiteral**, clang::SourceLocation)"},
+    {"_ZN5clang7AsmStmtC1ERNS_10ASTContextENS_14SourceLocationEbbbjjPPNS_14IdentifierInfoEPPNS_13StringLiteralEPPNS_4ExprES8_jS9_S3_", "clang::AsmStmt::AsmStmt(clang::ASTContext&, clang::SourceLocation, bool, bool, bool, unsigned int, unsigned int, clang::IdentifierInfo**, clang::StringRef**, clang::Expr**, clang::StringRef*, unsigned int, clang::StringRef**, clang::SourceLocation)"},
+    {"_ZN5clang7AsmStmtC2ERNS_10ASTContextENS_14SourceLocationEbbbjjPPNS_14IdentifierInfoEPPNS_13StringLiteralEPPNS_4ExprES8_jS9_S3_", "clang::AsmStmt::AsmStmt(clang::ASTContext&, clang::SourceLocation, bool, bool, bool, unsigned int, unsigned int, clang::IdentifierInfo**, clang::StringRef**, clang::Expr**, clang::StringRef*, unsigned int, clang::StringRef**, clang::SourceLocation)"},
     {"_ZN5clang21ObjCForCollectionStmtC1EPNS_4StmtEPNS_4ExprES2_NS_14SourceLocationES5_", "clang::ObjCForCollectionStmt::ObjCForCollectionStmt(clang::Stmt*, clang::Expr*, clang::Stmt*, clang::SourceLocation, clang::SourceLocation)"},
     {"_ZN5clang21ObjCForCollectionStmtC2EPNS_4StmtEPNS_4ExprES2_NS_14SourceLocationES5_", "clang::ObjCForCollectionStmt::ObjCForCollectionStmt(clang::Stmt*, clang::Expr*, clang::Stmt*, clang::SourceLocation, clang::SourceLocation)"},
     {"_ZN5clang13ObjCAtTryStmtC1ENS_14SourceLocationEPNS_4StmtEPS3_jS3_", "clang::ObjCAtTryStmt::ObjCAtTryStmt(clang::SourceLocation, clang::Stmt*, clang::Stmt**, unsigned int, clang::Stmt*)"},
@@ -10822,7 +10822,7 @@ const char *cases[][2] = {
     {"_ZN5clang13PrinterHelperD2Ev", "clang::PrinterHelper::~PrinterHelper()"},
     {"_ZN5clang11StmtVisitorIN12_GLOBAL__N_111StmtPrinterEvE5VisitEPNS_4StmtE", "clang::StmtVisitor<(anonymous namespace)::StmtPrinter, void>::Visit(clang::Stmt*)"},
     {"_ZN12_GLOBAL__N_111StmtPrinter13VisitCallExprEPN5clang8CallExprE", "(anonymous namespace)::StmtPrinter::VisitCallExpr(clang::CallExpr*)"},
-    {"_ZN12_GLOBAL__N_111StmtPrinter18VisitStringLiteralEPN5clang13StringLiteralE", "(anonymous namespace)::StmtPrinter::VisitStringLiteral(clang::StringLiteral*)"},
+    {"_ZN12_GLOBAL__N_111StmtPrinter18VisitStringLiteralEPN5clang13StringLiteralE", "(anonymous namespace)::StmtPrinter::VisitStringLiteral(clang::StringRef*)"},
     {"_ZN12_GLOBAL__N_111StmtPrinter18VisitUnaryOperatorEPN5clang13UnaryOperatorE", "(anonymous namespace)::StmtPrinter::VisitUnaryOperator(clang::UnaryOperator*)"},
     {"_ZN12_GLOBAL__N_111StmtPrinter9PrintExprEPN5clang4ExprE", "(anonymous namespace)::StmtPrinter::PrintExpr(clang::Expr*)"},
     {"_ZN12_GLOBAL__N_111StmtPrinter9PrintStmtEPN5clang4StmtEi", "(anonymous namespace)::StmtPrinter::PrintStmt(clang::Stmt*, int)"},
diff --git a/lld/MachO/SyntheticSections.h b/lld/MachO/SyntheticSections.h
index af99f22788d6e..931822c4a1e71 100644
--- a/lld/MachO/SyntheticSections.h
+++ b/lld/MachO/SyntheticSections.h
@@ -345,7 +345,7 @@ class ObjCStubsSection final : public SyntheticSection {
   void writeTo(uint8_t *buf) const override;
   void setUp();
 
-  static constexpr llvm::StringLiteral symbolPrefix = "_objc_msgSend$";
+  static constexpr llvm::StringRef symbolPrefix = "_objc_msgSend$";
   static bool isObjCStubSymbol(Symbol *sym);
   static StringRef getMethname(Symbol *sym);
 
diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h b/lldb/include/lldb/Interpreter/CommandInterpreter.h
index 2bafc30cc8e23..dc657be5027c6 100644
--- a/lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -681,7 +681,7 @@ class CommandInterpreter : public Broadcaster,
                               std::string &line) override;
 
   llvm::StringRef IOHandlerGetControlSequence(char ch) override {
-    static constexpr llvm::StringLiteral control_sequence("quit\n");
+    static constexpr llvm::StringRef control_sequence("quit\n");
     if (ch == 'd')
       return control_sequence;
     return {};
diff --git a/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h b/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
index a3dc52c435561..0f4baaae910de 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
@@ -32,15 +32,15 @@ class ScriptedInterface {
   }
 
   struct AbstractMethodRequirement {
-    llvm::StringLiteral name;
+    llvm::StringRef name;
     size_t min_arg_count = 0;
   };
 
   virtual llvm::SmallVector
   GetAbstractMethodRequirements() const = 0;
 
-  llvm::SmallVector const GetAbstractMethods() const {
-    llvm::SmallVector abstract_methods;
+  llvm::SmallVector const GetAbstractMethods() const {
+    llvm::SmallVector abstract_methods;
     llvm::transform(GetAbstractMethodRequirements(), abstract_methods.begin(),
                     [](const AbstractMethodRequirement &requirement) {
                       return requirement.name;
diff --git a/lldb/include/lldb/Interpreter/Options.h b/lldb/include/lldb/Interpreter/Options.h
index 9a6a17c2793fa..8a8e34bded416 100644
--- a/lldb/include/lldb/Interpreter/Options.h
+++ b/lldb/include/lldb/Interpreter/Options.h
@@ -364,11 +364,11 @@ llvm::Error CreateOptionParsingError(llvm::StringRef option_arg,
                                      llvm::StringRef long_option = {},
                                      llvm::StringRef additional_context = {});
 
-static constexpr llvm::StringLiteral g_bool_parsing_error_message =
+static constexpr llvm::StringRef g_bool_parsing_error_message =
     "Failed to parse as boolean";
-static constexpr llvm::StringLiteral g_int_parsing_error_message =
+static constexpr llvm::StringRef g_int_parsing_error_message =
     "Failed to parse as integer";
-static constexpr llvm::StringLiteral g_language_parsing_error_message =
+static constexpr llvm::StringRef g_language_parsing_error_message =
     "Unknown language";
 
 } // namespace lldb_private
diff --git a/lldb/include/lldb/Target/UnixSignals.h b/lldb/include/lldb/Target/UnixSignals.h
index b3605ccefddbe..833a7c004d30c 100644
--- a/lldb/include/lldb/Target/UnixSignals.h
+++ b/lldb/include/lldb/Target/UnixSignals.h
@@ -110,7 +110,7 @@ class UnixSignals {
   // Instead of calling this directly, use a ADD_SIGCODE macro to get compile
   // time checks when on the native platform.
   void AddSignalCode(
-      int signo, int code, const llvm::StringLiteral description,
+      int signo, int code, const llvm::StringRef description,
       SignalCodePrintOption print_option = SignalCodePrintOption::None);
 
   void RemoveSignal(int signo);
@@ -143,7 +143,7 @@ class UnixSignals {
   // Classes that inherit from UnixSignals can see and modify these
 
   struct SignalCode {
-    const llvm::StringLiteral m_description;
+    const llvm::StringRef m_description;
     const SignalCodePrintOption m_print_option;
   };
 
diff --git a/lldb/include/lldb/Utility/Log.h b/lldb/include/lldb/Utility/Log.h
index 1529178cb83b4..0e9754f3bb0e0 100644
--- a/lldb/include/lldb/Utility/Log.h
+++ b/lldb/include/lldb/Utility/Log.h
@@ -145,13 +145,13 @@ class Log final {
 
   // Description of a log channel category.
   struct Category {
-    llvm::StringLiteral name;
-    llvm::StringLiteral description;
+    llvm::StringRef name;
+    llvm::StringRef description;
     MaskType flag;
 
     template 
-    constexpr Category(llvm::StringLiteral name,
-                       llvm::StringLiteral description, Cat mask)
+    constexpr Category(llvm::StringRef name, llvm::StringRef description,
+                       Cat mask)
         : name(name), description(description), flag(MaskType(mask)) {
       static_assert(
           std::is_same>::value);
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 6ceb209269c9e..9fb682195fa19 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -694,8 +694,8 @@ LoadPluginCallback(void *baton, llvm::sys::fs::file_type ft,
                    llvm::StringRef path) {
   Status error;
 
-  static constexpr llvm::StringLiteral g_dylibext(".dylib");
-  static constexpr llvm::StringLiteral g_solibext(".so");
+  static constexpr llvm::StringRef g_dylibext(".dylib");
+  static constexpr llvm::StringRef g_solibext(".so");
 
   if (!baton)
     return FileSystem::eEnumerateDirectoryResultQuit;
@@ -867,7 +867,7 @@ TargetSP Debugger::FindTargetWithProcess(Process *process) {
 }
 
 llvm::StringRef Debugger::GetStaticBroadcasterClass() {
-  static constexpr llvm::StringLiteral class_name("lldb.debugger");
+  static constexpr llvm::StringRef class_name("lldb.debugger");
   return class_name;
 }
 
diff --git a/lldb/source/Core/Disassembler.cpp b/lldb/source/Core/Disassembler.cpp
index 68e52144eb6ef..94bc5085736d2 100644
--- a/lldb/source/Core/Disassembler.cpp
+++ b/lldb/source/Core/Disassembler.cpp
@@ -780,7 +780,7 @@ OptionValueSP Instruction::ReadDictionary(FILE *in_file, Stream &out_stream) {
   char buffer[1024];
 
   auto option_value_sp = std::make_shared();
-  static constexpr llvm::StringLiteral encoding_key("data_encoding");
+  static constexpr llvm::StringRef encoding_key("data_encoding");
   OptionValue::Type data_type = OptionValue::eTypeInvalid;
 
   while (!done) {
@@ -919,8 +919,8 @@ bool Instruction::TestEmulation(Stream &out_stream, const char *file_name) {
 
   OptionValueDictionary *data_dictionary =
       data_dictionary_sp->GetAsDictionary();
-  static constexpr llvm::StringLiteral description_key("assembly_string");
-  static constexpr llvm::StringLiteral triple_key("triple");
+  static constexpr llvm::StringRef description_key("assembly_string");
+  static constexpr llvm::StringRef triple_key("triple");
 
   OptionValueSP value_sp = data_dictionary->GetValueForKey(description_key);
 
diff --git a/lldb/source/Core/PluginManager.cpp b/lldb/source/Core/PluginManager.cpp
index 80c9465f9af72..3beba847d47fb 100644
--- a/lldb/source/Core/PluginManager.cpp
+++ b/lldb/source/Core/PluginManager.cpp
@@ -1645,7 +1645,7 @@ GetDebuggerPropertyForPlugins(Debugger &debugger, llvm::StringRef plugin_type_na
   lldb::OptionValuePropertiesSP parent_properties_sp(
       debugger.GetValueProperties());
   if (parent_properties_sp) {
-    static constexpr llvm::StringLiteral g_property_name("plugin");
+    static constexpr llvm::StringRef g_property_name("plugin");
 
     OptionValuePropertiesSP plugin_properties_sp =
         parent_properties_sp->GetSubProperty(nullptr, g_property_name);
@@ -1678,7 +1678,7 @@ GetDebuggerPropertyForPlugins(Debugger &debugger, llvm::StringRef plugin_type_na
 static lldb::OptionValuePropertiesSP GetDebuggerPropertyForPluginsOldStyle(
     Debugger &debugger, llvm::StringRef plugin_type_name,
     llvm::StringRef plugin_type_desc, bool can_create) {
-  static constexpr llvm::StringLiteral g_property_name("plugin");
+  static constexpr llvm::StringRef g_property_name("plugin");
   lldb::OptionValuePropertiesSP parent_properties_sp(
       debugger.GetValueProperties());
   if (parent_properties_sp) {
@@ -1751,16 +1751,15 @@ CreateSettingForPlugin(Debugger &debugger, llvm::StringRef plugin_type_name,
   return false;
 }
 
-static constexpr llvm::StringLiteral kDynamicLoaderPluginName("dynamic-loader");
-static constexpr llvm::StringLiteral kPlatformPluginName("platform");
-static constexpr llvm::StringLiteral kProcessPluginName("process");
-static constexpr llvm::StringLiteral kTracePluginName("trace");
-static constexpr llvm::StringLiteral kObjectFilePluginName("object-file");
-static constexpr llvm::StringLiteral kSymbolFilePluginName("symbol-file");
-static constexpr llvm::StringLiteral kSymbolLocatorPluginName("symbol-locator");
-static constexpr llvm::StringLiteral kJITLoaderPluginName("jit-loader");
-static constexpr llvm::StringLiteral
-    kStructuredDataPluginName("structured-data");
+static constexpr llvm::StringRef kDynamicLoaderPluginName("dynamic-loader");
+static constexpr llvm::StringRef kPlatformPluginName("platform");
+static constexpr llvm::StringRef kProcessPluginName("process");
+static constexpr llvm::StringRef kTracePluginName("trace");
+static constexpr llvm::StringRef kObjectFilePluginName("object-file");
+static constexpr llvm::StringRef kSymbolFilePluginName("symbol-file");
+static constexpr llvm::StringRef kSymbolLocatorPluginName("symbol-locator");
+static constexpr llvm::StringRef kJITLoaderPluginName("jit-loader");
+static constexpr llvm::StringRef kStructuredDataPluginName("structured-data");
 
 lldb::OptionValuePropertiesSP
 PluginManager::GetSettingForDynamicLoaderPlugin(Debugger &debugger,
diff --git a/lldb/source/Core/ThreadedCommunication.cpp b/lldb/source/Core/ThreadedCommunication.cpp
index 649ce71c29374..817b4d88ab303 100644
--- a/lldb/source/Core/ThreadedCommunication.cpp
+++ b/lldb/source/Core/ThreadedCommunication.cpp
@@ -33,7 +33,7 @@ using namespace lldb;
 using namespace lldb_private;
 
 llvm::StringRef ThreadedCommunication::GetStaticBroadcasterClass() {
-  static constexpr llvm::StringLiteral class_name("lldb.communication");
+  static constexpr llvm::StringRef class_name("lldb.communication");
   return class_name;
 }
 
diff --git a/lldb/source/Core/UserSettingsController.cpp b/lldb/source/Core/UserSettingsController.cpp
index b57c1b0eef9b4..3f085068c237a 100644
--- a/lldb/source/Core/UserSettingsController.cpp
+++ b/lldb/source/Core/UserSettingsController.cpp
@@ -102,7 +102,7 @@ Properties::Apropos(llvm::StringRef keyword,
 }
 
 llvm::StringRef Properties::GetExperimentalSettingsName() {
-  static constexpr llvm::StringLiteral g_experimental("experimental");
+  static constexpr llvm::StringRef g_experimental("experimental");
   return g_experimental;
 }
 
diff --git a/lldb/source/Expression/REPL.cpp b/lldb/source/Expression/REPL.cpp
index 4b53537e50e62..7151fca5f4d05 100644
--- a/lldb/source/Expression/REPL.cpp
+++ b/lldb/source/Expression/REPL.cpp
@@ -118,7 +118,7 @@ const char *REPL::IOHandlerGetFixIndentationCharacters() {
 }
 
 llvm::StringRef REPL::IOHandlerGetControlSequence(char ch) {
-  static constexpr llvm::StringLiteral control_sequence(":quit\n");
+  static constexpr llvm::StringRef control_sequence(":quit\n");
   if (ch == 'd')
     return control_sequence;
   return {};
diff --git a/lldb/source/Host/common/ZipFileResolver.cpp b/lldb/source/Host/common/ZipFileResolver.cpp
index f70ccb79d0896..6a217f423e696 100644
--- a/lldb/source/Host/common/ZipFileResolver.cpp
+++ b/lldb/source/Host/common/ZipFileResolver.cpp
@@ -22,14 +22,14 @@ bool ZipFileResolver::ResolveSharedLibraryPath(const FileSpec &file_spec,
                                                lldb::offset_t &so_file_size) {
   // When bionic loads .so file from APK or zip file, this file_spec will be
   // "zip_path!/so_path". Otherwise it is just a normal file path.
-  static constexpr llvm::StringLiteral k_zip_separator("!/");
+  static constexpr llvm::StringRef k_zip_separator("!/");
   std::string path(file_spec.GetPath());
   size_t pos = path.find(k_zip_separator);
 
 #if defined(_WIN32)
   // When the file_spec is resolved as a Windows path, the zip .so path will be
   // "zip_path!\so_path". Support both patterns on Windows.
-  static constexpr llvm::StringLiteral k_zip_separator_win("!\\");
+  static constexpr llvm::StringRef k_zip_separator_win("!\\");
   if (pos == std::string::npos)
     pos = path.find(k_zip_separator_win);
 #endif
diff --git a/lldb/source/Host/windows/PipeWindows.cpp b/lldb/source/Host/windows/PipeWindows.cpp
index 21e30f0ae8738..bd0b9b3fc9653 100644
--- a/lldb/source/Host/windows/PipeWindows.cpp
+++ b/lldb/source/Host/windows/PipeWindows.cpp
@@ -23,7 +23,7 @@ using namespace lldb;
 using namespace lldb_private;
 
 static std::atomic g_pipe_serial(0);
-static constexpr llvm::StringLiteral g_pipe_name_prefix = "\\\\.\\Pipe\\";
+static constexpr llvm::StringRef g_pipe_name_prefix = "\\\\.\\Pipe\\";
 
 PipeWindows::PipeWindows()
     : m_read(INVALID_HANDLE_VALUE), m_write(INVALID_HANDLE_VALUE),
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index 764dcfd1903b1..ee1ea190065a0 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -123,7 +123,7 @@ enum {
 };
 
 llvm::StringRef CommandInterpreter::GetStaticBroadcasterClass() {
-  static constexpr llvm::StringLiteral class_name("lldb.commandInterpreter");
+  static constexpr llvm::StringRef class_name("lldb.commandInterpreter");
   return class_name;
 }
 
diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
index ab013e79047ea..6148ba1f3b794 100644
--- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
+++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
@@ -100,7 +100,7 @@ enum {
 class DynamicLoaderDarwinKernelProperties : public Properties {
 public:
   static llvm::StringRef GetSettingName() {
-    static constexpr llvm::StringLiteral g_setting_name("darwin-kernel");
+    static constexpr llvm::StringRef g_setting_name("darwin-kernel");
     return g_setting_name;
   }
 
diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
index 3659dfcd3c4ca..e1b11411fa3fc 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
@@ -624,7 +624,7 @@ bool DynamicLoaderDarwin::UpdateDYLDImageInfoFromNewImageInfo(
 std::optional DynamicLoaderDarwin::GetStartAddress() {
   Log *log = GetLog(LLDBLog::DynamicLoader);
 
-  auto log_err = [log](llvm::StringLiteral err_msg) -> std::nullopt_t {
+  auto log_err = [log](llvm::StringRef err_msg) -> std::nullopt_t {
     LLDB_LOGV(log, "{}", err_msg);
     return std::nullopt;
   };
diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwinProperties.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwinProperties.cpp
index f4d8a071e6d5d..a981b502c2201 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwinProperties.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwinProperties.cpp
@@ -19,7 +19,7 @@ enum {
 };
 
 llvm::StringRef DynamicLoaderDarwinProperties::GetSettingName() {
-  static constexpr llvm::StringLiteral g_setting_name("darwin");
+  static constexpr llvm::StringRef g_setting_name("darwin");
   return g_setting_name;
 }
 
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
index ae34a983612f7..0c644da33f886 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
@@ -889,8 +889,8 @@ bool ClangUserExpression::AddArguments(ExecutionContext &exe_ctx,
       return false;
     }
 
-    static constexpr llvm::StringLiteral g_cplusplus_object_name("this");
-    static constexpr llvm::StringLiteral g_objc_object_name("self");
+    static constexpr llvm::StringRef g_cplusplus_object_name("this");
+    static constexpr llvm::StringRef g_objc_object_name("self");
     llvm::StringRef object_name =
         m_in_cplusplus_method ? g_cplusplus_object_name : g_objc_object_name;
 
@@ -920,7 +920,7 @@ bool ClangUserExpression::AddArguments(ExecutionContext &exe_ctx,
     }
 
     if (m_in_objectivec_method) {
-      static constexpr llvm::StringLiteral cmd_name("_cmd");
+      static constexpr llvm::StringRef cmd_name("_cmd");
 
       cmd_ptr = GetObjectPointer(frame_sp, cmd_name, object_ptr_error);
 
diff --git a/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
index 147c00e51b40d..3a4b79c3271cd 100644
--- a/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
+++ b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
@@ -14353,9 +14353,9 @@ bool EmulateInstructionARM::TestEmulation(Stream &out_stream, ArchSpec &arch,
     return false;
   }
 
-  static constexpr llvm::StringLiteral opcode_key("opcode");
-  static constexpr llvm::StringLiteral before_key("before_state");
-  static constexpr llvm::StringLiteral after_key("after_state");
+  static constexpr llvm::StringRef opcode_key("opcode");
+  static constexpr llvm::StringRef before_key("before_state");
+  static constexpr llvm::StringRef after_key("after_state");
 
   OptionValueSP value_sp = test_data->GetValueForKey(opcode_key);
 
diff --git a/lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp b/lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
index 75dcb6ee6dcf6..3fcb0eb9a0362 100644
--- a/lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
+++ b/lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
@@ -275,8 +275,8 @@ bool EmulationStateARM::LoadRegistersStateFromDictionary(
 
 bool EmulationStateARM::LoadStateFromDictionary(
     OptionValueDictionary *test_data) {
-  static constexpr llvm::StringLiteral memory_key("memory");
-  static constexpr llvm::StringLiteral registers_key("registers");
+  static constexpr llvm::StringRef memory_key("memory");
+  static constexpr llvm::StringRef registers_key("registers");
 
   if (!test_data)
     return false;
@@ -286,8 +286,8 @@ bool EmulationStateARM::LoadStateFromDictionary(
   // Load memory, if present.
 
   if (value_sp.get() != nullptr) {
-    static constexpr llvm::StringLiteral address_key("address");
-    static constexpr llvm::StringLiteral data_key("data");
+    static constexpr llvm::StringRef address_key("address");
+    static constexpr llvm::StringRef data_key("data");
     uint64_t start_address = 0;
 
     OptionValueDictionary *mem_dict = value_sp->GetAsDictionary();
@@ -325,7 +325,7 @@ bool EmulationStateARM::LoadStateFromDictionary(
   if (!LoadRegistersStateFromDictionary(reg_dict, 'r', dwarf_r0, 16))
     return false;
 
-  static constexpr llvm::StringLiteral cpsr_name("cpsr");
+  static constexpr llvm::StringRef cpsr_name("cpsr");
   value_sp = reg_dict->GetValueForKey(cpsr_name);
   if (value_sp.get() == nullptr)
     return false;
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp
index d8c095d6edeb7..6874fea65fb2b 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp
@@ -330,7 +330,7 @@ bool CPlusPlusNameParser::ConsumeAnonymousNamespace() {
   if (!ConsumeToken(tok::l_paren)) {
     return false;
   }
-  constexpr llvm::StringLiteral g_anonymous("anonymous");
+  constexpr llvm::StringRef g_anonymous("anonymous");
   if (HasMoreTokens() && Peek().is(tok::raw_identifier) &&
       Peek().getRawIdentifier() == g_anonymous) {
     Advance();
@@ -354,7 +354,7 @@ bool CPlusPlusNameParser::ConsumeLambda() {
   if (!ConsumeToken(tok::l_brace)) {
     return false;
   }
-  constexpr llvm::StringLiteral g_lambda("lambda");
+  constexpr llvm::StringRef g_lambda("lambda");
   if (HasMoreTokens() && Peek().is(tok::raw_identifier) &&
       Peek().getRawIdentifier() == g_lambda) {
     // Put the matched brace back so we can use ConsumeBrackets
diff --git a/lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp b/lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp
index 33955dccb6ccc..334d6abe25b3b 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp
@@ -69,8 +69,8 @@ GenericBitsetFrontEnd::GenericBitsetFrontEnd(ValueObject &valobj, StdLib stdlib)
 }
 
 llvm::StringRef GenericBitsetFrontEnd::GetDataContainerMemberName() {
-  static constexpr llvm::StringLiteral s_libcxx_case("__first_");
-  static constexpr llvm::StringLiteral s_libstdcpp_case("_M_w");
+  static constexpr llvm::StringRef s_libcxx_case("__first_");
+  static constexpr llvm::StringRef s_libstdcpp_case("_M_w");
   switch (m_stdlib) {
   case StdLib::LibCxx:
     return s_libcxx_case;
diff --git a/lldb/source/Plugins/Language/ObjC/CF.cpp b/lldb/source/Plugins/Language/ObjC/CF.cpp
index eba905b7b94f3..91611d8b17656 100644
--- a/lldb/source/Plugins/Language/ObjC/CF.cpp
+++ b/lldb/source/Plugins/Language/ObjC/CF.cpp
@@ -44,7 +44,7 @@ bool lldb_private::formatters::CFAbsoluteTimeSummaryProvider(
 
 bool lldb_private::formatters::CFBagSummaryProvider(
     ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
-  static constexpr llvm::StringLiteral g_TypeHint("CFBag");
+  static constexpr llvm::StringRef g_TypeHint("CFBag");
 
   ProcessSP process_sp = valobj.GetProcessSP();
   if (!process_sp)
@@ -222,7 +222,7 @@ bool lldb_private::formatters::CFBitVectorSummaryProvider(
 
 bool lldb_private::formatters::CFBinaryHeapSummaryProvider(
     ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
-  static constexpr llvm::StringLiteral g_TypeHint("CFBinaryHeap");
+  static constexpr llvm::StringRef g_TypeHint("CFBinaryHeap");
 
   ProcessSP process_sp = valobj.GetProcessSP();
   if (!process_sp)
diff --git a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
index 1d79edbede5d6..91390c45bdb81 100644
--- a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
+++ b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
@@ -340,7 +340,7 @@ bool lldb_private::formatters::NSIndexSetSummaryProvider(
 
 static void NSNumber_FormatChar(ValueObject &valobj, Stream &stream, char value,
                                 lldb::LanguageType lang) {
-  static constexpr llvm::StringLiteral g_TypeHint("NSNumber:char");
+  static constexpr llvm::StringRef g_TypeHint("NSNumber:char");
 
   llvm::StringRef prefix, suffix;
   if (Language *language = Language::FindPlugin(lang))
@@ -353,7 +353,7 @@ static void NSNumber_FormatChar(ValueObject &valobj, Stream &stream, char value,
 
 static void NSNumber_FormatShort(ValueObject &valobj, Stream &stream,
                                  short value, lldb::LanguageType lang) {
-  static constexpr llvm::StringLiteral g_TypeHint("NSNumber:short");
+  static constexpr llvm::StringRef g_TypeHint("NSNumber:short");
 
   llvm::StringRef prefix, suffix;
   if (Language *language = Language::FindPlugin(lang))
@@ -366,7 +366,7 @@ static void NSNumber_FormatShort(ValueObject &valobj, Stream &stream,
 
 static void NSNumber_FormatInt(ValueObject &valobj, Stream &stream, int value,
                                lldb::LanguageType lang) {
-  static constexpr llvm::StringLiteral g_TypeHint("NSNumber:int");
+  static constexpr llvm::StringRef g_TypeHint("NSNumber:int");
 
   llvm::StringRef prefix, suffix;
   if (Language *language = Language::FindPlugin(lang))
@@ -379,7 +379,7 @@ static void NSNumber_FormatInt(ValueObject &valobj, Stream &stream, int value,
 
 static void NSNumber_FormatLong(ValueObject &valobj, Stream &stream,
                                 int64_t value, lldb::LanguageType lang) {
-  static constexpr llvm::StringLiteral g_TypeHint("NSNumber:long");
+  static constexpr llvm::StringRef g_TypeHint("NSNumber:long");
 
   llvm::StringRef prefix, suffix;
   if (Language *language = Language::FindPlugin(lang))
@@ -393,7 +393,7 @@ static void NSNumber_FormatLong(ValueObject &valobj, Stream &stream,
 static void NSNumber_FormatInt128(ValueObject &valobj, Stream &stream,
                                   const llvm::APInt &value,
                                   lldb::LanguageType lang) {
-  static constexpr llvm::StringLiteral g_TypeHint("NSNumber:int128_t");
+  static constexpr llvm::StringRef g_TypeHint("NSNumber:int128_t");
 
   llvm::StringRef prefix, suffix;
   if (Language *language = Language::FindPlugin(lang))
@@ -409,7 +409,7 @@ static void NSNumber_FormatInt128(ValueObject &valobj, Stream &stream,
 
 static void NSNumber_FormatFloat(ValueObject &valobj, Stream &stream,
                                  float value, lldb::LanguageType lang) {
-  static constexpr llvm::StringLiteral g_TypeHint("NSNumber:float");
+  static constexpr llvm::StringRef g_TypeHint("NSNumber:float");
 
   llvm::StringRef prefix, suffix;
   if (Language *language = Language::FindPlugin(lang))
@@ -422,7 +422,7 @@ static void NSNumber_FormatFloat(ValueObject &valobj, Stream &stream,
 
 static void NSNumber_FormatDouble(ValueObject &valobj, Stream &stream,
                                   double value, lldb::LanguageType lang) {
-  static constexpr llvm::StringLiteral g_TypeHint("NSNumber:double");
+  static constexpr llvm::StringRef g_TypeHint("NSNumber:double");
 
   llvm::StringRef prefix, suffix;
   if (Language *language = Language::FindPlugin(lang))
@@ -825,8 +825,8 @@ bool lldb_private::formatters::NSURLSummaryProvider(
   if (!NSStringSummaryProvider(*text, summary, options) || summary.Empty())
     return false;
 
-  static constexpr llvm::StringLiteral quote_char("\"");
-  static constexpr llvm::StringLiteral g_TypeHint("NSString");
+  static constexpr llvm::StringRef quote_char("\"");
+  static constexpr llvm::StringRef g_TypeHint("NSString");
   llvm::StringRef prefix, suffix;
   if (Language *language = Language::FindPlugin(options.GetLanguage()))
     std::tie(prefix, suffix) = language->GetFormatterPrefixSuffix(g_TypeHint);
diff --git a/lldb/source/Plugins/Language/ObjC/NSArray.cpp b/lldb/source/Plugins/Language/ObjC/NSArray.cpp
index 072b8b5a6c860..98e145b04ded0 100644
--- a/lldb/source/Plugins/Language/ObjC/NSArray.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSArray.cpp
@@ -334,7 +334,7 @@ class NSArray1SyntheticFrontEnd : public SyntheticChildrenFrontEnd {
 
 bool lldb_private::formatters::NSArraySummaryProvider(
     ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
-  static constexpr llvm::StringLiteral g_TypeHint("NSArray");
+  static constexpr llvm::StringRef g_TypeHint("NSArray");
 
   ProcessSP process_sp = valobj.GetProcessSP();
   if (!process_sp)
diff --git a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
index cf8750fd4976e..d10f323af5cba 100644
--- a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
@@ -71,7 +71,8 @@ static CompilerType GetLLDBNSPairType(TargetSP target_sp) {
   if (!scratch_ts_sp)
     return compiler_type;
 
-  static constexpr llvm::StringLiteral g_lldb_autogen_nspair("__lldb_autogen_nspair");
+  static constexpr llvm::StringRef g_lldb_autogen_nspair(
+      "__lldb_autogen_nspair");
 
   compiler_type = scratch_ts_sp->GetTypeForIdentifier(g_lldb_autogen_nspair);
 
@@ -408,7 +409,7 @@ namespace Foundation1437 {
 template 
 bool lldb_private::formatters::NSDictionarySummaryProvider(
     ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
-  static constexpr llvm::StringLiteral g_TypeHint("NSDictionary");
+  static constexpr llvm::StringRef g_TypeHint("NSDictionary");
   ProcessSP process_sp = valobj.GetProcessSP();
   if (!process_sp)
     return false;
diff --git a/lldb/source/Plugins/Language/ObjC/NSSet.cpp b/lldb/source/Plugins/Language/ObjC/NSSet.cpp
index a184ec624b63e..dde47957f71e0 100644
--- a/lldb/source/Plugins/Language/ObjC/NSSet.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSSet.cpp
@@ -249,7 +249,7 @@ class NSSetCodeRunningSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
 template 
 bool lldb_private::formatters::NSSetSummaryProvider(
     ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
-  static constexpr llvm::StringLiteral g_TypeHint("NSSet");
+  static constexpr llvm::StringRef g_TypeHint("NSSet");
 
   ProcessSP process_sp = valobj.GetProcessSP();
   if (!process_sp)
diff --git a/lldb/source/Plugins/Language/ObjC/NSString.cpp b/lldb/source/Plugins/Language/ObjC/NSString.cpp
index a99d042572bfe..56723f102a2b6 100644
--- a/lldb/source/Plugins/Language/ObjC/NSString.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSString.cpp
@@ -33,7 +33,7 @@ NSString_Additionals::GetAdditionalSummaries() {
 bool lldb_private::formatters::NSStringSummaryProvider(
     ValueObject &valobj, Stream &stream,
     const TypeSummaryOptions &summary_options) {
-  static constexpr llvm::StringLiteral g_TypeHint("NSString");
+  static constexpr llvm::StringRef g_TypeHint("NSString");
 
   ProcessSP process_sp = valobj.GetProcessSP();
   if (!process_sp)
@@ -312,7 +312,7 @@ bool lldb_private::formatters::NSMutableAttributedStringSummaryProvider(
 bool lldb_private::formatters::NSTaggedString_SummaryProvider(
     ValueObject &valobj, ObjCLanguageRuntime::ClassDescriptorSP descriptor,
     Stream &stream, const TypeSummaryOptions &summary_options) {
-  static constexpr llvm::StringLiteral g_TypeHint("NSString");
+  static constexpr llvm::StringRef g_TypeHint("NSString");
 
   if (!descriptor)
     return false;
diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index 488c9bd1e54af..e3edc362e9fb0 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -137,8 +137,8 @@ using namespace lldb;
 using namespace lldb_private;
 using namespace llvm::MachO;
 
-static constexpr llvm::StringLiteral g_loader_path = "@loader_path";
-static constexpr llvm::StringLiteral g_executable_path = "@executable_path";
+static constexpr llvm::StringRef g_loader_path = "@loader_path";
+static constexpr llvm::StringRef g_executable_path = "@executable_path";
 
 LLDB_PLUGIN_DEFINE(ObjectFileMachO)
 
diff --git a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
index 5bc9cc133fbd3..b74915044b618 100644
--- a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
+++ b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
@@ -287,7 +287,7 @@ Status PlatformAndroid::DownloadModuleSlice(const FileSpec &src_file_spec,
 
   // For zip .so file, src_file_spec will be "zip_path!/so_path".
   // Extract "zip_path" from the source_file.
-  static constexpr llvm::StringLiteral k_zip_separator("!/");
+  static constexpr llvm::StringRef k_zip_separator("!/");
   size_t pos = source_file.find(k_zip_separator);
   if (pos != std::string::npos)
     source_file.resize(pos);
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
index 2a36f95c94d0c..23e4943da07b9 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -128,7 +128,7 @@ enum {
 class PlatformDarwinProperties : public Properties {
 public:
   static llvm::StringRef GetSettingName() {
-    static constexpr llvm::StringLiteral g_setting_name("darwin");
+    static constexpr llvm::StringRef g_setting_name("darwin");
     return g_setting_name;
   }
 
@@ -863,8 +863,8 @@ PlatformDarwin::ParseVersionBuildDir(llvm::StringRef dir) {
 
 llvm::Expected
 PlatformDarwin::FetchExtendedCrashInformation(Process &process) {
-  static constexpr llvm::StringLiteral crash_info_key("Crash-Info Annotations");
-  static constexpr llvm::StringLiteral asi_info_key(
+  static constexpr llvm::StringRef crash_info_key("Crash-Info Annotations");
+  static constexpr llvm::StringRef asi_info_key(
       "Application Specific Information");
 
   // We cache the information we find in the process extended info dict:
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
index 6f75e5ea70b6a..e997a3b09b69e 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
@@ -188,7 +188,7 @@ enum {
 class PlatformDarwinKernelProperties : public Properties {
 public:
   static llvm::StringRef GetSettingName() {
-    static constexpr llvm::StringLiteral g_setting_name("darwin-kernel");
+    static constexpr llvm::StringRef g_setting_name("darwin-kernel");
     return g_setting_name;
   }
 
@@ -411,8 +411,8 @@ void PlatformDarwinKernel::AddSDKSubdirsToSearchPaths(const std::string &dir) {
 FileSystem::EnumerateDirectoryResult
 PlatformDarwinKernel::FindKDKandSDKDirectoriesInDirectory(
     void *baton, llvm::sys::fs::file_type ft, llvm::StringRef path) {
-  static constexpr llvm::StringLiteral g_sdk_suffix = ".sdk";
-  static constexpr llvm::StringLiteral g_kdk_suffix = ".kdk";
+  static constexpr llvm::StringRef g_sdk_suffix = ".sdk";
+  static constexpr llvm::StringRef g_kdk_suffix = ".kdk";
 
   PlatformDarwinKernel *thisp = (PlatformDarwinKernel *)baton;
   const FileSpec file_spec(path);
@@ -473,8 +473,8 @@ FileSystem::EnumerateDirectoryResult
 PlatformDarwinKernel::GetKernelsAndKextsInDirectoryHelper(
     void *baton, llvm::sys::fs::file_type ft, llvm::StringRef path,
     bool recurse) {
-  static constexpr llvm::StringLiteral g_kext_suffix = ".kext";
-  static constexpr llvm::StringLiteral g_dsym_suffix = ".dSYM";
+  static constexpr llvm::StringRef g_kext_suffix = ".kext";
+  static constexpr llvm::StringRef g_dsym_suffix = ".dSYM";
 
   const FileSpec file_spec(path);
   llvm::StringRef file_spec_extension = file_spec.GetFileNameExtension();
@@ -657,7 +657,7 @@ bool PlatformDarwinKernel::KernelHasdSYMSibling(const FileSpec &kernel_binary) {
 //    /dir/dir/mach.development.t7004
 bool PlatformDarwinKernel::KerneldSYMHasNoSiblingBinary(
     const FileSpec &kernel_dsym) {
-  static constexpr llvm::StringLiteral g_dsym_suffix = ".dSYM";
+  static constexpr llvm::StringRef g_dsym_suffix = ".dSYM";
   std::string possible_path = kernel_dsym.GetPath();
   if (kernel_dsym.GetFileNameExtension() != g_dsym_suffix)
     return false;
@@ -687,7 +687,7 @@ bool PlatformDarwinKernel::KerneldSYMHasNoSiblingBinary(
 std::vector
 PlatformDarwinKernel::GetDWARFBinaryInDSYMBundle(const FileSpec &dsym_bundle) {
   std::vector results;
-  static constexpr llvm::StringLiteral g_dsym_suffix = ".dSYM";
+  static constexpr llvm::StringRef g_dsym_suffix = ".dSYM";
   if (dsym_bundle.GetFileNameExtension() != g_dsym_suffix) {
     return results;
   }
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 538c868014009..0dcef487dd063 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -2000,23 +2000,22 @@ ProcessGDBRemote::HandleThreadAsyncInterrupt(uint8_t signo,
 
 lldb::ThreadSP
 ProcessGDBRemote::SetThreadStopInfo(StructuredData::Dictionary *thread_dict) {
-  static constexpr llvm::StringLiteral g_key_tid("tid");
-  static constexpr llvm::StringLiteral g_key_name("name");
-  static constexpr llvm::StringLiteral g_key_reason("reason");
-  static constexpr llvm::StringLiteral g_key_metype("metype");
-  static constexpr llvm::StringLiteral g_key_medata("medata");
-  static constexpr llvm::StringLiteral g_key_qaddr("qaddr");
-  static constexpr llvm::StringLiteral g_key_dispatch_queue_t(
-      "dispatch_queue_t");
-  static constexpr llvm::StringLiteral g_key_associated_with_dispatch_queue(
+  static constexpr llvm::StringRef g_key_tid("tid");
+  static constexpr llvm::StringRef g_key_name("name");
+  static constexpr llvm::StringRef g_key_reason("reason");
+  static constexpr llvm::StringRef g_key_metype("metype");
+  static constexpr llvm::StringRef g_key_medata("medata");
+  static constexpr llvm::StringRef g_key_qaddr("qaddr");
+  static constexpr llvm::StringRef g_key_dispatch_queue_t("dispatch_queue_t");
+  static constexpr llvm::StringRef g_key_associated_with_dispatch_queue(
       "associated_with_dispatch_queue");
-  static constexpr llvm::StringLiteral g_key_queue_name("qname");
-  static constexpr llvm::StringLiteral g_key_queue_kind("qkind");
-  static constexpr llvm::StringLiteral g_key_queue_serial_number("qserialnum");
-  static constexpr llvm::StringLiteral g_key_registers("registers");
-  static constexpr llvm::StringLiteral g_key_memory("memory");
-  static constexpr llvm::StringLiteral g_key_description("description");
-  static constexpr llvm::StringLiteral g_key_signal("signal");
+  static constexpr llvm::StringRef g_key_queue_name("qname");
+  static constexpr llvm::StringRef g_key_queue_kind("qkind");
+  static constexpr llvm::StringRef g_key_queue_serial_number("qserialnum");
+  static constexpr llvm::StringRef g_key_registers("registers");
+  static constexpr llvm::StringRef g_key_memory("memory");
+  static constexpr llvm::StringRef g_key_description("description");
+  static constexpr llvm::StringRef g_key_signal("signal");
 
   // Stop with signal and thread info
   lldb::tid_t tid = LLDB_INVALID_THREAD_ID;
diff --git a/lldb/source/Plugins/REPL/Clang/ClangREPL.cpp b/lldb/source/Plugins/REPL/Clang/ClangREPL.cpp
index 41e3e2706c1a0..4012c165938d9 100644
--- a/lldb/source/Plugins/REPL/Clang/ClangREPL.cpp
+++ b/lldb/source/Plugins/REPL/Clang/ClangREPL.cpp
@@ -63,7 +63,7 @@ lldb::REPLSP ClangREPL::CreateInstance(Status &error,
 Status ClangREPL::DoInitialization() { return Status(); }
 
 llvm::StringRef ClangREPL::GetSourceFileBasename() {
-  static constexpr llvm::StringLiteral g_repl("repl.c");
+  static constexpr llvm::StringRef g_repl("repl.c");
   return g_repl;
 }
 
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
index 4b9f463ef5605..1e7c34f34381f 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
@@ -55,13 +55,13 @@ class ScriptedPythonInterface : virtual public ScriptedInterface {
     std::variant payload;
   };
 
-  llvm::Expected>
+  llvm::Expected>
   CheckAbstractMethodImplementation(
       const python::PythonDictionary &class_dict) const {
 
     using namespace python;
 
-    std::map checker;
+    std::map checker;
 #define SET_CASE_AND_CONTINUE(method_name, case)                               \
   {                                                                            \
     checker[method_name] = {case, {}};                                         \
@@ -70,7 +70,7 @@ class ScriptedPythonInterface : virtual public ScriptedInterface {
 
     for (const AbstractMethodRequirement &requirement :
          GetAbstractMethodRequirements()) {
-      llvm::StringLiteral method_name = requirement.name;
+      llvm::StringRef method_name = requirement.name;
       if (!class_dict.HasKey(method_name))
         SET_CASE_AND_CONTINUE(method_name,
                               AbstractMethodCheckerCases::eNotImplemented)
@@ -120,7 +120,7 @@ class ScriptedPythonInterface : virtual public ScriptedInterface {
     using Locker = ScriptInterpreterPythonImpl::Locker;
 
     Log *log = GetLog(LLDBLog::Script);
-    auto create_error = [](llvm::StringLiteral format, auto &&...ts) {
+    auto create_error = [](llvm::StringRef format, auto &&...ts) {
       return llvm::createStringError(
           llvm::formatv(format.data(), std::forward(ts)...)
               .str());
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
index 2dc784777151b..31f47d8d57d73 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
@@ -438,7 +438,7 @@ class IOHandlerPythonInterpreter : public IOHandler {
   ~IOHandlerPythonInterpreter() override = default;
 
   llvm::StringRef GetControlSequence(char ch) override {
-    static constexpr llvm::StringLiteral control_sequence("quit()\n");
+    static constexpr llvm::StringRef control_sequence("quit()\n");
     if (ch == 'd')
       return control_sequence;
     return {};
diff --git a/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp b/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
index 4ca8bd2f9085d..f429af57e90ad 100644
--- a/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
+++ b/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
@@ -120,7 +120,7 @@ enum {
 class StructuredDataDarwinLogProperties : public Properties {
 public:
   static llvm::StringRef GetSettingName() {
-    static constexpr llvm::StringLiteral g_setting_name("darwin-log");
+    static constexpr llvm::StringRef g_setting_name("darwin-log");
     return g_setting_name;
   }
 
@@ -165,12 +165,12 @@ const char *const s_filter_attributes[] = {
 };
 
 static llvm::StringRef GetDarwinLogTypeName() {
-  static constexpr llvm::StringLiteral s_key_name("DarwinLog");
+  static constexpr llvm::StringRef s_key_name("DarwinLog");
   return s_key_name;
 }
 
 static llvm::StringRef GetLogEventType() {
-  static constexpr llvm::StringLiteral s_event_type("log");
+  static constexpr llvm::StringRef s_event_type("log");
   return s_event_type;
 }
 
@@ -299,7 +299,7 @@ class RegexFilterRule : public FilterRule {
   }
 
   static llvm::StringRef StaticGetOperation() {
-    static constexpr llvm::StringLiteral s_operation("regex");
+    static constexpr llvm::StringRef s_operation("regex");
     return s_operation;
   }
 
@@ -344,7 +344,7 @@ class ExactMatchFilterRule : public FilterRule {
   }
 
   static llvm::StringRef StaticGetOperation() {
-    static constexpr llvm::StringLiteral s_operation("match");
+    static constexpr llvm::StringRef s_operation("match");
     return s_operation;
   }
 
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp
index 2fb0c224bf8e8..247af47df24e6 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp
@@ -16,7 +16,7 @@ namespace lldb_private::plugin {
 namespace dwarf {
 
 llvm::StringRef DW_TAG_value_to_name(dw_tag_t tag) {
-  static constexpr llvm::StringLiteral s_unknown_tag_name("");
+  static constexpr llvm::StringRef s_unknown_tag_name("");
   if (llvm::StringRef tag_name = llvm::dwarf::TagString(tag); !tag_name.empty())
     return tag_name;
 
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index 6f2c45e74132c..8aef2f302833b 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -555,7 +555,7 @@ void ManualDWARFIndex::Dump(Stream &s) {
   m_set.namespaces.Dump(&s);
 }
 
-constexpr llvm::StringLiteral kIdentifierManualDWARFIndex("DIDX");
+constexpr llvm::StringRef kIdentifierManualDWARFIndex("DIDX");
 // Define IDs for the different tables when encoding and decoding the
 // ManualDWARFIndex NameToDIE objects so we can avoid saving any empty maps.
 enum DataID {
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp b/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
index 44d90648700cf..cac97595294d1 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
@@ -92,7 +92,7 @@ void NameToDIE::Append(const NameToDIE &other) {
   }
 }
 
-constexpr llvm::StringLiteral kIdentifierNameToDIE("N2DI");
+constexpr llvm::StringRef kIdentifierNameToDIE("N2DI");
 
 bool NameToDIE::Decode(const DataExtractor &data, lldb::offset_t *offset_ptr,
                        const StringTableReader &strtab) {
diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/AbortWithPayloadFrameRecognizer.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/AbortWithPayloadFrameRecognizer.cpp
index 7cf875075cd7f..cf87e3eb42211 100644
--- a/lldb/source/Plugins/SystemRuntime/MacOSX/AbortWithPayloadFrameRecognizer.cpp
+++ b/lldb/source/Plugins/SystemRuntime/MacOSX/AbortWithPayloadFrameRecognizer.cpp
@@ -47,13 +47,13 @@ AbortWithPayloadFrameRecognizer::RecognizeFrame(lldb::StackFrameSP frame_sp) {
   // 1) to add the data passed to abort_with_payload to the
   //    ExtraCrashInformation dictionary.
   // 2) To make up faux arguments for this frame.
-  static constexpr llvm::StringLiteral namespace_key("namespace");
-  static constexpr llvm::StringLiteral code_key("code");
-  static constexpr llvm::StringLiteral payload_addr_key("payload_addr");
-  static constexpr llvm::StringLiteral payload_size_key("payload_size");
-  static constexpr llvm::StringLiteral reason_key("reason");
-  static constexpr llvm::StringLiteral flags_key("flags");
-  static constexpr llvm::StringLiteral info_key("abort_with_payload");
+  static constexpr llvm::StringRef namespace_key("namespace");
+  static constexpr llvm::StringRef code_key("code");
+  static constexpr llvm::StringRef payload_addr_key("payload_addr");
+  static constexpr llvm::StringRef payload_size_key("payload_size");
+  static constexpr llvm::StringRef reason_key("reason");
+  static constexpr llvm::StringRef flags_key("flags");
+  static constexpr llvm::StringRef info_key("abort_with_payload");
 
   Log *log = GetLog(LLDBLog::SystemRuntime);
   
diff --git a/lldb/source/Symbol/Symtab.cpp b/lldb/source/Symbol/Symtab.cpp
index 3c5075d9bb18b..e8e8243ac2a72 100644
--- a/lldb/source/Symbol/Symtab.cpp
+++ b/lldb/source/Symbol/Symtab.cpp
@@ -1196,7 +1196,7 @@ void Symtab::SaveToCache() {
       SetWasSavedToCache();
 }
 
-constexpr llvm::StringLiteral kIdentifierCStrMap("CMAP");
+constexpr llvm::StringRef kIdentifierCStrMap("CMAP");
 
 static void EncodeCStrMap(DataEncoder &encoder, ConstStringTable &strtab,
                           const UniqueCStringMap &cstr_map) {
@@ -1240,7 +1240,7 @@ bool DecodeCStrMap(const DataExtractor &data, lldb::offset_t *offset_ptr,
   return true;
 }
 
-constexpr llvm::StringLiteral kIdentifierSymbolTable("SYMB");
+constexpr llvm::StringRef kIdentifierSymbolTable("SYMB");
 constexpr uint32_t CURRENT_CACHE_VERSION = 1;
 
 /// The encoding format for the symbol table is as follows:
diff --git a/lldb/source/Target/Language.cpp b/lldb/source/Target/Language.cpp
index a75894ffa4b3b..81f8df494e927 100644
--- a/lldb/source/Target/Language.cpp
+++ b/lldb/source/Target/Language.cpp
@@ -43,7 +43,7 @@ LanguageProperties &Language::GetGlobalLanguageProperties() {
 }
 
 llvm::StringRef LanguageProperties::GetSettingName() {
-  static constexpr llvm::StringLiteral g_setting_name("language");
+  static constexpr llvm::StringRef g_setting_name("language");
   return g_setting_name;
 }
 
diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index 3e7546048e586..01d02bf9af4b8 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -73,7 +73,7 @@ enum {
 } // namespace
 
 llvm::StringRef PlatformProperties::GetSettingName() {
-  static constexpr llvm::StringLiteral g_setting_name("platform");
+  static constexpr llvm::StringRef g_setting_name("platform");
   return g_setting_name;
 }
 
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 68485a40a3fcc..47c780af1259d 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -411,7 +411,7 @@ ProcessSP Process::FindPlugin(lldb::TargetSP target_sp,
 }
 
 llvm::StringRef Process::GetStaticBroadcasterClass() {
-  static constexpr llvm::StringLiteral class_name("lldb.process");
+  static constexpr llvm::StringRef class_name("lldb.process");
   return class_name;
 }
 
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 46216ba2d566d..a5da46a6652c2 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -164,7 +164,7 @@ const Target::Arch &Target::Arch::operator=(const ArchSpec &spec) {
 }
 
 llvm::StringRef Target::GetStaticBroadcasterClass() {
-  static constexpr llvm::StringLiteral class_name("lldb.target");
+  static constexpr llvm::StringRef class_name("lldb.target");
   return class_name;
 }
 
diff --git a/lldb/source/Target/TargetList.cpp b/lldb/source/Target/TargetList.cpp
index 7f29bd7a07ab8..428d403677a03 100644
--- a/lldb/source/Target/TargetList.cpp
+++ b/lldb/source/Target/TargetList.cpp
@@ -30,7 +30,7 @@ using namespace lldb;
 using namespace lldb_private;
 
 llvm::StringRef TargetList::GetStaticBroadcasterClass() {
-  static constexpr llvm::StringLiteral class_name("lldb.targetList");
+  static constexpr llvm::StringRef class_name("lldb.targetList");
   return class_name;
 }
 
diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp
index a6130f6b925bb..c2c62a9c74b4f 100644
--- a/lldb/source/Target/Thread.cpp
+++ b/lldb/source/Target/Thread.cpp
@@ -212,7 +212,7 @@ Thread::ThreadEventData::GetStackFrameFromEvent(const Event *event_ptr) {
 // Thread class
 
 llvm::StringRef Thread::GetStaticBroadcasterClass() {
-  static constexpr llvm::StringLiteral class_name("lldb.thread");
+  static constexpr llvm::StringRef class_name("lldb.thread");
   return class_name;
 }
 
diff --git a/lldb/source/Target/UnixSignals.cpp b/lldb/source/Target/UnixSignals.cpp
index e3c7a83ece073..5a34ee00fde5a 100644
--- a/lldb/source/Target/UnixSignals.cpp
+++ b/lldb/source/Target/UnixSignals.cpp
@@ -111,7 +111,7 @@ void UnixSignals::AddSignal(int signo, llvm::StringRef name,
 }
 
 void UnixSignals::AddSignalCode(int signo, int code,
-                                const llvm::StringLiteral description,
+                                const llvm::StringRef description,
                                 SignalCodePrintOption print_option) {
   collection::iterator signal = m_signals.find(signo);
   assert(signal != m_signals.end() &&
diff --git a/lldb/source/Utility/Broadcaster.cpp b/lldb/source/Utility/Broadcaster.cpp
index c6b2606afe0c8..f7b202bca9d41 100644
--- a/lldb/source/Utility/Broadcaster.cpp
+++ b/lldb/source/Utility/Broadcaster.cpp
@@ -374,7 +374,7 @@ void Broadcaster::BroadcasterImpl::RestoreBroadcaster() {
 }
 
 llvm::StringRef Broadcaster::GetBroadcasterClass() const {
-  static constexpr llvm::StringLiteral class_name("lldb.anonymous");
+  static constexpr llvm::StringRef class_name("lldb.anonymous");
   return class_name;
 }
 
diff --git a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationTest.cpp b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationTest.cpp
index 425f6cfcd5bc9..4a0880e608911 100644
--- a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationTest.cpp
+++ b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationTest.cpp
@@ -48,8 +48,8 @@ class GDBRemoteCommunicationTest : public GDBRemoteTest {
 // checksum calculation works.
 TEST_F(GDBRemoteCommunicationTest, ReadPacket) {
   struct TestCase {
-    llvm::StringLiteral Packet;
-    llvm::StringLiteral Payload;
+    llvm::StringRef Packet;
+    llvm::StringRef Payload;
   };
   static constexpr TestCase Tests[] = {
       {{"$#00"}, {""}},
diff --git a/lldb/unittests/Target/LocateModuleCallbackTest.cpp b/lldb/unittests/Target/LocateModuleCallbackTest.cpp
index 6ffa41b16b4ff..1e5fb6553f4f3 100644
--- a/lldb/unittests/Target/LocateModuleCallbackTest.cpp
+++ b/lldb/unittests/Target/LocateModuleCallbackTest.cpp
@@ -28,17 +28,17 @@ using namespace testing;
 
 namespace {
 
-constexpr llvm::StringLiteral k_process_plugin("mock-process-plugin");
-constexpr llvm::StringLiteral k_platform_dir("remote-android");
-constexpr llvm::StringLiteral k_cache_dir(".cache");
-constexpr llvm::StringLiteral k_module_file("AndroidModule.so");
-constexpr llvm::StringLiteral k_symbol_file("AndroidModule.unstripped.so");
-constexpr llvm::StringLiteral k_breakpad_symbol_file("AndroidModule.so.sym");
-constexpr llvm::StringLiteral k_arch("aarch64-none-linux");
-constexpr llvm::StringLiteral
+constexpr llvm::StringRef k_process_plugin("mock-process-plugin");
+constexpr llvm::StringRef k_platform_dir("remote-android");
+constexpr llvm::StringRef k_cache_dir(".cache");
+constexpr llvm::StringRef k_module_file("AndroidModule.so");
+constexpr llvm::StringRef k_symbol_file("AndroidModule.unstripped.so");
+constexpr llvm::StringRef k_breakpad_symbol_file("AndroidModule.so.sym");
+constexpr llvm::StringRef k_arch("aarch64-none-linux");
+constexpr llvm::StringRef
     k_module_uuid("80008338-82A0-51E5-5922-C905D23890DA-BDDEFECC");
-constexpr llvm::StringLiteral k_function_symbol("boom");
-constexpr llvm::StringLiteral k_hidden_function_symbol("boom_hidden");
+constexpr llvm::StringRef k_function_symbol("boom");
+constexpr llvm::StringRef k_hidden_function_symbol("boom_hidden");
 const size_t k_module_size = 3784;
 
 ModuleSpec GetTestModuleSpec();
diff --git a/lldb/unittests/Utility/ListenerTest.cpp b/lldb/unittests/Utility/ListenerTest.cpp
index f7aa0f59d1848..6bf45bedfe6a1 100644
--- a/lldb/unittests/Utility/ListenerTest.cpp
+++ b/lldb/unittests/Utility/ListenerTest.cpp
@@ -115,7 +115,7 @@ TEST(ListenerTest, GetEventWait) {
 
 TEST(ListenerTest, StartStopListeningForEventSpec) {
   constexpr uint32_t event_mask = 1;
-  static constexpr llvm::StringLiteral broadcaster_class = "broadcaster-class";
+  static constexpr llvm::StringRef broadcaster_class = "broadcaster-class";
 
   class TestBroadcaster : public Broadcaster {
     using Broadcaster::Broadcaster;
diff --git a/llvm/include/llvm/ADT/StringExtras.h b/llvm/include/llvm/ADT/StringExtras.h
index 1317d521d4c19..94eaf3ab4e794 100644
--- a/llvm/include/llvm/ADT/StringExtras.h
+++ b/llvm/include/llvm/ADT/StringExtras.h
@@ -146,7 +146,7 @@ inline bool isPrint(char C) {
 /// punctuation characters can be found in the documentation of std::ispunct:
 /// https://en.cppreference.com/w/cpp/string/byte/ispunct.
 inline bool isPunct(char C) {
-  static constexpr StringLiteral Punctuations =
+  static constexpr StringRef Punctuations =
       R"(!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~)";
   return Punctuations.contains(C);
 }
diff --git a/llvm/include/llvm/ADT/StringRef.h b/llvm/include/llvm/ADT/StringRef.h
index 5b525c8e56ecc..f26de597128ce 100644
--- a/llvm/include/llvm/ADT/StringRef.h
+++ b/llvm/include/llvm/ADT/StringRef.h
@@ -843,38 +843,6 @@ namespace llvm {
     /// @}
   };
 
-  /// A wrapper around a string literal that serves as a proxy for constructing
-  /// global tables of StringRefs with the length computed at compile time.
-  /// In order to avoid the invocation of a global constructor, StringLiteral
-  /// should *only* be used in a constexpr context, as such:
-  ///
-  /// constexpr StringLiteral S("test");
-  ///
-  class StringLiteral : public StringRef {
-  private:
-    constexpr StringLiteral(const char *Str, size_t N) : StringRef(Str, N) {
-    }
-
-  public:
-    template 
-    constexpr StringLiteral(const char (&Str)[N])
-#if defined(__clang__) && __has_attribute(enable_if)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wgcc-compat"
-        __attribute((enable_if(__builtin_strlen(Str) == N - 1,
-                               "invalid string literal")))
-#pragma clang diagnostic pop
-#endif
-        : StringRef(Str, N - 1) {
-    }
-
-    // Explicit construction for strings like "foo\0bar".
-    template 
-    static constexpr StringLiteral withInnerNUL(const char (&Str)[N]) {
-      return StringLiteral(Str, N - 1);
-    }
-  };
-
   /// @name StringRef Comparison Operators
   /// @{
 
diff --git a/llvm/include/llvm/ADT/StringSwitch.h b/llvm/include/llvm/ADT/StringSwitch.h
index 7093da07663a0..a3d02f2caf635 100644
--- a/llvm/include/llvm/ADT/StringSwitch.h
+++ b/llvm/include/llvm/ADT/StringSwitch.h
@@ -66,116 +66,110 @@ class StringSwitch {
   ~StringSwitch() = default;
 
   // Case-sensitive case matchers
-  StringSwitch &Case(StringLiteral S, T Value) {
+  StringSwitch &Case(StringRef S, T Value) {
     if (!Result && Str == S) {
       Result = std::move(Value);
     }
     return *this;
   }
 
-  StringSwitch& EndsWith(StringLiteral S, T Value) {
+  StringSwitch &EndsWith(StringRef S, T Value) {
     if (!Result && Str.ends_with(S)) {
       Result = std::move(Value);
     }
     return *this;
   }
 
-  StringSwitch& StartsWith(StringLiteral S, T Value) {
+  StringSwitch &StartsWith(StringRef S, T Value) {
     if (!Result && Str.starts_with(S)) {
       Result = std::move(Value);
     }
     return *this;
   }
 
-  StringSwitch &Cases(StringLiteral S0, StringLiteral S1, T Value) {
+  StringSwitch &Cases(StringRef S0, StringRef S1, T Value) {
     return Case(S0, Value).Case(S1, Value);
   }
 
-  StringSwitch &Cases(StringLiteral S0, StringLiteral S1, StringLiteral S2,
-                      T Value) {
+  StringSwitch &Cases(StringRef S0, StringRef S1, StringRef S2, T Value) {
     return Case(S0, Value).Cases(S1, S2, Value);
   }
 
-  StringSwitch &Cases(StringLiteral S0, StringLiteral S1, StringLiteral S2,
-                      StringLiteral S3, T Value) {
+  StringSwitch &Cases(StringRef S0, StringRef S1, StringRef S2, StringRef S3,
+                      T Value) {
     return Case(S0, Value).Cases(S1, S2, S3, Value);
   }
 
-  StringSwitch &Cases(StringLiteral S0, StringLiteral S1, StringLiteral S2,
-                      StringLiteral S3, StringLiteral S4, T Value) {
+  StringSwitch &Cases(StringRef S0, StringRef S1, StringRef S2, StringRef S3,
+                      StringRef S4, T Value) {
     return Case(S0, Value).Cases(S1, S2, S3, S4, Value);
   }
 
-  StringSwitch &Cases(StringLiteral S0, StringLiteral S1, StringLiteral S2,
-                      StringLiteral S3, StringLiteral S4, StringLiteral S5,
-                      T Value) {
+  StringSwitch &Cases(StringRef S0, StringRef S1, StringRef S2, StringRef S3,
+                      StringRef S4, StringRef S5, T Value) {
     return Case(S0, Value).Cases(S1, S2, S3, S4, S5, Value);
   }
 
-  StringSwitch &Cases(StringLiteral S0, StringLiteral S1, StringLiteral S2,
-                      StringLiteral S3, StringLiteral S4, StringLiteral S5,
-                      StringLiteral S6, T Value) {
+  StringSwitch &Cases(StringRef S0, StringRef S1, StringRef S2, StringRef S3,
+                      StringRef S4, StringRef S5, StringRef S6, T Value) {
     return Case(S0, Value).Cases(S1, S2, S3, S4, S5, S6, Value);
   }
 
-  StringSwitch &Cases(StringLiteral S0, StringLiteral S1, StringLiteral S2,
-                      StringLiteral S3, StringLiteral S4, StringLiteral S5,
-                      StringLiteral S6, StringLiteral S7, T Value) {
+  StringSwitch &Cases(StringRef S0, StringRef S1, StringRef S2, StringRef S3,
+                      StringRef S4, StringRef S5, StringRef S6, StringRef S7,
+                      T Value) {
     return Case(S0, Value).Cases(S1, S2, S3, S4, S5, S6, S7, Value);
   }
 
-  StringSwitch &Cases(StringLiteral S0, StringLiteral S1, StringLiteral S2,
-                      StringLiteral S3, StringLiteral S4, StringLiteral S5,
-                      StringLiteral S6, StringLiteral S7, StringLiteral S8,
-                      T Value) {
+  StringSwitch &Cases(StringRef S0, StringRef S1, StringRef S2, StringRef S3,
+                      StringRef S4, StringRef S5, StringRef S6, StringRef S7,
+                      StringRef S8, T Value) {
     return Case(S0, Value).Cases(S1, S2, S3, S4, S5, S6, S7, S8, Value);
   }
 
-  StringSwitch &Cases(StringLiteral S0, StringLiteral S1, StringLiteral S2,
-                      StringLiteral S3, StringLiteral S4, StringLiteral S5,
-                      StringLiteral S6, StringLiteral S7, StringLiteral S8,
-                      StringLiteral S9, T Value) {
+  StringSwitch &Cases(StringRef S0, StringRef S1, StringRef S2, StringRef S3,
+                      StringRef S4, StringRef S5, StringRef S6, StringRef S7,
+                      StringRef S8, StringRef S9, T Value) {
     return Case(S0, Value).Cases(S1, S2, S3, S4, S5, S6, S7, S8, S9, Value);
   }
 
   // Case-insensitive case matchers.
-  StringSwitch &CaseLower(StringLiteral S, T Value) {
+  StringSwitch &CaseLower(StringRef S, T Value) {
     if (!Result && Str.equals_insensitive(S))
       Result = std::move(Value);
 
     return *this;
   }
 
-  StringSwitch &EndsWithLower(StringLiteral S, T Value) {
+  StringSwitch &EndsWithLower(StringRef S, T Value) {
     if (!Result && Str.ends_with_insensitive(S))
       Result = Value;
 
     return *this;
   }
 
-  StringSwitch &StartsWithLower(StringLiteral S, T Value) {
+  StringSwitch &StartsWithLower(StringRef S, T Value) {
     if (!Result && Str.starts_with_insensitive(S))
       Result = std::move(Value);
 
     return *this;
   }
 
-  StringSwitch &CasesLower(StringLiteral S0, StringLiteral S1, T Value) {
+  StringSwitch &CasesLower(StringRef S0, StringRef S1, T Value) {
     return CaseLower(S0, Value).CaseLower(S1, Value);
   }
 
-  StringSwitch &CasesLower(StringLiteral S0, StringLiteral S1, StringLiteral S2,
-                           T Value) {
+  StringSwitch &CasesLower(StringRef S0, StringRef S1, StringRef S2, T Value) {
     return CaseLower(S0, Value).CasesLower(S1, S2, Value);
   }
 
-  StringSwitch &CasesLower(StringLiteral S0, StringLiteral S1, StringLiteral S2,
-                           StringLiteral S3, T Value) {
+  StringSwitch &CasesLower(StringRef S0, StringRef S1, StringRef S2,
+                           StringRef S3, T Value) {
     return CaseLower(S0, Value).CasesLower(S1, S2, S3, Value);
   }
 
-  StringSwitch &CasesLower(StringLiteral S0, StringLiteral S1, StringLiteral S2,
-                           StringLiteral S3, StringLiteral S4, T Value) {
+  StringSwitch &CasesLower(StringRef S0, StringRef S1, StringRef S2,
+                           StringRef S3, StringRef S4, T Value) {
     return CaseLower(S0, Value).CasesLower(S1, S2, S3, S4, Value);
   }
 
diff --git a/llvm/include/llvm/ADT/StringTable.h b/llvm/include/llvm/ADT/StringTable.h
index 4049f892fa66e..387e2488012cd 100644
--- a/llvm/include/llvm/ADT/StringTable.h
+++ b/llvm/include/llvm/ADT/StringTable.h
@@ -56,7 +56,7 @@ class StringTable {
 
   // We directly handle string literals with a templated converting constructor
   // because we *don't* want to do `strlen` on them -- we fully expect null
-  // bytes in this input. This is somewhat the opposite of how `StringLiteral`
+  // bytes in this input. This is somewhat the opposite of how `StringRef`
   // works.
   template 
   constexpr StringTable(const char (&RawTable)[N]) : Table(RawTable, N) {
diff --git a/llvm/include/llvm/ADT/Twine.h b/llvm/include/llvm/ADT/Twine.h
index 1f1fd1967efbc..ee872ffa04d40 100644
--- a/llvm/include/llvm/ADT/Twine.h
+++ b/llvm/include/llvm/ADT/Twine.h
@@ -307,14 +307,6 @@ namespace llvm {
       assert(isValid() && "Invalid twine!");
     }
 
-    /// Construct from a StringLiteral.
-    /*implicit*/ Twine(const StringLiteral &Str)
-        : LHSKind(StringLiteralKind) {
-      LHS.ptrAndLength.ptr = Str.data();
-      LHS.ptrAndLength.length = Str.size();
-      assert(isValid() && "Invalid twine!");
-    }
-
     /// Construct from a SmallString.
     /*implicit*/ Twine(const SmallVectorImpl &Str)
         : LHSKind(PtrAndLengthKind) {
diff --git a/llvm/include/llvm/Analysis/TargetLibraryInfo.h b/llvm/include/llvm/Analysis/TargetLibraryInfo.h
index f51d2bb9d50a2..c62c6a4aae134 100644
--- a/llvm/include/llvm/Analysis/TargetLibraryInfo.h
+++ b/llvm/include/llvm/Analysis/TargetLibraryInfo.h
@@ -84,7 +84,7 @@ class TargetLibraryInfoImpl {
 
   unsigned char AvailableArray[(NumLibFuncs+3)/4];
   DenseMap CustomNames;
-  static StringLiteral const StandardNames[NumLibFuncs];
+  static StringRef const StandardNames[NumLibFuncs];
   bool ShouldExtI32Param, ShouldExtI32Return, ShouldSignExtI32Param, ShouldSignExtI32Return;
   unsigned SizeOfInt;
 
diff --git a/llvm/include/llvm/CodeGen/TargetRegisterInfo.h b/llvm/include/llvm/CodeGen/TargetRegisterInfo.h
index f4bf74c8caa5b..eedc53bbf0036 100644
--- a/llvm/include/llvm/CodeGen/TargetRegisterInfo.h
+++ b/llvm/include/llvm/CodeGen/TargetRegisterInfo.h
@@ -1230,7 +1230,7 @@ class TargetRegisterInfo : public MCRegisterInfo {
     return {};
   }
 
-  virtual SmallVector
+  virtual SmallVector
   getVRegFlagsOfReg(Register Reg, const MachineFunction &MF) const {
     return {};
   }
diff --git a/llvm/include/llvm/DWARFLinker/DWARFLinkerBase.h b/llvm/include/llvm/DWARFLinker/DWARFLinkerBase.h
index 70b25cf02df7f..eb8e2b94ad108 100644
--- a/llvm/include/llvm/DWARFLinker/DWARFLinkerBase.h
+++ b/llvm/include/llvm/DWARFLinker/DWARFLinkerBase.h
@@ -53,7 +53,7 @@ enum class DebugSectionKind : uint8_t {
 static constexpr size_t SectionKindsNum =
     static_cast(DebugSectionKind::NumberOfEnumEntries);
 
-static constexpr StringLiteral SectionNames[SectionKindsNum] = {
+static constexpr StringRef SectionNames[SectionKindsNum] = {
     "debug_info",     "debug_line",     "debug_frame",       "debug_ranges",
     "debug_rnglists", "debug_loc",      "debug_loclists",    "debug_aranges",
     "debug_abbrev",   "debug_macinfo",  "debug_macro",       "debug_addr",
@@ -62,8 +62,7 @@ static constexpr StringLiteral SectionNames[SectionKindsNum] = {
     "apple_objc",     "apple_types"};
 
 /// Return the name of the section.
-static constexpr const StringLiteral &
-getSectionName(DebugSectionKind SectionKind) {
+static constexpr const StringRef &getSectionName(DebugSectionKind SectionKind) {
   return SectionNames[static_cast(SectionKind)];
 }
 
diff --git a/llvm/include/llvm/DWARFLinker/Parallel/DWARFLinker.h b/llvm/include/llvm/DWARFLinker/Parallel/DWARFLinker.h
index 8acc046d07249..16b13e54f585d 100644
--- a/llvm/include/llvm/DWARFLinker/Parallel/DWARFLinker.h
+++ b/llvm/include/llvm/DWARFLinker/Parallel/DWARFLinker.h
@@ -100,7 +100,7 @@ struct SectionDescriptorBase {
   /// Returns section kind.
   DebugSectionKind getKind() { return SectionKind; }
   /// Returns section name.
-  const StringLiteral &getName() const { return getSectionName(SectionKind); }
+  const StringRef &getName() const { return getSectionName(SectionKind); }
   /// Returns endianess used by section.
   llvm::endianness getEndianess() const { return Endianess; }
   /// Returns FormParams used by section.
diff --git a/llvm/include/llvm/Demangle/ItaniumDemangle.h b/llvm/include/llvm/Demangle/ItaniumDemangle.h
index 7fba3fdc1abc9..c6a91f99ede77 100644
--- a/llvm/include/llvm/Demangle/ItaniumDemangle.h
+++ b/llvm/include/llvm/Demangle/ItaniumDemangle.h
@@ -2385,11 +2385,11 @@ class BoolExpr : public Node {
   }
 };
 
-class StringLiteral : public Node {
+class StringRef : public Node {
   const Node *Type;
 
 public:
-  StringLiteral(const Node *Type_) : Node(KStringLiteral), Type(Type_) {}
+  StringRef(const Node *Type_) : Node(KStringRef), Type(Type_) {}
 
   template void match(Fn F) const { F(Type); }
 
@@ -4853,7 +4853,7 @@ Node *AbstractManglingParser::parseExprPrimary() {
       return nullptr;
     // FIXME: We need to include the string contents in the mangling.
     if (consumeIf('E'))
-      return make(T);
+      return make(T);
     return nullptr;
   }
   case 'D':
diff --git a/llvm/include/llvm/Demangle/ItaniumNodes.def b/llvm/include/llvm/Demangle/ItaniumNodes.def
index 330552663ee65..185e30cdbbe50 100644
--- a/llvm/include/llvm/Demangle/ItaniumNodes.def
+++ b/llvm/include/llvm/Demangle/ItaniumNodes.def
@@ -86,7 +86,7 @@ NODE(InitListExpr)
 NODE(FoldExpr)
 NODE(ThrowExpr)
 NODE(BoolExpr)
-NODE(StringLiteral)
+NODE(StringRef)
 NODE(LambdaExpr)
 NODE(EnumLiteral)
 NODE(IntegerLiteral)
diff --git a/llvm/include/llvm/Frontend/OpenMP/OMPAssume.h b/llvm/include/llvm/Frontend/OpenMP/OMPAssume.h
index c7462ffe6bc0f..2c61e9cc45821 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMPAssume.h
+++ b/llvm/include/llvm/Frontend/OpenMP/OMPAssume.h
@@ -24,7 +24,7 @@ namespace omp {
 /// Helper to describe assume clauses.
 struct AssumptionClauseMappingInfo {
   /// The identifier describing the (beginning of the) clause.
-  llvm::StringLiteral Identifier;
+  llvm::StringRef Identifier;
   /// Flag to determine if the identifier is a full name or the start of a name.
   bool StartsWith;
   /// Flag to determine if a directive lists follows.
diff --git a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
index 928a03148c416..a642479318580 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -1367,13 +1367,13 @@ OMP_ASSUME_CLAUSE(Identifier, StartsWith, HasDirectiveList, HasExpression)
 #define __OMP_ASSUME_CLAUSE(...)
 #endif
 
-__OMP_ASSUME_CLAUSE(llvm::StringLiteral("ext_"), true, false, false)
-__OMP_ASSUME_CLAUSE(llvm::StringLiteral("absent"), false, true, false)
-__OMP_ASSUME_CLAUSE(llvm::StringLiteral("contains"), false, true, false)
-__OMP_ASSUME_CLAUSE(llvm::StringLiteral("holds"), false, false, true)
-__OMP_ASSUME_CLAUSE(llvm::StringLiteral("no_openmp"), false, false, false)
-__OMP_ASSUME_CLAUSE(llvm::StringLiteral("no_openmp_routines"), false, false, false)
-__OMP_ASSUME_CLAUSE(llvm::StringLiteral("no_parallelism"), false, false, false)
+__OMP_ASSUME_CLAUSE(llvm::StringRef("ext_"), true, false, false)
+__OMP_ASSUME_CLAUSE(llvm::StringRef("absent"), false, true, false)
+__OMP_ASSUME_CLAUSE(llvm::StringRef("contains"), false, true, false)
+__OMP_ASSUME_CLAUSE(llvm::StringRef("holds"), false, false, true)
+__OMP_ASSUME_CLAUSE(llvm::StringRef("no_openmp"), false, false, false)
+__OMP_ASSUME_CLAUSE(llvm::StringRef("no_openmp_routines"), false, false, false)
+__OMP_ASSUME_CLAUSE(llvm::StringRef("no_parallelism"), false, false, false)
 
 #undef __OMP_ASSUME_CLAUSE
 #undef OMP_ASSUME_CLAUSE
diff --git a/llvm/include/llvm/LTO/LTO.h b/llvm/include/llvm/LTO/LTO.h
index 242a05f7d32c0..f8b5571256a8e 100644
--- a/llvm/include/llvm/LTO/LTO.h
+++ b/llvm/include/llvm/LTO/LTO.h
@@ -80,7 +80,7 @@ std::string recomputeLTOCacheKey(const std::string &Key, StringRef ExtraID);
 
 namespace lto {
 
-StringLiteral getThinLTODefaultCPU(const Triple &TheTriple);
+StringRef getThinLTODefaultCPU(const Triple &TheTriple);
 
 /// Given the original \p Path to an output file, replace any path
 /// prefix matching \p OldPrefix with \p NewPrefix. Also, create the
diff --git a/llvm/include/llvm/Remarks/BitstreamRemarkContainer.h b/llvm/include/llvm/Remarks/BitstreamRemarkContainer.h
index cc4df5845b67c..3d8079d27fb97 100644
--- a/llvm/include/llvm/Remarks/BitstreamRemarkContainer.h
+++ b/llvm/include/llvm/Remarks/BitstreamRemarkContainer.h
@@ -25,7 +25,7 @@ namespace remarks {
 /// Note: this is different from the version of the remark entry.
 constexpr uint64_t CurrentContainerVersion = 0;
 /// The magic number used for identifying remark blocks.
-constexpr StringLiteral ContainerMagic("RMRK");
+constexpr StringRef ContainerMagic("RMRK");
 
 /// Type of the remark container.
 /// The remark container has two modes:
diff --git a/llvm/include/llvm/Remarks/RemarkFormat.h b/llvm/include/llvm/Remarks/RemarkFormat.h
index 9c589eed44f39..40c1b19ba7901 100644
--- a/llvm/include/llvm/Remarks/RemarkFormat.h
+++ b/llvm/include/llvm/Remarks/RemarkFormat.h
@@ -19,7 +19,7 @@
 namespace llvm {
 namespace remarks {
 
-constexpr StringLiteral Magic("REMARKS");
+constexpr StringRef Magic("REMARKS");
 
 /// The format used for serializing/deserializing remarks.
 enum class Format { Unknown, YAML, YAMLStrTab, Bitstream };
diff --git a/llvm/include/llvm/Support/JSON.h b/llvm/include/llvm/Support/JSON.h
index 14a5c7142ed8c..38a75262d7dc5 100644
--- a/llvm/include/llvm/Support/JSON.h
+++ b/llvm/include/llvm/Support/JSON.h
@@ -659,7 +659,7 @@ class Path {
   /// Records that the value at the current path is invalid.
   /// Message is e.g. "expected number" and becomes part of the final error.
   /// This overwrites any previously written error message in the root.
-  void report(llvm::StringLiteral Message);
+  void report(llvm::StringRef Message);
 
   /// The root may be treated as a Path.
   Path(Root &R) : Parent(nullptr), Seg(&R) {}
@@ -701,10 +701,10 @@ class Path {
 /// It also stores the latest reported error and the path where it occurred.
 class Path::Root {
   llvm::StringRef Name;
-  llvm::StringLiteral ErrorMessage;
+  llvm::StringRef ErrorMessage;
   std::vector ErrorPath; // Only valid in error state. Reversed.
 
-  friend void Path::report(llvm::StringLiteral Message);
+  friend void Path::report(llvm::StringRef Message);
 
 public:
   Root(llvm::StringRef Name = "") : Name(Name), ErrorMessage("") {}
@@ -853,7 +853,7 @@ class ObjectMapper {
 
   /// Maps a property to a field.
   /// If the property is missing or invalid, reports an error.
-  template  bool map(StringLiteral Prop, T &Out) {
+  template  bool map(StringRef Prop, T &Out) {
     assert(*this && "Must check this is an object before calling map()");
     if (const Value *E = O->get(Prop))
       return fromJSON(*E, Out, P.field(Prop));
@@ -864,7 +864,7 @@ class ObjectMapper {
   /// Maps a property to a field, if it exists.
   /// If the property exists and is invalid, reports an error.
   /// (Optional requires special handling, because missing keys are OK).
-  template  bool map(StringLiteral Prop, std::optional &Out) {
+  template  bool map(StringRef Prop, std::optional &Out) {
     assert(*this && "Must check this is an object before calling map()");
     if (const Value *E = O->get(Prop))
       return fromJSON(*E, Out, P.field(Prop));
@@ -875,7 +875,7 @@ class ObjectMapper {
   /// Maps a property to a field, if it exists.
   /// If the property exists and is invalid, reports an error.
   /// If the property does not exist, Out is unchanged.
-  template  bool mapOptional(StringLiteral Prop, T &Out) {
+  template  bool mapOptional(StringRef Prop, T &Out) {
     assert(*this && "Must check this is an object before calling map()");
     if (const Value *E = O->get(Prop))
       return fromJSON(*E, Out, P.field(Prop));
diff --git a/llvm/include/llvm/Support/RISCVISAUtils.h b/llvm/include/llvm/Support/RISCVISAUtils.h
index 77f8c3e45f1ab..ee981a1c5595a 100644
--- a/llvm/include/llvm/Support/RISCVISAUtils.h
+++ b/llvm/include/llvm/Support/RISCVISAUtils.h
@@ -20,7 +20,7 @@
 namespace llvm {
 
 namespace RISCVISAUtils {
-constexpr StringLiteral AllStdExts = "mafdqlcbkjtpvnh";
+constexpr StringRef AllStdExts = "mafdqlcbkjtpvnh";
 
 /// Represents the major and version number components of a RISC-V extension.
 struct ExtensionVersion {
diff --git a/llvm/include/llvm/TargetParser/RISCVTargetParser.h b/llvm/include/llvm/TargetParser/RISCVTargetParser.h
index c237e1ddd6b38..f26716910ea2e 100644
--- a/llvm/include/llvm/TargetParser/RISCVTargetParser.h
+++ b/llvm/include/llvm/TargetParser/RISCVTargetParser.h
@@ -39,8 +39,8 @@ struct CPUModel {
 };
 
 struct CPUInfo {
-  StringLiteral Name;
-  StringLiteral DefaultMarch;
+  StringRef Name;
+  StringRef DefaultMarch;
   bool FastScalarUnalignedAccess;
   bool FastVectorUnalignedAccess;
   CPUModel Model;
diff --git a/llvm/include/llvm/Telemetry/Telemetry.h b/llvm/include/llvm/Telemetry/Telemetry.h
index 344a49df5cbf0..827fd49d2dccb 100644
--- a/llvm/include/llvm/Telemetry/Telemetry.h
+++ b/llvm/include/llvm/Telemetry/Telemetry.h
@@ -127,7 +127,7 @@ class Destination {
 public:
   virtual ~Destination() = default;
   virtual Error receiveEntry(const TelemetryInfo *Entry) = 0;
-  virtual StringLiteral name() const = 0;
+  virtual StringRef name() const = 0;
 };
 
 /// This class is the main interaction point between any LLVM tool
diff --git a/llvm/include/llvm/TextAPI/Symbol.h b/llvm/include/llvm/TextAPI/Symbol.h
index 5a5eb0eb48325..6ea91c7b7cef0 100644
--- a/llvm/include/llvm/TextAPI/Symbol.h
+++ b/llvm/include/llvm/TextAPI/Symbol.h
@@ -59,11 +59,11 @@ enum class EncodeKind : uint8_t {
   ObjectiveCInstanceVariable,
 };
 
-constexpr StringLiteral ObjC1ClassNamePrefix = ".objc_class_name_";
-constexpr StringLiteral ObjC2ClassNamePrefix = "_OBJC_CLASS_$_";
-constexpr StringLiteral ObjC2MetaClassNamePrefix = "_OBJC_METACLASS_$_";
-constexpr StringLiteral ObjC2EHTypePrefix = "_OBJC_EHTYPE_$_";
-constexpr StringLiteral ObjC2IVarPrefix = "_OBJC_IVAR_$_";
+constexpr StringRef ObjC1ClassNamePrefix = ".objc_class_name_";
+constexpr StringRef ObjC2ClassNamePrefix = "_OBJC_CLASS_$_";
+constexpr StringRef ObjC2MetaClassNamePrefix = "_OBJC_METACLASS_$_";
+constexpr StringRef ObjC2EHTypePrefix = "_OBJC_EHTYPE_$_";
+constexpr StringRef ObjC2IVarPrefix = "_OBJC_IVAR_$_";
 
 /// ObjC Interface symbol mappings.
 enum class ObjCIFSymbolKind : uint8_t {
diff --git a/llvm/lib/Analysis/TargetLibraryInfo.cpp b/llvm/lib/Analysis/TargetLibraryInfo.cpp
index 8557901192e40..83850f02b2793 100644
--- a/llvm/lib/Analysis/TargetLibraryInfo.cpp
+++ b/llvm/lib/Analysis/TargetLibraryInfo.cpp
@@ -42,8 +42,7 @@ static cl::opt ClVectorLibrary(
                clEnumValN(TargetLibraryInfoImpl::AMDLIBM, "AMDLIBM",
                           "AMD vector math library")));
 
-StringLiteral const TargetLibraryInfoImpl::StandardNames[LibFunc::NumLibFuncs] =
-    {
+StringRef const TargetLibraryInfoImpl::StandardNames[LibFunc::NumLibFuncs] = {
 #define TLI_DEFINE_STRING
 #include "llvm/Analysis/TargetLibraryInfo.def"
 };
@@ -182,7 +181,7 @@ static void initializeBase(TargetLibraryInfoImpl &TLI, const Triple &T) {
 /// target triple. This should be carefully written so that a missing target
 /// triple gets a sane set of defaults.
 static void initializeLibCalls(TargetLibraryInfoImpl &TLI, const Triple &T,
-                               ArrayRef StandardNames) {
+                               ArrayRef StandardNames) {
   // Set IO unlocked variants as unavailable
   // Set them as available per system below
   TLI.setUnavailable(LibFunc_getc_unlocked);
@@ -915,7 +914,7 @@ static void initializeLibCalls(TargetLibraryInfoImpl &TLI, const Triple &T,
 /// target triple. This should be carefully written so that a missing target
 /// triple gets a sane set of defaults.
 static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T,
-                       ArrayRef StandardNames) {
+                       ArrayRef StandardNames) {
   initializeBase(TLI, T);
   initializeLibCalls(TLI, T, StandardNames);
 }
@@ -992,7 +991,7 @@ static StringRef sanitizeFunctionName(StringRef funcName) {
 }
 
 static DenseMap
-buildIndexMap(ArrayRef StandardNames) {
+buildIndexMap(ArrayRef StandardNames) {
   DenseMap Indices;
   unsigned Idx = 0;
   Indices.reserve(LibFunc::NumLibFuncs);
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
index 8bf513538de7c..7019c982fd68e 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
@@ -1455,7 +1455,7 @@ unsigned DWARFVerifier::verifyNameIndexAttribute(
   struct FormClassTable {
     dwarf::Index Index;
     DWARFFormValue::FormClass Class;
-    StringLiteral ClassName;
+    StringRef ClassName;
   };
   static constexpr FormClassTable Table[] = {
       {dwarf::DW_IDX_compile_unit, DWARFFormValue::FC_Constant, {"constant"}},
diff --git a/llvm/lib/FileCheck/FileCheck.cpp b/llvm/lib/FileCheck/FileCheck.cpp
index b6c28385ebb09..8699971b7466e 100644
--- a/llvm/lib/FileCheck/FileCheck.cpp
+++ b/llvm/lib/FileCheck/FileCheck.cpp
@@ -318,7 +318,7 @@ Pattern::parseVariable(StringRef &Str, const SourceMgr &SM) {
 
 // StringRef holding all characters considered as horizontal whitespaces by
 // FileCheck input canonicalization.
-constexpr StringLiteral SpaceChars = " \t";
+constexpr StringRef SpaceChars = " \t";
 
 // Parsing helper function that strips the first character in S and returns it.
 static char popFront(StringRef &S) {
diff --git a/llvm/lib/InterfaceStub/ELFObjHandler.cpp b/llvm/lib/InterfaceStub/ELFObjHandler.cpp
index 9c81a8832c0f2..624db35f60682 100644
--- a/llvm/lib/InterfaceStub/ELFObjHandler.cpp
+++ b/llvm/lib/InterfaceStub/ELFObjHandler.cpp
@@ -428,7 +428,7 @@ template  class DynSym {
 /// @param Offset The start index of the desired substring.
 static Expected terminatedSubstr(StringRef Str, size_t Offset) {
   size_t StrEnd = Str.find('\0', Offset);
-  if (StrEnd == StringLiteral::npos) {
+  if (StrEnd == StringRef::npos) {
     return createError(
         "String overran bounds of string table (no null terminator)");
   }
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp
index 0f53c60851217..52c84110d4d12 100644
--- a/llvm/lib/LTO/LTO.cpp
+++ b/llvm/lib/LTO/LTO.cpp
@@ -1718,7 +1718,7 @@ ThinBackend lto::createInProcessThinBackend(ThreadPoolStrategy Parallelism,
   return ThinBackend(Func, Parallelism);
 }
 
-StringLiteral lto::getThinLTODefaultCPU(const Triple &TheTriple) {
+StringRef lto::getThinLTODefaultCPU(const Triple &TheTriple) {
   if (!TheTriple.isOSDarwin())
     return "";
   if (TheTriple.getArch() == Triple::x86_64)
diff --git a/llvm/lib/MC/MCSectionMachO.cpp b/llvm/lib/MC/MCSectionMachO.cpp
index 67453cea53a26..07b953839c0a2 100644
--- a/llvm/lib/MC/MCSectionMachO.cpp
+++ b/llvm/lib/MC/MCSectionMachO.cpp
@@ -23,47 +23,42 @@ using namespace llvm;
 /// types.  This *must* be kept in order with and stay synchronized with the
 /// section type list.
 static constexpr struct {
-  StringLiteral AssemblerName, EnumName;
+  StringRef AssemblerName, EnumName;
 } SectionTypeDescriptors[MachO::LAST_KNOWN_SECTION_TYPE + 1] = {
-    {StringLiteral("regular"), StringLiteral("S_REGULAR")}, // 0x00
-    {StringLiteral("zerofill"), StringLiteral("S_ZEROFILL")}, // 0x01
-    {StringLiteral("cstring_literals"),
-     StringLiteral("S_CSTRING_LITERALS")}, // 0x02
-    {StringLiteral("4byte_literals"),
-     StringLiteral("S_4BYTE_LITERALS")}, // 0x03
-    {StringLiteral("8byte_literals"),
-     StringLiteral("S_8BYTE_LITERALS")}, // 0x04
-    {StringLiteral("literal_pointers"),
-     StringLiteral("S_LITERAL_POINTERS")}, // 0x05
-    {StringLiteral("non_lazy_symbol_pointers"),
-     StringLiteral("S_NON_LAZY_SYMBOL_POINTERS")}, // 0x06
-    {StringLiteral("lazy_symbol_pointers"),
-     StringLiteral("S_LAZY_SYMBOL_POINTERS")},                        // 0x07
-    {StringLiteral("symbol_stubs"), StringLiteral("S_SYMBOL_STUBS")}, // 0x08
-    {StringLiteral("mod_init_funcs"),
-     StringLiteral("S_MOD_INIT_FUNC_POINTERS")}, // 0x09
-    {StringLiteral("mod_term_funcs"),
-     StringLiteral("S_MOD_TERM_FUNC_POINTERS")},                     // 0x0A
-    {StringLiteral("coalesced"), StringLiteral("S_COALESCED")},      // 0x0B
-    {StringLiteral("") /*FIXME??*/, StringLiteral("S_GB_ZEROFILL")}, // 0x0C
-    {StringLiteral("interposing"), StringLiteral("S_INTERPOSING")},  // 0x0D
-    {StringLiteral("16byte_literals"),
-     StringLiteral("S_16BYTE_LITERALS")},                           // 0x0E
-    {StringLiteral("") /*FIXME??*/, StringLiteral("S_DTRACE_DOF")}, // 0x0F
-    {StringLiteral("") /*FIXME??*/,
-     StringLiteral("S_LAZY_DYLIB_SYMBOL_POINTERS")}, // 0x10
-    {StringLiteral("thread_local_regular"),
-     StringLiteral("S_THREAD_LOCAL_REGULAR")}, // 0x11
-    {StringLiteral("thread_local_zerofill"),
-     StringLiteral("S_THREAD_LOCAL_ZEROFILL")}, // 0x12
-    {StringLiteral("thread_local_variables"),
-     StringLiteral("S_THREAD_LOCAL_VARIABLES")}, // 0x13
-    {StringLiteral("thread_local_variable_pointers"),
-     StringLiteral("S_THREAD_LOCAL_VARIABLE_POINTERS")}, // 0x14
-    {StringLiteral("thread_local_init_function_pointers"),
-     StringLiteral("S_THREAD_LOCAL_INIT_FUNCTION_POINTERS")}, // 0x15
-    {StringLiteral("") /* linker-synthesized */,
-     StringLiteral("S_INIT_FUNC_OFFSETS")}, // 0x16
+    {StringRef("regular"), StringRef("S_REGULAR")},                   // 0x00
+    {StringRef("zerofill"), StringRef("S_ZEROFILL")},                 // 0x01
+    {StringRef("cstring_literals"), StringRef("S_CSTRING_LITERALS")}, // 0x02
+    {StringRef("4byte_literals"), StringRef("S_4BYTE_LITERALS")},     // 0x03
+    {StringRef("8byte_literals"), StringRef("S_8BYTE_LITERALS")},     // 0x04
+    {StringRef("literal_pointers"), StringRef("S_LITERAL_POINTERS")}, // 0x05
+    {StringRef("non_lazy_symbol_pointers"),
+     StringRef("S_NON_LAZY_SYMBOL_POINTERS")}, // 0x06
+    {StringRef("lazy_symbol_pointers"),
+     StringRef("S_LAZY_SYMBOL_POINTERS")},                    // 0x07
+    {StringRef("symbol_stubs"), StringRef("S_SYMBOL_STUBS")}, // 0x08
+    {StringRef("mod_init_funcs"),
+     StringRef("S_MOD_INIT_FUNC_POINTERS")}, // 0x09
+    {StringRef("mod_term_funcs"),
+     StringRef("S_MOD_TERM_FUNC_POINTERS")},                        // 0x0A
+    {StringRef("coalesced"), StringRef("S_COALESCED")},             // 0x0B
+    {StringRef("") /*FIXME??*/, StringRef("S_GB_ZEROFILL")},        // 0x0C
+    {StringRef("interposing"), StringRef("S_INTERPOSING")},         // 0x0D
+    {StringRef("16byte_literals"), StringRef("S_16BYTE_LITERALS")}, // 0x0E
+    {StringRef("") /*FIXME??*/, StringRef("S_DTRACE_DOF")},         // 0x0F
+    {StringRef("") /*FIXME??*/,
+     StringRef("S_LAZY_DYLIB_SYMBOL_POINTERS")}, // 0x10
+    {StringRef("thread_local_regular"),
+     StringRef("S_THREAD_LOCAL_REGULAR")}, // 0x11
+    {StringRef("thread_local_zerofill"),
+     StringRef("S_THREAD_LOCAL_ZEROFILL")}, // 0x12
+    {StringRef("thread_local_variables"),
+     StringRef("S_THREAD_LOCAL_VARIABLES")}, // 0x13
+    {StringRef("thread_local_variable_pointers"),
+     StringRef("S_THREAD_LOCAL_VARIABLE_POINTERS")}, // 0x14
+    {StringRef("thread_local_init_function_pointers"),
+     StringRef("S_THREAD_LOCAL_INIT_FUNCTION_POINTERS")}, // 0x15
+    {StringRef("") /* linker-synthesized */,
+     StringRef("S_INIT_FUNC_OFFSETS")}, // 0x16
 };
 
 /// SectionAttrDescriptors - This is an array of descriptors for section
@@ -71,22 +66,24 @@ static constexpr struct {
 /// by attribute, instead it is searched.
 static constexpr struct {
   unsigned AttrFlag;
-  StringLiteral AssemblerName, EnumName;
+  StringRef AssemblerName, EnumName;
 } SectionAttrDescriptors[] = {
-#define ENTRY(ASMNAME, ENUM) \
-  { MachO::ENUM, StringLiteral(ASMNAME), StringLiteral(#ENUM) },
-ENTRY("pure_instructions",   S_ATTR_PURE_INSTRUCTIONS)
-ENTRY("no_toc",              S_ATTR_NO_TOC)
-ENTRY("strip_static_syms",   S_ATTR_STRIP_STATIC_SYMS)
-ENTRY("no_dead_strip",       S_ATTR_NO_DEAD_STRIP)
-ENTRY("live_support",        S_ATTR_LIVE_SUPPORT)
-ENTRY("self_modifying_code", S_ATTR_SELF_MODIFYING_CODE)
-ENTRY("debug",               S_ATTR_DEBUG)
-ENTRY("" /*FIXME*/,          S_ATTR_SOME_INSTRUCTIONS)
-ENTRY("" /*FIXME*/,          S_ATTR_EXT_RELOC)
-ENTRY("" /*FIXME*/,          S_ATTR_LOC_RELOC)
+#define ENTRY(ASMNAME, ENUM)                                                   \
+  {MachO::ENUM, StringRef(ASMNAME), StringRef(#ENUM)},
+    ENTRY("pure_instructions", S_ATTR_PURE_INSTRUCTIONS) ENTRY("no_toc",
+                                                               S_ATTR_NO_TOC)
+        ENTRY("strip_static_syms", S_ATTR_STRIP_STATIC_SYMS) ENTRY(
+            "no_dead_strip", S_ATTR_NO_DEAD_STRIP) ENTRY("live_support",
+                                                         S_ATTR_LIVE_SUPPORT)
+            ENTRY("self_modifying_code", S_ATTR_SELF_MODIFYING_CODE)
+                ENTRY("debug", S_ATTR_DEBUG) ENTRY("" /*FIXME*/,
+                                                   S_ATTR_SOME_INSTRUCTIONS)
+                    ENTRY("" /*FIXME*/, S_ATTR_EXT_RELOC)
+                        ENTRY("" /*FIXME*/, S_ATTR_LOC_RELOC)
 #undef ENTRY
-  { 0, StringLiteral("none"), StringLiteral("") }, // used if section has no attributes but has a stub size
+                            {0, StringRef("none"),
+                             StringRef("")}, // used if section has no
+                                             // attributes but has a stub size
 };
 
 MCSectionMachO::MCSectionMachO(StringRef Segment, StringRef Section,
diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp
index e34a770b1b53e..0e2d1144be29a 100644
--- a/llvm/lib/Support/CommandLine.cpp
+++ b/llvm/lib/Support/CommandLine.cpp
@@ -1119,7 +1119,7 @@ static bool hasUTF8ByteOrderMark(ArrayRef S) {
 static void ExpandBasePaths(StringRef BasePath, StringSaver &Saver,
                             const char *&Arg) {
   assert(sys::path::is_absolute(BasePath));
-  constexpr StringLiteral Token("");
+  constexpr StringRef Token("");
   const StringRef ArgString(Arg);
 
   SmallString<128> ResponseFile;
diff --git a/llvm/lib/Support/FloatingPointMode.cpp b/llvm/lib/Support/FloatingPointMode.cpp
index 5a2836eb82434..98a4b7e267a36 100644
--- a/llvm/lib/Support/FloatingPointMode.cpp
+++ b/llvm/lib/Support/FloatingPointMode.cpp
@@ -64,24 +64,13 @@ FPClassTest llvm::unknown_sign(FPClassTest Mask) {
 //
 // Bits are consumed as printed. Each field should only be represented in one
 // printed field.
-static constexpr std::pair NoFPClassName[] = {
-  {fcAllFlags, "all"},
-  {fcNan, "nan"},
-  {fcSNan, "snan"},
-  {fcQNan, "qnan"},
-  {fcInf, "inf"},
-  {fcNegInf, "ninf"},
-  {fcPosInf, "pinf"},
-  {fcZero, "zero"},
-  {fcNegZero, "nzero"},
-  {fcPosZero, "pzero"},
-  {fcSubnormal, "sub"},
-  {fcNegSubnormal, "nsub"},
-  {fcPosSubnormal, "psub"},
-  {fcNormal, "norm"},
-  {fcNegNormal, "nnorm"},
-  {fcPosNormal, "pnorm"}
-};
+static constexpr std::pair NoFPClassName[] = {
+    {fcAllFlags, "all"},      {fcNan, "nan"},       {fcSNan, "snan"},
+    {fcQNan, "qnan"},         {fcInf, "inf"},       {fcNegInf, "ninf"},
+    {fcPosInf, "pinf"},       {fcZero, "zero"},     {fcNegZero, "nzero"},
+    {fcPosZero, "pzero"},     {fcSubnormal, "sub"}, {fcNegSubnormal, "nsub"},
+    {fcPosSubnormal, "psub"}, {fcNormal, "norm"},   {fcNegNormal, "nnorm"},
+    {fcPosNormal, "pnorm"}};
 
 raw_ostream &llvm::operator<<(raw_ostream &OS, FPClassTest Mask) {
   OS << '(';
diff --git a/llvm/lib/Support/FormatVariadic.cpp b/llvm/lib/Support/FormatVariadic.cpp
index f3e8d0a7fe6f3..26d37ed5d8829 100644
--- a/llvm/lib/Support/FormatVariadic.cpp
+++ b/llvm/lib/Support/FormatVariadic.cpp
@@ -179,7 +179,7 @@ formatv_object_base::parseFormatString(StringRef Fmt, size_t NumArgs,
   // When validation fails, return an array of replacement items that
   // will print an error message as the outout of this formatv() (used when
   // validation is enabled in release mode).
-  auto getErrorReplacements = [SavedFmtStr](StringLiteral ErrorMsg) {
+  auto getErrorReplacements = [SavedFmtStr](StringRef ErrorMsg) {
     return SmallVector{
         ReplacementItem("Invalid formatv() call: "), ReplacementItem(ErrorMsg),
         ReplacementItem(" for format string: "), ReplacementItem(SavedFmtStr)};
diff --git a/llvm/lib/Support/JSON.cpp b/llvm/lib/Support/JSON.cpp
index a5c617bb4a076..bc3df1fb348c4 100644
--- a/llvm/lib/Support/JSON.cpp
+++ b/llvm/lib/Support/JSON.cpp
@@ -208,7 +208,7 @@ bool operator==(const Value &L, const Value &R) {
   llvm_unreachable("Unknown value kind");
 }
 
-void Path::report(llvm::StringLiteral Msg) {
+void Path::report(llvm::StringRef Msg) {
   // Walk up to the root context, and count the number of segments.
   unsigned Count = 0;
   const Path *P;
diff --git a/llvm/lib/Support/YAMLTraits.cpp b/llvm/lib/Support/YAMLTraits.cpp
index f326422138488..cde4833cadea4 100644
--- a/llvm/lib/Support/YAMLTraits.cpp
+++ b/llvm/lib/Support/YAMLTraits.cpp
@@ -775,8 +775,8 @@ void Output::output(StringRef S, QuotingType MustQuote) {
     return;
   }
 
-  StringLiteral Quote = MustQuote == QuotingType::Single ? StringLiteral("'")
-                                                         : StringLiteral("\"");
+  StringRef Quote =
+      MustQuote == QuotingType::Single ? StringRef("'") : StringRef("\"");
   output(Quote); // Starting quote.
 
   // When using double-quoted strings (and only in that case), non-printable
@@ -799,7 +799,7 @@ void Output::output(StringRef S, QuotingType MustQuote) {
   while (j < End) {
     if (S[j] == '\'') {                   // Escape quotes.
       output(StringRef(&Base[i], j - i)); // "flush".
-      output(StringLiteral("''"));        // Print it as ''
+      output(StringRef("''"));            // Print it as ''
       i = j + 1;
     }
     ++j;
diff --git a/llvm/lib/Target/AArch64/AArch64MCInstLower.cpp b/llvm/lib/Target/AArch64/AArch64MCInstLower.cpp
index 46ce151ca82b6..9fd8d6b3ba055 100644
--- a/llvm/lib/Target/AArch64/AArch64MCInstLower.cpp
+++ b/llvm/lib/Target/AArch64/AArch64MCInstLower.cpp
@@ -65,7 +65,7 @@ MCSymbol *AArch64MCInstLower::GetGlobalValueSymbol(const GlobalValue *GV,
 
     StringRef Name = Printer.getSymbol(GV)->getName();
     // Don't mangle ARM64EC runtime functions.
-    static constexpr StringLiteral ExcludedFns[] = {
+    static constexpr StringRef ExcludedFns[] = {
         "__os_arm64x_check_icall_cfg", "__os_arm64x_dispatch_call_no_redirect",
         "__os_arm64x_check_icall"};
     if (is_contained(ExcludedFns, Name))
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
index 90c341ac0819c..09a32456e3d80 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
@@ -1483,7 +1483,7 @@ void AMDGPUAsmPrinter::EmitPALMetadata(const MachineFunction &MF,
           (unsigned)(ExtraLDSSize * ExtraLdsDwGranularity * sizeof(uint32_t)));
 
       // Set PsInputEna and PsInputAddr .spi_ps_input_ena and .spi_ps_input_addr
-      static StringLiteral const PsInputFields[] = {
+      static StringRef const PsInputFields[] = {
           ".persp_sample_ena",    ".persp_center_ena",
           ".persp_centroid_ena",  ".persp_pull_model_ena",
           ".linear_sample_ena",   ".linear_center_ena",
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp b/llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp
index 546db318c17d5..12bcf270782a0 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp
@@ -54,8 +54,7 @@ enum ImplicitArgumentMask {
 };
 
 #define AMDGPU_ATTRIBUTE(Name, Str) {Name, Str},
-static constexpr std::pair
-    ImplicitAttrs[] = {
+static constexpr std::pair ImplicitAttrs[] = {
 #include "AMDGPUAttributes.def"
 };
 
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp b/llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
index bb00442342d84..c399f9a89589f 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
@@ -775,15 +775,11 @@ bool AMDGPUCallLowering::passSpecialInputs(MachineIRBuilder &MIRBuilder,
     AMDGPUFunctionArgInfo::LDS_KERNEL_ID,
   };
 
-  static constexpr StringLiteral ImplicitAttrNames[] = {
-    "amdgpu-no-dispatch-ptr",
-    "amdgpu-no-queue-ptr",
-    "amdgpu-no-implicitarg-ptr",
-    "amdgpu-no-dispatch-id",
-    "amdgpu-no-workgroup-id-x",
-    "amdgpu-no-workgroup-id-y",
-    "amdgpu-no-workgroup-id-z",
-    "amdgpu-no-lds-kernel-id",
+  static constexpr StringRef ImplicitAttrNames[] = {
+      "amdgpu-no-dispatch-ptr",    "amdgpu-no-queue-ptr",
+      "amdgpu-no-implicitarg-ptr", "amdgpu-no-dispatch-id",
+      "amdgpu-no-workgroup-id-x",  "amdgpu-no-workgroup-id-y",
+      "amdgpu-no-workgroup-id-z",  "amdgpu-no-lds-kernel-id",
   };
 
   MachineRegisterInfo &MRI = MF.getRegInfo();
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp b/llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp
index a899805dc46b1..ae138bbffd5b1 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp
@@ -122,7 +122,7 @@ static bool shouldPrintAsStr(char Specifier, Type *OpType) {
   return Specifier == 's' && isa(OpType);
 }
 
-constexpr StringLiteral NonLiteralStr("???");
+constexpr StringRef NonLiteralStr("???");
 static_assert(NonLiteralStr.size() == 3);
 
 static StringRef getAsConstantStr(Value *V) {
diff --git a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
index d8f441d1ccfe4..db06a74d6bfea 100644
--- a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
+++ b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
@@ -1710,12 +1710,12 @@ class AMDGPUAsmParser : public MCTargetAsmParser {
   };
 
   struct StructuredOpField : OperandInfoTy {
-    StringLiteral Id;
-    StringLiteral Desc;
+    StringRef Id;
+    StringRef Desc;
     unsigned Width;
     bool IsDefined = false;
 
-    StructuredOpField(StringLiteral Id, StringLiteral Desc, unsigned Width,
+    StructuredOpField(StringRef Id, StringRef Desc, unsigned Width,
                       int64_t Default)
         : OperandInfoTy(Default), Id(Id), Desc(Desc), Width(Width) {}
     virtual ~StructuredOpField() = default;
@@ -2768,7 +2768,7 @@ bool AMDGPUAsmParser::AddNextRegisterToList(MCRegister &Reg, unsigned &RegWidth,
 }
 
 struct RegInfo {
-  StringLiteral Name;
+  StringRef Name;
   RegisterKind Kind;
 };
 
diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
index 992f7ed99d3bb..73d283a3ca64c 100644
--- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -3355,7 +3355,7 @@ void SITargetLowering::passSpecialInputs(
   // in the same location as the input.
   // clang-format off
   static constexpr std::pair ImplicitAttrs[] = {
+                              StringRef> ImplicitAttrs[] = {
      {AMDGPUFunctionArgInfo::DISPATCH_PTR, "amdgpu-no-dispatch-ptr"},
      {AMDGPUFunctionArgInfo::QUEUE_PTR, "amdgpu-no-queue-ptr" },
      {AMDGPUFunctionArgInfo::IMPLICIT_ARG_PTR, "amdgpu-no-implicitarg-ptr"},
diff --git a/llvm/lib/Target/AMDGPU/SIMemoryLegalizer.cpp b/llvm/lib/Target/AMDGPU/SIMemoryLegalizer.cpp
index be6cff873532b..a15bca6027335 100644
--- a/llvm/lib/Target/AMDGPU/SIMemoryLegalizer.cpp
+++ b/llvm/lib/Target/AMDGPU/SIMemoryLegalizer.cpp
@@ -721,7 +721,7 @@ void diagnoseUnknownMMRAASName(const MachineInstr &MI, StringRef AS) {
 /// Default. Otherwise returns all the address spaces concerned by the MMRA.
 static SIAtomicAddrSpace getFenceAddrSpaceMMRA(const MachineInstr &MI,
                                                SIAtomicAddrSpace Default) {
-  static constexpr StringLiteral FenceASPrefix = "amdgpu-as";
+  static constexpr StringRef FenceASPrefix = "amdgpu-as";
 
   auto MMRA = MMRAMetadata(MI.getMMRAMetadata());
   if (!MMRA)
diff --git a/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp b/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
index 704435dad65d7..0e885c25907df 100644
--- a/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
@@ -3890,10 +3890,10 @@ SIRegisterInfo::getNumUsedPhysRegs(const MachineRegisterInfo &MRI,
   return 0;
 }
 
-SmallVector
+SmallVector
 SIRegisterInfo::getVRegFlagsOfReg(Register Reg,
                                   const MachineFunction &MF) const {
-  SmallVector RegFlags;
+  SmallVector RegFlags;
   const SIMachineFunctionInfo *FuncInfo = MF.getInfo();
   if (FuncInfo->checkFlag(Reg, AMDGPU::VirtRegFlag::WWM_REG))
     RegFlags.push_back("WWM_REG");
diff --git a/llvm/lib/Target/AMDGPU/SIRegisterInfo.h b/llvm/lib/Target/AMDGPU/SIRegisterInfo.h
index 8e481e3ac2304..8c344d3ad6066 100644
--- a/llvm/lib/Target/AMDGPU/SIRegisterInfo.h
+++ b/llvm/lib/Target/AMDGPU/SIRegisterInfo.h
@@ -468,7 +468,7 @@ class SIRegisterInfo final : public AMDGPUGenRegisterInfo {
                              : std::optional{};
   }
 
-  SmallVector
+  SmallVector
   getVRegFlagsOfReg(Register Reg, const MachineFunction &MF) const override;
 };
 
diff --git a/llvm/lib/Target/AMDGPU/Utils/AMDGPUAsmUtils.cpp b/llvm/lib/Target/AMDGPU/Utils/AMDGPUAsmUtils.cpp
index a8e4ce133ffbc..c88c6fa5792b6 100644
--- a/llvm/lib/Target/AMDGPU/Utils/AMDGPUAsmUtils.cpp
+++ b/llvm/lib/Target/AMDGPU/Utils/AMDGPUAsmUtils.cpp
@@ -241,151 +241,128 @@ StringRef getHwreg(uint64_t Encoding, const MCSubtargetInfo &STI) {
 
 namespace MTBUFFormat {
 
-StringLiteral const DfmtSymbolic[] = {
-  "BUF_DATA_FORMAT_INVALID",
-  "BUF_DATA_FORMAT_8",
-  "BUF_DATA_FORMAT_16",
-  "BUF_DATA_FORMAT_8_8",
-  "BUF_DATA_FORMAT_32",
-  "BUF_DATA_FORMAT_16_16",
-  "BUF_DATA_FORMAT_10_11_11",
-  "BUF_DATA_FORMAT_11_11_10",
-  "BUF_DATA_FORMAT_10_10_10_2",
-  "BUF_DATA_FORMAT_2_10_10_10",
-  "BUF_DATA_FORMAT_8_8_8_8",
-  "BUF_DATA_FORMAT_32_32",
-  "BUF_DATA_FORMAT_16_16_16_16",
-  "BUF_DATA_FORMAT_32_32_32",
-  "BUF_DATA_FORMAT_32_32_32_32",
-  "BUF_DATA_FORMAT_RESERVED_15"
-};
-
-StringLiteral const NfmtSymbolicGFX10[] = {
-  "BUF_NUM_FORMAT_UNORM",
-  "BUF_NUM_FORMAT_SNORM",
-  "BUF_NUM_FORMAT_USCALED",
-  "BUF_NUM_FORMAT_SSCALED",
-  "BUF_NUM_FORMAT_UINT",
-  "BUF_NUM_FORMAT_SINT",
-  "",
-  "BUF_NUM_FORMAT_FLOAT"
-};
-
-StringLiteral const NfmtSymbolicSICI[] = {
-  "BUF_NUM_FORMAT_UNORM",
-  "BUF_NUM_FORMAT_SNORM",
-  "BUF_NUM_FORMAT_USCALED",
-  "BUF_NUM_FORMAT_SSCALED",
-  "BUF_NUM_FORMAT_UINT",
-  "BUF_NUM_FORMAT_SINT",
-  "BUF_NUM_FORMAT_SNORM_OGL",
-  "BUF_NUM_FORMAT_FLOAT"
-};
-
-StringLiteral const NfmtSymbolicVI[] = {    // VI and GFX9
-  "BUF_NUM_FORMAT_UNORM",
-  "BUF_NUM_FORMAT_SNORM",
-  "BUF_NUM_FORMAT_USCALED",
-  "BUF_NUM_FORMAT_SSCALED",
-  "BUF_NUM_FORMAT_UINT",
-  "BUF_NUM_FORMAT_SINT",
-  "BUF_NUM_FORMAT_RESERVED_6",
-  "BUF_NUM_FORMAT_FLOAT"
-};
-
-StringLiteral const UfmtSymbolicGFX10[] = {
-  "BUF_FMT_INVALID",
-
-  "BUF_FMT_8_UNORM",
-  "BUF_FMT_8_SNORM",
-  "BUF_FMT_8_USCALED",
-  "BUF_FMT_8_SSCALED",
-  "BUF_FMT_8_UINT",
-  "BUF_FMT_8_SINT",
-
-  "BUF_FMT_16_UNORM",
-  "BUF_FMT_16_SNORM",
-  "BUF_FMT_16_USCALED",
-  "BUF_FMT_16_SSCALED",
-  "BUF_FMT_16_UINT",
-  "BUF_FMT_16_SINT",
-  "BUF_FMT_16_FLOAT",
-
-  "BUF_FMT_8_8_UNORM",
-  "BUF_FMT_8_8_SNORM",
-  "BUF_FMT_8_8_USCALED",
-  "BUF_FMT_8_8_SSCALED",
-  "BUF_FMT_8_8_UINT",
-  "BUF_FMT_8_8_SINT",
-
-  "BUF_FMT_32_UINT",
-  "BUF_FMT_32_SINT",
-  "BUF_FMT_32_FLOAT",
-
-  "BUF_FMT_16_16_UNORM",
-  "BUF_FMT_16_16_SNORM",
-  "BUF_FMT_16_16_USCALED",
-  "BUF_FMT_16_16_SSCALED",
-  "BUF_FMT_16_16_UINT",
-  "BUF_FMT_16_16_SINT",
-  "BUF_FMT_16_16_FLOAT",
-
-  "BUF_FMT_10_11_11_UNORM",
-  "BUF_FMT_10_11_11_SNORM",
-  "BUF_FMT_10_11_11_USCALED",
-  "BUF_FMT_10_11_11_SSCALED",
-  "BUF_FMT_10_11_11_UINT",
-  "BUF_FMT_10_11_11_SINT",
-  "BUF_FMT_10_11_11_FLOAT",
-
-  "BUF_FMT_11_11_10_UNORM",
-  "BUF_FMT_11_11_10_SNORM",
-  "BUF_FMT_11_11_10_USCALED",
-  "BUF_FMT_11_11_10_SSCALED",
-  "BUF_FMT_11_11_10_UINT",
-  "BUF_FMT_11_11_10_SINT",
-  "BUF_FMT_11_11_10_FLOAT",
-
-  "BUF_FMT_10_10_10_2_UNORM",
-  "BUF_FMT_10_10_10_2_SNORM",
-  "BUF_FMT_10_10_10_2_USCALED",
-  "BUF_FMT_10_10_10_2_SSCALED",
-  "BUF_FMT_10_10_10_2_UINT",
-  "BUF_FMT_10_10_10_2_SINT",
-
-  "BUF_FMT_2_10_10_10_UNORM",
-  "BUF_FMT_2_10_10_10_SNORM",
-  "BUF_FMT_2_10_10_10_USCALED",
-  "BUF_FMT_2_10_10_10_SSCALED",
-  "BUF_FMT_2_10_10_10_UINT",
-  "BUF_FMT_2_10_10_10_SINT",
-
-  "BUF_FMT_8_8_8_8_UNORM",
-  "BUF_FMT_8_8_8_8_SNORM",
-  "BUF_FMT_8_8_8_8_USCALED",
-  "BUF_FMT_8_8_8_8_SSCALED",
-  "BUF_FMT_8_8_8_8_UINT",
-  "BUF_FMT_8_8_8_8_SINT",
-
-  "BUF_FMT_32_32_UINT",
-  "BUF_FMT_32_32_SINT",
-  "BUF_FMT_32_32_FLOAT",
-
-  "BUF_FMT_16_16_16_16_UNORM",
-  "BUF_FMT_16_16_16_16_SNORM",
-  "BUF_FMT_16_16_16_16_USCALED",
-  "BUF_FMT_16_16_16_16_SSCALED",
-  "BUF_FMT_16_16_16_16_UINT",
-  "BUF_FMT_16_16_16_16_SINT",
-  "BUF_FMT_16_16_16_16_FLOAT",
-
-  "BUF_FMT_32_32_32_UINT",
-  "BUF_FMT_32_32_32_SINT",
-  "BUF_FMT_32_32_32_FLOAT",
-  "BUF_FMT_32_32_32_32_UINT",
-  "BUF_FMT_32_32_32_32_SINT",
-  "BUF_FMT_32_32_32_32_FLOAT"
-};
+StringRef const DfmtSymbolic[] = {
+    "BUF_DATA_FORMAT_INVALID",     "BUF_DATA_FORMAT_8",
+    "BUF_DATA_FORMAT_16",          "BUF_DATA_FORMAT_8_8",
+    "BUF_DATA_FORMAT_32",          "BUF_DATA_FORMAT_16_16",
+    "BUF_DATA_FORMAT_10_11_11",    "BUF_DATA_FORMAT_11_11_10",
+    "BUF_DATA_FORMAT_10_10_10_2",  "BUF_DATA_FORMAT_2_10_10_10",
+    "BUF_DATA_FORMAT_8_8_8_8",     "BUF_DATA_FORMAT_32_32",
+    "BUF_DATA_FORMAT_16_16_16_16", "BUF_DATA_FORMAT_32_32_32",
+    "BUF_DATA_FORMAT_32_32_32_32", "BUF_DATA_FORMAT_RESERVED_15"};
+
+StringRef const NfmtSymbolicGFX10[] = {"BUF_NUM_FORMAT_UNORM",
+                                       "BUF_NUM_FORMAT_SNORM",
+                                       "BUF_NUM_FORMAT_USCALED",
+                                       "BUF_NUM_FORMAT_SSCALED",
+                                       "BUF_NUM_FORMAT_UINT",
+                                       "BUF_NUM_FORMAT_SINT",
+                                       "",
+                                       "BUF_NUM_FORMAT_FLOAT"};
+
+StringRef const NfmtSymbolicSICI[] = {
+    "BUF_NUM_FORMAT_UNORM",     "BUF_NUM_FORMAT_SNORM",
+    "BUF_NUM_FORMAT_USCALED",   "BUF_NUM_FORMAT_SSCALED",
+    "BUF_NUM_FORMAT_UINT",      "BUF_NUM_FORMAT_SINT",
+    "BUF_NUM_FORMAT_SNORM_OGL", "BUF_NUM_FORMAT_FLOAT"};
+
+StringRef const NfmtSymbolicVI[] = { // VI and GFX9
+    "BUF_NUM_FORMAT_UNORM",      "BUF_NUM_FORMAT_SNORM",
+    "BUF_NUM_FORMAT_USCALED",    "BUF_NUM_FORMAT_SSCALED",
+    "BUF_NUM_FORMAT_UINT",       "BUF_NUM_FORMAT_SINT",
+    "BUF_NUM_FORMAT_RESERVED_6", "BUF_NUM_FORMAT_FLOAT"};
+
+StringRef const UfmtSymbolicGFX10[] = {"BUF_FMT_INVALID",
+
+                                       "BUF_FMT_8_UNORM",
+                                       "BUF_FMT_8_SNORM",
+                                       "BUF_FMT_8_USCALED",
+                                       "BUF_FMT_8_SSCALED",
+                                       "BUF_FMT_8_UINT",
+                                       "BUF_FMT_8_SINT",
+
+                                       "BUF_FMT_16_UNORM",
+                                       "BUF_FMT_16_SNORM",
+                                       "BUF_FMT_16_USCALED",
+                                       "BUF_FMT_16_SSCALED",
+                                       "BUF_FMT_16_UINT",
+                                       "BUF_FMT_16_SINT",
+                                       "BUF_FMT_16_FLOAT",
+
+                                       "BUF_FMT_8_8_UNORM",
+                                       "BUF_FMT_8_8_SNORM",
+                                       "BUF_FMT_8_8_USCALED",
+                                       "BUF_FMT_8_8_SSCALED",
+                                       "BUF_FMT_8_8_UINT",
+                                       "BUF_FMT_8_8_SINT",
+
+                                       "BUF_FMT_32_UINT",
+                                       "BUF_FMT_32_SINT",
+                                       "BUF_FMT_32_FLOAT",
+
+                                       "BUF_FMT_16_16_UNORM",
+                                       "BUF_FMT_16_16_SNORM",
+                                       "BUF_FMT_16_16_USCALED",
+                                       "BUF_FMT_16_16_SSCALED",
+                                       "BUF_FMT_16_16_UINT",
+                                       "BUF_FMT_16_16_SINT",
+                                       "BUF_FMT_16_16_FLOAT",
+
+                                       "BUF_FMT_10_11_11_UNORM",
+                                       "BUF_FMT_10_11_11_SNORM",
+                                       "BUF_FMT_10_11_11_USCALED",
+                                       "BUF_FMT_10_11_11_SSCALED",
+                                       "BUF_FMT_10_11_11_UINT",
+                                       "BUF_FMT_10_11_11_SINT",
+                                       "BUF_FMT_10_11_11_FLOAT",
+
+                                       "BUF_FMT_11_11_10_UNORM",
+                                       "BUF_FMT_11_11_10_SNORM",
+                                       "BUF_FMT_11_11_10_USCALED",
+                                       "BUF_FMT_11_11_10_SSCALED",
+                                       "BUF_FMT_11_11_10_UINT",
+                                       "BUF_FMT_11_11_10_SINT",
+                                       "BUF_FMT_11_11_10_FLOAT",
+
+                                       "BUF_FMT_10_10_10_2_UNORM",
+                                       "BUF_FMT_10_10_10_2_SNORM",
+                                       "BUF_FMT_10_10_10_2_USCALED",
+                                       "BUF_FMT_10_10_10_2_SSCALED",
+                                       "BUF_FMT_10_10_10_2_UINT",
+                                       "BUF_FMT_10_10_10_2_SINT",
+
+                                       "BUF_FMT_2_10_10_10_UNORM",
+                                       "BUF_FMT_2_10_10_10_SNORM",
+                                       "BUF_FMT_2_10_10_10_USCALED",
+                                       "BUF_FMT_2_10_10_10_SSCALED",
+                                       "BUF_FMT_2_10_10_10_UINT",
+                                       "BUF_FMT_2_10_10_10_SINT",
+
+                                       "BUF_FMT_8_8_8_8_UNORM",
+                                       "BUF_FMT_8_8_8_8_SNORM",
+                                       "BUF_FMT_8_8_8_8_USCALED",
+                                       "BUF_FMT_8_8_8_8_SSCALED",
+                                       "BUF_FMT_8_8_8_8_UINT",
+                                       "BUF_FMT_8_8_8_8_SINT",
+
+                                       "BUF_FMT_32_32_UINT",
+                                       "BUF_FMT_32_32_SINT",
+                                       "BUF_FMT_32_32_FLOAT",
+
+                                       "BUF_FMT_16_16_16_16_UNORM",
+                                       "BUF_FMT_16_16_16_16_SNORM",
+                                       "BUF_FMT_16_16_16_16_USCALED",
+                                       "BUF_FMT_16_16_16_16_SSCALED",
+                                       "BUF_FMT_16_16_16_16_UINT",
+                                       "BUF_FMT_16_16_16_16_SINT",
+                                       "BUF_FMT_16_16_16_16_FLOAT",
+
+                                       "BUF_FMT_32_32_32_UINT",
+                                       "BUF_FMT_32_32_32_SINT",
+                                       "BUF_FMT_32_32_32_FLOAT",
+                                       "BUF_FMT_32_32_32_32_UINT",
+                                       "BUF_FMT_32_32_32_32_SINT",
+                                       "BUF_FMT_32_32_32_32_FLOAT"};
 
 unsigned const DfmtNfmt2UFmtGFX10[] = {
   DFMT_INVALID     | (NFMT_UNORM   << NFMT_SHIFT),
@@ -481,85 +458,83 @@ unsigned const DfmtNfmt2UFmtGFX10[] = {
   DFMT_32_32_32_32 | (NFMT_FLOAT   << NFMT_SHIFT)
 };
 
-StringLiteral const UfmtSymbolicGFX11[] = {
-  "BUF_FMT_INVALID",
-
-  "BUF_FMT_8_UNORM",
-  "BUF_FMT_8_SNORM",
-  "BUF_FMT_8_USCALED",
-  "BUF_FMT_8_SSCALED",
-  "BUF_FMT_8_UINT",
-  "BUF_FMT_8_SINT",
-
-  "BUF_FMT_16_UNORM",
-  "BUF_FMT_16_SNORM",
-  "BUF_FMT_16_USCALED",
-  "BUF_FMT_16_SSCALED",
-  "BUF_FMT_16_UINT",
-  "BUF_FMT_16_SINT",
-  "BUF_FMT_16_FLOAT",
-
-  "BUF_FMT_8_8_UNORM",
-  "BUF_FMT_8_8_SNORM",
-  "BUF_FMT_8_8_USCALED",
-  "BUF_FMT_8_8_SSCALED",
-  "BUF_FMT_8_8_UINT",
-  "BUF_FMT_8_8_SINT",
-
-  "BUF_FMT_32_UINT",
-  "BUF_FMT_32_SINT",
-  "BUF_FMT_32_FLOAT",
-
-  "BUF_FMT_16_16_UNORM",
-  "BUF_FMT_16_16_SNORM",
-  "BUF_FMT_16_16_USCALED",
-  "BUF_FMT_16_16_SSCALED",
-  "BUF_FMT_16_16_UINT",
-  "BUF_FMT_16_16_SINT",
-  "BUF_FMT_16_16_FLOAT",
-
-  "BUF_FMT_10_11_11_FLOAT",
-
-  "BUF_FMT_11_11_10_FLOAT",
-
-  "BUF_FMT_10_10_10_2_UNORM",
-  "BUF_FMT_10_10_10_2_SNORM",
-  "BUF_FMT_10_10_10_2_UINT",
-  "BUF_FMT_10_10_10_2_SINT",
-
-  "BUF_FMT_2_10_10_10_UNORM",
-  "BUF_FMT_2_10_10_10_SNORM",
-  "BUF_FMT_2_10_10_10_USCALED",
-  "BUF_FMT_2_10_10_10_SSCALED",
-  "BUF_FMT_2_10_10_10_UINT",
-  "BUF_FMT_2_10_10_10_SINT",
-
-  "BUF_FMT_8_8_8_8_UNORM",
-  "BUF_FMT_8_8_8_8_SNORM",
-  "BUF_FMT_8_8_8_8_USCALED",
-  "BUF_FMT_8_8_8_8_SSCALED",
-  "BUF_FMT_8_8_8_8_UINT",
-  "BUF_FMT_8_8_8_8_SINT",
-
-  "BUF_FMT_32_32_UINT",
-  "BUF_FMT_32_32_SINT",
-  "BUF_FMT_32_32_FLOAT",
-
-  "BUF_FMT_16_16_16_16_UNORM",
-  "BUF_FMT_16_16_16_16_SNORM",
-  "BUF_FMT_16_16_16_16_USCALED",
-  "BUF_FMT_16_16_16_16_SSCALED",
-  "BUF_FMT_16_16_16_16_UINT",
-  "BUF_FMT_16_16_16_16_SINT",
-  "BUF_FMT_16_16_16_16_FLOAT",
-
-  "BUF_FMT_32_32_32_UINT",
-  "BUF_FMT_32_32_32_SINT",
-  "BUF_FMT_32_32_32_FLOAT",
-  "BUF_FMT_32_32_32_32_UINT",
-  "BUF_FMT_32_32_32_32_SINT",
-  "BUF_FMT_32_32_32_32_FLOAT"
-};
+StringRef const UfmtSymbolicGFX11[] = {"BUF_FMT_INVALID",
+
+                                       "BUF_FMT_8_UNORM",
+                                       "BUF_FMT_8_SNORM",
+                                       "BUF_FMT_8_USCALED",
+                                       "BUF_FMT_8_SSCALED",
+                                       "BUF_FMT_8_UINT",
+                                       "BUF_FMT_8_SINT",
+
+                                       "BUF_FMT_16_UNORM",
+                                       "BUF_FMT_16_SNORM",
+                                       "BUF_FMT_16_USCALED",
+                                       "BUF_FMT_16_SSCALED",
+                                       "BUF_FMT_16_UINT",
+                                       "BUF_FMT_16_SINT",
+                                       "BUF_FMT_16_FLOAT",
+
+                                       "BUF_FMT_8_8_UNORM",
+                                       "BUF_FMT_8_8_SNORM",
+                                       "BUF_FMT_8_8_USCALED",
+                                       "BUF_FMT_8_8_SSCALED",
+                                       "BUF_FMT_8_8_UINT",
+                                       "BUF_FMT_8_8_SINT",
+
+                                       "BUF_FMT_32_UINT",
+                                       "BUF_FMT_32_SINT",
+                                       "BUF_FMT_32_FLOAT",
+
+                                       "BUF_FMT_16_16_UNORM",
+                                       "BUF_FMT_16_16_SNORM",
+                                       "BUF_FMT_16_16_USCALED",
+                                       "BUF_FMT_16_16_SSCALED",
+                                       "BUF_FMT_16_16_UINT",
+                                       "BUF_FMT_16_16_SINT",
+                                       "BUF_FMT_16_16_FLOAT",
+
+                                       "BUF_FMT_10_11_11_FLOAT",
+
+                                       "BUF_FMT_11_11_10_FLOAT",
+
+                                       "BUF_FMT_10_10_10_2_UNORM",
+                                       "BUF_FMT_10_10_10_2_SNORM",
+                                       "BUF_FMT_10_10_10_2_UINT",
+                                       "BUF_FMT_10_10_10_2_SINT",
+
+                                       "BUF_FMT_2_10_10_10_UNORM",
+                                       "BUF_FMT_2_10_10_10_SNORM",
+                                       "BUF_FMT_2_10_10_10_USCALED",
+                                       "BUF_FMT_2_10_10_10_SSCALED",
+                                       "BUF_FMT_2_10_10_10_UINT",
+                                       "BUF_FMT_2_10_10_10_SINT",
+
+                                       "BUF_FMT_8_8_8_8_UNORM",
+                                       "BUF_FMT_8_8_8_8_SNORM",
+                                       "BUF_FMT_8_8_8_8_USCALED",
+                                       "BUF_FMT_8_8_8_8_SSCALED",
+                                       "BUF_FMT_8_8_8_8_UINT",
+                                       "BUF_FMT_8_8_8_8_SINT",
+
+                                       "BUF_FMT_32_32_UINT",
+                                       "BUF_FMT_32_32_SINT",
+                                       "BUF_FMT_32_32_FLOAT",
+
+                                       "BUF_FMT_16_16_16_16_UNORM",
+                                       "BUF_FMT_16_16_16_16_SNORM",
+                                       "BUF_FMT_16_16_16_16_USCALED",
+                                       "BUF_FMT_16_16_16_16_SSCALED",
+                                       "BUF_FMT_16_16_16_16_UINT",
+                                       "BUF_FMT_16_16_16_16_SINT",
+                                       "BUF_FMT_16_16_16_16_FLOAT",
+
+                                       "BUF_FMT_32_32_32_UINT",
+                                       "BUF_FMT_32_32_32_SINT",
+                                       "BUF_FMT_32_32_32_FLOAT",
+                                       "BUF_FMT_32_32_32_32_UINT",
+                                       "BUF_FMT_32_32_32_32_SINT",
+                                       "BUF_FMT_32_32_32_32_FLOAT"};
 
 unsigned const DfmtNfmt2UFmtGFX11[] = {
   DFMT_INVALID     | (NFMT_UNORM   << NFMT_SHIFT),
diff --git a/llvm/lib/Target/AMDGPU/Utils/AMDGPUAsmUtils.h b/llvm/lib/Target/AMDGPU/Utils/AMDGPUAsmUtils.h
index c84c1a7dc18c4..d8115fc7aaeeb 100644
--- a/llvm/lib/Target/AMDGPU/Utils/AMDGPUAsmUtils.h
+++ b/llvm/lib/Target/AMDGPU/Utils/AMDGPUAsmUtils.h
@@ -15,7 +15,7 @@
 
 namespace llvm {
 
-class StringLiteral;
+class StringRef;
 class MCSubtargetInfo;
 
 namespace AMDGPU {
@@ -26,13 +26,13 @@ const int OPR_ID_DUPLICATE = -3;
 const int OPR_VAL_INVALID = -4;
 
 struct CustomOperand {
-  StringLiteral Name;
+  StringRef Name;
   unsigned Encoding = 0;
   bool (*Cond)(const MCSubtargetInfo &STI) = nullptr;
 };
 
 struct CustomOperandVal {
-  StringLiteral Name;
+  StringRef Name;
   unsigned Max;
   unsigned Default;
   unsigned Shift;
@@ -93,12 +93,12 @@ StringRef getHwreg(uint64_t Encoding, const MCSubtargetInfo &STI);
 
 namespace MTBUFFormat {
 
-extern StringLiteral const DfmtSymbolic[];
-extern StringLiteral const NfmtSymbolicGFX10[];
-extern StringLiteral const NfmtSymbolicSICI[];
-extern StringLiteral const NfmtSymbolicVI[];
-extern StringLiteral const UfmtSymbolicGFX10[];
-extern StringLiteral const UfmtSymbolicGFX11[];
+extern StringRef const DfmtSymbolic[];
+extern StringRef const NfmtSymbolicGFX10[];
+extern StringRef const NfmtSymbolicSICI[];
+extern StringRef const NfmtSymbolicVI[];
+extern StringRef const UfmtSymbolicGFX10[];
+extern StringRef const UfmtSymbolicGFX11[];
 extern unsigned const DfmtNfmt2UFmtGFX10[];
 extern unsigned const DfmtNfmt2UFmtGFX11[];
 
@@ -119,7 +119,7 @@ extern const char* const IdSymbolic[];
 namespace UCVersion {
 
 struct GFXVersion {
-  StringLiteral Symbol;
+  StringRef Symbol;
   unsigned Code;
 };
 
diff --git a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
index 319ada3b27bd5..1cca7a339a6f3 100644
--- a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
@@ -1752,7 +1752,7 @@ unsigned encodeFieldSaSdst(unsigned SaSdst) {
 namespace Exp {
 
 struct ExpTgt {
-  StringLiteral Name;
+  StringRef Name;
   unsigned Tgt;
   unsigned MaxIndex;
 };
@@ -1839,7 +1839,7 @@ StringRef getDfmtName(unsigned Id) {
   return DfmtSymbolic[Id];
 }
 
-static StringLiteral const *getNfmtLookupTable(const MCSubtargetInfo &STI) {
+static StringRef const *getNfmtLookupTable(const MCSubtargetInfo &STI) {
   if (isSI(STI) || isCI(STI))
     return NfmtSymbolicSICI;
   if (isVI(STI) || isGFX9(STI))
diff --git a/llvm/lib/Target/AMDGPU/Utils/AMDKernelCodeTUtils.cpp b/llvm/lib/Target/AMDGPU/Utils/AMDKernelCodeTUtils.cpp
index 99ea929ea93fe..9eadfe4ad4084 100644
--- a/llvm/lib/Target/AMDGPU/Utils/AMDKernelCodeTUtils.cpp
+++ b/llvm/lib/Target/AMDGPU/Utils/AMDKernelCodeTUtils.cpp
@@ -163,8 +163,8 @@ GEN_HAS_MEMBER(wavefront_size)
 GEN_HAS_MEMBER(call_convention)
 GEN_HAS_MEMBER(runtime_loader_kernel_symbol)
 
-static ArrayRef get_amd_kernel_code_t_FldNames() {
-  static constexpr StringLiteral const Table[] = {
+static ArrayRef get_amd_kernel_code_t_FldNames() {
+  static constexpr StringRef const Table[] = {
       "", // not found placeholder
 #define RECORD(name, altName, print, parse) #name
 #include "Utils/AMDKernelCodeTInfo.h"
@@ -173,8 +173,8 @@ static ArrayRef get_amd_kernel_code_t_FldNames() {
   return ArrayRef(Table);
 }
 
-static ArrayRef get_amd_kernel_code_t_FldAltNames() {
-  static constexpr StringLiteral const Table[] = {
+static ArrayRef get_amd_kernel_code_t_FldAltNames() {
+  static constexpr StringRef const Table[] = {
       "", // not found placeholder
 #define RECORD(name, altName, print, parse) #altName
 #include "Utils/AMDKernelCodeTInfo.h"
@@ -203,8 +203,8 @@ static ArrayRef getMCExprIndexTable() {
   return ArrayRef(Table);
 }
 
-static StringMap createIndexMap(ArrayRef names,
-                                     ArrayRef altNames) {
+static StringMap createIndexMap(ArrayRef names,
+                                     ArrayRef altNames) {
   StringMap map;
   assert(names.size() == altNames.size());
   for (unsigned i = 0; i < names.size(); ++i) {
diff --git a/llvm/lib/Target/DirectX/DXILOpBuilder.cpp b/llvm/lib/Target/DirectX/DXILOpBuilder.cpp
index 9f88ccd7a7b7d..88f8417ab8c9c 100644
--- a/llvm/lib/Target/DirectX/DXILOpBuilder.cpp
+++ b/llvm/lib/Target/DirectX/DXILOpBuilder.cpp
@@ -19,7 +19,7 @@
 using namespace llvm;
 using namespace llvm::dxil;
 
-constexpr StringLiteral DXILOpNamePrefix = "dx.op.";
+constexpr StringRef DXILOpNamePrefix = "dx.op.";
 
 namespace {
 enum OverloadKind : uint16_t {
diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86InstComments.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86InstComments.cpp
index 681d0dab37d09..77d64170f1682 100644
--- a/llvm/lib/Target/X86/MCTargetDesc/X86InstComments.cpp
+++ b/llvm/lib/Target/X86/MCTargetDesc/X86InstComments.cpp
@@ -653,7 +653,7 @@ static bool printFMAComments(const MCInst *MI, raw_ostream &OS,
 // inputs to the binary function. This table was taken from
 // https://gist.github.com/dougallj/81a80cd381988466c4e1c4889ecac95b#file-2-x86-base-txt
 // with slight massaging.
-constexpr StringLiteral TernlogFunctions[] = {
+constexpr StringRef TernlogFunctions[] = {
     "0",
     "~(a | b | c)",
     "c & ~(a | b)",
@@ -1014,15 +1014,9 @@ static bool printFPCLASSComments(const MCInst *MI, raw_ostream &OS,
   if (Categories == 0) {
     OS << "false";
   } else {
-    static constexpr StringLiteral CategoryNames[] = {
-      "QuietNaN",
-      "PositiveZero",
-      "NegativeZero",
-      "PositiveInfinity",
-      "NegativeInfinity",
-      "Subnormal",
-      "Negative",
-      "SignalingNaN",
+    static constexpr StringRef CategoryNames[] = {
+        "QuietNaN",         "PositiveZero", "NegativeZero", "PositiveInfinity",
+        "NegativeInfinity", "Subnormal",    "Negative",     "SignalingNaN",
     };
     bool Conjoin = false;
     for (size_t I = 0, E = std::size(CategoryNames); I != E; ++I) {
diff --git a/llvm/lib/Target/X86/X86InsertPrefetch.cpp b/llvm/lib/Target/X86/X86InsertPrefetch.cpp
index 953b755a0ca4c..8f8a54161e648 100644
--- a/llvm/lib/Target/X86/X86InsertPrefetch.cpp
+++ b/llvm/lib/Target/X86/X86InsertPrefetch.cpp
@@ -113,7 +113,7 @@ bool X86InsertPrefetch::findPrefetchInfo(const FunctionSamples *TopSamples,
   if (FunctionSamples::UseMD5)
     return false;
 
-  static constexpr std::pair HintTypes[] = {
+  static constexpr std::pair HintTypes[] = {
       {"_nta_", X86::PREFETCHNTA},
       {"_t0_", X86::PREFETCHT0},
       {"_t1_", X86::PREFETCHT1},
diff --git a/llvm/lib/TargetParser/PPCTargetParser.cpp b/llvm/lib/TargetParser/PPCTargetParser.cpp
index 422d758c772e1..4a837a6e91ef9 100644
--- a/llvm/lib/TargetParser/PPCTargetParser.cpp
+++ b/llvm/lib/TargetParser/PPCTargetParser.cpp
@@ -19,7 +19,7 @@ namespace llvm {
 namespace PPC {
 
 struct CPUInfo {
-  StringLiteral Name;
+  StringRef Name;
   // FIXME: add the features field for this CPU.
 };
 
diff --git a/llvm/lib/TargetParser/RISCVISAInfo.cpp b/llvm/lib/TargetParser/RISCVISAInfo.cpp
index d6e1eac0d85af..497ce0e75873f 100644
--- a/llvm/lib/TargetParser/RISCVISAInfo.cpp
+++ b/llvm/lib/TargetParser/RISCVISAInfo.cpp
@@ -35,8 +35,8 @@ struct RISCVSupportedExtension {
 };
 
 struct RISCVProfile {
-  StringLiteral Name;
-  StringLiteral MArch;
+  StringRef Name;
+  StringRef MArch;
 
   bool operator<(const RISCVProfile &RHS) const {
     return StringRef(Name) < StringRef(RHS.Name);
@@ -741,9 +741,9 @@ Error RISCVISAInfo::checkDependency() {
   bool HasVector = Exts.count("zve32x") != 0;
   bool HasZvl = MinVLen != 0;
   bool HasZcmt = Exts.count("zcmt") != 0;
-  static constexpr StringLiteral XqciExts[] = {
-      {"xqcia"},  {"xqciac"},  {"xqcicli"}, {"xqcicm"},
-      {"xqcics"}, {"xqcicsr"}, {"xqcilsm"}, {"xqcisls"}};
+  static constexpr StringRef XqciExts[] = {{"xqcia"},   {"xqciac"}, {"xqcicli"},
+                                           {"xqcicm"},  {"xqcics"}, {"xqcicsr"},
+                                           {"xqcilsm"}, {"xqcisls"}};
 
   if (HasI && HasE)
     return getIncompatibleError("i", "e");
@@ -782,7 +782,7 @@ Error RISCVISAInfo::checkDependency() {
 }
 
 struct ImpliedExtsEntry {
-  StringLiteral Name;
+  StringRef Name;
   const char *ImpliedExt;
 
   bool operator<(const ImpliedExtsEntry &Other) const {
@@ -846,7 +846,7 @@ void RISCVISAInfo::updateImplication() {
   }
 }
 
-static constexpr StringLiteral CombineIntoExts[] = {
+static constexpr StringRef CombineIntoExts[] = {
     {"zk"},    {"zkn"},  {"zks"},   {"zvkn"},  {"zvknc"},
     {"zvkng"}, {"zvks"}, {"zvksc"}, {"zvksg"},
 };
@@ -1012,7 +1012,7 @@ std::string RISCVISAInfo::getTargetFeatureForExtension(StringRef Ext) {
 }
 
 struct RISCVExtBit {
-  const StringLiteral ext;
+  const StringRef ext;
   uint8_t groupid;
   uint8_t bitpos;
 };
diff --git a/llvm/lib/TargetParser/TargetParser.cpp b/llvm/lib/TargetParser/TargetParser.cpp
index 02295fdb0ecd0..2b12e2c0fd4e1 100644
--- a/llvm/lib/TargetParser/TargetParser.cpp
+++ b/llvm/lib/TargetParser/TargetParser.cpp
@@ -21,8 +21,8 @@ using namespace AMDGPU;
 namespace {
 
 struct GPUInfo {
-  StringLiteral Name;
-  StringLiteral CanonicalName;
+  StringRef Name;
+  StringRef CanonicalName;
   AMDGPU::GPUKind Kind;
   unsigned Features;
 };
diff --git a/llvm/lib/TargetParser/X86TargetParser.cpp b/llvm/lib/TargetParser/X86TargetParser.cpp
index e4b7ed7cf9b61..71684a20fd9c5 100644
--- a/llvm/lib/TargetParser/X86TargetParser.cpp
+++ b/llvm/lib/TargetParser/X86TargetParser.cpp
@@ -23,7 +23,7 @@ namespace {
 using FeatureBitset = Bitset;
 
 struct ProcInfo {
-  StringLiteral Name;
+  StringRef Name;
   X86::CPUKind Kind;
   unsigned KeyFeature;
   FeatureBitset Features;
@@ -32,7 +32,7 @@ struct ProcInfo {
 };
 
 struct FeatureInfo {
-  StringLiteral NameWithPlus;
+  StringRef NameWithPlus;
   FeatureBitset ImpliedFeatures;
 
   StringRef getName(bool WithPlus = false) const {
diff --git a/llvm/lib/TextAPI/Utils.cpp b/llvm/lib/TextAPI/Utils.cpp
index 68d73eac86691..595b982c0982a 100644
--- a/llvm/lib/TextAPI/Utils.cpp
+++ b/llvm/lib/TextAPI/Utils.cpp
@@ -158,7 +158,7 @@ bool llvm::MachO::isPrivateLibrary(StringRef Path, bool IsSymLink) {
   return false;
 }
 
-static StringLiteral RegexMetachars = "()^$|+.[]\\{}";
+static StringRef RegexMetachars = "()^$|+.[]\\{}";
 
 llvm::Expected llvm::MachO::createRegexFromGlob(StringRef Glob) {
   SmallString<128> RegexString("^");
diff --git a/llvm/lib/Transforms/HipStdPar/HipStdPar.cpp b/llvm/lib/Transforms/HipStdPar/HipStdPar.cpp
index 92042ddab38dc..fb741420be7b2 100644
--- a/llvm/lib/Transforms/HipStdPar/HipStdPar.cpp
+++ b/llvm/lib/Transforms/HipStdPar/HipStdPar.cpp
@@ -230,46 +230,45 @@ PreservedAnalyses
   return PreservedAnalyses::none();
 }
 
-static constexpr std::pair ReplaceMap[]{
-  {"aligned_alloc",             "__hipstdpar_aligned_alloc"},
-  {"calloc",                    "__hipstdpar_calloc"},
-  {"free",                      "__hipstdpar_free"},
-  {"malloc",                    "__hipstdpar_malloc"},
-  {"memalign",                  "__hipstdpar_aligned_alloc"},
-  {"posix_memalign",            "__hipstdpar_posix_aligned_alloc"},
-  {"realloc",                   "__hipstdpar_realloc"},
-  {"reallocarray",              "__hipstdpar_realloc_array"},
-  {"_ZdaPv",                    "__hipstdpar_operator_delete"},
-  {"_ZdaPvm",                   "__hipstdpar_operator_delete_sized"},
-  {"_ZdaPvSt11align_val_t",     "__hipstdpar_operator_delete_aligned"},
-  {"_ZdaPvmSt11align_val_t",    "__hipstdpar_operator_delete_aligned_sized"},
-  {"_ZdlPv",                    "__hipstdpar_operator_delete"},
-  {"_ZdlPvm",                   "__hipstdpar_operator_delete_sized"},
-  {"_ZdlPvSt11align_val_t",     "__hipstdpar_operator_delete_aligned"},
-  {"_ZdlPvmSt11align_val_t",    "__hipstdpar_operator_delete_aligned_sized"},
-  {"_Znam",                     "__hipstdpar_operator_new"},
-  {"_ZnamRKSt9nothrow_t",       "__hipstdpar_operator_new_nothrow"},
-  {"_ZnamSt11align_val_t",      "__hipstdpar_operator_new_aligned"},
-  {"_ZnamSt11align_val_tRKSt9nothrow_t",
-                                "__hipstdpar_operator_new_aligned_nothrow"},
-
-  {"_Znwm",                     "__hipstdpar_operator_new"},
-  {"_ZnwmRKSt9nothrow_t",       "__hipstdpar_operator_new_nothrow"},
-  {"_ZnwmSt11align_val_t",      "__hipstdpar_operator_new_aligned"},
-  {"_ZnwmSt11align_val_tRKSt9nothrow_t",
-                                "__hipstdpar_operator_new_aligned_nothrow"},
-  {"__builtin_calloc",          "__hipstdpar_calloc"},
-  {"__builtin_free",            "__hipstdpar_free"},
-  {"__builtin_malloc",          "__hipstdpar_malloc"},
-  {"__builtin_operator_delete", "__hipstdpar_operator_delete"},
-  {"__builtin_operator_new",    "__hipstdpar_operator_new"},
-  {"__builtin_realloc",         "__hipstdpar_realloc"},
-  {"__libc_calloc",             "__hipstdpar_calloc"},
-  {"__libc_free",               "__hipstdpar_free"},
-  {"__libc_malloc",             "__hipstdpar_malloc"},
-  {"__libc_memalign",           "__hipstdpar_aligned_alloc"},
-  {"__libc_realloc",            "__hipstdpar_realloc"}
-};
+static constexpr std::pair ReplaceMap[]{
+    {"aligned_alloc", "__hipstdpar_aligned_alloc"},
+    {"calloc", "__hipstdpar_calloc"},
+    {"free", "__hipstdpar_free"},
+    {"malloc", "__hipstdpar_malloc"},
+    {"memalign", "__hipstdpar_aligned_alloc"},
+    {"posix_memalign", "__hipstdpar_posix_aligned_alloc"},
+    {"realloc", "__hipstdpar_realloc"},
+    {"reallocarray", "__hipstdpar_realloc_array"},
+    {"_ZdaPv", "__hipstdpar_operator_delete"},
+    {"_ZdaPvm", "__hipstdpar_operator_delete_sized"},
+    {"_ZdaPvSt11align_val_t", "__hipstdpar_operator_delete_aligned"},
+    {"_ZdaPvmSt11align_val_t", "__hipstdpar_operator_delete_aligned_sized"},
+    {"_ZdlPv", "__hipstdpar_operator_delete"},
+    {"_ZdlPvm", "__hipstdpar_operator_delete_sized"},
+    {"_ZdlPvSt11align_val_t", "__hipstdpar_operator_delete_aligned"},
+    {"_ZdlPvmSt11align_val_t", "__hipstdpar_operator_delete_aligned_sized"},
+    {"_Znam", "__hipstdpar_operator_new"},
+    {"_ZnamRKSt9nothrow_t", "__hipstdpar_operator_new_nothrow"},
+    {"_ZnamSt11align_val_t", "__hipstdpar_operator_new_aligned"},
+    {"_ZnamSt11align_val_tRKSt9nothrow_t",
+     "__hipstdpar_operator_new_aligned_nothrow"},
+
+    {"_Znwm", "__hipstdpar_operator_new"},
+    {"_ZnwmRKSt9nothrow_t", "__hipstdpar_operator_new_nothrow"},
+    {"_ZnwmSt11align_val_t", "__hipstdpar_operator_new_aligned"},
+    {"_ZnwmSt11align_val_tRKSt9nothrow_t",
+     "__hipstdpar_operator_new_aligned_nothrow"},
+    {"__builtin_calloc", "__hipstdpar_calloc"},
+    {"__builtin_free", "__hipstdpar_free"},
+    {"__builtin_malloc", "__hipstdpar_malloc"},
+    {"__builtin_operator_delete", "__hipstdpar_operator_delete"},
+    {"__builtin_operator_new", "__hipstdpar_operator_new"},
+    {"__builtin_realloc", "__hipstdpar_realloc"},
+    {"__libc_calloc", "__hipstdpar_calloc"},
+    {"__libc_free", "__hipstdpar_free"},
+    {"__libc_malloc", "__hipstdpar_malloc"},
+    {"__libc_memalign", "__hipstdpar_aligned_alloc"},
+    {"__libc_realloc", "__hipstdpar_realloc"}};
 
 PreservedAnalyses
 HipStdParAllocationInterpositionPass::run(Module &M, ModuleAnalysisManager&) {
diff --git a/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp
index 417d721d049e7..598c5069a496a 100644
--- a/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp
@@ -131,8 +131,8 @@ static cl::opt ClPropagateNonFTConstStoresAsFT(
         "For debugging purposes only"),
     cl::Hidden);
 
-constexpr StringLiteral kNsanModuleCtorName("nsan.module_ctor");
-constexpr StringLiteral kNsanInitName("__nsan_init");
+constexpr StringRef kNsanModuleCtorName("nsan.module_ctor");
+constexpr StringRef kNsanInitName("__nsan_init");
 
 // The following values must be kept in sync with the runtime.
 constexpr int kShadowScale = 2;
diff --git a/llvm/lib/WindowsManifest/WindowsManifestMerger.cpp b/llvm/lib/WindowsManifest/WindowsManifestMerger.cpp
index b59b666ce04f9..bb0611fd8a549 100644
--- a/llvm/lib/WindowsManifest/WindowsManifestMerger.cpp
+++ b/llvm/lib/WindowsManifest/WindowsManifestMerger.cpp
@@ -56,7 +56,7 @@ class WindowsManifestMerger::WindowsManifestMergerImpl {
 
 #if LLVM_ENABLE_LIBXML2
 
-static constexpr std::pair MtNsHrefsPrefixes[] = {
+static constexpr std::pair MtNsHrefsPrefixes[] = {
     {"urn:schemas-microsoft-com:asm.v1", "ms_asmv1"},
     {"urn:schemas-microsoft-com:asm.v2", "ms_asmv2"},
     {"urn:schemas-microsoft-com:asm.v3", "ms_asmv3"},
diff --git a/llvm/tools/llvm-exegesis/lib/Analysis.cpp b/llvm/tools/llvm-exegesis/lib/Analysis.cpp
index be10c32cf08d5..f8712b4dde716 100644
--- a/llvm/tools/llvm-exegesis/lib/Analysis.cpp
+++ b/llvm/tools/llvm-exegesis/lib/Analysis.cpp
@@ -91,7 +91,7 @@ static void writeMeasurementValue(raw_ostream &OS, const double Value) {
   static constexpr auto SerializationLen = MaxDigitCount + DecimalSeparatorLen;
 
   // WARNING: when changing the format, also adjust the small-size estimate ^.
-  static constexpr StringLiteral SimpleFloatFormat = StringLiteral("{0:F}");
+  static constexpr StringRef SimpleFloatFormat = StringRef("{0:F}");
 
   writeEscaped(
       OS, formatv(SimpleFloatFormat.data(), Value).sstr());
diff --git a/llvm/tools/llvm-exegesis/lib/LlvmState.h b/llvm/tools/llvm-exegesis/lib/LlvmState.h
index 761472b2de2a2..b8aa3abe714c2 100644
--- a/llvm/tools/llvm-exegesis/lib/LlvmState.h
+++ b/llvm/tools/llvm-exegesis/lib/LlvmState.h
@@ -26,7 +26,7 @@
 #include 
 #include 
 
-static constexpr llvm::StringLiteral kNoRegister("%noreg");
+static constexpr llvm::StringRef kNoRegister("%noreg");
 
 namespace llvm {
 namespace exegesis {
diff --git a/llvm/tools/llvm-readtapi/DiffEngine.cpp b/llvm/tools/llvm-readtapi/DiffEngine.cpp
index 6434c871fa64b..4ef9276d3471c 100644
--- a/llvm/tools/llvm-readtapi/DiffEngine.cpp
+++ b/llvm/tools/llvm-readtapi/DiffEngine.cpp
@@ -62,10 +62,10 @@ DiffScalarVal::print(raw_ostream &OS,
 
 } // end namespace llvm
 
-StringLiteral SymScalar::getSymbolNamePrefix(MachO::EncodeKind Kind) {
+StringRef SymScalar::getSymbolNamePrefix(MachO::EncodeKind Kind) {
   switch (Kind) {
   case MachO::EncodeKind::GlobalSymbol:
-    return StringLiteral("");
+    return StringRef("");
   case MachO::EncodeKind::ObjectiveCClass:
     return ObjC2MetaClassNamePrefix;
   case MachO::EncodeKind ::ObjectiveCClassEHType:
diff --git a/llvm/tools/llvm-readtapi/DiffEngine.h b/llvm/tools/llvm-readtapi/DiffEngine.h
index 58b0c1b3ea9cb..30686205f9cc5 100644
--- a/llvm/tools/llvm-readtapi/DiffEngine.h
+++ b/llvm/tools/llvm-readtapi/DiffEngine.h
@@ -94,7 +94,7 @@ class SymScalar {
   /// The order is the file from which the diff is found.
   InterfaceInputOrder Order;
   const MachO::Symbol *Val;
-  StringLiteral getSymbolNamePrefix(MachO::EncodeKind Kind);
+  StringRef getSymbolNamePrefix(MachO::EncodeKind Kind);
 };
 
 class DiffStrVec : public AttributeDiff {
diff --git a/llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp b/llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp
index 316c74876025a..71dfd37faa6a3 100644
--- a/llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp
+++ b/llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp
@@ -37,15 +37,11 @@ static bool shouldKeepDebugNamedMetadata(NamedMDNode &MD) {
 
 // Named metadata with simple list-like behavior, so that it's valid to remove
 // operands individually.
-static constexpr StringLiteral ListNamedMetadata[] = {
-  "llvm.module.flags",
-  "llvm.ident",
-  "opencl.spir.version",
-  "opencl.ocl.version",
-  "opencl.used.extensions",
-  "opencl.used.optional.core.features",
-  "opencl.compiler.options"
-};
+static constexpr StringRef ListNamedMetadata[] = {
+    "llvm.module.flags",      "llvm.ident",
+    "opencl.spir.version",    "opencl.ocl.version",
+    "opencl.used.extensions", "opencl.used.optional.core.features",
+    "opencl.compiler.options"};
 
 /// Remove unneeded arguments to named metadata.
 static void reduceNamedMetadataOperands(Oracle &O, ReducerWorkItem &WorkItem) {
diff --git a/llvm/tools/opt/optdriver.cpp b/llvm/tools/opt/optdriver.cpp
index 8ef249e1708b9..7618b12776827 100644
--- a/llvm/tools/opt/optdriver.cpp
+++ b/llvm/tools/opt/optdriver.cpp
@@ -318,7 +318,7 @@ struct TimeTracerRAII {
 // TODO: use a codegen version of PassRegistry.def/PassBuilder::is*Pass() once
 // it exists.
 static bool shouldPinPassToLegacyPM(StringRef Pass) {
-  static constexpr StringLiteral PassNameExactToIgnore[] = {
+  static constexpr StringRef PassNameExactToIgnore[] = {
       "nvvm-reflect",
       "nvvm-intr-range",
       "amdgpu-simplifylib",
@@ -335,13 +335,13 @@ static bool shouldPinPassToLegacyPM(StringRef Pass) {
   if (llvm::is_contained(PassNameExactToIgnore, Pass))
     return false;
 
-  static constexpr StringLiteral PassNamePrefix[] = {
+  static constexpr StringRef PassNamePrefix[] = {
       "x86-",    "xcore-", "wasm-",  "systemz-", "ppc-",    "nvvm-",
       "nvptx-",  "mips-",  "lanai-", "hexagon-", "bpf-",    "avr-",
       "thumb2-", "arm-",   "si-",    "gcn-",     "amdgpu-", "aarch64-",
       "amdgcn-", "polly-", "riscv-", "dxil-"};
-  static constexpr StringLiteral PassNameContain[] = {"-eh-prepare"};
-  static constexpr StringLiteral PassNameExact[] = {
+  static constexpr StringRef PassNameContain[] = {"-eh-prepare"};
+  static constexpr StringRef PassNameExact[] = {
       "safe-stack",
       "cost-model",
       "codegenprepare",
diff --git a/llvm/unittests/ADT/ScopedHashTableTest.cpp b/llvm/unittests/ADT/ScopedHashTableTest.cpp
index 8ce5c7cecf998..8b83734e5e12f 100644
--- a/llvm/unittests/ADT/ScopedHashTableTest.cpp
+++ b/llvm/unittests/ADT/ScopedHashTableTest.cpp
@@ -14,7 +14,6 @@
 
 using ::llvm::ScopedHashTable;
 using ::llvm::ScopedHashTableScope;
-using ::llvm::StringLiteral;
 using ::llvm::StringRef;
 
 using ::testing::Test;
@@ -26,11 +25,11 @@ class ScopedHashTableTest : public Test {
   ScopedHashTable symbolTable{};
   ScopedHashTableScope globalScope{symbolTable};
 
-  static constexpr StringLiteral kGlobalName = "global";
-  static constexpr StringLiteral kGlobalValue = "gvalue";
-  static constexpr StringLiteral kLocalName = "local";
-  static constexpr StringLiteral kLocalValue = "lvalue";
-  static constexpr StringLiteral kLocalValue2 = "lvalue2";
+  static constexpr StringRef kGlobalName = "global";
+  static constexpr StringRef kGlobalValue = "gvalue";
+  static constexpr StringRef kLocalName = "local";
+  static constexpr StringRef kLocalValue = "lvalue";
+  static constexpr StringRef kLocalValue2 = "lvalue2";
 };
 
 TEST_F(ScopedHashTableTest, AccessWithNoActiveScope) {
diff --git a/llvm/unittests/ADT/StringRefTest.cpp b/llvm/unittests/ADT/StringRefTest.cpp
index ec9cdc197597d..a69704927abe8 100644
--- a/llvm/unittests/ADT/StringRefTest.cpp
+++ b/llvm/unittests/ADT/StringRefTest.cpp
@@ -57,7 +57,7 @@ TEST(StringRefTest, EmptyInitializerList) {
 
 TEST(StringRefTest, Iteration) {
   StringRef S("hello");
-  constexpr StringLiteral CS("hello");
+  constexpr StringRef CS("hello");
 
   // Note: Cannot use literal strings in equal() as iteration over a literal
   // string includes the null terminator.
@@ -1107,7 +1107,7 @@ TEST(StringRefTest, DropWhileUntil) {
   EXPECT_EQ("", Taken);
 }
 
-TEST(StringRefTest, StringLiteral) {
+TEST(StringRefTest, StringRef) {
   constexpr StringRef StringRefs[] = {"Foo", "Bar"};
   EXPECT_EQ(StringRef("Foo"), StringRefs[0]);
   EXPECT_EQ(3u, (std::integral_constant::value));
@@ -1115,7 +1115,7 @@ TEST(StringRefTest, StringLiteral) {
             (std::integral_constant::value));
   EXPECT_EQ(StringRef("Bar"), StringRefs[1]);
 
-  constexpr StringLiteral Strings[] = {"Foo", "Bar"};
+  constexpr StringRef Strings[] = {"Foo", "Bar"};
   EXPECT_EQ(StringRef("Foo"), Strings[0]);
   EXPECT_EQ(3u, (std::integral_constant::value));
   EXPECT_EQ(false, (std::integral_constant::value));
diff --git a/llvm/unittests/ADT/StringSwitchTest.cpp b/llvm/unittests/ADT/StringSwitchTest.cpp
index 2ce6cdca8d36a..95c6b9ffa719e 100644
--- a/llvm/unittests/ADT/StringSwitchTest.cpp
+++ b/llvm/unittests/ADT/StringSwitchTest.cpp
@@ -157,7 +157,7 @@ TEST(StringSwitchTest, Cases) {
 
   auto Translate = [](StringRef S) {
     return llvm::StringSwitch(S)
-        .Cases(StringLiteral::withInnerNUL("wind\0ws"), "win32", "winnt",
+        .Cases(StringRef::withInnerNUL("wind\0ws"), "win32", "winnt",
                OSType::Windows)
         .Cases("linux", "unix", "*nix", "posix", OSType::Linux)
         .Default(OSType::Unknown);
@@ -184,7 +184,7 @@ TEST(StringSwitchTest, CasesLower) {
 
   auto Translate = [](StringRef S) {
     return llvm::StringSwitch(S)
-        .CasesLower(StringLiteral::withInnerNUL("wind\0ws"), "win32", "winnt",
+        .CasesLower(StringRef::withInnerNUL("wind\0ws"), "win32", "winnt",
                     OSType::Windows)
         .CasesLower("linux", "unix", "*nix", "posix", OSType::Linux)
         .Default(OSType::Unknown);
diff --git a/llvm/unittests/ADT/TwineTest.cpp b/llvm/unittests/ADT/TwineTest.cpp
index d45805f4db7a3..771453e174705 100644
--- a/llvm/unittests/ADT/TwineTest.cpp
+++ b/llvm/unittests/ADT/TwineTest.cpp
@@ -30,7 +30,7 @@ TEST(TwineTest, Construction) {
   EXPECT_EQ("hi", Twine(StringRef("hi")).str());
   EXPECT_EQ("hi", Twine(StringRef(std::string("hi"))).str());
   EXPECT_EQ("hi", Twine(StringRef("hithere", 2)).str());
-  EXPECT_EQ("hi", Twine(StringLiteral("hi")).str());
+  EXPECT_EQ("hi", Twine(StringRef("hi")).str());
   EXPECT_EQ("hi", Twine(SmallString<4>("hi")).str());
   EXPECT_EQ("hi", Twine(formatv("{0}", "hi")).str());
   EXPECT_EQ("hi", Twine(std::string_view("hi")).str());
@@ -98,8 +98,7 @@ TEST(TwineTest, toNullTerminatedStringRef) {
   EXPECT_EQ(0,
            *Twine(StringRef("hello")).toNullTerminatedStringRef(storage).end());
   EXPECT_EQ(
-      0,
-      *Twine(StringLiteral("hello")).toNullTerminatedStringRef(storage).end());
+      0, *Twine(StringRef("hello")).toNullTerminatedStringRef(storage).end());
   EXPECT_EQ(0, *Twine(SmallString<11>("hello"))
                     .toNullTerminatedStringRef(storage)
                     .end());
@@ -109,7 +108,7 @@ TEST(TwineTest, toNullTerminatedStringRef) {
 }
 
 TEST(TwineTest, isSingleStringLiteral) {
-  EXPECT_TRUE(Twine(StringLiteral("hi")).isSingleStringLiteral());
+  EXPECT_TRUE(Twine(StringRef("hi")).isSingleStringLiteral());
   EXPECT_FALSE(Twine("hi").isSingleStringLiteral());
   EXPECT_FALSE(Twine(StringRef("hi")).isSingleStringLiteral());
 }
diff --git a/llvm/unittests/IR/ModuleTest.cpp b/llvm/unittests/IR/ModuleTest.cpp
index 36c356730d27a..a82394696cdd5 100644
--- a/llvm/unittests/IR/ModuleTest.cpp
+++ b/llvm/unittests/IR/ModuleTest.cpp
@@ -360,7 +360,7 @@ define void @Foo1() {
                                                    Err, Context);
   ASSERT_TRUE(M1.get());
 
-  StringLiteral M2Str = R"(
+  StringRef M2Str = R"(
 ; ModuleID = ''
 source_filename = ""
 
diff --git a/llvm/unittests/Support/BinaryStreamTest.cpp b/llvm/unittests/Support/BinaryStreamTest.cpp
index 70cd4036fb2a6..1c587fb819caa 100644
--- a/llvm/unittests/Support/BinaryStreamTest.cpp
+++ b/llvm/unittests/Support/BinaryStreamTest.cpp
@@ -459,8 +459,8 @@ TEST_F(BinaryStreamTest, FixedStreamArrayIteratorArrow) {
 
 // Test that VarStreamArray works correctly.
 TEST_F(BinaryStreamTest, VarStreamArray) {
-  StringLiteral Strings("1. Test2. Longer Test3. Really Long Test4. Super "
-                        "Extra Longest Test Of All");
+  StringRef Strings("1. Test2. Longer Test3. Really Long Test4. Super "
+                    "Extra Longest Test Of All");
   ArrayRef StringBytes(
       reinterpret_cast(Strings.data()), Strings.size());
   initializeInput(StringBytes, 1);
diff --git a/llvm/unittests/Support/DJBTest.cpp b/llvm/unittests/Support/DJBTest.cpp
index cc8a3d0000090..2567e78020d9f 100644
--- a/llvm/unittests/Support/DJBTest.cpp
+++ b/llvm/unittests/Support/DJBTest.cpp
@@ -14,8 +14,8 @@ using namespace llvm;
 
 TEST(DJBTest, caseFolding) {
   struct TestCase {
-    StringLiteral One;
-    StringLiteral Two;
+    StringRef One;
+    StringRef Two;
   };
 
   static constexpr TestCase Tests[] = {
@@ -57,7 +57,7 @@ TEST(DJBTest, caseFolding) {
 
 TEST(DJBTest, knownValuesLowerCase) {
   struct TestCase {
-    StringLiteral Text;
+    StringRef Text;
     uint32_t Hash;
   };
   static constexpr TestCase Tests[] = {
diff --git a/llvm/unittests/Support/FormatVariadicTest.cpp b/llvm/unittests/Support/FormatVariadicTest.cpp
index 03102c96d4662..7a50345cbb3c0 100644
--- a/llvm/unittests/Support/FormatVariadicTest.cpp
+++ b/llvm/unittests/Support/FormatVariadicTest.cpp
@@ -445,7 +445,7 @@ TEST(FormatVariadicTest, StringFormatting) {
   const char FooArray[] = "FooArray";
   const char *FooPtr = "FooPtr";
   llvm::StringRef FooRef("FooRef");
-  constexpr StringLiteral FooLiteral("FooLiteral");
+  constexpr StringRef FooLiteral("FooLiteral");
   std::string FooString("FooString");
   // 1. Test that we can print various types of strings.
   EXPECT_EQ(FooArray, formatv("{0}", FooArray).str());
diff --git a/llvm/unittests/Support/Path.cpp b/llvm/unittests/Support/Path.cpp
index 187f47d9cfe07..2c1d6de6a9e30 100644
--- a/llvm/unittests/Support/Path.cpp
+++ b/llvm/unittests/Support/Path.cpp
@@ -2007,7 +2007,7 @@ TEST_F(FileSystemTest, readNativeFile) {
 }
 
 TEST_F(FileSystemTest, readNativeFileToEOF) {
-  constexpr StringLiteral Content = "0123456789";
+  constexpr StringRef Content = "0123456789";
   createFileWithData(NonExistantFile, false, fs::CD_CreateNew, Content);
   FileRemover Cleanup(NonExistantFile);
   const auto &Read = [&](SmallVectorImpl &V,
@@ -2037,7 +2037,7 @@ TEST_F(FileSystemTest, readNativeFileToEOF) {
 
     // Check appending.
     {
-      constexpr StringLiteral Prefix = "prefix-";
+      constexpr StringRef Prefix = "prefix-";
       for (SmallVectorImpl *V : Vectors) {
         V->assign(Prefix.begin(), Prefix.end());
         ASSERT_THAT_ERROR(Read(*V, std::nullopt), Succeeded());
diff --git a/llvm/unittests/Telemetry/TelemetryTest.cpp b/llvm/unittests/Telemetry/TelemetryTest.cpp
index 6b37e89f16435..21718cbf92393 100644
--- a/llvm/unittests/Telemetry/TelemetryTest.cpp
+++ b/llvm/unittests/Telemetry/TelemetryTest.cpp
@@ -143,7 +143,7 @@ class TestStorageDestination : public Destination {
     return Error::success();
   }
 
-  StringLiteral name() const override { return "TestDestination"; }
+  StringRef name() const override { return "TestDestination"; }
 
 private:
   TestContext *CurrentContext;
diff --git a/llvm/utils/TableGen/Basic/CodeGenIntrinsics.cpp b/llvm/utils/TableGen/Basic/CodeGenIntrinsics.cpp
index 0846f66ea6452..d6d229cb8c028 100644
--- a/llvm/utils/TableGen/Basic/CodeGenIntrinsics.cpp
+++ b/llvm/utils/TableGen/Basic/CodeGenIntrinsics.cpp
@@ -162,7 +162,7 @@ static bool doesSuffixLookLikeMangledType(StringRef Suffix) {
     return true;
 
   // Match one of the named types.
-  static constexpr StringLiteral NamedTypes[] = {
+  static constexpr StringRef NamedTypes[] = {
       "isVoid", "Metadata", "f16",  "f32",     "f64",
       "f80",    "f128",     "bf16", "ppcf128", "x86amx"};
   return is_contained(NamedTypes, Suffix);
diff --git a/llvm/utils/TableGen/Basic/IntrinsicEmitter.cpp b/llvm/utils/TableGen/Basic/IntrinsicEmitter.cpp
index fc2b8908a35b8..efa63c4504509 100644
--- a/llvm/utils/TableGen/Basic/IntrinsicEmitter.cpp
+++ b/llvm/utils/TableGen/Basic/IntrinsicEmitter.cpp
@@ -223,7 +223,7 @@ void IntrinsicEmitter::EmitTargetInfo(const CodeGenIntrinsicTable &Ints,
   OS << R"(// Target mapping.
 #ifdef GET_INTRINSIC_TARGET_DATA
 struct IntrinsicTargetInfo {
-  StringLiteral Name;
+  StringRef Name;
   size_t Offset;
   size_t Count;
 };
@@ -240,7 +240,7 @@ static constexpr IntrinsicTargetInfo TargetInfos[] = {
 void IntrinsicEmitter::EmitIntrinsicToNameTable(
     const CodeGenIntrinsicTable &Ints, raw_ostream &OS) {
   // Built up a table of the intrinsic names.
-  constexpr StringLiteral NotIntrinsic = "not_intrinsic";
+  constexpr StringRef NotIntrinsic = "not_intrinsic";
   StringToOffsetTable Table;
   Table.GetOrAddStringOffset(NotIntrinsic);
   for (const auto &Int : Ints)
@@ -803,9 +803,9 @@ Intrinsic::getIntrinsicFor{}Builtin(StringRef TargetPrefix,
   // names to lookup into this table.
   OS << R"(
   struct TargetEntry {
-    StringLiteral TargetPrefix;
+    StringRef TargetPrefix;
     ArrayRef Names;
-    StringLiteral CommonPrefix;
+    StringRef CommonPrefix;
     bool operator<(StringRef RHS) const {
       return TargetPrefix < RHS;
     };
diff --git a/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp b/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp
index a81f2b53f2846..a0a2a8a3e8da8 100644
--- a/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp
+++ b/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp
@@ -42,7 +42,7 @@ std::string getMatchOpcodeForImmPredicate(const TreePredicateFn &Predicate) {
 }
 
 // GIMT_Encode2/4/8
-constexpr StringLiteral EncodeMacroName = "GIMT_Encode";
+constexpr StringRef EncodeMacroName = "GIMT_Encode";
 
 } // namespace
 
diff --git a/llvm/utils/TableGen/Common/GlobalISel/PatternParser.cpp b/llvm/utils/TableGen/Common/GlobalISel/PatternParser.cpp
index cb423ce142fb7..8d190885636d5 100644
--- a/llvm/utils/TableGen/Common/GlobalISel/PatternParser.cpp
+++ b/llvm/utils/TableGen/Common/GlobalISel/PatternParser.cpp
@@ -19,7 +19,7 @@
 
 namespace llvm {
 namespace gi {
-static constexpr StringLiteral MIFlagsEnumClassName = "MIFlagEnum";
+static constexpr StringRef MIFlagsEnumClassName = "MIFlagEnum";
 
 namespace {
 class PrettyStackTraceParse : public PrettyStackTraceEntry {
diff --git a/llvm/utils/TableGen/Common/GlobalISel/Patterns.h b/llvm/utils/TableGen/Common/GlobalISel/Patterns.h
index b0d47c381553c..d9104b8681cb5 100644
--- a/llvm/utils/TableGen/Common/GlobalISel/Patterns.h
+++ b/llvm/utils/TableGen/Common/GlobalISel/Patterns.h
@@ -65,9 +65,9 @@ struct VariadicPackTypeInfo {
 ///   - Special types, e.g. GITypeOf, Variadic arguments list.
 class PatternType {
 public:
-  static constexpr StringLiteral SpecialTyClassName = "GISpecialType";
-  static constexpr StringLiteral TypeOfClassName = "GITypeOf";
-  static constexpr StringLiteral VariadicClassName = "GIVariadic";
+  static constexpr StringRef SpecialTyClassName = "GISpecialType";
+  static constexpr StringRef TypeOfClassName = "GITypeOf";
+  static constexpr StringRef VariadicClassName = "GIVariadic";
 
   enum PTKind : uint8_t {
     PT_None,
@@ -553,7 +553,7 @@ class OperandTypeChecker {
 /// PatFragPattern.
 class PatFrag {
 public:
-  static constexpr StringLiteral ClassName = "GICombinePatFrag";
+  static constexpr StringRef ClassName = "GICombinePatFrag";
 
   enum ParamKind {
     PK_Root,
@@ -696,7 +696,7 @@ enum BuiltinKind {
 
 class BuiltinPattern : public InstructionPattern {
   struct BuiltinInfo {
-    StringLiteral DefName;
+    StringRef DefName;
     BuiltinKind Kind;
     unsigned NumOps;
     unsigned NumDefs;
@@ -708,7 +708,7 @@ class BuiltinPattern : public InstructionPattern {
   }};
 
 public:
-  static constexpr StringLiteral ClassName = "GIBuiltinInst";
+  static constexpr StringRef ClassName = "GIBuiltinInst";
 
   BuiltinPattern(const Record &Def, StringRef Name)
       : InstructionPattern(K_Builtin, Name), I(getBuiltinInfo(Def)) {}
diff --git a/llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp b/llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp
index 149ba7a1d9032..d3b90d3866390 100644
--- a/llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp
+++ b/llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp
@@ -78,9 +78,9 @@ cl::opt DebugTypeInfer("gicombiner-debug-typeinfer",
                              cl::desc("Print type inference debug logs"),
                              cl::cat(GICombinerEmitterCat));
 
-constexpr StringLiteral CXXCustomActionPrefix = "GICXXCustomAction_";
-constexpr StringLiteral CXXPredPrefix = "GICXXPred_MI_Predicate_";
-constexpr StringLiteral MatchDataClassName = "GIDefMatchData";
+constexpr StringRef CXXCustomActionPrefix = "GICXXCustomAction_";
+constexpr StringRef CXXPredPrefix = "GICXXPred_MI_Predicate_";
+constexpr StringRef MatchDataClassName = "GIDefMatchData";
 
 //===- CodeExpansions Helpers  --------------------------------------------===//
 
diff --git a/mlir/docs/ActionTracing.md b/mlir/docs/ActionTracing.md
index 984516d5c5e7e..bd6d589fc9878 100644
--- a/mlir/docs/ActionTracing.md
+++ b/mlir/docs/ActionTracing.md
@@ -62,8 +62,8 @@ public:
       : Base(irUnits) {}
   /// This tag should uniquely identify this action, it can be matched for filtering
   /// during processing.
-  static constexpr StringLiteral tag = "unique-tag-for-my-action";
-  static constexpr StringLiteral desc =
+  static constexpr StringRef tag = "unique-tag-for-my-action";
+  static constexpr StringRef desc =
       "This action will encapsulate a some very specific transformation";
 };
 ```
@@ -97,8 +97,8 @@ public:
       : Base(irUnits), count(count), padding(padding) {}
   /// This tag should uniquely identify this action, it can be matched for filtering
   /// during processing.
-  static constexpr StringLiteral tag = "unique-tag-for-my-action";
-  static constexpr StringLiteral desc =
+  static constexpr StringRef tag = "unique-tag-for-my-action";
+  static constexpr StringRef desc =
       "This action will encapsulate a some very specific transformation";
   /// Extra members can be carried by the Action
   int count;
diff --git a/mlir/examples/toy/Ch7/include/toy/Dialect.h b/mlir/examples/toy/Ch7/include/toy/Dialect.h
index 64094c3515915..feb204c3970ec 100644
--- a/mlir/examples/toy/Ch7/include/toy/Dialect.h
+++ b/mlir/examples/toy/Ch7/include/toy/Dialect.h
@@ -74,7 +74,7 @@ class StructType : public mlir::Type::TypeBase shape, Type elementType,
@@ -182,7 +182,7 @@ class SparseDnTensorHandleType
                                        TypeStorage>::Base;
   using Base::Base;
 
-  static constexpr StringLiteral name = "gpu.sparse.dntensor_handle";
+  static constexpr StringRef name = "gpu.sparse.dntensor_handle";
 };
 
 class SparseSpMatHandleType
@@ -192,7 +192,7 @@ class SparseSpMatHandleType
       typename Type::TypeBase::Base;
   using Base::Base;
 
-  static constexpr StringLiteral name = "gpu.sparse.spmat_handle";
+  static constexpr StringRef name = "gpu.sparse.spmat_handle";
 };
 
 class SparseSpGEMMOpHandleType
@@ -202,7 +202,7 @@ class SparseSpGEMMOpHandleType
                                        TypeStorage>::Base;
   using Base::Base;
 
-  static constexpr StringLiteral name = "gpu.sparse.spgemmop_handle";
+  static constexpr StringRef name = "gpu.sparse.spgemmop_handle";
 };
 
 } // namespace gpu
diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td
index 267389774bd5a..24991cde9e03a 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td
@@ -1190,8 +1190,8 @@ def LLVM_TargetFeaturesAttr : LLVM_Attr<"TargetFeatures", "target_features">
     static TargetFeaturesAttr featuresAt(Operation* op);
 
     /// Canonical name for this attribute within MLIR.
-    static constexpr StringLiteral getAttributeName() {
-      return StringLiteral("target_features");
+    static constexpr StringRef getAttributeName() {
+      return StringRef("target_features");
     }
   }];
 
diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td
index cdb5ab5220e4f..826ad72a9002f 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td
@@ -331,7 +331,7 @@ class LLVM_IntrOpBase {      \
   public:                                                                      \
     using Base::Base;                                                          \
-    static constexpr StringLiteral name = TypeName;                            \
+    static constexpr StringRef name = TypeName;                                \
   }
 
 DEFINE_TRIVIAL_LLVM_TYPE(LLVMVoidType, "llvm.void");
diff --git a/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td b/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td
index 71dac3ad39b7b..83e8018c0a133 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td
@@ -31,17 +31,17 @@ def ROCDL_Dialect : Dialect {
     /// Get the name of the attribute used to annotate external kernel
     /// functions.
     static StringRef getKernelFuncAttrName() { return "rocdl.kernel"; }
-    static constexpr ::llvm::StringLiteral getFlatWorkGroupSizeAttrName() {
-      return ::llvm::StringLiteral("rocdl.flat_work_group_size");
+    static constexpr ::llvm::StringRef getFlatWorkGroupSizeAttrName() {
+      return ::llvm::StringRef("rocdl.flat_work_group_size");
     }
-    static constexpr ::llvm::StringLiteral getReqdWorkGroupSizeAttrName() {
-      return ::llvm::StringLiteral("rocdl.reqd_work_group_size");
+    static constexpr ::llvm::StringRef getReqdWorkGroupSizeAttrName() {
+      return ::llvm::StringRef("rocdl.reqd_work_group_size");
     }
     /// MLIR's gpu-related infrastructure effectively assume uniform workgroup
     /// sizes, so this attribute defaults to "true" on `rocdl.kernel` functions.
     /// It is provided here to allow overriding this assumption.
-    static constexpr ::llvm::StringLiteral getUniformWorkGroupSizeAttrName() {
-      return ::llvm::StringLiteral("rocdl.uniform_work_group_size");
+    static constexpr ::llvm::StringRef getUniformWorkGroupSizeAttrName() {
+      return ::llvm::StringRef("rocdl.uniform_work_group_size");
     }
 
     /// The address space value that represents global memory.
diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgBase.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgBase.td
index 73f984dc072d3..af13db74ebc6f 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgBase.td
+++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgBase.td
@@ -48,7 +48,7 @@ def Linalg_Dialect : Dialect {
   let hasConstantMaterializer = 1;
   let extraClassDeclaration = [{
     /// Attribute name used to memoize indexing maps for named ops.
-    constexpr const static ::llvm::StringLiteral
+    constexpr const static ::llvm::StringRef
         kMemoizedIndexingMapsAttrName = "linalg.memoized_indexing_maps";
 
     using RegionBuilderFunType = llvm::function_ref<
diff --git a/mlir/include/mlir/Dialect/OpenACC/OpenACC.h b/mlir/include/mlir/Dialect/OpenACC/OpenACC.h
index 748cb7f28fc8c..55cf1a6d420c3 100644
--- a/mlir/include/mlir/Dialect/OpenACC/OpenACC.h
+++ b/mlir/include/mlir/Dialect/OpenACC/OpenACC.h
@@ -165,19 +165,19 @@ inline bool isMappableType(mlir::Type type) {
 }
 
 /// Used to obtain the attribute name for declare.
-static constexpr StringLiteral getDeclareAttrName() {
-  return StringLiteral("acc.declare");
+static constexpr StringRef getDeclareAttrName() {
+  return StringRef("acc.declare");
 }
 
-static constexpr StringLiteral getDeclareActionAttrName() {
-  return StringLiteral("acc.declare_action");
+static constexpr StringRef getDeclareActionAttrName() {
+  return StringRef("acc.declare_action");
 }
 
-static constexpr StringLiteral getRoutineInfoAttrName() {
-  return StringLiteral("acc.routine_info");
+static constexpr StringRef getRoutineInfoAttrName() {
+  return StringRef("acc.routine_info");
 }
 
-static constexpr StringLiteral getCombinedConstructsAttrName() {
+static constexpr StringRef getCombinedConstructsAttrName() {
   return CombinedConstructsTypeAttr::name;
 }
 
diff --git a/mlir/include/mlir/Dialect/Quant/IR/QuantTypes.h b/mlir/include/mlir/Dialect/Quant/IR/QuantTypes.h
index 43440ba623b9c..755bbb115cade 100644
--- a/mlir/include/mlir/Dialect/Quant/IR/QuantTypes.h
+++ b/mlir/include/mlir/Dialect/Quant/IR/QuantTypes.h
@@ -202,7 +202,7 @@ class AnyQuantizedType
   using Base::Base;
   using Base::getChecked;
 
-  static constexpr StringLiteral name = "quant.any";
+  static constexpr StringRef name = "quant.any";
 
   /// Gets an instance of the type with all parameters specified but not
   /// checked.
@@ -263,7 +263,7 @@ class UniformQuantizedType
   using Base::Base;
   using Base::getChecked;
 
-  static constexpr StringLiteral name = "quant.uniform";
+  static constexpr StringRef name = "quant.uniform";
 
   /// Gets an instance of the type with all parameters specified but not
   /// checked.
@@ -323,7 +323,7 @@ class UniformQuantizedPerAxisType
   using Base::Base;
   using Base::getChecked;
 
-  static constexpr StringLiteral name = "quant.uniform_per_axis";
+  static constexpr StringRef name = "quant.uniform_per_axis";
 
   /// Gets an instance of the type with all parameters specified but not
   /// checked.
@@ -393,7 +393,7 @@ class CalibratedQuantizedType
   using Base::Base;
   using Base::getChecked;
 
-  static constexpr StringLiteral name = "quant.calibrated";
+  static constexpr StringRef name = "quant.calibrated";
 
   /// Gets an instance of the type with all parameters specified but not
   /// checked.
diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAttributes.h b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAttributes.h
index 2bdd7a5bf3dd8..8b1aed6a6ea2d 100644
--- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAttributes.h
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAttributes.h
@@ -81,7 +81,7 @@ class InterfaceVarABIAttr
                    IntegerAttr descriptorSet, IntegerAttr binding,
                    IntegerAttr storageClass);
 
-  static constexpr StringLiteral name = "spirv.interface_var_abi";
+  static constexpr StringRef name = "spirv.interface_var_abi";
 };
 
 /// An attribute that specifies the SPIR-V (version, capabilities, extensions)
@@ -134,7 +134,7 @@ class VerCapExtAttr
                    IntegerAttr version, ArrayAttr capabilities,
                    ArrayAttr extensions);
 
-  static constexpr StringLiteral name = "spirv.ver_cap_ext";
+  static constexpr StringRef name = "spirv.ver_cap_ext";
 };
 
 /// An attribute that specifies the target version, allowed extensions and
@@ -190,7 +190,7 @@ class TargetEnvAttr
   /// Returns the target resource limits.
   ResourceLimitsAttr getResourceLimits() const;
 
-  static constexpr StringLiteral name = "spirv.target_env";
+  static constexpr StringRef name = "spirv.target_env";
 };
 } // namespace spirv
 } // namespace mlir
diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVTypes.h b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVTypes.h
index 2e29e9afaabf4..6d5a395a620fb 100644
--- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVTypes.h
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVTypes.h
@@ -130,7 +130,7 @@ class ArrayType : public Type::TypeBase
diff --git a/mlir/include/mlir/IR/BuiltinAttributes.h b/mlir/include/mlir/IR/BuiltinAttributes.h
index 901df3a25a46f..94c0b422065e2 100644
--- a/mlir/include/mlir/IR/BuiltinAttributes.h
+++ b/mlir/include/mlir/IR/BuiltinAttributes.h
@@ -1045,7 +1045,7 @@ class DistinctAttr
   /// unique identifier.
   static DistinctAttr create(Attribute referencedAttr);
 
-  static constexpr StringLiteral name = "builtin.distinct";
+  static constexpr StringRef name = "builtin.distinct";
 };
 
 //===----------------------------------------------------------------------===//
diff --git a/mlir/include/mlir/IR/DialectImplementation.h b/mlir/include/mlir/IR/DialectImplementation.h
index f45b88dc6deca..67f40e3372586 100644
--- a/mlir/include/mlir/IR/DialectImplementation.h
+++ b/mlir/include/mlir/IR/DialectImplementation.h
@@ -26,7 +26,7 @@ struct HasStaticDialectName : std::false_type {};
 template 
 struct HasStaticDialectName<
     T, typename std::enable_if<
-           std::is_same<::llvm::StringLiteral,
+           std::is_same<::llvm::StringRef,
                         std::decay_t>::value,
            void>::type> : std::true_type {};
 
diff --git a/mlir/include/mlir/IR/OpImplementation.h b/mlir/include/mlir/IR/OpImplementation.h
index 6c1ff4d0e5e6b..effd2e1704fa5 100644
--- a/mlir/include/mlir/IR/OpImplementation.h
+++ b/mlir/include/mlir/IR/OpImplementation.h
@@ -831,7 +831,7 @@ class AsmParser {
         result = failure();
     }
     /// Case that uses the provided value when true.
-    KeywordSwitch &Case(StringLiteral str, ResultT value) {
+    KeywordSwitch &Case(StringRef str, ResultT value) {
       return Case(str, [&](StringRef, SMLoc) { return std::move(value); });
     }
     KeywordSwitch &Default(ResultT value) {
@@ -842,7 +842,7 @@ class AsmParser {
     /// any errors need to be emitted).
     template 
     std::enable_if_t::value, KeywordSwitch &>
-    Case(StringLiteral str, FnT &&fn) {
+    Case(StringRef str, FnT &&fn) {
       if (result)
         return *this;
 
diff --git a/mlir/include/mlir/Pass/Pass.h b/mlir/include/mlir/Pass/Pass.h
index 7725a3a2910bd..3babae78e4b1f 100644
--- a/mlir/include/mlir/Pass/Pass.h
+++ b/mlir/include/mlir/Pass/Pass.h
@@ -500,7 +500,7 @@ class PassExecutionAction : public tracing::ActionImpl {
   PassExecutionAction(ArrayRef irUnits, const Pass &pass);
 
   /// The tag required by ActionImpl to identify this action.
-  static constexpr StringLiteral tag = "pass-execution";
+  static constexpr StringRef tag = "pass-execution";
 
   /// Print a textual version of this action to `os`.
   void print(raw_ostream &os) const override;
diff --git a/mlir/include/mlir/Rewrite/PatternApplicator.h b/mlir/include/mlir/Rewrite/PatternApplicator.h
index f7871f819a273..296794c4498cc 100644
--- a/mlir/include/mlir/Rewrite/PatternApplicator.h
+++ b/mlir/include/mlir/Rewrite/PatternApplicator.h
@@ -32,8 +32,8 @@ class ApplyPatternAction : public tracing::ActionImpl {
   using Base = tracing::ActionImpl;
   ApplyPatternAction(ArrayRef irUnits, const Pattern &pattern)
       : Base(irUnits), pattern(pattern) {}
-  static constexpr StringLiteral tag = "apply-pattern";
-  static constexpr StringLiteral desc =
+  static constexpr StringRef tag = "apply-pattern";
+  static constexpr StringRef desc =
       "Encapsulate the application of rewrite patterns";
 
   void print(raw_ostream &os) const override {
diff --git a/mlir/include/mlir/Support/LLVM.h b/mlir/include/mlir/Support/LLVM.h
index 020c0fba726c8..b3a5e149a2471 100644
--- a/mlir/include/mlir/Support/LLVM.h
+++ b/mlir/include/mlir/Support/LLVM.h
@@ -40,7 +40,7 @@ namespace llvm {
 template 
 class SmallString;
 class StringRef;
-class StringLiteral;
+class StringRef;
 class Twine;
 
 // Containers.
@@ -109,7 +109,6 @@ using llvm::isa_and_present;
 
 // String types
 using llvm::SmallString;
-using llvm::StringLiteral;
 using llvm::StringRef;
 using llvm::Twine;
 
diff --git a/mlir/include/mlir/Target/LLVMIR/ModuleImport.h b/mlir/include/mlir/Target/LLVMIR/ModuleImport.h
index 33c9af7c6335a..d55a745725423 100644
--- a/mlir/include/mlir/Target/LLVMIR/ModuleImport.h
+++ b/mlir/include/mlir/Target/LLVMIR/ModuleImport.h
@@ -256,14 +256,12 @@ class ModuleImport {
   /// list `immArgPositions` contains the positions of immargs on the LLVM
   /// intrinsic, and `immArgAttrNames` list (of the same length) contains the
   /// corresponding MLIR attribute names.
-  LogicalResult
-  convertIntrinsicArguments(ArrayRef values,
-                            ArrayRef opBundles,
-                            bool requiresOpBundles,
-                            ArrayRef immArgPositions,
-                            ArrayRef immArgAttrNames,
-                            SmallVectorImpl &valuesOut,
-                            SmallVectorImpl &attrsOut);
+  LogicalResult convertIntrinsicArguments(
+      ArrayRef values,
+      ArrayRef opBundles, bool requiresOpBundles,
+      ArrayRef immArgPositions, ArrayRef immArgAttrNames,
+      SmallVectorImpl &valuesOut,
+      SmallVectorImpl &attrsOut);
 
 private:
   /// Clears the accumulated state before processing a new region.
diff --git a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
index 1b62437761ed9..605d6a349ee2d 100644
--- a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
+++ b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
@@ -440,8 +440,7 @@ llvm::CallInst *createIntrinsicCall(
     llvm::IRBuilderBase &builder, ModuleTranslation &moduleTranslation,
     Operation *intrOp, llvm::Intrinsic::ID intrinsic, unsigned numResults,
     ArrayRef overloadedResults, ArrayRef overloadedOperands,
-    ArrayRef immArgPositions,
-    ArrayRef immArgAttrNames);
+    ArrayRef immArgPositions, ArrayRef immArgAttrNames);
 
 } // namespace detail
 
diff --git a/mlir/include/mlir/Tools/lsp-server-support/Protocol.h b/mlir/include/mlir/Tools/lsp-server-support/Protocol.h
index 5d2eb01a523a7..9d38964e8c235 100644
--- a/mlir/include/mlir/Tools/lsp-server-support/Protocol.h
+++ b/mlir/include/mlir/Tools/lsp-server-support/Protocol.h
@@ -1213,9 +1213,9 @@ struct CodeAction {
   /// The kind of the code action.
   /// Used to filter code actions.
   std::optional kind;
-  const static llvm::StringLiteral kQuickFix;
-  const static llvm::StringLiteral kRefactor;
-  const static llvm::StringLiteral kInfo;
+  const static llvm::StringRef kQuickFix;
+  const static llvm::StringRef kRefactor;
+  const static llvm::StringRef kInfo;
 
   /// The diagnostics that this code action resolves.
   std::optional> diagnostics;
diff --git a/mlir/include/mlir/Tools/lsp-server-support/Transport.h b/mlir/include/mlir/Tools/lsp-server-support/Transport.h
index 6843bc76ab9dc..8ad39650d794c 100644
--- a/mlir/include/mlir/Tools/lsp-server-support/Transport.h
+++ b/mlir/include/mlir/Tools/lsp-server-support/Transport.h
@@ -143,7 +143,7 @@ class MessageHandler {
   }
 
   template 
-  void method(llvm::StringLiteral method, ThisT *thisPtr,
+  void method(llvm::StringRef method, ThisT *thisPtr,
               void (ThisT::*handler)(const Param &, Callback)) {
     methodHandlers[method] = [method, handler,
                               thisPtr](llvm::json::Value rawParams,
@@ -156,7 +156,7 @@ class MessageHandler {
   }
 
   template 
-  void notification(llvm::StringLiteral method, ThisT *thisPtr,
+  void notification(llvm::StringRef method, ThisT *thisPtr,
                     void (ThisT::*handler)(const Param &)) {
     notificationHandlers[method] = [method, handler,
                                     thisPtr](llvm::json::Value rawParams) {
@@ -175,7 +175,7 @@ class MessageHandler {
 
   /// Create an OutgoingNotification object used for the given method.
   template 
-  OutgoingNotification outgoingNotification(llvm::StringLiteral method) {
+  OutgoingNotification outgoingNotification(llvm::StringRef method) {
     return [&, method](const T ¶ms) {
       std::lock_guard transportLock(transportOutputMutex);
       Logger::info("--> {0}", method);
@@ -189,7 +189,7 @@ class MessageHandler {
   /// is invoked.
   template 
   OutgoingRequest
-  outgoingRequest(llvm::StringLiteral method,
+  outgoingRequest(llvm::StringRef method,
                   OutgoingRequestCallback callback) {
     return [&, method, callback](const Param ¶m, llvm::json::Value id) {
       auto callbackWrapper = [method, callback = std::move(callback)](
diff --git a/mlir/lib/Bytecode/Writer/BytecodeWriter.cpp b/mlir/lib/Bytecode/Writer/BytecodeWriter.cpp
index 0e96aa97abeba..f374649a1dbce 100644
--- a/mlir/lib/Bytecode/Writer/BytecodeWriter.cpp
+++ b/mlir/lib/Bytecode/Writer/BytecodeWriter.cpp
@@ -146,7 +146,7 @@ class EncodingEmitter {
   //===--------------------------------------------------------------------===//
 
   /// Backpatch a byte in the result buffer at the given offset.
-  void patchByte(uint64_t offset, uint8_t value, StringLiteral desc) {
+  void patchByte(uint64_t offset, uint8_t value, StringRef desc) {
     LLVM_DEBUG(llvm::dbgs() << "patchByte(" << offset << ',' << uint64_t(value)
                             << ")\t" << desc << '\n');
     assert(offset < size() && offset >= prevResultSize &&
@@ -156,7 +156,7 @@ class EncodingEmitter {
 
   /// Emit the provided blob of data, which is owned by the caller and is
   /// guaranteed to not die before the end of the bytecode process.
-  void emitOwnedBlob(ArrayRef data, StringLiteral desc) {
+  void emitOwnedBlob(ArrayRef data, StringRef desc) {
     LLVM_DEBUG(llvm::dbgs()
                << "emitOwnedBlob(" << data.size() << "b)\t" << desc << '\n');
     // Push the current buffer before adding the provided data.
@@ -169,7 +169,7 @@ class EncodingEmitter {
   /// bytecode process. The alignment value is also encoded, making it available
   /// on load.
   void emitOwnedBlobAndAlignment(ArrayRef data, uint32_t alignment,
-                                 StringLiteral desc) {
+                                 StringRef desc) {
     emitVarInt(alignment, desc);
     emitVarInt(data.size(), desc);
 
@@ -177,7 +177,7 @@ class EncodingEmitter {
     emitOwnedBlob(data, desc);
   }
   void emitOwnedBlobAndAlignment(ArrayRef data, uint32_t alignment,
-                                 StringLiteral desc) {
+                                 StringRef desc) {
     ArrayRef castedData(reinterpret_cast(data.data()),
                                  data.size());
     emitOwnedBlobAndAlignment(castedData, alignment, desc);
@@ -205,14 +205,14 @@ class EncodingEmitter {
 
   /// Emit a single byte.
   template 
-  void emitByte(T byte, StringLiteral desc) {
+  void emitByte(T byte, StringRef desc) {
     LLVM_DEBUG(llvm::dbgs()
                << "emitByte(" << uint64_t(byte) << ")\t" << desc << '\n');
     currentResult.push_back(static_cast(byte));
   }
 
   /// Emit a range of bytes.
-  void emitBytes(ArrayRef bytes, StringLiteral desc) {
+  void emitBytes(ArrayRef bytes, StringRef desc) {
     LLVM_DEBUG(llvm::dbgs()
                << "emitBytes(" << bytes.size() << "b)\t" << desc << '\n');
     llvm::append_range(currentResult, bytes);
@@ -225,7 +225,7 @@ class EncodingEmitter {
   /// All remaining bits in the first byte, along with all of the bits in
   /// additional bytes, provide the value of the integer encoded in
   /// little-endian order.
-  void emitVarInt(uint64_t value, StringLiteral desc) {
+  void emitVarInt(uint64_t value, StringRef desc) {
     LLVM_DEBUG(llvm::dbgs() << "emitVarInt(" << value << ")\t" << desc << '\n');
 
     // In the most common case, the value can be represented in a single byte.
@@ -239,13 +239,13 @@ class EncodingEmitter {
   /// a varint with zigzag encoding, meaning that we use the low bit of the
   /// value to indicate the sign of the value. This allows for more efficient
   /// encoding of negative values by limiting the number of active bits
-  void emitSignedVarInt(uint64_t value, StringLiteral desc) {
+  void emitSignedVarInt(uint64_t value, StringRef desc) {
     emitVarInt((value << 1) ^ (uint64_t)((int64_t)value >> 63), desc);
   }
 
   /// Emit a variable length integer whose low bit is used to encode the
   /// provided flag, i.e. encoded as: (value << 1) | (flag ? 1 : 0).
-  void emitVarIntWithFlag(uint64_t value, bool flag, StringLiteral desc) {
+  void emitVarIntWithFlag(uint64_t value, bool flag, StringRef desc) {
     emitVarInt((value << 1) | (flag ? 1 : 0), desc);
   }
 
@@ -253,13 +253,13 @@ class EncodingEmitter {
   // String Emission
 
   /// Emit the given string as a nul terminated string.
-  void emitNulTerminatedString(StringRef str, StringLiteral desc) {
+  void emitNulTerminatedString(StringRef str, StringRef desc) {
     emitString(str, desc);
     emitByte(0, "null terminator");
   }
 
   /// Emit the given string without a nul terminator.
-  void emitString(StringRef str, StringLiteral desc) {
+  void emitString(StringRef str, StringRef desc) {
     emitBytes({reinterpret_cast(str.data()), str.size()},
               desc);
   }
@@ -310,7 +310,7 @@ class EncodingEmitter {
   /// than 1. We mark it noinline here so that the single byte hot path isn't
   /// pessimized.
   LLVM_ATTRIBUTE_NOINLINE void emitMultiByteVarInt(uint64_t value,
-                                                   StringLiteral desc);
+                                                   StringRef desc);
 
   /// Append a new result buffer to the current contents.
   void appendResult(std::vector &&result) {
@@ -615,7 +615,7 @@ void EncodingEmitter::writeTo(raw_ostream &os) const {
   os.write((const char *)currentResult.data(), currentResult.size());
 }
 
-void EncodingEmitter::emitMultiByteVarInt(uint64_t value, StringLiteral desc) {
+void EncodingEmitter::emitMultiByteVarInt(uint64_t value, StringRef desc) {
   // Compute the number of bytes needed to encode the value. Each byte can hold
   // up to 7-bits of data. We only check up to the number of bits we can encode
   // in the first byte (8).
diff --git a/mlir/lib/Conversion/ArmSMEToLLVM/ArmSMEToLLVM.cpp b/mlir/lib/Conversion/ArmSMEToLLVM/ArmSMEToLLVM.cpp
index 40a3489f7a4d7..6bfe05ff9eef1 100644
--- a/mlir/lib/Conversion/ArmSMEToLLVM/ArmSMEToLLVM.cpp
+++ b/mlir/lib/Conversion/ArmSMEToLLVM/ArmSMEToLLVM.cpp
@@ -36,7 +36,7 @@ using namespace mlir;
 
 namespace {
 
-static constexpr StringLiteral kInMemoryTileIdAttr("arm_sme.in_memory_tile_id");
+static constexpr StringRef kInMemoryTileIdAttr("arm_sme.in_memory_tile_id");
 
 /// Helper to create an arm_sme.intr.ld1*.(horiz|vert)' intrinsic.
 static Operation *createLoadTileSliceIntrinsic(
diff --git a/mlir/lib/Conversion/GPUToLLVMSPV/GPUToLLVMSPV.cpp b/mlir/lib/Conversion/GPUToLLVMSPV/GPUToLLVMSPV.cpp
index 8b6b553f6eed0..cc25708576f75 100644
--- a/mlir/lib/Conversion/GPUToLLVMSPV/GPUToLLVMSPV.cpp
+++ b/mlir/lib/Conversion/GPUToLLVMSPV/GPUToLLVMSPV.cpp
@@ -106,7 +106,7 @@ struct GPUBarrierConversion final : ConvertOpToLLVMPattern {
   LogicalResult
   matchAndRewrite(gpu::BarrierOp op, OpAdaptor adaptor,
                   ConversionPatternRewriter &rewriter) const final {
-    constexpr StringLiteral funcName = "_Z7barrierj";
+    constexpr StringRef funcName = "_Z7barrierj";
 
     Operation *moduleOp = op->getParentWithTrait();
     assert(moduleOp && "Expecting module");
diff --git a/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp b/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp
index afebded1c3ea4..dd34cb5a5ad86 100644
--- a/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp
+++ b/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp
@@ -76,7 +76,7 @@ Value getLaneId(ConversionPatternRewriter &rewriter, Location loc,
                                                    ValueRange{minus1, mbcntLo});
   return laneId;
 }
-static constexpr StringLiteral amdgcnDataLayout =
+static constexpr StringRef amdgcnDataLayout =
     "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32"
     "-p7:160:256:256:32-p8:128:128-p9:192:256:256:32-i64:64-v16:16-v24:32-v32:"
     "32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:"
diff --git a/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp b/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp
index dece254c325fc..d41c155941bdc 100644
--- a/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp
+++ b/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp
@@ -55,7 +55,7 @@ using namespace mlir::scf;
 // TODO: Implement a cleaner solution, factoring out the "matching" logic
 // from the pattern and its callees into a separate function that can be called
 // from both the pattern and the op legality check.
-static constexpr StringLiteral kVisitedAttrName = "SCFToGPU_visited";
+static constexpr StringRef kVisitedAttrName = "SCFToGPU_visited";
 
 // Extract an indexed value from KernelDim3.
 static Value getDim3Value(const gpu::KernelDim3 &dim3, unsigned pos) {
diff --git a/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp b/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp
index b11511f21d03d..6cb4fae475b94 100644
--- a/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp
+++ b/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp
@@ -1125,102 +1125,102 @@ StringRef getTypeMangling(Type type, bool isSigned) {
 }
 
 template 
-constexpr StringLiteral getGroupFuncName();
+constexpr StringRef getGroupFuncName();
 
 template <>
-constexpr StringLiteral getGroupFuncName() {
+constexpr StringRef getGroupFuncName() {
   return "_Z17__spirv_GroupIAddii";
 }
 template <>
-constexpr StringLiteral getGroupFuncName() {
+constexpr StringRef getGroupFuncName() {
   return "_Z17__spirv_GroupFAddii";
 }
 template <>
-constexpr StringLiteral getGroupFuncName() {
+constexpr StringRef getGroupFuncName() {
   return "_Z17__spirv_GroupSMinii";
 }
 template <>
-constexpr StringLiteral getGroupFuncName() {
+constexpr StringRef getGroupFuncName() {
   return "_Z17__spirv_GroupUMinii";
 }
 template <>
-constexpr StringLiteral getGroupFuncName() {
+constexpr StringRef getGroupFuncName() {
   return "_Z17__spirv_GroupFMinii";
 }
 template <>
-constexpr StringLiteral getGroupFuncName() {
+constexpr StringRef getGroupFuncName() {
   return "_Z17__spirv_GroupSMaxii";
 }
 template <>
-constexpr StringLiteral getGroupFuncName() {
+constexpr StringRef getGroupFuncName() {
   return "_Z17__spirv_GroupUMaxii";
 }
 template <>
-constexpr StringLiteral getGroupFuncName() {
+constexpr StringRef getGroupFuncName() {
   return "_Z17__spirv_GroupFMaxii";
 }
 template <>
-constexpr StringLiteral getGroupFuncName() {
+constexpr StringRef getGroupFuncName() {
   return "_Z27__spirv_GroupNonUniformIAddii";
 }
 template <>
-constexpr StringLiteral getGroupFuncName() {
+constexpr StringRef getGroupFuncName() {
   return "_Z27__spirv_GroupNonUniformFAddii";
 }
 template <>
-constexpr StringLiteral getGroupFuncName() {
+constexpr StringRef getGroupFuncName() {
   return "_Z27__spirv_GroupNonUniformIMulii";
 }
 template <>
-constexpr StringLiteral getGroupFuncName() {
+constexpr StringRef getGroupFuncName() {
   return "_Z27__spirv_GroupNonUniformFMulii";
 }
 template <>
-constexpr StringLiteral getGroupFuncName() {
+constexpr StringRef getGroupFuncName() {
   return "_Z27__spirv_GroupNonUniformSMinii";
 }
 template <>
-constexpr StringLiteral getGroupFuncName() {
+constexpr StringRef getGroupFuncName() {
   return "_Z27__spirv_GroupNonUniformUMinii";
 }
 template <>
-constexpr StringLiteral getGroupFuncName() {
+constexpr StringRef getGroupFuncName() {
   return "_Z27__spirv_GroupNonUniformFMinii";
 }
 template <>
-constexpr StringLiteral getGroupFuncName() {
+constexpr StringRef getGroupFuncName() {
   return "_Z27__spirv_GroupNonUniformSMaxii";
 }
 template <>
-constexpr StringLiteral getGroupFuncName() {
+constexpr StringRef getGroupFuncName() {
   return "_Z27__spirv_GroupNonUniformUMaxii";
 }
 template <>
-constexpr StringLiteral getGroupFuncName() {
+constexpr StringRef getGroupFuncName() {
   return "_Z27__spirv_GroupNonUniformFMaxii";
 }
 template <>
-constexpr StringLiteral getGroupFuncName() {
+constexpr StringRef getGroupFuncName() {
   return "_Z33__spirv_GroupNonUniformBitwiseAndii";
 }
 template <>
-constexpr StringLiteral getGroupFuncName() {
+constexpr StringRef getGroupFuncName() {
   return "_Z32__spirv_GroupNonUniformBitwiseOrii";
 }
 template <>
-constexpr StringLiteral getGroupFuncName() {
+constexpr StringRef getGroupFuncName() {
   return "_Z33__spirv_GroupNonUniformBitwiseXorii";
 }
 template <>
-constexpr StringLiteral getGroupFuncName() {
+constexpr StringRef getGroupFuncName() {
   return "_Z33__spirv_GroupNonUniformLogicalAndii";
 }
 template <>
-constexpr StringLiteral getGroupFuncName() {
+constexpr StringRef getGroupFuncName() {
   return "_Z32__spirv_GroupNonUniformLogicalOrii";
 }
 template <>
-constexpr StringLiteral getGroupFuncName() {
+constexpr StringRef getGroupFuncName() {
   return "_Z33__spirv_GroupNonUniformLogicalXorii";
 }
 } // namespace
diff --git a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
index b45829bcf6d2c..b3dbcc6f76871 100644
--- a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
+++ b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
@@ -4113,7 +4113,7 @@ static ParseResult parseAffineMapWithMinMax(OpAsmParser &parser,
                                             MinMaxKind kind) {
   // Using `const` not `constexpr` below to workaround a MSVC optimizer bug,
   // see: https://reviews.llvm.org/D134227#3821753
-  const llvm::StringLiteral tmpAttrStrName = "__pseudo_bound_map";
+  const llvm::StringRef tmpAttrStrName = "__pseudo_bound_map";
 
   StringRef mapName = kind == MinMaxKind::Min
                           ? AffineParallelOp::getUpperBoundsMapAttrStrName()
diff --git a/mlir/lib/Dialect/ArmSME/Transforms/EnableArmStreaming.cpp b/mlir/lib/Dialect/ArmSME/Transforms/EnableArmStreaming.cpp
index eafdc1de5ef34..1b6e238137e0d 100644
--- a/mlir/lib/Dialect/ArmSME/Transforms/EnableArmStreaming.cpp
+++ b/mlir/lib/Dialect/ArmSME/Transforms/EnableArmStreaming.cpp
@@ -52,7 +52,7 @@ using namespace mlir;
 using namespace mlir::arm_sme;
 namespace {
 
-constexpr StringLiteral
+constexpr StringRef
     kEnableArmStreamingIgnoreAttr("enable_arm_streaming_ignore");
 
 template 
diff --git a/mlir/lib/Dialect/ArmSME/Transforms/OuterProductFusion.cpp b/mlir/lib/Dialect/ArmSME/Transforms/OuterProductFusion.cpp
index 23f2c2bf65e47..dbac386fd0987 100644
--- a/mlir/lib/Dialect/ArmSME/Transforms/OuterProductFusion.cpp
+++ b/mlir/lib/Dialect/ArmSME/Transforms/OuterProductFusion.cpp
@@ -32,16 +32,15 @@ using namespace mlir::arm_sme;
 namespace {
 
 // Common match failure reasons.
-static constexpr StringLiteral
-    kMatchFailureNoAccumulator("no accumulator operand");
-static constexpr StringLiteral kMatchFailureExpectedOuterProductDefOp(
+static constexpr StringRef kMatchFailureNoAccumulator("no accumulator operand");
+static constexpr StringRef kMatchFailureExpectedOuterProductDefOp(
     "defining op of accumulator must be 'arm_sme.outerproduct'");
-static constexpr StringLiteral kMatchFailureInconsistentCombiningKind(
+static constexpr StringRef kMatchFailureInconsistentCombiningKind(
     "combining kind (add or sub) of outer products must match");
-static constexpr StringLiteral kMatchFailureInconsistentMasking(
+static constexpr StringRef kMatchFailureInconsistentMasking(
     "unsupported masking, either both outerproducts are masked "
     "or neither");
-static constexpr StringLiteral kMatchFailureOuterProductNotSingleUse(
+static constexpr StringRef kMatchFailureOuterProductNotSingleUse(
     "outer product(s) not single use and cannot be removed, no benefit to "
     "fusing");
 
diff --git a/mlir/lib/Dialect/ArmSME/Transforms/VectorLegalization.cpp b/mlir/lib/Dialect/ArmSME/Transforms/VectorLegalization.cpp
index 12c65a72babcb..8509161da498d 100644
--- a/mlir/lib/Dialect/ArmSME/Transforms/VectorLegalization.cpp
+++ b/mlir/lib/Dialect/ArmSME/Transforms/VectorLegalization.cpp
@@ -45,13 +45,13 @@ namespace {
 //===----------------------------------------------------------------------===//
 
 // Common match failure reasons.
-static constexpr StringLiteral kMatchFailureNotSMETileTypeMultiple(
+static constexpr StringRef kMatchFailureNotSMETileTypeMultiple(
     "op vector size is not multiple of SME tiles");
-static constexpr StringLiteral kMatchFailureUnsupportedMaskOp(
+static constexpr StringRef kMatchFailureUnsupportedMaskOp(
     "op mask is unsupported for legalization/decomposition");
-static constexpr StringLiteral
+static constexpr StringRef
     kMatchFailureNonPermutationMap("op affine map is not a permutation");
-static constexpr StringLiteral kMatchFailureNotIllegalToLegal(
+static constexpr StringRef kMatchFailureNotIllegalToLegal(
     "expected transpose from illegal type to legal type");
 
 /// An SMESubTile represents a single SME-sized sub-tile from decomposing a
diff --git a/mlir/lib/Dialect/ArmSVE/Transforms/LegalizeVectorStorage.cpp b/mlir/lib/Dialect/ArmSVE/Transforms/LegalizeVectorStorage.cpp
index d2ac850a5f70b..d813fb4b47b91 100644
--- a/mlir/lib/Dialect/ArmSVE/Transforms/LegalizeVectorStorage.cpp
+++ b/mlir/lib/Dialect/ArmSVE/Transforms/LegalizeVectorStorage.cpp
@@ -25,7 +25,7 @@ using namespace mlir::arm_sve;
 // detect IR this pass failed to completely legalize, and report an error.
 // If everything was successfully legalized, no tagged ops will remain after
 // this pass.
-constexpr StringLiteral kSVELegalizerTag("__arm_sve_legalize_vector_storage__");
+constexpr StringRef kSVELegalizerTag("__arm_sve_legalize_vector_storage__");
 
 /// Definitions:
 ///
diff --git a/mlir/lib/Dialect/Bufferization/IR/BufferizationDialect.cpp b/mlir/lib/Dialect/Bufferization/IR/BufferizationDialect.cpp
index e5a0c3c45b09e..ff1d9a9837397 100644
--- a/mlir/lib/Dialect/Bufferization/IR/BufferizationDialect.cpp
+++ b/mlir/lib/Dialect/Bufferization/IR/BufferizationDialect.cpp
@@ -21,12 +21,11 @@ using namespace mlir::bufferization;
 
 /// Attribute name used to mark function arguments who's buffers can be written
 /// to during One-Shot Module Bufferize.
-constexpr const ::llvm::StringLiteral BufferizationDialect::kWritableAttrName;
+constexpr const ::llvm::StringRef BufferizationDialect::kWritableAttrName;
 
 /// Attribute name used to mark the bufferization layout for region arguments
 /// during One-Shot Module Bufferize.
-constexpr const ::llvm::StringLiteral
-    BufferizationDialect::kBufferLayoutAttrName;
+constexpr const ::llvm::StringRef BufferizationDialect::kBufferLayoutAttrName;
 
 /// An attribute that can be attached to ops with an allocation and/or
 /// deallocation side effect. It indicates that the op is under a "manual
@@ -36,7 +35,7 @@ constexpr const ::llvm::StringLiteral
 /// guaranteed to deallocate a buffer under "manual deallocation" are
 /// allowed to have this attribute. (Deallocation ops without this
 /// attribute are rejected by the ownership-based buffer deallocation pass.)
-constexpr const ::llvm::StringLiteral BufferizationDialect::kManualDeallocation;
+constexpr const ::llvm::StringRef BufferizationDialect::kManualDeallocation;
 
 //===----------------------------------------------------------------------===//
 // Bufferization Dialect Interfaces
diff --git a/mlir/lib/Dialect/Bufferization/Transforms/OneShotAnalysis.cpp b/mlir/lib/Dialect/Bufferization/Transforms/OneShotAnalysis.cpp
index fc1b221b4f036..b7ff15bb514dd 100644
--- a/mlir/lib/Dialect/Bufferization/Transforms/OneShotAnalysis.cpp
+++ b/mlir/lib/Dialect/Bufferization/Transforms/OneShotAnalysis.cpp
@@ -79,12 +79,11 @@ static bool isaTensor(Type t) { return isa(t); }
 //===----------------------------------------------------------------------===//
 
 /// Attribute marker to specify op operands that bufferize in-place.
-constexpr StringLiteral kInPlaceOperandsAttrName = "__inplace_operands_attr__";
+constexpr StringRef kInPlaceOperandsAttrName = "__inplace_operands_attr__";
 
-constexpr StringLiteral kOpResultAliasSetAttrName =
-    "__opresult_alias_set_attr__";
+constexpr StringRef kOpResultAliasSetAttrName = "__opresult_alias_set_attr__";
 
-constexpr StringLiteral kBbArgAliasSetAttrName = "__bbarg_alias_set_attr__";
+constexpr StringRef kBbArgAliasSetAttrName = "__bbarg_alias_set_attr__";
 
 /// Mark whether OpOperand will be bufferized inplace.
 static void setInPlaceOpOperand(OpOperand &opOperand, bool inPlace) {
diff --git a/mlir/lib/Dialect/DLTI/DLTI.cpp b/mlir/lib/Dialect/DLTI/DLTI.cpp
index 2510e774f2b2a..a0ad0b027d5ef 100644
--- a/mlir/lib/Dialect/DLTI/DLTI.cpp
+++ b/mlir/lib/Dialect/DLTI/DLTI.cpp
@@ -562,10 +562,10 @@ dlti::query(Operation *op, ArrayRef keys, bool emitError) {
   return currentAttr;
 }
 
-constexpr const StringLiteral mlir::DLTIDialect::kDataLayoutAttrName;
-constexpr const StringLiteral mlir::DLTIDialect::kDataLayoutEndiannessKey;
-constexpr const StringLiteral mlir::DLTIDialect::kDataLayoutEndiannessBig;
-constexpr const StringLiteral mlir::DLTIDialect::kDataLayoutEndiannessLittle;
+constexpr const StringRef mlir::DLTIDialect::kDataLayoutAttrName;
+constexpr const StringRef mlir::DLTIDialect::kDataLayoutEndiannessKey;
+constexpr const StringRef mlir::DLTIDialect::kDataLayoutEndiannessBig;
+constexpr const StringRef mlir::DLTIDialect::kDataLayoutEndiannessLittle;
 
 namespace {
 class TargetDataLayoutInterface : public DataLayoutDialectInterface {
diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
index ef5f1b069b40a..31de1a5e6adb7 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
@@ -2753,13 +2753,13 @@ LogicalResult LLVMFuncOp::verify() {
          };
          return TypeSwitch(op)
              .Case([&](auto landingpad) {
-               constexpr StringLiteral errorMessage =
+               constexpr StringRef errorMessage =
                    "'llvm.landingpad' should have a consistent result type "
                    "inside a function";
                return checkType(landingpad.getType(), errorMessage);
              })
              .Case([&](auto resume) {
-               constexpr StringLiteral errorMessage =
+               constexpr StringRef errorMessage =
                    "'llvm.resume' should have a consistent input type inside a "
                    "function";
                return checkType(resume.getValue().getType(), errorMessage);
diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgDialect.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgDialect.cpp
index 9e50c355c5041..d9920a53e3793 100644
--- a/mlir/lib/Dialect/Linalg/IR/LinalgDialect.cpp
+++ b/mlir/lib/Dialect/Linalg/IR/LinalgDialect.cpp
@@ -67,8 +67,7 @@ struct LinalgInlinerInterface : public DialectInlinerInterface {
 //===----------------------------------------------------------------------===//
 
 /// Attribute name used to memoize indexing maps for named ops.
-constexpr const ::llvm::StringLiteral
-    LinalgDialect::kMemoizedIndexingMapsAttrName;
+constexpr const ::llvm::StringRef LinalgDialect::kMemoizedIndexingMapsAttrName;
 
 /// Trait to check if T provides a `regionBuilder` method.
 template 
diff --git a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
index a1d619c8cd19d..845a8849bac39 100644
--- a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
+++ b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
@@ -1683,9 +1683,9 @@ transform::PackTransposeOp::apply(transform::TransformRewriter &rewriter,
   else if (unPackOp)
     linalgOp = unPackOp.getSource().getDefiningOp();
   if (linalgOp != linalgOpTarget) {
-    auto errorMsg =
-        packOp ? StringLiteral{"not a single use by the LinalgOp target"}
-               : StringLiteral{"not produced by the LinalgOp target"};
+    auto errorMsg = packOp
+                        ? StringRef{"not a single use by the LinalgOp target"}
+                        : StringRef{"not produced by the LinalgOp target"};
     return emitSilenceableError() << errorMsg;
   }
 
@@ -1705,8 +1705,8 @@ transform::PackTransposeOp::apply(transform::TransformRewriter &rewriter,
     ArrayRef perm =
         (permType == OuterOrInnerPerm::Outer) ? getOuterPerm() : getInnerPerm();
     auto errorMsg = (permType == OuterOrInnerPerm::Outer)
-                        ? StringLiteral{"invalid outer_perm"}
-                        : StringLiteral{"invalid inner_perm"};
+                        ? StringRef{"invalid outer_perm"}
+                        : StringRef{"invalid inner_perm"};
     if (!isValidPackingPermutation(packOp, perm, permType) ||
         !isValidPackingPermutation(unPackOp, perm, permType)) {
       Operation *packOrUnpackOp =
diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.h b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.h
index 3e61b5f27fcc2..5cd70dee83e54 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.h
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.h
@@ -240,8 +240,8 @@ class LoopEmitter {
   };
   const std::vector &getValBuffer() const { return valBuffer; };
 
-  constexpr static llvm::StringLiteral getLoopEmitterLoopAttrName() {
-    return llvm::StringLiteral("Emitted from");
+  constexpr static llvm::StringRef getLoopEmitterLoopAttrName() {
+    return llvm::StringRef("Emitted from");
   }
 
 private:
diff --git a/mlir/lib/Dialect/Transform/Interfaces/MatchInterfaces.cpp b/mlir/lib/Dialect/Transform/Interfaces/MatchInterfaces.cpp
index 783eb137b9aff..9c57081fdba5b 100644
--- a/mlir/lib/Dialect/Transform/Interfaces/MatchInterfaces.cpp
+++ b/mlir/lib/Dialect/Transform/Interfaces/MatchInterfaces.cpp
@@ -15,10 +15,10 @@ using namespace mlir;
 //===----------------------------------------------------------------------===//
 
 /// Keyword syntax for positional specification inversion.
-constexpr const static llvm::StringLiteral kDimExceptKeyword = "except";
+constexpr const static llvm::StringRef kDimExceptKeyword = "except";
 
 /// Keyword syntax for full inclusion in positional specification.
-constexpr const static llvm::StringLiteral kDimAllKeyword = "all";
+constexpr const static llvm::StringRef kDimAllKeyword = "all";
 
 ParseResult transform::parseTransformMatchDims(OpAsmParser &parser,
                                                DenseI64ArrayAttr &rawDimList,
diff --git a/mlir/lib/Pass/PassStatistics.cpp b/mlir/lib/Pass/PassStatistics.cpp
index 779dcfe7b6661..6408061406558 100644
--- a/mlir/lib/Pass/PassStatistics.cpp
+++ b/mlir/lib/Pass/PassStatistics.cpp
@@ -14,8 +14,7 @@
 using namespace mlir;
 using namespace mlir::detail;
 
-constexpr StringLiteral kPassStatsDescription =
-    "... Pass statistics report ...";
+constexpr StringRef kPassStatsDescription = "... Pass statistics report ...";
 
 namespace {
 /// Information pertaining to a specific statistic.
diff --git a/mlir/lib/Query/Matcher/Parser.h b/mlir/lib/Query/Matcher/Parser.h
index 58968023022d5..32ae4a8df82dd 100644
--- a/mlir/lib/Query/Matcher/Parser.h
+++ b/mlir/lib/Query/Matcher/Parser.h
@@ -16,8 +16,8 @@
 // provided to the parser.
 //
 // The grammar for the supported expressions is as follows:
-//         :=  | 
-//      := "quoted string"
+//         :=  | 
+//      := "quoted string"
 //  := ()
 //        := [a-zA-Z]+
 //       :=  | ,
diff --git a/mlir/lib/Query/QueryParser.cpp b/mlir/lib/Query/QueryParser.cpp
index 31aead7d403d0..850c6afd0937a 100644
--- a/mlir/lib/Query/QueryParser.cpp
+++ b/mlir/lib/Query/QueryParser.cpp
@@ -67,7 +67,7 @@ struct QueryParser::LexOrCompleteWord {
     }
   }
 
-  LexOrCompleteWord &Case(llvm::StringLiteral caseStr, const T &value,
+  LexOrCompleteWord &Case(llvm::StringRef caseStr, const T &value,
                           bool isCompletion = true) {
 
     if (wordCompletionPos == llvm::StringRef::npos)
diff --git a/mlir/lib/Support/Timing.cpp b/mlir/lib/Support/Timing.cpp
index ac16eb7d224c9..412811416cdcd 100644
--- a/mlir/lib/Support/Timing.cpp
+++ b/mlir/lib/Support/Timing.cpp
@@ -34,8 +34,7 @@ using namespace detail;
 using DisplayMode = DefaultTimingManager::DisplayMode;
 using OutputFormat = DefaultTimingManager::OutputFormat;
 
-constexpr llvm::StringLiteral kTimingDescription =
-    "... Execution time report ...";
+constexpr llvm::StringRef kTimingDescription = "... Execution time report ...";
 
 //===----------------------------------------------------------------------===//
 // TimingManager
diff --git a/mlir/lib/Target/LLVMIR/DataLayoutImporter.cpp b/mlir/lib/Target/LLVMIR/DataLayoutImporter.cpp
index 35001757f214e..8d8493ab29323 100644
--- a/mlir/lib/Target/LLVMIR/DataLayoutImporter.cpp
+++ b/mlir/lib/Target/LLVMIR/DataLayoutImporter.cpp
@@ -165,7 +165,7 @@ DataLayoutImporter::tryToEmplaceEndiannessEntry(StringRef endianness,
 
 LogicalResult
 DataLayoutImporter::tryToEmplaceAddrSpaceEntry(StringRef token,
-                                               llvm::StringLiteral spaceKey) {
+                                               llvm::StringRef spaceKey) {
   auto key = StringAttr::get(context, spaceKey);
   if (keyEntries.count(key))
     return success();
diff --git a/mlir/lib/Target/LLVMIR/DataLayoutImporter.h b/mlir/lib/Target/LLVMIR/DataLayoutImporter.h
index 59b60acd24be2..41db8304cb673 100644
--- a/mlir/lib/Target/LLVMIR/DataLayoutImporter.h
+++ b/mlir/lib/Target/LLVMIR/DataLayoutImporter.h
@@ -98,7 +98,7 @@ class DataLayoutImporter {
 
   /// Adds an alloca address space entry if there is none yet.
   LogicalResult tryToEmplaceAddrSpaceEntry(StringRef token,
-                                           llvm::StringLiteral spaceKey);
+                                           llvm::StringRef spaceKey);
 
   /// Adds a stack alignment entry if there is none yet.
   LogicalResult tryToEmplaceStackAlignmentEntry(StringRef token);
diff --git a/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMIRToLLVMTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMIRToLLVMTranslation.cpp
index 4fd043c7c93e6..faca165c3f95a 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMIRToLLVMTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMIRToLLVMTranslation.cpp
@@ -32,10 +32,10 @@ using namespace mlir::LLVM::detail;
 
 #include "mlir/Dialect/LLVMIR/LLVMConversionEnumsFromLLVM.inc"
 
-static constexpr StringLiteral vecTypeHintMDName = "vec_type_hint";
-static constexpr StringLiteral workGroupSizeHintMDName = "work_group_size_hint";
-static constexpr StringLiteral reqdWorkGroupSizeMDName = "reqd_work_group_size";
-static constexpr StringLiteral intelReqdSubGroupSizeMDName =
+static constexpr StringRef vecTypeHintMDName = "vec_type_hint";
+static constexpr StringRef workGroupSizeHintMDName = "work_group_size_hint";
+static constexpr StringRef reqdWorkGroupSizeMDName = "reqd_work_group_size";
+static constexpr StringRef intelReqdSubGroupSizeMDName =
     "intel_reqd_sub_group_size";
 
 /// Returns true if the LLVM IR intrinsic is convertible to an MLIR LLVM dialect
diff --git a/mlir/lib/Target/LLVMIR/ModuleImport.cpp b/mlir/lib/Target/LLVMIR/ModuleImport.cpp
index 2d8d7745eca9b..95946dc0b57b6 100644
--- a/mlir/lib/Target/LLVMIR/ModuleImport.cpp
+++ b/mlir/lib/Target/LLVMIR/ModuleImport.cpp
@@ -1349,7 +1349,7 @@ ModuleImport::convertValues(ArrayRef values) {
 LogicalResult ModuleImport::convertIntrinsicArguments(
     ArrayRef values, ArrayRef opBundles,
     bool requiresOpBundles, ArrayRef immArgPositions,
-    ArrayRef immArgAttrNames, SmallVectorImpl &valuesOut,
+    ArrayRef immArgAttrNames, SmallVectorImpl &valuesOut,
     SmallVectorImpl &attrsOut) {
   assert(immArgPositions.size() == immArgAttrNames.size() &&
          "LLVM `immArgPositions` and MLIR `immArgAttrNames` should have equal "
@@ -1851,32 +1851,32 @@ static void processMemoryEffects(llvm::Function *func, LLVMFuncOp funcOp) {
 // List of LLVM IR attributes that map to an explicit attribute on the MLIR
 // LLVMFuncOp.
 static constexpr std::array kExplicitAttributes{
-    StringLiteral("aarch64_in_za"),
-    StringLiteral("aarch64_inout_za"),
-    StringLiteral("aarch64_new_za"),
-    StringLiteral("aarch64_out_za"),
-    StringLiteral("aarch64_preserves_za"),
-    StringLiteral("aarch64_pstate_sm_body"),
-    StringLiteral("aarch64_pstate_sm_compatible"),
-    StringLiteral("aarch64_pstate_sm_enabled"),
-    StringLiteral("alwaysinline"),
-    StringLiteral("approx-func-fp-math"),
-    StringLiteral("convergent"),
-    StringLiteral("denormal-fp-math"),
-    StringLiteral("denormal-fp-math-f32"),
-    StringLiteral("fp-contract"),
-    StringLiteral("frame-pointer"),
-    StringLiteral("no-infs-fp-math"),
-    StringLiteral("no-nans-fp-math"),
-    StringLiteral("no-signed-zeros-fp-math"),
-    StringLiteral("noinline"),
-    StringLiteral("nounwind"),
-    StringLiteral("optnone"),
-    StringLiteral("target-features"),
-    StringLiteral("tune-cpu"),
-    StringLiteral("unsafe-fp-math"),
-    StringLiteral("vscale_range"),
-    StringLiteral("willreturn"),
+    StringRef("aarch64_in_za"),
+    StringRef("aarch64_inout_za"),
+    StringRef("aarch64_new_za"),
+    StringRef("aarch64_out_za"),
+    StringRef("aarch64_preserves_za"),
+    StringRef("aarch64_pstate_sm_body"),
+    StringRef("aarch64_pstate_sm_compatible"),
+    StringRef("aarch64_pstate_sm_enabled"),
+    StringRef("alwaysinline"),
+    StringRef("approx-func-fp-math"),
+    StringRef("convergent"),
+    StringRef("denormal-fp-math"),
+    StringRef("denormal-fp-math-f32"),
+    StringRef("fp-contract"),
+    StringRef("frame-pointer"),
+    StringRef("no-infs-fp-math"),
+    StringRef("no-nans-fp-math"),
+    StringRef("no-signed-zeros-fp-math"),
+    StringRef("noinline"),
+    StringRef("nounwind"),
+    StringRef("optnone"),
+    StringRef("target-features"),
+    StringRef("tune-cpu"),
+    StringRef("unsafe-fp-math"),
+    StringRef("vscale_range"),
+    StringRef("willreturn"),
 };
 
 static void processPassthroughAttrs(llvm::Function *func, LLVMFuncOp funcOp) {
diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
index 4367100e3aca6..9a245b6522f58 100644
--- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
@@ -849,8 +849,7 @@ llvm::CallInst *mlir::LLVM::detail::createIntrinsicCall(
     llvm::IRBuilderBase &builder, ModuleTranslation &moduleTranslation,
     Operation *intrOp, llvm::Intrinsic::ID intrinsic, unsigned numResults,
     ArrayRef overloadedResults, ArrayRef overloadedOperands,
-    ArrayRef immArgPositions,
-    ArrayRef immArgAttrNames) {
+    ArrayRef immArgPositions, ArrayRef immArgAttrNames) {
   assert(immArgPositions.size() == immArgAttrNames.size() &&
          "LLVM `immArgPositions` and MLIR `immArgAttrNames` should have equal "
          "length");
diff --git a/mlir/lib/Tools/lsp-server-support/Protocol.cpp b/mlir/lib/Tools/lsp-server-support/Protocol.cpp
index e4eb2518e079e..52e222d00acb0 100644
--- a/mlir/lib/Tools/lsp-server-support/Protocol.cpp
+++ b/mlir/lib/Tools/lsp-server-support/Protocol.cpp
@@ -29,9 +29,8 @@ using namespace mlir::lsp;
 
 // Helper that doesn't treat `null` and absent fields as failures.
 template 
-static bool mapOptOrNull(const llvm::json::Value ¶ms,
-                         llvm::StringLiteral prop, T &out,
-                         llvm::json::Path path) {
+static bool mapOptOrNull(const llvm::json::Value ¶ms, llvm::StringRef prop,
+                         T &out, llvm::json::Path path) {
   const llvm::json::Object *o = params.getAsObject();
   assert(o);
 
@@ -1025,9 +1024,9 @@ llvm::json::Value mlir::lsp::toJSON(const WorkspaceEdit &value) {
 // CodeAction
 //===----------------------------------------------------------------------===//
 
-const llvm::StringLiteral CodeAction::kQuickFix = "quickfix";
-const llvm::StringLiteral CodeAction::kRefactor = "refactor";
-const llvm::StringLiteral CodeAction::kInfo = "info";
+const llvm::StringRef CodeAction::kQuickFix = "quickfix";
+const llvm::StringRef CodeAction::kRefactor = "refactor";
+const llvm::StringRef CodeAction::kInfo = "info";
 
 llvm::json::Value mlir::lsp::toJSON(const CodeAction &value) {
   llvm::json::Object codeAction{{"title", value.title}};
diff --git a/mlir/lib/Tools/mlir-pdll-lsp-server/Protocol.cpp b/mlir/lib/Tools/mlir-pdll-lsp-server/Protocol.cpp
index 27a1b712ae801..88cae2e038157 100644
--- a/mlir/lib/Tools/mlir-pdll-lsp-server/Protocol.cpp
+++ b/mlir/lib/Tools/mlir-pdll-lsp-server/Protocol.cpp
@@ -25,9 +25,8 @@ using namespace mlir::lsp;
 
 // Helper that doesn't treat `null` and absent fields as failures.
 template 
-static bool mapOptOrNull(const llvm::json::Value ¶ms,
-                         llvm::StringLiteral prop, T &out,
-                         llvm::json::Path path) {
+static bool mapOptOrNull(const llvm::json::Value ¶ms, llvm::StringRef prop,
+                         T &out, llvm::json::Path path) {
   const llvm::json::Object *o = params.getAsObject();
   assert(o);
 
diff --git a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp
index 99f3569b767b1..0a6d044f9972a 100644
--- a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp
+++ b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp
@@ -813,7 +813,7 @@ class GreedyPatternRewriteIteration
   GreedyPatternRewriteIteration(ArrayRef units, int64_t iteration)
       : tracing::ActionImpl(units),
         iteration(iteration) {}
-  static constexpr StringLiteral tag = "GreedyPatternRewriteIteration";
+  static constexpr StringRef tag = "GreedyPatternRewriteIteration";
   void print(raw_ostream &os) const override {
     os << "GreedyPatternRewriteIteration(" << iteration << ")";
   }
diff --git a/mlir/lib/Transforms/Utils/WalkPatternRewriteDriver.cpp b/mlir/lib/Transforms/Utils/WalkPatternRewriteDriver.cpp
index ee5c642c943c4..7c9224d8545ee 100644
--- a/mlir/lib/Transforms/Utils/WalkPatternRewriteDriver.cpp
+++ b/mlir/lib/Transforms/Utils/WalkPatternRewriteDriver.cpp
@@ -30,7 +30,7 @@ struct WalkAndApplyPatternsAction final
     : tracing::ActionImpl {
   MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(WalkAndApplyPatternsAction)
   using ActionImpl::ActionImpl;
-  static constexpr StringLiteral tag = "walk-and-apply-patterns";
+  static constexpr StringRef tag = "walk-and-apply-patterns";
   void print(raw_ostream &os) const override { os << tag; }
 };
 
diff --git a/mlir/test/lib/Analysis/DataFlow/TestDenseBackwardDataFlowAnalysis.cpp b/mlir/test/lib/Analysis/DataFlow/TestDenseBackwardDataFlowAnalysis.cpp
index fa6223aa9168b..366df5418312a 100644
--- a/mlir/test/lib/Analysis/DataFlow/TestDenseBackwardDataFlowAnalysis.cpp
+++ b/mlir/test/lib/Analysis/DataFlow/TestDenseBackwardDataFlowAnalysis.cpp
@@ -216,9 +216,9 @@ struct TestNextAccessPass
       llvm::cl::desc(
           "assume external functions have read effect on all arguments")};
 
-  static constexpr llvm::StringLiteral kTagAttrName = "name";
-  static constexpr llvm::StringLiteral kNextAccessAttrName = "next_access";
-  static constexpr llvm::StringLiteral kAtEntryPointAttrName =
+  static constexpr llvm::StringRef kTagAttrName = "name";
+  static constexpr llvm::StringRef kNextAccessAttrName = "next_access";
+  static constexpr llvm::StringRef kAtEntryPointAttrName =
       "next_at_entry_point";
 
   static Attribute makeNextAccessAttribute(Operation *op,
diff --git a/mlir/test/lib/Analysis/TestSlice.cpp b/mlir/test/lib/Analysis/TestSlice.cpp
index 7e8320dbf3ec3..6249a5266be7c 100644
--- a/mlir/test/lib/Analysis/TestSlice.cpp
+++ b/mlir/test/lib/Analysis/TestSlice.cpp
@@ -13,8 +13,8 @@
 
 using namespace mlir;
 
-static const StringLiteral kToSortMark = "test_to_sort";
-static const StringLiteral kOrderIndex = "test_sort_index";
+static const StringRef kToSortMark = "test_to_sort";
+static const StringRef kOrderIndex = "test_sort_index";
 
 namespace {
 
diff --git a/mlir/test/lib/Dialect/SCF/TestSCFUtils.cpp b/mlir/test/lib/Dialect/SCF/TestSCFUtils.cpp
index b4f3fa30f8ab5..e1f1fb7afbd84 100644
--- a/mlir/test/lib/Dialect/SCF/TestSCFUtils.cpp
+++ b/mlir/test/lib/Dialect/SCF/TestSCFUtils.cpp
@@ -101,18 +101,15 @@ struct TestSCFIfUtilsPass
   }
 };
 
-static const StringLiteral kTestPipeliningLoopMarker =
-    "__test_pipelining_loop__";
-static const StringLiteral kTestPipeliningStageMarker =
-    "__test_pipelining_stage__";
+static const StringRef kTestPipeliningLoopMarker = "__test_pipelining_loop__";
+static const StringRef kTestPipeliningStageMarker = "__test_pipelining_stage__";
 /// Marker to express the order in which operations should be after
 /// pipelining.
-static const StringLiteral kTestPipeliningOpOrderMarker =
+static const StringRef kTestPipeliningOpOrderMarker =
     "__test_pipelining_op_order__";
 
-static const StringLiteral kTestPipeliningAnnotationPart =
-    "__test_pipelining_part";
-static const StringLiteral kTestPipeliningAnnotationIteration =
+static const StringRef kTestPipeliningAnnotationPart = "__test_pipelining_part";
+static const StringRef kTestPipeliningAnnotationIteration =
     "__test_pipelining_iteration";
 
 struct TestSCFPipeliningPass
diff --git a/mlir/test/lib/Dialect/Test/TestTypes.h b/mlir/test/lib/Dialect/Test/TestTypes.h
index cef3f056a7986..bcbcf7054e535 100644
--- a/mlir/test/lib/Dialect/Test/TestTypes.h
+++ b/mlir/test/lib/Dialect/Test/TestTypes.h
@@ -132,7 +132,7 @@ class TestRecursiveType
 public:
   using Base::Base;
 
-  static constexpr ::mlir::StringLiteral name = "test.recursive";
+  static constexpr ::mlir::StringRef name = "test.recursive";
 
   static TestRecursiveType get(::mlir::MLIRContext *ctx,
                                ::llvm::StringRef name) {
diff --git a/mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.cpp b/mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.cpp
index face4de8e27d3..a5e3492f1db71 100644
--- a/mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.cpp
+++ b/mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.cpp
@@ -41,8 +41,8 @@ class TestTransformOp
 
   static ArrayRef getAttributeNames() { return {}; }
 
-  static constexpr llvm::StringLiteral getOperationName() {
-    return llvm::StringLiteral("transform.test_transform_op");
+  static constexpr llvm::StringRef getOperationName() {
+    return llvm::StringRef("transform.test_transform_op");
   }
 
   DiagnosedSilenceableFailure apply(transform::TransformRewriter &rewriter,
@@ -96,8 +96,8 @@ class TestTransformUnrestrictedOpNoInterface
 
   static ArrayRef getAttributeNames() { return {}; }
 
-  static constexpr llvm::StringLiteral getOperationName() {
-    return llvm::StringLiteral(
+  static constexpr llvm::StringRef getOperationName() {
+    return llvm::StringRef(
         "transform.test_transform_unrestricted_op_no_interface");
   }
 
diff --git a/mlir/test/lib/IR/TestBytecodeRoundtrip.cpp b/mlir/test/lib/IR/TestBytecodeRoundtrip.cpp
index 4894ad5294990..2d8385dbb2c0e 100644
--- a/mlir/test/lib/IR/TestBytecodeRoundtrip.cpp
+++ b/mlir/test/lib/IR/TestBytecodeRoundtrip.cpp
@@ -151,7 +151,7 @@ struct TestBytecodeRoundtripPass
           // For version less than 2.0, override the encoding of IntegerType.
           if (auto type = llvm::dyn_cast(entryValue)) {
             llvm::outs() << "Overriding IntegerType encoding...\n";
-            dialectGroupName = StringLiteral("funky");
+            dialectGroupName = StringRef("funky");
             writer.writeVarInt(/* IntegerType */ 999);
             writer.writeVarInt(type.getWidth() << 2 | type.getSignedness());
             return success();
@@ -176,7 +176,7 @@ struct TestBytecodeRoundtripPass
           // `dialectName` is the name of the group we have the opportunity to
           // override. In this case, override only the dialect group "funky",
           // for which does not exist in memory.
-          if (dialectName != StringLiteral("funky"))
+          if (dialectName != StringRef("funky"))
             return success();
 
           uint64_t encoding;
@@ -217,7 +217,7 @@ struct TestBytecodeRoundtripPass
             // Specify that this type will need to be written as part of the
             // builtin group. This will override the default dialect group of
             // the attribute (test).
-            dialectGroupName = StringLiteral("builtin");
+            dialectGroupName = StringRef("builtin");
             if (succeeded(iface->writeType(builtinI32Type, writer)))
               return success();
           }
@@ -240,7 +240,7 @@ struct TestBytecodeRoundtripPass
     parseConfig.getBytecodeReaderConfig().attachTypeCallback(
         [&](DialectBytecodeReader &reader, StringRef dialectName,
             Type &entry) -> LogicalResult {
-          if (dialectName != StringLiteral("builtin"))
+          if (dialectName != StringRef("builtin"))
             return success();
           Type builtinAttr = iface->readType(reader);
           if (auto integerType =
@@ -276,7 +276,7 @@ struct TestBytecodeRoundtripPass
             // Specify that this attribute will need to be written as part of
             // the builtin group. This will override the default dialect group
             // of the attribute (test).
-            dialectGroupName = StringLiteral("builtin");
+            dialectGroupName = StringRef("builtin");
             auto denseAttr = DenseIntElementsAttr::get(
                 RankedTensorType::get({2}, i32Type),
                 {testParamAttrs.getV0(), testParamAttrs.getV1()});
diff --git a/mlir/test/mlir-tblgen/attrdefs.td b/mlir/test/mlir-tblgen/attrdefs.td
index 35d2c49619ee6..458307544e36e 100644
--- a/mlir/test/mlir-tblgen/attrdefs.td
+++ b/mlir/test/mlir-tblgen/attrdefs.td
@@ -54,7 +54,7 @@ def C_IndexAttr : TestAttr<"Index"> {
   let hasCustomAssemblyFormat = 1;
 
 // DECL-LABEL: class IndexAttr : public ::mlir::Attribute
-// DECL: static constexpr ::llvm::StringLiteral getMnemonic() {
+// DECL: static constexpr ::llvm::StringRef getMnemonic() {
 // DECL:   return {"index"};
 // DECL: }
 // DECL: static ::mlir::Attribute parse(
@@ -87,7 +87,7 @@ def B_CompoundAttrA : TestAttr<"CompoundA"> {
 // DECL-LABEL: class CompoundAAttr : public ::mlir::Attribute
 // DECL: static CompoundAAttr getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, int widthOfSomething, ::test::SimpleTypeA exampleTdType, ::llvm::APFloat apFloat, ::llvm::ArrayRef dims, ::mlir::Type inner);
 // DECL: static ::llvm::LogicalResult verify(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, int widthOfSomething, ::test::SimpleTypeA exampleTdType, ::llvm::APFloat apFloat, ::llvm::ArrayRef dims, ::mlir::Type inner);
-// DECL: static constexpr ::llvm::StringLiteral getMnemonic() {
+// DECL: static constexpr ::llvm::StringRef getMnemonic() {
 // DECL:   return {"cmpnd_a"};
 // DECL: }
 // DECL: static ::mlir::Attribute parse(
diff --git a/mlir/test/mlir-tblgen/op-decl-and-defs.td b/mlir/test/mlir-tblgen/op-decl-and-defs.td
index a03d0b40d4655..587e0b6d6b7a6 100644
--- a/mlir/test/mlir-tblgen/op-decl-and-defs.td
+++ b/mlir/test/mlir-tblgen/op-decl-and-defs.td
@@ -93,8 +93,8 @@ def NS_AOp : NS_Op<"a_op", [IsolatedFromAbove, IsolatedFromAbove]> {
 // CHECK: public:
 // CHECK:   using Op::Op;
 // CHECK:   using Adaptor = AOpAdaptor;
-// CHECK:   static constexpr ::llvm::StringLiteral getOperationName() {
-// CHECK:     return ::llvm::StringLiteral("test.a_op");
+// CHECK:   static constexpr ::llvm::StringRef getOperationName() {
+// CHECK:     return ::llvm::StringRef("test.a_op");
 // CHECK:   }
 // CHECK:   ::mlir::Operation::operand_range getODSOperands(unsigned index) {
 // CHECK:   ::mlir::TypedValue<::mlir::IntegerType> getA() {
diff --git a/mlir/test/mlir-tblgen/typedefs.td b/mlir/test/mlir-tblgen/typedefs.td
index b9e3a7954e361..7cb36b81c2f6e 100644
--- a/mlir/test/mlir-tblgen/typedefs.td
+++ b/mlir/test/mlir-tblgen/typedefs.td
@@ -71,7 +71,7 @@ def B_CompoundTypeA : TestType<"CompoundA"> {
 // DECL-LABEL: class CompoundAType : public ::mlir::Type
 // DECL: static CompoundAType getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, int widthOfSomething, ::test::SimpleTypeA exampleTdType, SomeCppStruct exampleCppType, ::llvm::ArrayRef dims, ::mlir::Type inner);
 // DECL: static ::llvm::LogicalResult verify(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, int widthOfSomething, ::test::SimpleTypeA exampleTdType, SomeCppStruct exampleCppType, ::llvm::ArrayRef dims, ::mlir::Type inner);
-// DECL: static constexpr ::llvm::StringLiteral getMnemonic() {
+// DECL: static constexpr ::llvm::StringRef getMnemonic() {
 // DECL:   return {"cmpnd_a"};
 // DECL: }
 // DECL: static ::mlir::Type parse(::mlir::AsmParser &odsParser);
@@ -90,7 +90,7 @@ def C_IndexType : TestType<"Index"> {
   let hasCustomAssemblyFormat = 1;
 
 // DECL-LABEL: class IndexType : public ::mlir::Type
-// DECL: static constexpr ::llvm::StringLiteral getMnemonic() {
+// DECL: static constexpr ::llvm::StringRef getMnemonic() {
 // DECL:   return {"index"};
 // DECL: }
 // DECL: static ::mlir::Type parse(::mlir::AsmParser &odsParser);
diff --git a/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp b/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
index 6a39424bd463f..cec1207fc4d11 100644
--- a/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
+++ b/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
@@ -297,13 +297,13 @@ void DefGen::emitName() {
     name = typeDef->getTypeName();
   }
   std::string nameDecl =
-      strfmt("static constexpr ::llvm::StringLiteral name = \"{0}\";\n", name);
+      strfmt("static constexpr ::llvm::StringRef name = \"{0}\";\n", name);
   defCls.declare(std::move(nameDecl));
 }
 
 void DefGen::emitDialectName() {
   std::string decl =
-      strfmt("static constexpr ::llvm::StringLiteral dialectName = \"{0}\";\n",
+      strfmt("static constexpr ::llvm::StringRef dialectName = \"{0}\";\n",
              def.getDialect().getName());
   defCls.declare(std::move(decl));
 }
@@ -395,7 +395,7 @@ void DefGen::emitInvariantsVerifier(bool hasImpl, bool hasCustomVerifier) {
 
 void DefGen::emitParserPrinter() {
   auto *mnemonic = defCls.addStaticMethod(
-      "::llvm::StringLiteral", "getMnemonic");
+      "::llvm::StringRef", "getMnemonic");
   mnemonic->body().indent() << strfmt("return {\"{0}\"};", *def.getMnemonic());
 
   // Declare the parser and printer, if needed.
diff --git a/mlir/tools/mlir-tblgen/DialectGen.cpp b/mlir/tools/mlir-tblgen/DialectGen.cpp
index 414cad5e1dcc2..f6cf2607a08c6 100644
--- a/mlir/tools/mlir-tblgen/DialectGen.cpp
+++ b/mlir/tools/mlir-tblgen/DialectGen.cpp
@@ -116,8 +116,8 @@ class {0} : public ::mlir::{2} {
   friend class ::mlir::MLIRContext;
 public:
   ~{0}() override;
-  static constexpr ::llvm::StringLiteral getDialectNamespace() {
-    return ::llvm::StringLiteral("{1}");
+  static constexpr ::llvm::StringRef getDialectNamespace() {
+    return ::llvm::StringRef("{1}");
   }
 )";
 
@@ -203,7 +203,7 @@ static const char *const discardableAttrHelperDecl = R"(
     class {0}AttrHelper {{
       ::mlir::StringAttr name;
     public:
-      static constexpr ::llvm::StringLiteral getNameStr() {{
+      static constexpr ::llvm::StringRef getNameStr() {{
         return "{4}.{1}";
       }
       constexpr ::mlir::StringAttr getName() {{
diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
index a970cbc5caceb..a7a9377a34763 100644
--- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -549,9 +549,8 @@ void OpOrAdaptorHelper::computeAttrMetadata() {
   // Store the position of the legacy operand_segment_sizes /
   // result_segment_sizes so we can emit a backward compatible property readers
   // and writers.
-  StringRef legacyOperandSegmentSizeName =
-      StringLiteral("operand_segment_sizes");
-  StringRef legacyResultSegmentSizeName = StringLiteral("result_segment_sizes");
+  StringRef legacyOperandSegmentSizeName = StringRef("operand_segment_sizes");
+  StringRef legacyResultSegmentSizeName = StringRef("result_segment_sizes");
   operandSegmentSizesLegacyIndex = 0;
   resultSegmentSizesLegacyIndex = 0;
   for (auto item : sortedAttrMetadata) {
@@ -4068,10 +4067,10 @@ void OpEmitter::genTraits() {
 }
 
 void OpEmitter::genOpNameGetter() {
-  auto *method = opClass.addStaticMethod(
-      "::llvm::StringLiteral", "getOperationName");
+  auto *method = opClass.addStaticMethod("::llvm::StringRef",
+                                                            "getOperationName");
   ERROR_IF_PRUNED(method, "getOperationName", op);
-  method->body() << "  return ::llvm::StringLiteral(\"" << op.getOperationName()
+  method->body() << "  return ::llvm::StringRef(\"" << op.getOperationName()
                  << "\");";
 }
 
diff --git a/mlir/tools/mlir-tblgen/PassGen.cpp b/mlir/tools/mlir-tblgen/PassGen.cpp
index 4b4ac41b9effb..9db438b6e3b90 100644
--- a/mlir/tools/mlir-tblgen/PassGen.cpp
+++ b/mlir/tools/mlir-tblgen/PassGen.cpp
@@ -190,16 +190,16 @@ class {0}Base : public {1} {
   ~{0}Base() = default;
 
   /// Returns the command-line argument attached to this pass.
-  static constexpr ::llvm::StringLiteral getArgumentName() {
-    return ::llvm::StringLiteral("{2}");
+  static constexpr ::llvm::StringRef getArgumentName() {
+    return ::llvm::StringRef("{2}");
   }
   ::llvm::StringRef getArgument() const override { return "{2}"; }
 
   ::llvm::StringRef getDescription() const override { return "{3}"; }
 
   /// Returns the derived pass name.
-  static constexpr ::llvm::StringLiteral getPassName() {
-    return ::llvm::StringLiteral("{0}");
+  static constexpr ::llvm::StringRef getPassName() {
+    return ::llvm::StringRef("{0}");
   }
   ::llvm::StringRef getName() const override { return "{0}"; }
 
@@ -388,16 +388,16 @@ class {0}Base : public {1} {
   ~{0}Base() = default;
 
   /// Returns the command-line argument attached to this pass.
-  static constexpr ::llvm::StringLiteral getArgumentName() {
-    return ::llvm::StringLiteral("{2}");
+  static constexpr ::llvm::StringRef getArgumentName() {
+    return ::llvm::StringRef("{2}");
   }
   ::llvm::StringRef getArgument() const override { return "{2}"; }
 
   ::llvm::StringRef getDescription() const override { return "{3}"; }
 
   /// Returns the derived pass name.
-  static constexpr ::llvm::StringLiteral getPassName() {
-    return ::llvm::StringLiteral("{0}");
+  static constexpr ::llvm::StringRef getPassName() {
+    return ::llvm::StringRef("{0}");
   }
   ::llvm::StringRef getName() const override { return "{0}"; }
 
diff --git a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
index 75b8829be4da5..47a64f633f2d8 100644
--- a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
+++ b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
@@ -520,7 +520,7 @@ static mlir::GenRegistration
 // These enums are encoded as  to constant values in SPIR-V blob, but we
 // directly use the constant value as attribute in SPIR-V dialect. So need
 // to handle them separately from normal enum attributes.
-constexpr llvm::StringLiteral constantIdEnumAttrs[] = {
+constexpr llvm::StringRef constantIdEnumAttrs[] = {
     "SPIRV_ScopeAttr", "SPIRV_KHR_CooperativeMatrixUseAttr",
     "SPIRV_KHR_CooperativeMatrixLayoutAttr", "SPIRV_MemorySemanticsAttr",
     "SPIRV_MatrixLayoutAttr"};
diff --git a/mlir/unittests/Bytecode/BytecodeTest.cpp b/mlir/unittests/Bytecode/BytecodeTest.cpp
index cb915a092a0be..72e9fa4a2918a 100644
--- a/mlir/unittests/Bytecode/BytecodeTest.cpp
+++ b/mlir/unittests/Bytecode/BytecodeTest.cpp
@@ -23,7 +23,7 @@
 using namespace llvm;
 using namespace mlir;
 
-StringLiteral irWithResources = R"(
+StringRef irWithResources = R"(
 module @TestDialectResources attributes {
   bytecode.test = dense_resource : tensor<4xi32>
 } {}
@@ -110,8 +110,8 @@ class OpWithoutProperties : public Op {
 class TestOpPropertiesDialect : public Dialect {
 public:
   MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestOpPropertiesDialect)
-  static constexpr StringLiteral getDialectNamespace() {
-    return StringLiteral("test_op_properties");
+  static constexpr StringRef getDialectNamespace() {
+    return StringRef("test_op_properties");
   }
   explicit TestOpPropertiesDialect(MLIRContext *context)
       : Dialect(getDialectNamespace(), context,
@@ -121,7 +121,7 @@ class TestOpPropertiesDialect : public Dialect {
 };
 } // namespace
 
-constexpr StringLiteral withoutPropertiesAttrsSrc = R"mlir(
+constexpr StringRef withoutPropertiesAttrsSrc = R"mlir(
     "test_op_properties.op_without_properties"()
       {inherent_attr = 42, other_attr = 56} : () -> ()
 )mlir";
diff --git a/mlir/unittests/Debug/DebugCounterTest.cpp b/mlir/unittests/Debug/DebugCounterTest.cpp
index eeeb538a94ba3..1a6c8e80572ef 100644
--- a/mlir/unittests/Debug/DebugCounterTest.cpp
+++ b/mlir/unittests/Debug/DebugCounterTest.cpp
@@ -17,7 +17,7 @@ namespace {
 
 struct CounterAction : public ActionImpl {
   MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(CounterAction)
-  static constexpr StringLiteral tag = "counter-action";
+  static constexpr StringRef tag = "counter-action";
 };
 
 TEST(DebugCounterTest, CounterTest) {
diff --git a/mlir/unittests/Debug/ExecutionContextTest.cpp b/mlir/unittests/Debug/ExecutionContextTest.cpp
index 642adff51002a..2c78b24b112c3 100644
--- a/mlir/unittests/Debug/ExecutionContextTest.cpp
+++ b/mlir/unittests/Debug/ExecutionContextTest.cpp
@@ -17,15 +17,15 @@ using namespace mlir::tracing;
 namespace {
 struct DebuggerAction : public ActionImpl {
   MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(DebuggerAction)
-  static constexpr StringLiteral tag = "debugger-action";
+  static constexpr StringRef tag = "debugger-action";
 };
 struct OtherAction : public ActionImpl {
   MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(OtherAction)
-  static constexpr StringLiteral tag = "other-action";
+  static constexpr StringRef tag = "other-action";
 };
 struct ThirdAction : public ActionImpl {
   MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ThirdAction)
-  static constexpr StringLiteral tag = "third-action";
+  static constexpr StringRef tag = "third-action";
 };
 
 // Simple action that does nothing.
diff --git a/mlir/unittests/Debug/FileLineColLocBreakpointManagerTest.cpp b/mlir/unittests/Debug/FileLineColLocBreakpointManagerTest.cpp
index 5b48e80749c8b..6d00c95efd625 100644
--- a/mlir/unittests/Debug/FileLineColLocBreakpointManagerTest.cpp
+++ b/mlir/unittests/Debug/FileLineColLocBreakpointManagerTest.cpp
@@ -32,7 +32,7 @@ namespace {
 struct FileLineColLocTestingAction
     : public ActionImpl {
   MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(FileLineColLocTestingAction)
-  static constexpr StringLiteral tag = "file-line-col-loc-testing-action";
+  static constexpr StringRef tag = "file-line-col-loc-testing-action";
   FileLineColLocTestingAction(ArrayRef irUnits)
       : ActionImpl(irUnits) {}
 };
diff --git a/mlir/unittests/Dialect/Transform/Preload.cpp b/mlir/unittests/Dialect/Transform/Preload.cpp
index 8504928d85cb2..7b217a30079ff 100644
--- a/mlir/unittests/Dialect/Transform/Preload.cpp
+++ b/mlir/unittests/Dialect/Transform/Preload.cpp
@@ -31,7 +31,7 @@ std::unique_ptr createTestTransformDialectInterpreterPass();
 } // namespace test
 } // namespace mlir
 
-const static llvm::StringLiteral library = R"MLIR(
+const static llvm::StringRef library = R"MLIR(
 module attributes {transform.with_named_sequence} {
   transform.named_sequence private @__transform_main(%arg0: !transform.any_op {transform.readonly}) {
     transform.debug.emit_remark_at %arg0, "from external symbol" : !transform.any_op
@@ -39,7 +39,7 @@ module attributes {transform.with_named_sequence} {
   }
 })MLIR";
 
-const static llvm::StringLiteral input = R"MLIR(
+const static llvm::StringRef input = R"MLIR(
 module attributes {transform.with_named_sequence} {
   transform.named_sequence private @__transform_main(%arg0: !transform.any_op {transform.readonly})
 
diff --git a/mlir/unittests/IR/OpPropertiesTest.cpp b/mlir/unittests/IR/OpPropertiesTest.cpp
index b4a633a2c62e6..d01a124e8ca60 100644
--- a/mlir/unittests/IR/OpPropertiesTest.cpp
+++ b/mlir/unittests/IR/OpPropertiesTest.cpp
@@ -155,8 +155,8 @@ class OpWithoutProperties : public Op {
 class TestOpPropertiesDialect : public Dialect {
 public:
   MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestOpPropertiesDialect)
-  static constexpr StringLiteral getDialectNamespace() {
-    return StringLiteral("test_op_properties");
+  static constexpr StringRef getDialectNamespace() {
+    return StringRef("test_op_properties");
   }
   explicit TestOpPropertiesDialect(MLIRContext *context)
       : Dialect(getDialectNamespace(), context,
@@ -165,7 +165,7 @@ class TestOpPropertiesDialect : public Dialect {
   }
 };
 
-constexpr StringLiteral mlirSrc = R"mlir(
+constexpr StringRef mlirSrc = R"mlir(
     "test_op_properties.op_with_properties"()
       <{a = -42 : i32,
         b = -4.200000e+01 : f32,
@@ -384,7 +384,7 @@ TEST(OpPropertiesTest, getOrAddProperties) {
   op->erase();
 }
 
-constexpr StringLiteral withoutPropertiesAttrsSrc = R"mlir(
+constexpr StringRef withoutPropertiesAttrsSrc = R"mlir(
     "test_op_properties.op_without_properties"()
       {inherent_attr = 42, other_attr = 56} : () -> ()
 )mlir";
diff --git a/mlir/unittests/IR/SymbolTableTest.cpp b/mlir/unittests/IR/SymbolTableTest.cpp
index 5dcec749f0f42..89c6859b92415 100644
--- a/mlir/unittests/IR/SymbolTableTest.cpp
+++ b/mlir/unittests/IR/SymbolTableTest.cpp
@@ -61,7 +61,7 @@ class ReplaceAllSymbolUsesTest : public ::testing::Test {
   std::unique_ptr context;
 
 private:
-  constexpr static llvm::StringLiteral kInput = R"MLIR(
+  constexpr static llvm::StringRef kInput = R"MLIR(
       module {
         test.conversion_func_op private @foo() {
           "test.conversion_call_op"() { callee=@bar } : () -> ()
diff --git a/mlir/unittests/IR/TypeAttrNamesTest.cpp b/mlir/unittests/IR/TypeAttrNamesTest.cpp
index 488c164b23b4b..279edf9807b87 100644
--- a/mlir/unittests/IR/TypeAttrNamesTest.cpp
+++ b/mlir/unittests/IR/TypeAttrNamesTest.cpp
@@ -24,7 +24,7 @@ namespace {
 struct FooType : Type::TypeBase {
   using Base::Base;
 
-  static constexpr StringLiteral name = "fake.foo";
+  static constexpr StringRef name = "fake.foo";
 
   MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(FooType)
 };
@@ -32,7 +32,7 @@ struct FooType : Type::TypeBase {
 struct BarAttr : Attribute::AttrBase {
   using Base::Base;
 
-  static constexpr StringLiteral name = "fake.bar";
+  static constexpr StringRef name = "fake.bar";
 
   MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(BarAttr)
 };
@@ -44,8 +44,8 @@ struct FakeDialect : Dialect {
     addAttributes();
   }
 
-  static constexpr ::llvm::StringLiteral getDialectNamespace() {
-    return ::llvm::StringLiteral("fake");
+  static constexpr ::llvm::StringRef getDialectNamespace() {
+    return ::llvm::StringRef("fake");
   }
 
   MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(FakeDialect)
diff --git a/mlir/unittests/IR/TypeTest.cpp b/mlir/unittests/IR/TypeTest.cpp
index 30f6642a9ca71..0bb0225dbe5ee 100644
--- a/mlir/unittests/IR/TypeTest.cpp
+++ b/mlir/unittests/IR/TypeTest.cpp
@@ -20,7 +20,7 @@ struct LeafType;
 struct MiddleType : Type::TypeBase {
   using Base::Base;
 
-  static constexpr StringLiteral name = "test.middle";
+  static constexpr StringRef name = "test.middle";
 
   static bool classof(Type ty) {
     return ty.getTypeID() == TypeID::get() || Base::classof(ty);
@@ -30,7 +30,7 @@ struct MiddleType : Type::TypeBase {
 struct LeafType : Type::TypeBase {
   using Base::Base;
 
-  static constexpr StringLiteral name = "test.leaf";
+  static constexpr StringRef name = "test.leaf";
 };
 
 struct FakeDialect : Dialect {
@@ -38,8 +38,8 @@ struct FakeDialect : Dialect {
       : Dialect(getDialectNamespace(), context, TypeID::get()) {
     addTypes();
   }
-  static constexpr ::llvm::StringLiteral getDialectNamespace() {
-    return ::llvm::StringLiteral("fake");
+  static constexpr ::llvm::StringRef getDialectNamespace() {
+    return ::llvm::StringRef("fake");
   }
 };
 
diff --git a/mlir/unittests/Interfaces/DataLayoutInterfacesTest.cpp b/mlir/unittests/Interfaces/DataLayoutInterfacesTest.cpp
index db294b8b040e9..0c56e4abe7880 100644
--- a/mlir/unittests/Interfaces/DataLayoutInterfacesTest.cpp
+++ b/mlir/unittests/Interfaces/DataLayoutInterfacesTest.cpp
@@ -21,18 +21,16 @@
 using namespace mlir;
 
 namespace {
-constexpr static llvm::StringLiteral kAttrName = "dltest.layout";
-constexpr static llvm::StringLiteral kEndiannesKeyName = "dltest.endianness";
-constexpr static llvm::StringLiteral kAllocaKeyName =
-    "dltest.alloca_memory_space";
-constexpr static llvm::StringLiteral kProgramKeyName =
+constexpr static llvm::StringRef kAttrName = "dltest.layout";
+constexpr static llvm::StringRef kEndiannesKeyName = "dltest.endianness";
+constexpr static llvm::StringRef kAllocaKeyName = "dltest.alloca_memory_space";
+constexpr static llvm::StringRef kProgramKeyName =
     "dltest.program_memory_space";
-constexpr static llvm::StringLiteral kGlobalKeyName =
-    "dltest.global_memory_space";
-constexpr static llvm::StringLiteral kStackAlignmentKeyName =
+constexpr static llvm::StringRef kGlobalKeyName = "dltest.global_memory_space";
+constexpr static llvm::StringRef kStackAlignmentKeyName =
     "dltest.stack_alignment";
 
-constexpr static llvm::StringLiteral kTargetSystemDescAttrName =
+constexpr static llvm::StringRef kTargetSystemDescAttrName =
     "dl_target_sys_desc_test.target_system_spec";
 
 /// Trivial array storage for the custom data layout spec attribute, just a list
@@ -65,7 +63,7 @@ struct CustomDataLayoutSpec
 
   using Base::Base;
 
-  static constexpr StringLiteral name = "test.custom_data_layout_spec";
+  static constexpr StringRef name = "test.custom_data_layout_spec";
 
   static CustomDataLayoutSpec get(MLIRContext *ctx,
                                   ArrayRef entries) {
@@ -123,7 +121,7 @@ struct CustomTargetSystemSpec
 
   using Base::Base;
 
-  static constexpr StringLiteral name = "test.custom_target_system_spec";
+  static constexpr StringRef name = "test.custom_target_system_spec";
 
   static CustomTargetSystemSpec
   get(MLIRContext *ctx, ArrayRef entries) {
@@ -157,7 +155,7 @@ struct SingleQueryType
 
   using Base::Base;
 
-  static constexpr StringLiteral name = "test.single_query";
+  static constexpr StringRef name = "test.single_query";
 
   static SingleQueryType get(MLIRContext *ctx) { return Base::get(ctx); }
 
@@ -234,7 +232,7 @@ struct TypeNoLayout : public Type::TypeBase {
 
   using Base::Base;
 
-  static constexpr StringLiteral name = "test.no_layout";
+  static constexpr StringRef name = "test.no_layout";
 
   static TypeNoLayout get(MLIRContext *ctx) { return Base::get(ctx); }
 };
diff --git a/mlir/unittests/Parser/ParserTest.cpp b/mlir/unittests/Parser/ParserTest.cpp
index 52b965bcc1326..39d0288151d79 100644
--- a/mlir/unittests/Parser/ParserTest.cpp
+++ b/mlir/unittests/Parser/ParserTest.cpp
@@ -66,7 +66,7 @@ TEST(MLIRParser, ParseAttr) {
   MLIRContext context;
   Builder b(&context);
   { // Successful parse
-    StringLiteral attrAsm = "array";
+    StringRef attrAsm = "array";
     size_t numRead = 0;
     Attribute attr = parseAttribute(attrAsm, &context, Type(), &numRead);
     EXPECT_EQ(attr, b.getDenseI64ArrayAttr({1, 2, 3}));