[PATCH] D105380: DRAFT: [clang] fixes named return of variables with dependent alignment

Matheus Izvekov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 2 15:59:39 PDT 2021


mizvekov created this revision.
mizvekov requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Signed-off-by: Matheus Izvekov <mizvekov at gmail.com>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105380

Files:
  clang/lib/Sema/SemaStmt.cpp


Index: clang/lib/Sema/SemaStmt.cpp
===================================================================
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -3393,9 +3393,17 @@
     return NamedReturnInfo();
   }
 
+  auto isAlignmentDependent = [](const VarDecl *VD) {
+    for (auto *I : VD->specific_attrs<AlignedAttr>())
+      if (I->isAlignmentDependent())
+        return true;
+    return false;
+  };
+
   // Variables with higher required alignment than their type's ABI
   // alignment cannot use NRVO.
   if (!VDType->isDependentType() && VD->hasAttr<AlignedAttr>() &&
+      !isAlignmentDependent(VD) &&
       Context.getDeclAlign(VD) > Context.getTypeAlignInChars(VDType))
     Info.S = NamedReturnInfo::MoveEligible;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105380.356290.patch
Type: text/x-patch
Size: 748 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210702/f78e2c91/attachment.bin>


More information about the cfe-commits mailing list