@@ -118,30 +118,28 @@ void SuspiciousEnumUsageCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
118
118
119
119
void SuspiciousEnumUsageCheck::registerMatchers (MatchFinder *Finder) {
120
120
const auto EnumExpr = [](StringRef RefName, StringRef DeclName) {
121
- return expr (ignoringImpCasts (expr ().bind (RefName)),
122
- ignoringImpCasts (hasType (enumDecl ().bind (DeclName))));
121
+ return expr (hasType (enumDecl ().bind (DeclName))).bind (RefName);
123
122
};
124
123
125
124
Finder->addMatcher (
126
- binaryOperator (hasOperatorName ( " | " ), hasLHS ( EnumExpr ( " " , " enumDecl " )),
127
- hasRHS ( expr ( EnumExpr ( " " , " otherEnumDecl " ),
128
- ignoringImpCasts (hasType (enumDecl (
129
- unless ( equalsBoundNode ( " enumDecl " )))) ))))
125
+ binaryOperator (
126
+ hasOperatorName ( " | " ), hasLHS ( hasType ( enumDecl (). bind ( " enumDecl " )) ),
127
+ hasRHS (hasType (enumDecl (unless ( equalsBoundNode ( " enumDecl " )))
128
+ . bind ( " otherEnumDecl " ))))
130
129
.bind (" diffEnumOp" ),
131
130
this );
132
131
133
132
Finder->addMatcher (
134
133
binaryOperator (hasAnyOperatorName (" +" , " |" ),
135
134
hasLHS (EnumExpr (" lhsExpr" , " enumDecl" )),
136
- hasRHS (expr (EnumExpr (" rhsExpr" , " " ),
137
- ignoringImpCasts (hasType (
138
- enumDecl (equalsBoundNode (" enumDecl" ))))))),
135
+ hasRHS (expr (hasType (enumDecl (equalsBoundNode (" enumDecl" ))))
136
+ .bind (" rhsExpr" ))),
139
137
this );
140
138
141
139
Finder->addMatcher (
142
140
binaryOperator (
143
141
hasAnyOperatorName (" +" , " |" ),
144
- hasOperands (expr (hasType (isInteger ()), unless (EnumExpr ( " " , " " ))),
142
+ hasOperands (expr (hasType (isInteger ()), unless (hasType ( enumDecl () ))),
145
143
EnumExpr (" enumExpr" , " enumDecl" ))),
146
144
this );
147
145
0 commit comments