3636
3737using namespace clang ::ast_matchers;
3838
39- namespace clang ::tidy::misc {
39+ namespace clang ::tidy::modernize {
4040
4141namespace {
4242AST_MATCHER (FunctionDecl, locationPermitsConstexpr) {
@@ -87,14 +87,16 @@ AST_MATCHER(Decl, allRedeclsInSameFile) {
8787AST_MATCHER (FunctionDecl, isConstexprSpecified) {
8888 return Node.isConstexprSpecified ();
8989}
90+ } // namespace
9091
91- bool satisfiesConstructorPropertiesUntil20 (const CXXConstructorDecl *Ctor,
92- ASTContext &Ctx) {
92+ static bool
93+ satisfiesConstructorPropertiesUntil20 (const CXXConstructorDecl *Ctor,
94+ ASTContext &Ctx) {
9395 const CXXRecordDecl *Rec = Ctor->getParent ();
9496 llvm::SmallPtrSet<const RecordDecl *, 8 > Bases{};
95- for (const CXXBaseSpecifier Base : Rec->bases ()) {
97+ for (const CXXBaseSpecifier Base : Rec->bases ())
9698 Bases.insert (Base.getType ()->getAsRecordDecl ());
97- }
99+
98100 llvm::SmallPtrSet<const FieldDecl *, 8 > Fields{Rec->field_begin (),
99101 Rec->field_end ()};
100102 llvm::SmallPtrSet<const FieldDecl *, 4 > Indirects{};
@@ -147,7 +149,7 @@ bool satisfiesConstructorPropertiesUntil20(const CXXConstructorDecl *Ctor,
147149 return true ;
148150}
149151
150- const Type *unwrapPointee (const Type *T) {
152+ static const Type *unwrapPointee (const Type *T) {
151153 if (!T->isPointerOrReferenceType ())
152154 return T;
153155
@@ -163,11 +165,11 @@ const Type *unwrapPointee(const Type *T) {
163165 return T;
164166}
165167
166- bool isLiteralType (QualType QT, const ASTContext &Ctx,
167- const bool ConservativeLiteralType);
168+ static bool isLiteralType (QualType QT, const ASTContext &Ctx,
169+ const bool ConservativeLiteralType);
168170
169- bool isLiteralType (const Type *T, const ASTContext &Ctx,
170- const bool ConservativeLiteralType) {
171+ static bool isLiteralType (const Type *T, const ASTContext &Ctx,
172+ const bool ConservativeLiteralType) {
171173 if (!T)
172174 return false ;
173175
@@ -211,18 +213,18 @@ bool isLiteralType(const Type *T, const ASTContext &Ctx,
211213 return false ;
212214}
213215
214- bool isLiteralType (QualType QT, const ASTContext &Ctx,
215- const bool ConservativeLiteralType) {
216+ static bool isLiteralType (QualType QT, const ASTContext &Ctx,
217+ const bool ConservativeLiteralType) {
216218 return isLiteralType (QT.getTypePtr (), Ctx, ConservativeLiteralType);
217219}
218220
219- bool satisfiesProperties11 (
221+ static bool satisfiesProperties11 (
220222 const FunctionDecl *FDecl, ASTContext &Ctx,
221223 const bool ConservativeLiteralType,
222224 const bool AddConstexprToMethodOfClassWithoutConstexprConstructor) {
223- if (FDecl->isConstexprSpecified ()) {
225+ if (FDecl->isConstexprSpecified ())
224226 return true ;
225- }
227+
226228 const LangOptions LO = Ctx.getLangOpts ();
227229 const CXXMethodDecl *Method = llvm::dyn_cast<CXXMethodDecl>(FDecl);
228230 if (Method && !Method->isStatic () &&
@@ -373,7 +375,7 @@ bool satisfiesProperties11(
373375
374376// The only difference between C++14 and C++17 is that `constexpr` lambdas
375377// can be used in C++17.
376- bool satisfiesProperties1417 (
378+ static bool satisfiesProperties1417 (
377379 const FunctionDecl *FDecl, ASTContext &Ctx,
378380 const bool ConservativeLiteralType,
379381 const bool AddConstexprToMethodOfClassWithoutConstexprConstructor) {
@@ -573,13 +575,13 @@ bool satisfiesProperties1417(
573575 return true ;
574576}
575577
576- bool satisfiesProperties20 (
578+ static bool satisfiesProperties20 (
577579 const FunctionDecl *FDecl, ASTContext &Ctx,
578580 const bool ConservativeLiteralType,
579581 const bool AddConstexprToMethodOfClassWithoutConstexprConstructor) {
580- if (FDecl->isConstexprSpecified ()) {
582+ if (FDecl->isConstexprSpecified ())
581583 return true ;
582- }
584+
583585 const LangOptions LO = Ctx.getLangOpts ();
584586 const CXXMethodDecl *Method = llvm::dyn_cast<CXXMethodDecl>(FDecl);
585587 if (Method && !Method->isStatic () &&
@@ -732,12 +734,12 @@ bool satisfiesProperties20(
732734 return true ;
733735}
734736
735- bool satisfiesProperties2326 (
737+ static bool satisfiesProperties2326 (
736738 const FunctionDecl *FDecl, ASTContext &Ctx,
737739 const bool AddConstexprToMethodOfClassWithoutConstexprConstructor) {
738- if (FDecl->isConstexprSpecified ()) {
740+ if (FDecl->isConstexprSpecified ())
739741 return true ;
740- }
742+
741743 const LangOptions LO = Ctx.getLangOpts ();
742744 const CXXMethodDecl *Method = llvm::dyn_cast<CXXMethodDecl>(FDecl);
743745 if (Method && !Method->isStatic () &&
@@ -757,8 +759,7 @@ bool satisfiesProperties2326(
757759 return true ;
758760}
759761
760- // FIXME: add test for uncalled lambda that throws, and called lambda that
761- // throws
762+ namespace {
762763// FIXME: fix CXX23 allowing decomposition decls, but it is only a feature since
763764// CXX26
764765AST_MATCHER_P2 (FunctionDecl, satisfiesProperties, bool , ConservativeLiteralType,
@@ -943,4 +944,4 @@ void UseConstexprCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
943944 Options.store (Opts, " AddConstexprToMethodOfClassWithoutConstexprConstructor" ,
944945 AddConstexprToMethodOfClassWithoutConstexprConstructor);
945946}
946- } // namespace clang::tidy::misc
947+ } // namespace clang::tidy::modernize
0 commit comments