Skip to content

Commit ef4fd56

Browse files
committed
format
1 parent f6235e0 commit ef4fd56

File tree

3 files changed

+96
-102
lines changed

3 files changed

+96
-102
lines changed

clang/include/clang/ASTMatchers/ASTMatchers.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5931,8 +5931,8 @@ AST_POLYMORPHIC_MATCHER_P(hasAnySubstatement,
59315931
/// a compound statement immediately followed by a binary operator
59325932
/// immediately followed by a return statement.
59335933
extern const internal::VariadicFunction<
5934-
internal::HasAdjSubstatementsMatcherType,
5935-
internal::Matcher<Stmt>, internal::hasAdjSubstatementsFunc>
5934+
internal::HasAdjSubstatementsMatcherType, internal::Matcher<Stmt>,
5935+
internal::hasAdjSubstatementsFunc>
59365936
hasAdjSubstatements;
59375937

59385938
/// Checks that a compound statement contains a specific number of

clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Lines changed: 92 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -2401,202 +2401,195 @@ TEST(HasAnySubstatement, FindsSubstatementBetweenOthers) {
24012401

24022402
TEST(HasAdjSubstatements, MatchesAdjacentSubstatements) {
24032403
// Basic case: compound statement followed by binary operator
2404-
EXPECT_TRUE(matches("void f() { {} 1+2; }",
2405-
compoundStmt(hasAdjSubstatements(compoundStmt(),
2406-
binaryOperator()))));
2404+
EXPECT_TRUE(matches(
2405+
"void f() { {} 1+2; }",
2406+
compoundStmt(hasAdjSubstatements(compoundStmt(), binaryOperator()))));
24072407
}
24082408

24092409
TEST(HasAdjSubstatements, DoesNotMatchNonAdjacentSubstatements) {
24102410
// Statements exist but not adjacent
2411-
EXPECT_TRUE(notMatches("void f() { {} 1; 1+2; }",
2412-
compoundStmt(hasAdjSubstatements(compoundStmt(),
2413-
binaryOperator()))));
2411+
EXPECT_TRUE(notMatches(
2412+
"void f() { {} 1; 1+2; }",
2413+
compoundStmt(hasAdjSubstatements(compoundStmt(), binaryOperator()))));
24142414
}
24152415

24162416
TEST(HasAdjSubstatements, MatchesInNestedCompoundStatements) {
24172417
// Should match in nested compound statements
2418-
EXPECT_TRUE(matches("void f() { if (true) { {} 1+2; } }",
2419-
compoundStmt(hasAdjSubstatements(compoundStmt(),
2420-
binaryOperator()))));
2418+
EXPECT_TRUE(matches(
2419+
"void f() { if (true) { {} 1+2; } }",
2420+
compoundStmt(hasAdjSubstatements(compoundStmt(), binaryOperator()))));
24212421
}
24222422

24232423
TEST(HasAdjSubstatements, MatchesFirstAdjacentPair) {
24242424
// When multiple adjacent pairs exist, should match the first one
2425-
EXPECT_TRUE(matches("void f() { {} 1+2; {} 3+4; }",
2426-
compoundStmt(hasAdjSubstatements(compoundStmt(),
2427-
binaryOperator()))));
2425+
EXPECT_TRUE(matches(
2426+
"void f() { {} 1+2; {} 3+4; }",
2427+
compoundStmt(hasAdjSubstatements(compoundStmt(), binaryOperator()))));
24282428
}
24292429

24302430
TEST(HasAdjSubstatements, DoesNotMatchEmptyCompound) {
24312431
// Empty compound statement has no adjacent pairs
2432-
EXPECT_TRUE(notMatches("void f() { }",
2433-
compoundStmt(hasAdjSubstatements(compoundStmt(),
2434-
binaryOperator()))));
2432+
EXPECT_TRUE(notMatches(
2433+
"void f() { }",
2434+
compoundStmt(hasAdjSubstatements(compoundStmt(), binaryOperator()))));
24352435
}
24362436

24372437
TEST(HasAdjSubstatements, DoesNotMatchSingleStatement) {
24382438
// Single statement has no adjacent pairs
2439-
EXPECT_TRUE(notMatches("void f() { 1+2; }",
2440-
compoundStmt(hasAdjSubstatements(compoundStmt(),
2441-
binaryOperator()))));
2439+
EXPECT_TRUE(notMatches(
2440+
"void f() { 1+2; }",
2441+
compoundStmt(hasAdjSubstatements(compoundStmt(), binaryOperator()))));
24422442
}
24432443

24442444
TEST(HasAdjSubstatements, MatchesDifferentStatementTypes) {
24452445
// Test with different statement types
2446-
EXPECT_TRUE(matches("void f() { for (;;); while (true); }",
2447-
compoundStmt(hasAdjSubstatements(forStmt(), whileStmt()))));
2448-
2449-
EXPECT_TRUE(matches("void f() { int x; return; }",
2450-
compoundStmt(hasAdjSubstatements(declStmt(), returnStmt()))));
2446+
EXPECT_TRUE(
2447+
matches("void f() { for (;;); while (true); }",
2448+
compoundStmt(hasAdjSubstatements(forStmt(), whileStmt()))));
2449+
2450+
EXPECT_TRUE(
2451+
matches("void f() { int x; return; }",
2452+
compoundStmt(hasAdjSubstatements(declStmt(), returnStmt()))));
24512453
}
24522454

24532455
TEST(HasAdjSubstatements, WorksWithStmtExpr) {
24542456
// Test that it works with StmtExpr (polymorphic support)
2455-
EXPECT_TRUE(matches("void f() { int x = ({ {} 1+2; }); }",
2456-
stmtExpr(hasAdjSubstatements(compoundStmt(),
2457-
binaryOperator()))));
2457+
EXPECT_TRUE(
2458+
matches("void f() { int x = ({ {} 1+2; }); }",
2459+
stmtExpr(hasAdjSubstatements(compoundStmt(), binaryOperator()))));
24582460
}
24592461

24602462
TEST(HasAdjSubstatements, DoesNotMatchWrongOrder) {
24612463
// The order matters - binaryOperator must come after compoundStmt
2462-
EXPECT_TRUE(notMatches("void f() { 1+2; {} }",
2463-
compoundStmt(hasAdjSubstatements(compoundStmt(),
2464-
binaryOperator()))));
2464+
EXPECT_TRUE(notMatches(
2465+
"void f() { 1+2; {} }",
2466+
compoundStmt(hasAdjSubstatements(compoundStmt(), binaryOperator()))));
24652467
}
24662468

24672469
TEST(HasAdjSubstatements, MatchesWithStatementsBetween) {
24682470
// Should still match even if there are other statements before/after
2469-
EXPECT_TRUE(matches("void f() { int x; {} 1+2; int y; }",
2470-
compoundStmt(hasAdjSubstatements(compoundStmt(),
2471-
binaryOperator()))));
2471+
EXPECT_TRUE(matches(
2472+
"void f() { int x; {} 1+2; int y; }",
2473+
compoundStmt(hasAdjSubstatements(compoundStmt(), binaryOperator()))));
24722474
}
24732475

24742476
TEST(HasAdjSubstatements, VariadicMatchesThreeAdjacentSubstatements) {
24752477
// Test variadic version with 3 matchers
2476-
EXPECT_TRUE(matches("void f() { {} 1+2; 3+4; }",
2477-
compoundStmt(hasAdjSubstatements(compoundStmt(),
2478-
binaryOperator(),
2479-
binaryOperator()))));
2478+
EXPECT_TRUE(
2479+
matches("void f() { {} 1+2; 3+4; }",
2480+
compoundStmt(hasAdjSubstatements(compoundStmt(), binaryOperator(),
2481+
binaryOperator()))));
24802482
}
24812483

24822484
TEST(HasAdjSubstatements, VariadicMatchesFourAdjacentSubstatements) {
24832485
// Test variadic version with 4 matchers
2484-
EXPECT_TRUE(matches("void f() { int x; return; {} 1+2; }",
2485-
compoundStmt(hasAdjSubstatements(declStmt(),
2486-
returnStmt(),
2487-
compoundStmt(),
2488-
binaryOperator()))));
2486+
EXPECT_TRUE(matches(
2487+
"void f() { int x; return; {} 1+2; }",
2488+
compoundStmt(hasAdjSubstatements(declStmt(), returnStmt(), compoundStmt(),
2489+
binaryOperator()))));
24892490
}
24902491

24912492
TEST(HasAdjSubstatements, VariadicMatchesFiveAdjacentSubstatements) {
24922493
// Test variadic version with 5 matchers
2493-
EXPECT_TRUE(matches("void f() { for (;;); while (true); if (true) {} return; 1+2; }",
2494-
compoundStmt(hasAdjSubstatements(forStmt(),
2495-
whileStmt(),
2496-
ifStmt(),
2497-
returnStmt(),
2498-
binaryOperator()))));
2494+
EXPECT_TRUE(matches(
2495+
"void f() { for (;;); while (true); if (true) {} return; 1+2; }",
2496+
compoundStmt(hasAdjSubstatements(forStmt(), whileStmt(), ifStmt(),
2497+
returnStmt(), binaryOperator()))));
24992498
}
25002499

25012500
TEST(HasAdjSubstatements, VariadicDoesNotMatchNonAdjacentSequence) {
25022501
// Three matchers but statements are not all adjacent
2503-
EXPECT_TRUE(notMatches("void f() { {} 1; 1+2; 3+4; }",
2504-
compoundStmt(hasAdjSubstatements(compoundStmt(),
2505-
binaryOperator(),
2506-
binaryOperator()))));
2502+
EXPECT_TRUE(
2503+
notMatches("void f() { {} 1; 1+2; 3+4; }",
2504+
compoundStmt(hasAdjSubstatements(
2505+
compoundStmt(), binaryOperator(), binaryOperator()))));
25072506
}
25082507

25092508
TEST(HasAdjSubstatements, VariadicDoesNotMatchPartialSequence) {
25102509
// First two match but third doesn't
2511-
EXPECT_TRUE(notMatches("void f() { {} 1+2; return; }",
2512-
compoundStmt(hasAdjSubstatements(compoundStmt(),
2513-
binaryOperator(),
2514-
binaryOperator()))));
2510+
EXPECT_TRUE(
2511+
notMatches("void f() { {} 1+2; return; }",
2512+
compoundStmt(hasAdjSubstatements(
2513+
compoundStmt(), binaryOperator(), binaryOperator()))));
25152514
}
25162515

25172516
TEST(HasAdjSubstatements, VariadicMatchesInNestedCompound) {
25182517
// Test variadic version in nested compound statements
2519-
EXPECT_TRUE(matches("void f() { if (true) { {} 1+2; 3+4; } }",
2520-
compoundStmt(hasAdjSubstatements(compoundStmt(),
2521-
binaryOperator(),
2522-
binaryOperator()))));
2518+
EXPECT_TRUE(
2519+
matches("void f() { if (true) { {} 1+2; 3+4; } }",
2520+
compoundStmt(hasAdjSubstatements(compoundStmt(), binaryOperator(),
2521+
binaryOperator()))));
25232522
}
25242523

25252524
TEST(HasAdjSubstatements, VariadicMatchesWithDifferentTypes) {
25262525
// Test variadic version with different statement types
2527-
EXPECT_TRUE(matches("void f() { for (;;); while (true); if (true) {} }",
2528-
compoundStmt(hasAdjSubstatements(forStmt(),
2529-
whileStmt(),
2530-
ifStmt()))));
2526+
EXPECT_TRUE(matches(
2527+
"void f() { for (;;); while (true); if (true) {} }",
2528+
compoundStmt(hasAdjSubstatements(forStmt(), whileStmt(), ifStmt()))));
25312529
}
25322530

25332531
TEST(HasAdjSubstatements, VariadicDoesNotMatchWrongOrder) {
25342532
// Order matters in variadic version
2535-
EXPECT_TRUE(notMatches("void f() { 1+2; {} 3+4; }",
2536-
compoundStmt(hasAdjSubstatements(compoundStmt(),
2537-
binaryOperator(),
2538-
binaryOperator()))));
2533+
EXPECT_TRUE(
2534+
notMatches("void f() { 1+2; {} 3+4; }",
2535+
compoundStmt(hasAdjSubstatements(
2536+
compoundStmt(), binaryOperator(), binaryOperator()))));
25392537
}
25402538

25412539
TEST(HasAdjSubstatements, VariadicMatchesFirstSequence) {
25422540
// When multiple sequences exist, should match the first one
2543-
EXPECT_TRUE(matches("void f() { {} 1+2; 3+4; {} 5+6; 7+8; }",
2544-
compoundStmt(hasAdjSubstatements(compoundStmt(),
2545-
binaryOperator(),
2546-
binaryOperator()))));
2541+
EXPECT_TRUE(
2542+
matches("void f() { {} 1+2; 3+4; {} 5+6; 7+8; }",
2543+
compoundStmt(hasAdjSubstatements(compoundStmt(), binaryOperator(),
2544+
binaryOperator()))));
25472545
}
25482546

25492547
TEST(HasAdjSubstatements, VariadicWorksWithStmtExpr) {
25502548
// Test variadic version with StmtExpr
2551-
EXPECT_TRUE(matches("void f() { int x = ({ {} 1+2; 3+4; }); }",
2552-
stmtExpr(hasAdjSubstatements(compoundStmt(),
2553-
binaryOperator(),
2554-
binaryOperator()))));
2549+
EXPECT_TRUE(
2550+
matches("void f() { int x = ({ {} 1+2; 3+4; }); }",
2551+
stmtExpr(hasAdjSubstatements(compoundStmt(), binaryOperator(),
2552+
binaryOperator()))));
25552553
}
25562554

25572555
TEST(HasAdjSubstatements, VariadicRequiresMinimumStatements) {
25582556
// Need at least as many statements as matchers
2559-
EXPECT_TRUE(notMatches("void f() { {} 1+2; }",
2560-
compoundStmt(hasAdjSubstatements(compoundStmt(),
2561-
binaryOperator(),
2562-
binaryOperator()))));
2557+
EXPECT_TRUE(
2558+
notMatches("void f() { {} 1+2; }",
2559+
compoundStmt(hasAdjSubstatements(
2560+
compoundStmt(), binaryOperator(), binaryOperator()))));
25632561
}
25642562

25652563
TEST(HasAdjSubstatements, VariadicMatchesWithStatementsBetween) {
25662564
// Should still match even if there are other statements before/after
2567-
EXPECT_TRUE(matches("void f() { int x; {} 1+2; 3+4; int y; }",
2568-
compoundStmt(hasAdjSubstatements(compoundStmt(),
2569-
binaryOperator(),
2570-
binaryOperator()))));
2565+
EXPECT_TRUE(
2566+
matches("void f() { int x; {} 1+2; 3+4; int y; }",
2567+
compoundStmt(hasAdjSubstatements(compoundStmt(), binaryOperator(),
2568+
binaryOperator()))));
25712569
}
25722570

25732571
TEST(HasAdjSubstatements, VariadicMatchesComplexSequence) {
25742572
// Test with a complex sequence of different statement types
2575-
EXPECT_TRUE(matches("void f() { int a; int b; return; {} 1+2; }",
2576-
compoundStmt(hasAdjSubstatements(declStmt(),
2577-
declStmt(),
2578-
returnStmt(),
2579-
compoundStmt(),
2580-
binaryOperator()))));
2573+
EXPECT_TRUE(matches(
2574+
"void f() { int a; int b; return; {} 1+2; }",
2575+
compoundStmt(hasAdjSubstatements(declStmt(), declStmt(), returnStmt(),
2576+
compoundStmt(), binaryOperator()))));
25812577
}
25822578

25832579
TEST(HasAdjSubstatements, VariadicDoesNotMatchGapInSequence) {
25842580
// Sequence has a gap in the middle
2585-
EXPECT_TRUE(notMatches("void f() { {} 1+2; int x; 3+4; }",
2586-
compoundStmt(hasAdjSubstatements(compoundStmt(),
2587-
binaryOperator(),
2588-
binaryOperator()))));
2581+
EXPECT_TRUE(
2582+
notMatches("void f() { {} 1+2; int x; 3+4; }",
2583+
compoundStmt(hasAdjSubstatements(
2584+
compoundStmt(), binaryOperator(), binaryOperator()))));
25892585
}
25902586

25912587
TEST(HasAdjSubstatements, VariadicMatchesLongSequence) {
25922588
// Test with a longer sequence (6 statements)
25932589
EXPECT_TRUE(matches("void f() { int a; int b; int c; return; {} 1+2; }",
2594-
compoundStmt(hasAdjSubstatements(declStmt(),
2595-
declStmt(),
2596-
declStmt(),
2597-
returnStmt(),
2598-
compoundStmt(),
2599-
binaryOperator()))));
2590+
compoundStmt(hasAdjSubstatements(
2591+
declStmt(), declStmt(), declStmt(), returnStmt(),
2592+
compoundStmt(), binaryOperator()))));
26002593
}
26012594

26022595
TEST(Member, MatchesMemberAllocationFunction) {

llvm/include/llvm/ADT/STLExtras.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1780,7 +1780,8 @@ OutputIt copy_if(R &&Range, OutputIt Out, UnaryPredicate P) {
17801780

17811781
template <typename R1, typename R2, typename BinaryPredicate>
17821782
auto search(R1 &&Range1, R2 &&Range2, BinaryPredicate P) {
1783-
return std::search(adl_begin(Range1), adl_end(Range1), adl_begin(Range2), adl_end(Range2), P);
1783+
return std::search(adl_begin(Range1), adl_end(Range1), adl_begin(Range2),
1784+
adl_end(Range2), P);
17841785
}
17851786

17861787
/// Return the single value in \p Range that satisfies

0 commit comments

Comments
 (0)