[clang] [clang] Use a Worklist for some CodeGenFunctions (PR #115395)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 20 17:32:16 PST 2024


================
@@ -0,0 +1,37 @@
+// RUN: split-file %s %t
+// RUN: python %t/gen.py %t/switch-overflow.c %t/tmp.c && %clang_cc1 -emit-llvm %t/tmp.c -o - | FileCheck %t/tmp.c
+
+//--- gen.py
----------------
efriedma-quic wrote:

I guess 32000 is small enough that a test won't be that expensive, but a python script seems like overkill.  Maybe use a bit of C preprocessor trickery like the following:

```
#define CASES1(n) case n: case n+1: case n+2 case n+3:
#define CASES2(n) CASES1(n) CASES1(n+4) CASES1(n+8) CASES1(n+12)
#define CASES3(n) CASES2(n) CASES2(n+16) CASES2(n+32) CASES2(n+48)
void foo() {
  switch (1337) {
  CASES3(0)
    break;
  }
}
```

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


More information about the cfe-commits mailing list