# GSoC 2025: ClangIR upstreaming

DevFeed: [GSoC 2025: ClangIR upstreaming](<https://devfeed.tech/articles/gsoc-2025-clangir-upstreaming-43126.md>)

Original publisher: [Read original article](<https://blog.llvm.org/posts/2025-gsoc-clangir-upstreaming/>)

Author: Amr Hesham (amrdeveloper)

Published: 2025-12-01T00:00:00Z

Content type: article

Language: en

Sources: [LLVM Project](<https://devfeed.tech/sources/the-llvm-project-blog.md>)

Topics: [LLVM](<https://devfeed.tech/topics/llvm.md>), [mlir](<https://devfeed.tech/topics/mlir.md>), [c/c++](<https://devfeed.tech/topics/c-c-plus-plus.md>), [C++](<https://devfeed.tech/topics/c-plus-plus.md>), [Exception handling](<https://devfeed.tech/topics/exception-handling.md>)

Tags: [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [clang](<https://devfeed.tech/tags/clang.md>), [clangir](<https://devfeed.tech/tags/clangir.md>), [code](<https://devfeed.tech/tags/code.md>), [exception-handling](<https://devfeed.tech/tags/exception-handling.md>), [gsoc](<https://devfeed.tech/tags/gsoc.md>), [llvm](<https://devfeed.tech/tags/llvm.md>), [mlir](<https://devfeed.tech/tags/mlir.md>)

## AI overview

A Google Summer of Code 2025 project report describes upstreaming ClangIR, a high-level C/C++ representation implemented with MLIR between Clang's AST and LLVM IR. The work covered design improvements, built-in vector operations, complex-number operations, and C++ exception handling.

## Source excerpt

Hello everyone 👋! My name is Amr Hesham, and for Google Summer of Code 2025, I've been working on the ClangIR Upstreaming project. My mentors were Bruno Cardoso Lopes, Andy Kaylor and Erich Keane. Background ClangIR is a high-level representation in Clang that reflects aspects of the C/C++ languages and their extensions. It is implemented using MLIR and occupies a position between Clang's AST and LLVM IR. Starting from April 2024, the upstreaming process started to migrate the code from the incubator to the main LLVM repository. The ClangIR upstreaming process includes the following steps: Improve the design of ClangIR dialect operations, attributes, syntax and implementation details if needed. Align with LLVM coding standards and quality expectations. Implement missing features in the incubator and upstream it. Backport the new design/implementation from the LLVM repository to the incubator. Implement folders for ClangIR dialect operations. The goal of this project was to implement the following C/C++ features in the ClangIR project. Built-in VectorType (vector_size and ext_vector_type attributes) with operators and built-ins functions. ComplexType with operators and all -complex-range flag values to allow selecting different arithmatic calculation algorithms, for example, the SMITH, R. L. Algorithm 116: Complex division. Commun. ACM 5, 8 (1962). C++ Exception handling. What we did Over the coding period, I did the following. Builtin VectorType I have implemented support for all C/C++ operators for built-in VectorType that includes arithmetic, comparison, shifts and logical operators, also supporting using VectorType in many expressions, for example, index and ternary expression, and now we can compile C++ code successfully. Also, implemented folders for ClangIR VectorType operations to fold specific patterns. For example, in cir::VecExtractOp, if both the vector and the index are constant, we can fold that operation and replace it with the actual result. // Before