This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Remove the direct use of StdSymbolMapping.inc usage.
ClosedPublic

Authored by hokein on Feb 3 2023, 8:15 AM.

Details

Summary

Replace them with the library APIs.

Diff Detail

Event Timeline

hokein created this revision.Feb 3 2023, 8:15 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 3 2023, 8:15 AM
hokein requested review of this revision.Feb 3 2023, 8:15 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 3 2023, 8:15 AM
kadircet added inline comments.Feb 6 2023, 1:21 AM
clang-tools-extra/clangd/index/CanonicalIncludes.cpp
753–754

what about getting rid of StdSymbolMapping completely and changing CanonicalIncludes::mapSymbol to use tooling::stdlib ?
only call site is through SymbolCollector, which has access to LangOptions.

hokein updated this revision to Diff 495036.Feb 6 2023, 1:59 AM
hokein marked an inline comment as done.

address review comment: remove StdSymbolMapping in the CanonicalIncluedes.

clang-tools-extra/clangd/index/CanonicalIncludes.cpp
753–754

Yeah, good idea. This simplifies the code further, thanks!

kadircet added inline comments.Feb 6 2023, 2:35 AM
clang-tools-extra/clangd/index/CanonicalIncludes.cpp
711

i think the comment is misleading. as if we had some alternatives in the tooling::stdlib, it would already pick one for us. the issue is we don't have it in the mapping at all.

717

this is a slight behaviour change. we'd actually return "" whenever the language isn't CPlusPlus or C11. could you retain that behaviour?

clang-tools-extra/clangd/index/SymbolCollector.cpp
837–838

nit: rather than creating a new copy of the symbol name everytime, i'd also update the mapSymbol interface to take in StringRef Scope, StringRef Name instead.

hokein updated this revision to Diff 495065.Feb 6 2023, 3:14 AM
hokein marked 2 inline comments as done.

address review comments

thanks a lot. since this is the last (and only) upstream user of the raw mappings. can you also move them into clang/lib/Tooling/Inclusions/Stdlib/ as part of this patch?

clang-tools-extra/clangd/index/CanonicalIncludes.h
43

these parameter comments are a little bit unconventional, maybe just mention that Scope should have trailing colons (e.g. std::) and name shouldn't have any (e.g. vector) ? also mention that it should be empty ("") for global namespace?

kadircet accepted this revision.Feb 6 2023, 5:01 AM
This revision is now accepted and ready to land.Feb 6 2023, 5:01 AM
hokein marked an inline comment as done.Feb 6 2023, 5:18 AM

thanks a lot. since this is the last (and only) upstream user of the raw mappings. can you also move them into clang/lib/Tooling/Inclusions/Stdlib/ as part of this patch?

As discussed, I will address this in a followup patch.

clang-tools-extra/clangd/index/CanonicalIncludes.cpp
711

yeah, this comment was moved from the old version. I removed it as it is covered by the above FIXME.

clang-tools-extra/clangd/index/CanonicalIncludes.h
43

Removed the parameter comments, and refined the doc comment of the function.

hokein updated this revision to Diff 495096.Feb 6 2023, 5:19 AM
hokein marked an inline comment as done.

refined the comment.

kadircet added inline comments.Feb 6 2023, 5:24 AM
clang-tools-extra/clangd/index/CanonicalIncludes.h
43

s/full/fully

45

s/for global namespace symbol/for global namespace/

This revision was automatically updated to reflect the committed changes.
hokein marked 2 inline comments as done.