[Clangd] Fixed ExtractVariable test
authorShaurya Gupta <shauryab98@gmail.com>
Fri, 19 Jul 2019 12:11:04 +0000 (12:11 +0000)
committerShaurya Gupta <shauryab98@gmail.com>
Fri, 19 Jul 2019 12:11:04 +0000 (12:11 +0000)
llvm-svn: 366568

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

index f918b73..c5c5ca0 100644 (file)
@@ -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