diff options
author | David Majnemer <david.majnemer@gmail.com> | 2014-07-30 01:30:47 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2014-07-30 01:30:47 +0000 |
commit | 34b5749989062e3049296cf656cc3551ebe47e65 (patch) | |
tree | b909046d61f66d0a403d635856ead8c437d42457 /clang/lib/Sema/SemaDeclObjC.cpp | |
parent | 9dcc254a47256162dbd616fc34c9dac774969306 (diff) | |
download | bcm5719-llvm-34b5749989062e3049296cf656cc3551ebe47e65.tar.gz bcm5719-llvm-34b5749989062e3049296cf656cc3551ebe47e65.zip |
MS ABI: Consider alignment attributes on typedefs for layout
The MS ABI has a notion of 'required alignment' for fields; this
alignment supercedes pragma pack directives.
MSVC takes into account alignment attributes on typedefs when
determining whether or not a field has a certain required alignment.
Do the same in clang by tracking whether or not we saw such an attribute
when calculating the type's bitwidth and alignment.
This fixes PR20418.
Reviewers: rnk
Differential Revision: http://reviews.llvm.org/D4714
llvm-svn: 214274
Diffstat (limited to 'clang/lib/Sema/SemaDeclObjC.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index b5205b3e623..0ebc5838d2f 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -2107,7 +2107,12 @@ static bool matchTypes(ASTContext &Context, Sema::MethodMatchStrategy strategy, // validate the basic, low-level compatibility of the two types. // As a minimum, require the sizes and alignments to match. - if (Context.getTypeInfo(left) != Context.getTypeInfo(right)) + TypeInfo LeftTI = Context.getTypeInfo(left); + TypeInfo RightTI = Context.getTypeInfo(right); + if (LeftTI.Width != RightTI.Width) + return false; + + if (LeftTI.Align != RightTI.Align) return false; // Consider all the kinds of non-dependent canonical types: @@ -2159,7 +2164,13 @@ static bool tryMatchRecordTypes(ASTContext &Context, return false; // Require size and alignment to match. - if (Context.getTypeInfo(lt) != Context.getTypeInfo(rt)) return false; + TypeInfo LeftTI = Context.getTypeInfo(lt); + TypeInfo RightTI = Context.getTypeInfo(rt); + if (LeftTI.Width != RightTI.Width) + return false; + + if (LeftTI.Align != RightTI.Align) + return false; // Require fields to match. RecordDecl::field_iterator li = left->field_begin(), le = left->field_end(); |