}
}
+/// ParseObjcTypeQualifierList - This routine parses the objective-c's type
+/// qualifier list and builds their bitmask representation in the input
+/// argument.
+void Parser::ParseObjcTypeQualifierList(ObjcDeclSpec &DS) {
+ bool found = true;
+ while (found) {
+ found = false;
+ if (Tok.is(tok::identifier)) {
+ const IdentifierInfo *II = Tok.getIdentifierInfo();
+ unsigned i;
+ for (i = 0; i < objc_NumQuals; ++i) {
+ if (II == ObjcTypeQuals[i]) {
+ switch (i) {
+ case objc_in:
+ DS.setObjcDeclQualifier(ObjcDeclSpec::DQ_In);
+ ConsumeToken();
+ found = true;
+ break;
+ case objc_out:
+ DS.setObjcDeclQualifier(ObjcDeclSpec::DQ_Out);
+ ConsumeToken();
+ found = true;
+ break;
+ case objc_inout:
+ DS.setObjcDeclQualifier(ObjcDeclSpec::DQ_Inout);
+ ConsumeToken();
+ found = true;
+ break;
+ case objc_oneway:
+ DS.setObjcDeclQualifier(ObjcDeclSpec::DQ_Oneway);
+ ConsumeToken();
+ found = true;
+ break;
+ case objc_bycopy:
+ DS.setObjcDeclQualifier(ObjcDeclSpec::DQ_Bycopy);
+ ConsumeToken();
+ found = true;
+ break;
+ case objc_byref:
+ DS.setObjcDeclQualifier(ObjcDeclSpec::DQ_Byref);
+ ConsumeToken();
+ found = true;
+ break;
+ }
+ if (found)
+ break;
+ }
+ }
+ }
+ }
+}
+
/// ParseTag - Parse "struct-or-union-or-class-or-enum identifier[opt]", where
/// the first token has already been read and has been turned into an instance
/// of DeclSpec::TST (TagType). This returns true if there is an error parsing,
}
}
-/// objc-type-qualifier: one of
-/// in out inout bycopy byref oneway
-///
-bool Parser::isObjCTypeQualifier() {
- if (Tok.is(tok::identifier)) {
- const IdentifierInfo *II = Tok.getIdentifierInfo();
- for (unsigned i = 0; i < objc_NumQuals; ++i)
- if (II == ObjcTypeQuals[i]) return true;
- }
- return false;
-}
-
/// property-attrlist: one of
/// readonly getter setter assign retain copy nonatomic
///
SourceLocation LParenLoc = ConsumeParen(), RParenLoc;
TypeTy *Ty = 0;
- while (isObjCTypeQualifier())
- ConsumeToken();
+ // Parse type qualifiers, in, inout, etc.
+ ObjcDeclSpec DS;
+ ParseObjcTypeQualifierList(DS);
if (isTypeSpecifierQualifier()) {
Ty = ParseTypeName();
Diag(Tok, diag::ext_empty_source_file);
// Initialization for Objective-C context sensitive keywords recognition.
- // Referenced in Parser::isObjCTypeQualifier.
+ // Referenced in Parser::ParseObjcTypeQualifierList.
if (getLang().ObjC1) {
ObjcTypeQuals[objc_in] = &PP.getIdentifierTable().get("in");
ObjcTypeQuals[objc_out] = &PP.getIdentifierTable().get("out");
08FB7793FE84155DC02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */;
+ compatibilityVersion = "Xcode 2.4";
hasScannedForEncodings = 1;
mainGroup = 08FB7794FE84155DC02AAC07 /* clang */;
projectDirPath = "";
}
};
-
+/// ObjcDeclSpec - This class captures information about
+/// "declaration specifiers" specific to objective-c
+class ObjcDeclSpec {
+public:
+ /// ObjcDeclQualifier - Qualifier used on types in method declarations
+ enum ObjcDeclQualifier {
+ DQ_None = 0x0,
+ DQ_In = 0x1,
+ DQ_Inout = 0x2,
+ DQ_Out = 0x4,
+ DQ_Bycopy = 0x8,
+ DQ_Byref = 0x10,
+ DQ_Oneway = 0x20
+ };
+
+ ObjcDeclSpec() : objcDeclQualifier(DQ_None) {}
+ ObjcDeclQualifier getObjcDeclQualifier() const { return objcDeclQualifier; }
+ void setObjcDeclQualifier(ObjcDeclQualifier DQVal)
+ { objcDeclQualifier = (ObjcDeclQualifier) (objcDeclQualifier | DQVal); }
+
+private:
+ ObjcDeclQualifier objcDeclQualifier : 6;
+};
+
/// DeclaratorChunk - One instance of this struct is used for each type in a
/// declarator that is parsed.
///
namespace clang {
class DeclSpec;
+ class ObjcDeclSpec;
class Declarator;
class AttributeList;
class Scope;
objc_NumQuals
};
IdentifierInfo *ObjcTypeQuals[objc_NumQuals];
- bool isObjCTypeQualifier();
// Definitions for ObjC2's @property attributes.
enum ObjCPropertyAttr {
objc_readonly=0, objc_getter, objc_setter, objc_assign,
DeclTy *ParseInitDeclaratorListAfterFirstDeclarator(Declarator &D);
void ParseDeclarationSpecifiers(DeclSpec &DS);
void ParseSpecifierQualifierList(DeclSpec &DS);
+
+ void ParseObjcTypeQualifierList(ObjcDeclSpec &DS);
bool ParseTag(DeclTy *&Decl, unsigned TagType, SourceLocation StartLoc);
void ParseEnumSpecifier(DeclSpec &DS);