HomePhabricator

Switch from using a DiagnosticTrap and a note for "while defining a special…

Authored by Richard Smith <richard-llvm@metafoo.co.uk> on May 25 2017, 3:47 PM.

Description

Switch from using a DiagnosticTrap and a note for "while defining a special member function" context notes to registering an entry on the context stack.

Also reorder the steps within defining special members to be consistent.

This has a few benefits: if multiple diagnostics are produced while checking
such a member, the note is now attached to the first such diagnostic rather
than the last, this prepares us for persisting these diagnostics between the
point at which we require the implicit instantiation of a template and the
point at which that instantiation is actually performed, and this fixes some
cases where we would fail to produce a full note stack leading back to user
code in the case of such a diagnostic.

The reordering exposed a case where we could recursively attempt to define a
defaulted destructor while we're already defining one (and other such cases
also appear to be possible, with or without this change), so this change also
reuses the "willHaveBody" flag on function declarations to track that we're in
the middle of synthesizing a body for the function and bails out if we try to
define a function that we're already defining.

llvm-svn: 303930

Event Timeline

Richard Smith <richard-llvm@metafoo.co.uk> committed rG883dbc43d9b3: Switch from using a DiagnosticTrap and a note for "while defining a special… (authored by Richard Smith <richard-llvm@metafoo.co.uk>).May 25 2017, 3:47 PM