[cfe-commits] r41932 - in /cfe/trunk: Parse/ParseObjc.cpp Sema/Sema.h Sema/SemaDecl.cpp clang.xcodeproj/project.pbxproj include/clang/Parse/Action.h
Fariborz Jahanian
fjahanian at apple.com
Thu Sep 13 13:56:14 PDT 2007
Author: fjahanian
Date: Thu Sep 13 15:56:13 2007
New Revision: 41932
URL: http://llvm.org/viewvc/llvm-project?rev=41932&view=rev
Log:
Patch for collecting ivars before running action on them.
Modified:
cfe/trunk/Parse/ParseObjc.cpp
cfe/trunk/Sema/Sema.h
cfe/trunk/Sema/SemaDecl.cpp
cfe/trunk/clang.xcodeproj/project.pbxproj
cfe/trunk/include/clang/Parse/Action.h
Modified: cfe/trunk/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseObjc.cpp?rev=41932&r1=41931&r2=41932&view=diff
==============================================================================
--- cfe/trunk/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/Parse/ParseObjc.cpp Thu Sep 13 15:56:13 2007
@@ -606,9 +606,12 @@
void Parser::ParseObjCClassInstanceVariables(DeclTy *interfaceDecl) {
assert(Tok.getKind() == tok::l_brace && "expected {");
llvm::SmallVector<DeclTy*, 16> IvarDecls;
+ llvm::SmallVector<DeclTy*, 32> AllIvarDecls;
+ llvm::SmallVector<tok::ObjCKeywordKind, 32> AllVisibilities;
SourceLocation LBraceLoc = ConsumeBrace(); // the "{"
+ tok::ObjCKeywordKind visibility = tok::objc_private;
// While we still have something to read, read the instance variables.
while (Tok.getKind() != tok::r_brace &&
Tok.getKind() != tok::eof) {
@@ -621,7 +624,6 @@
continue;
}
// Set the default visibility to private.
- tok::ObjCKeywordKind visibility = tok::objc_private;
if (Tok.getKind() == tok::at) { // parse objc-visibility-spec
ConsumeToken(); // eat the @ sign
switch (Tok.getObjCKeywordID()) {
@@ -639,8 +641,10 @@
}
}
ParseStructDeclaration(interfaceDecl, IvarDecls);
- for (unsigned i = 0; i < IvarDecls.size(); i++)
- Actions.ObjcAddInstanceVariable(interfaceDecl, IvarDecls[i], visibility);
+ for (unsigned i = 0; i < IvarDecls.size(); i++) {
+ AllIvarDecls.push_back(IvarDecls[i]);
+ AllVisibilities.push_back(visibility);
+ }
IvarDecls.clear();
if (Tok.getKind() == tok::semi) {
@@ -654,6 +658,10 @@
SkipUntil(tok::r_brace, true, true);
}
}
+ if (AllIvarDecls.size()) { // Check for {} - no ivars in braces
+ Actions.ObjcAddInstanceVariable(interfaceDecl,
+ &AllIvarDecls[0], AllIvarDecls.size(), &AllVisibilities[0]);
+ }
MatchRHSPunctuation(tok::r_brace, LBraceLoc);
return;
}
Modified: cfe/trunk/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/Sema.h?rev=41932&r1=41931&r2=41932&view=diff
==============================================================================
--- cfe/trunk/Sema/Sema.h (original)
+++ cfe/trunk/Sema/Sema.h Thu Sep 13 15:56:13 2007
@@ -369,8 +369,9 @@
tok::TokenKind MethodType, TypeTy *ReturnType,
IdentifierInfo *SelectorName, AttributeList *AttrList);
- virtual void ObjcAddInstanceVariable(DeclTy *ClassDec, DeclTy *Ivar,
- tok::ObjCKeywordKind visibility);
+ virtual void ObjcAddInstanceVariable(DeclTy *ClassDec, DeclTy **Ivar,
+ unsigned numIvars,
+ tok::ObjCKeywordKind *visibility);
private:
// UsualUnaryConversions - promotes integers (C99 6.3.1.1p2) and converts
// functions and arrays to their respective pointers (C99 6.3.2.1).
Modified: cfe/trunk/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDecl.cpp?rev=41932&r1=41931&r2=41932&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/Sema/SemaDecl.cpp Thu Sep 13 15:56:13 2007
@@ -875,31 +875,36 @@
return IDecl;
}
-void Sema::ObjcAddInstanceVariable(DeclTy *ClassDecl, DeclTy *Ivar,
- tok::ObjCKeywordKind visibility) {
- assert((ClassDecl && Ivar) && "missing class or instance variable");
+void Sema::ObjcAddInstanceVariable(DeclTy *ClassDecl, DeclTy **Ivar,
+ unsigned numIvars,
+ tok::ObjCKeywordKind *visibility) {
+ assert((ClassDecl && numIvars) && "missing class or instance variable");
ObjcInterfaceDecl *OInterface = dyn_cast<ObjcInterfaceDecl>(
static_cast<Decl *>(ClassDecl));
- ObjcIvarDecl *OIvar = dyn_cast<ObjcIvarDecl>(static_cast<Decl *>(Ivar));
-
- assert((OInterface && OIvar) && "mistyped class or instance variable");
-
- switch (visibility) {
- case tok::objc_private:
- OIvar->setAccessControl(ObjcIvarDecl::Private);
- break;
- case tok::objc_public:
- OIvar->setAccessControl(ObjcIvarDecl::Public);
- break;
- case tok::objc_protected:
- OIvar->setAccessControl(ObjcIvarDecl::Protected);
- break;
- case tok::objc_package:
- OIvar->setAccessControl(ObjcIvarDecl::Package);
- break;
- default:
- OIvar->setAccessControl(ObjcIvarDecl::None);
- break;
+ assert (OInterface && "mistyped class");
+ for (unsigned i = 0; i != numIvars; ++i) {
+ ObjcIvarDecl *OIvar = dyn_cast<ObjcIvarDecl>(static_cast<Decl *>(Ivar[i]));
+ tok::ObjCKeywordKind ivarVisibility = visibility[i];
+
+ assert(OIvar && "mistyped instance variable");
+
+ switch (ivarVisibility) {
+ case tok::objc_private:
+ OIvar->setAccessControl(ObjcIvarDecl::Private);
+ break;
+ case tok::objc_public:
+ OIvar->setAccessControl(ObjcIvarDecl::Public);
+ break;
+ case tok::objc_protected:
+ OIvar->setAccessControl(ObjcIvarDecl::Protected);
+ break;
+ case tok::objc_package:
+ OIvar->setAccessControl(ObjcIvarDecl::Package);
+ break;
+ default:
+ OIvar->setAccessControl(ObjcIvarDecl::None);
+ break;
+ }
}
// FIXME: add to the class...
}
Modified: cfe/trunk/clang.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/clang.xcodeproj/project.pbxproj?rev=41932&r1=41931&r2=41932&view=diff
==============================================================================
--- cfe/trunk/clang.xcodeproj/project.pbxproj (original)
+++ cfe/trunk/clang.xcodeproj/project.pbxproj Thu Sep 13 15:56:13 2007
@@ -675,6 +675,7 @@
08FB7793FE84155DC02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */;
+ compatibilityVersion = "Xcode 2.4";
hasScannedForEncodings = 1;
mainGroup = 08FB7794FE84155DC02AAC07 /* clang */;
projectDirPath = "";
Modified: cfe/trunk/include/clang/Parse/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Action.h?rev=41932&r1=41931&r2=41932&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/trunk/include/clang/Parse/Action.h Thu Sep 13 15:56:13 2007
@@ -449,8 +449,9 @@
AttributeList *AttrList) {
return 0;
}
- virtual void ObjcAddInstanceVariable(DeclTy *ClassDec, DeclTy *Ivars,
- tok::ObjCKeywordKind visibility) {
+ virtual void ObjcAddInstanceVariable(DeclTy *ClassDec, DeclTy **Ivars,
+ unsigned numIvars,
+ tok::ObjCKeywordKind *visibility) {
return;
}
virtual void ObjcAddMethodsToClass(DeclTy *ClassDecl,
More information about the cfe-commits
mailing list