[PATCH] D81351: [clangd] Parse std::make_unique, and emit template diagnostics at expansion.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jun 7 15:27:19 PDT 2020


sammccall created this revision.
sammccall added a reviewer: hokein.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, MaskRay, ilya-biryukov.
Herald added a reviewer: aaron.ballman.
Herald added a project: clang.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81351

Files:
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/Diagnostics.h
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
  clang/include/clang/Frontend/PrecompiledPreamble.h
  clang/lib/Frontend/PrecompiledPreamble.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81351.269079.patch
Type: text/x-patch
Size: 15411 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200607/754d7831/attachment-0001.bin>


More information about the cfe-commits mailing list