Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion clang-tools-extra/clang-tidy/.clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Checks: >
-bugprone-branch-clone,
-bugprone-easily-swappable-parameters,
-bugprone-narrowing-conversions,
-bugprone-suspicious-stringview-data-usage,
-bugprone-unchecked-optional-access,
-bugprone-unused-return-value,
modernize-*,
Expand Down
4 changes: 4 additions & 0 deletions clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ void yamlize(IO &IO, ClangTidyOptions::OptionMap &Val, bool,
for (auto &Option : SortedOptions) {
bool UseDefault = false;
void *SaveInfo = nullptr;
// Requires 'llvm::yaml::IO' to accept 'StringRef'
// NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage)
IO.preflightKey(Option.first.data(), true, false, UseDefault, SaveInfo);
IO.scalarString(Option.second, needsQuotes(Option.second));
IO.postflightKey(SaveInfo);
Expand All @@ -116,6 +118,8 @@ void yamlize(IO &IO, ClangTidyOptions::OptionMap &Val, bool,
} else if (isa<MappingNode>(I.getCurrentNode())) {
IO.beginMapping();
for (StringRef Key : IO.keys()) {
// Requires 'llvm::yaml::IO' to accept 'StringRef'
// NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage)
IO.mapRequired(Key.data(), Val[Key].Value);
}
IO.endMapping();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ static bool bodyEmpty(const ASTContext *Context, const CompoundStmt *Body) {
CharSourceRange::getCharRange(Body->getLBracLoc().getLocWithOffset(1),
Body->getRBracLoc()),
Context->getSourceManager(), Context->getLangOpts(), &Invalid);
return !Invalid && std::strspn(Text.data(), " \t\r\n") == Text.size();
return !Invalid && Text.ltrim(" \t\r\n").empty();
}

UseEqualsDefaultCheck::UseEqualsDefaultCheck(StringRef Name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,7 @@ std::string IdentifierNamingCheck::HungarianNotation::getDeclTypeName(

// Remove keywords
for (StringRef Kw : Keywords) {
for (size_t Pos = 0;
(Pos = Type.find(Kw.data(), Pos)) != std::string::npos;) {
for (size_t Pos = 0; (Pos = Type.find(Kw, Pos)) != std::string::npos;) {
Type.replace(Pos, Kw.size(), "");
}
}
Expand Down Expand Up @@ -373,7 +372,7 @@ std::string IdentifierNamingCheck::HungarianNotation::getDeclTypeName(
" int", " char", " double", " long", " short"};
bool RedundantRemoved = false;
for (auto Kw : TailsOfMultiWordType) {
size_t Pos = Type.rfind(Kw.data());
size_t Pos = Type.rfind(Kw);
if (Pos != std::string::npos) {
const size_t PtrCount = getAsteriskCount(Type, ND);
Type = Type.substr(0, Pos + Kw.size() + PtrCount);
Expand Down Expand Up @@ -602,9 +601,8 @@ std::string IdentifierNamingCheck::HungarianNotation::getDataTypePrefix(
if (PtrCount > 0) {
ModifiedTypeName = [&](std::string Str, StringRef From, StringRef To) {
size_t StartPos = 0;
while ((StartPos = Str.find(From.data(), StartPos)) !=
std::string::npos) {
Str.replace(StartPos, From.size(), To.data());
while ((StartPos = Str.find(From, StartPos)) != std::string::npos) {
Str.replace(StartPos, From.size(), To);
StartPos += To.size();
}
return Str;
Expand Down