Skip to content

Commit 1b314bb

Browse files
committed
Remove dead code
1 parent c66668e commit 1b314bb

File tree

2 files changed

+30
-89
lines changed

2 files changed

+30
-89
lines changed

clang-tools-extra/clang-tidy/portability/AvoidPlatformSpecificFundamentalTypesCheck.cpp

Lines changed: 30 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -21,84 +21,33 @@ AvoidPlatformSpecificFundamentalTypesCheck::
2121
ClangTidyContext *Context)
2222
: ClangTidyCheck(Name, Context) {}
2323

24-
bool AvoidPlatformSpecificFundamentalTypesCheck::isFundamentalIntegerType(
25-
const Type *T) const {
26-
if (!T->isBuiltinType())
27-
return false;
28-
29-
const auto *BT = T->getAs<BuiltinType>();
30-
if (!BT)
31-
return false;
32-
33-
switch (BT->getKind()) {
34-
case BuiltinType::Int:
35-
case BuiltinType::UInt:
36-
case BuiltinType::Short:
37-
case BuiltinType::UShort:
38-
case BuiltinType::Long:
39-
case BuiltinType::ULong:
40-
case BuiltinType::LongLong:
41-
case BuiltinType::ULongLong:
42-
return true;
43-
default:
44-
return false;
45-
}
46-
}
47-
48-
bool AvoidPlatformSpecificFundamentalTypesCheck::isSemanticType(
49-
const Type *T) const {
50-
if (!T->isBuiltinType())
51-
return false;
52-
53-
const auto *BT = T->getAs<BuiltinType>();
54-
if (!BT)
55-
return false;
56-
57-
switch (BT->getKind()) {
58-
case BuiltinType::Bool:
59-
case BuiltinType::Char_S:
60-
case BuiltinType::Char_U:
61-
case BuiltinType::SChar:
62-
case BuiltinType::UChar:
63-
case BuiltinType::WChar_S:
64-
case BuiltinType::WChar_U:
65-
case BuiltinType::Char8:
66-
case BuiltinType::Char16:
67-
case BuiltinType::Char32:
68-
return true;
69-
default:
70-
return false;
71-
}
72-
}
73-
7424
void AvoidPlatformSpecificFundamentalTypesCheck::registerMatchers(
7525
MatchFinder *Finder) {
7626
// Create a matcher for platform-specific fundamental integer types
7727
// This should only match direct uses of builtin types, not typedefs
78-
auto PlatformSpecificFundamentalType = qualType(
79-
allOf(
80-
// Must be a builtin type directly (not through typedef)
81-
builtinType(),
82-
// Only match the specific fundamental integer types we care about
83-
anyOf(
84-
asString("int"),
85-
asString("unsigned int"),
86-
asString("short"),
87-
asString("unsigned short"),
88-
asString("long"),
89-
asString("unsigned long"),
90-
asString("long long"),
91-
asString("unsigned long long")
92-
)
93-
)
94-
);
95-
96-
// Match variable declarations with platform-specific fundamental integer types
28+
auto PlatformSpecificFundamentalType = qualType(allOf(
29+
// Must be a builtin type directly (not through typedef)
30+
builtinType(),
31+
// Only match the specific fundamental integer types we care about
32+
anyOf(asString("short"), asString("short int"), asString("signed short"),
33+
asString("signed short int"), asString("unsigned short"),
34+
asString("unsigned short int"), asString("int"), asString("signed"),
35+
asString("signed int"), asString("unsigned"),
36+
asString("unsigned int"), asString("long"), asString("long int"),
37+
asString("signed long"), asString("signed long int"),
38+
asString("unsigned long"), asString("unsigned long int"),
39+
asString("long long"), asString("long long int"),
40+
asString("signed long long"), asString("signed long long int"),
41+
asString("unsigned long long"),
42+
asString("unsigned long long int"))));
43+
44+
// Match variable declarations with platform-specific fundamental integer
45+
// types
9746
Finder->addMatcher(
98-
varDecl(hasType(PlatformSpecificFundamentalType)).bind("var_decl"),
99-
this);
47+
varDecl(hasType(PlatformSpecificFundamentalType)).bind("var_decl"), this);
10048

