[clang] [ThreadSafety] Fix C++20 build (PR #212042)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Jul 25 10:22:01 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-analysis
Author: Benjamin Kramer (d0k)
<details>
<summary>Changes</summary>
In C++20 (P1008R1 https://wg21.link/p1008r1), aggregates are prohibited from having any user-declared constructors, even if they are = delete or = default.
---
Full diff: https://github.com/llvm/llvm-project/pull/212042.diff
1 Files Affected:
- (modified) clang/lib/Analysis/ThreadSafety.cpp (+6-2)
``````````diff
diff --git a/clang/lib/Analysis/ThreadSafety.cpp b/clang/lib/Analysis/ThreadSafety.cpp
index 2b394865c5a5e..fe94910e905a3 100644
--- a/clang/lib/Analysis/ThreadSafety.cpp
+++ b/clang/lib/Analysis/ThreadSafety.cpp
@@ -1802,9 +1802,13 @@ class BuildLockset : public ConstStmtVisitor<BuildLockset> {
public:
enum Point : char { Pre = 0, Post = 1 };
- struct ContextSwitchScope {
+ class ContextSwitchScope {
DualLocalVarContext &DC;
Point LastPoint;
+
+ public:
+ ContextSwitchScope(DualLocalVarContext &DC, Point LastPoint)
+ : DC(DC), LastPoint(LastPoint) {}
ContextSwitchScope(const ContextSwitchScope &) = delete;
ContextSwitchScope &operator=(const ContextSwitchScope &) = delete;
~ContextSwitchScope() { DC.switchContextTo(LastPoint); }
@@ -1814,7 +1818,7 @@ class BuildLockset : public ConstStmtVisitor<BuildLockset> {
[[nodiscard]] ContextSwitchScope switchToContextForScope(Point P) {
Point PriorPoint = CurrPoint;
switchContextTo(P);
- return ContextSwitchScope{*this, PriorPoint};
+ return ContextSwitchScope(*this, PriorPoint);
}
/// Update the pre- and post-contexts to be associated with the next Stmt \p
``````````
</details>
https://github.com/llvm/llvm-project/pull/212042
More information about the cfe-commits
mailing list