ilya-biryukov created this revision.
ilya-biryukov added a reviewer: sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman, jkorous, MaskRay.
Herald added a project: clang.

Applying it produces incorrect code at the moment.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68630

Files:
  clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp


Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -528,6 +528,8 @@
   // replace array types
   EXPECT_EQ(apply(R"cpp(au^to x = "test")cpp"),
             R"cpp(const char * x = "test")cpp");
+
+  EXPECT_UNAVAILABLE("dec^ltype(au^to) x = 10;");
 }
 
 TWEAK_TEST(ExtractFunction);
Index: clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
===================================================================
--- clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
@@ -61,7 +61,9 @@
   if (auto *Node = Inputs.ASTSelection.commonAncestor()) {
     if (auto *TypeNode = Node->ASTNode.get<TypeLoc>()) {
       if (const AutoTypeLoc Result = TypeNode->getAs<AutoTypeLoc>()) {
-        CachedLocation = Result;
+        // Code in apply() does handle 'decltype(auto)' yet.
+        if (!Result.getTypePtr()->isDecltypeAuto())
+          CachedLocation = Result;
       }
     }
   }


Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -528,6 +528,8 @@
   // replace array types
   EXPECT_EQ(apply(R"cpp(au^to x = "test")cpp"),
             R"cpp(const char * x = "test")cpp");
+
+  EXPECT_UNAVAILABLE("dec^ltype(au^to) x = 10;");
 }
 
 TWEAK_TEST(ExtractFunction);
Index: clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
===================================================================
--- clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
@@ -61,7 +61,9 @@
   if (auto *Node = Inputs.ASTSelection.commonAncestor()) {
     if (auto *TypeNode = Node->ASTNode.get<TypeLoc>()) {
       if (const AutoTypeLoc Result = TypeNode->getAs<AutoTypeLoc>()) {
-        CachedLocation = Result;
+        // Code in apply() does handle 'decltype(auto)' yet.
+        if (!Result.getTypePtr()->isDecltypeAuto())
+          CachedLocation = Result;
       }
     }
   }
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to