[clang] [clang-repl] Extend the C support. (PR #89804)

Stefan Gränitz via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 24 09:22:37 PDT 2024


================
@@ -0,0 +1,21 @@
+// REQUIRES: host-supports-jit
+// UNSUPPORTED: system-aix
+
+// RUN: cat %s | clang-repl -Xcc -xc -Xcc -Xclang -Xcc -verify | FileCheck %s
+// RUN: cat %s | clang-repl -Xcc -xc -Xcc -O2 -Xcc -Xclang -Xcc -verify| FileCheck %s
+int printf(const char *, ...);
+int i = 42; err // expected-error{{use of undeclared identifier}}
+int i = 42;
+struct S { float f; struct S *m;} s = {1.0, 0};
+// FIXME: Making foo inline fails to emit the function.
----------------
weliveindetail wrote:

Interesting. Not sure it's relevant, but the difference in IR is the missing `(...)` in front of the callee token:
<img width="963" alt="Screenshot 2024-04-24 at 17 58 49" src="https://github.com/llvm/llvm-project/assets/7307454/f3b564d4-c511-4667-9b02-7ef8bc379eea">

Does this mean something like "unknown actual parameters"?

It also happens with a `static` function, but here we emit the function body right away (and we know the actual args in IR):
<img width="1079" alt="Screenshot 2024-04-24 at 18 05 46" src="https://github.com/llvm/llvm-project/assets/7307454/45f34a45-c989-46dc-8169-ad00291643e5">

I guess this is not the whole story though. Printf looks like this:
```
define internal void @__stmts__0() #0 {
entry:
  %call = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef 2)
  ret void
}

declare i32 @printf(ptr noundef, ...) #1
```

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


More information about the cfe-commits mailing list