101-
// Match function declarations with platform-specific fundamental integer return types
49+
// Match function declarations with platform-specific fundamental integer
50+
// return types
10251
Finder->addMatcher(
10352
functionDecl(returns(PlatformSpecificFundamentalType)).bind("func_decl"),
10453
this);
@@ -113,51 +62,47 @@ void AvoidPlatformSpecificFundamentalTypesCheck::registerMatchers(
11362
fieldDecl(hasType(PlatformSpecificFundamentalType)).bind("field_decl"),
11463
this);
11564

116-
// Match typedef declarations with platform-specific fundamental underlying types
65+
// Match typedef declarations with platform-specific fundamental underlying
66+
// types
11767
Finder->addMatcher(
118-
typedefDecl(hasUnderlyingType(PlatformSpecificFundamentalType)).bind("typedef_decl"),
68+
typedefDecl(hasUnderlyingType(PlatformSpecificFundamentalType))
69+
.bind("typedef_decl"),
11970
this);
12071

121-
// Match type alias declarations with platform-specific fundamental underlying types
122-
Finder->addMatcher(
123-
typeAliasDecl(hasType(PlatformSpecificFundamentalType)).bind("alias_decl"),
124-
this);
72+
// Match type alias declarations with platform-specific fundamental underlying
73+
// types
74+
Finder->addMatcher(typeAliasDecl(hasType(PlatformSpecificFundamentalType))
75+
.bind("alias_decl"),
76+
this);
12577
}
12678

12779
void AvoidPlatformSpecificFundamentalTypesCheck::check(
12880
const MatchFinder::MatchResult &Result) {
12981
SourceLocation Loc;
13082
QualType QT;
131-
std::string DeclType;
13283

13384
if (const auto *VD = Result.Nodes.getNodeAs<VarDecl>("var_decl")) {
13485
Loc = VD->getLocation();
13586
QT = VD->getType();
136-
DeclType = "variable";
13787
} else if (const auto *FD =
13888
Result.Nodes.getNodeAs<FunctionDecl>("func_decl")) {
13989
Loc = FD->getLocation();
14090
QT = FD->getReturnType();
141-
DeclType = "function return type";
14291
} else if (const auto *PD =
14392
Result.Nodes.getNodeAs<ParmVarDecl>("param_decl")) {
14493
Loc = PD->getLocation();
14594
QT = PD->getType();
146-
DeclType = "function parameter";
14795
} else if (const auto *FD = Result.Nodes.getNodeAs<FieldDecl>("field_decl")) {
14896
Loc = FD->getLocation();
14997
QT = FD->getType();
150-
DeclType = "field";
15198
} else if (const auto *TD =
15299
Result.Nodes.getNodeAs<TypedefDecl>("typedef_decl")) {
153100
Loc = TD->getLocation();
154101
QT = TD->getUnderlyingType();
155-
DeclType = "typedef";
156102
} else if (const auto *AD =
157103
Result.Nodes.getNodeAs<TypeAliasDecl>("alias_decl")) {
158104
Loc = AD->getLocation();
159105
QT = AD->getUnderlyingType();
160-
DeclType = "type alias";
161106
} else {
162107
return;
163108
}

clang-tools-extra/clang-tidy/portability/AvoidPlatformSpecificFundamentalTypesCheck.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ class AvoidPlatformSpecificFundamentalTypesCheck : public ClangTidyCheck {
3636
std::optional<TraversalKind> getCheckTraversalKind() const override {
3737
return TK_IgnoreUnlessSpelledInSource;
3838
}
39-
40-
private:
41-
bool isFundamentalIntegerType(const Type *T) const;
42-
bool isSemanticType(const Type *T) const;
4339
};
4440

4541
} // namespace clang::tidy::portability

0 commit comments

Comments
 (0)