@@ -1688,8 +1688,7 @@ CharUnits ASTContext::getDeclAlign(const Decl *D, bool ForAlignof) const {
1688
1688
if (VD->hasGlobalStorage() && !ForAlignof) {
1689
1689
uint64_t TypeSize =
1690
1690
!BaseT->isIncompleteType() ? getTypeSize(T.getTypePtr()) : 0;
1691
- Align =
1692
- std::max(Align, getTargetInfo().getMinGlobalAlign(TypeSize, VD));
1691
+ Align = std::max(Align, getMinGlobalAlignOfVar(TypeSize, VD));
1693
1692
}
1694
1693
1695
1694
// Fields can be subject to extra alignment constraints, like if
@@ -2514,7 +2513,7 @@ unsigned ASTContext::getTargetDefaultAlignForAttributeAligned() const {
2514
2513
unsigned ASTContext::getAlignOfGlobalVar(QualType T, const VarDecl *VD) const {
2515
2514
uint64_t TypeSize = getTypeSize(T.getTypePtr());
2516
2515
return std::max(getPreferredTypeAlign(T),
2517
- getTargetInfo().getMinGlobalAlign (TypeSize, VD));
2516
+ getMinGlobalAlignOfVar (TypeSize, VD));
2518
2517
}
2519
2518
2520
2519
/// getAlignOfGlobalVarInChars - Return the alignment in characters that
@@ -2524,6 +2523,14 @@ CharUnits ASTContext::getAlignOfGlobalVarInChars(QualType T,
2524
2523
return toCharUnitsFromBits(getAlignOfGlobalVar(T, VD));
2525
2524
}
2526
2525
2526
+ unsigned ASTContext::getMinGlobalAlignOfVar(uint64_t Size,
2527
+ const VarDecl *VD) const {
2528
+ // Make the default handling as that of a non-weak definition in the
2529
+ // current translation unit.
2530
+ bool HasNonWeakDef = !VD || (VD->hasDefinition() && !VD->isWeak());
2531
+ return getTargetInfo().getMinGlobalAlign(Size, HasNonWeakDef);
2532
+ }
2533
+
2527
2534
CharUnits ASTContext::getOffsetOfBaseWithVBPtr(const CXXRecordDecl *RD) const {
2528
2535
CharUnits Offset = CharUnits::Zero();
2529
2536
const ASTRecordLayout *Layout = &getASTRecordLayout(RD);
0 commit comments