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
6 changes: 2 additions & 4 deletions clang-tools-extra/clang-tidy/abseil/AbseilTidyModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,12 @@ class AbseilModule : public ClangTidyModule {
CheckFactories.registerCheck<NoNamespaceCheck>("abseil-no-namespace");
CheckFactories.registerCheck<RedundantStrcatCallsCheck>(
"abseil-redundant-strcat-calls");
CheckFactories.registerCheck<StrCatAppendCheck>(
"abseil-str-cat-append");
CheckFactories.registerCheck<StrCatAppendCheck>("abseil-str-cat-append");
CheckFactories.registerCheck<StringFindStartswithCheck>(
"abseil-string-find-startswith");
CheckFactories.registerCheck<StringFindStrContainsCheck>(
"abseil-string-find-str-contains");
CheckFactories.registerCheck<TimeComparisonCheck>(
"abseil-time-comparison");
CheckFactories.registerCheck<TimeComparisonCheck>("abseil-time-comparison");
CheckFactories.registerCheck<TimeSubtractionCheck>(
"abseil-time-subtraction");
CheckFactories.registerCheck<UpgradeDurationConversionsCheck>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace clang::tidy::abseil {

// Find potential incorrect uses of integer division of absl::Duration objects.
//
// For the user-facing documentation see:
// For the user-facing documentation see:
// http://clang.llvm.org/extra/clang-tidy/checks/abseil/duration-division.html

class DurationDivisionCheck : public ClangTidyCheck {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ void NoInternalDependenciesCheck::registerMatchers(MatchFinder *Finder) {
this);
}

void NoInternalDependenciesCheck::check(const MatchFinder::MatchResult &Result) {
void NoInternalDependenciesCheck::check(
const MatchFinder::MatchResult &Result) {
const auto *InternalDependency =
Result.Nodes.getNodeAs<NestedNameSpecifierLoc>("InternalDep");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===--- NoInternalDependenciesCheck.h - clang-tidy----------------------*- C++ -*-===//
//===--- NoInternalDependenciesCheck.h - clang-tidy--------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down
7 changes: 3 additions & 4 deletions clang-tools-extra/clang-tidy/abseil/NoNamespaceCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ using namespace clang::ast_matchers;
namespace clang::tidy::abseil {

void NoNamespaceCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(
namespaceDecl(hasName("::absl"), unless(isInAbseilFile()))
.bind("abslNamespace"),
this);
Finder->addMatcher(namespaceDecl(hasName("::absl"), unless(isInAbseilFile()))
.bind("abslNamespace"),
this);
}

void NoNamespaceCheck::check(const MatchFinder::MatchResult &Result) {
Expand Down
32 changes: 16 additions & 16 deletions clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace clang::tidy::abseil {
// - Make it work in macros if the outer and inner StrCats are both in the
// argument.

void RedundantStrcatCallsCheck::registerMatchers(MatchFinder* Finder) {
void RedundantStrcatCallsCheck::registerMatchers(MatchFinder *Finder) {
const auto CallToStrcat =
callExpr(callee(functionDecl(hasName("::absl::StrCat"))));
const auto CallToStrappend =
Expand Down Expand Up @@ -62,7 +62,7 @@ const clang::CallExpr *processArgument(const Expr *Arg,
const MatchFinder::MatchResult &Result,
StrCatCheckResult *CheckResult) {
const auto IsAlphanum = hasDeclaration(cxxMethodDecl(hasName("AlphaNum")));
static const auto* const Strcat = new auto(hasName("::absl::StrCat"));
static const auto *const Strcat = new auto(hasName("::absl::StrCat"));
const auto IsStrcat = cxxBindTemporaryExpr(
has(callExpr(callee(functionDecl(*Strcat))).bind("StrCat")));
if (const auto *SubStrcatCall = selectFirst<const CallExpr>(
Expand All @@ -81,18 +81,18 @@ const clang::CallExpr *processArgument(const Expr *Arg,
StrCatCheckResult processCall(const CallExpr *RootCall, bool IsAppend,
const MatchFinder::MatchResult &Result) {
StrCatCheckResult CheckResult;
std::deque<const CallExpr*> CallsToProcess = {RootCall};
std::deque<const CallExpr *> CallsToProcess = {RootCall};

while (!CallsToProcess.empty()) {
++CheckResult.NumCalls;

const CallExpr* CallExpr = CallsToProcess.front();
const CallExpr *CallExpr = CallsToProcess.front();
CallsToProcess.pop_front();

int StartArg = CallExpr == RootCall && IsAppend;
for (const auto *Arg : CallExpr->arguments()) {
if (StartArg-- > 0)
continue;
if (StartArg-- > 0)
continue;
if (const clang::CallExpr *Sub =
processArgument(Arg, Result, &CheckResult)) {
CallsToProcess.push_back(Sub);
Expand All @@ -101,18 +101,18 @@ StrCatCheckResult processCall(const CallExpr *RootCall, bool IsAppend,
}
return CheckResult;
}
} // namespace
} // namespace

void RedundantStrcatCallsCheck::check(const MatchFinder::MatchResult& Result) {
void RedundantStrcatCallsCheck::check(const MatchFinder::MatchResult &Result) {
bool IsAppend = false;

const CallExpr *RootCall = nullptr;
if ((RootCall = Result.Nodes.getNodeAs<CallExpr>("StrCat")))
IsAppend = false;
else if ((RootCall = Result.Nodes.getNodeAs<CallExpr>("StrAppend")))
IsAppend = true;
else
return;
if ((RootCall = Result.Nodes.getNodeAs<CallExpr>("StrCat")))
IsAppend = false;
else if ((RootCall = Result.Nodes.getNodeAs<CallExpr>("StrAppend")))
IsAppend = true;
else
return;

if (RootCall->getBeginLoc().isMacroID()) {
// Ignore calls within macros.
Expand All @@ -128,8 +128,8 @@ void RedundantStrcatCallsCheck::check(const MatchFinder::MatchResult& Result) {
return;
}

diag(RootCall->getBeginLoc(),
"multiple calls to 'absl::StrCat' can be flattened into a single call")
diag(RootCall->getBeginLoc(),
"multiple calls to 'absl::StrCat' can be flattened into a single call")
<< CheckResult.Hints;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

namespace clang::tidy::abseil {

/// Flags redundant calls to absl::StrCat when the result is being passed to
/// another call of absl::StrCat/absl::StrAppend. Also suggests a fix to
/// Flags redundant calls to absl::StrCat when the result is being passed to
/// another call of absl::StrCat/absl::StrAppend. Also suggests a fix to
/// collapse the calls.
/// Example:
/// StrCat(1, StrCat(2, 3)) ==> StrCat(1, 2, 3)
Expand Down
8 changes: 4 additions & 4 deletions clang-tools-extra/clang-tidy/abseil/StrCatAppendCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ AST_MATCHER_P(Stmt, IgnoringTemporaries, ast_matchers::internal::Matcher<Stmt>,
return InnerMatcher.matches(*E, Finder, Builder);
}

} // namespace
} // namespace

// TODO: str += StrCat(...)
// str.append(StrCat(...))

void StrCatAppendCheck::registerMatchers(MatchFinder *Finder) {
const auto StrCat = functionDecl(hasName("::absl::StrCat"));
// The arguments of absl::StrCat are implicitly converted to AlphaNum. This
// matches to the arguments because of that behavior.
// The arguments of absl::StrCat are implicitly converted to AlphaNum. This
// matches to the arguments because of that behavior.
const auto AlphaNum = IgnoringTemporaries(cxxConstructExpr(
argumentCountIs(1), hasType(cxxRecordDecl(hasName("::absl::AlphaNum"))),
hasArgument(0, ignoringImpCasts(declRefExpr(to(equalsBoundNode("LHS")),
Expand Down Expand Up @@ -73,7 +73,7 @@ void StrCatAppendCheck::registerMatchers(MatchFinder *Finder) {
void StrCatAppendCheck::check(const MatchFinder::MatchResult &Result) {
const auto *Op = Result.Nodes.getNodeAs<CXXOperatorCallExpr>("Op");
const auto *Call = Result.Nodes.getNodeAs<CallExpr>("Call");
assert(Op != nullptr && Call != nullptr && "Matcher does not work as expected");
assert(Op && Call && "Matcher does not work as expected");

// Handles the case 'x = absl::StrCat(x)', which has no effect.
if (Call->getNumArgs() == 1) {
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-tidy/abseil/StrCatAppendCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace clang::tidy::abseil {

/// Flags uses of absl::StrCat to append to a string. Suggests absl::StrAppend
/// should be used instead.
/// should be used instead.
///
/// For the user-facing documentation see:
/// http://clang.llvm.org/extra/clang-tidy/checks/abseil/str-cat-append.html
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class TimeSubtractionCheck : public ClangTidyCheck {
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;

private:
void emitDiagnostic(const Expr* Node, llvm::StringRef Replacement);
void emitDiagnostic(const Expr *Node, llvm::StringRef Replacement);
};

} // namespace clang::tidy::abseil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

namespace clang::tidy::abseil {

/// Finds deprecated uses of `absl::Duration` arithmetic operators and factories.
/// Finds deprecated uses of `absl::Duration` arithmetic operators and
/// factories.
///
/// For the user-facing documentation see:
/// http://clang.llvm.org/extra/clang-tidy/checks/abseil/upgrade-duration-conversions.html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void StructPackAlignCheck::check(const MatchFinder::MatchResult &Result) {
// Do not trigger on templated struct declarations because the packing and
// alignment requirements are unknown.
if (Struct->isTemplated())
return;
return;

// Packing and alignment requirements for invalid decls are meaningless.
if (Struct->isInvalidDecl())
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class StructPackAlignCheck : public ClangTidyCheck {
public:
StructPackAlignCheck(StringRef Name, ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),
MaxConfiguredAlignment(Options.get("MaxConfiguredAlignment", 128)) {}
MaxConfiguredAlignment(Options.get("MaxConfiguredAlignment", 128)) {}
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ bool UnrollLoopsCheck::extractValue(int &Value, const BinaryOperator *Op,
return true;
}

bool UnrollLoopsCheck::exprHasLargeNumIterations(const Expr *Expression,
const ASTContext *Context) const {
bool UnrollLoopsCheck::exprHasLargeNumIterations(
const Expr *Expression, const ASTContext *Context) const {
Expr::EvalResult Result;
if (Expression->EvaluateAsRValue(Result, *Context)) {
if (!Result.Val.isInt())
Expand Down
Loading