[clang] 1feb7af - [clangd] support expanding `decltype(expr)`

Sam McCall via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 12 18:27:24 PST 2023


Author: v1nh1shungry
Date: 2023-01-13T03:26:33+01:00
New Revision: 1feb7af046889728233e67e3163ab30020207bb2

URL: https://github.com/llvm/llvm-project/commit/1feb7af046889728233e67e3163ab30020207bb2
DIFF: https://github.com/llvm/llvm-project/commit/1feb7af046889728233e67e3163ab30020207bb2.diff

LOG: [clangd] support expanding `decltype(expr)`

Enable the existing tweak `ExpandAutoType` to expand
`decltype(expr)`, e.g.

```
decltype(0) i;
```

will expand to

```
int i;
```

Therefore, rename the tweak `ExpandAutoType` to `ExpandDeducedType`.

This patch also fixes some nits,

* avoid replacing reference to a function
* avoid replacing array types and reference to an array

Fixes https://github.com/clangd/clangd/issues/1456

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D141226

Added: 
    clang-tools-extra/clangd/refactor/tweaks/ExpandDeducedType.cpp
    clang-tools-extra/clangd/unittests/tweaks/ExpandDeducedTypeTests.cpp

Modified: 
    clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
    clang-tools-extra/clangd/test/check-fail.test
    clang-tools-extra/clangd/test/check-lines.test
    clang-tools-extra/clangd/test/check.test
    clang-tools-extra/clangd/test/code-action-request.test
    clang-tools-extra/clangd/test/request-reply.test
    clang-tools-extra/clangd/unittests/CMakeLists.txt
    clang-tools-extra/clangd/unittests/tweaks/TweakTesting.h
    clang/docs/tools/clang-formatted-files.txt
    llvm/utils/gn/secondary/clang-tools-extra/clangd/refactor/tweaks/BUILD.gn
    llvm/utils/gn/secondary/clang-tools-extra/clangd/unittests/BUILD.gn

Removed: 
    clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
    clang-tools-extra/clangd/unittests/tweaks/ExpandAutoTypeTests.cpp


