Skip to content

Commit

Permalink
[clangd] Track performance of IncludeCleaner
Browse files Browse the repository at this point in the history
Reviewed By: kadircet

Differential Revision: https://reviews.llvm.org/D112783
  • Loading branch information
kirillbobyrev committed Oct 29, 2021
1 parent 154c036 commit 32f1029
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions clang-tools-extra/clangd/IncludeCleaner.cpp
Expand Up @@ -197,6 +197,7 @@ bool mayConsiderUnused(const Inclusion *Inc) {
} // namespace

ReferencedLocations findReferencedLocations(ParsedAST &AST) {
trace::Span Tracer("IncludeCleaner::findReferencedLocations");
ReferencedLocations Result;
ReferencedLocationCrawler Crawler(Result);
Crawler.TraverseAST(AST.getASTContext());
Expand Down Expand Up @@ -225,6 +226,7 @@ findReferencedFiles(const llvm::DenseSet<SourceLocation> &Locs,
std::vector<const Inclusion *>
getUnused(const IncludeStructure &Includes,
const llvm::DenseSet<IncludeStructure::HeaderID> &ReferencedFiles) {
trace::Span Tracer("IncludeCleaner::getUnused");
std::vector<const Inclusion *> Unused;
for (const Inclusion &MFI : Includes.MainFileIncludes) {
// FIXME: Skip includes that are not self-contained.
Expand Down Expand Up @@ -253,6 +255,7 @@ llvm::DenseSet<IncludeStructure::HeaderID>
translateToHeaderIDs(const llvm::DenseSet<FileID> &Files,
const IncludeStructure &Includes,
const SourceManager &SM) {
trace::Span Tracer("IncludeCleaner::translateToHeaderIDs");
llvm::DenseSet<IncludeStructure::HeaderID> TranslatedHeaderIDs;
TranslatedHeaderIDs.reserve(Files.size());
for (FileID FID : Files) {
Expand All @@ -279,6 +282,7 @@ std::vector<const Inclusion *> computeUnusedIncludes(ParsedAST &AST) {

std::vector<Diag> issueUnusedIncludesDiagnostics(ParsedAST &AST,
llvm::StringRef Code) {
trace::Span Tracer("IncludeCleaner::issueUnusedIncludesDiagnostics");
const Config &Cfg = Config::current();
if (Cfg.Diagnostics.UnusedIncludes != Config::UnusedIncludesPolicy::Strict ||
Cfg.Diagnostics.SuppressAll ||
Expand Down

0 comments on commit 32f1029

Please sign in to comment.