[all-commits] [llvm/llvm-project] 658af9: [clangd] Parse std::make_unique, and emit template...

Sam McCall via All-commits all-commits at lists.llvm.org
Tue Jun 9 03:47:47 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 658af9435071d5da017c1d65298bdea19ec095e1
      https://github.com/llvm/llvm-project/commit/658af9435071d5da017c1d65298bdea19ec095e1
  Author: Sam McCall <sam.mccall at gmail.com>
  Date:   2020-06-09 (Tue, 09 Jun 2020)

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

  Log Message:
  -----------
  [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




More information about the All-commits mailing list