1- // ===--- AvoidPlatformSpecificFundamentalTypesCheck.cpp - clang-tidy ---------------===//
1+ // ===--- AvoidPlatformSpecificFundamentalTypesCheck.cpp - clang-tidy
2+ // ---------------===//
23//
34// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
45// See https://llvm.org/LICENSE.txt for license information.
@@ -31,8 +32,9 @@ AST_MATCHER_P(clang::TypeLoc, hasType,
3132
3233} // namespace
3334
34- AvoidPlatformSpecificFundamentalTypesCheck::AvoidPlatformSpecificFundamentalTypesCheck (
35- StringRef Name, ClangTidyContext *Context)
35+ AvoidPlatformSpecificFundamentalTypesCheck::
36+ AvoidPlatformSpecificFundamentalTypesCheck (StringRef Name,
37+ ClangTidyContext *Context)
3638 : ClangTidyCheck(Name, Context) {}
3739
3840bool AvoidPlatformSpecificFundamentalTypesCheck::isFundamentalIntegerType (
@@ -59,7 +61,8 @@ bool AvoidPlatformSpecificFundamentalTypesCheck::isFundamentalIntegerType(
5961 }
6062}
6163
62- bool AvoidPlatformSpecificFundamentalTypesCheck::isSemanticType (const Type *T) const {
64+ bool AvoidPlatformSpecificFundamentalTypesCheck::isSemanticType (
65+ const Type *T) const {
6366 if (!T->isBuiltinType ())
6467 return false ;
6568
@@ -84,35 +87,24 @@ bool AvoidPlatformSpecificFundamentalTypesCheck::isSemanticType(const Type *T) c
8487 }
8588}
8689
87- void AvoidPlatformSpecificFundamentalTypesCheck::registerMatchers (MatchFinder *Finder) {
90+ void AvoidPlatformSpecificFundamentalTypesCheck::registerMatchers (
91+ MatchFinder *Finder) {
8892 // Match variable declarations with fundamental integer types
89- Finder->addMatcher (
90- varDecl ().bind (" var_decl" ),
91- this );
93+ Finder->addMatcher (varDecl ().bind (" var_decl" ), this );
9294
9395 // Match function declarations with fundamental integer return types
94- Finder->addMatcher (
95- functionDecl ().bind (" func_decl" ),
96- this );
96+ Finder->addMatcher (functionDecl ().bind (" func_decl" ), this );
9797
9898 // Match function parameters with fundamental integer types
99- Finder->addMatcher (
100- parmVarDecl ().bind (" param_decl" ),
101- this );
99+ Finder->addMatcher (parmVarDecl ().bind (" param_decl" ), this );
102100
103101 // Match field declarations with fundamental integer types
104- Finder->addMatcher (
105- fieldDecl ().bind (" field_decl" ),
106- this );
102+ Finder->addMatcher (fieldDecl ().bind (" field_decl" ), this );
107103
108104 // Match typedef declarations to check their underlying types
109- Finder->addMatcher (
110- typedefDecl ().bind (" typedef_decl" ),
111- this );
105+ Finder->addMatcher (typedefDecl ().bind (" typedef_decl" ), this );
112106
113- Finder->addMatcher (
114- typeAliasDecl ().bind (" alias_decl" ),
115- this );
107+ Finder->addMatcher (typeAliasDecl ().bind (" alias_decl" ), this );
116108}
117109
118110void AvoidPlatformSpecificFundamentalTypesCheck::check (
@@ -125,23 +117,27 @@ void AvoidPlatformSpecificFundamentalTypesCheck::check(
125117 Loc = VD->getLocation ();
126118 QT = VD->getType ();
127119 DeclType = " variable" ;
128- } else if (const auto *FD = Result.Nodes .getNodeAs <FunctionDecl>(" func_decl" )) {
120+ } else if (const auto *FD =
121+ Result.Nodes .getNodeAs <FunctionDecl>(" func_decl" )) {
129122 Loc = FD->getLocation ();
130123 QT = FD->getReturnType ();
131124 DeclType = " function return type" ;
132- } else if (const auto *PD = Result.Nodes .getNodeAs <ParmVarDecl>(" param_decl" )) {
125+ } else if (const auto *PD =
126+ Result.Nodes .getNodeAs <ParmVarDecl>(" param_decl" )) {
133127 Loc = PD->getLocation ();
134128 QT = PD->getType ();
135129 DeclType = " function parameter" ;
136130 } else if (const auto *FD = Result.Nodes .getNodeAs <FieldDecl>(" field_decl" )) {
137131 Loc = FD->getLocation ();
138132 QT = FD->getType ();
139133 DeclType = " field" ;
140- } else if (const auto *TD = Result.Nodes .getNodeAs <TypedefDecl>(" typedef_decl" )) {
134+ } else if (const auto *TD =
135+ Result.Nodes .getNodeAs <TypedefDecl>(" typedef_decl" )) {
141136 Loc = TD->getLocation ();
142137 QT = TD->getUnderlyingType ();
143138 DeclType = " typedef" ;
144- } else if (const auto *AD = Result.Nodes .getNodeAs <TypeAliasDecl>(" alias_decl" )) {
139+ } else if (const auto *AD =
140+ Result.Nodes .getNodeAs <TypeAliasDecl>(" alias_decl" )) {
145141 Loc = AD->getLocation ();
146142 QT = AD->getUnderlyingType ();
147143 DeclType = " type alias" ;
0 commit comments