diff options
author | Eric Christopher <echristo@apple.com> | 2012-07-19 22:22:51 +0000 |
---|---|---|
committer | Eric Christopher <echristo@apple.com> | 2012-07-19 22:22:51 +0000 |
commit | 7457aaf8c91eb367e5a69f68431794d1ef35a24d (patch) | |
tree | 71f41eb463f25da79f1164fb766321f69499635f /clang/lib/Sema/SemaDecl.cpp | |
parent | 27540f8d8c14934ee73c6dc8ea3c6ba16a99de8a (diff) | |
download | bcm5719-llvm-7457aaf8c91eb367e5a69f68431794d1ef35a24d.tar.gz bcm5719-llvm-7457aaf8c91eb367e5a69f68431794d1ef35a24d.zip |
Reset the layout of an ObjC class if we see an ivar in a category
or implementation since we've now got a different layout.
Fixes rdar://11842763
llvm-svn: 160526
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 4ea8df8b661..430ce9f7f78 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -9802,6 +9802,23 @@ void Sema::ActOnFields(Scope* S, if (EnclosingDecl->isInvalidDecl()) return; + // If this is an Objective-C @implementation or category and we have + // new fields here we should reset the layout of the interface since + // it will now change. + if (!Fields.empty() && isa<ObjCContainerDecl>(EnclosingDecl)) { + ObjCContainerDecl *DC = cast<ObjCContainerDecl>(EnclosingDecl); + switch (DC->getKind()) { + default: break; + case Decl::ObjCCategory: + Context.ResetObjCLayout(cast<ObjCCategoryDecl>(DC)->getClassInterface()); + break; + case Decl::ObjCImplementation: + Context. + ResetObjCLayout(cast<ObjCImplementationDecl>(DC)->getClassInterface()); + break; + } + } + RecordDecl *Record = dyn_cast<RecordDecl>(EnclosingDecl); // Start counting up the number of named members; make sure to include |