[PATCH] D140000: [clangd] Compute the unused includes in the check mode.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 14 01:34:41 PST 2022
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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140000.482759.patch
Type: text/x-patch
Size: 1160 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221214/4297c3a1/attachment.bin>
More information about the cfe-commits
mailing list