[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
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@374048 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/clangd/refactor/tweaks/ExpandAutoType.cpp b/clangd/refactor/tweaks/ExpandAutoType.cpp
index eaab40b..76c14ae 100644
--- a/clangd/refactor/tweaks/ExpandAutoType.cpp
+++ b/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;
}
}
}
diff --git a/clangd/unittests/TweakTests.cpp b/clangd/unittests/TweakTests.cpp
index 97cd4a2..8cc29dd 100644
--- a/clangd/unittests/TweakTests.cpp
+++ b/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);