@@ -9142,44 +9142,48 @@ class SwiftifyInfoPrinter {
9142
9142
} // namespace
9143
9143
9144
9144
namespace {
9145
- // / Look for any side effects within a Stmt.
9146
- struct CATExprValidator : clang::ConstStmtVisitor<CATExprValidator, bool > {
9147
- bool VisitDeclRefExpr (const clang::DeclRefExpr *e) { return true ; }
9148
- bool VisitIntegerLiteral (const clang::IntegerLiteral *) { return true ; }
9149
- bool VisitImplicitCastExpr (const clang::ImplicitCastExpr *c) { return this ->Visit (c->getSubExpr ()); }
9150
- bool VisitParenExpr (const clang::ParenExpr *p) { return this ->Visit (p->getSubExpr ()); }
9145
+ struct CountedByExpressionValidator
9146
+ : clang::ConstStmtVisitor<CountedByExpressionValidator, bool > {
9147
+ bool VisitDeclRefExpr (const clang::DeclRefExpr *e) { return true ; }
9148
+ bool VisitIntegerLiteral (const clang::IntegerLiteral *) { return true ; }
9149
+ bool VisitImplicitCastExpr (const clang::ImplicitCastExpr *c) {
9150
+ return this ->Visit (c->getSubExpr ());
9151
+ }
9152
+ bool VisitParenExpr (const clang::ParenExpr *p) {
9153
+ return this ->Visit (p->getSubExpr ());
9154
+ }
9151
9155
9152
9156
#define SUPPORTED_UNOP (UNOP ) \
9153
- bool VisitUnary ## UNOP(const clang::UnaryOperator *unop) { \
9154
- return this ->Visit (unop->getSubExpr ()); \
9155
- }
9156
- SUPPORTED_UNOP (Plus)
9157
- SUPPORTED_UNOP (Minus)
9158
- SUPPORTED_UNOP (Not)
9157
+ bool VisitUnary ## UNOP(const clang::UnaryOperator *unop) { \
9158
+ return this ->Visit (unop->getSubExpr ()); \
9159
+ }
9160
+ SUPPORTED_UNOP (Plus)
9161
+ SUPPORTED_UNOP (Minus)
9162
+ SUPPORTED_UNOP (Not)
9159
9163
#undef SUPPORTED_UNOP
9160
9164
9161
9165
#define SUPPORTED_BINOP (BINOP ) \
9162
- bool VisitBin ## BINOP(const clang::BinaryOperator *binop) { \
9163
- return this ->Visit (binop->getLHS ()) && this ->Visit (binop->getRHS ()); \
9164
- }
9165
- SUPPORTED_BINOP (Add)
9166
- SUPPORTED_BINOP (Sub)
9167
- SUPPORTED_BINOP (Div)
9168
- SUPPORTED_BINOP (Mul)
9169
- SUPPORTED_BINOP (Rem)
9170
- SUPPORTED_BINOP (Shl)
9171
- SUPPORTED_BINOP (Shr)
9172
- SUPPORTED_BINOP (And)
9173
- SUPPORTED_BINOP (Xor)
9174
- SUPPORTED_BINOP (Or)
9166
+ bool VisitBin ## BINOP(const clang::BinaryOperator *binop) { \
9167
+ return this ->Visit (binop->getLHS ()) && this ->Visit (binop->getRHS ()); \
9168
+ }
9169
+ SUPPORTED_BINOP (Add)
9170
+ SUPPORTED_BINOP (Sub)
9171
+ SUPPORTED_BINOP (Div)
9172
+ SUPPORTED_BINOP (Mul)
9173
+ SUPPORTED_BINOP (Rem)
9174
+ SUPPORTED_BINOP (Shl)
9175
+ SUPPORTED_BINOP (Shr)
9176
+ SUPPORTED_BINOP (And)
9177
+ SUPPORTED_BINOP (Xor)
9178
+ SUPPORTED_BINOP (Or)
9175
9179
#undef SUPPORTED_BINOP
9176
9180
9177
- bool VisitStmt (const clang::Stmt *) { return false ; }
9178
- };
9181
+ bool VisitStmt (const clang::Stmt *) { return false ; }
9182
+ };
9179
9183
} // namespace
9180
9184
9181
9185
static bool SwiftifiableCAT (const clang::CountAttributedType *CAT) {
9182
- return CAT && CATExprValidator ().Visit (CAT->getCountExpr ());
9186
+ return CAT && CountedByExpressionValidator ().Visit (CAT->getCountExpr ());
9183
9187
}
9184
9188
9185
9189
void ClangImporter::Implementation::swiftify (FuncDecl *MappedDecl) {
0 commit comments