Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-query/QueryParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ template <typename T> 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)
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ std::optional<int64_t> 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");

Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-tidy/NoLintDirectiveHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class NoLintToken {

// Consume the entire buffer and return all `NoLintToken`s that were found.
static SmallVector<NoLintToken> getNoLints(StringRef Buffer) {
static constexpr llvm::StringLiteral NOLINT = "NOLINT";
static constexpr llvm::StringRef NOLINT = "NOLINT";
SmallVector<NoLintToken> NoLints;

size_t Pos = 0;
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-tidy/abseil/AbseilMatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> makeCharacterLiteral(const StringLiteral *Literal,
std::optional<std::string> makeCharacterLiteral(const StringRef *Literal,
const ASTContext &Context) {
assert(Literal->getLength() == 1 &&
"Only single character string should be matched");
Expand All @@ -29,7 +29,7 @@ std::optional<std::string> 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);
Expand Down Expand Up @@ -99,7 +99,7 @@ void FasterStrsplitDelimiterCheck::registerMatchers(MatchFinder *Finder) {

void FasterStrsplitDelimiterCheck::check(
const MatchFinder::MatchResult &Result) {
const auto *Literal = Result.Nodes.getNodeAs<StringLiteral>("Literal");
const auto *Literal = Result.Nodes.getNodeAs<StringRef>("Literal");

if (Literal->getBeginLoc().isMacroID() || Literal->getEndLoc().isMacroID())
return;
Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/clang-tidy/android/CloexecCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ std::string buildFixMsgForStringFlag(const Expr *Arg, const SourceManager &SM,
" \"" + Twine(Mode) + "\"")
.str();

StringRef SR = cast<StringLiteral>(Arg->IgnoreParenCasts())->getString();
StringRef SR = cast<StringRef>(Arg->IgnoreParenCasts())->getString();
return ("\"" + SR + Twine(Mode) + "\"").str();
}
} // namespace
Expand Down Expand Up @@ -84,7 +84,7 @@ void CloexecCheck::insertStringFlag(
const auto *ModeArg = MatchedCall->getArg(ArgPos);

// Check if the <Mode> may be in the mode string.
const auto *ModeStr = dyn_cast<StringLiteral>(ModeArg->IgnoreParenCasts());
const auto *ModeStr = dyn_cast<StringRef>(ModeArg->IgnoreParenCasts());
if (!ModeStr || ModeStr->getString().contains(Mode))
return;

Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-tidy/android/CloexecFopenCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ bool ArgumentCommentCheck::shouldAddComment(const Expr *Arg) const {
(CommentFloatLiterals && isa<FloatingLiteral>(Arg)) ||
(CommentUserDefinedLiterals && isa<UserDefinedLiteral>(Arg)) ||
(CommentCharacterLiterals && isa<CharacterLiteral>(Arg)) ||
(CommentStringLiterals && isa<StringLiteral>(Arg)) ||
(CommentStringLiterals && isa<StringRef>(Arg)) ||
(CommentNullPtrs && isa<CXXNullPtrLiteralExpr>(Arg));
}

Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<StringLiteral>(Stmt1);
const auto *StringLit2 = cast<StringLiteral>(Stmt2);
const auto *StringLit1 = cast<StringRef>(Stmt1);
const auto *StringLit2 = cast<StringRef>(Stmt2);
return StringLit1->getBytes() == StringLit2->getBytes();
}
case Stmt::MemberExprClass: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 };

Expand All @@ -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) {
Expand All @@ -80,11 +80,10 @@ static unsigned getLength(const Expr *E,
if (const auto *StrDRE = dyn_cast<DeclRefExpr>(E))
if (const auto *StrVD = dyn_cast<VarDecl>(StrDRE->getDecl()))
if (const Expr *StrInit = StrVD->getInit())
if (const auto *StrSL =
dyn_cast<StringLiteral>(StrInit->IgnoreImpCasts()))
if (const auto *StrSL = dyn_cast<StringRef>(StrInit->IgnoreImpCasts()))
return StrSL->getLength();

if (const auto *SrcSL = dyn_cast<StringLiteral>(E))
if (const auto *SrcSL = dyn_cast<StringRef>(E))
return SrcSL->getLength();

return 0;
Expand Down
Loading
Loading