Bring order to the OpenCL keywords

Avoid the gratuitous repurposing of C++ keyword 'private' by using a keyword
alias.

Also attempt to document the OpenCL keywords based on scraps of information
found online.

The purpose of this commit is to reduce impact on the C++ parser.

llvm-svn: 197511
This commit is contained in:
Alp Toker 2013-12-17 18:17:46 +00:00
parent b5769dbb86
commit de50ff3c4b
2 changed files with 13 additions and 26 deletions

View File

@ -296,7 +296,7 @@ KEYWORD(mutable , KEYCXX)
KEYWORD(namespace , KEYCXX)
KEYWORD(new , KEYCXX)
KEYWORD(operator , KEYCXX)
KEYWORD(private , KEYCXX|KEYOPENCL)
KEYWORD(private , KEYCXX)
KEYWORD(protected , KEYCXX)
KEYWORD(public , KEYCXX)
KEYWORD(reinterpret_cast , KEYCXX)
@ -451,24 +451,26 @@ KEYWORD(__thiscall , KEYALL)
KEYWORD(__forceinline , KEYALL)
KEYWORD(__unaligned , KEYMS)
// OpenCL-specific keywords
KEYWORD(__kernel , KEYOPENCL)
ALIAS("kernel", __kernel , KEYOPENCL)
KEYWORD(vec_step , KEYOPENCL|KEYALTIVEC)
KEYWORD(__private , KEYOPENCL)
// OpenCL address space qualifiers
KEYWORD(__global , KEYOPENCL)
KEYWORD(__local , KEYOPENCL)
KEYWORD(__constant , KEYOPENCL)
KEYWORD(__private , KEYOPENCL)
ALIAS("global", __global , KEYOPENCL)
ALIAS("local", __local , KEYOPENCL)
ALIAS("constant", __constant , KEYOPENCL)
ALIAS("private", __private , KEYOPENCL)
// OpenCL function qualifiers
KEYWORD(__kernel , KEYOPENCL)
ALIAS("kernel", __kernel , KEYOPENCL)
// OpenCL access qualifiers
KEYWORD(__read_only , KEYOPENCL)
KEYWORD(__write_only , KEYOPENCL)
KEYWORD(__read_write , KEYOPENCL)
ALIAS("read_only", __read_only , KEYOPENCL)
ALIAS("write_only", __write_only , KEYOPENCL)
ALIAS("read_write", __read_write , KEYOPENCL)
KEYWORD(__builtin_astype , KEYOPENCL)
// OpenCL C data types
KEYWORD(image1d_t , KEYOPENCL)
KEYWORD(image1d_array_t , KEYOPENCL)
KEYWORD(image1d_buffer_t , KEYOPENCL)
@ -477,6 +479,9 @@ KEYWORD(image2d_array_t , KEYOPENCL)
KEYWORD(image3d_t , KEYOPENCL)
KEYWORD(sampler_t , KEYOPENCL)
KEYWORD(event_t , KEYOPENCL)
// OpenCL builtins
KEYWORD(__builtin_astype , KEYOPENCL)
KEYWORD(vec_step , KEYOPENCL|KEYALTIVEC)
// Borland Extensions.
KEYWORD(__pascal , KEYALL)

View File

@ -633,7 +633,6 @@ void Parser::ParseOpenCLQualifiers(DeclSpec &DS) {
switch(Tok.getKind()) {
// OpenCL qualifiers:
case tok::kw___private:
case tok::kw_private:
DS.getAttributes().addNewInteger(
Actions.getASTContext(),
PP.getIdentifierInfo("address_space"), Loc, 0);
@ -3304,9 +3303,6 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
break;
// OpenCL qualifiers:
case tok::kw_private:
if (!getLangOpts().OpenCL)
goto DoneWithDeclSpec;
case tok::kw___private:
case tok::kw___global:
case tok::kw___local:
@ -4030,12 +4026,7 @@ void Parser::ParseEnumBody(SourceLocation StartLoc, Decl *EnumDecl) {
bool Parser::isTypeQualifier() const {
switch (Tok.getKind()) {
default: return false;
// type-qualifier only in OpenCL
case tok::kw_private:
return getLangOpts().OpenCL;
// type-qualifier
// type-qualifier
case tok::kw_const:
case tok::kw_volatile:
case tok::kw_restrict:
@ -4217,9 +4208,6 @@ bool Parser::isTypeSpecifierQualifier() {
return true;
case tok::kw_private:
return getLangOpts().OpenCL;
// C11 _Atomic
case tok::kw__Atomic:
return true;
@ -4235,9 +4223,6 @@ bool Parser::isDeclarationSpecifier(bool DisambiguatingWithExpression) {
switch (Tok.getKind()) {
default: return false;
case tok::kw_private:
return getLangOpts().OpenCL;
case tok::identifier: // foo::bar
// Unfortunate hack to support "Class.factoryMethod" notation.
if (getLangOpts().ObjC1 && NextToken().is(tok::period))
@ -4561,9 +4546,6 @@ void Parser::ParseTypeQualifierListOpt(DeclSpec &DS,
break;
// OpenCL qualifiers:
case tok::kw_private:
if (!getLangOpts().OpenCL)
goto DoneWithTypeQuals;
case tok::kw___private:
case tok::kw___global:
case tok::kw___local: