This is an archive of the discontinued LLVM Phabricator instance.

CodeGen: Properly null-check typeid expressions
ClosedPublic

Authored by majnemer on Jul 18 2014, 1:13 PM.

Details

Summary

Thoroughly check for a pointer dereference which yields a glvalue. Look
through casts, comma operators, conditional operators, paren
expressions, etc.

This was originally D4416.

Diff Detail

Repository
rL LLVM

Event Timeline

majnemer updated this revision to Diff 11669.Jul 18 2014, 1:13 PM
majnemer retitled this revision from to CodeGen: Properly null-check typeid expressions.
majnemer updated this object.
majnemer added a reviewer: rsmith.
majnemer added a subscriber: Unknown Object (MLST).
rsmith added inline comments.Jul 18 2014, 1:25 PM
lib/CodeGen/CGExprCXX.cpp
1632 ↗(On Diff #11669)

Do you need to walk through OpaqueValueExprs to support this for binary conditional operators? Does this work:

struct T { operator bool(); } *p, t, &q = t;
typeid(*p ?: q);
majnemer updated this revision to Diff 11671.Jul 18 2014, 1:33 PM
  • Handle OpaqueValueExprs in typeid correctly
rsmith accepted this revision.Jul 18 2014, 1:52 PM
rsmith edited edge metadata.

LGTM

test/CodeGenCXX/typeid-should-throw.cpp
62–64 ↗(On Diff #11671)

You could make t and r parameters to match the style of other tests.

This revision is now accepted and ready to land.Jul 18 2014, 1:52 PM
majnemer closed this revision.Jul 18 2014, 5:25 PM
majnemer updated this revision to Diff 11678.

Closed by commit rL213434 (authored by @majnemer).