This is an archive of the discontinued LLVM Phabricator instance.

[Sema] Provide constructor signature help for smart pointer factories
DraftPublic

Authored by tom-anders on Apr 9 2023, 5:42 AM.
This is a draft revision that has not yet been submitted for review.

Details

Reviewers
None

Diff Detail

Event Timeline

tom-anders created this revision.Apr 9 2023, 5:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 9 2023, 5:42 AM
nridge added a subscriber: nridge.Apr 25 2023, 9:27 PM

Adding a link to the issue that this pertains to: https://github.com/clangd/clangd/issues/447

This direction looks promising to me.

There is precedent for having a config option whose value is a list of qualified names (https://clangd.llvm.org/config.html#fullyqualifiednamespaces), we could have a similar setting for the user to specify custom smart pointer factory names like QSharedPointer::create.

clang/lib/Sema/SemaCodeComplete.cpp
6122

If we generalize this to user-specified factory functions, getAsType() will need a null check here (in case the user mistakenly specified a function with a non-type template argument), and likewise below.

(Maybe it doesn't hurt to have a null check even now, in case it can produce a null type in the presence of invalid code or something?)