[PATCH] D68630: [clangd] Disable expand auto on decltype(auto)
Ilya Biryukov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 8 03:36:53 PDT 2019
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;
}
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68630.223814.patch
Type: text/x-patch
Size: 1143 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191008/18b2a1ea/attachment-0001.bin>
More information about the cfe-commits
mailing list