[PATCH] D111711: [clangd] IncludeCleaner: ReferencedLocationCrawler should handle FunctionDecls

Kirill Bobyrev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 13 05:58:31 PDT 2021


kbobyrev created this revision.
kbobyrev added a reviewer: sammccall.
Herald added subscribers: usaxena95, arphaman.
kbobyrev requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111711

Files:
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp


Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -79,6 +79,11 @@
           "struct ^X { ^X(int) {} int ^foo(); };",
           "auto x = X(42); auto y = x.foo();",
       },
+      // Function
+      {
+          "void ^foo();",
+          "void foo() {}",
+      },
       // Static function
       {
           "struct ^X { static bool ^foo(); }; bool X::^foo() {}",
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===================================================================
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -39,6 +39,11 @@
     return true;
   }
 
+  bool VisitFunctionDecl(FunctionDecl *FD) {
+    add(FD->getDefinition());
+    return true;
+  }
+
   bool VisitCXXConstructExpr(CXXConstructExpr *CCE) {
     add(CCE->getConstructor());
     return true;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111711.379357.patch
Type: text/x-patch
Size: 1051 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211013/16b653a2/attachment.bin>


More information about the cfe-commits mailing list