[all-commits] [llvm/llvm-project] b02d97: [clang][sema] Generate builtin operator overloads ...
Jan Svoboda via All-commits
all-commits at lists.llvm.org
Mon Jun 20 02:03:43 PDT 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: b02d970b4335561940dd584f6e6497ab684c788d
https://github.com/llvm/llvm-project/commit/b02d970b4335561940dd584f6e6497ab684c788d
Author: Jan Svoboda <jan_svoboda at apple.com>
Date: 2022-06-20 (Mon, 20 Jun 2022)
Changed paths:
M clang/include/clang/AST/Type.h
M clang/lib/Sema/SemaOverload.cpp
A clang/test/CodeGenCXX/atomic-builtin-compound-assignment-overload.cpp
A clang/test/SemaCXX/atomic-builtin-compound-assignment-overload.cpp
Log Message:
-----------
[clang][sema] Generate builtin operator overloads for (volatile) _Atomic types
We observed a failed assert in overloaded compound-assignment operator resolution:
```
Assertion failed: (Result.isInvalid() && "C++ binary operator overloading is missing candidates!"), function CreateOverloadedBinOp, file SemaOverload.cpp, line 13944.
...
frame #4: clang` clang::Sema::CreateOverloadedBinOp(..., Opc=BO_OrAssign, ..., PerformADL=true, AllowRewrittenCandidates=false, ...) at SemaOverload.cpp:13943
frame #5: clang` BuildOverloadedBinOp(..., Opc=BO_OrAssign, ...) at SemaExpr.cpp:15228
frame #6: clang` clang::Sema::BuildBinOp(..., Opc=BO_OrAssign, ...) at SemaExpr.cpp:15330
frame #7: clang` clang::Sema::ActOnBinOp(..., Kind=pipeequal, ...) at SemaExpr.cpp:15187
frame #8: clang` clang::Parser::ParseRHSOfBinaryExpression(..., MinPrec=Assignment) at ParseExpr.cpp:629
frame #9: clang` clang::Parser::ParseAssignmentExpression(..., isTypeCast=NotTypeCast) at ParseExpr.cpp:176
frame #10: clang` clang::Parser::ParseExpression(... isTypeCast=NotTypeCast) at ParseExpr.cpp:124
frame #11: clang` clang::Parser::ParseExprStatement(...) at ParseStmt.cpp:464
```
A simple reproducer is:
```
_Atomic unsigned an_atomic_uint;
enum { an_enum_value = 1 };
void enum1() { an_atomic_uint += an_enum_value; }
```
This patch fixes the issue by generating builtin operator overloads for (volatile) _Atomic types.
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D125349
More information about the All-commits
mailing list