[cfe-commits] r41973 - in /cfe/trunk: Parse/ParseDecl.cpp Parse/ParseObjc.cpp Sema/Sema.h Sema/SemaDecl.cpp include/clang/Parse/Action.h
Steve Naroff
snaroff at apple.com
Fri Sep 14 16:09:53 PDT 2007
Author: snaroff
Date: Fri Sep 14 18:09:53 2007
New Revision: 41973
URL: http://llvm.org/viewvc/llvm-project?rev=41973&view=rev
Log:
Rename Action::ParseRecordBody() to ProcessFieldDecls(), and add a visibility argument.
Remove Action::ObjcAddVisibilityToIvars(). No need for an extra API when it is trivial to add this info to the previous hook.
In general, I want to start migrating away from having Actions prefixed with "Parse" (which is confusing, since the Action API doesn't do any parsing, per se).
Modified:
cfe/trunk/Parse/ParseDecl.cpp
cfe/trunk/Parse/ParseObjc.cpp
cfe/trunk/Sema/Sema.h
cfe/trunk/Sema/SemaDecl.cpp
cfe/trunk/include/clang/Parse/Action.h
Modified: cfe/trunk/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseDecl.cpp?rev=41973&r1=41972&r2=41973&view=diff
==============================================================================
--- cfe/trunk/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/Parse/ParseDecl.cpp Fri Sep 14 18:09:53 2007
@@ -757,7 +757,7 @@
MatchRHSPunctuation(tok::r_brace, LBraceLoc);
- Actions.ParseRecordBody(RecordLoc, TagDecl, &FieldDecls[0],FieldDecls.size());
+ Actions.ProcessFieldDecls(RecordLoc,TagDecl,&FieldDecls[0],FieldDecls.size());
AttributeList *AttrList = 0;
// If attributes exist after struct contents, parse them.
Modified: cfe/trunk/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseObjc.cpp?rev=41973&r1=41972&r2=41973&view=diff
==============================================================================
--- cfe/trunk/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/Parse/ParseObjc.cpp Fri Sep 14 18:09:53 2007
@@ -659,10 +659,9 @@
}
}
if (AllIvarDecls.size()) { // Check for {} - no ivars in braces
- Actions.ObjcAddVisibilityToIvars(interfaceDecl,
- &AllIvarDecls[0], AllIvarDecls.size(), &AllVisibilities[0]);
- Actions.ParseRecordBody(LBraceLoc, interfaceDecl,
- &AllIvarDecls[0], AllIvarDecls.size());
+ Actions.ProcessFieldDecls(LBraceLoc, 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=41973&r1=41972&r2=41973&view=diff
==============================================================================
--- cfe/trunk/Sema/Sema.h (original)
+++ cfe/trunk/Sema/Sema.h Fri Sep 14 18:09:53 2007
@@ -155,8 +155,11 @@
SourceLocation NameLoc, AttributeList *Attr);
virtual DeclTy *ParseField(Scope *S, DeclTy *TagDecl,SourceLocation DeclStart,
Declarator &D, ExprTy *BitfieldWidth);
- virtual void ParseRecordBody(SourceLocation RecLoc, DeclTy *TagDecl,
- DeclTy **Fields, unsigned NumFields);
+
+ // This is used for both record definitions and ObjC interface declarations.
+ virtual void ProcessFieldDecls(SourceLocation RecLoc, DeclTy *TagDecl,
+ DeclTy **Fields, unsigned NumFields,
+ tok::ObjCKeywordKind *visibility = 0);
virtual DeclTy *ParseEnumConstant(Scope *S, DeclTy *EnumDecl,
DeclTy *LastEnumConstant,
SourceLocation IdLoc, IdentifierInfo *Id,
@@ -368,10 +371,6 @@
virtual DeclTy *ObjcBuildMethodDeclaration(SourceLocation MethodLoc,
tok::TokenKind MethodType, TypeTy *ReturnType,
IdentifierInfo *SelectorName, AttributeList *AttrList);
-
- virtual void ObjcAddVisibilityToIvars(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=41973&r1=41972&r2=41973&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/Sema/SemaDecl.cpp Fri Sep 14 18:09:53 2007
@@ -877,40 +877,6 @@
return IDecl;
}
-void Sema::ObjcAddVisibilityToIvars(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));
- 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...
-}
-
/// ObjcClassDeclaration -
/// Scope will always be top level file scope.
Action::DeclTy *
@@ -1092,10 +1058,31 @@
return NewFD;
}
-// FIXME: Change ParseRecordBody name to something more generic as
-// it also used for ivar semantics check.
-void Sema::ParseRecordBody(SourceLocation RecLoc, DeclTy *RecDecl,
- DeclTy **Fields, unsigned NumFields) {
+static void ObjcSetIvarVisibility(ObjcIvarDecl *OIvar,
+ tok::ObjCKeywordKind ivarVisibility) {
+ assert(OIvar && "missing 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;
+ }
+}
+
+void Sema::ProcessFieldDecls(SourceLocation RecLoc, DeclTy *RecDecl,
+ DeclTy **Fields, unsigned NumFields,
+ tok::ObjCKeywordKind *visibility) {
Decl *EnclosingDecl = static_cast<Decl*>(RecDecl);
assert(EnclosingDecl && "missing record or interface decl");
RecordDecl *Record = dyn_cast<RecordDecl>(EnclosingDecl);
@@ -1127,6 +1114,10 @@
// Get the type for the field.
Type *FDTy = FD->getType().getTypePtr();
+ // If we have visibility info, make sure the AST is set accordingly.
+ if (visibility)
+ ObjcSetIvarVisibility(dyn_cast<ObjcIvarDecl>(FD), visibility[i]);
+
// C99 6.7.2.1p2 - A field may not be a function type.
if (FDTy->isFunctionType()) {
Diag(FD->getLocation(), diag::err_field_declared_as_function,
Modified: cfe/trunk/include/clang/Parse/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Action.h?rev=41973&r1=41972&r2=41973&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/trunk/include/clang/Parse/Action.h Fri Sep 14 18:09:53 2007
@@ -180,9 +180,9 @@
Declarator &D, ExprTy *BitfieldWidth) {
return 0;
}
- virtual void ParseRecordBody(SourceLocation RecLoc, DeclTy *TagDecl,
- DeclTy **Fields, unsigned NumFields) {}
-
+ virtual void ProcessFieldDecls(SourceLocation RecLoc, DeclTy *TagDecl,
+ DeclTy **Fields, unsigned NumFields,
+ tok::ObjCKeywordKind *visibility = 0) {}
virtual DeclTy *ParseEnumConstant(Scope *S, DeclTy *EnumDecl,
DeclTy *LastEnumConstant,
SourceLocation IdLoc, IdentifierInfo *Id,
@@ -449,11 +449,6 @@
AttributeList *AttrList) {
return 0;
}
- virtual void ObjcAddVisibilityToIvars(DeclTy *ClassDec, DeclTy **Ivars,
- unsigned numIvars,
- tok::ObjCKeywordKind *visibility) {
- return;
- }
virtual void ObjcAddMethodsToClass(DeclTy *ClassDecl,
DeclTy **allMethods, unsigned allNum) {
return;
More information about the cfe-commits
mailing list