@@ -9142,44 +9142,48 @@ class SwiftifyInfoPrinter {
91429142} // namespace
91439143
91449144namespace {
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+ }
91519155
91529156#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)
91599163#undef SUPPORTED_UNOP
91609164
91619165#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)
91759179#undef SUPPORTED_BINOP
91769180
9177- bool VisitStmt (const clang::Stmt *) { return false ; }
9178- };
9181+ bool VisitStmt (const clang::Stmt *) { return false ; }
9182+ };
91799183} // namespace
91809184
91819185static bool SwiftifiableCAT (const clang::CountAttributedType *CAT) {
9182- return CAT && CATExprValidator ().Visit (CAT->getCountExpr ());
9186+ return CAT && CountedByExpressionValidator ().Visit (CAT->getCountExpr ());
91839187}
91849188
91859189void ClangImporter::Implementation::swiftify (FuncDecl *MappedDecl) {
0 commit comments