Skip to content

Commit 411b8b4

Browse files
author
git apple-llvm automerger
committed
Merge commit 'fc2fb60bab75' from llvm.org/master into apple/main
2 parents 610b61f + fc2fb60 commit 411b8b4

File tree

1 file changed

+78
-79
lines changed

1 file changed

+78
-79
lines changed

clang-tools-extra/clangd/unittests/TweakTests.cpp

Lines changed: 78 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -305,172 +305,171 @@ TEST_F(ExtractVariableTest, Test) {
305305
EXPECT_UNAVAILABLE(UnavailableCases);
306306

307307
// 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() {
312311
int a = 5 * (4 + (3 [[- 1)]]);
313312
})cpp",
314-
R"cpp(void varDecl() {
313+
R"cpp(void varDecl() {
315314
auto dummy = (3 - 1); int a = 5 * (4 + dummy);
316315
})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++
342341
void f(int a) {
343342
int y = PLUS([[1+a]]);
344343
})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++
351350
void f(int a) {
352351
auto dummy = PLUS(1+a); int y = dummy;
353352
})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;}
356355
void f(int a) {
357356
if(1)
358357
LOOP(5 + [[3]])
359358
})cpp",
360-
R"cpp(#define LOOP(x) while (1) {a = x;}
359+
R"cpp(#define LOOP(x) while (1) {a = x;}
361360
void f(int a) {
362361
auto dummy = 3; if(1)
363362
LOOP(5 + dummy)
364363
})cpp"},
365-
{R"cpp(#define LOOP(x) do {x;} while(1);
364+
{R"cpp(#define LOOP(x) do {x;} while(1);
366365
void f(int a) {
367366
if(1)
368367
LOOP(5 + [[3]])
369368
})cpp",
370-
R"cpp(#define LOOP(x) do {x;} while(1);
369+
R"cpp(#define LOOP(x) do {x;} while(1);
371370
void f(int a) {
372371
auto dummy = 3; if(1)
373372
LOOP(5 + dummy)
374373
})cpp"},
375-
// attribute testing
376-
{R"cpp(void f(int a) {
374+
// attribute testing
375+
{R"cpp(void f(int a) {
377376
[ [gsl::suppress("type")] ] for (;;) a = [[1]] + 1;
378377
})cpp",
379-
R"cpp(void f(int a) {
378+
R"cpp(void f(int a) {
380379
auto dummy = 1; [ [gsl::suppress("type")] ] for (;;) a = dummy + 1;
381380
})cpp"},
382-
// MemberExpr
383-
{R"cpp(class T {
381+
// MemberExpr
382+
{R"cpp(class T {
384383
T f() {
385384
return [[T().f()]].f();
386385
}
387386
};)cpp",
388-
R"cpp(class T {
387+
R"cpp(class T {
389388
T f() {
390389
auto dummy = T().f(); return dummy.f();
391390
}
392391
};)cpp"},
393-
// Function DeclRefExpr
394-
{R"cpp(int f() {
392+
// Function DeclRefExpr
393+
{R"cpp(int f() {
395394
return [[f]]();
396395
})cpp",
397-
R"cpp(int f() {
396+
R"cpp(int f() {
398397
auto dummy = f(); return dummy;
399398
})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.
403402

404-
// Binary subexpressions
405-
{R"cpp(void f() {
403+
// Binary subexpressions
404+
{R"cpp(void f() {
406405
int x = 1 + [[2 + 3 + 4]] + 5;
407406
})cpp",
408-
R"cpp(void f() {
407+
R"cpp(void f() {
409408
auto dummy = 2 + 3 + 4; int x = 1 + dummy + 5;
410409
})cpp"},
411-
{R"cpp(void f() {
410+
{R"cpp(void f() {
412411
int x = [[1 + 2 + 3]] + 4 + 5;
413412
})cpp",
414-
R"cpp(void f() {
413+
R"cpp(void f() {
415414
auto dummy = 1 + 2 + 3; int x = dummy + 4 + 5;
416415
})cpp"},
417-
{R"cpp(void f() {
416+
{R"cpp(void f() {
418417
int x = 1 + 2 + [[3 + 4 + 5]];
419418
})cpp",
420-
R"cpp(void f() {
419+
R"cpp(void f() {
421420
auto dummy = 3 + 4 + 5; int x = 1 + 2 + dummy;
422421
})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() {
425424
int x = 1 - [[2 - 3 - 4]] - 5;
426425
})cpp",
427-
R"cpp(void f() {
426+
R"cpp(void f() {
428427
auto dummy = 1 - 2 - 3 - 4; int x = dummy - 5;
429428
})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() {
432431
int x = 0 + 1 * [[2 + 3]] * 4 + 5;
433432
})cpp",
434-
R"cpp(void f() {
433+
R"cpp(void f() {
435434
auto dummy = 1 * 2 + 3 * 4; int x = 0 + dummy + 5;
436435
})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 {
440439
S(int);
441440
};
442441
S operator+(S, S);
443442
444443
void f() {
445444
S x = S(1) + [[S(2) + S(3) + S(4)]] + S(5);
446445
})cpp",
447-
R"cpp(struct S {
446+
R"cpp(struct S {
448447
S(int);
449448
};
450449
S operator+(S, S);
451450
452451
void f() {
453452
auto dummy = S(2) + S(3) + S(4); S x = S(1) + dummy + S(5);
454453
})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
458457
void f() {
459458
int x = 1 + [[ECHO(2 + 3) + 4]] + 5;
460459
})cpp",
461-
R"cpp(#define ECHO(X) X
460+
R"cpp(#define ECHO(X) X
462461
void f() {
463462
auto dummy = 1 + ECHO(2 + 3) + 4; int x = dummy + 5;
464463
})cpp"},
465-
{R"cpp(#define ECHO(X) X
464+
{R"cpp(#define ECHO(X) X
466465
void f() {
467466
int x = 1 + [[ECHO(2) + ECHO(3) + 4]] + 5;
468467
})cpp",
469-
R"cpp(#define ECHO(X) X
468+
R"cpp(#define ECHO(X) X
470469
void f() {
471470
auto dummy = 1 + ECHO(2) + ECHO(3) + 4; int x = dummy + 5;
472471
})cpp"},
473-
};
472+
};
474473
for (const auto &IO : InputOutputs) {
475474
EXPECT_EQ(IO.second, apply(IO.first)) << IO.first;
476475
}
@@ -721,7 +720,7 @@ TEST_F(ExtractFunctionTest, ControlFlow) {
721720

722721
TEST_F(ExtractFunctionTest, ExistingReturnStatement) {
723722
Context = File;
724-
const char* Before = R"cpp(
723+
const char *Before = R"cpp(
725724
bool lucky(int N);
726725
int getNum(bool Superstitious, int Min, int Max) {
727726
if (Superstitious) [[{
@@ -736,7 +735,7 @@ TEST_F(ExtractFunctionTest, ExistingReturnStatement) {
736735
)cpp";
737736
// FIXME: min/max should be by value.
738737
// FIXME: avoid emitting redundant braces
739-
const char* After = R"cpp(
738+
const char *After = R"cpp(
740739
bool lucky(int N);
741740
int extracted(int &Min, int &Max) {
742741
{

0 commit comments

Comments
 (0)