This is an archive of the discontinued LLVM Phabricator instance.

Sema: Properly perform lookup when acting on fields for desig inits
ClosedPublic

Authored by majnemer on Aug 9 2014, 8:13 PM.

Details

Summary

Clang used a custom implementation of lookup when handling designated
initializers. The custom code was not particularly optimized and relied
on standard lookup for typo-correction anyway.

This custom code has to go, it doesn't properly support MSVC-style
anonymous structs embedded inside other records; replace it with the
typo-correction path.

This has the side effect of speeding up semantic handling of the fields
for a designated initializer while simplifying the code at the same
time.

This fixes PR20573.

Diff Detail

Repository
rL LLVM

Event Timeline

majnemer updated this revision to Diff 12329.Aug 9 2014, 8:13 PM
majnemer retitled this revision from to Sema: Properly perform lookup when acting on fields for desig inits.
majnemer updated this object.
majnemer added a reviewer: rsmith.
majnemer added a subscriber: Unknown Object (MLST).
rsmith added inline comments.Aug 9 2014, 10:16 PM
lib/Sema/SemaInit.cpp
1923–1931 ↗(On Diff #12329)

This looks to be unreachable now.

I think you should rearrange this a little: if lookup found something, but didn't find a field, then issue this diagnostic. Otherwise, fall through to here and do typo correction.

1933–1934 ↗(On Diff #12329)

This comment doesn't make sense any more.

majnemer updated this revision to Diff 12342.Aug 11 2014, 1:20 AM
  • Address review comments
rsmith accepted this revision.Aug 11 2014, 11:03 AM
rsmith edited edge metadata.

LGTM

lib/Sema/SemaInit.cpp
1924 ↗(On Diff #12342)

Assign directly to KnownField here and remove ReplacementField.

1929 ↗(On Diff #12342)

Maybe else?

This revision is now accepted and ready to land.Aug 11 2014, 11:03 AM
majnemer closed this revision.Aug 11 2014, 11:43 AM
majnemer updated this revision to Diff 12360.

Closed by commit rL215372 (authored by @majnemer).