Skip to content

Commit 68070f9

Browse files
authored
[clang-tidy][NFC] run clang-format over 'cert', 'cppcore', 'fuchsia',… (llvm#143316)
… 'google' checks
1 parent ce46adb commit 68070f9

22 files changed

+83
-76
lines changed

clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,7 @@ class CERTModule : public ClangTidyModule {
250250
"cert-dcl51-cpp");
251251
CheckFactories.registerCheck<misc::NewDeleteOverloadsCheck>(
252252
"cert-dcl54-cpp");
253-
CheckFactories.registerCheck<DontModifyStdNamespaceCheck>(
254-
"cert-dcl58-cpp");
253+
CheckFactories.registerCheck<DontModifyStdNamespaceCheck>("cert-dcl58-cpp");
255254
CheckFactories.registerCheck<google::build::UnnamedNamespaceInHeaderCheck>(
256255
"cert-dcl59-cpp");
257256
// ERR
@@ -278,8 +277,7 @@ class CERTModule : public ClangTidyModule {
278277
"cert-oop54-cpp");
279278
CheckFactories.registerCheck<NonTrivialTypesLibcMemoryCallsCheck>(
280279
"cert-oop57-cpp");
281-
CheckFactories.registerCheck<MutatingCopyCheck>(
282-
"cert-oop58-cpp");
280+
CheckFactories.registerCheck<MutatingCopyCheck>("cert-oop58-cpp");
283281

284282
// C checkers
285283
// ARR

clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -433,21 +433,22 @@ void ProTypeMemberInitCheck::checkMissingMemberInitializer(
433433
// Gather all fields (direct and indirect) that need to be initialized.
434434
SmallPtrSet<const FieldDecl *, 16> FieldsToInit;
435435
bool AnyMemberHasInitPerUnion = false;
436-
forEachFieldWithFilter(ClassDecl, ClassDecl.fields(),
437-
AnyMemberHasInitPerUnion, [&](const FieldDecl *F) {
438-
if (IgnoreArrays && F->getType()->isArrayType())
439-
return;
440-
if (F->hasInClassInitializer() && F->getParent()->isUnion()) {
441-
AnyMemberHasInitPerUnion = true;
442-
removeFieldInitialized(F, FieldsToInit);
443-
}
444-
if (!F->hasInClassInitializer() &&
445-
utils::type_traits::isTriviallyDefaultConstructible(F->getType(),
446-
Context) &&
447-
!isEmpty(Context, F->getType()) && !F->isUnnamedBitField() &&
448-
!AnyMemberHasInitPerUnion)
449-
FieldsToInit.insert(F);
450-
});
436+
forEachFieldWithFilter(
437+
ClassDecl, ClassDecl.fields(), AnyMemberHasInitPerUnion,
438+
[&](const FieldDecl *F) {
439+
if (IgnoreArrays && F->getType()->isArrayType())
440+
return;
441+
if (F->hasInClassInitializer() && F->getParent()->isUnion()) {
442+
AnyMemberHasInitPerUnion = true;
443+
removeFieldInitialized(F, FieldsToInit);
444+
}
445+
if (!F->hasInClassInitializer() &&
446+
utils::type_traits::isTriviallyDefaultConstructible(F->getType(),
447+
Context) &&
448+
!isEmpty(Context, F->getType()) && !F->isUnnamedBitField() &&
449+
!AnyMemberHasInitPerUnion)
450+
FieldsToInit.insert(F);
451+
});
451452
if (FieldsToInit.empty())
452453
return;
453454

@@ -500,17 +501,18 @@ void ProTypeMemberInitCheck::checkMissingMemberInitializer(
500501
AnyMemberHasInitPerUnion = false;
501502
forEachFieldWithFilter(ClassDecl, ClassDecl.fields(),
502503
AnyMemberHasInitPerUnion, [&](const FieldDecl *F) {
503-
if (!FieldsToInit.count(F))
504-
return;
505-
// Don't suggest fixes for enums because we don't know a good default.
506-
// Don't suggest fixes for bitfields because in-class initialization is not
507-
// possible until C++20.
508-
if (F->getType()->isEnumeralType() ||
509-
(!getLangOpts().CPlusPlus20 && F->isBitField()))
510-
return;
511-
FieldsToFix.insert(F);
512-
AnyMemberHasInitPerUnion = true;
513-
});
504+
if (!FieldsToInit.count(F))
505+
return;
506+
// Don't suggest fixes for enums because we don't
507+
// know a good default. Don't suggest fixes for
508+
// bitfields because in-class initialization is not
509+
// possible until C++20.
510+
if (F->getType()->isEnumeralType() ||
511+
(!getLangOpts().CPlusPlus20 && F->isBitField()))
512+
return;
513+
FieldsToFix.insert(F);
514+
AnyMemberHasInitPerUnion = true;
515+
});
514516
if (FieldsToFix.empty())
515517
return;
516518

clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@
1414
namespace clang::tidy::cppcoreguidelines {
1515

1616
/// Flags slicing (incomplete copying of an object's state) of member variables
17-
/// or vtable. See:
18-
/// - https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es63-dont-slice
19-
/// for the former, and
20-
/// - https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c145-access-polymorphic-objects-through-pointers-and-references
21-
/// for the latter
17+
/// or vtable.
2218
///
2319
/// For the user-facing documentation see:
2420
/// http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/slicing.html

clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ void SpecialMemberFunctionsCheck::check(
116116
if (!MatchedDecl)
117117
return;
118118

119-
ClassDefId ID(MatchedDecl->getLocation(), std::string(MatchedDecl->getName()));
119+
ClassDefId ID(MatchedDecl->getLocation(),
120+
std::string(MatchedDecl->getName()));
120121

121122
auto StoreMember = [this, &ID](SpecialMemberFunctionData Data) {
122123
llvm::SmallVectorImpl<SpecialMemberFunctionData> &Members =

clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,12 @@ struct DenseMapInfo<
8484
clang::tidy::cppcoreguidelines::SpecialMemberFunctionsCheck::ClassDefId;
8585

8686
static inline ClassDefId getEmptyKey() {
87-
return {DenseMapInfo<clang::SourceLocation>::getEmptyKey(),
88-
"EMPTY"};
87+
return {DenseMapInfo<clang::SourceLocation>::getEmptyKey(), "EMPTY"};
8988
}
9089

9190
static inline ClassDefId getTombstoneKey() {
9291
return {DenseMapInfo<clang::SourceLocation>::getTombstoneKey(),
93-
"TOMBSTONE"};
92+
"TOMBSTONE"};
9493
}
9594

9695
static unsigned getHashValue(ClassDefId Val) {

clang-tools-extra/clang-tidy/darwin/AvoidSpinlockCheck.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace clang::tidy::darwin {
1919
/// For the user-facing documentation see:
2020
/// http://clang.llvm.org/extra/clang-tidy/checks/darwin/avoid-spinlock.html
2121
class AvoidSpinlockCheck : public ClangTidyCheck {
22-
public:
22+
public:
2323
AvoidSpinlockCheck(StringRef Name, ClangTidyContext *Context)
2424
: ClangTidyCheck(Name, Context) {}
2525
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
@@ -28,4 +28,4 @@ class AvoidSpinlockCheck : public ClangTidyCheck {
2828

2929
} // namespace clang::tidy::darwin
3030

31-
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_DARWIN_AVOIDSPINLOCKCHECK_H
31+
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_DARWIN_AVOIDSPINLOCKCHECK_H

clang-tools-extra/clang-tidy/darwin/DarwinTidyModule.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ namespace darwin {
1818
class DarwinModule : public ClangTidyModule {
1919
public:
2020
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
21-
CheckFactories.registerCheck<AvoidSpinlockCheck>(
22-
"darwin-avoid-spinlock");
21+
CheckFactories.registerCheck<AvoidSpinlockCheck>("darwin-avoid-spinlock");
2322
CheckFactories.registerCheck<DispatchOnceNonstaticCheck>(
2423
"darwin-dispatch-once-nonstatic");
2524
}

clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ bool MultipleInheritanceCheck::getInterfaceStatus(const CXXRecordDecl *Node,
4949
bool MultipleInheritanceCheck::isCurrentClassInterface(
5050
const CXXRecordDecl *Node) const {
5151
// Interfaces should have no fields.
52-
if (!Node->field_empty()) return false;
52+
if (!Node->field_empty())
53+
return false;
5354

5455
// Interfaces should have exclusively pure methods.
5556
return llvm::none_of(Node->methods(), [](const CXXMethodDecl *M) {
@@ -68,11 +69,14 @@ bool MultipleInheritanceCheck::isInterface(const CXXRecordDecl *Node) {
6869

6970
// To be an interface, all base classes must be interfaces as well.
7071
for (const auto &I : Node->bases()) {
71-
if (I.isVirtual()) continue;
72+
if (I.isVirtual())
73+
continue;
7274
const auto *Ty = I.getType()->getAs<RecordType>();
73-
if (!Ty) continue;
75+
if (!Ty)
76+
continue;
7477
const RecordDecl *D = Ty->getDecl()->getDefinition();
75-
if (!D) continue;
78+
if (!D)
79+
continue;
7680
const auto *Base = cast<CXXRecordDecl>(D);
7781
if (!isInterface(Base)) {
7882
addNodeToInterfaceMap(Node, false);
@@ -97,20 +101,25 @@ void MultipleInheritanceCheck::check(const MatchFinder::MatchResult &Result) {
97101
// concrete classes
98102
unsigned NumConcrete = 0;
99103
for (const auto &I : D->bases()) {
100-
if (I.isVirtual()) continue;
104+
if (I.isVirtual())
105+
continue;
101106
const auto *Ty = I.getType()->getAs<RecordType>();
102-
if (!Ty) continue;
107+
if (!Ty)
108+
continue;
103109
const auto *Base = cast<CXXRecordDecl>(Ty->getDecl()->getDefinition());
104-
if (!isInterface(Base)) NumConcrete++;
110+
if (!isInterface(Base))
111+
NumConcrete++;
105112
}
106113

107114
// Check virtual bases to see if there is more than one concrete
108115
// non-virtual base.
109116
for (const auto &V : D->vbases()) {
110117
const auto *Ty = V.getType()->getAs<RecordType>();
111-
if (!Ty) continue;
118+
if (!Ty)
119+
continue;
112120
const auto *Base = cast<CXXRecordDecl>(Ty->getDecl()->getDefinition());
113-
if (!isInterface(Base)) NumConcrete++;
121+
if (!isInterface(Base))
122+
NumConcrete++;
114123
}
115124

116125
if (NumConcrete > 1) {

clang-tools-extra/clang-tidy/fuchsia/StaticallyConstructedObjectsCheck.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
namespace clang::tidy::fuchsia {
1515

1616
/// Constructing global, non-trivial objects with static storage is
17-
/// disallowed, unless the object is statically initialized with a constexpr
17+
/// disallowed, unless the object is statically initialized with a constexpr
1818
/// constructor or has no explicit constructor.
1919
///
2020
/// For the user-facing documentation see:

clang-tools-extra/clang-tidy/fuchsia/TrailingReturnCheck.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
namespace clang::tidy::fuchsia {
1515

16-
/// Functions that have trailing returns are disallowed, except for those
17-
/// using decltype specifiers and lambda with otherwise unutterable
16+
/// Functions that have trailing returns are disallowed, except for those
17+
/// using decltype specifiers and lambda with otherwise unutterable
1818
/// return types.
1919
///
2020
/// For the user-facing documentation see:

0 commit comments

Comments
 (0)