[PATCH] D48724: [clangd] Log sema completion context kind and query scopes. NFC
Eric Liu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 28 07:55:57 PDT 2018
ioeric created this revision.
ioeric added a reviewer: sammccall.
Herald added subscribers: cfe-commits, jkorous, MaskRay, ilya-biryukov.
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D48724
Files:
clangd/CodeComplete.cpp
Index: clangd/CodeComplete.cpp
===================================================================
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -40,6 +40,7 @@
#include "clang/Sema/Sema.h"
#include "clang/Tooling/Core/Replacement.h"
#include "llvm/Support/Format.h"
+#include "llvm/Support/FormatVariadic.h"
#include <queue>
// We log detailed candidate here if you run with -debug-only=codecomplete.
@@ -939,6 +940,7 @@
int NSema = 0, NIndex = 0, NBoth = 0; // Counters for logging.
bool Incomplete = false; // Would more be available with a higher limit?
llvm::Optional<FuzzyMatcher> Filter; // Initialized once Sema runs.
+ std::vector<std::string> QueryScopes; // Initialized once Sema runs.
std::unique_ptr<IncludeInserter> Includes; // Initialized once compiler runs.
FileProximityMatcher FileProximityMatch;
@@ -968,6 +970,10 @@
Includes.reset(); // Make sure this doesn't out-live Clang.
SPAN_ATTACH(Tracer, "sema_completion_kind",
getCompletionKindString(Recorder->CCContext.getKind()));
+ log(llvm::formatv(
+ "Code complete: sema context {0}, query scopes [{1}]",
+ getCompletionKindString(Recorder->CCContext.getKind()),
+ llvm::join(QueryScopes.begin(), QueryScopes.end(), ",")));
});
Recorder = RecorderOwner.get();
@@ -995,6 +1001,8 @@
CompletionList runWithSema() {
Filter = FuzzyMatcher(
Recorder->CCSema->getPreprocessor().getCodeCompletionFilter());
+ QueryScopes = getQueryScopes(Recorder->CCContext,
+ Recorder->CCSema->getSourceManager());
// Sema provides the needed context to query the index.
// FIXME: in addition to querying for extra/overlapping symbols, we should
// explicitly request symbols corresponding to Sema results.
@@ -1024,8 +1032,7 @@
Req.MaxCandidateCount = Opts.Limit;
Req.Query = Filter->pattern();
Req.RestrictForCodeCompletion = true;
- Req.Scopes = getQueryScopes(Recorder->CCContext,
- Recorder->CCSema->getSourceManager());
+ Req.Scopes = QueryScopes;
Req.ProximityPaths.push_back(FileName);
log(llvm::formatv("Code complete: fuzzyFind(\"{0}\", scopes=[{1}])",
Req.Query,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48724.153324.patch
Type: text/x-patch
Size: 2308 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180628/65bcaf2b/attachment.bin>
More information about the cfe-commits
mailing list