This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Names that are not spelled in source code are reserved.
ClosedPublic

Authored by ioeric on Oct 17 2018, 7:38 AM.

Details

Summary

These are often not expected to be used directly e.g.

TEST_F(Fixture, X) {
  ^  // "Fixture_X_Test" expanded in the macro should be down ranked.
}

Only doing this for sema for now, as such symbols are mostly coming from sema
e.g. gtest macros expanded in the main file. We could also add a similar field
for the index symbol.

Event Timeline

ioeric created this revision.Oct 17 2018, 7:38 AM

Idea looks good, I think it needs some renames and index support.

clangd/AST.h
33

nit: should start with lowercase: isSpelledInSourceCode?

clangd/Quality.cpp
182

This doesn't match the current definition of ReservedName.
I'd suggest either:

  • adding a new boolean (ImplementationDetail? maybe we'll add other heuristics) and treating this as independent of reserved-ness
  • renaming the current ReservedName flag to cover this expanded scope (again, ImplementationDetail is a reasonable name)
192

The new ReservedName cases don't survive a round-trip through the index (unlike the existing ones, which get recomputed from the name).

I think you want to add a new flag bit to Symbol, set it in SymbolCollector, and read it here. (IIRC new flags in the Flags field are handled transparently by yaml and binary serialization).

ioeric updated this revision to Diff 170046.Oct 18 2018, 12:49 AM
ioeric marked 3 inline comments as done.
  • address comments
ioeric added inline comments.Oct 18 2018, 12:49 AM
clangd/Quality.cpp
182

ImplementationDetail sounds great.

192

Yeah, I wasn't sure what the name to use here and wanted to get a a second opinion on adding the new flag. Thanks for the name!

sammccall accepted this revision.Oct 18 2018, 3:34 AM
sammccall added inline comments.
clangd/Quality.cpp
181

We could consider putting this in a one-liner function in AST.h or so, in case we want to add more heuristics - so SymbolCollector and Quality remain consistent. Up to you.

This revision is now accepted and ready to land.Oct 18 2018, 3:34 AM
ioeric updated this revision to Diff 170068.Oct 18 2018, 5:22 AM
ioeric marked an inline comment as done.
  • add isImplementationDetail helper
This revision was automatically updated to reflect the committed changes.