This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Add metrics for selection tree and recovery expressions.
ClosedPublic

Authored by hokein on May 11 2020, 2:10 AM.

Diff Detail

Event Timeline

hokein created this revision.May 11 2020, 2:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 11 2020, 2:10 AM
sammccall added inline comments.May 11 2020, 3:16 AM
clang-tools-extra/clangd/Selection.cpp
39

this deserves a comment about what we're tracking and why.
Like "measure the fraction of selections that were enabled by recovery AST"

40

just realized a slightly more elegant(?) way to measure this:

Metric SelectionUsedRecovery("selection_recovery", Distribution);
...
for (...) {
  if (...) {
    SelectionUsedRecovery.record(1); // used
    return;
  }
}
SelectionUsedRecovery.record(0); // not used

Now the count is the total number of selections, and the average is the fraction that used recovery.

48

FWIW, my original RecoveryExpr proposal included a StmtClass for the type of expr that was "supposed" to be here. (e.g. CallExpr for a failed overload resolution). It was dropped to keep the scope minimal.

I'm not sure if that exact idea generalizes to all the places that RecoveryExpr is used, but it would be great to somehow keep track of the semantic context where recovery was used. And I think it would make a great label here. Maybe this would be better as a dedicated enum, or just a string literal (e.g. "variable initializer").

Anyway, an idea for another time...

48

not clear quite what you mean by this - the *actual* type isn't a suitable label, as it's a large unbounded set.
The presence/absense might be interesting I guess, but I'm not sure about it: it's unclear what significance it has if the containing expression's type is know, if we're selecting something inside it. (More significant if the selected expression's type is known/unknown because a contained RecoveryExpr's type is known/unknown, but we can't track that)

I'm not sure this is a FIXME, it seems most likely we decide not to fix it.

hokein updated this revision to Diff 263382.May 12 2020, 2:09 AM
hokein marked 2 inline comments as done.

address comments, and remove the fixme.

sammccall accepted this revision.May 12 2020, 2:50 AM
sammccall added inline comments.
clang-tools-extra/clangd/unittests/SelectionTests.cpp
454

delete commented code

This revision is now accepted and ready to land.May 12 2020, 2:50 AM
This revision was automatically updated to reflect the committed changes.