Skip to content

Commit 0fcfcfe

Browse files
committed
address comments
1 parent 5fb85ea commit 0fcfcfe

File tree

15 files changed

+74
-58
lines changed

15 files changed

+74
-58
lines changed

clang/include/clang/Basic/AttrDocs.td

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7505,18 +7505,18 @@ attribute requires a string literal argument to identify the handle being releas
75057505
def zOSExportDocs : Documentation {
75067506
let Category = DocCatFunction;
75077507
let Content = [{
7508-
Use the _Export keyword with a function name or external variable to declare
7508+
Use the ``_Export`` keyword on a function or external variable to declare
75097509
that it is to be exported (made available to other modules). You must define
7510-
the object name in the same translation unit in which you use the _Export
7510+
the object name in the same translation unit in which you use the ``_Export``
75117511
keyword. For example:
75127512

75137513
.. code-block:: c
75147514

75157515
int _Export anthony(float);
75167516

7517-
This statement exports the function anthony, if you define the function in the
7518-
translation unit. The _Export keyword must immediately precede the object name.
7519-
If you apply the _Export keyword to a class, the compiler automatically exports
7517+
This statement exports the function ``anthony``, if you define the function in the
7518+
translation unit. The ``_Export`` keyword must immediately precede the declaration name.
7519+
If you apply the ``_Export`` keyword to a class, the compiler automatically exports
75207520
all static data members and member functions of the class. However, if you want
75217521
it to apply to individual class members, then you must apply it to each member
75227522
that can be referenced.

clang/include/clang/Parse/Parser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ class Parser : public CodeCompletionHandler {
857857

858858
/// Helper functions for handling zOS pragmas.
859859
NestedNameSpecifier *zOSParseIdentifier(StringRef PragmaName,
860-
IdentifierInfo *IdentName);
860+
const IdentifierInfo *IdentName);
861861
bool zOSParseParameterList(StringRef PragmaName,
862862
std::optional<SmallVector<QualType, 4>> &TypeList,
863863
Qualifiers &CVQual);

clang/include/clang/Sema/DeclSpec.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ class DeclSpec {
399399
LLVM_PREFERRED_TYPE(bool)
400400
unsigned FS_noreturn_specified : 1;
401401
LLVM_PREFERRED_TYPE(bool)
402-
unsigned export_specified : 1;
402+
unsigned ExportSpecified : 1; // z/OS extension
403403

404404
// friend-specifier
405405
LLVM_PREFERRED_TYPE(bool)
@@ -446,7 +446,7 @@ class DeclSpec {
446446
SourceLocation FS_forceinlineLoc;
447447
SourceLocation FriendLoc, ModulePrivateLoc, ConstexprLoc;
448448
SourceLocation TQ_pipeLoc;
449-
SourceLocation exportLoc;
449+
SourceLocation ExportLoc;
450450

451451
WrittenBuiltinSpecs writtenBS;
452452
void SaveWrittenBuiltinSpecs();
@@ -495,7 +495,7 @@ class DeclSpec {
495495
TypeSpecPipe(false), TypeSpecSat(false), ConstrainedAuto(false),
496496
TypeQualifiers(TQ_unspecified), FS_inline_specified(false),
497497
FS_forceinline_specified(false), FS_virtual_specified(false),
498-
FS_noreturn_specified(false), export_specified(false),
498+
FS_noreturn_specified(false), ExportSpecified(false),
499499
FriendSpecifiedFirst(false), ConstexprSpecifier(static_cast<unsigned>(
500500
ConstexprSpecKind::Unspecified)),
501501
Attrs(attrFactory), writtenBS(), ObjCQualifiers(nullptr) {}
@@ -664,8 +664,8 @@ class DeclSpec {
664664
bool isNoreturnSpecified() const { return FS_noreturn_specified; }
665665
SourceLocation getNoreturnSpecLoc() const { return FS_noreturnLoc; }
666666

667-
bool isExportSpecified() const { return export_specified; }
668-
SourceLocation getExportSpecLoc() const { return exportLoc; }
667+
bool isExportSpecified() const { return ExportSpecified; }
668+
SourceLocation getExportSpecLoc() const { return ExportLoc; }
669669

670670
void ClearFunctionSpecs() {
671671
FS_inline_specified = false;
@@ -1964,9 +1964,9 @@ class Declarator {
19641964
LLVM_PREFERRED_TYPE(bool)
19651965
unsigned InlineStorageUsed : 1;
19661966

1967-
/// Indicates whether this is set as _Export
1967+
/// Indicates whether this is set as _Export.
19681968
LLVM_PREFERRED_TYPE(bool)
1969-
unsigned ExportSpecified : 1;
1969+
unsigned ExportSpecified : 1; // z/OS extension
19701970

19711971
/// Indicates whether this declarator has an initializer.
19721972
LLVM_PREFERRED_TYPE(bool)
@@ -2014,7 +2014,7 @@ class Declarator {
20142014
/// this declarator as a parameter pack.
20152015
SourceLocation EllipsisLoc;
20162016

2017-
/// The source location of the _Export keyword on this declarator
2017+
/// The source location of the _Export keyword on this declarator.
20182018
SourceLocation ExportLoc;
20192019

20202020
Expr *PackIndexingExpr;
@@ -2126,13 +2126,13 @@ class Declarator {
21262126
Range.setEnd(SR.getEnd());
21272127
}
21282128

2129-
/// Set this declarator as _Export
2129+
/// Set this declarator as _Export.
21302130
void SetExport(SourceLocation Loc) {
21312131
ExportSpecified = true;
21322132
ExportLoc = Loc;
21332133
}
21342134

2135-
/// Whether this declarator is marked as _Export
2135+
/// Whether this declarator is marked as _Export.
21362136
bool IsExport() const { return ExportSpecified; }
21372137

21382138
/// Get the location of the _Export keyword
@@ -2157,6 +2157,7 @@ class Declarator {
21572157
ExportSpecified = false;
21582158
CommaLoc = SourceLocation();
21592159
EllipsisLoc = SourceLocation();
2160+
ExportLoc = SourceLocation();
21602161
PackIndexingExpr = nullptr;
21612162
}
21622163

clang/lib/Parse/ParseDecl.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4457,8 +4457,7 @@ void Parser::ParseDeclarationSpecifiers(
44574457
break;
44584458

44594459
case tok::kw__Export:
4460-
// If we find kw__Export, it is being applied to a var or function
4461-
// This will be handled in ParseDeclaratorInternal()
4460+
// We're done with the declaration-specifiers.
44624461
goto DoneWithDeclSpec;
44634462
break;
44644463

@@ -6187,7 +6186,9 @@ bool Parser::isDeclarationSpecifier(
61876186
case tok::kw_virtual:
61886187
case tok::kw_explicit:
61896188
case tok::kw__Noreturn:
6189+
#if SDP // need this in declspec?
61906190
case tok::kw__Export:
6191+
#endif
61916192

61926193
// alignment-specifier
61936194
case tok::kw__Alignas:

clang/lib/Parse/ParsePragma.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,8 +1417,9 @@ bool Parser::HandlePragmaMSAllocText(StringRef PragmaName,
14171417
return true;
14181418
}
14191419

1420-
NestedNameSpecifier *Parser::zOSParseIdentifier(StringRef PragmaName,
1421-
IdentifierInfo *IdentName) {
1420+
NestedNameSpecifier *
1421+
Parser::zOSParseIdentifier(StringRef PragmaName,
1422+
const IdentifierInfo *IdentName) {
14221423
NestedNameSpecifier *NestedId = nullptr;
14231424
if (Tok.is(tok::coloncolon)) {
14241425
NestedId = NestedNameSpecifier::Create(Actions.Context, IdentName);
@@ -1435,14 +1436,13 @@ NestedNameSpecifier *Parser::zOSParseIdentifier(StringRef PragmaName,
14351436
}
14361437
while (Tok.is(tok::coloncolon)) {
14371438
PP.Lex(Tok);
1438-
IdentName = Tok.getIdentifierInfo();
1439+
IdentifierInfo *II = Tok.getIdentifierInfo();
14391440
if (Tok.isNot(tok::identifier)) {
14401441
PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_identifier)
14411442
<< PragmaName;
14421443
return nullptr;
14431444
}
1444-
NestedId =
1445-
NestedNameSpecifier::Create(Actions.Context, NestedId, IdentName);
1445+
NestedId = NestedNameSpecifier::Create(Actions.Context, NestedId, II);
14461446
PP.Lex(Tok);
14471447
}
14481448
return NestedId;
@@ -1455,12 +1455,14 @@ bool Parser::zOSParseParameterList(
14551455
TypeList = SmallVector<QualType, 4>();
14561456
PP.Lex(Tok);
14571457
while (Tok.isNot(tok::eof) && !Tok.is(tok::r_paren)) {
1458-
//SourceRange MatchingCTypeRange;
14591458
TypeResult TResult = ParseTypeName(nullptr, DeclaratorContext::Prototype);
14601459
if (!TResult.isInvalid()) {
14611460
QualType QT = TResult.get().get();
1462-
if (!QT.getTypePtr()->isVoidType())
1461+
if (!QT.getTypePtr()->isVoidType()) {
1462+
fprintf(stderr, "SDP: paramType -\n");
1463+
QT.getCanonicalType()->dump();
14631464
TypeList->push_back(QT);
1465+
}
14641466
}
14651467
if (Tok.is(tok::comma) || Tok.is(tok::identifier))
14661468
PP.Lex(Tok);

clang/lib/Parse/ParseStmt.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,11 @@ StmtResult Parser::ParseStatementOrDeclarationAfterAttributes(
538538
case tok::annot_pragma_attribute:
539539
HandlePragmaAttribute();
540540
return StmtEmpty();
541+
case tok::annot_pragma_export:
542+
ProhibitAttributes(CXX11Attrs);
543+
ProhibitAttributes(GNUAttrs);
544+
HandlePragmaExport();
545+
return StmtEmpty();
541546
}
542547

543548
// If we reached this code, the statement must end in a semicolon.
@@ -1122,6 +1127,9 @@ void Parser::ParseCompoundStatementLeadingPragmas() {
11221127
case tok::annot_pragma_dump:
11231128
HandlePragmaDump();
11241129
break;
1130+
case tok::annot_pragma_export:
1131+
HandlePragmaExport();
1132+
break;
11251133
default:
11261134
checkForPragmas = false;
11271135
break;

clang/lib/Sema/DeclSpec.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,8 +1105,8 @@ bool DeclSpec::setFunctionSpecNoreturn(SourceLocation Loc,
11051105
}
11061106

11071107
bool DeclSpec::setExportSpec(SourceLocation Loc) {
1108-
export_specified = true;
1109-
exportLoc = Loc;
1108+
ExportSpecified = true;
1109+
ExportLoc = Loc;
11101110
return false;
11111111
}
11121112

clang/lib/Sema/SemaAttr.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,29 +1334,25 @@ static bool typeListMatches(ASTContext& Context, FunctionDecl *FD,
13341334
for (unsigned i = 0; i != FD->getNumParams(); ++i) {
13351335
const ParmVarDecl *PVD = FD->getParamDecl(i);
13361336
QualType ParmType = PVD->getType().getCanonicalType();
1337-
fprintf(stderr, "SDP: --- pramtype\n");
1338-
ParmType->dump();
1337+
#if SDP
1338+
// SDP QualType ParmType = PVD->getOriginalType().getCanonicalType();
13391339
if (ParmType->isArrayType())
13401340
ParmType = Context.getArrayDecayedType(ParmType);
13411341
else if (ParmType->isFunctionType())
1342-
{ fprintf(stderr, " - is function\n");
13431342
ParmType = Context.getPointerType(ParmType);
1344-
}
1345-
ParmType->dump();
1343+
#endif
13461344

13471345
QualType MapArgType = (*Label.TypeList)[i].getCanonicalType();
1348-
fprintf(stderr, "SDP: --- MapArgtype\n");
1349-
MapArgType->dump();
1346+
#if SDP
13501347
if (MapArgType->isArrayType())
13511348
MapArgType = Context.getArrayDecayedType(MapArgType);
13521349
else if (MapArgType->isFunctionType())
1353-
{ fprintf(stderr, " - is function\n");
13541350
MapArgType = Context.getPointerType(MapArgType);
1355-
}
13561351
MapArgType.getDesugaredType(Context)->dump();
13571352

13581353
assert(!ParmType->canDecayToPointerType());
13591354
assert(!MapArgType->canDecayToPointerType());
1355+
#endif
13601356
if (ParmType != MapArgType)
13611357
return false;
13621358
}

clang/lib/Sema/SemaType.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4250,7 +4250,6 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
42504250
// The TypeSourceInfo that this function returns will not be a null type.
42514251
// If there is an error, this function will fill in a dummy type as fallback.
42524252
QualType T = declSpecType;
4253-
fprintf(stderr, "SDP: === GetFullTypeForDeclarator\n"); T->dump(); fprintf(stderr, "SDP: === GetFullTypeForDeclarator\n");
42544253
Declarator &D = state.getDeclarator();
42554254
Sema &S = state.getSema();
42564255
ASTContext &Context = S.Context;
@@ -5723,7 +5722,6 @@ TypeSourceInfo *Sema::GetTypeForDeclarator(Declarator &D) {
57235722

57245723
TypeSourceInfo *ReturnTypeInfo = nullptr;
57255724
QualType T = GetDeclSpecTypeForDeclarator(state, ReturnTypeInfo);
5726-
fprintf(stderr, "SDP: === GetTypeForDeclarator\n"); T->dump(); fprintf(stderr, "SDP: === GetTypeForDeclarator\n");
57275725
if (D.isPrototypeContext() && getLangOpts().ObjCAutoRefCount)
57285726
inferARCWriteback(state, T);
57295727

clang/test/CodeGen/attr-export-failing.cpp

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)