commit | 180f8032f0f67faf2a73791ee37a87cb8560135c | [log] [tgz] |
---|---|---|
author | Michael Jabbour <117195239+michael-jabbour-sonarsource@users.noreply.github.com> | Fri Mar 07 11:02:19 2025 +0100 |
committer | GitHub <noreply@github.com> | Fri Mar 07 11:02:19 2025 +0100 |
tree | 94e0b94fdcd740ea7932cd13d99f2ed44404d647 | |
parent | 21610e3ecc8bc727f99047e544186b35b1291bcd [diff] |
[clang] Fix ASTWriter crash after merging named enums (#114240) Clang already removes parsed enumerators when merging typedefs to anonymous enums. This is why the following example decl used to be handled correctly while merging, and ASTWriter behaves as expected: ```c typedef enum { Val } AnonEnum; ``` However, the mentioned mechanism didn't handle named enums. This leads to stale declarations in `IdResolver`, causing an assertion violation in ASTWriter ``Assertion `DeclIDs.contains(D) && "Declaration not emitted!"' failed`` when a module is being serialized with the following example merged enums: ```c typedef enum Enum1 { Val_A } Enum1; enum Enum2 { Val_B }; ``` The PR applies the same mechanism in the named enums case. Additionally, I dropped the call to `getLexicalDeclContext()->removeDecl` as it was causing a wrong odr-violation diagnostic with anonymous enums. Might be easier to to review commit by commit. Any feedback is appreciated. ### Context This fixes frontend crashes that were encountered when certain Objective-C modules are included on Xcode 16. For example, by running `CC=/path/to/clang-19 xcodebuild clean build` on a project that contains the following Objective-C file: ```c #include <os/atomic.h> int main() { return memory_order_relaxed; } ``` This crashes the parser in release, when ASTReader tries to load the enumerator declaration.
Welcome to the LLVM project!
This repository contains the source code for LLVM, a toolkit for the construction of highly optimized compilers, optimizers, and run-time environments.
The LLVM project has multiple components. The core of the project is itself called “LLVM”. This contains all of the tools, libraries, and header files needed to process intermediate representations and convert them into object files. Tools include an assembler, disassembler, bitcode analyzer, and bitcode optimizer.
C-like languages use the Clang frontend. This component compiles C, C++, Objective-C, and Objective-C++ code into LLVM bitcode -- and from there into object files, using LLVM.
Other components include: the libc++ C++ standard library, the LLD linker, and more.
Consult the Getting Started with LLVM page for information on building and running LLVM.
For information on how to contribute to the LLVM project, please take a look at the Contributing to LLVM guide.
Join the LLVM Discourse forums, Discord chat, LLVM Office Hours or Regular sync-ups.
The LLVM project has adopted a code of conduct for participants to all modes of communication within the project.