Boaz Brickner
|
156ab889f8
|
Support mangling imported C++ functions using Clang's MangleContext (#5062)
Keep a pointer to the Clang declaration in Carbon's function declaration
and use it in Carbon mangling by calling Clang mangling.
Create Clang's `MangleContext` once on demand.
Part of #4666.
C++ Interop Demo:
```c++
// hello_world.h
void hello_world();
```
```c++
// hello_world.cpp
#include <cstdio>
void hello_world() { printf("Hello World!\n"); }
```
```
// main.carbon
library "Main";
import Cpp library "hello_world.h";
fn Run() -> i32 {
Cpp.hello_world();
return 0;
}
```
```shell
$ clang -c hello_world.cpp
$ bazel-bin/toolchain/carbon compile main.carbon
$ bazel-bin/toolchain/carbon link hello_world.o main.o --output=demo
$ ./demo
Hello World!
```
|
2025-03-06 09:51:01 +00:00 |
|