@@ -82,7 +82,7 @@ static std::string format(StringRef Code) {
82
82
}
83
83
84
84
static void compareSnippets (StringRef Expected,
85
- const llvm::Optional<std::string> &MaybeActual) {
85
+ const llvm::Optional<std::string> &MaybeActual) {
86
86
ASSERT_TRUE (MaybeActual) << " Rewrite failed. Expecting: " << Expected;
87
87
auto Actual = *MaybeActual;
88
88
std::string HL = " #include \" header.h\"\n " ;
@@ -1265,31 +1265,29 @@ void testIt()
1265
1265
auto RewriteOutput =
1266
1266
CodePrefix + RangeLoop + LoopBody + RangeLoop + LoopBody + CodeSuffix;
1267
1267
1268
- auto MatchedLoop = forStmt (
1269
- has (declStmt (
1270
- hasSingleDecl (varDecl (hasInitializer (integerLiteral (equals (0 ))))
1271
- .bind (" loopVar" )))),
1272
- has (binaryOperator (hasOperatorName (" !=" ),
1273
- hasLHS (ignoringImplicit (declRefExpr (
1274
- to (varDecl (equalsBoundNode (" loopVar" )))))),
1275
- hasRHS (expr ().bind (" upperBoundExpr" )))),
1276
- has (unaryOperator (hasOperatorName (" ++" ),
1277
- hasUnaryOperand (declRefExpr (
1278
- to (varDecl (equalsBoundNode (" loopVar" ))))))
1279
- .bind (" incrementOp" )));
1268
+ auto MatchedLoop = forStmt (
1269
+ has (declStmt (hasSingleDecl (
1270
+ varDecl (hasInitializer (integerLiteral (equals (0 )))).bind (" loopVar" )))),
1271
+ has (binaryOperator (hasOperatorName (" !=" ),
1272
+ hasLHS (ignoringImplicit (declRefExpr (
1273
+ to (varDecl (equalsBoundNode (" loopVar" )))))),
1274
+ hasRHS (expr ().bind (" upperBoundExpr" )))),
1275
+ has (unaryOperator (hasOperatorName (" ++" ),
1276
+ hasUnaryOperand (declRefExpr (
1277
+ to (varDecl (equalsBoundNode (" loopVar" ))))))
1278
+ .bind (" incrementOp" )));
1280
1279
1281
- auto RewriteRule =
1282
- changeTo (transformer::enclose (node (" loopVar" ), node (" incrementOp" )),
1283
- cat (" auto " , name (" loopVar" ), " : boost::irange(" ,
1284
- node (" upperBoundExpr" ), " )" ));
1285
-
1286
- testRule (makeRule (traverse (TK_IgnoreUnlessSpelledInSource, MatchedLoop),
1287
- RewriteRule),
1288
- RewriteInput, RewriteOutput);
1280
+ auto RewriteRule =
1281
+ changeTo (transformer::enclose (node (" loopVar" ), node (" incrementOp" )),
1282
+ cat (" auto " , name (" loopVar" ), " : boost::irange(" ,
1283
+ node (" upperBoundExpr" ), " )" ));
1289
1284
1290
- testRuleFailure (makeRule (traverse (TK_AsIs, MatchedLoop), RewriteRule),
1291
- RewriteInput);
1285
+ testRule (makeRule (traverse (TK_IgnoreUnlessSpelledInSource, MatchedLoop),
1286
+ RewriteRule),
1287
+ RewriteInput, RewriteOutput);
1292
1288
1289
+ testRuleFailure (makeRule (traverse (TK_AsIs, MatchedLoop), RewriteRule),
1290
+ RewriteInput);
1293
1291
}
1294
1292
1295
1293
TEST_F (TransformerTest, ImplicitNodes_ForStmt2) {
@@ -1338,31 +1336,29 @@ void testIt()
1338
1336
1339
1337
auto RewriteOutput =
1340
1338
CodePrefix + RangeLoop + LoopBody + RangeLoop + LoopBody + CodeSuffix;
1341
- auto MatchedLoop = forStmt (
1342
- hasLoopInit (declStmt (
1343
- hasSingleDecl (varDecl (hasInitializer (integerLiteral (equals (0 ))))
1344
- .bind (" loopVar" )))),
1345
- hasCondition (binaryOperator (hasOperatorName (" !=" ),
1346
- hasLHS (ignoringImplicit (declRefExpr (to (
1347
- varDecl (equalsBoundNode (" loopVar" )))))),
1348
- hasRHS (expr ().bind (" upperBoundExpr" )))),
1349
- hasIncrement (unaryOperator (hasOperatorName (" ++" ),
1350
- hasUnaryOperand (declRefExpr (to (
1351
- varDecl (equalsBoundNode (" loopVar" ))))))
1352
- .bind (" incrementOp" )));
1353
-
1354
- auto RewriteRule =
1355
- changeTo (transformer::enclose (node (" loopVar" ), node (" incrementOp" )),
1356
- cat (" auto " , name (" loopVar" ), " : boost::irange(" ,
1357
- node (" upperBoundExpr" ), " )" ));
1358
-
1359
- testRule (makeRule (traverse (TK_IgnoreUnlessSpelledInSource, MatchedLoop),
1360
- RewriteRule),
1361
- RewriteInput, RewriteOutput);
1362
-
1363
- testRuleFailure (makeRule (traverse (TK_AsIs, MatchedLoop), RewriteRule),
1364
- RewriteInput);
1339
+ auto MatchedLoop = forStmt (
1340
+ hasLoopInit (declStmt (hasSingleDecl (
1341
+ varDecl (hasInitializer (integerLiteral (equals (0 )))).bind (" loopVar" )))),
1342
+ hasCondition (binaryOperator (hasOperatorName (" !=" ),
1343
+ hasLHS (ignoringImplicit (declRefExpr (to (
1344
+ varDecl (equalsBoundNode (" loopVar" )))))),
1345
+ hasRHS (expr ().bind (" upperBoundExpr" )))),
1346
+ hasIncrement (unaryOperator (hasOperatorName (" ++" ),
1347
+ hasUnaryOperand (declRefExpr (
1348
+ to (varDecl (equalsBoundNode (" loopVar" ))))))
1349
+ .bind (" incrementOp" )));
1350
+
1351
+ auto RewriteRule =
1352
+ changeTo (transformer::enclose (node (" loopVar" ), node (" incrementOp" )),
1353
+ cat (" auto " , name (" loopVar" ), " : boost::irange(" ,
1354
+ node (" upperBoundExpr" ), " )" ));
1355
+
1356
+ testRule (makeRule (traverse (TK_IgnoreUnlessSpelledInSource, MatchedLoop),
1357
+ RewriteRule),
1358
+ RewriteInput, RewriteOutput);
1365
1359
1360
+ testRuleFailure (makeRule (traverse (TK_AsIs, MatchedLoop), RewriteRule),
1361
+ RewriteInput);
1366
1362
}
1367
1363
1368
1364
TEST_F (TransformerTest, TemplateInstantiation) {
0 commit comments