@@ -305,172 +305,171 @@ TEST_F(ExtractVariableTest, Test) {
305
305
EXPECT_UNAVAILABLE (UnavailableCases);
306
306
307
307
// vector of pairs of input and output strings
308
- const std::vector<std::pair<std::string, std::string>>
309
- InputOutputs = {
310
- // extraction from variable declaration/assignment
311
- {R"cpp( void varDecl() {
308
+ const std::vector<std::pair<std::string, std::string>> InputOutputs = {
309
+ // extraction from variable declaration/assignment
310
+ {R"cpp( void varDecl() {
312
311
int a = 5 * (4 + (3 [[- 1)]]);
313
312
})cpp" ,
314
- R"cpp( void varDecl() {
313
+ R"cpp( void varDecl() {
315
314
auto dummy = (3 - 1); int a = 5 * (4 + dummy);
316
315
})cpp" },
317
- // FIXME: extraction from switch case
318
- /* {R"cpp(void f(int a) {
319
- if(1)
320
- while(a < 1)
321
- switch (1) {
322
- case 1:
323
- a = [[1 + 2]];
324
- break;
325
- default:
326
- break;
327
- }
328
- })cpp",
329
- R"cpp(void f(int a) {
330
- auto dummy = 1 + 2; if(1)
331
- while(a < 1)
332
- switch (1) {
333
- case 1:
334
- a = dummy;
335
- break;
336
- default:
337
- break;
338
- }
339
- })cpp"},*/
340
- // Macros
341
- {R"cpp( #define PLUS(x) x++
316
+ // FIXME: extraction from switch case
317
+ /* {R"cpp(void f(int a) {
318
+ if(1)
319
+ while(a < 1)
320
+ switch (1) {
321
+ case 1:
322
+ a = [[1 + 2]];
323
+ break;
324
+ default:
325
+ break;
326
+ }
327
+ })cpp",
328
+ R"cpp(void f(int a) {
329
+ auto dummy = 1 + 2; if(1)
330
+ while(a < 1)
331
+ switch (1) {
332
+ case 1:
333
+ a = dummy;
334
+ break;
335
+ default:
336
+ break;
337
+ }
338
+ })cpp"},*/
339
+ // Macros
340
+ {R"cpp( #define PLUS(x) x++
342
341
void f(int a) {
343
342
int y = PLUS([[1+a]]);
344
343
})cpp" ,
345
- /* FIXME: It should be extracted like this.
346
- R"cpp(#define PLUS(x) x++
347
- void f(int a) {
348
- auto dummy = 1+a; int y = PLUS(dummy);
349
- })cpp"},*/
350
- R"cpp( #define PLUS(x) x++
344
+ /* FIXME: It should be extracted like this.
345
+ R"cpp(#define PLUS(x) x++
346
+ void f(int a) {
347
+ auto dummy = 1+a; int y = PLUS(dummy);
348
+ })cpp"},*/
349
+ R"cpp( #define PLUS(x) x++
351
350
void f(int a) {
352
351
auto dummy = PLUS(1+a); int y = dummy;
353
352
})cpp" },
354
- // ensure InsertionPoint isn't inside a macro
355
- {R"cpp( #define LOOP(x) while (1) {a = x;}
353
+ // ensure InsertionPoint isn't inside a macro
354
+ {R"cpp( #define LOOP(x) while (1) {a = x;}
356
355
void f(int a) {
357
356
if(1)
358
357
LOOP(5 + [[3]])
359
358
})cpp" ,
360
- R"cpp( #define LOOP(x) while (1) {a = x;}
359
+ R"cpp( #define LOOP(x) while (1) {a = x;}
361
360
void f(int a) {
362
361
auto dummy = 3; if(1)
363
362
LOOP(5 + dummy)
364
363
})cpp" },
365
- {R"cpp( #define LOOP(x) do {x;} while(1);
364
+ {R"cpp( #define LOOP(x) do {x;} while(1);
366
365
void f(int a) {
367
366
if(1)
368
367
LOOP(5 + [[3]])
369
368
})cpp" ,
370
- R"cpp( #define LOOP(x) do {x;} while(1);
369
+ R"cpp( #define LOOP(x) do {x;} while(1);
371
370
void f(int a) {
372
371
auto dummy = 3; if(1)
373
372
LOOP(5 + dummy)
374
373
})cpp" },
375
- // attribute testing
376
- {R"cpp( void f(int a) {
374
+ // attribute testing
375
+ {R"cpp( void f(int a) {
377
376
[ [gsl::suppress("type")] ] for (;;) a = [[1]] + 1;
378
377
})cpp" ,
379
- R"cpp( void f(int a) {
378
+ R"cpp( void f(int a) {
380
379
auto dummy = 1; [ [gsl::suppress("type")] ] for (;;) a = dummy + 1;
381
380
})cpp" },
382
- // MemberExpr
383
- {R"cpp( class T {
381
+ // MemberExpr
382
+ {R"cpp( class T {
384
383
T f() {
385
384
return [[T().f()]].f();
386
385
}
387
386
};)cpp" ,
388
- R"cpp( class T {
387
+ R"cpp( class T {
389
388
T f() {
390
389
auto dummy = T().f(); return dummy.f();
391
390
}
392
391
};)cpp" },
393
- // Function DeclRefExpr
394
- {R"cpp( int f() {
392
+ // Function DeclRefExpr
393
+ {R"cpp( int f() {
395
394
return [[f]]();
396
395
})cpp" ,
397
- R"cpp( int f() {
396
+ R"cpp( int f() {
398
397
auto dummy = f(); return dummy;
399
398
})cpp" },
400
- // FIXME: Wrong result for \[\[clang::uninitialized\]\] int b = [[1]];
401
- // since the attr is inside the DeclStmt and the bounds of
402
- // DeclStmt don't cover the attribute.
399
+ // FIXME: Wrong result for \[\[clang::uninitialized\]\] int b = [[1]];
400
+ // since the attr is inside the DeclStmt and the bounds of
401
+ // DeclStmt don't cover the attribute.
403
402
404
- // Binary subexpressions
405
- {R"cpp( void f() {
403
+ // Binary subexpressions
404
+ {R"cpp( void f() {
406
405
int x = 1 + [[2 + 3 + 4]] + 5;
407
406
})cpp" ,
408
- R"cpp( void f() {
407
+ R"cpp( void f() {
409
408
auto dummy = 2 + 3 + 4; int x = 1 + dummy + 5;
410
409
})cpp" },
411
- {R"cpp( void f() {
410
+ {R"cpp( void f() {
412
411
int x = [[1 + 2 + 3]] + 4 + 5;
413
412
})cpp" ,
414
- R"cpp( void f() {
413
+ R"cpp( void f() {
415
414
auto dummy = 1 + 2 + 3; int x = dummy + 4 + 5;
416
415
})cpp" },
417
- {R"cpp( void f() {
416
+ {R"cpp( void f() {
418
417
int x = 1 + 2 + [[3 + 4 + 5]];
419
418
})cpp" ,
420
- R"cpp( void f() {
419
+ R"cpp( void f() {
421
420
auto dummy = 3 + 4 + 5; int x = 1 + 2 + dummy;
422
421
})cpp" },
423
- // Non-associative operations have no special support
424
- {R"cpp( void f() {
422
+ // Non-associative operations have no special support
423
+ {R"cpp( void f() {
425
424
int x = 1 - [[2 - 3 - 4]] - 5;
426
425
})cpp" ,
427
- R"cpp( void f() {
426
+ R"cpp( void f() {
428
427
auto dummy = 1 - 2 - 3 - 4; int x = dummy - 5;
429
428
})cpp" },
430
- // A mix of associative operators isn't associative.
431
- {R"cpp( void f() {
429
+ // A mix of associative operators isn't associative.
430
+ {R"cpp( void f() {
432
431
int x = 0 + 1 * [[2 + 3]] * 4 + 5;
433
432
})cpp" ,
434
- R"cpp( void f() {
433
+ R"cpp( void f() {
435
434
auto dummy = 1 * 2 + 3 * 4; int x = 0 + dummy + 5;
436
435
})cpp" },
437
- // Overloaded operators are supported, we assume associativity
438
- // as if they were built-in.
439
- {R"cpp( struct S {
436
+ // Overloaded operators are supported, we assume associativity
437
+ // as if they were built-in.
438
+ {R"cpp( struct S {
440
439
S(int);
441
440
};
442
441
S operator+(S, S);
443
442
444
443
void f() {
445
444
S x = S(1) + [[S(2) + S(3) + S(4)]] + S(5);
446
445
})cpp" ,
447
- R"cpp( struct S {
446
+ R"cpp( struct S {
448
447
S(int);
449
448
};
450
449
S operator+(S, S);
451
450
452
451
void f() {
453
452
auto dummy = S(2) + S(3) + S(4); S x = S(1) + dummy + S(5);
454
453
})cpp" },
455
- // Don't try to analyze across macro boundaries
456
- // FIXME: it'd be nice to do this someday (in a safe way)
457
- {R"cpp( #define ECHO(X) X
454
+ // Don't try to analyze across macro boundaries
455
+ // FIXME: it'd be nice to do this someday (in a safe way)
456
+ {R"cpp( #define ECHO(X) X
458
457
void f() {
459
458
int x = 1 + [[ECHO(2 + 3) + 4]] + 5;
460
459
})cpp" ,
461
- R"cpp( #define ECHO(X) X
460
+ R"cpp( #define ECHO(X) X
462
461
void f() {
463
462
auto dummy = 1 + ECHO(2 + 3) + 4; int x = dummy + 5;
464
463
})cpp" },
465
- {R"cpp( #define ECHO(X) X
464
+ {R"cpp( #define ECHO(X) X
466
465
void f() {
467
466
int x = 1 + [[ECHO(2) + ECHO(3) + 4]] + 5;
468
467
})cpp" ,
469
- R"cpp( #define ECHO(X) X
468
+ R"cpp( #define ECHO(X) X
470
469
void f() {
471
470
auto dummy = 1 + ECHO(2) + ECHO(3) + 4; int x = dummy + 5;
472
471
})cpp" },
473
- };
472
+ };
474
473
for (const auto &IO : InputOutputs) {
475
474
EXPECT_EQ (IO.second , apply (IO.first )) << IO.first ;
476
475
}
@@ -721,7 +720,7 @@ TEST_F(ExtractFunctionTest, ControlFlow) {
721
720
722
721
TEST_F (ExtractFunctionTest, ExistingReturnStatement) {
723
722
Context = File;
724
- const char * Before = R"cpp(
723
+ const char * Before = R"cpp(
725
724
bool lucky(int N);
726
725
int getNum(bool Superstitious, int Min, int Max) {
727
726
if (Superstitious) [[{
@@ -736,7 +735,7 @@ TEST_F(ExtractFunctionTest, ExistingReturnStatement) {
736
735
)cpp" ;
737
736
// FIXME: min/max should be by value.
738
737
// FIXME: avoid emitting redundant braces
739
- const char * After = R"cpp(
738
+ const char * After = R"cpp(
740
739
bool lucky(int N);
741
740
int extracted(int &Min, int &Max) {
742
741
{
0 commit comments