Skip to content

Commit

Permalink
[OpenACC/NFC] Make 'trailing objects' use private inheritence.
Browse files Browse the repository at this point in the history
I noticed this while working on something else, these are supposed to be
privately inherited.
  • Loading branch information
erichkeane committed Dec 16, 2024
1 parent 8402a0f commit 8c16323
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 27 deletions.
57 changes: 38 additions & 19 deletions clang/include/clang/AST/OpenACCClause.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,9 @@ using DeviceTypeArgument = std::pair<IdentifierInfo *, SourceLocation>;
/// an identifier. The 'asterisk' means 'the rest'.
class OpenACCDeviceTypeClause final
: public OpenACCClauseWithParams,
public llvm::TrailingObjects<OpenACCDeviceTypeClause,
private llvm::TrailingObjects<OpenACCDeviceTypeClause,
DeviceTypeArgument> {
friend TrailingObjects;
// Data stored in trailing objects as IdentifierInfo* /SourceLocation pairs. A
// nullptr IdentifierInfo* represents an asterisk.
unsigned NumArchs;
Expand Down Expand Up @@ -377,7 +378,8 @@ class OpenACCClauseWithExprs : public OpenACCClauseWithParams {
// Represents the 'devnum' and expressions lists for the 'wait' clause.
class OpenACCWaitClause final
: public OpenACCClauseWithExprs,
public llvm::TrailingObjects<OpenACCWaitClause, Expr *> {
private llvm::TrailingObjects<OpenACCWaitClause, Expr *> {
friend TrailingObjects;
SourceLocation QueuesLoc;
OpenACCWaitClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
Expr *DevNumExpr, SourceLocation QueuesLoc,
Expand Down Expand Up @@ -419,7 +421,8 @@ class OpenACCWaitClause final

class OpenACCNumGangsClause final
: public OpenACCClauseWithExprs,
public llvm::TrailingObjects<OpenACCNumGangsClause, Expr *> {
private llvm::TrailingObjects<OpenACCNumGangsClause, Expr *> {
friend TrailingObjects;

OpenACCNumGangsClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
ArrayRef<Expr *> IntExprs, SourceLocation EndLoc)
Expand Down Expand Up @@ -449,7 +452,8 @@ class OpenACCNumGangsClause final

class OpenACCTileClause final
: public OpenACCClauseWithExprs,
public llvm::TrailingObjects<OpenACCTileClause, Expr *> {
private llvm::TrailingObjects<OpenACCTileClause, Expr *> {
friend TrailingObjects;
OpenACCTileClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
ArrayRef<Expr *> SizeExprs, SourceLocation EndLoc)
: OpenACCClauseWithExprs(OpenACCClauseKind::Tile, BeginLoc, LParenLoc,
Expand Down Expand Up @@ -503,7 +507,8 @@ class OpenACCClauseWithSingleIntExpr : public OpenACCClauseWithExprs {

class OpenACCGangClause final
: public OpenACCClauseWithExprs,
public llvm::TrailingObjects<OpenACCGangClause, Expr *, OpenACCGangKind> {
private llvm::TrailingObjects<OpenACCGangClause, Expr *, OpenACCGangKind> {
friend TrailingObjects;
protected:
OpenACCGangClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
ArrayRef<OpenACCGangKind> GangKinds,
Expand Down Expand Up @@ -658,7 +663,8 @@ class OpenACCClauseWithVarList : public OpenACCClauseWithExprs {

class OpenACCPrivateClause final
: public OpenACCClauseWithVarList,
public llvm::TrailingObjects<OpenACCPrivateClause, Expr *> {
private llvm::TrailingObjects<OpenACCPrivateClause, Expr *> {
friend TrailingObjects;

OpenACCPrivateClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
ArrayRef<Expr *> VarList, SourceLocation EndLoc)
Expand All @@ -680,7 +686,8 @@ class OpenACCPrivateClause final

class OpenACCFirstPrivateClause final
: public OpenACCClauseWithVarList,
public llvm::TrailingObjects<OpenACCFirstPrivateClause, Expr *> {
private llvm::TrailingObjects<OpenACCFirstPrivateClause, Expr *> {
friend TrailingObjects;

OpenACCFirstPrivateClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
ArrayRef<Expr *> VarList, SourceLocation EndLoc)
Expand All @@ -702,7 +709,8 @@ class OpenACCFirstPrivateClause final

class OpenACCDevicePtrClause final
: public OpenACCClauseWithVarList,
public llvm::TrailingObjects<OpenACCDevicePtrClause, Expr *> {
private llvm::TrailingObjects<OpenACCDevicePtrClause, Expr *> {
friend TrailingObjects;

OpenACCDevicePtrClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
ArrayRef<Expr *> VarList, SourceLocation EndLoc)
Expand All @@ -724,7 +732,8 @@ class OpenACCDevicePtrClause final

class OpenACCAttachClause final
: public OpenACCClauseWithVarList,
public llvm::TrailingObjects<OpenACCAttachClause, Expr *> {
private llvm::TrailingObjects<OpenACCAttachClause, Expr *> {
friend TrailingObjects;

OpenACCAttachClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
ArrayRef<Expr *> VarList, SourceLocation EndLoc)
Expand All @@ -746,7 +755,8 @@ class OpenACCAttachClause final

class OpenACCDetachClause final
: public OpenACCClauseWithVarList,
public llvm::TrailingObjects<OpenACCDetachClause, Expr *> {
private llvm::TrailingObjects<OpenACCDetachClause, Expr *> {
friend TrailingObjects;

OpenACCDetachClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
ArrayRef<Expr *> VarList, SourceLocation EndLoc)
Expand All @@ -768,7 +778,8 @@ class OpenACCDetachClause final

class OpenACCDeleteClause final
: public OpenACCClauseWithVarList,
public llvm::TrailingObjects<OpenACCDeleteClause, Expr *> {
private llvm::TrailingObjects<OpenACCDeleteClause, Expr *> {
friend TrailingObjects;

OpenACCDeleteClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
ArrayRef<Expr *> VarList, SourceLocation EndLoc)
Expand All @@ -790,7 +801,8 @@ class OpenACCDeleteClause final

class OpenACCUseDeviceClause final
: public OpenACCClauseWithVarList,
public llvm::TrailingObjects<OpenACCUseDeviceClause, Expr *> {
private llvm::TrailingObjects<OpenACCUseDeviceClause, Expr *> {
friend TrailingObjects;

OpenACCUseDeviceClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
ArrayRef<Expr *> VarList, SourceLocation EndLoc)
Expand All @@ -812,7 +824,8 @@ class OpenACCUseDeviceClause final

class OpenACCNoCreateClause final
: public OpenACCClauseWithVarList,
public llvm::TrailingObjects<OpenACCNoCreateClause, Expr *> {
private llvm::TrailingObjects<OpenACCNoCreateClause, Expr *> {
friend TrailingObjects;

OpenACCNoCreateClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
ArrayRef<Expr *> VarList, SourceLocation EndLoc)
Expand All @@ -834,7 +847,8 @@ class OpenACCNoCreateClause final

class OpenACCPresentClause final
: public OpenACCClauseWithVarList,
public llvm::TrailingObjects<OpenACCPresentClause, Expr *> {
private llvm::TrailingObjects<OpenACCPresentClause, Expr *> {
friend TrailingObjects;

OpenACCPresentClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
ArrayRef<Expr *> VarList, SourceLocation EndLoc)
Expand All @@ -856,7 +870,8 @@ class OpenACCPresentClause final

class OpenACCCopyClause final
: public OpenACCClauseWithVarList,
public llvm::TrailingObjects<OpenACCCopyClause, Expr *> {
private llvm::TrailingObjects<OpenACCCopyClause, Expr *> {
friend TrailingObjects;

OpenACCCopyClause(OpenACCClauseKind Spelling, SourceLocation BeginLoc,
SourceLocation LParenLoc, ArrayRef<Expr *> VarList,
Expand Down Expand Up @@ -885,7 +900,8 @@ class OpenACCCopyClause final

class OpenACCCopyInClause final
: public OpenACCClauseWithVarList,
public llvm::TrailingObjects<OpenACCCopyInClause, Expr *> {
private llvm::TrailingObjects<OpenACCCopyInClause, Expr *> {
friend TrailingObjects;
bool IsReadOnly;

OpenACCCopyInClause(OpenACCClauseKind Spelling, SourceLocation BeginLoc,
Expand Down Expand Up @@ -917,7 +933,8 @@ class OpenACCCopyInClause final

class OpenACCCopyOutClause final
: public OpenACCClauseWithVarList,
public llvm::TrailingObjects<OpenACCCopyOutClause, Expr *> {
private llvm::TrailingObjects<OpenACCCopyOutClause, Expr *> {
friend TrailingObjects;
bool IsZero;

OpenACCCopyOutClause(OpenACCClauseKind Spelling, SourceLocation BeginLoc,
Expand Down Expand Up @@ -949,7 +966,8 @@ class OpenACCCopyOutClause final

class OpenACCCreateClause final
: public OpenACCClauseWithVarList,
public llvm::TrailingObjects<OpenACCCreateClause, Expr *> {
private llvm::TrailingObjects<OpenACCCreateClause, Expr *> {
friend TrailingObjects;
bool IsZero;

OpenACCCreateClause(OpenACCClauseKind Spelling, SourceLocation BeginLoc,
Expand Down Expand Up @@ -981,7 +999,8 @@ class OpenACCCreateClause final

class OpenACCReductionClause final
: public OpenACCClauseWithVarList,
public llvm::TrailingObjects<OpenACCReductionClause, Expr *> {
private llvm::TrailingObjects<OpenACCReductionClause, Expr *> {
friend TrailingObjects;
OpenACCReductionOperator Op;

OpenACCReductionClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
Expand Down
23 changes: 15 additions & 8 deletions clang/include/clang/AST/StmtOpenACC.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,12 @@ class OpenACCAssociatedStmtConstruct : public OpenACCConstructStmt {
/// the 'Kind'.
class OpenACCComputeConstruct final
: public OpenACCAssociatedStmtConstruct,
public llvm::TrailingObjects<OpenACCComputeConstruct,
const OpenACCClause *> {
private llvm::TrailingObjects<OpenACCComputeConstruct,
const OpenACCClause *> {
friend class ASTStmtWriter;
friend class ASTStmtReader;
friend class ASTContext;
friend TrailingObjects;
OpenACCComputeConstruct(unsigned NumClauses)
: OpenACCAssociatedStmtConstruct(
OpenACCComputeConstructClass, OpenACCDirectiveKind::Invalid,
Expand Down Expand Up @@ -189,7 +190,7 @@ class OpenACCComputeConstruct final
/// Construct.
class OpenACCLoopConstruct final
: public OpenACCAssociatedStmtConstruct,
public llvm::TrailingObjects<OpenACCLoopConstruct,
private llvm::TrailingObjects<OpenACCLoopConstruct,
const OpenACCClause *> {
// The compute/combined construct kind this loop is associated with, or
// invalid if this is an orphaned loop construct.
Expand All @@ -202,6 +203,7 @@ class OpenACCLoopConstruct final
friend class OpenACCAssociatedStmtConstruct;
friend class OpenACCCombinedConstruct;
friend class OpenACCComputeConstruct;
friend TrailingObjects;

OpenACCLoopConstruct(unsigned NumClauses);

Expand Down Expand Up @@ -245,8 +247,9 @@ class OpenACCLoopConstruct final
// shared with both loop and compute constructs.
class OpenACCCombinedConstruct final
: public OpenACCAssociatedStmtConstruct,
public llvm::TrailingObjects<OpenACCCombinedConstruct,
private llvm::TrailingObjects<OpenACCCombinedConstruct,
const OpenACCClause *> {
friend TrailingObjects;
OpenACCCombinedConstruct(unsigned NumClauses)
: OpenACCAssociatedStmtConstruct(
OpenACCCombinedConstructClass, OpenACCDirectiveKind::Invalid,
Expand Down Expand Up @@ -297,8 +300,9 @@ class OpenACCCombinedConstruct final
// and clauses, but is otherwise pretty simple.
class OpenACCDataConstruct final
: public OpenACCAssociatedStmtConstruct,
public llvm::TrailingObjects<OpenACCDataConstruct,
private llvm::TrailingObjects<OpenACCDataConstruct,
const OpenACCClause *> {
friend TrailingObjects;
OpenACCDataConstruct(unsigned NumClauses)
: OpenACCAssociatedStmtConstruct(
OpenACCDataConstructClass, OpenACCDirectiveKind::Data,
Expand Down Expand Up @@ -345,8 +349,9 @@ class OpenACCDataConstruct final
// This class represents a 'enter data' construct, which JUST has clauses.
class OpenACCEnterDataConstruct final
: public OpenACCConstructStmt,
public llvm::TrailingObjects<OpenACCEnterDataConstruct,
private llvm::TrailingObjects<OpenACCEnterDataConstruct,
const OpenACCClause *> {
friend TrailingObjects;
OpenACCEnterDataConstruct(unsigned NumClauses)
: OpenACCConstructStmt(OpenACCEnterDataConstructClass,
OpenACCDirectiveKind::EnterData, SourceLocation{},
Expand Down Expand Up @@ -382,8 +387,9 @@ class OpenACCEnterDataConstruct final
// This class represents a 'exit data' construct, which JUST has clauses.
class OpenACCExitDataConstruct final
: public OpenACCConstructStmt,
public llvm::TrailingObjects<OpenACCExitDataConstruct,
private llvm::TrailingObjects<OpenACCExitDataConstruct,
const OpenACCClause *> {
friend TrailingObjects;
OpenACCExitDataConstruct(unsigned NumClauses)
: OpenACCConstructStmt(OpenACCExitDataConstructClass,
OpenACCDirectiveKind::ExitData, SourceLocation{},
Expand Down Expand Up @@ -420,8 +426,9 @@ class OpenACCExitDataConstruct final
// statement and clauses, but is otherwise pretty simple.
class OpenACCHostDataConstruct final
: public OpenACCAssociatedStmtConstruct,
public llvm::TrailingObjects<OpenACCHostDataConstruct,
private llvm::TrailingObjects<OpenACCHostDataConstruct,
const OpenACCClause *> {
friend TrailingObjects;
OpenACCHostDataConstruct(unsigned NumClauses)
: OpenACCAssociatedStmtConstruct(
OpenACCHostDataConstructClass, OpenACCDirectiveKind::HostData,
Expand Down

0 comments on commit 8c16323

Please sign in to comment.