aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-05-03 10:38:35 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-05-03 10:38:35 +0000
commitb2dbbb99e12806eaaf53b7ccabc32f42b5719443 (patch)
tree8a9bace0e7166787de15f9ec84781d9f8ebc8f3b
parent24cbfb96f09318f59dc73eaaf4909a79788ec5ac (diff)
Split out getASTObjCImplementationLayout
- The difference from getASTObjCInterfaceLayout is that the computes the layout including synthesized ivars. - No functionality change, they currently both compute the same thing -- whether that includes synthesized ivars or not depends on when they get called!!! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70690 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/ASTContext.h16
-rw-r--r--lib/AST/ASTContext.cpp27
2 files changed, 33 insertions, 10 deletions
diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h
index fef2ed7231..18ea40b1e9 100644
--- a/include/clang/AST/ASTContext.h
+++ b/include/clang/AST/ASTContext.h
@@ -93,8 +93,7 @@ class ASTContext {
/// ASTRecordLayouts - A cache mapping from RecordDecls to ASTRecordLayouts.
/// This is lazily created. This is intentionally not serialized.
llvm::DenseMap<const RecordDecl*, const ASTRecordLayout*> ASTRecordLayouts;
- llvm::DenseMap<const ObjCInterfaceDecl*,
- const ASTRecordLayout*> ASTObjCInterfaces;
+ llvm::DenseMap<const ObjCContainerDecl*, const ASTRecordLayout*> ObjCLayouts;
llvm::DenseMap<unsigned, FixedWidthIntType*> SignedFixedWidthIntTypes;
llvm::DenseMap<unsigned, FixedWidthIntType*> UnsignedFixedWidthIntTypes;
@@ -530,7 +529,16 @@ public:
/// position information.
const ASTRecordLayout &getASTRecordLayout(const RecordDecl *D);
+ /// getASTObjCInterfaceLayout - Get or compute information about the
+ /// layout of the specified Objective-C interface.
const ASTRecordLayout &getASTObjCInterfaceLayout(const ObjCInterfaceDecl *D);
+
+ /// getASTObjCImplementationLayout - Get or compute information about
+ /// the layout of the specified Objective-C implementation. This may
+ /// differ from the interface if synthesized ivars are present.
+ const ASTRecordLayout &
+ getASTObjCImplementationLayout(const ObjCImplementationDecl *D);
+
const RecordDecl *addRecordToClass(const ObjCInterfaceDecl *D);
void CollectObjCIvars(const ObjCInterfaceDecl *OI,
llvm::SmallVectorImpl<FieldDecl*> &Fields);
@@ -741,7 +749,9 @@ private:
const FieldDecl *Field,
bool OutermostType = false,
bool EncodingProperty = false);
-
+
+ const ASTRecordLayout &getObjCLayout(const ObjCInterfaceDecl *D,
+ const ObjCImplementationDecl *Impl);
};
} // end namespace clang
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index 0494de199f..3342ca5bc9 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -63,8 +63,8 @@ ASTContext::~ASTContext() {
}
{
- llvm::DenseMap<const ObjCInterfaceDecl*, const ASTRecordLayout*>::iterator
- I = ASTObjCInterfaces.begin(), E = ASTObjCInterfaces.end();
+ llvm::DenseMap<const ObjCContainerDecl*, const ASTRecordLayout*>::iterator
+ I = ObjCLayouts.begin(), E = ObjCLayouts.end();
while (I != E) {
ASTRecordLayout *R = const_cast<ASTRecordLayout*>((I++)->second);
delete R;
@@ -736,13 +736,16 @@ const RecordDecl *ASTContext::addRecordToClass(const ObjCInterfaceDecl *D) {
return RD;
}
-/// getASTObjcInterfaceLayout - Get or compute information about the layout of
-/// the specified Objective C, which indicates its size and ivar
-/// position information.
+/// getInterfaceLayoutImpl - Get or compute information about the
+/// layout of the given interface.
+///
+/// \param Impl - If given, also include the layout of the interface's
+/// implementation. This may differ by including synthesized ivars.
const ASTRecordLayout &
-ASTContext::getASTObjCInterfaceLayout(const ObjCInterfaceDecl *D) {
+ASTContext::getObjCLayout(const ObjCInterfaceDecl *D,
+ const ObjCImplementationDecl *Impl) {
// Look up this layout, if already laid out, return what we have.
- const ASTRecordLayout *&Entry = ASTObjCInterfaces[D];
+ const ASTRecordLayout *&Entry = ObjCLayouts[D];
if (Entry) return *Entry;
// Allocate and assign into ASTRecordLayouts here. The "Entry" reference can
@@ -795,6 +798,16 @@ ASTContext::getASTObjCInterfaceLayout(const ObjCInterfaceDecl *D) {
return *NewEntry;
}
+const ASTRecordLayout &
+ASTContext::getASTObjCInterfaceLayout(const ObjCInterfaceDecl *D) {
+ return getObjCLayout(D, 0);
+}
+
+const ASTRecordLayout &
+ASTContext::getASTObjCImplementationLayout(const ObjCImplementationDecl *D) {
+ return getObjCLayout(D->getClassInterface(), D);
+}
+
/// getASTRecordLayout - Get or compute information about the layout of the
/// specified record (struct/union/class), which indicates its size and field
/// position information.