hokein created this revision.
hokein added a reviewer: kadircet.
Herald added a subscriber: arphaman.
Herald added a project: All.
hokein requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140000

Files:
  clang-tools-extra/clangd/tool/Check.cpp


Index: clang-tools-extra/clangd/tool/Check.cpp
===================================================================
--- clang-tools-extra/clangd/tool/Check.cpp
+++ clang-tools-extra/clangd/tool/Check.cpp
@@ -33,6 +33,7 @@
 #include "Feature.h"
 #include "GlobalCompilationDatabase.h"
 #include "Hover.h"
+#include "IncludeCleaner.h"
 #include "InlayHints.h"
 #include "ParsedAST.h"
 #include "Preamble.h"
@@ -332,6 +333,15 @@
     Inputs.ClangTidyProvider = Opts.ClangTidyProvider;
   }
 
+  void computeUnusedIncludes() {
+    auto UnusedIncludes =  clang::clangd::computeUnusedIncludes(*AST);
+    log("Computing unused includes");
+    for (const auto *Unused : UnusedIncludes) {
+      log("  - {0} @Line:{1}", Unused->Written,
+          Unused->HashLine + 1 /*1-based*/);
+    }
+  }
+
   // Build Inlay Hints for the entire AST or the specified range
   void buildInlayHints(llvm::Optional<Range> LineRange) {
     log("Building inlay hints");
@@ -464,6 +474,7 @@
     return false;
   C.buildInlayHints(LineRange);
   C.buildSemanticHighlighting(LineRange);
+  C.computeUnusedIncludes();
   if (CheckLocations)
     C.testLocationFeatures(LineRange);
 


Index: clang-tools-extra/clangd/tool/Check.cpp
===================================================================
--- clang-tools-extra/clangd/tool/Check.cpp
+++ clang-tools-extra/clangd/tool/Check.cpp
@@ -33,6 +33,7 @@
 #include "Feature.h"
 #include "GlobalCompilationDatabase.h"
 #include "Hover.h"
+#include "IncludeCleaner.h"
 #include "InlayHints.h"
 #include "ParsedAST.h"
 #include "Preamble.h"
@@ -332,6 +333,15 @@
     Inputs.ClangTidyProvider = Opts.ClangTidyProvider;
   }
 
+  void computeUnusedIncludes() {
+    auto UnusedIncludes =  clang::clangd::computeUnusedIncludes(*AST);
+    log("Computing unused includes");
+    for (const auto *Unused : UnusedIncludes) {
+      log("  - {0} @Line:{1}", Unused->Written,
+          Unused->HashLine + 1 /*1-based*/);
+    }
+  }
+
   // Build Inlay Hints for the entire AST or the specified range
   void buildInlayHints(llvm::Optional<Range> LineRange) {
     log("Building inlay hints");
@@ -464,6 +474,7 @@
     return false;
   C.buildInlayHints(LineRange);
   C.buildSemanticHighlighting(LineRange);
+  C.computeUnusedIncludes();
   if (CheckLocations)
     C.testLocationFeatures(LineRange);
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D140000: [clangd] ... Haojian Wu via Phabricator via cfe-commits

Reply via email to