This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Include fixer for missing functions in C
ClosedPublic

Authored by sammccall on Dec 9 2021, 7:56 PM.

Details

Summary

A function call unresolved() in C will generate an implicit declaration
of the missing function and warn ext_implicit_function_decl or so.
(Compared to in C++ where we get err_undeclared_var_use).
We want to try to resolve these names.

Unfortunately typo correction is disabled in sema for performance
reasons unless this warning is promoted to error.
(We need typo correction for include-fixer.)
It's not clear to me where a switch to force this correction on should
go, include-fixer is kind of a hack. So hack more by telling sema we're
promoting them to error.

Fixes https://github.com/clangd/clangd/issues/937

Diff Detail

Event Timeline

sammccall created this revision.Dec 9 2021, 7:56 PM
sammccall requested review of this revision.Dec 9 2021, 7:56 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptDec 9 2021, 7:56 PM
nridge added a subscriber: nridge.Dec 9 2021, 10:59 PM
kadircet accepted this revision.Jan 10 2022, 1:43 AM
kadircet added inline comments.
clang/lib/Sema/SemaDecl.cpp
15012

maybe some comments around importance of the sequencing here? it would probably be nice to have that at a higher level documentation too, but unclear where. as in theory it's not just about the typo correction but also emitting diagnostics while doing so.

This revision is now accepted and ready to land.Jan 10 2022, 1:43 AM
sammccall marked an inline comment as done.Jan 10 2022, 3:17 AM
sammccall added inline comments.
clang/lib/Sema/SemaDecl.cpp
15012

Yeah, this is obviously pretty hacky, and I don't have great ideas to improve it.
Added a comment to leave some breadcrumbs and discourage moving this code around.

This revision was landed with ongoing or failed builds.Jan 10 2022, 3:17 AM
This revision was automatically updated to reflect the committed changes.
sammccall marked an inline comment as done.