Skip to content

Commit 01a082a

Browse files
committed
[AST] Adopt ArgumentList
Switch out the representation of argument lists in various AST nodes with ArgumentList.
1 parent 7c7c531 commit 01a082a

19 files changed

+443
-1590
lines changed

include/swift/AST/Attr.h

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
#include "swift/AST/PlatformKind.h"
3838
#include "swift/AST/Requirement.h"
3939
#include "swift/AST/StorageImpl.h"
40-
#include "swift/AST/TrailingCallArguments.h"
4140
#include "llvm/ADT/iterator_range.h"
4241
#include "llvm/ADT/SmallVector.h"
4342
#include "llvm/ADT/StringRef.h"
@@ -46,6 +45,7 @@
4645
#include "llvm/Support/VersionTuple.h"
4746

4847
namespace swift {
48+
class ArgumentList;
4949
class ASTPrinter;
5050
class ASTContext;
5151
struct PrintOptions;
@@ -1530,48 +1530,40 @@ class ClangImporterSynthesizedTypeAttr : public DeclAttribute {
15301530
};
15311531

15321532
/// Defines a custom attribute.
1533-
class CustomAttr final : public DeclAttribute,
1534-
public TrailingCallArguments<CustomAttr> {
1533+
class CustomAttr final : public DeclAttribute {
15351534
TypeExpr *typeExpr;
1536-
Expr *arg;
1535+
ArgumentList *argList;
15371536
PatternBindingInitializer *initContext;
15381537
Expr *semanticInit = nullptr;
15391538

1540-
unsigned hasArgLabelLocs : 1;
1541-
unsigned numArgLabels : 16;
15421539
mutable unsigned isArgUnsafeBit : 1;
15431540

15441541
CustomAttr(SourceLoc atLoc, SourceRange range, TypeExpr *type,
1545-
PatternBindingInitializer *initContext, Expr *arg,
1546-
ArrayRef<Identifier> argLabels, ArrayRef<SourceLoc> argLabelLocs,
1542+
PatternBindingInitializer *initContext, ArgumentList *argList,
15471543
bool implicit);
15481544

15491545
public:
15501546
static CustomAttr *create(ASTContext &ctx, SourceLoc atLoc, TypeExpr *type,
15511547
bool implicit = false) {
1552-
return create(ctx, atLoc, type, false, nullptr, SourceLoc(), { }, { }, { },
1553-
SourceLoc(), implicit);
1548+
return create(ctx, atLoc, type, /*initContext*/ nullptr,
1549+
/*argList*/ nullptr, implicit);
15541550
}
15551551

15561552
static CustomAttr *create(ASTContext &ctx, SourceLoc atLoc, TypeExpr *type,
1557-
bool hasInitializer,
15581553
PatternBindingInitializer *initContext,
1559-
SourceLoc lParenLoc,
1560-
ArrayRef<Expr *> args,
1561-
ArrayRef<Identifier> argLabels,
1562-
ArrayRef<SourceLoc> argLabelLocs,
1563-
SourceLoc rParenLoc,
1564-
bool implicit = false);
1565-
1566-
unsigned getNumArguments() const { return numArgLabels; }
1567-
bool hasArgumentLabelLocs() const { return hasArgLabelLocs; }
1554+
ArgumentList *argList, bool implicit = false);
15681555

15691556
TypeExpr *getTypeExpr() const { return typeExpr; }
15701557
TypeRepr *getTypeRepr() const;
15711558
Type getType() const;
15721559

1573-
Expr *getArg() const { return arg; }
1574-
void setArg(Expr *newArg) { arg = newArg; }
1560+
/// Whether the attribute has any arguments.
1561+
bool hasArgs() const { return argList != nullptr; }
1562+
1563+
/// The argument list of the attribute if it has any arguments, \c nullptr
1564+
/// otherwise.
1565+
ArgumentList *getArgs() const { return argList; }
1566+
void setArgs(ArgumentList *newArgs) { argList = newArgs; }
15751567

15761568
/// Determine whether the argument is '(unsafe)', a special subexpression
15771569
/// used by global actors.

0 commit comments

Comments
 (0)