[cfe-commits] r100227 - in /cfe/trunk: include/clang/AST/DeclObjC.h lib/AST/DeclObjC.cpp
Daniel Dunbar
daniel at zuster.org
Fri Apr 2 14:13:59 PDT 2010
Author: ddunbar
Date: Fri Apr 2 16:13:59 2010
New Revision: 100227
URL: http://llvm.org/viewvc/llvm-project?rev=100227&view=rev
Log:
AST: Add ObjCIvarDecl::getContainingInterface().
Modified:
cfe/trunk/include/clang/AST/DeclObjC.h
cfe/trunk/lib/AST/DeclObjC.cpp
Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=100227&r1=100226&r2=100227&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Fri Apr 2 16:13:59 2010
@@ -635,6 +635,12 @@
TypeSourceInfo *TInfo,
AccessControl ac, Expr *BW = NULL);
+ /// \brief Return the class interface that this ivar is logically contained
+ /// in; this is either the interface where the ivar was declared, or the
+ /// interface the ivar is conceptually a part of in the case of synthesized
+ /// ivars.
+ const ObjCInterfaceDecl *getContainingInterface() const;
+
void setAccessControl(AccessControl ac) { DeclAccess = ac; }
AccessControl getAccessControl() const { return AccessControl(DeclAccess); }
Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=100227&r1=100226&r2=100227&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Fri Apr 2 16:13:59 2010
@@ -584,7 +584,30 @@
return new (C) ObjCIvarDecl(DC, L, Id, T, TInfo, ac, BW);
}
+const ObjCInterfaceDecl *ObjCIvarDecl::getContainingInterface() const {
+ const ObjCContainerDecl *DC = cast<ObjCContainerDecl>(getDeclContext());
+ switch (DC->getKind()) {
+ default:
+ case ObjCCategoryImpl:
+ case ObjCProtocol:
+ assert(0 && "invalid ivar container!");
+ return 0;
+
+ // Ivars can only appear in class extension categories.
+ case ObjCCategory: {
+ const ObjCCategoryDecl *CD = cast<ObjCCategoryDecl>(DC);
+ assert(CD->IsClassExtension() && "invalid container for ivar!");
+ return CD->getClassInterface();
+ }
+
+ case ObjCImplementation:
+ return cast<ObjCImplementationDecl>(DC)->getClassInterface();
+
+ case ObjCInterface:
+ return cast<ObjCInterfaceDecl>(DC);
+ }
+}
//===----------------------------------------------------------------------===//
// ObjCAtDefsFieldDecl
More information about the cfe-commits
mailing list