[clang] [clang-cl] [Sema] Support MSVC non-const lvalue to user-defined temporary reference (PR #99833)

Reid Kleckner via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 22 15:48:24 PDT 2024


================
@@ -5138,7 +5148,11 @@ TryReferenceInit(Sema &S, Expr *Init, QualType DeclType,
   //     -- Otherwise, the reference shall be an lvalue reference to a
   //        non-volatile const type (i.e., cv1 shall be const), or the reference
   //        shall be an rvalue reference.
-  if (!isRValRef && (!T1.isConstQualified() || T1.isVolatileQualified())) {
+  const bool CanBindLValueRef =
----------------
rnk wrote:

This boolean isn't needed if `!isRValRef`. Can you structure it as:
```
  if (!isRValRef) {
    bool CanBindLValueRef = ...
    if (!CanBindLValueRef) {
    }
  }
```
... or whatever is most readable, I just want to reduce the scope of the variable and avoid extra LangOpt checks.

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


More information about the cfe-commits mailing list