зеркало из https://github.com/microsoft/clang-1.git
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). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41973 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
13ed7fea97
Коммит
f13271f840
|
@ -757,7 +757,7 @@ void Parser::ParseStructUnionBody(SourceLocation RecordLoc,
|
|||
|
||||
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.
|
||||
|
|
|
@ -659,10 +659,9 @@ void Parser::ParseObjCClassInstanceVariables(DeclTy *interfaceDecl) {
|
|||
}
|
||||
}
|
||||
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;
|
||||
|
|
11
Sema/Sema.h
11
Sema/Sema.h
|
@ -155,8 +155,11 @@ private:
|
|||
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 @@ public:
|
|||
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).
|
||||
|
|
|
@ -877,40 +877,6 @@ Sema::DeclTy *Sema::ObjcStartClassInterface(SourceLocation AtInterfaceLoc,
|
|||
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 @@ Sema::DeclTy *Sema::ParseField(Scope *S, DeclTy *TagDecl,
|
|||
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 @@ void Sema::ParseRecordBody(SourceLocation RecLoc, DeclTy *RecDecl,
|
|||
// 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,
|
||||
|
|
|
@ -180,9 +180,9 @@ public:
|
|||
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 @@ public:
|
|||
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;
|
||||
|
|
Загрузка…
Ссылка в новой задаче