This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Omit parameter hint if parameter name comment is present
ClosedPublic

Authored by nridge on Apr 18 2021, 12:19 AM.

Diff Detail

Event Timeline

nridge created this revision.Apr 18 2021, 12:19 AM
nridge requested review of this revision.Apr 18 2021, 12:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 18 2021, 12:19 AM
sammccall accepted this revision.Apr 23 2021, 2:03 PM

Just a few optional ideas, this is fine as-is

clang-tools-extra/clangd/InlayHints.cpp
108

nit: one of these trim()s can be an rtrim

122

In order to use sourcePrefix it we're doing the buffer lookup stuff for every param.

Would be a little more direct to grab the mainfile buffer + fileid at the start, and then here just decompose the top macrocallerloc straight away.

Seems a little simpler to reason about, no idea if the performance matters much, up to you.

131

I think we should handle the case where we never find /*. *maybe* it can't happen, but I wouldn't want to bet too much on it.

Alternatively, rewinding back to the start of the (possibly long) comment just to check if it matches a fixed string seems a little roundabout.

Could be:

if (!SourcePrefix.consume_back("*/")) return false;
SourcePrefix = SourcePrefix.rtrim().rtrim('=').rtrim();
if (!SourcePrefix.consume_back(ParamName)) return false;
return SourcePrefix.rtrim().endswith("/*");
This revision is now accepted and ready to land.Apr 23 2021, 2:03 PM
nridge updated this revision to Diff 340391.Apr 25 2021, 3:59 PM
nridge marked 3 inline comments as done.

Address review comments

This revision was landed with ongoing or failed builds.Apr 25 2021, 4:20 PM
This revision was automatically updated to reflect the committed changes.