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
2 changes: 2 additions & 0 deletions clang-tools-extra/clang-tidy/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BasedOnStyle: LLVM
QualifierAlignment: Left
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ AST_MATCHER(CXXRecordDecl, correctHandleCaptureThisLambda) {
if (Node.hasSimpleMoveAssignment())
return false;

for (CXXConstructorDecl const *C : Node.ctors()) {
for (const CXXConstructorDecl *C : Node.ctors()) {
if (C->isCopyOrMoveConstructor() && C->isDefaulted() && !C->isDeleted())
return false;
}
for (CXXMethodDecl const *M : Node.methods()) {
for (const CXXMethodDecl *M : Node.methods()) {
if (M->isCopyAssignmentOperator())
llvm::errs() << M->isDeleted() << "\n";
if (M->isCopyAssignmentOperator() && M->isDefaulted() && !M->isDeleted())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class MultiLevelImplicitPointerConversionCheck : public ClangTidyCheck {
}

private:
bool const EnableInC;
const bool EnableInC;
};

} // namespace clang::tidy::bugprone
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class SmartPtrArrayMismatchCheck : public ClangTidyCheck {
static const char PointerTypeN[];

private:
StringRef const SmartPointerName;
const StringRef SmartPointerName;
};

} // namespace clang::tidy::bugprone
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ AST_MATCHER(VarDecl, isReferenced) { return Node.isReferenced(); }
AST_MATCHER(VarDecl, explicitMarkUnused) {
// Implementations should not emit a warning that a name-independent
// declaration is used or unused.
LangOptions const &LangOpts = Finder->getASTContext().getLangOpts();
const LangOptions &LangOpts = Finder->getASTContext().getLangOpts();
return Node.hasAttr<UnusedAttr>() ||
(LangOpts.CPlusPlus26 && Node.isPlaceholderVar(LangOpts));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,73 +14,73 @@ using namespace clang::ast_matchers;

namespace clang::tidy::cppcoreguidelines {

static bool isCopyConstructible(CXXRecordDecl const &Node) {
static bool isCopyConstructible(const CXXRecordDecl &Node) {
if (Node.needsOverloadResolutionForCopyConstructor() &&
Node.needsImplicitCopyConstructor()) {
// unresolved
for (CXXBaseSpecifier const &BS : Node.bases()) {
CXXRecordDecl const *BRD = BS.getType()->getAsCXXRecordDecl();
for (const CXXBaseSpecifier &BS : Node.bases()) {
const CXXRecordDecl *BRD = BS.getType()->getAsCXXRecordDecl();
if (BRD != nullptr && !isCopyConstructible(*BRD))
return false;
}
}
if (Node.hasSimpleCopyConstructor())
return true;
for (CXXConstructorDecl const *Ctor : Node.ctors())
for (const CXXConstructorDecl *Ctor : Node.ctors())
if (Ctor->isCopyConstructor())
return !Ctor->isDeleted();
return false;
}

static bool isMoveConstructible(CXXRecordDecl const &Node) {
static bool isMoveConstructible(const CXXRecordDecl &Node) {
if (Node.needsOverloadResolutionForMoveConstructor() &&
Node.needsImplicitMoveConstructor()) {
// unresolved
for (CXXBaseSpecifier const &BS : Node.bases()) {
CXXRecordDecl const *BRD = BS.getType()->getAsCXXRecordDecl();
for (const CXXBaseSpecifier &BS : Node.bases()) {
const CXXRecordDecl *BRD = BS.getType()->getAsCXXRecordDecl();
if (BRD != nullptr && !isMoveConstructible(*BRD))
return false;
}
}
if (Node.hasSimpleMoveConstructor())
return true;
for (CXXConstructorDecl const *Ctor : Node.ctors())
for (const CXXConstructorDecl *Ctor : Node.ctors())
if (Ctor->isMoveConstructor())
return !Ctor->isDeleted();
return false;
}

static bool isCopyAssignable(CXXRecordDecl const &Node) {
static bool isCopyAssignable(const CXXRecordDecl &Node) {
if (Node.needsOverloadResolutionForCopyAssignment() &&
Node.needsImplicitCopyAssignment()) {
// unresolved
for (CXXBaseSpecifier const &BS : Node.bases()) {
CXXRecordDecl const *BRD = BS.getType()->getAsCXXRecordDecl();
for (const CXXBaseSpecifier &BS : Node.bases()) {
const CXXRecordDecl *BRD = BS.getType()->getAsCXXRecordDecl();
if (BRD != nullptr && !isCopyAssignable(*BRD))
return false;
}
}
if (Node.hasSimpleCopyAssignment())
return true;
for (CXXMethodDecl const *Method : Node.methods())
for (const CXXMethodDecl *Method : Node.methods())
if (Method->isCopyAssignmentOperator())
return !Method->isDeleted();
return false;
}

static bool isMoveAssignable(CXXRecordDecl const &Node) {
static bool isMoveAssignable(const CXXRecordDecl &Node) {
if (Node.needsOverloadResolutionForMoveAssignment() &&
Node.needsImplicitMoveAssignment()) {
// unresolved
for (CXXBaseSpecifier const &BS : Node.bases()) {
CXXRecordDecl const *BRD = BS.getType()->getAsCXXRecordDecl();
for (const CXXBaseSpecifier &BS : Node.bases()) {
const CXXRecordDecl *BRD = BS.getType()->getAsCXXRecordDecl();
if (BRD != nullptr && !isMoveAssignable(*BRD))
return false;
}
}
if (Node.hasSimpleMoveAssignment())
return true;
for (CXXMethodDecl const *Method : Node.methods())
for (const CXXMethodDecl *Method : Node.methods())
if (Method->isMoveAssignmentOperator())
return !Method->isDeleted();
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ using namespace clang;
namespace {

AST_MATCHER(NamedDecl, isOperatorDecl) {
DeclarationName::NameKind const NK = Node.getDeclName().getNameKind();
const DeclarationName::NameKind NK = Node.getDeclName().getNameKind();
return NK != DeclarationName::Identifier &&
NK != DeclarationName::CXXConstructorName &&
NK != DeclarationName::CXXDestructorName;
Expand Down Expand Up @@ -104,7 +104,7 @@ void OverrideWithDifferentVisibilityCheck::check(

const auto *const OverriddenFunction =
Result.Nodes.getNodeAs<FunctionDecl>("base_func");
AccessSpecifier const ActualAccess = MatchedFunction->getAccess();
const AccessSpecifier ActualAccess = MatchedFunction->getAccess();
AccessSpecifier OverriddenAccess = OverriddenFunction->getAccess();

const CXXBaseSpecifier *InheritanceWithStrictVisibility = nullptr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,14 @@ void ConcatNestedNamespacesCheck::reportDiagnostic(
ConcatNameSpace.append("::");
}

for (SourceRange const &Front : Fronts)
for (const SourceRange &Front : Fronts)
DB << FixItHint::CreateRemoval(Front);
DB << FixItHint::CreateReplacement(
Namespaces.back().getReplacedNamespaceFrontRange(), ConcatNameSpace);
if (LastRBrace != Namespaces.back().getDefaultNamespaceBackRange())
DB << FixItHint::CreateReplacement(LastRBrace,
("} // " + ConcatNameSpace).str());
for (SourceRange const &Back : llvm::reverse(Backs))
for (const SourceRange &Back : llvm::reverse(Backs))
DB << FixItHint::CreateRemoval(Back);
}

Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,14 +334,14 @@ void UseAutoCheck::replaceIterators(const DeclStmt *D, ASTContext *Context) {

static void ignoreTypeLocClasses(
TypeLoc &Loc,
std::initializer_list<TypeLoc::TypeLocClass> const &LocClasses) {
const std::initializer_list<TypeLoc::TypeLocClass> &LocClasses) {
while (llvm::is_contained(LocClasses, Loc.getTypeLocClass()))
Loc = Loc.getNextTypeLoc();
}

static bool isMultiLevelPointerToTypeLocClasses(
TypeLoc Loc,
std::initializer_list<TypeLoc::TypeLocClass> const &LocClasses) {
const std::initializer_list<TypeLoc::TypeLocClass> &LocClasses) {
ignoreTypeLocClasses(Loc, {TypeLoc::Paren, TypeLoc::Qualified});
TypeLoc::TypeLocClass TLC = Loc.getTypeLocClass();
if (TLC != TypeLoc::Pointer && TLC != TypeLoc::MemberPointer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -953,30 +953,30 @@ std::string IdentifierNamingCheck::fixupWithCase(
break;

case IdentifierNamingCheck::CT_LowerCase:
for (auto const &Word : Words) {
for (const auto &Word : Words) {
if (&Word != &Words.front())
Fixup += "_";
Fixup += Word.lower();
}
break;

case IdentifierNamingCheck::CT_UpperCase:
for (auto const &Word : Words) {
for (const auto &Word : Words) {
if (&Word != &Words.front())
Fixup += "_";
Fixup += Word.upper();
}
break;

case IdentifierNamingCheck::CT_CamelCase:
for (auto const &Word : Words) {
for (const auto &Word : Words) {
Fixup += toupper(Word.front());
Fixup += Word.substr(1).lower();
}
break;

case IdentifierNamingCheck::CT_CamelBack:
for (auto const &Word : Words) {
for (const auto &Word : Words) {
if (&Word == &Words.front()) {
Fixup += Word.lower();
} else {
Expand All @@ -987,7 +987,7 @@ std::string IdentifierNamingCheck::fixupWithCase(
break;

case IdentifierNamingCheck::CT_CamelSnakeCase:
for (auto const &Word : Words) {
for (const auto &Word : Words) {
if (&Word != &Words.front())
Fixup += "_";
Fixup += toupper(Word.front());
Expand All @@ -996,7 +996,7 @@ std::string IdentifierNamingCheck::fixupWithCase(
break;

case IdentifierNamingCheck::CT_CamelSnakeBack:
for (auto const &Word : Words) {
for (const auto &Word : Words) {
if (&Word != &Words.front()) {
Fixup += "_";
Fixup += toupper(Word.front());
Expand All @@ -1008,7 +1008,7 @@ std::string IdentifierNamingCheck::fixupWithCase(
break;

case IdentifierNamingCheck::CT_LeadingUpperSnakeCase:
for (auto const &Word : Words) {
for (const auto &Word : Words) {
if (&Word != &Words.front()) {
Fixup += "_";
Fixup += Word.lower();
Expand Down