[clangd] Parse std::make_unique, and emit template diagnostics at expansion.
Summary: Parsing std::make_unique is an exception to the usual non-parsing of function bodies in the preamble. (A hook is added to PreambleCallbacks to allow this). This allows us to diagnose make_unique<Foo>(wrong arg list), and opens the door to providing signature help (by detecting where the arg list is forwarded to). This function is trivial (checked libc++ and libstdc++) and doesn't result in any extra templates being instantiated, so this should be cheap. This uncovered a second issue (already visible with class templates)... Errors produced by template instantiation have primary locations within the template, with instantiation stack reported as notes. For templates defined in headers, these end up reported at the #include directive, which isn't terribly helpful as the header itself is probably fine. This patch reports them at the instantiation site (the first location in the instantiation stack that's in the main file). This in turn required a bit of refactoring in Diagnostics so we can delay relocating the diagnostic until all notes are available. https://github.com/clangd/clangd/issues/412 Reviewers: hokein, aaron.ballman Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D81351
Loading
Please register or sign in to comment