[clang-tools-extra] r374048 - [clangd] Disable expand auto on decltype(auto)

Ilya Biryukov via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 8 07:03:45 PDT 2019


Author: ibiryukov
Date: Tue Oct  8 07:03:45 2019
New Revision: 374048

URL: http://llvm.org/viewvc/llvm-project?rev=374048&view=rev
Log:
[clangd] Disable expand auto on decltype(auto)

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

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

Modified: clang-tools-extra/trunk/clangd/refactor/tweaks/ExpandAutoType.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/refactor/tweaks/ExpandAutoType.cpp?rev=374048&r1=374047&r2=374048&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/refactor/tweaks/ExpandAutoType.cpp (original)
+++ clang-tools-extra/trunk/clangd/refactor/tweaks/ExpandAutoType.cpp Tue Oct  8 07:03:45 2019
@@ -61,7 +61,9 @@ bool ExpandAutoType::prepare(const Selec
   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;
       }
     }
   }

Modified: clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp?rev=374048&r1=374047&r2=374048&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp (original)
+++ clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp Tue Oct  8 07:03:45 2019
@@ -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);




More information about the cfe-commits mailing list