[clangd] Disable expand auto on decltype(auto)
authorIlya Biryukov <ibiryukov@google.com>
Tue, 8 Oct 2019 14:03:45 +0000 (14:03 +0000)
committerIlya Biryukov <ibiryukov@google.com>
Tue, 8 Oct 2019 14:03:45 +0000 (14:03 +0000)
Summary: Applying it produces incorrect code at the moment.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: kuhnel, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D68630

llvm-svn: 374048

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

index eaab40b..76c14ae 100644 (file)
@@ -61,7 +61,9 @@ bool ExpandAutoType::prepare(const Selection& Inputs) {
   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 97cd4a2..8cc29dd 100644 (file)
@@ -528,6 +528,8 @@ TEST_F(ExpandAutoTypeTest, Test) {
   // 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);