r197511 - Bring order to the OpenCL keywords
Alp Toker
alp at nuanti.com
Tue Dec 17 10:17:46 PST 2013
Author: alp
Date: Tue Dec 17 12:17:46 2013
New Revision: 197511
URL: http://llvm.org/viewvc/llvm-project?rev=197511&view=rev
Log:
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.
Modified:
cfe/trunk/include/clang/Basic/TokenKinds.def
cfe/trunk/lib/Parse/ParseDecl.cpp
Modified: cfe/trunk/include/clang/Basic/TokenKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=197511&r1=197510&r2=197511&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/TokenKinds.def (original)
+++ cfe/trunk/include/clang/Basic/TokenKinds.def Tue Dec 17 12:17:46 2013
@@ -296,7 +296,7 @@ KEYWORD(mutable , KE
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 , KE
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 , KE
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)
Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=197511&r1=197510&r2=197511&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Tue Dec 17 12:17:46 2013
@@ -633,7 +633,6 @@ void Parser::ParseOpenCLQualifiers(DeclS
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(
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(SourceLocatio
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
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(D
break;
// OpenCL qualifiers:
- case tok::kw_private:
- if (!getLangOpts().OpenCL)
- goto DoneWithTypeQuals;
case tok::kw___private:
case tok::kw___global:
case tok::kw___local:
More information about the cfe-commits
mailing list