diff options
| author | David Majnemer <david.majnemer@gmail.com> | 2015-02-03 08:49:32 +0000 | 
|---|---|---|
| committer | David Majnemer <david.majnemer@gmail.com> | 2015-02-03 08:49:32 +0000 | 
| commit | e1a0b2e2af7af1ae4b481eea838837d440825c3e (patch) | |
| tree | 3dac5302b082399bee9b2e49c4f15f09880f4859 /clang/lib/CodeGen | |
| parent | 5821ff78efc158978019c49f1e310701c25ffd26 (diff) | |
| download | bcm5719-llvm-e1a0b2e2af7af1ae4b481eea838837d440825c3e.tar.gz bcm5719-llvm-e1a0b2e2af7af1ae4b481eea838837d440825c3e.zip  | |
MS ABI: Records with fields with required aligmnet shouldn't be common
llvm-svn: 227954
Diffstat (limited to 'clang/lib/CodeGen')
| -rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 22 | 
1 files changed, 19 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index dc7ec6f6548..bc52028a064 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -2162,9 +2162,25 @@ static bool isVarDeclStrongDefinition(const ASTContext &Context,    // Declarations with a required alignment do not have common linakge in MSVC    // mode. -  if (Context.getLangOpts().MSVCCompat && -      (Context.isAlignmentRequired(D->getType()) || D->hasAttr<AlignedAttr>())) -    return true; +  if (Context.getLangOpts().MSVCCompat) { +    if (D->hasAttr<AlignedAttr>()) +      return true; +    QualType VarType = D->getType(); +    if (Context.isAlignmentRequired(VarType)) +      return true; + +    if (const auto *RT = VarType->getAs<RecordType>()) { +      const RecordDecl *RD = RT->getDecl(); +      for (const FieldDecl *FD : RD->fields()) { +        if (FD->isBitField()) +          continue; +        if (FD->hasAttr<AlignedAttr>()) +          return true; +        if (Context.isAlignmentRequired(FD->getType())) +          return true; +      } +    } +  }    return false;  }  | 

