Issue |
122702
|
Summary |
Passing Constructor Expressions to conditional operator causes data loss while using clang compiler.
|
Labels |
clang
|
Assignees |
|
Reporter |
bhavayc
|
I use the clang compiler present at my company's common hub to create an AST dump of generated C/C++ code. It works fine for most of my use cases. However, recently, I discovered an edge case where the Clang compiler was not dumping all the information for constructor expressions used with a conditional operator. The code is compiling though. Refer to the below code _expression_, where a constructor _expression_ MyClass(2, "World") is passed to the false condition of the conditional operator in C++. In the below _expression_ the information about the constructor passed to the if true condition MyClass(1) is stored properly **BUT** **in the Linux platform**, the constructor data for the if false condition gets lost. I want to see if we are missing something in Linux or should add additional flags for linux. Everything works fine in Windows.
Code _expression_ in question
**MyClass cObj = ((foo > threshold) ? MyClass(1) : _MyClass(2, "World"))_;**
This is my source cpp file:
[doit.cpp.txt](https://github.com/user-attachments/files/18396637/doit.cpp.txt)
The command used to invoke the clang compiler:
<myClangDir> -fsyntax-only -fno-color-diagnostics -Xclang -ast-dump=json -x c++ -fopenmp "<source>.cpp" -v > ",<myFile>.json"
The Lines highlighted in the below image refer to the data that is being lost on linux for the constructor expressions
![Image](https://github.com/user-attachments/assets/05f40f1d-40b0-4380-ad08-6a7d5aa14ce6)
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs