This is an archive of the discontinued LLVM Phabricator instance.

[Sema/Attribute] Ignore noderef attribute in unevaluated context
ClosedPublic

Authored by thejh on Nov 19 2020, 3:53 PM.

Details

Summary

The noderef attribute is for catching code that accesses pointers in
a different address space. Unevaluated code is always safe in that regard.

Diff Detail

Event Timeline

thejh created this revision.Nov 19 2020, 3:53 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 19 2020, 3:53 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
thejh requested review of this revision.Nov 19 2020, 3:53 PM
thejh updated this revision to Diff 306555.Nov 19 2020, 4:44 PM

re-uploading to trigger a new build, since the build error looks unrelated.
maybe current trunk is flaky?

leonardchan accepted this revision.Nov 19 2020, 5:12 PM

LGTM but you should probably also wait for @aaron.ballman or @rsmith to also chime in.

This revision is now accepted and ready to land.Nov 19 2020, 5:12 PM
aaron.ballman added inline comments.Nov 20 2020, 9:14 AM
clang/test/Frontend/noderef.c
71

Can you add tests for the weird situations where the expression actually is evaluated? e.g.,

struct S {
  virtual ~S(); // Make S polymorphic
};

S NODEREF *s;
typeid(*s); // Actually evaluates *s at runtime

struct T {
  unsigned i;
};

T t1;
T NODEREF *t2 = &t1;

sizeof(int[++t2->i]); // Actually evaluates t2->i at runtime
thejh updated this revision to Diff 306792.Nov 20 2020, 3:23 PM
thejh marked an inline comment as done.

As requested by @aaron.ballman, added tests for edgecases where
sizeof()/typeid() can cause memory access.

thejh added inline comments.Nov 20 2020, 3:24 PM
clang/test/Frontend/noderef.c
71

Oh jeez, good point. I'm extremely happy that other people have done the hard work of building the ExpressionEvaluationContext logic... I've added tests for the cases you described.

thejh added a comment.Nov 23 2020, 5:06 AM

@aaron.ballman Can you land it for me? I don't have commit access.

@aaron.ballman Can you land it for me? I don't have commit access.

Happy to do so -- are you okay with "Jann Horn <jannh@google.com>" for author attribution?

thejh added a comment.Nov 23 2020, 5:08 AM

@aaron.ballman Can you land it for me? I don't have commit access.

Happy to do so -- are you okay with "Jann Horn <jannh@google.com>" for author attribution?

Yes, thanks.

@aaron.ballman Can you land it for me? I don't have commit access.

Happy to do so -- are you okay with "Jann Horn <jannh@google.com>" for author attribution?

Yes, thanks.

Thank you for the patch! I've committed the changes for you in 00dad9d028ce31739b992a3ce2df5de054a9fa3c

aaron.ballman closed this revision.Nov 23 2020, 5:11 AM