This is an archive of the discontinued LLVM Phabricator instance.

[Sema] Remove dead code in BuildAnonymousStructUnionMemberReference. NFCI
ClosedPublic

Authored by EricWF on Apr 7 2018, 8:37 PM.

Details

Summary

This patch cleans up a bunch of dead or unused code in BuildAnonymousStructUnionMemberReference.

The dead code was a branch that built a new CXXThisExpr when we weren't given a base object expression or base variable.
However, BuildAnonymousFoo has only two callers. One of which always builds a base object expression first, the second only calls when the IndirectFieldDecl is not a C++ class member. Even within C this branch seems entirely unused.

I tried diligently to write a test which hit it with no success.

This patch removes the branch and replaces it with an assertion that we were given either a base object expression or a base variable.

Diff Detail

Repository
rL LLVM

Event Timeline

EricWF created this revision.Apr 7 2018, 8:37 PM
rjmccall accepted this revision.Apr 7 2018, 9:21 PM

I think there was a point when we weren't always creating CXXThisExprs eagerly for these accesses. Now that we are, yeah, this should be dead.

This revision is now accepted and ready to land.Apr 7 2018, 9:21 PM
This revision was automatically updated to reflect the committed changes.