AmrDeveloper wrote:

In Clang-17+ the AST will looks like

```
`-CStyleCastExpr <line:7:3, col:16> '_Atomic(S)' <ConstructorConversion>
    `-CXXConstructExpr <col:3, col:16> 'S' 'void (const S &) noexcept'
    `-ImplicitCastExpr <col:16> 'const S' lvalue <NoOp>
        `-DeclRefExpr <col:16> 'S' lvalue Var 0x2c290190 's' 'S'
```

In CStyleCastExpr the expr type will be atomic but the subexpr type is non 
atomic

This was not a problem in Clang < 16 because the AST was emitting implicit cast 
to make both types equals

```
`-CStyleCastExpr <line:7:3, col:16> '_Atomic(S)' <NoOp>
    `-ImplicitCastExpr <col:16> '_Atomic(S)' <NonAtomicToAtomic> 
part_of_explicit_cast
    `-ImplicitCastExpr <col:16> 'S':'S' <ConstructorConversion> 
part_of_explicit_cast
        `-CXXConstructExpr <col:16> 'S':'S' 'void (const S &) noexcept'
        `-ImplicitCastExpr <col:16> 'const S':'const S' lvalue <NoOp>
            `-DeclRefExpr <col:16> 'S':'S' lvalue Var 0x60192dc19930 's' 'S':'S'
```

In CStyleCastExpr, the expr type will be atomic and the subexpr type will be 
implicit casted to atomic,
the emitted IR is correct but we should expect the types are equals but without 
having the same qualifiers

I will add release notes before land, just created this PR to make sure this 
approach makes sense and will not cause any issues

Godbolt: https://godbolt.org/z/v87819zhq

https://github.com/llvm/llvm-project/pull/207811
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to