Issue |
151602
|
Summary |
[Clang] Local class is not nested to a member function in DWARF after optimization
|
Labels |
clang
|
Assignees |
|
Reporter |
zhihaoy
|
test_dwarf.h
```cpp
#include <stdio.h>
namespace myns
{
struct myclass
{
int b;
myclass() : b(100)
{
class ctornested
{
public:
void foobar()
{
printf("assert %s\n", a);
}
char *a;
} wat;
wat.foobar();
putc(b, stderr);
}
};
} // namespace myns
__attribute__((__visibility__("default"))) extern void fglobal();
```
test_dwarf.cpp
```cpp
#include "test_dwarf.h"
void fglobal()
{
myns::myclass{};
}
```
clang --version
```
clang version 19.1.7 (RESF 19.1.7-2.module+el8.10.0+1965+112b558b)
Target: aarch64-redhat-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Configuration file: /etc/clang/aarch64-redhat-linux-gnu-clang.cfg
```
Compile the program with `clang++ -g -O3 -std=c++17 -shared -fPIC -fvisibility=hidden -o libtest_dwarf.so *.cpp`
llvm-dwarfdump libtest_dwarf.so [rel.txt](https://github.com/user-attachments/files/21538092/rel.txt)
Class `ctornested` is now nested in a "subprogram" with no other info, where the `myns` namespace owns nothing about it, nor `myclass`. The local class doesn't have to be in a constructor; it happens to non-special member functions as well.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs