clang 22.0.0git
ParseOpenMP.cpp File Reference

This file implements parsing of all OpenMP directives and clauses. More...

#include "clang/AST/ASTContext.h"
#include "clang/AST/OpenMPClause.h"
#include "clang/Basic/DiagnosticParse.h"
#include "clang/Basic/OpenMPKinds.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/TokenKinds.h"
#include "clang/Parse/Parser.h"
#include "clang/Parse/RAIIObjectsForParser.h"
#include "clang/Sema/EnterExpressionEvaluationContext.h"
#include "clang/Sema/Scope.h"
#include "clang/Sema/SemaAMDGPU.h"
#include "clang/Sema/SemaCodeCompletion.h"
#include "clang/Sema/SemaOpenMP.h"
#include "llvm/ADT/SmallBitVector.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Frontend/OpenMP/DirectiveNameParser.h"
#include "llvm/Frontend/OpenMP/OMPAssume.h"
#include "llvm/Frontend/OpenMP/OMPContext.h"
#include <optional>

Go to the source code of this file.

Functions

static OpenMPDirectiveKind checkOpenMPDirectiveName (Parser &P, SourceLocation Loc, OpenMPDirectiveKind Kind, StringRef Name)
static OpenMPDirectiveKind parseOpenMPDirectiveKind (Parser &P)
static DeclarationName parseOpenMPReductionId (Parser &P)
static bool parseDeclareSimdClauses (Parser &P, OMPDeclareSimdDeclAttr::BranchStateTy &BS, ExprResult &SimdLen, SmallVectorImpl< Expr * > &Uniforms, SmallVectorImpl< Expr * > &Aligneds, SmallVectorImpl< Expr * > &Alignments, SmallVectorImpl< Expr * > &Linears, SmallVectorImpl< unsigned > &LinModifiers, SmallVectorImpl< Expr * > &Steps)
 Parses clauses for 'declare simd' directive.
static bool checkExtensionProperty (Parser &P, SourceLocation Loc, OMPTraitProperty &TIProperty, OMPTraitSelector &TISelector, llvm::StringMap< SourceLocation > &Seen)
static ExprResult parseContextScore (Parser &P)
 Parse optional 'score' '(' <expr> ')' ':'.
static std::optional< SimpleClauseData > parseOpenMPSimpleClause (Parser &P, OpenMPClauseKind Kind)
static bool ParseReductionId (Parser &P, CXXScopeSpec &ReductionIdScopeSpec, UnqualifiedId &ReductionId)
static OpenMPMapModifierKind isMapModifier (Parser &P)
 Checks if the token is a valid map-type-modifier.
static OpenMPMapClauseKind isMapType (Parser &P)
 Checks if the token is a valid map-type.
static void parseMapType (Parser &P, SemaOpenMP::OpenMPVarListDataTy &Data)
 Parse map-type in map clause.
static bool parseStepSize (Parser &P, SemaOpenMP::OpenMPVarListDataTy &Data, OpenMPClauseKind CKind, SourceLocation ELoc)
 Parse step size expression.
static ExprResult parseOpenMPAllocateClauseModifiers (Parser &P, OpenMPClauseKind Kind, SemaOpenMP::OpenMPVarListDataTy &Data)
 Parse 'allocate' clause modifiers.

Detailed Description

This file implements parsing of all OpenMP directives and clauses.

Definition in file ParseOpenMP.cpp.

Function Documentation

◆ checkExtensionProperty()

bool checkExtensionProperty ( Parser & P,
SourceLocation Loc,
OMPTraitProperty & TIProperty,
OMPTraitSelector & TISelector,
llvm::StringMap< SourceLocation > & Seen )
static

◆ checkOpenMPDirectiveName()

OpenMPDirectiveKind checkOpenMPDirectiveName ( Parser & P,
SourceLocation Loc,
OpenMPDirectiveKind Kind,
StringRef Name )
static

