[clang-tidy][NFC] run clang-format over 'android', 'boost' and 'bugprone' checks (#143315)
This commit is contained in:
@@ -34,7 +34,8 @@ namespace android {
|
||||
class AndroidModule : public ClangTidyModule {
|
||||
public:
|
||||
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
|
||||
CheckFactories.registerCheck<CloexecAccept4Check>("android-cloexec-accept4");
|
||||
CheckFactories.registerCheck<CloexecAccept4Check>(
|
||||
"android-cloexec-accept4");
|
||||
CheckFactories.registerCheck<CloexecAcceptCheck>("android-cloexec-accept");
|
||||
CheckFactories.registerCheck<CloexecCreatCheck>("android-cloexec-creat");
|
||||
CheckFactories.registerCheck<CloexecDupCheck>("android-cloexec-dup");
|
||||
|
||||
@@ -26,11 +26,10 @@ void CloexecAcceptCheck::registerMatchers(MatchFinder *Finder) {
|
||||
}
|
||||
|
||||
void CloexecAcceptCheck::check(const MatchFinder::MatchResult &Result) {
|
||||
std::string ReplacementText =
|
||||
(Twine("accept4(") + getSpellingArg(Result, 0) + ", " +
|
||||
getSpellingArg(Result, 1) + ", " + getSpellingArg(Result, 2) +
|
||||
", SOCK_CLOEXEC)")
|
||||
.str();
|
||||
std::string ReplacementText = (Twine("accept4(") + getSpellingArg(Result, 0) +
|
||||
", " + getSpellingArg(Result, 1) + ", " +
|
||||
getSpellingArg(Result, 2) + ", SOCK_CLOEXEC)")
|
||||
.str();
|
||||
|
||||
replaceFunc(
|
||||
Result,
|
||||
|
||||
@@ -36,7 +36,7 @@ std::string buildFixMsgForStringFlag(const Expr *Arg, const SourceManager &SM,
|
||||
|
||||
const char *CloexecCheck::FuncDeclBindingStr = "funcDecl";
|
||||
|
||||
const char *CloexecCheck::FuncBindingStr ="func";
|
||||
const char *CloexecCheck::FuncBindingStr = "func";
|
||||
|
||||
void CloexecCheck::registerMatchersImpl(
|
||||
MatchFinder *Finder, internal::Matcher<FunctionDecl> Function) {
|
||||
|
||||
@@ -16,11 +16,10 @@ namespace clang::tidy::android {
|
||||
void CloexecCreatCheck::registerMatchers(MatchFinder *Finder) {
|
||||
auto CharPointerType = hasType(pointerType(pointee(isAnyCharacter())));
|
||||
auto MODETType = hasType(namedDecl(hasName("mode_t")));
|
||||
registerMatchersImpl(Finder,
|
||||
functionDecl(isExternC(), returns(isInteger()),
|
||||
hasName("creat"),
|
||||
hasParameter(0, CharPointerType),
|
||||
hasParameter(1, MODETType)));
|
||||
registerMatchersImpl(Finder, functionDecl(isExternC(), returns(isInteger()),
|
||||
hasName("creat"),
|
||||
hasParameter(0, CharPointerType),
|
||||
hasParameter(1, MODETType)));
|
||||
}
|
||||
|
||||
void CloexecCreatCheck::check(const MatchFinder::MatchResult &Result) {
|
||||
|
||||
@@ -15,11 +15,10 @@ namespace clang::tidy::android {
|
||||
|
||||
void CloexecFopenCheck::registerMatchers(MatchFinder *Finder) {
|
||||
auto CharPointerType = hasType(pointerType(pointee(isAnyCharacter())));
|
||||
registerMatchersImpl(Finder,
|
||||
functionDecl(isExternC(), returns(asString("FILE *")),
|
||||
hasName("fopen"),
|
||||
hasParameter(0, CharPointerType),
|
||||
hasParameter(1, CharPointerType)));
|
||||
registerMatchersImpl(
|
||||
Finder, functionDecl(isExternC(), returns(asString("FILE *")),
|
||||
hasName("fopen"), hasParameter(0, CharPointerType),
|
||||
hasParameter(1, CharPointerType)));
|
||||
}
|
||||
|
||||
void CloexecFopenCheck::check(const MatchFinder::MatchResult &Result) {
|
||||
|
||||
@@ -20,12 +20,11 @@ void CloexecOpenCheck::registerMatchers(MatchFinder *Finder) {
|
||||
hasAnyName("open", "open64"),
|
||||
hasParameter(0, CharPointerType),
|
||||
hasParameter(1, hasType(isInteger()))));
|
||||
registerMatchersImpl(Finder,
|
||||
functionDecl(isExternC(), returns(isInteger()),
|
||||
hasName("openat"),
|
||||
hasParameter(0, hasType(isInteger())),
|
||||
hasParameter(1, CharPointerType),
|
||||
hasParameter(2, hasType(isInteger()))));
|
||||
registerMatchersImpl(
|
||||
Finder, functionDecl(isExternC(), returns(isInteger()), hasName("openat"),
|
||||
hasParameter(0, hasType(isInteger())),
|
||||
hasParameter(1, CharPointerType),
|
||||
hasParameter(2, hasType(isInteger()))));
|
||||
}
|
||||
|
||||
void CloexecOpenCheck::check(const MatchFinder::MatchResult &Result) {
|
||||
|
||||
@@ -14,10 +14,10 @@ using namespace clang::ast_matchers;
|
||||
namespace clang::tidy::android {
|
||||
|
||||
void CloexecPipe2Check::registerMatchers(MatchFinder *Finder) {
|
||||
registerMatchersImpl(Finder,
|
||||
functionDecl(returns(isInteger()), hasName("pipe2"),
|
||||
hasParameter(0, hasType(pointsTo(isInteger()))),
|
||||
hasParameter(1, hasType(isInteger()))));
|
||||
registerMatchersImpl(
|
||||
Finder, functionDecl(returns(isInteger()), hasName("pipe2"),
|
||||
hasParameter(0, hasType(pointsTo(isInteger()))),
|
||||
hasParameter(1, hasType(isInteger()))));
|
||||
}
|
||||
|
||||
void CloexecPipe2Check::check(const MatchFinder::MatchResult &Result) {
|
||||
|
||||
@@ -14,19 +14,19 @@ using namespace clang::ast_matchers;
|
||||
namespace clang::tidy::android {
|
||||
|
||||
void CloexecPipeCheck::registerMatchers(MatchFinder *Finder) {
|
||||
registerMatchersImpl(Finder,
|
||||
functionDecl(returns(isInteger()), hasName("pipe"),
|
||||
hasParameter(0, hasType(pointsTo(isInteger())))));
|
||||
registerMatchersImpl(
|
||||
Finder, functionDecl(returns(isInteger()), hasName("pipe"),
|
||||
hasParameter(0, hasType(pointsTo(isInteger())))));
|
||||
}
|
||||
|
||||
void CloexecPipeCheck::check(const MatchFinder::MatchResult &Result) {
|
||||
std::string ReplacementText =
|
||||
(Twine("pipe2(") + getSpellingArg(Result, 0) + ", O_CLOEXEC)").str();
|
||||
|
||||
replaceFunc(
|
||||
Result,
|
||||
"prefer pipe2() with O_CLOEXEC to avoid leaking file descriptors to child processes",
|
||||
ReplacementText);
|
||||
replaceFunc(Result,
|
||||
"prefer pipe2() with O_CLOEXEC to avoid leaking file descriptors "
|
||||
"to child processes",
|
||||
ReplacementText);
|
||||
}
|
||||
|
||||
} // namespace clang::tidy::android
|
||||
|
||||
@@ -14,12 +14,11 @@ using namespace clang::ast_matchers;
|
||||
namespace clang::tidy::android {
|
||||
|
||||
void CloexecSocketCheck::registerMatchers(MatchFinder *Finder) {
|
||||
registerMatchersImpl(Finder,
|
||||
functionDecl(isExternC(), returns(isInteger()),
|
||||
hasName("socket"),
|
||||
hasParameter(0, hasType(isInteger())),
|
||||
hasParameter(1, hasType(isInteger())),
|
||||
hasParameter(2, hasType(isInteger()))));
|
||||
registerMatchersImpl(
|
||||
Finder, functionDecl(isExternC(), returns(isInteger()), hasName("socket"),
|
||||
hasParameter(0, hasType(isInteger())),
|
||||
hasParameter(1, hasType(isInteger())),
|
||||
hasParameter(2, hasType(isInteger()))));
|
||||
}
|
||||
|
||||
void CloexecSocketCheck::check(const MatchFinder::MatchResult &Result) {
|
||||
|
||||
@@ -36,16 +36,18 @@ void DynamicStaticInitializersCheck::registerMatchers(MatchFinder *Finder) {
|
||||
this);
|
||||
}
|
||||
|
||||
void DynamicStaticInitializersCheck::check(const MatchFinder::MatchResult &Result) {
|
||||
void DynamicStaticInitializersCheck::check(
|
||||
const MatchFinder::MatchResult &Result) {
|
||||
const auto *Var = Result.Nodes.getNodeAs<VarDecl>("var");
|
||||
SourceLocation Loc = Var->getLocation();
|
||||
if (!Loc.isValid() || !utils::isPresumedLocInHeaderFile(Loc, *Result.SourceManager,
|
||||
HeaderFileExtensions))
|
||||
if (!Loc.isValid() || !utils::isPresumedLocInHeaderFile(
|
||||
Loc, *Result.SourceManager, HeaderFileExtensions))
|
||||
return;
|
||||
// If the initializer is a constant expression, then the compiler
|
||||
// doesn't have to dynamically initialize it.
|
||||
diag(Loc, "static variable %0 may be dynamically initialized in this header file")
|
||||
<< Var;
|
||||
diag(Loc,
|
||||
"static variable %0 may be dynamically initialized in this header file")
|
||||
<< Var;
|
||||
}
|
||||
|
||||
} // namespace clang::tidy::bugprone
|
||||
|
||||
@@ -18,9 +18,9 @@ void InaccurateEraseCheck::registerMatchers(MatchFinder *Finder) {
|
||||
const auto EndCall =
|
||||
callExpr(
|
||||
callee(functionDecl(hasAnyName("remove", "remove_if", "unique"))),
|
||||
hasArgument(
|
||||
1, optionally(cxxMemberCallExpr(callee(cxxMethodDecl(hasName("end"))))
|
||||
.bind("end"))))
|
||||
hasArgument(1, optionally(cxxMemberCallExpr(
|
||||
callee(cxxMethodDecl(hasName("end"))))
|
||||
.bind("end"))))
|
||||
.bind("alg");
|
||||
|
||||
const auto DeclInStd = type(hasUnqualifiedDesugaredType(
|
||||
@@ -35,10 +35,8 @@ void InaccurateEraseCheck::registerMatchers(MatchFinder *Finder) {
|
||||
}
|
||||
|
||||
void InaccurateEraseCheck::check(const MatchFinder::MatchResult &Result) {
|
||||
const auto *MemberCall =
|
||||
Result.Nodes.getNodeAs<CXXMemberCallExpr>("erase");
|
||||
const auto *EndExpr =
|
||||
Result.Nodes.getNodeAs<CXXMemberCallExpr>("end");
|
||||
const auto *MemberCall = Result.Nodes.getNodeAs<CXXMemberCallExpr>("erase");
|
||||
const auto *EndExpr = Result.Nodes.getNodeAs<CXXMemberCallExpr>("end");
|
||||
const SourceLocation Loc = MemberCall->getBeginLoc();
|
||||
|
||||
FixItHint Hint;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//===--- IncorrectRoundingsCheck.cpp - clang-tidy ------------------------------===//
|
||||
//===--- IncorrectRoundingsCheck.cpp - clang-tidy--------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
|
||||
@@ -83,8 +83,8 @@ static bool isVarThatIsPossiblyChanged(const Decl *Func, const Stmt *LoopStmt,
|
||||
isChanged(LoopStmt, Var, Context);
|
||||
// FIXME: Track references.
|
||||
}
|
||||
} else if (isa<MemberExpr, CallExpr,
|
||||
ObjCIvarRefExpr, ObjCPropertyRefExpr, ObjCMessageExpr>(Cond)) {
|
||||
} else if (isa<MemberExpr, CallExpr, ObjCIvarRefExpr, ObjCPropertyRefExpr,
|
||||
ObjCMessageExpr>(Cond)) {
|
||||
// FIXME: Handle MemberExpr.
|
||||
return true;
|
||||
} else if (const auto *CE = dyn_cast<CastExpr>(Cond)) {
|
||||
@@ -274,8 +274,7 @@ static bool hasRecursionOverStaticLoopCondVariables(const Expr *Cond,
|
||||
|
||||
void InfiniteLoopCheck::registerMatchers(MatchFinder *Finder) {
|
||||
const auto LoopCondition = allOf(
|
||||
hasCondition(
|
||||
expr(forCallable(decl().bind("func"))).bind("condition")),
|
||||
hasCondition(expr(forCallable(decl().bind("func"))).bind("condition")),
|
||||
unless(hasBody(hasDescendant(
|
||||
loopEndingStmt(forCallable(equalsBoundNode("func")))))));
|
||||
|
||||
@@ -324,7 +323,7 @@ void InfiniteLoopCheck::check(const MatchFinder::MatchResult &Result) {
|
||||
diag(LoopStmt->getBeginLoc(),
|
||||
"this loop is infinite; none of its condition variables (%0)"
|
||||
" are updated in the loop body")
|
||||
<< CondVarNames;
|
||||
<< CondVarNames;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,12 +34,11 @@ public:
|
||||
LambdaFunctionNameCheck::SourceRangeSet *SME)
|
||||
: SuppressMacroExpansions(SME) {}
|
||||
|
||||
void MacroExpands(const Token &MacroNameTok,
|
||||
const MacroDefinition &MD, SourceRange Range,
|
||||
const MacroArgs *Args) override {
|
||||
void MacroExpands(const Token &MacroNameTok, const MacroDefinition &MD,
|
||||
SourceRange Range, const MacroArgs *Args) override {
|
||||
bool HasFile = false;
|
||||
bool HasLine = false;
|
||||
for (const auto& T : MD.getMacroInfo()->tokens()) {
|
||||
for (const Token &T : MD.getMacroInfo()->tokens()) {
|
||||
if (T.is(tok::identifier)) {
|
||||
StringRef IdentName = T.getIdentifierInfo()->getName();
|
||||
if (IdentName == "__FILE__") {
|
||||
@@ -55,7 +54,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
LambdaFunctionNameCheck::SourceRangeSet* SuppressMacroExpansions;
|
||||
LambdaFunctionNameCheck::SourceRangeSet *SuppressMacroExpansions;
|
||||
};
|
||||
|
||||
AST_MATCHER(CXXMethodDecl, isInLambda) { return Node.getParent()->isLambda(); }
|
||||
|
||||
@@ -74,7 +74,7 @@ void MisplacedOperatorInStrlenInAllocCheck::check(
|
||||
if (!Alloc)
|
||||
Alloc = Result.Nodes.getNodeAs<CXXNewExpr>("Alloc");
|
||||
assert(Alloc && "Matched node bound by 'Alloc' should be either 'CallExpr'"
|
||||
" or 'CXXNewExpr'");
|
||||
" or 'CXXNewExpr'");
|
||||
|
||||
const auto *StrLen = Result.Nodes.getNodeAs<CallExpr>("StrLen");
|
||||
const auto *BinOp = Result.Nodes.getNodeAs<BinaryOperator>("BinOp");
|
||||
|
||||
@@ -21,7 +21,8 @@ namespace clang::tidy::bugprone {
|
||||
/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone/misplaced-operator-in-strlen-in-alloc.html
|
||||
class MisplacedOperatorInStrlenInAllocCheck : public ClangTidyCheck {
|
||||
public:
|
||||
MisplacedOperatorInStrlenInAllocCheck(StringRef Name, ClangTidyContext *Context)
|
||||
MisplacedOperatorInStrlenInAllocCheck(StringRef Name,
|
||||
ClangTidyContext *Context)
|
||||
: ClangTidyCheck(Name, Context) {}
|
||||
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
|
||||
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
|
||||
|
||||
@@ -76,8 +76,8 @@ void MisplacedPointerArithmeticInAllocCheck::check(
|
||||
} else {
|
||||
const auto *CtrE = New->getConstructExpr();
|
||||
if (!CtrE || !CtrE->getArg(CtrE->getNumArgs() - 1)
|
||||
->getType()
|
||||
->isIntegralOrEnumerationType())
|
||||
->getType()
|
||||
->isIntegralOrEnumerationType())
|
||||
return;
|
||||
CallName = "operator new";
|
||||
}
|
||||
|
||||
@@ -95,16 +95,14 @@ void MultipleNewInOneExpressionCheck::registerMatchers(MatchFinder *Finder) {
|
||||
|
||||
Finder->addMatcher(
|
||||
callExpr(
|
||||
hasAnyArgument(
|
||||
expr(HasNewExpr1).bind("arg1")),
|
||||
hasAnyArgument(expr(HasNewExpr1).bind("arg1")),
|
||||
hasAnyArgument(
|
||||
expr(HasNewExpr2, unless(equalsBoundNode("arg1"))).bind("arg2")),
|
||||
hasAncestor(BadAllocCatchingTryBlock)),
|
||||
this);
|
||||
Finder->addMatcher(
|
||||
cxxConstructExpr(
|
||||
hasAnyArgument(
|
||||
expr(HasNewExpr1).bind("arg1")),
|
||||
hasAnyArgument(expr(HasNewExpr1).bind("arg1")),
|
||||
hasAnyArgument(
|
||||
expr(HasNewExpr2, unless(equalsBoundNode("arg1"))).bind("arg2")),
|
||||
unless(isListInitialization()),
|
||||
|
||||
@@ -677,7 +677,7 @@ void NotNullTerminatedResultCheck::registerMatchers(MatchFinder *Finder) {
|
||||
std::optional<unsigned> SourcePos, unsigned LengthPos,
|
||||
bool WithIncrease)
|
||||
: Name(Name), DestinationPos(DestinationPos), SourcePos(SourcePos),
|
||||
LengthPos(LengthPos), WithIncrease(WithIncrease){};
|
||||
LengthPos(LengthPos), WithIncrease(WithIncrease) {};
|
||||
|
||||
StringRef Name;
|
||||
std::optional<unsigned> DestinationPos;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
namespace clang::tidy::bugprone {
|
||||
|
||||
class PosixReturnCheck: public ClangTidyCheck {
|
||||
class PosixReturnCheck : public ClangTidyCheck {
|
||||
public:
|
||||
PosixReturnCheck(StringRef Name, ClangTidyContext *Context)
|
||||
: ClangTidyCheck(Name, Context) {}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//===--- RedundantBranchConditionCheck.cpp - clang-tidy -------------------------===//
|
||||
//===--- RedundantBranchConditionCheck.cpp - clang-tidy--------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
@@ -70,7 +70,8 @@ void RedundantBranchConditionCheck::registerMatchers(MatchFinder *Finder) {
|
||||
// FIXME: Handle longer conjunctive and disjunctive clauses.
|
||||
}
|
||||
|
||||
void RedundantBranchConditionCheck::check(const MatchFinder::MatchResult &Result) {
|
||||
void RedundantBranchConditionCheck::check(
|
||||
const MatchFinder::MatchResult &Result) {
|
||||
const auto *OuterIf = Result.Nodes.getNodeAs<IfStmt>(OuterIfStr);
|
||||
const auto *InnerIf = Result.Nodes.getNodeAs<IfStmt>(InnerIfStr);
|
||||
const auto *CondVar = Result.Nodes.getNodeAs<VarDecl>(CondVarStr);
|
||||
|
||||
@@ -22,7 +22,9 @@ constexpr llvm::StringLiteral MinimalConformingFunctions[] = {
|
||||
// mentioned POSIX specification was not updated after 'quick_exit' appeared
|
||||
// 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.
|
||||
// The list is repeated in bugprone-signal-handler.rst and should be kept up to
|
||||
// date.
|
||||
// clang-format off
|
||||
constexpr llvm::StringLiteral POSIXConformingFunctions[] = {
|
||||
"_Exit",
|
||||
"_exit",
|
||||
@@ -215,7 +217,9 @@ constexpr llvm::StringLiteral POSIXConformingFunctions[] = {
|
||||
"wmemcpy",
|
||||
"wmemmove",
|
||||
"wmemset",
|
||||
"write"};
|
||||
"write"
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
using namespace clang::ast_matchers;
|
||||
|
||||
@@ -322,12 +326,12 @@ SourceRange getSourceRangeOfStmt(const Stmt *S, ASTContext &Ctx) {
|
||||
return P.getSourceRange();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
AST_MATCHER(FunctionDecl, isStandardFunction) {
|
||||
return isStandardFunction(&Node);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
SignalHandlerCheck::SignalHandlerCheck(StringRef Name,
|
||||
ClangTidyContext *Context)
|
||||
: ClangTidyCheck(Name, Context),
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
|
||||
namespace clang::tidy::bugprone {
|
||||
|
||||
/// Finds ``cnd_wait``, ``cnd_timedwait``, ``wait``, ``wait_for``, or
|
||||
/// ``wait_until`` function calls when the function is not invoked from a loop
|
||||
/// that checks whether a condition predicate holds or the function has a
|
||||
/// Finds ``cnd_wait``, ``cnd_timedwait``, ``wait``, ``wait_for``, or
|
||||
/// ``wait_until`` function calls when the function is not invoked from a loop
|
||||
/// that checks whether a condition predicate holds or the function has a
|
||||
/// condition parameter.
|
||||
///
|
||||
/// For the user-facing documentation see:
|
||||
|
||||
@@ -47,8 +47,9 @@ void StringLiteralWithEmbeddedNulCheck::registerMatchers(MatchFinder *Finder) {
|
||||
|
||||
// Detect passing a suspicious string literal to a string constructor.
|
||||
// example: std::string str = "abc\0def";
|
||||
Finder->addMatcher(traverse(TK_AsIs,
|
||||
cxxConstructExpr(StringConstructorExpr, hasArgument(0, StrLitWithNul))),
|
||||
Finder->addMatcher(
|
||||
traverse(TK_AsIs, cxxConstructExpr(StringConstructorExpr,
|
||||
hasArgument(0, StrLitWithNul))),
|
||||
this);
|
||||
|
||||
// Detect passing a suspicious string literal through an overloaded operator.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//===--- SuspiciousEnumUsageCheck.h - clang-tidy--------------------------*- C++ -*-===//
|
||||
//===--- SuspiciousEnumUsageCheck.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.
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
void checkSuspiciousBitmaskUsage(const Expr*, const EnumDecl*);
|
||||
void checkSuspiciousBitmaskUsage(const Expr *, const EnumDecl *);
|
||||
const bool StrictMode;
|
||||
};
|
||||
|
||||
|
||||
@@ -21,8 +21,7 @@ void SuspiciousMemsetUsageCheck::registerMatchers(MatchFinder *Finder) {
|
||||
// Match the standard memset:
|
||||
// void *memset(void *buffer, int fill_char, size_t byte_count);
|
||||
auto MemsetDecl =
|
||||
functionDecl(hasName("::memset"),
|
||||
parameterCountIs(3),
|
||||
functionDecl(hasName("::memset"), parameterCountIs(3),
|
||||
hasParameter(0, hasType(pointerType(pointee(voidType())))),
|
||||
hasParameter(1, hasType(isInteger())),
|
||||
hasParameter(2, hasType(isInteger())));
|
||||
|
||||
@@ -18,8 +18,7 @@ namespace clang::tidy::bugprone {
|
||||
void SuspiciousSemicolonCheck::registerMatchers(MatchFinder *Finder) {
|
||||
Finder->addMatcher(
|
||||
stmt(anyOf(ifStmt(hasThen(nullStmt().bind("semi")),
|
||||
unless(hasElse(stmt())),
|
||||
unless(isConstexpr())),
|
||||
unless(hasElse(stmt())), unless(isConstexpr())),
|
||||
forStmt(hasBody(nullStmt().bind("semi"))),
|
||||
cxxForRangeStmt(hasBody(nullStmt().bind("semi"))),
|
||||
whileStmt(hasBody(nullStmt().bind("semi")))))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//===--- UndelegatedConstructorCheck.cpp - clang-tidy --------------------------===//
|
||||
//===--- UndelegatedConstructorCheck.cpp - clang-tidy----------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
|
||||
Reference in New Issue
Block a user