-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[OpenMP][Flang] Fix semantic check and scoping for declare mappers #139593
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1389,8 +1389,28 @@ TYPE_PARSER( | |
TYPE_PARSER(sourced(construct<OpenMPDeclareTargetConstruct>( | ||
verbatim("DECLARE TARGET"_tok), Parser<OmpDeclareTargetSpecifier>{}))) | ||
|
||
static OmpMapperSpecifier ConstructOmpMapperSpecifier( | ||
std::optional<Name> &&mapperName, TypeSpec &&typeSpec, Name &&varName) { | ||
// If a name is present, parse: name ":" typeSpec "::" name | ||
// This matches the syntax: <mapper-name> : <type-spec> :: <variable-name> | ||
if (mapperName.has_value() && mapperName->ToString() != "default") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The function ConstructOmpMapperSpecifier continues to accept a std::optional for the mapper name while the parse tree now uses a std::string. Consider aligning the interface to accept a std::string (or handle an empty string) for consistency. Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||
return OmpMapperSpecifier{ | ||
mapperName->ToString(), std::move(typeSpec), std::move(varName)}; | ||
} | ||
// If the name is missing, use the DerivedTypeSpec name to construct the | ||
// default mapper name. | ||
// This matches the syntax: <type-spec> :: <variable-name> | ||
if (auto *derived = std::get_if<DerivedTypeSpec>(&typeSpec.u)) { | ||
return OmpMapperSpecifier{ | ||
std::get<Name>(derived->t).ToString() + ".omp.default.mapper", | ||
std::move(typeSpec), std::move(varName)}; | ||
} | ||
return OmpMapperSpecifier{std::string("omp.default.mapper"), | ||
std::move(typeSpec), std::move(varName)}; | ||
} | ||
|
||
// mapper-specifier | ||
TYPE_PARSER(construct<OmpMapperSpecifier>( | ||
TYPE_PARSER(applyFunction<OmpMapperSpecifier>(ConstructOmpMapperSpecifier, | ||
maybe(name / ":" / !":"_tok), typeSpec / "::", name)) | ||
|
||
// OpenMP 5.2: 5.8.8 Declare Mapper Construct | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Given the change from std::optional to std::string for mapper names, adding a comment to explain the rationale for this decision would improve clarity and help maintain consistency across the codebase.
Copilot uses AI. Check for mistakes.