[PATCH] D91828: [Sema/Attribute] Ignore noderef attribute in unevaluated context

Jann Horn via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 20 15:24:07 PST 2020


thejh added inline comments.


================
Comment at: clang/test/Frontend/noderef.c:71
+  x = sizeof(s->a + (s->b)); // ok
+
   // Nested struct access
----------------
aaron.ballman wrote:
> 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
> ```
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.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91828/new/

https://reviews.llvm.org/D91828



More information about the cfe-commits mailing list