Skip to content

Commit

Permalink
[clangd] Trace per-token time in clangd --check
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-mccall committed Nov 10, 2021
1 parent f7500a4 commit 63667c1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions clang-tools-extra/clangd/tool/Check.cpp
Expand Up @@ -37,6 +37,7 @@
#include "index/FileIndex.h"
#include "refactor/Tweak.h"
#include "support/ThreadsafeFS.h"
#include "support/Trace.h"
#include "clang/AST/ASTContext.h"
#include "clang/Basic/DiagnosticIDs.h"
#include "clang/Format/Format.h"
Expand Down Expand Up @@ -195,6 +196,7 @@ class Checker {
void testLocationFeatures(
llvm::function_ref<bool(const Position &)> ShouldCheckLine,
const bool EnableCodeCompletion) {
trace::Span Trace("testLocationFeatures");
log("Testing features at each token (may be slow in large files)");
auto &SM = AST->getSourceManager();
auto SpelledTokens = AST->getTokens().spelledTokens(SM.getMainFileID());
Expand All @@ -210,6 +212,10 @@ class Checker {
if (!ShouldCheckLine(Pos))
continue;

trace::Span Trace("Token");
SPAN_ATTACH(Trace, "pos", Pos);
SPAN_ATTACH(Trace, "text", Tok.text(AST->getSourceManager()));

// FIXME: dumping the tokens may leak sensitive code into bug reports.
// Add an option to turn this off, once we decide how options work.
vlog(" {0} {1}", Pos, Tok.text(AST->getSourceManager()));
Expand Down

0 comments on commit 63667c1

Please sign in to comment.