################################################################################
diff  --git a/clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt b/clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
index 3d59608a04239..319503b1143c3 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
+++ b/clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
@@ -17,7 +17,7 @@ add_clang_library(clangDaemonTweaks OBJECT
   DumpAST.cpp
   DefineInline.cpp
   DefineOutline.cpp
-  ExpandAutoType.cpp
+  ExpandDeducedType.cpp
   ExpandMacro.cpp
   ExtractFunction.cpp
   ExtractVariable.cpp

diff  --git a/clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp b/clang-tools-extra/clangd/refactor/tweaks/ExpandDeducedType.cpp
similarity index 64%
rename from clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
rename to clang-tools-extra/clangd/refactor/tweaks/ExpandDeducedType.cpp
index b420d0e874862..fec5f5797cb62 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/ExpandDeducedType.cpp
@@ -1,4 +1,4 @@
-//===--- ExpandAutoType.cpp --------------------------------------*- C++-*-===//
+//===--- ExpandDeducedType.cpp -----------------------------------*- C++-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -29,8 +29,14 @@ namespace {
 /// After:
 ///    MyClass x = Something();
 ///    ^^^^^^^
-/// FIXME: Handle decltype as well
-class ExpandAutoType : public Tweak {
+/// Expand `decltype(expr)` to the deduced type
+/// Before:
+///   decltype(0) i;
+///   ^^^^^^^^^^^
+/// After:
+///   int i;
+///   ^^^
+class ExpandDeducedType : public Tweak {
 public:
   const char *id() const final;
   llvm::StringLiteral kind() const override {
@@ -41,12 +47,14 @@ class ExpandAutoType : public Tweak {
   std::string title() const override;
 
 private:
-  SourceRange AutoRange;
+  SourceRange Range;
 };
 
-REGISTER_TWEAK(ExpandAutoType)
+REGISTER_TWEAK(ExpandDeducedType)
 
-std::string ExpandAutoType::title() const { return "Expand auto type"; }
+std::string ExpandDeducedType::title() const {
+  return "Replace with deduced type";
+}
 
 // Structured bindings must use auto, e.g. `const auto& [a,b,c] = ...;`.
 // Return whether N (an AutoTypeLoc) is such an auto that must not be expanded.
@@ -58,6 +66,13 @@ bool isStructuredBindingType(const SelectionTree::Node *N) {
   return N && N->ASTNode.get<DecompositionDecl>();
 }
 
+bool isLambda(QualType QT) {
+  if (!QT.isNull())
+    if (const auto *RD = QT->getAsRecordDecl())
+      return RD->isLambda();
+  return false;
+}
+
 // Returns true iff Node is a lambda, and thus should not be expanded. Loc is
 // the location of the auto type.
 bool isDeducedAsLambda(const SelectionTree::Node *Node, SourceLocation Loc) {
@@ -68,10 +83,9 @@ bool isDeducedAsLambda(const SelectionTree::Node *Node, SourceLocation Loc) {
   for (const auto *It = Node; It; It = It->Parent) {
     if (const auto *DD = It->ASTNode.get<DeclaratorDecl>()) {
       if (DD->getTypeSourceInfo() &&
-          DD->getTypeSourceInfo()->getTypeLoc().getBeginLoc() == Loc) {
-        if (auto *RD = DD->getType()->getAsRecordDecl())
-          return RD->isLambda();
-      }
+          DD->getTypeSourceInfo()->getTypeLoc().getBeginLoc() == Loc &&
+          isLambda(DD->getType()))
+        return true;
     }
   }
   return false;
@@ -86,14 +100,14 @@ bool isTemplateParam(const SelectionTree::Node *Node) {
   return false;
 }
 
-bool ExpandAutoType::prepare(const Selection &Inputs) {
+bool ExpandDeducedType::prepare(const Selection &Inputs) {
   if (auto *Node = Inputs.ASTSelection.commonAncestor()) {
     if (auto *TypeNode = Node->ASTNode.get<TypeLoc>()) {
       if (const AutoTypeLoc Result = TypeNode->getAs<AutoTypeLoc>()) {
         if (!isStructuredBindingType(Node) &&
             !isDeducedAsLambda(Node, Result.getBeginLoc()) &&
             !isTemplateParam(Node))
-          AutoRange = Result.getSourceRange();
+          Range = Result.getSourceRange();
       }
       if (auto TTPAuto = TypeNode->getAs<TemplateTypeParmTypeLoc>()) {
         // We exclude concept constraints for now, as the SourceRange is wrong.
@@ -102,41 +116,53 @@ bool ExpandAutoType::prepare(const Selection &Inputs) {
         // TTPAuto->getSourceRange only covers "auto", not "C auto".
         if (TTPAuto.getDecl()->isImplicit() &&
             !TTPAuto.getDecl()->hasTypeConstraint())
-          AutoRange = TTPAuto.getSourceRange();
+          Range = TTPAuto.getSourceRange();
+      }
+
+      if (auto DTTL = TypeNode->getAs<DecltypeTypeLoc>()) {
+        if (!isLambda(cast<DecltypeType>(DTTL.getType())->getUnderlyingType()))
+          Range = DTTL.getSourceRange();
       }
     }
   }
 
-  return AutoRange.isValid();
+  return Range.isValid();
 }
 
-Expected<Tweak::Effect> ExpandAutoType::apply(const Selection& Inputs) {
+Expected<Tweak::Effect> ExpandDeducedType::apply(const Selection &Inputs) {
   auto &SrcMgr = Inputs.AST->getSourceManager();
 
   std::optional<clang::QualType> DeducedType =
-      getDeducedType(Inputs.AST->getASTContext(), AutoRange.getBegin());
+      getDeducedType(Inputs.AST->getASTContext(), Range.getBegin());
 
   // if we can't resolve the type, return an error message
   if (DeducedType == std::nullopt || (*DeducedType)->isUndeducedAutoType())
     return error("Could not deduce type for 'auto' type");
 
-  // if it's a lambda expression, return an error message
-  if (isa<RecordType>(*DeducedType) &&
-      cast<RecordType>(*DeducedType)->getDecl()->isLambda()) {
-    return error("Could not expand type of lambda expression");
-  }
-
-  // if it's a function expression, return an error message
-  // naively replacing 'auto' with the type will break declarations.
-  // FIXME: there are other types that have similar problems
-  if (DeducedType->getTypePtr()->isFunctionPointerType()) {
-    return error("Could not expand type of function pointer");
-  }
-
-  std::string PrettyTypeName = printType(*DeducedType,
-      Inputs.ASTSelection.commonAncestor()->getDeclContext());
-
-  tooling::Replacement Expansion(SrcMgr, CharSourceRange(AutoRange, true),
+  // we shouldn't replace a dependent type which is likely not to print
+  // usefully, e.g.
+  //   template <class T>
+  //   struct Foobar {
+  //     decltype(T{}) foobar;
+  //     ^^^^^^^^^^^^^ would turn out to be `<dependent-type>`
+  //   };
+  if ((*DeducedType)->isDependentType())
+    return error("Could not expand a dependent type");
+
+  // Some types aren't written as single chunks of text, e.g:
+  //   auto fptr = &func; // auto is void(*)()
+  // ==>
+  //   void (*fptr)() = &func;
+  // Replacing these requires examining the declarator, we don't support it yet.
+  std::string PrettyDeclarator = printType(
+      *DeducedType, Inputs.ASTSelection.commonAncestor()->getDeclContext(),
+      "DECLARATOR_ID");
+  llvm::StringRef PrettyTypeName = PrettyDeclarator;
+  if (!PrettyTypeName.consume_back("DECLARATOR_ID"))
+    return error("Could not expand type that isn't a simple string");
+  PrettyTypeName = PrettyTypeName.rtrim();
+
+  tooling::Replacement Expansion(SrcMgr, CharSourceRange(Range, true),
                                  PrettyTypeName);
 
   return Effect::mainFileEdit(SrcMgr, tooling::Replacements(Expansion));

diff  --git a/clang-tools-extra/clangd/test/check-fail.test b/clang-tools-extra/clangd/test/check-fail.test
index 5a370b4653b1c..ce16596ec4fc8 100644
--- a/clang-tools-extra/clangd/test/check-fail.test
+++ b/clang-tools-extra/clangd/test/check-fail.test
@@ -7,7 +7,7 @@
 // CHECK: [pp_file_not_found] Line {{.*}}: 'missing.h' file not found
 // CHECK: Building AST...
 // CHECK: Testing features at each token
-// CHECK: tweak: ExpandAutoType ==> FAIL
+// CHECK: tweak: ExpandDeducedType ==> FAIL
 // CHECK: All checks completed, 2 errors
 
 #include "missing.h"

diff  --git a/clang-tools-extra/clangd/test/check-lines.test b/clang-tools-extra/clangd/test/check-lines.test
index 4e8509869d8f9..3488849dfdb81 100644
--- a/clang-tools-extra/clangd/test/check-lines.test
+++ b/clang-tools-extra/clangd/test/check-lines.test
@@ -7,7 +7,7 @@
 // CHECK: Building preamble...
 // CHECK: Building AST...
 // CHECK: Testing features at each token
-// CHECK: tweak: ExpandAutoType ==> FAIL
+// CHECK: tweak: ExpandDeducedType ==> FAIL
 // CHECK: All checks completed, 1 errors
 
 void fun();

diff  --git a/clang-tools-extra/clangd/test/check.test b/clang-tools-extra/clangd/test/check.test
index 280e01ef0a044..60a542fba8bea 100644
--- a/clang-tools-extra/clangd/test/check.test
+++ b/clang-tools-extra/clangd/test/check.test
@@ -7,7 +7,7 @@
 // CHECK: Built preamble
 // CHECK: Building AST...
 // CHECK: Testing features at each token
-// CHECK-DAG: tweak: ExpandAuto
+// CHECK-DAG: tweak: ExpandDeducedType
 // CHECK-DAG: hover: true
 // CHECK-DAG: tweak: AddUsing
 // CHECK: All checks completed, 0 errors

diff  --git a/clang-tools-extra/clangd/test/code-action-request.test b/clang-tools-extra/clangd/test/code-action-request.test
index f16f77989b473..f1511f58f561f 100644
--- a/clang-tools-extra/clangd/test/code-action-request.test
+++ b/clang-tools-extra/clangd/test/code-action-request.test
@@ -43,11 +43,11 @@
 # CHECK-NEXT:              "line": 0
 # CHECK-NEXT:            }
 # CHECK-NEXT:          },
-# CHECK-NEXT:          "tweakID": "ExpandAutoType"
+# CHECK-NEXT:          "tweakID": "ExpandDeducedType"
 # CHECK-NEXT:        }
 # CHECK-NEXT:      ],
 # CHECK-NEXT:      "command": "clangd.applyTweak",
-# CHECK-NEXT:      "title": "Expand auto type"
+# CHECK-NEXT:      "title": "Replace with deduced type"
 # CHECK-NEXT:    }
 # CHECK-NEXT:  ]
 ---
@@ -92,7 +92,7 @@
 # CHECK-NEXT:  "result": [
 # CHECK-NEXT:    {
 ---
-{"jsonrpc":"2.0","id":4,"method":"workspace/executeCommand","params":{"command":"clangd.applyTweak","arguments":[{"file":"test:///main.cpp","selection":{"end":{"character":4,"line":0},"start":{"character":0,"line":0}},"tweakID":"ExpandAutoType"}]}}
+{"jsonrpc":"2.0","id":4,"method":"workspace/executeCommand","params":{"command":"clangd.applyTweak","arguments":[{"file":"test:///main.cpp","selection":{"end":{"character":4,"line":0},"start":{"character":0,"line":0}},"tweakID":"ExpandDeducedType"}]}}
 #      CHECK:    "newText": "int",
 # CHECK-NEXT:    "range": {
 # CHECK-NEXT:      "end": {

diff  --git a/clang-tools-extra/clangd/test/request-reply.test b/clang-tools-extra/clangd/test/request-reply.test
index 08e1c6c69f8e3..de88feee06728 100644
--- a/clang-tools-extra/clangd/test/request-reply.test
+++ b/clang-tools-extra/clangd/test/request-reply.test
@@ -3,7 +3,7 @@
 ---
 {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"auto i = 0;"}}}
 ---
-{"jsonrpc":"2.0","id":4,"method":"workspace/executeCommand","params":{"command":"clangd.applyTweak","arguments":[{"file":"test:///main.cpp","selection":{"end":{"character":4,"line":0},"start":{"character":0,"line":0}},"tweakID":"ExpandAutoType"}]}}
+{"jsonrpc":"2.0","id":4,"method":"workspace/executeCommand","params":{"command":"clangd.applyTweak","arguments":[{"file":"test:///main.cpp","selection":{"end":{"character":4,"line":0},"start":{"character":0,"line":0}},"tweakID":"ExpandDeducedType"}]}}
 #      CHECK:  "id": 0,
 #      CHECK:  "method": "workspace/applyEdit",
 #      CHECK:  "newText": "int",
@@ -25,7 +25,7 @@
 # CHECK-NEXT:  },
 # CHECK-NEXT:  "id": 4,
 ---
-{"jsonrpc":"2.0","id":5,"method":"workspace/executeCommand","params":{"command":"clangd.applyTweak","arguments":[{"file":"test:///main.cpp","selection":{"end":{"character":4,"line":0},"start":{"character":0,"line":0}},"tweakID":"ExpandAutoType"}]}}
+{"jsonrpc":"2.0","id":5,"method":"workspace/executeCommand","params":{"command":"clangd.applyTweak","arguments":[{"file":"test:///main.cpp","selection":{"end":{"character":4,"line":0},"start":{"character":0,"line":0}},"tweakID":"ExpandDeducedType"}]}}
 #      CHECK:  "id": 1,
 #      CHECK:  "method": "workspace/applyEdit",
 ---

diff  --git a/clang-tools-extra/clangd/unittests/CMakeLists.txt b/clang-tools-extra/clangd/unittests/CMakeLists.txt
index 7d142529c5a0c..ee278b4365be7 100644
--- a/clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ b/clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -119,7 +119,7 @@ add_unittest(ClangdUnitTests ClangdTests
   tweaks/DumpASTTests.cpp
   tweaks/DumpRecordLayoutTests.cpp
   tweaks/DumpSymbolTests.cpp
-  tweaks/ExpandAutoTypeTests.cpp
+  tweaks/ExpandDeducedTypeTests.cpp
   tweaks/ExpandMacroTests.cpp
   tweaks/ExtractFunctionTests.cpp
   tweaks/ExtractVariableTests.cpp

diff  --git a/clang-tools-extra/clangd/unittests/tweaks/ExpandAutoTypeTests.cpp b/clang-tools-extra/clangd/unittests/tweaks/ExpandDeducedTypeTests.cpp
similarity index 54%
rename from clang-tools-extra/clangd/unittests/tweaks/ExpandAutoTypeTests.cpp
rename to clang-tools-extra/clangd/unittests/tweaks/ExpandDeducedTypeTests.cpp
index c538e85d4e58a..3730ab4a87136 100644
--- a/clang-tools-extra/clangd/unittests/tweaks/ExpandAutoTypeTests.cpp
+++ b/clang-tools-extra/clangd/unittests/tweaks/ExpandDeducedTypeTests.cpp
@@ -1,4 +1,4 @@
-//===-- ExpandAutoTypeTests.cpp ---------------------------------*- C++ -*-===//
+//===-- ExpandDeducedTypeTests.cpp ------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -16,9 +16,9 @@ namespace clang {
 namespace clangd {
 namespace {
 
-TWEAK_TEST(ExpandAutoType);
+TWEAK_TEST(ExpandDeducedType);
 
-TEST_F(ExpandAutoTypeTest, Test) {
+TEST_F(ExpandDeducedTypeTest, Test) {
   Header = R"cpp(
     namespace ns {
       struct Class {
@@ -50,7 +50,10 @@ TEST_F(ExpandAutoTypeTest, Test) {
               StartsWith("fail: Could not deduce type for 'auto' type"));
   // function pointers should not be replaced
   EXPECT_THAT(apply("au^to x = &ns::Func;"),
-              StartsWith("fail: Could not expand type of function pointer"));
+              StartsWith("fail: Could not expand type"));
+  // function references should not be replaced
+  EXPECT_THAT(apply("au^to &x = ns::Func;"),
+              StartsWith("fail: Could not expand type"));
   // lambda types are not replaced
   EXPECT_UNAVAILABLE("au^to x = []{};");
   // inline namespaces
@@ -59,9 +62,12 @@ TEST_F(ExpandAutoTypeTest, Test) {
   // local class
   EXPECT_EQ(apply("namespace x { void y() { struct S{}; ^auto z = S(); } }"),
             "namespace x { void y() { struct S{}; S z = S(); } }");
-  // replace array types
+  // replace pointers
   EXPECT_EQ(apply(R"cpp(au^to x = "test";)cpp"),
             R"cpp(const char * x = "test";)cpp");
+  // pointers to an array are not replaced
+  EXPECT_THAT(apply(R"cpp(au^to s = &"foobar";)cpp"),
+              StartsWith("fail: Could not expand type"));
 
   EXPECT_EQ(apply("ns::Class * foo() { au^to c = foo(); }"),
             "ns::Class * foo() { ns::Class * c = foo(); }");
@@ -71,6 +77,15 @@ TEST_F(ExpandAutoTypeTest, Test) {
 
   EXPECT_EQ(apply("dec^ltype(auto) x = 10;"), "int x = 10;");
   EXPECT_EQ(apply("decltype(au^to) x = 10;"), "int x = 10;");
+  // references to array types are not replaced
+  EXPECT_THAT(apply(R"cpp(decl^type(auto) s = "foobar"; // error-ok)cpp"),
+              StartsWith("fail: Could not expand type"));
+  // array types are not replaced
+  EXPECT_THAT(apply("int arr[10]; decl^type(auto) foobar = arr; // error-ok"),
+              StartsWith("fail: Could not expand type"));
+  // pointers to an array are not replaced
+  EXPECT_THAT(apply(R"cpp(decl^type(auto) s = &"foobar";)cpp"),
+              StartsWith("fail: Could not expand type"));
   // expanding types in structured bindings is syntactically invalid.
   EXPECT_UNAVAILABLE("const ^auto &[x,y] = (int[]){1,2};");
 
@@ -78,6 +93,40 @@ TEST_F(ExpandAutoTypeTest, Test) {
   EXPECT_THAT(apply("template <typename T> void x() { ^auto y = T::z(); }"),
               StartsWith("fail: Could not deduce type for 'auto' type"));
 
+  // check primitive type
+  EXPECT_EQ(apply("decl^type(0) i;"), "int i;");
+  // function should not be replaced
+  EXPECT_THAT(apply("void f(); decl^type(f) g;"),
+              StartsWith("fail: Could not expand type"));
+  // check return type in function proto
+  EXPECT_EQ(apply("decl^type(0) f();"), "int f();");
+  // check trailing return type
+  EXPECT_EQ(apply("auto f() -> decl^type(0) { return 0; }"),
+            "auto f() -> int { return 0; }");
+  // check function parameter type
+  EXPECT_EQ(apply("void f(decl^type(0));"), "void f(int);");
+  // check template parameter type
+  EXPECT_EQ(apply("template <decl^type(0)> struct Foobar {};"),
+            "template <int> struct Foobar {};");
+  // check default template argument
+  EXPECT_EQ(apply("template <class = decl^type(0)> class Foo {};"),
+            "template <class = int> class Foo {};");
+  // check template argument
+  EXPECT_EQ(apply("template <class> class Bar {}; Bar<decl^type(0)> b;"),
+            "template <class> class Bar {}; Bar<int> b;");
+  // dependent types are not replaced
+  EXPECT_THAT(apply("template <class T> struct Foobar { decl^type(T{}) t; };"),
+              StartsWith("fail: Could not expand a dependent type"));
+  // references to array types are not replaced
+  EXPECT_THAT(apply(R"cpp(decl^type("foobar") s; // error-ok)cpp"),
+              StartsWith("fail: Could not expand type"));
+  // array types are not replaced
+  EXPECT_THAT(apply("int arr[10]; decl^type(arr) foobar;"),
+              StartsWith("fail: Could not expand type"));
+  // pointers to an array are not replaced
+  EXPECT_THAT(apply(R"cpp(decl^type(&"foobar") s;)cpp"),
+              StartsWith("fail: Could not expand type"));
+
   ExtraArgs.push_back("-std=c++20");
   EXPECT_UNAVAILABLE("template <au^to X> class Y;");
 
@@ -90,6 +139,10 @@ TEST_F(ExpandAutoTypeTest, Test) {
   // FIXME: should work on constrained auto params, once SourceRange is fixed.
   EXPECT_UNAVAILABLE("template<class> concept C = true;"
                      "auto X = [](C ^auto *){return 0;};");
+
+  // lambda should not be replaced
+  EXPECT_UNAVAILABLE("auto f = [](){}; decl^type(f) g;");
+  EXPECT_UNAVAILABLE("decl^type([]{}) f;");
 }
 
 } // namespace

diff  --git a/clang-tools-extra/clangd/unittests/tweaks/TweakTesting.h b/clang-tools-extra/clangd/unittests/tweaks/TweakTesting.h
index 183f773becc71..9c6b1f9c000ae 100644
--- a/clang-tools-extra/clangd/unittests/tweaks/TweakTesting.h
+++ b/clang-tools-extra/clangd/unittests/tweaks/TweakTesting.h
@@ -25,9 +25,9 @@ namespace clangd {
 // Fixture base for testing tweaks. Intended to be subclassed for each tweak.
 //
 // Usage:
-// TWEAK_TEST(ExpandAutoType);
+// TWEAK_TEST(ExpandDeducedType);
 //
-// TEST_F(ExpandAutoTypeTest, ShortensTypes) {
+// TEST_F(ExpandDeducedTypeTest, ShortensTypes) {
 //   Header = R"cpp(
 //     namespace foo { template<typename> class X{}; }
 //     using namespace foo;

diff  --git a/clang/docs/tools/clang-formatted-files.txt b/clang/docs/tools/clang-formatted-files.txt
index 3bad9a2008159..708501329238b 100644
--- a/clang/docs/tools/clang-formatted-files.txt
+++ b/clang/docs/tools/clang-formatted-files.txt
@@ -1611,7 +1611,7 @@ clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp
 clang-tools-extra/clangd/unittests/tweaks/DumpASTTests.cpp
 clang-tools-extra/clangd/unittests/tweaks/DumpRecordLayoutTests.cpp
 clang-tools-extra/clangd/unittests/tweaks/DumpSymbolTests.cpp
-clang-tools-extra/clangd/unittests/tweaks/ExpandAutoTypeTests.cpp
+clang-tools-extra/clangd/unittests/tweaks/ExpandDeducedTypeTests.cpp
 clang-tools-extra/clangd/unittests/tweaks/ExpandMacroTests.cpp
 clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
 clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp

diff  --git a/llvm/utils/gn/secondary/clang-tools-extra/clangd/refactor/tweaks/BUILD.gn b/llvm/utils/gn/secondary/clang-tools-extra/clangd/refactor/tweaks/BUILD.gn
index 5a3465844f75e..7ad4e5cfd1222 100644
--- a/llvm/utils/gn/secondary/clang-tools-extra/clangd/refactor/tweaks/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang-tools-extra/clangd/refactor/tweaks/BUILD.gn
@@ -18,7 +18,7 @@ source_set("tweaks") {
     "DefineInline.cpp",
     "DefineOutline.cpp",
     "DumpAST.cpp",
-    "ExpandAutoType.cpp",
+    "ExpandDeducedType.cpp",
     "ExpandMacro.cpp",
     "ExtractFunction.cpp",
     "ExtractVariable.cpp",

diff  --git a/llvm/utils/gn/secondary/clang-tools-extra/clangd/unittests/BUILD.gn b/llvm/utils/gn/secondary/clang-tools-extra/clangd/unittests/BUILD.gn
index d7fddee09cba1..a7ab1be69021c 100644
--- a/llvm/utils/gn/secondary/clang-tools-extra/clangd/unittests/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang-tools-extra/clangd/unittests/BUILD.gn
@@ -130,7 +130,7 @@ unittest("ClangdTests") {
     "tweaks/DumpASTTests.cpp",
     "tweaks/DumpRecordLayoutTests.cpp",
     "tweaks/DumpSymbolTests.cpp",
-    "tweaks/ExpandAutoTypeTests.cpp",
+    "tweaks/ExpandDeducedTypeTests.cpp",
     "tweaks/ExpandMacroTests.cpp",
     "tweaks/ExtractFunctionTests.cpp",
     "tweaks/ExtractVariableTests.cpp",


        


More information about the cfe-commits mailing list