[cfe-commits] r43580 - in /cfe/trunk: Parse/ParseDecl.cpp Parse/ParseObjc.cpp Parse/Parser.cpp clang.xcodeproj/project.pbxproj include/clang/Parse/DeclSpec.h include/clang/Parse/Parser.h
Fariborz Jahanian
fjahanian at apple.com
Wed Oct 31 14:59:44 PDT 2007
Author: fjahanian
Date: Wed Oct 31 16:59:43 2007
New Revision: 43580
URL: http://llvm.org/viewvc/llvm-project?rev=43580&view=rev
Log:
More infrastructure to recognize objective-c's type qualifiers (in,inout, etc.)
Modified:
cfe/trunk/Parse/ParseDecl.cpp
cfe/trunk/Parse/ParseObjc.cpp
cfe/trunk/Parse/Parser.cpp
cfe/trunk/clang.xcodeproj/project.pbxproj
cfe/trunk/include/clang/Parse/DeclSpec.h
cfe/trunk/include/clang/Parse/Parser.h
Modified: cfe/trunk/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseDecl.cpp?rev=43580&r1=43579&r2=43580&view=diff
==============================================================================
--- cfe/trunk/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/Parse/ParseDecl.cpp Wed Oct 31 16:59:43 2007
@@ -552,6 +552,58 @@
}
}
+/// 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,
Modified: cfe/trunk/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseObjc.cpp?rev=43580&r1=43579&r2=43580&view=diff
==============================================================================
--- cfe/trunk/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/Parse/ParseObjc.cpp Wed Oct 31 16:59:43 2007
@@ -451,18 +451,6 @@
}
}
-/// 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
///
@@ -489,8 +477,9 @@
SourceLocation LParenLoc = ConsumeParen(), RParenLoc;
TypeTy *Ty = 0;
- while (isObjCTypeQualifier())
- ConsumeToken();
+ // Parse type qualifiers, in, inout, etc.
+ ObjcDeclSpec DS;
+ ParseObjcTypeQualifierList(DS);
if (isTypeSpecifierQualifier()) {
Ty = ParseTypeName();
Modified: cfe/trunk/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/Parser.cpp?rev=43580&r1=43579&r2=43580&view=diff
==============================================================================
--- cfe/trunk/Parse/Parser.cpp (original)
+++ cfe/trunk/Parse/Parser.cpp Wed Oct 31 16:59:43 2007
@@ -235,7 +235,7 @@
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");
Modified: cfe/trunk/clang.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/clang.xcodeproj/project.pbxproj?rev=43580&r1=43579&r2=43580&view=diff
==============================================================================
--- cfe/trunk/clang.xcodeproj/project.pbxproj (original)
+++ cfe/trunk/clang.xcodeproj/project.pbxproj Wed Oct 31 16:59:43 2007
@@ -756,6 +756,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/DeclSpec.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/DeclSpec.h?rev=43580&r1=43579&r2=43580&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/DeclSpec.h (original)
+++ cfe/trunk/include/clang/Parse/DeclSpec.h Wed Oct 31 16:59:43 2007
@@ -277,7 +277,30 @@
}
};
-
+/// 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.
///
Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=43580&r1=43579&r2=43580&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Wed Oct 31 16:59:43 2007
@@ -19,6 +19,7 @@
namespace clang {
class DeclSpec;
+ class ObjcDeclSpec;
class Declarator;
class AttributeList;
class Scope;
@@ -284,7 +285,6 @@
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,
@@ -399,6 +399,8 @@
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);
More information about the cfe-commits
mailing list