Skip to content

Commit 1b36caf

Browse files
committedOct 8, 2019
[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 llvm-svn: 374048
1 parent 3c46461 commit 1b36caf

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed
 

‎clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ bool ExpandAutoType::prepare(const Selection& Inputs) {
6161
if (auto *Node = Inputs.ASTSelection.commonAncestor()) {
6262
if (auto *TypeNode = Node->ASTNode.get<TypeLoc>()) {
6363
if (const AutoTypeLoc Result = TypeNode->getAs<AutoTypeLoc>()) {
64-
CachedLocation = Result;
64+
// Code in apply() does handle 'decltype(auto)' yet.
65+
if (!Result.getTypePtr()->isDecltypeAuto())
66+
CachedLocation = Result;
6567
}
6668
}
6769
}

‎clang-tools-extra/clangd/unittests/TweakTests.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,8 @@ TEST_F(ExpandAutoTypeTest, Test) {
528528
// replace array types
529529
EXPECT_EQ(apply(R"cpp(au^to x = "test")cpp"),
530530
R"cpp(const char * x = "test")cpp");
531+
532+
EXPECT_UNAVAILABLE("dec^ltype(au^to) x = 10;");
531533
}
532534

533535
TWEAK_TEST(ExtractFunction);

0 commit comments

Comments
 (0)
Please sign in to comment.