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
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 @@ -23,7 +23,6 @@ Checks: >
-readability-avoid-nested-conditional-operator,
-readability-braces-around-statements,
-readability-container-contains,
-readability-convert-member-functions-to-static,
-readability-else-after-return,
-readability-function-cognitive-complexity,
-readability-identifier-length,
Expand Down
3 changes: 2 additions & 1 deletion clang-tools-extra/clang-tidy/ClangTidyProfiling.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ class ClangTidyProfiling {
private:
std::optional<StorageParams> Storage;

void printUserFriendlyTable(llvm::raw_ostream &OS, llvm::TimerGroup &TG);
static void printUserFriendlyTable(llvm::raw_ostream &OS,
llvm::TimerGroup &TG);
void printAsJSON(llvm::raw_ostream &OS, llvm::TimerGroup &TG);
void storeProfileData(llvm::TimerGroup &TG);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class IdDependentBackwardBranchCheck : public ClangTidyCheck {
const MemberExpr *MemExpr,
const FieldDecl *PotentialField);
/// Returns the loop type.
LoopType getLoopType(const Stmt *Loop);
static LoopType getLoopType(const Stmt *Loop);

public:
IdDependentBackwardBranchCheck(StringRef Name, ClangTidyContext *Context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class KernelNameRestrictionPPCallbacks : public PPCallbacks {
private:
/// Returns true if the name of the file with path FileName is 'kernel.cl',
/// 'verilog.cl', or 'vhdl.cl'. The file name check is case insensitive.
bool fileNameIsRestricted(StringRef FileName);
static bool fileNameIsRestricted(StringRef FileName);

struct IncludeDirective {
SourceLocation Loc; // Location in the include directive.
Expand Down
13 changes: 7 additions & 6 deletions clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ class UnrollLoopsCheck : public ClangTidyCheck {
/// Attempts to extract an integer value from either side of the
/// BinaryOperator. Returns true and saves the result to &value if successful,
/// returns false otherwise.
bool extractValue(int &Value, const BinaryOperator *Op,
const ASTContext *Context);
static bool extractValue(int &Value, const BinaryOperator *Op,
const ASTContext *Context);
/// Returns true if the given loop statement has a large number of iterations,
/// as determined by the integer value in the loop's condition expression,
/// if one exists.
Expand All @@ -59,13 +59,14 @@ class UnrollLoopsCheck : public ClangTidyCheck {
const ASTContext *Context) const;
/// Returns the type of unrolling, if any, associated with the given
/// statement.
enum UnrollType unrollType(const Stmt *Statement, ASTContext *Context);
static enum UnrollType unrollType(const Stmt *Statement, ASTContext *Context);
/// Returns the condition expression within a given for statement. If there is
/// none, or if the Statement is not a loop, then returns a NULL pointer.
const Expr *getCondExpr(const Stmt *Statement);
static const Expr *getCondExpr(const Stmt *Statement);
/// Returns True if the loop statement has known bounds.
bool hasKnownBounds(const Stmt *Statement, const IntegerLiteral *CXXLoopBound,
const ASTContext *Context);
static bool hasKnownBounds(const Stmt *Statement,
const IntegerLiteral *CXXLoopBound,
const ASTContext *Context);
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
};

Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-tidy/android/CloexecCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void CloexecCheck::insertStringFlag(
}

StringRef CloexecCheck::getSpellingArg(const MatchFinder::MatchResult &Result,
int N) const {
int N) {
const auto *MatchedCall = Result.Nodes.getNodeAs<CallExpr>(FuncBindingStr);
const SourceManager &SM = *Result.SourceManager;
return Lexer::getSourceText(
Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/clang-tidy/android/CloexecCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ class CloexecCheck : public ClangTidyCheck {
const char Mode, const int ArgPos);

/// Helper function to get the spelling of a particular argument.
StringRef getSpellingArg(const ast_matchers::MatchFinder::MatchResult &Result,
int N) const;
static StringRef
getSpellingArg(const ast_matchers::MatchFinder::MatchResult &Result, int N);

/// Binding name of the FuncDecl of a function call.
static const char *FuncDeclBindingStr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ void AssignmentInIfConditionCheck::check(
: Check(Check) {}

// Dont traverse into any lambda expressions.
bool TraverseLambdaExpr(LambdaExpr *, DataRecursionQueue * = nullptr) {
static bool TraverseLambdaExpr(LambdaExpr *,
DataRecursionQueue * = nullptr) {
return true;
}

// Dont traverse into any requires expressions.
bool TraverseRequiresExpr(RequiresExpr *,
DataRecursionQueue * = nullptr) {
static bool TraverseRequiresExpr(RequiresExpr *,
DataRecursionQueue * = nullptr) {
return true;
}

Expand Down
16 changes: 10 additions & 6 deletions clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,32 @@ static bool isFallthroughSwitchBranch(const SwitchBranch &Branch) {
struct SwitchCaseVisitor : RecursiveASTVisitor<SwitchCaseVisitor> {
using RecursiveASTVisitor<SwitchCaseVisitor>::DataRecursionQueue;

bool TraverseLambdaExpr(LambdaExpr *, DataRecursionQueue * = nullptr) {
static bool TraverseLambdaExpr(LambdaExpr *,
DataRecursionQueue * = nullptr) {
return true; // Ignore lambdas
}

bool TraverseDecl(Decl *) {
static bool TraverseDecl(Decl *) {
return true; // No need to check declarations
}

bool TraverseSwitchStmt(SwitchStmt *, DataRecursionQueue * = nullptr) {
static bool TraverseSwitchStmt(SwitchStmt *,
DataRecursionQueue * = nullptr) {
return true; // Ignore sub-switches
}

// NOLINTNEXTLINE(readability-identifier-naming) - FIXME
bool TraverseSwitchCase(SwitchCase *, DataRecursionQueue * = nullptr) {
static bool TraverseSwitchCase(SwitchCase *,
DataRecursionQueue * = nullptr) {
return true; // Ignore cases
}

bool TraverseDefaultStmt(DefaultStmt *, DataRecursionQueue * = nullptr) {
static bool TraverseDefaultStmt(DefaultStmt *,
DataRecursionQueue * = nullptr) {
return true; // Ignore defaults
}

bool TraverseAttributedStmt(AttributedStmt *S) {
static bool TraverseAttributedStmt(AttributedStmt *S) {
if (!S)
return true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class MacroRepeatedPPCallbacks : public PPCallbacks {
unsigned countArgumentExpansions(const MacroInfo *MI,
const IdentifierInfo *Arg) const;

bool hasSideEffects(const Token *ResultArgToks) const;
static bool hasSideEffects(const Token *ResultArgToks);
};
} // End of anonymous namespace.

Expand Down Expand Up @@ -159,8 +159,7 @@ unsigned MacroRepeatedPPCallbacks::countArgumentExpansions(
return Max;
}

bool MacroRepeatedPPCallbacks::hasSideEffects(
const Token *ResultArgToks) const {
bool MacroRepeatedPPCallbacks::hasSideEffects(const Token *ResultArgToks) {
for (; ResultArgToks->isNot(tok::eof); ++ResultArgToks) {
if (ResultArgToks->isOneOf(tok::plusplus, tok::minusminus))
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ bool MultipleInheritanceCheck::getInterfaceStatus(const CXXRecordDecl *Node,
}

bool MultipleInheritanceCheck::isCurrentClassInterface(
const CXXRecordDecl *Node) const {
const CXXRecordDecl *Node) {
// Interfaces should have no fields.
if (!Node->field_empty())
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class MultipleInheritanceCheck : public ClangTidyCheck {
private:
void addNodeToInterfaceMap(const CXXRecordDecl *Node, bool IsInterface);
bool getInterfaceStatus(const CXXRecordDecl *Node, bool &IsInterface) const;
bool isCurrentClassInterface(const CXXRecordDecl *Node) const;
static bool isCurrentClassInterface(const CXXRecordDecl *Node);
bool isInterface(const CXXRecordDecl *Node);

// Contains the identity of each named CXXRecord as an interface. This is
Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/clang-tidy/misc/StaticAssertCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class StaticAssertCheck : public ClangTidyCheck {
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;

private:
SourceLocation getLastParenLoc(const ASTContext *ASTCtx,
SourceLocation AssertLoc);
static SourceLocation getLastParenLoc(const ASTContext *ASTCtx,
SourceLocation AssertLoc);
};

} // namespace clang::tidy::misc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class ThrowByValueCatchByReferenceCheck : public ClangTidyCheck {
void diagnoseThrowLocations(const CXXThrowExpr *ThrowExpr);
void diagnoseCatchLocations(const CXXCatchStmt *CatchStmt,
ASTContext &Context);
bool isFunctionParameter(const DeclRefExpr *DeclRefExpr);
bool isCatchVariable(const DeclRefExpr *DeclRefExpr);
static bool isFunctionParameter(const DeclRefExpr *DeclRefExpr);
static bool isCatchVariable(const DeclRefExpr *DeclRefExpr);
bool isFunctionOrCatchVar(const DeclRefExpr *DeclRefExpr);
const bool CheckAnonymousTemporaries;
const bool WarnOnLargeObject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class UnusedParametersCheck::IndexerVisitor
return Index[Fn->getCanonicalDecl()].OtherRefs;
}

bool shouldTraversePostOrder() const { return true; }
static bool shouldTraversePostOrder() { return true; }

bool WalkUpFromDeclRefExpr(DeclRefExpr *DeclRef) {
if (const auto *Fn = dyn_cast<FunctionDecl>(DeclRef->getDecl())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ class ExternCRefutationVisitor
ExternCRefutationVisitor(std::vector<IncludeMarker> &IncludesToBeProcessed,
SourceManager &SM)
: IncludesToBeProcessed(IncludesToBeProcessed), SM(SM) {}
bool shouldWalkTypesOfTypeLocs() const { return false; }
bool shouldVisitLambdaBody() const { return false; }
static bool shouldWalkTypesOfTypeLocs() { return false; }
static bool shouldVisitLambdaBody() { return false; }

bool VisitLinkageSpecDecl(LinkageSpecDecl *LinkSpecDecl) const {
if (LinkSpecDecl->getLanguage() != LinkageSpecLanguageIDs::C ||
Expand Down
22 changes: 11 additions & 11 deletions clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,26 @@ class LoopConvertCheck : public ClangTidyCheck {
bool NeedsReverseCall = false;
};

void getAliasRange(SourceManager &SM, SourceRange &DeclRange);
static void getAliasRange(SourceManager &SM, SourceRange &DeclRange);

void doConversion(ASTContext *Context, const VarDecl *IndexVar,
const ValueDecl *MaybeContainer, const UsageResult &Usages,
const DeclStmt *AliasDecl, bool AliasUseRequired,
bool AliasFromForInit, const ForStmt *Loop,
RangeDescriptor Descriptor);

StringRef getContainerString(ASTContext *Context, const ForStmt *Loop,
const Expr *ContainerExpr);
static StringRef getContainerString(ASTContext *Context, const ForStmt *Loop,
const Expr *ContainerExpr);

void getArrayLoopQualifiers(ASTContext *Context,
const ast_matchers::BoundNodes &Nodes,
const Expr *ContainerExpr,
const UsageResult &Usages,
RangeDescriptor &Descriptor);
static void getArrayLoopQualifiers(ASTContext *Context,
const ast_matchers::BoundNodes &Nodes,
const Expr *ContainerExpr,
const UsageResult &Usages,
RangeDescriptor &Descriptor);

void getIteratorLoopQualifiers(ASTContext *Context,
const ast_matchers::BoundNodes &Nodes,
RangeDescriptor &Descriptor);
static void getIteratorLoopQualifiers(ASTContext *Context,
const ast_matchers::BoundNodes &Nodes,
RangeDescriptor &Descriptor);

void determineRangeDescriptor(ASTContext *Context,
const ast_matchers::BoundNodes &Nodes,
Expand Down
7 changes: 4 additions & 3 deletions clang-tools-extra/clang-tidy/modernize/UseStdNumbersCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,13 @@ AST_MATCHER_P(clang::Expr, anyOfExhaustive, std::vector<Matcher<clang::Stmt>>,
// the literal of every constant and for formulas' subexpressions that look at
// literals.
struct MatchBuilder {
auto
ignoreParenAndArithmeticCasting(const Matcher<clang::Expr> Matcher) const {
static auto
ignoreParenAndArithmeticCasting(const Matcher<clang::Expr> Matcher) {
return expr(hasType(qualType(isArithmetic())), ignoringParenCasts(Matcher));
}

auto ignoreParenAndFloatingCasting(const Matcher<clang::Expr> Matcher) const {
static auto
ignoreParenAndFloatingCasting(const Matcher<clang::Expr> Matcher) {
return expr(hasType(qualType(isFloating())), ignoringParenCasts(Matcher));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct UnqualNameVisitor : public RecursiveASTVisitor<UnqualNameVisitor> {

bool Collision = false;

bool shouldWalkTypesOfTypeLocs() const { return false; }
static bool shouldWalkTypesOfTypeLocs() { return false; }

bool visitUnqualName(StringRef UnqualName) {
// Check for collisions with function arguments.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ class UnnecessaryCopyInitialization : public ClangTidyCheck {
const VarDecl *ObjectArg);
void handleCopyFromLocalVar(const CheckContext &Ctx, const VarDecl &OldVar);

void maybeIssueFixes(const CheckContext &Ctx, DiagnosticBuilder &Diagnostic);
static void maybeIssueFixes(const CheckContext &Ctx,
DiagnosticBuilder &Diagnostic);

const std::vector<StringRef> AllowedTypes;
const std::vector<StringRef> ExcludedContainerTypes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ struct AvoidUnconditionalPreprocessorIfPPCallbacks : public PPCallbacks {
return true;
}

bool isImmutableToken(const Token &Tok) {
static bool isImmutableToken(const Token &Tok) {
switch (Tok.getKind()) {
case tok::eod:
case tok::eof:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ AST_MATCHER(CXXMethodDecl, usesThis) {

// If we enter a class declaration, don't traverse into it as any usages of
// `this` will correspond to the nested class.
bool TraverseCXXRecordDecl(CXXRecordDecl *RD) { return true; }
static bool TraverseCXXRecordDecl(CXXRecordDecl *RD) { return true; }

} UsageOfThis;

Expand Down
Loading