From: Shaurya Gupta Date: Fri, 19 Jul 2019 12:11:04 +0000 (+0000) Subject: [Clangd] Fixed ExtractVariable test X-Git-Tag: llvmorg-11-init~13987 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=20a0e7caaf39d14929c1469f341acb664356eeb9;p=platform%2Fupstream%2Fllvm.git [Clangd] Fixed ExtractVariable test llvm-svn: 366568 --- diff --git a/clang-tools-extra/clangd/unittests/TweakTests.cpp b/clang-tools-extra/clangd/unittests/TweakTests.cpp index f918b73..c5c5ca0 100644 --- a/clang-tools-extra/clangd/unittests/TweakTests.cpp +++ b/clang-tools-extra/clangd/unittests/TweakTests.cpp @@ -398,17 +398,23 @@ TEST(TweakTest, ExtractVariable) { } })cpp"},*/ // ensure InsertionPoint isn't inside a macro - // FIXME: SelectionTree needs to be fixed for macros - /*{R"cpp(#define LOOP(x) while (1) {a = x;} + {R"cpp(#define LOOP(x) while (1) {a = x;} void f(int a) { if(1) LOOP(5 + [[3]]) })cpp", - R"cpp(#define LOOP(x) while (1) {a = x;} + /*FIXME: It should be extracted like this. SelectionTree needs to be + * fixed for macros. + R"cpp(#define LOOP(x) while (1) {a = x;} + void f(int a) { + auto dummy = 3; if(1) + LOOP(5 + dummy) + })cpp"},*/ + R"cpp(#define LOOP(x) while (1) {a = x;} void f(int a) { - auto dummy = 3; if(1) - LOOP(5 + dummy) - })cpp"},*/ + auto dummy = LOOP(5 + 3); if(1) + dummy + })cpp"}, {R"cpp(#define LOOP(x) do {x;} while(1); void f(int a) { if(1) @@ -426,15 +432,15 @@ TEST(TweakTest, ExtractVariable) { R"cpp(void f(int a) { auto dummy = 1; label: [ [gsl::suppress("type")] ] for (;;) a = dummy; })cpp"}, - // FIXME: Doesn't work because bug in selection tree - /*{R"cpp(#define PLUS(x) x++ + // macro testing + {R"cpp(#define PLUS(x) x++ void f(int a) { PLUS([[a]]); })cpp", R"cpp(#define PLUS(x) x++ void f(int a) { auto dummy = a; PLUS(dummy); - })cpp"},*/ + })cpp"}, // FIXME: Doesn't work correctly for \[\[clang::uninitialized\]\] int // b = [[1]]; since the attr is inside the DeclStmt and the bounds of // DeclStmt don't cover the attribute