Skip to content
Open
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 @@ -27,7 +27,6 @@ Checks: >
-readability-implicit-bool-conversion,
-readability-isolate-declaration,
-readability-magic-numbers,
-readability-named-parameter,
-readability-qualified-auto,
-readability-simplify-boolean-expr,
-readability-static-definition-in-anonymous-namespace,
Expand Down
11 changes: 6 additions & 5 deletions clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ template <> struct MappingTraits<ClangTidyOptions::StringPair> {
};

struct NOptionMap {
NOptionMap(IO &) {}
NOptionMap(IO &, const ClangTidyOptions::OptionMap &OptionMap) {
NOptionMap(IO & /*unused*/) {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these truly named unused in the declaration?

Copy link
Contributor Author

@capitan-davide capitan-davide Sep 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case in particular, that parameter is never named; unused is what the checker falls back to when it cannot find a declaration with a name. In general, we can change the default unused to something more meaningful (manually)

NOptionMap(IO & /*unused*/, const ClangTidyOptions::OptionMap &OptionMap) {
Options.reserve(OptionMap.size());
for (const auto &KeyValue : OptionMap)
Options.emplace_back(std::string(KeyValue.getKey()),
KeyValue.getValue().Value);
}
ClangTidyOptions::OptionMap denormalize(IO &) {
ClangTidyOptions::OptionMap denormalize(IO & /*unused*/) {
ClangTidyOptions::OptionMap Map;
for (const auto &KeyValue : Options)
Map[KeyValue.first] = ClangTidyOptions::ClangTidyValue(KeyValue.second);
Expand All @@ -83,7 +83,7 @@ struct NOptionMap {
};

template <>
void yamlize(IO &IO, ClangTidyOptions::OptionMap &Val, bool,
void yamlize(IO &IO, ClangTidyOptions::OptionMap &Val, bool /*unused*/,
EmptyContext &Ctx) {
if (IO.outputting()) {
// Ensure check options are sorted
Expand Down Expand Up @@ -130,7 +130,8 @@ struct ChecksVariant {
std::optional<std::vector<std::string>> AsVector;
};

template <> void yamlize(IO &IO, ChecksVariant &Val, bool, EmptyContext &Ctx) {
template <>
void yamlize(IO &IO, ChecksVariant &Val, bool /*unused*/, EmptyContext &Ctx) {
if (!IO.outputting()) {
// Special case for reading from YAML
// Must support reading from both a string or a list
Expand Down
95 changes: 49 additions & 46 deletions clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,65 +181,63 @@ void ExpandModularHeadersPPCallbacks::EndOfMainFile() {
// Handle all other callbacks.
// Just parse to the corresponding location to generate the same callback for
// the PPCallbacks registered in our custom preprocessor.
void ExpandModularHeadersPPCallbacks::Ident(SourceLocation Loc, StringRef) {
void ExpandModularHeadersPPCallbacks::Ident(SourceLocation Loc,
StringRef /*str*/) {
parseToLocation(Loc);
}
void ExpandModularHeadersPPCallbacks::PragmaDirective(SourceLocation Loc,
PragmaIntroducerKind) {
void ExpandModularHeadersPPCallbacks::PragmaDirective(
SourceLocation Loc, PragmaIntroducerKind /*Introducer*/) {
parseToLocation(Loc);
}
void ExpandModularHeadersPPCallbacks::PragmaComment(SourceLocation Loc,
const IdentifierInfo *,
StringRef) {
void ExpandModularHeadersPPCallbacks::PragmaComment(
SourceLocation Loc, const IdentifierInfo * /*Kind*/, StringRef /*Str*/) {
parseToLocation(Loc);
}
void ExpandModularHeadersPPCallbacks::PragmaDetectMismatch(SourceLocation Loc,
StringRef,
StringRef) {
void ExpandModularHeadersPPCallbacks::PragmaDetectMismatch(
SourceLocation Loc, StringRef /*Name*/, StringRef /*Value*/) {
parseToLocation(Loc);
}
void ExpandModularHeadersPPCallbacks::PragmaDebug(SourceLocation Loc,
StringRef) {
StringRef /*DebugType*/) {
parseToLocation(Loc);
}
void ExpandModularHeadersPPCallbacks::PragmaMessage(SourceLocation Loc,
StringRef,
PragmaMessageKind,
StringRef) {
StringRef /*Namespace*/,
PragmaMessageKind /*Kind*/,
StringRef /*Str*/) {
parseToLocation(Loc);
}
void ExpandModularHeadersPPCallbacks::PragmaDiagnosticPush(SourceLocation Loc,
StringRef) {
void ExpandModularHeadersPPCallbacks::PragmaDiagnosticPush(
SourceLocation Loc, StringRef /*Namespace*/) {
parseToLocation(Loc);
}
void ExpandModularHeadersPPCallbacks::PragmaDiagnosticPop(SourceLocation Loc,
StringRef) {
void ExpandModularHeadersPPCallbacks::PragmaDiagnosticPop(
SourceLocation Loc, StringRef /*Namespace*/) {
parseToLocation(Loc);
}
void ExpandModularHeadersPPCallbacks::PragmaDiagnostic(SourceLocation Loc,
StringRef,
diag::Severity,
StringRef) {
void ExpandModularHeadersPPCallbacks::PragmaDiagnostic(
SourceLocation Loc, StringRef /*Namespace*/, diag::Severity /*mapping*/,
StringRef /*Str*/) {
parseToLocation(Loc);
}
void ExpandModularHeadersPPCallbacks::HasInclude(SourceLocation Loc, StringRef,
bool, OptionalFileEntryRef,
SrcMgr::CharacteristicKind) {
void ExpandModularHeadersPPCallbacks::HasInclude(
SourceLocation Loc, StringRef /*FileName*/, bool /*IsAngled*/,
OptionalFileEntryRef /*File*/, SrcMgr::CharacteristicKind /*FileType*/) {
parseToLocation(Loc);
}
void ExpandModularHeadersPPCallbacks::PragmaOpenCLExtension(
SourceLocation NameLoc, const IdentifierInfo *, SourceLocation StateLoc,
unsigned) {
SourceLocation NameLoc, const IdentifierInfo * /*Name*/,
SourceLocation StateLoc, unsigned /*State*/) {
// FIXME: Figure out whether it's the right location to parse to.
parseToLocation(NameLoc);
}
void ExpandModularHeadersPPCallbacks::PragmaWarning(SourceLocation Loc,
PragmaWarningSpecifier,
ArrayRef<int>) {
void ExpandModularHeadersPPCallbacks::PragmaWarning(
SourceLocation Loc, PragmaWarningSpecifier /*WarningSpec*/,
ArrayRef<int> /*Ids*/) {
parseToLocation(Loc);
}
void ExpandModularHeadersPPCallbacks::PragmaWarningPush(SourceLocation Loc,
int) {
int /*Level*/) {
parseToLocation(Loc);
}
void ExpandModularHeadersPPCallbacks::PragmaWarningPop(SourceLocation Loc) {
Expand All @@ -253,10 +251,9 @@ void ExpandModularHeadersPPCallbacks::PragmaAssumeNonNullEnd(
SourceLocation Loc) {
parseToLocation(Loc);
}
void ExpandModularHeadersPPCallbacks::MacroExpands(const Token &MacroNameTok,
const MacroDefinition &,
SourceRange Range,
const MacroArgs *) {
void ExpandModularHeadersPPCallbacks::MacroExpands(
const Token &MacroNameTok, const MacroDefinition & /*MD*/,
SourceRange Range, const MacroArgs * /*Args*/) {
// FIXME: Figure out whether it's the right location to parse to.
parseToLocation(Range.getBegin());
}
Expand All @@ -265,12 +262,13 @@ void ExpandModularHeadersPPCallbacks::MacroDefined(const Token &MacroNameTok,
parseToLocation(MD->getLocation());
}
void ExpandModularHeadersPPCallbacks::MacroUndefined(
const Token &, const MacroDefinition &, const MacroDirective *Undef) {
const Token & /*MacroNameTok*/, const MacroDefinition & /*MD*/,
const MacroDirective *Undef) {
if (Undef)
parseToLocation(Undef->getLocation());
}
void ExpandModularHeadersPPCallbacks::Defined(const Token &MacroNameTok,
const MacroDefinition &,
const MacroDefinition & /*MD*/,
SourceRange Range) {
// FIXME: Figure out whether it's the right location to parse to.
parseToLocation(Range.getBegin());
Expand All @@ -280,27 +278,32 @@ void ExpandModularHeadersPPCallbacks::SourceRangeSkipped(
// FIXME: Figure out whether it's the right location to parse to.
parseToLocation(EndifLoc);
}
void ExpandModularHeadersPPCallbacks::If(SourceLocation Loc, SourceRange,
ConditionValueKind) {
void ExpandModularHeadersPPCallbacks::If(
SourceLocation Loc, SourceRange /*ConditionRange*/,
ConditionValueKind /*ConditionValue*/) {
parseToLocation(Loc);
}
void ExpandModularHeadersPPCallbacks::Elif(SourceLocation Loc, SourceRange,
ConditionValueKind, SourceLocation) {
void ExpandModularHeadersPPCallbacks::Elif(
SourceLocation Loc, SourceRange /*ConditionRange*/,
ConditionValueKind /*ConditionValue*/, SourceLocation /*IfLoc*/) {
parseToLocation(Loc);
}
void ExpandModularHeadersPPCallbacks::Ifdef(SourceLocation Loc, const Token &,
const MacroDefinition &) {
void ExpandModularHeadersPPCallbacks::Ifdef(SourceLocation Loc,
const Token & /*MacroNameTok*/,
const MacroDefinition & /*MD*/) {
parseToLocation(Loc);
}
void ExpandModularHeadersPPCallbacks::Ifndef(SourceLocation Loc, const Token &,
const MacroDefinition &) {
void ExpandModularHeadersPPCallbacks::Ifndef(SourceLocation Loc,
const Token & /*MacroNameTok*/,
const MacroDefinition & /*MD*/) {
parseToLocation(Loc);
}
void ExpandModularHeadersPPCallbacks::Else(SourceLocation Loc, SourceLocation) {
void ExpandModularHeadersPPCallbacks::Else(SourceLocation Loc,
SourceLocation /*IfLoc*/) {
parseToLocation(Loc);
}
void ExpandModularHeadersPPCallbacks::Endif(SourceLocation Loc,
SourceLocation) {
SourceLocation /*IfLoc*/) {
parseToLocation(Loc);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,19 @@ class KernelNameRestrictionPPCallbacks : public PPCallbacks {

} // namespace

void KernelNameRestrictionCheck::registerPPCallbacks(const SourceManager &SM,
Preprocessor *PP,
Preprocessor *) {
void KernelNameRestrictionCheck::registerPPCallbacks(
const SourceManager &SM, Preprocessor *PP,
Preprocessor * /*ModuleExpanderPP*/) {
PP->addPPCallbacks(
std::make_unique<KernelNameRestrictionPPCallbacks>(*this, SM));
}

void KernelNameRestrictionPPCallbacks::InclusionDirective(
SourceLocation HashLoc, const Token &, StringRef FileName, bool,
CharSourceRange, OptionalFileEntryRef, StringRef, StringRef, const Module *,
bool, SrcMgr::CharacteristicKind) {
SourceLocation HashLoc, const Token & /*IncludeTok*/, StringRef FileName,
bool /*IsAngled*/, CharSourceRange /*FilenameRange*/,
OptionalFileEntryRef /*File*/, StringRef /*SearchPath*/,
StringRef /*RelativePath*/, const Module * /*SuggestedModule*/,
bool /*ModuleImported*/, SrcMgr::CharacteristicKind /*FileType*/) {
IncludeDirective ID = {HashLoc, FileName};
IncludeDirectives.push_back(std::move(ID));
}
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) {
bool TraverseLambdaExpr(LambdaExpr * /*unused*/,
DataRecursionQueue * /*unused*/ = nullptr) {
return true;
}

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

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

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

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

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

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ getFailureInfoImpl(StringRef Name, bool IsInGlobalNamespace, bool IsMacro,
}

std::optional<RenamerClangTidyCheck::FailureInfo>
ReservedIdentifierCheck::getDeclFailureInfo(const NamedDecl *Decl,
const SourceManager &) const {
ReservedIdentifierCheck::getDeclFailureInfo(
const NamedDecl *Decl, const SourceManager & /*SM*/) const {
assert(Decl && Decl->getIdentifier() && !Decl->getName().empty() &&
"Decl must be an explicit identifier with a name.");
// Implicit identifiers cannot fail.
Expand All @@ -187,8 +187,8 @@ ReservedIdentifierCheck::getDeclFailureInfo(const NamedDecl *Decl,
}

std::optional<RenamerClangTidyCheck::FailureInfo>
ReservedIdentifierCheck::getMacroFailureInfo(const Token &MacroNameTok,
const SourceManager &) const {
ReservedIdentifierCheck::getMacroFailureInfo(
const Token &MacroNameTok, const SourceManager & /*SM*/) const {
return getFailureInfoImpl(MacroNameTok.getIdentifierInfo()->getName(), true,
/*IsMacro = */ true, getLangOpts(), Invert,
AllowedIdentifiers);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class UpgradeGoogletestCasePPCallback : public PPCallbacks {
: Check(Check), PP(PP) {}

void MacroExpands(const Token &MacroNameTok, const MacroDefinition &MD,
SourceRange Range, const MacroArgs *) override {
SourceRange Range, const MacroArgs * /*Args*/) override {
macroUsed(MacroNameTok, MD, Range.getBegin(), CheckAction::Rename);
}

Expand Down Expand Up @@ -119,9 +119,9 @@ class UpgradeGoogletestCasePPCallback : public PPCallbacks {

} // namespace

void UpgradeGoogletestCaseCheck::registerPPCallbacks(const SourceManager &,
Preprocessor *PP,
Preprocessor *) {
void UpgradeGoogletestCaseCheck::registerPPCallbacks(
const SourceManager & /*SM*/, Preprocessor *PP,
Preprocessor * /*ModuleExpanderPP*/) {
PP->addPPCallbacks(
std::make_unique<UpgradeGoogletestCasePPCallback>(this, PP));
}
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-tidy/llvm/UseRangesCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class StdToLLVMReplacer : public utils::UseRangesCheck::Replacer {
}

std::optional<std::string>
getHeaderInclusion(const NamedDecl &) const override {
getHeaderInclusion(const NamedDecl & /*OriginalName*/) const override {
return "llvm/ADT/STLExtras.h";
}

Expand Down
11 changes: 7 additions & 4 deletions clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,13 @@ class CyclicDependencyCallbacks : public PPCallbacks {
Files.push_back({NewFile, FileName, std::exchange(NextToEnter, {})});
}

void InclusionDirective(SourceLocation, const Token &, StringRef FilePath,
bool, CharSourceRange Range,
OptionalFileEntryRef File, StringRef, StringRef,
const Module *, bool,
void InclusionDirective(SourceLocation /*HashLoc*/,
const Token & /*IncludeTok*/, StringRef FilePath,
bool /*IsAngled*/, CharSourceRange Range,
OptionalFileEntryRef File, StringRef /*SearchPath*/,
StringRef /*RelativePath*/,
const Module * /*SuggestedModule*/,
bool /*ModuleImported*/,
SrcMgr::CharacteristicKind FileType) override {
if (FileType != clang::SrcMgr::C_User)
return;
Expand Down
4 changes: 3 additions & 1 deletion clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,9 @@ static bool textEquals(const char (&Needle)[N], const char *HayStack) {
return StringRef{HayStack, N - 1} == Needle;
}

template <size_t N> static size_t len(const char (&)[N]) { return N - 1; }
template <size_t N> static size_t len(const char (& /*unused*/)[N]) {
return N - 1;
}

void MacroToEnumCallbacks::PragmaDirective(SourceLocation Loc,
PragmaIntroducerKind Introducer) {
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-tidy/plugin/ClangTidyPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class ClangTidyPluginAction : public PluginASTAction {
std::move(Context), std::move(DiagEngine), std::move(Vec));
}

bool ParseArgs(const CompilerInstance &,
bool ParseArgs(const CompilerInstance & /*CI*/,
const std::vector<std::string> &Args) override {
ClangTidyGlobalOptions GlobalOptions;
ClangTidyOptions DefaultOptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ class FindUsageOfThis : public RecursiveASTVisitor<FindUsageOfThis> {
return Parent;
}

bool VisitUnresolvedMemberExpr(const UnresolvedMemberExpr *) {
bool VisitUnresolvedMemberExpr(const UnresolvedMemberExpr * /*unused*/) {
// An UnresolvedMemberExpr might resolve to a non-const non-static
// member function.
Usage = NonConst;
return false; // Stop traversal.
}

bool VisitCXXConstCastExpr(const CXXConstCastExpr *) {
bool VisitCXXConstCastExpr(const CXXConstCastExpr * /*unused*/) {
// Workaround to support the pattern
// class C {
// const S *get() const;
Expand Down
Loading