Page MenuHomePhabricator

[Parse] Forward brace locations to TypeConstructExpr

Authored by vsk on Jan 10 2018, 3:22 PM.



When parsing C++ type construction expressions with list initialization,
forward the locations of the braces to Sema.

Without these locations, the code coverage pass crashes on the given test
case, because the pass relies on getLocEnd() returning a valid location.

Here is what this patch does in more detail:

  • Forwards init-list brace locations to Sema (ParseExprCXX),
  • Builds an InitializationKind with these locations (SemaExprCXX), and
  • Uses these locations for constructor initialization (SemaInit).

The remaining changes fall out of introducing a new overload for
creating direct-list InitializationKinds.

Testing: check-clang, and a stage2 coverage-enabled build of clang with
asserts enabled.

Diff Detail

rC Clang

Event Timeline

vsk created this revision.Jan 10 2018, 3:22 PM

On the whole, this approach looks reasonable to me. Just a few minor nits for clarity.


I think this could be changed to reduce the number of returns:

SourceLocation Open, Close; // Or use a range and get rid of the funky std::tie() calls
// FIXME: <blah>
if (!ListInitialization)
  std::tie(Open, Close) = std::tie(LParenOrBraceLoc, RParenOrBraceLoc);
return  CXXUnresolvedConstructExpr::Create(Context, TInfo, Open, Exprs, Close);

Can use the same trick here.

vsk updated this revision to Diff 130021.Jan 16 2018, 1:34 PM
vsk marked 2 inline comments as done.
This revision is now accepted and ready to land.Jan 17 2018, 6:59 AM
This revision was automatically updated to reflect the committed changes.
orivej added a subscriber: orivej.Oct 12 2018, 4:11 PM
orivej added inline comments.