This revision was automatically updated to reflect the committed changes.
Closed by commit rG1b36caf45e5e: [clangd] Disable expand auto on decltype(auto)
(authored by ilya-biryukov).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D68630/new/
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;
}
}
}
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;
}
}
}
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits