[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 29 12:59:11 PST 2023


efriedma-quic wrote:

Some examples to consider:

```
// Crazy array indexing... but strictly speaking, legal.
struct S { int count; int arr[] __attribute((counted_by(count))); };
int f1(int c, struct S *var) {
  return var[10].arr[10];
}
// Double dereferenced variable.
int f2(int c, struct S **var) {
  return (**var).arr[10];
}
// Increment (which is a UnaryOperator...)
int f3(int c, struct S*s) {
  return s++->arr[c];
}
// Outer struct
struct SS { int a; struct S s; };
int f4(int c, struct SS *s) {
  return s->s.arr[c];
}
```

https://github.com/llvm/llvm-project/pull/73730


More information about the cfe-commits mailing list