Definition at line 59 of file ParseOpenMP.cpp.

References clang::Parser::Diag(), and clang::Parser::getLangOpts().

Referenced by parseOpenMPDirectiveKind().

◆ isMapModifier()

OpenMPMapModifierKind isMapModifier ( Parser & P)
static

Checks if the token is a valid map-type-modifier.

FIXME: It will return an OpenMPMapClauseKind if that's what it parses.

Definition at line 4028 of file ParseOpenMP.cpp.

References clang::Parser::getCurToken(), clang::Parser::getLangOpts(), clang::getOpenMPSimpleClauseType(), clang::Parser::getPreprocessor(), clang::Preprocessor::getSpelling(), clang::OMPC_MAP_MODIFIER_unknown, and Tok.

Referenced by clang::Parser::parseMapTypeModifiers().

◆ isMapType()

OpenMPMapClauseKind isMapType ( Parser & P)
static

Checks if the token is a valid map-type.

If it is not MapType kind, OMPC_MAP_unknown is returned.

Definition at line 4167 of file ParseOpenMP.cpp.

References clang::Parser::getCurToken(), clang::Parser::getLangOpts(), clang::getOpenMPSimpleClauseType(), clang::Parser::getPreprocessor(), clang::Preprocessor::getSpelling(), clang::OMPC_MAP_unknown, and Tok.

Referenced by parseMapType(), and clang::Parser::parseMapTypeModifiers().

◆ parseContextScore()

◆ parseDeclareSimdClauses()

bool parseDeclareSimdClauses ( Parser & P,
OMPDeclareSimdDeclAttr::BranchStateTy & BS,
ExprResult & SimdLen,
SmallVectorImpl< Expr * > & Uniforms,
SmallVectorImpl< Expr * > & Aligneds,
SmallVectorImpl< Expr * > & Alignments,
SmallVectorImpl< Expr * > & Linears,
SmallVectorImpl< unsigned > & LinModifiers,
SmallVectorImpl< Expr * > & Steps )
static

Parses clauses for 'declare simd' directive.

clause: 'inbranch' | 'notinbranch' 'simdlen' '(' <expr> ')' { 'uniform' '(' <argument_list> ')' } { 'aligned '(' <argument_list> [ ':' <alignment> ] ')' } { 'linear '(' <argument_list> [ ':' <step> ] ')' }

Definition at line 658 of file ParseOpenMP.cpp.

References clang::SemaOpenMP::CheckOpenMPLinearModifier(), clang::Parser::ConsumeToken(), clang::Data, clang::Parser::Diag(), clang::Parser::getActions(), clang::Parser::getCurToken(), clang::Sema::getLangOpts(), clang::IdentifierInfo::getName(), clang::ActionResult< PtrTy, Compress >::isInvalid(), clang::ActionResult< PtrTy, Compress >::isUsable(), clang::OMPC_LINEAR_unknown, clang::Sema::OpenMP(), clang::Parser::ParseOpenMPParensExpr(), clang::Parser::ParseOpenMPVarList(), and Tok.

◆ parseMapType()

void parseMapType ( Parser & P,
SemaOpenMP::OpenMPVarListDataTy & Data )
static

Parse map-type in map clause.

map([ [map-type-modifier[,] [map-type-modifier[,] ...] map-type : ] list) where, map-type ::= to | from | tofrom | alloc | release | delete

Definition at line 4185 of file ParseOpenMP.cpp.

References clang::Parser::ConsumeToken(), clang::Data, clang::Parser::Diag(), clang::Parser::getCurToken(), isMapType(), clang::OMPC_MAP_unknown, and Tok.

Referenced by clang::Parser::ParseOpenMPVarList().

◆ parseOpenMPAllocateClauseModifiers()

◆ parseOpenMPDirectiveKind()

◆ parseOpenMPReductionId()

◆ parseOpenMPSimpleClause()

◆ ParseReductionId()

◆ parseStepSize()