[PATCH] D114287: [clangd] IncludeCleaner: Mark possible expr resolutions as used

Kirill Bobyrev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 22 01:44:41 PST 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb5f20372a82f: [clangd] IncludeCleaner: Mark possible expr resolutions as used (authored by kbobyrev).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114287/new/

https://reviews.llvm.org/D114287

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
@@ -97,6 +97,10 @@
           "inline void ^foo() {}",
           "void bar() { foo(); }",
       },
+      {
+          "int ^foo(char); int ^foo(float);",
+          "template<class T> int x = foo(T{});",
+      },
       // 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
@@ -13,6 +13,7 @@
 #include "SourceCode.h"
 #include "support/Logger.h"
 #include "support/Trace.h"
+#include "clang/AST/ExprCXX.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Lex/HeaderSearch.h"
@@ -104,6 +105,13 @@
     return true;
   }
 
+  // When the overload is not resolved yet, mark all candidates as used.
+  bool VisitOverloadExpr(OverloadExpr *E) {
+    for (const auto *ResolutionDecl : E->decls())
+      add(ResolutionDecl);
+    return true;
+  }
+
 private:
   using Base = RecursiveASTVisitor<ReferencedLocationCrawler>;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114287.388817.patch
Type: text/x-patch
Size: 1393 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211122/9b6c270a/attachment.bin>


More information about the cfe-commits mailing list