Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions clang-tools-extra/clang-tidy/.clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ BasedOnStyle: LLVM
QualifierAlignment: Left
LineEnding: LF
InsertNewlineAtEOF: true
KeepEmptyLines:
AtEndOfFile: false
AtStartOfBlock: false
AtStartOfFile: false
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,6 @@ void ClangTidyDiagnosticConsumer::removeDuplicatedDiagnosticsOfAliasCheckers() {
(*Inserted.first)->Message.Fix;

if (CandidateFix != ExistingFix) {

// In case of a conflict, don't suggest any fix-it.
ExistingError.Message.Fix.clear();
ExistingError.Notes.emplace_back(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ bool KernelNameRestrictionPPCallbacks::fileNameIsRestricted(
}

void KernelNameRestrictionPPCallbacks::EndOfMainFile() {

// Check main file for restricted names.
OptionalFileEntryRef Entry = SM.getFileEntryRefForID(SM.getMainFileID());
const StringRef FileName = llvm::sys::path::filename(Entry->getName());
Expand Down
1 change: 0 additions & 1 deletion clang-tools-extra/clang-tidy/boost/UseRangesCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ class FixedBoostReplace : public BoostReplacer {
} // namespace

utils::UseRangesCheck::ReplacerMap UseRangesCheck::getReplacerMap() const {

ReplacerMap Results;
static const Signature SingleSig = {{0}};
static const Signature TwoSig = {{0}, {2}};
Expand Down
1 change: 0 additions & 1 deletion clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ void BranchCloneCheck::registerMatchers(MatchFinder *Finder) {
///
static bool isIdenticalStmt(const ASTContext &Ctx, const Stmt *Stmt1,
const Stmt *Stmt2, bool IgnoreSideEffects) {

if (!Stmt1 || !Stmt2)
return !Stmt1 && !Stmt2;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ static constexpr llvm::StringLiteral ErrorMsg =

void ComparePointerToMemberVirtualFunctionCheck::registerMatchers(
MatchFinder *Finder) {

auto DirectMemberVirtualFunctionPointer = unaryOperator(
allOf(hasOperatorName("&"),
hasUnaryOperand(declRefExpr(to(cxxMethodDecl(isVirtual()))))));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ handleFrom(const ast_matchers::internal::Matcher<RecordDecl> &IsAHandle,

static ast_matchers::internal::Matcher<Stmt> handleFromTemporaryValue(
const ast_matchers::internal::Matcher<RecordDecl> &IsAHandle) {

const auto TemporaryExpr = anyOf(
cxxBindTemporaryExpr(),
cxxFunctionalCastExpr(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ void IncDecInConditionsCheck::registerMatchers(MatchFinder *Finder) {
}

void IncDecInConditionsCheck::check(const MatchFinder::MatchResult &Result) {

SourceLocation ExprLoc;
bool IsIncrementOp = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ void MacroParenthesesPPCallbacks::replacementList(const Token &MacroNameTok,

void MacroParenthesesPPCallbacks::argument(const Token &MacroNameTok,
const MacroInfo *MI) {

// Skip variable declaration.
bool VarDecl = possibleVarDecl(MI, MI->tokens_begin());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ namespace clang::tidy::bugprone {

void NondeterministicPointerIterationOrderCheck::registerMatchers(
MatchFinder *Finder) {

auto LoopVariable = varDecl(hasType(
qualType(hasCanonicalType(anyOf(referenceType(), pointerType())))));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,9 @@ void OptionalValueConversionCheck::registerMatchers(MatchFinder *Finder) {
hasName(MakeOptional),
returns(BindOptionalType)))),
hasArgument(0, OptionalDerefMatcher)),
callExpr(

argumentCountIs(1),
callExpr(argumentCountIs(1),

hasArgument(0, OptionalDerefMatcher))),
hasArgument(0, OptionalDerefMatcher))),
unless(anyOf(hasAncestor(typeLoc()),
hasAncestor(expr(matchers::hasUnevaluatedContext())))))
.bind("expr"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ using namespace clang::ast_matchers;
namespace clang::tidy::bugprone {

void SpuriouslyWakeUpFunctionsCheck::registerMatchers(MatchFinder *Finder) {

auto HasUniqueLock = hasDescendant(declRefExpr(
hasDeclaration(varDecl(hasType(recordDecl(classTemplateSpecializationDecl(
hasName("::std::unique_lock"),
Expand Down Expand Up @@ -45,9 +44,7 @@ void SpuriouslyWakeUpFunctionsCheck::registerMatchers(MatchFinder *Finder) {
onImplicitObjectArgument(
declRefExpr(to(varDecl(hasType(references(recordDecl(
hasName("::std::condition_variable")))))))),
HasUniqueLock)

))
HasUniqueLock)))
.bind("wait"));

auto HasWaitDescendantC = hasDescendant(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,8 @@ void SuspiciousMemsetUsageCheck::check(const MatchFinder::MatchResult &Result) {
return;
Diag << FixItHint::CreateReplacement(
CharSourceRange::getTokenRange(CharRange), "0");
}

else if (const auto *NumFill =
Result.Nodes.getNodeAs<IntegerLiteral>("num-fill")) {
} else if (const auto *NumFill =
Result.Nodes.getNodeAs<IntegerLiteral>("num-fill")) {
// Case 2: fill_char of memset() is larger in size than an unsigned char
// so it gets truncated during conversion.

Expand All @@ -88,9 +86,7 @@ void SuspiciousMemsetUsageCheck::check(const MatchFinder::MatchResult &Result) {

diag(NumFill->getBeginLoc(), "memset fill value is out of unsigned "
"character range, gets truncated");
}

else if (const auto *Call = Result.Nodes.getNodeAs<CallExpr>("call")) {
} else if (const auto *Call = Result.Nodes.getNodeAs<CallExpr>("call")) {
// Case 3: byte_count of memset() is zero. This is most likely an
// argument swap.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ SuspiciousStringviewDataUsageCheck::getCheckTraversalKind() const {
}

void SuspiciousStringviewDataUsageCheck::registerMatchers(MatchFinder *Finder) {

auto AncestorCall = anyOf(
cxxConstructExpr(), callExpr(unless(cxxOperatorCallExpr())), lambdaExpr(),
initListExpr(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ void TaggedUnionMemberCountCheck::storeOptions(
}

void TaggedUnionMemberCountCheck::registerMatchers(MatchFinder *Finder) {

auto NotFromSystemHeaderOrStdNamespace =
unless(anyOf(isExpansionInSystemHeader(), isInStdNamespace()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ void ProBoundsAvoidUncheckedContainerAccessCheck::registerMatchers(

void ProBoundsAvoidUncheckedContainerAccessCheck::check(
const MatchFinder::MatchResult &Result) {

const auto *MatchedExpr = Result.Nodes.getNodeAs<CallExpr>("caller");

if (FixMode == None) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,6 @@ void ProTypeMemberInitCheck::checkMissingMemberInitializer(
void ProTypeMemberInitCheck::checkMissingBaseClassInitializer(
const ASTContext &Context, const CXXRecordDecl &ClassDecl,
const CXXConstructorDecl *Ctor) {

// Gather any base classes that need to be initialized.
SmallVector<const RecordDecl *, 4> AllBases;
SmallPtrSet<const RecordDecl *, 4> BasesToInit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ toString(SpecialMemberFunctionsCheck::SpecialMemberFunctionKind K) {
static std::string
join(ArrayRef<SpecialMemberFunctionsCheck::SpecialMemberFunctionKind> SMFS,
llvm::StringRef AndOr) {

assert(!SMFS.empty() &&
"List of defined or undefined members should never be empty.");
std::string Buffer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ static FixItHint changePrivateDestructorVisibilityTo(

void VirtualClassDestructorCheck::check(
const MatchFinder::MatchResult &Result) {

const auto *MatchedClassOrStruct =
Result.Nodes.getNodeAs<CXXRecordDecl>("ProblematicClassOrStruct");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ using namespace clang::ast_matchers;
namespace clang::tidy::google::objc {

void AvoidThrowingObjCExceptionCheck::registerMatchers(MatchFinder *Finder) {

Finder->addMatcher(objcThrowStmt().bind("throwStmt"), this);
Finder->addMatcher(
objcMessageExpr(anyOf(hasSelector("raise:format:"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ void PreferStaticOverAnonymousNamespaceCheck::registerMatchers(

void PreferStaticOverAnonymousNamespaceCheck::check(
const MatchFinder::MatchResult &Result) {

if (const auto *Func = Result.Nodes.getNodeAs<FunctionDecl>("function")) {
if (Func->isCXXClassMember())
diag(Func->getLocation(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ static llvm::SmallString<64U> skeleton(StringRef Name) {
const char *Curr = Name.data();
const char *End = Curr + Name.size();
while (Curr < End) {

const char *Prev = Curr;
UTF32 CodePoint = 0;
const ConversionResult Result = convertUTF8Sequence(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,6 @@ static bool areStringsSameIgnoreSpaces(const llvm::StringRef Left,

static bool areExprsSameMacroOrLiteral(const BinaryOperator *BinOp,
const ASTContext *Context) {

if (!BinOp)
return false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ void UnusedParametersCheck::warnOnUnusedParameter(
!Result.SourceManager->isInMainFile(Function->getLocation()) ||
!Indexer->getOtherRefs(Function).empty() || isOverrideMethod(Function) ||
isLambdaCallOperator(Function)) {

// It is illegal to omit parameter name here in C code, so early-out.
if (!Result.Context->getLangOpts().CPlusPlus)
return;
Expand Down
3 changes: 0 additions & 3 deletions clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ buildBindArguments(const MatchFinder::MatchResult &Result,
// Start at index 1 as first argument to bind is the function name.
unsigned CaptureIndex = 0;
for (size_t I = 1, ArgCount = BindCall->getNumArgs(); I < ArgCount; ++I) {

const Expr *E = BindCall->getArg(I);
BindArgument &B = BindArguments.emplace_back();

Expand Down Expand Up @@ -327,7 +326,6 @@ static int findPositionOfPlaceholderUse(ArrayRef<BindArgument> Args,
static void addPlaceholderArgs(const LambdaProperties &LP,
llvm::raw_ostream &Stream,
bool PermissiveParameterList) {

ArrayRef<BindArgument> Args = LP.BindArguments;

const auto *MaxPlaceholderIt = llvm::max_element(
Expand Down Expand Up @@ -465,7 +463,6 @@ static const FunctionDecl *getCallOperator(const CXXRecordDecl *Callable,
static const FunctionDecl *
getCallMethodDecl(const MatchFinder::MatchResult &Result, CallableType Type,
CallableMaterializationKind Materialization) {

const Expr *Callee = Result.Nodes.getNodeAs<Expr>("ref");
const Expr *CallExpression = ignoreTemporariesAndPointers(Callee);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ IncludeModernizePPCallbacks::IncludeModernizePPCallbacks(
const LangOptions &LangOpts, const SourceManager &SM, bool CheckHeaderFile)
: IncludesToBeProcessed(IncludesToBeProcessed), SM(SM),
CheckHeaderFile(CheckHeaderFile) {

static constexpr std::pair<StringRef, StringRef> CXX98Headers[] = {
{"assert.h", "cassert"}, {"complex.h", "complex"},
{"ctype.h", "cctype"}, {"errno.h", "cerrno"},
Expand Down Expand Up @@ -167,7 +166,6 @@ void IncludeModernizePPCallbacks::InclusionDirective(
bool IsAngled, CharSourceRange FilenameRange, OptionalFileEntryRef File,
StringRef SearchPath, StringRef RelativePath, const Module *SuggestedModule,
bool ModuleImported, SrcMgr::CharacteristicKind FileType) {

// If we don't want to warn for non-main file reports and this is one, skip
// it.
if (!CheckHeaderFile && !SM.isInMainFile(HashLoc))
Expand Down
2 changes: 0 additions & 2 deletions clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ static StatementMatcher makeArrayLoopMatcher() {
/// Client code will need to make sure that:
/// - The two containers on which 'begin' and 'end' are called are the same.
static StatementMatcher makeIteratorLoopMatcher(bool IsReverse) {

auto BeginNameMatcher = IsReverse ? hasAnyName("rbegin", "crbegin")
: hasAnyName("begin", "cbegin");
auto BeginNameMatcherStd = IsReverse
Expand Down Expand Up @@ -563,7 +562,6 @@ LoopConvertCheck::LoopConvertCheck(StringRef Name, ClangTidyContext *Context)
UseCxx20IfAvailable(Options.get("UseCxx20ReverseRanges", true)),
ReverseFunction(Options.get("MakeReverseRangeFunction", "")),
ReverseHeader(Options.get("MakeReverseRangeHeader", "")) {

if (ReverseFunction.empty() && !ReverseHeader.empty()) {
configurationDiag(
"modernize-loop-convert: 'MakeReverseRangeHeader' is set but "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ void MinMaxUseInitializerListCheck::registerPPCallbacks(

void MinMaxUseInitializerListCheck::check(
const MatchFinder::MatchResult &Match) {

const auto *TopCall = Match.Nodes.getNodeAs<CallExpr>("topCall");

const FindArgsResult Result = findArgs(TopCall);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ matchEnableIfSpecializationImplTypename(TypeLoc TheType) {

if (const auto SpecializationLoc =
TheType.getAs<TemplateSpecializationTypeLoc>()) {

const auto *Specialization =
dyn_cast<TemplateSpecializationType>(SpecializationLoc.getTypePtr());
if (!Specialization)
Expand Down Expand Up @@ -101,7 +100,6 @@ static std::optional<TemplateSpecializationTypeLoc>
matchEnableIfSpecializationImplTrait(TypeLoc TheType) {
if (const auto SpecializationLoc =
TheType.getAs<TemplateSpecializationTypeLoc>()) {

const auto *Specialization =
dyn_cast<TemplateSpecializationType>(SpecializationLoc.getTypePtr());
if (!Specialization)
Expand Down Expand Up @@ -182,7 +180,6 @@ matchTrailingTemplateParam(const FunctionTemplateDecl *FunctionTemplate) {
TemplateParams->getParam(TemplateParams->size() - 1);
if (const auto *LastTemplateParam =
dyn_cast<NonTypeTemplateParmDecl>(LastParam)) {

if (!LastTemplateParam->hasDefaultArgument() ||
!LastTemplateParam->getName().empty())
return {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ static unsigned getNumberOfDesignated(const InitListExpr *SyntacticInitList) {
namespace {

struct Designators {

Designators(const InitListExpr *InitList) : InitList(InitList) {
assert(InitList->isSyntacticForm());
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ void UseOverrideCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
}

void UseOverrideCheck::registerMatchers(MatchFinder *Finder) {

auto IgnoreDestructorMatcher =
IgnoreDestructors ? cxxMethodDecl(unless(cxxDestructorDecl()))
: cxxMethodDecl();
Expand Down
1 change: 0 additions & 1 deletion clang-tools-extra/clang-tidy/modernize/UseRangesCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ class StdNumericReplacer : public StdReplacer {
} // namespace

utils::UseRangesCheck::ReplacerMap UseRangesCheck::getReplacerMap() const {

utils::UseRangesCheck::ReplacerMap Result;

// template<typename Iter> Func(Iter first, Iter last,...).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ UseStdPrintCheck::UseStdPrintCheck(StringRef Name, ClangTidyContext *Context)
utils::IncludeSorter::IS_LLVM),
areDiagsSelfContained()),
MaybeHeaderToInclude(Options.get("PrintHeader")) {

if (PrintfLikeFunctions.empty() && FprintfLikeFunctions.empty()) {
PrintfLikeFunctions.emplace_back("::printf");
PrintfLikeFunctions.emplace_back("absl::PrintF");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ static SourceRange
findReturnTypeAndCVSourceRange(const FunctionDecl &F, const TypeLoc &ReturnLoc,
const ASTContext &Ctx, const SourceManager &SM,
const LangOptions &LangOpts, Preprocessor *PP) {

// We start with the range of the return type and expand to neighboring
// qualifiers (const, volatile and restrict).
SourceRange ReturnTypeRange = F.getReturnTypeSourceRange();
Expand Down Expand Up @@ -459,7 +458,6 @@ UseTrailingReturnTypeCheck::UseTrailingReturnTypeCheck(
: ClangTidyCheck(Name, Context),
TransformFunctions(Options.get("TransformFunctions", true)),
TransformLambdas(Options.get("TransformLambdas", TransformLambda::All)) {

if (TransformFunctions == false && TransformLambdas == TransformLambda::None)
this->configurationDiag(
"The check 'modernize-use-trailing-return-type' will not perform any "
Expand Down Expand Up @@ -604,7 +602,6 @@ void UseTrailingReturnTypeCheck::check(const MatchFinder::MatchResult &Result) {
void UseTrailingReturnTypeCheck::diagOnLambda(
const LambdaExpr *Lambda,
const ast_matchers::MatchFinder::MatchResult &Result) {

const CXXMethodDecl *Method = Lambda->getCallOperator();
if (!Method || Lambda->hasExplicitResultType())
return;
Expand Down
1 change: 0 additions & 1 deletion clang-tools-extra/clang-tidy/modernize/UseUsingCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ namespace clang::tidy::modernize {
/// For the user-facing documentation see:
/// https://clang.llvm.org/extra/clang-tidy/checks/modernize/use-using.html
class UseUsingCheck : public ClangTidyCheck {

const bool IgnoreMacros;
const bool IgnoreExternC;
SourceLocation LastReplacementEnd;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ using namespace clang::ast_matchers;
namespace clang::tidy::performance {

void NoexceptSwapCheck::registerMatchers(MatchFinder *Finder) {

// Match non-const method with single argument that is non-const reference to
// a class type that owns method and return void.
// Matches: void Class::swap(Class&)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ static SourceRange getTypeRange(const ParmVarDecl &Param) {
static std::optional<Token>
findConstToRemove(const ParmVarDecl &Param,
const MatchFinder::MatchResult &Result) {

const CharSourceRange FileRange = Lexer::makeFileCharRange(
CharSourceRange::getTokenRange(getTypeRange(Param)),
*Result.SourceManager, Result.Context->getLangOpts());
Expand Down
Loading
Loading