Skip to content

Commit 8ce8105

Browse files
committed
[ObjC] Stop hard-coding the list of keywords that are allowed in
selectors The design intent is that ObjC selector pieces can be arbitrary keywords, including basic C keywords like `if`, and the grammar permits this and makes it unambiguous. Use TokenKinds.def to autogenerate the list of allowed keywords instead. rdar://150383689
1 parent bf59716 commit 8ce8105

File tree

2 files changed

+7
-69
lines changed

2 files changed

+7
-69
lines changed

clang/lib/Parse/ParseObjc.cpp

Lines changed: 2 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,75 +1095,8 @@ IdentifierInfo *Parser::ParseObjCSelectorPiece(SourceLocation &SelectorLoc) {
10951095
}
10961096

10971097
case tok::identifier:
1098-
case tok::kw_asm:
1099-
case tok::kw_auto:
1100-
case tok::kw_bool:
1101-
case tok::kw_break:
1102-
case tok::kw_case:
1103-
case tok::kw_catch:
1104-
case tok::kw_char:
1105-
case tok::kw_class:
1106-
case tok::kw_const:
1107-
case tok::kw_const_cast:
1108-
case tok::kw_continue:
1109-
case tok::kw_default:
1110-
case tok::kw_delete:
1111-
case tok::kw_do:
1112-
case tok::kw_double:
1113-
case tok::kw_dynamic_cast:
1114-
case tok::kw_else:
1115-
case tok::kw_enum:
1116-
case tok::kw_explicit:
1117-
case tok::kw_export:
1118-
case tok::kw_extern:
1119-
case tok::kw_false:
1120-
case tok::kw_float:
1121-
case tok::kw_for:
1122-
case tok::kw_friend:
1123-
case tok::kw_goto:
1124-
case tok::kw_if:
1125-
case tok::kw_inline:
1126-
case tok::kw_int:
1127-
case tok::kw_long:
1128-
case tok::kw_mutable:
1129-
case tok::kw_namespace:
1130-
case tok::kw_new:
1131-
case tok::kw_operator:
1132-
case tok::kw_private:
1133-
case tok::kw_protected:
1134-
case tok::kw_public:
1135-
case tok::kw_register:
1136-
case tok::kw_reinterpret_cast:
1137-
case tok::kw_restrict:
1138-
case tok::kw_return:
1139-
case tok::kw_short:
1140-
case tok::kw_signed:
1141-
case tok::kw_sizeof:
1142-
case tok::kw_static:
1143-
case tok::kw_static_cast:
1144-
case tok::kw_struct:
1145-
case tok::kw_switch:
1146-
case tok::kw_template:
1147-
case tok::kw_this:
1148-
case tok::kw_throw:
1149-
case tok::kw_true:
1150-
case tok::kw_try:
1151-
case tok::kw_typedef:
1152-
case tok::kw_typeid:
1153-
case tok::kw_typename:
1154-
case tok::kw_typeof:
1155-
case tok::kw_union:
1156-
case tok::kw_unsigned:
1157-
case tok::kw_using:
1158-
case tok::kw_virtual:
1159-
case tok::kw_void:
1160-
case tok::kw_volatile:
1161-
case tok::kw_wchar_t:
1162-
case tok::kw_while:
1163-
case tok::kw__Bool:
1164-
case tok::kw__Complex:
1165-
case tok::kw___alignof:
1166-
case tok::kw___auto_type:
1098+
#define KEYWORD(X,Y) case tok::kw_ ## X:
1099+
#include "clang/Basic/TokenKinds.def"
11671100
IdentifierInfo *II = Tok.getIdentifierInfo();
11681101
SelectorLoc = ConsumeToken();
11691102
return II;

clang/test/SemaObjCXX/cxxoperator-selector.mm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,10 @@ - (id) and{return 0; };
1919
- (id) xor{return 0; };
2020
- (id) or{return 0; };
2121

22+
- (void)decltype {}
23+
- (void)constexpr {}
24+
- (void)noexcept {}
25+
- (void)nullptr {}
26+
2227
- (void)dataSetForValuesBetween:(NSDate *)startDate and:(NSDate *)endDate { return; }
2328
@end

0 commit comments

Comments
 (0)