[llvm] [llvm] Support building with c++23 (PR #154372)

Kyle Krüger via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 20 02:09:28 PDT 2025


================
@@ -615,7 +623,7 @@ bool SwitchMatcher::addMatcher(Matcher &Candidate) {
 }
 
 void SwitchMatcher::finalize() {
-  assert(Condition == nullptr && "Already finalized");
+  assert(Condition.get() == nullptr && "Already finalized");
----------------
kykrueger wrote:

It seems like 
```
  std::unique_ptr<PredicateMatcher> Condition;
```
does indeed however get auto-initialized.

As described at [cplusplus.com](https://cplusplus.com/reference/memory/unique_ptr/unique_ptr/): 
> default constructor (1), and (2)
> The object is empty (owns nothing), with value-initialized [stored pointer] (https://cplusplus.com/unique_ptr::get) and [stored deleter](https://cplusplus.com/unique_ptr::get_deleter).

And since I removed our forced initialization to nullptr to avoid instantiating a unique_ptr to PredicateMatcher which is at the point of this initialization an incomplete class, I am concerned that the old checks to see if Condition is a nullptr will no longer evaluate the same as before, introducing a regression.

https://github.com/llvm/llvm-project/pull/154372


More information about the llvm-commits mailing list