diff options
author | Justas Janickas <Justas.Janickas@arm.com> | 2021-08-24 11:59:42 +0100 |
---|---|---|
committer | Justas Janickas <Justas.Janickas@arm.com> | 2021-08-31 10:08:38 +0100 |
commit | f9bc1b3bee557de5735c745f9558c47ca568bd96 (patch) | |
tree | c220ebdefbf7a73d4d28782b930a44220f1457d8 /clang/lib/Parse/ParseDecl.cpp | |
parent | c1184ca6eb97e0ac5f7b6cdcc99e3905d27f9d95 (diff) | |
download | llvm-f9bc1b3bee557de5735c745f9558c47ca568bd96.zip llvm-f9bc1b3bee557de5735c745f9558c47ca568bd96.tar.gz llvm-f9bc1b3bee557de5735c745f9558c47ca568bd96.tar.bz2 |
[OpenCL] Defines helper function for kernel language compatible OpenCL version
This change defines a helper function getOpenCLCompatibleVersion()
inside LangOptions class. The function contains mapping between
C++ for OpenCL versions and their corresponding compatible OpenCL
versions. This mapping function should be updated each time a new
C++ for OpenCL language version is introduced. The helper function
is expected to simplify conditions on OpenCL C and C++ for OpenCL
versions inside compiler code.
Code refactoring performed.
Differential Revision: https://reviews.llvm.org/D108693
Diffstat (limited to 'clang/lib/Parse/ParseDecl.cpp')
-rw-r--r-- | clang/lib/Parse/ParseDecl.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 7ff32e2..7cec896 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -3985,8 +3985,8 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, isInvalid = DS.SetTypeAltiVecBool(true, Loc, PrevSpec, DiagID, Policy); break; case tok::kw_pipe: - if (!getLangOpts().OpenCL || (getLangOpts().OpenCLVersion < 200 && - !getLangOpts().OpenCLCPlusPlus)) { + if (!getLangOpts().OpenCL || + getLangOpts().getOpenCLCompatibleVersion() < 200) { // OpenCL 2.0 and later define this keyword. OpenCL 1.2 and earlier // should support the "pipe" word as identifier. Tok.getIdentifierInfo()->revertTokenIDToIdentifier(); @@ -5171,8 +5171,8 @@ bool Parser::isDeclarationSpecifier(bool DisambiguatingWithExpression) { // OpenCL 2.0 and later define this keyword. case tok::kw_pipe: - return (getLangOpts().OpenCL && getLangOpts().OpenCLVersion >= 200) || - getLangOpts().OpenCLCPlusPlus; + return getLangOpts().OpenCL && + getLangOpts().getOpenCLCompatibleVersion() >= 200; case tok::identifier: // foo::bar // Unfortunate hack to support "Class.factoryMethod" notation. @@ -5702,8 +5702,8 @@ static bool isPtrOperatorToken(tok::TokenKind Kind, const LangOptions &Lang, return true; // OpenCL 2.0 and later define this keyword. - if (Kind == tok::kw_pipe && - ((Lang.OpenCL && Lang.OpenCLVersion >= 200) || Lang.OpenCLCPlusPlus)) + if (Kind == tok::kw_pipe && Lang.OpenCL && + Lang.getOpenCLCompatibleVersion() >= 200) return true; if (!Lang.CPlusPlus) |