-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[SystemZ][z/OS] Add visibility features for z/OS (eg. _Export, pragma export) #111035
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
base: main
Are you sure you want to change the base?
Changes from 9 commits
e8d355c
6cf4355
e1cbba0
b23cfff
39a1411
9cfc3cc
e0cb769
82e9962
e7e560a
b5c7f01
b99182f
5d40056
266840a
1deb06a
5fb85ea
0fcfcfe
b54bd17
6ba783c
b407888
a1faeca
7871a6d
9672490
a156ebd
c6eb30f
5f0a685
a5187aa
507960b
aa8ffc7
34b2109
8432125
1198786
9e23c5d
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 | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6863,6 +6863,27 @@ attribute requires a string literal argument to identify the handle being releas | |||||||||||||||||||||||||
| }]; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| def zOSExportDocs : Documentation { | ||||||||||||||||||||||||||
| let Category = DocCatFunction; | ||||||||||||||||||||||||||
| let Content = [{ | ||||||||||||||||||||||||||
| Use the _Export keyword with a function name or external variable to declare | ||||||||||||||||||||||||||
| that it is to be exported (made available to other modules). You must define | ||||||||||||||||||||||||||
| the object name in the same translation unit in which you use the _Export | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| the object name in the same translation unit in which you use the _Export | |
| the object name in the same translation unit in which you use the ``_Export`` |
Outdated
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.
| This statement exports the function anthony, if you define the function in the | |
| translation unit. The _Export keyword must immediately precede the object name. | |
| If you apply the _Export keyword to a class, the compiler automatically exports | |
| all static data members and member functions of the class. However, if you want | |
| it to apply to individual class members, then you must apply it to each member | |
| that can be referenced. | |
| This statement exports the function ``anthony``, if you define the function in the | |
| translation unit. The ``_Export`` keyword must immediately precede the declaration name. | |
| If you apply the ``_Export`` keyword to a class, the compiler automatically exports | |
| all static data members and member functions of the class. However, if you want | |
| it to apply to individual class members, then you must apply it to each member | |
| that can be referenced. |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -398,6 +398,8 @@ class DeclSpec { | |||||
| unsigned FS_virtual_specified : 1; | ||||||
| LLVM_PREFERRED_TYPE(bool) | ||||||
| unsigned FS_noreturn_specified : 1; | ||||||
| LLVM_PREFERRED_TYPE(bool) | ||||||
| unsigned export_specified : 1; | ||||||
|
||||||
| unsigned export_specified : 1; | |
| unsigned ExportSpecified : 1; // zOS extension |
Outdated
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.
| SourceLocation exportLoc; | |
| SourceLocation ExportLoc; |
Outdated
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.
| /// Indicates whether this is set as _Export | |
| /// Indicates whether this is set as _Export. |
Outdated
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.
| unsigned ExportSpecified : 1; | |
| unsigned ExportSpecified : 1; // zOS extension |
Outdated
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.
| /// The source location of the _Export keyword on this declarator | |
| /// The source location of the _Export keyword on this declarator. |
Outdated
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.
| /// Set this declarator as _Export | |
| /// Set this declarator as _Export. |
I'll stop commenting on these now, can you take a pass over all the new comments you've added and ensure they have appropriate trailing punctuation?
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1906,6 +1906,36 @@ class Sema final : public SemaBase { | |
| ActOnPragmaMSFunction(SourceLocation Loc, | ||
| const llvm::SmallVectorImpl<StringRef> &NoBuiltins); | ||
|
|
||
| /// A label from a C++ #pragma export, for a symbol that we | ||
| /// haven't seen the declaration for yet. The TypeList is the argument list | ||
| /// the function must match if HasTypeList is true. | ||
| struct SymbolLabel { | ||
| std::optional<SmallVector<QualType, 4>> TypeList; | ||
| StringRef MappedName; | ||
| SourceLocation NameLoc; | ||
| bool HasTypeList; | ||
| Qualifiers CVQual; | ||
| }; | ||
|
|
||
| typedef SmallVector<SymbolLabel, 1> PendingSymbolOverloads; | ||
| typedef llvm::DenseMap<NestedNameSpecifier *, PendingSymbolOverloads> | ||
| SymbolNames; | ||
| SymbolNames PendingExportNames; | ||
|
|
||
| FunctionDecl *tryFunctionLookUp(NestedNameSpecifier *NestedName, | ||
|
||
| SourceLocation NameLoc); | ||
|
|
||
| /// trySymbolLookUp try to look up a decl matching the nested specifier | ||
| /// with optional type list. | ||
| NamedDecl *trySymbolLookUp(NestedNameSpecifier *NestedName, | ||
|
||
| const clang::Sema::SymbolLabel &Label); | ||
|
|
||
| /// ActonPragmaExport - called on well-formed '\#pragma export'. | ||
| void ActOnPragmaExport(NestedNameSpecifier *NestedId, | ||
| SourceLocation ExportNameLoc, | ||
| std::optional<SmallVector<QualType, 4>> &&TypeList, | ||
| Qualifiers CVQual); | ||
|
|
||
| /// Only called on function definitions; if there is a pragma in scope | ||
| /// with the effect of a range-based optnone, consider marking the function | ||
| /// with attribute optnone. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4449,6 +4449,12 @@ void Parser::ParseDeclarationSpecifiers( | |
| isInvalid = DS.setFunctionSpecNoreturn(Loc, PrevSpec, DiagID); | ||
| break; | ||
|
|
||
| case tok::kw__Export: | ||
| // If we find kw__Export, it is being applied to a var or function | ||
| // This will be handled in ParseDeclaratorInternal() | ||
|
||
| goto DoneWithDeclSpec; | ||
|
Collaborator
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. Does this mean
Contributor
Author
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.
Collaborator
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.
@perry-ca, I don't see any test in this PR for int (*_Export x)(void) = 0;Is the above accepted with this PR? Which conceptual model is being implemented here?
Contributor
Author
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 test case above is valid and exports x. I'll add a test case to cover this. You are correct. This keyword is expected to appear right before the identifier of the symbol being exported. |
||
| break; | ||
|
|
||
| // friend | ||
| case tok::kw_friend: | ||
| if (DSContext == DeclSpecContext::DSC_class) { | ||
|
|
@@ -6174,6 +6180,7 @@ bool Parser::isDeclarationSpecifier( | |
| case tok::kw_virtual: | ||
| case tok::kw_explicit: | ||
| case tok::kw__Noreturn: | ||
| case tok::kw__Export: | ||
|
|
||
| // alignment-specifier | ||
| case tok::kw__Alignas: | ||
|
|
@@ -6765,6 +6772,17 @@ void Parser::ParseDeclaratorInternal(Declarator &D, | |
|
|
||
| tok::TokenKind Kind = Tok.getKind(); | ||
|
|
||
| // If this variable or function is marked as _Export, set the bit | ||
| if (Kind == tok::kw__Export) { | ||
| SourceLocation loc = ConsumeToken(); | ||
| D.SetExport(loc); | ||
| D.SetRangeEnd(loc); | ||
|
|
||
| if (DirectDeclParser) | ||
| (this->*DirectDeclParser)(D); | ||
| return; | ||
| } | ||
|
|
||
| if (D.getDeclSpec().isTypeSpecPipe() && !isPipeDeclarator(D)) { | ||
| DeclSpec DS(AttrFactory); | ||
| ParseTypeQualifierListOpt(DS); | ||
|
|
||
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.