diff options
| author | John McCall <rjmccall@apple.com> | 2011-01-20 07:57:12 +0000 |
|---|---|---|
| committer | John McCall <rjmccall@apple.com> | 2011-01-20 07:57:12 +0000 |
| commit | 4e81961a1e24aff155ef981f14ac84e2cd1f7de7 (patch) | |
| tree | f51b6aaae4c8bf1d280227e695fcc9e93adb9b10 /clang/lib/AST/Decl.cpp | |
| parent | 4dc72284b254925713e08f5cf8d992d28a4a6412 (diff) | |
| download | bcm5719-llvm-4e81961a1e24aff155ef981f14ac84e2cd1f7de7.tar.gz bcm5719-llvm-4e81961a1e24aff155ef981f14ac84e2cd1f7de7.zip | |
Fix the computation of alignment for fields of packed+aligned structs.
Part of the fix for PR8413.
llvm-svn: 123904
Diffstat (limited to 'clang/lib/AST/Decl.cpp')
| -rw-r--r-- | clang/lib/AST/Decl.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 9e2e8763f85..b1da849ae15 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -1881,6 +1881,25 @@ bool FieldDecl::isAnonymousStructOrUnion() const { return false; } +unsigned FieldDecl::getFieldIndex() const { + if (CachedFieldIndex) return CachedFieldIndex - 1; + + unsigned index = 0; + RecordDecl::field_iterator + i = getParent()->field_begin(), e = getParent()->field_end(); + while (true) { + assert(i != e && "failed to find field in parent!"); + if (*i == this) + break; + + ++i; + ++index; + } + + CachedFieldIndex = index + 1; + return index; +} + //===----------------------------------------------------------------------===// // TagDecl Implementation //===----------------------------------------------------------------------===// |

