Skip to content

Commit 78d8d09

Browse files
committed
[IDE] Adopt ArgumentList
1 parent ad55c09 commit 78d8d09

File tree

13 files changed

+591
-826
lines changed

13 files changed

+591
-826
lines changed

include/swift/IDE/Utils.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,9 @@ class NameMatcher: public ASTWalker {
244244
std::vector<ResolvedLoc> ResolvedLocs;
245245
ArrayRef<Token> TokensToCheck;
246246

247-
/// The \c Expr argument of a parent \c CustomAttr (if one exists) and
247+
/// The \c ArgumentList of a parent \c CustomAttr (if one exists) and
248248
/// the \c SourceLoc of the type name it applies to.
249-
llvm::Optional<Located<Expr *>> CustomAttrArg;
249+
llvm::Optional<Located<ArgumentList *>> CustomAttrArgList;
250250
unsigned InactiveConfigRegionNestings = 0;
251251
unsigned SelectorNestings = 0;
252252

@@ -265,12 +265,13 @@ class NameMatcher: public ASTWalker {
265265
bool shouldSkip(SourceRange Range);
266266
bool shouldSkip(CharSourceRange Range);
267267
bool tryResolve(ASTWalker::ParentTy Node, SourceLoc NameLoc);
268-
bool tryResolve(ASTWalker::ParentTy Node, DeclNameLoc NameLoc, Expr *Arg);
268+
bool tryResolve(ASTWalker::ParentTy Node, DeclNameLoc NameLoc,
269+
ArgumentList *Args);
269270
bool tryResolve(ASTWalker::ParentTy Node, SourceLoc NameLoc, LabelRangeType RangeType,
270271
ArrayRef<CharSourceRange> LabelLocs,
271272
Optional<unsigned> FirstTrailingLabel);
272273
bool handleCustomAttrs(Decl *D);
273-
Expr *getApplicableArgFor(Expr* E);
274+
ArgumentList *getApplicableArgsFor(Expr* E);
274275

275276
std::pair<bool, Expr*> walkToExprPre(Expr *E) override;
276277
Expr* walkToExprPost(Expr *E) override;
@@ -283,6 +284,9 @@ class NameMatcher: public ASTWalker {
283284
std::pair<bool, Pattern*> walkToPatternPre(Pattern *P) override;
284285
bool shouldWalkIntoGenericParams() override { return true; }
285286

287+
std::pair<bool, ArgumentList *>
288+
walkToArgumentListPre(ArgumentList *ArgList) override;
289+
286290
// FIXME: Remove this
287291
bool shouldWalkAccessorsTheOldWay() override { return true; }
288292

@@ -568,13 +572,14 @@ struct CallArgInfo {
568572
};
569573

570574
std::vector<CallArgInfo>
571-
getCallArgInfo(SourceManager &SM, Expr *Arg, LabelRangeEndAt EndKind);
575+
getCallArgInfo(SourceManager &SM, ArgumentList *Args, LabelRangeEndAt EndKind);
572576

573577
// Get the ranges of argument labels from an Arg, either tuple or paren, and
574578
// the index of the first trailing closure argument, if any. This includes empty
575579
// ranges for any unlabelled arguments, including the first trailing closure.
576580
std::pair<std::vector<CharSourceRange>, Optional<unsigned>>
577-
getCallArgLabelRanges(SourceManager &SM, Expr *Arg, LabelRangeEndAt EndKind);
581+
getCallArgLabelRanges(SourceManager &SM, ArgumentList *Args,
582+
LabelRangeEndAt EndKind);
578583

579584
/// Whether a decl is defined from clang source.
580585
bool isFromClang(const Decl *D);

include/swift/Sema/IDETypeChecking.h

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -233,50 +233,6 @@ namespace swift {
233233
std::vector<VariableTypeInfo> &VariableTypeInfos,
234234
llvm::raw_ostream &OS);
235235

236-
/// FIXME: All of the below goes away once CallExpr directly stores its
237-
/// arguments.
238-
239-
/// Return value for getOriginalArgumentList().
240-
struct OriginalArgumentList {
241-
SmallVector<Expr *, 4> args;
242-
SmallVector<Identifier, 4> labels;
243-
SmallVector<SourceLoc, 4> labelLocs;
244-
SourceLoc lParenLoc;
245-
SourceLoc rParenLoc;
246-
Optional<unsigned> unlabeledTrailingClosureIdx;
247-
248-
/// The number of trailing closures in the argument list.
249-
unsigned getNumTrailingClosures() const {
250-
if (!unlabeledTrailingClosureIdx)
251-
return 0;
252-
return args.size() - *unlabeledTrailingClosureIdx;
253-
}
254-
255-
/// Whether any unlabeled or labeled trailing closures are present.
256-
bool hasAnyTrailingClosures() const {
257-
return unlabeledTrailingClosureIdx.hasValue();
258-
}
259-
260-
/// Whether the given index is for an unlabeled trailing closure.
261-
bool isUnlabeledTrailingClosureIdx(unsigned i) const {
262-
return unlabeledTrailingClosureIdx && *unlabeledTrailingClosureIdx == i;
263-
}
264-
265-
/// Whether the given index is for a labeled trailing closure in an
266-
/// argument list with multiple trailing closures.
267-
bool isLabeledTrailingClosureIdx(unsigned i) const {
268-
if (!unlabeledTrailingClosureIdx)
269-
return false;
270-
return i > *unlabeledTrailingClosureIdx && i < args.size();
271-
}
272-
};
273-
274-
/// When applying a solution to a constraint system, the type checker rewrites
275-
/// argument lists of calls to insert default arguments and collect varargs.
276-
/// Sometimes for diagnostics we want to work on the original argument list as
277-
/// written by the user; this performs the reverse transformation.
278-
OriginalArgumentList getOriginalArgumentList(Expr *expr);
279-
280236
/// Returns the root type and result type of the keypath type in a keypath
281237
/// dynamic member lookup subscript, or \c None if it cannot be determined.
282238
///

0 commit comments

Comments
 (0)