From 6164f5bd2af7661f676bbaa5d3c6268a49c09c6c Mon Sep 17 00:00:00 2001 From: David Ungar Date: Tue, 28 May 2019 19:47:12 -0700 Subject: [PATCH 1/3] Add TrailingAngleBrackLoc to EditorPlaceholder for upcoming scope code. --- include/swift/AST/Expr.h | 6 ++++++ lib/AST/ASTDumper.cpp | 14 +++++++++++++- lib/Parse/ParseExpr.cpp | 1 + test/Parse/source_locs.swift | 5 ++++- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/include/swift/AST/Expr.h b/include/swift/AST/Expr.h index 679cc010a96..3b63f1c191f 100644 --- a/include/swift/AST/Expr.h +++ b/include/swift/AST/Expr.h @@ -4666,16 +4666,19 @@ public: class EditorPlaceholderExpr : public Expr { Identifier Placeholder; SourceLoc Loc; + SourceLoc TrailingAngleBracketLoc; TypeLoc PlaceholderTy; TypeRepr *ExpansionTyR; Expr *SemanticExpr; public: EditorPlaceholderExpr(Identifier Placeholder, SourceLoc Loc, + SourceLoc TrailingAngleBracketLoc, TypeLoc PlaceholderTy, TypeRepr *ExpansionTyR) : Expr(ExprKind::EditorPlaceholder, /*Implicit=*/false), Placeholder(Placeholder), Loc(Loc), + TrailingAngleBracketLoc(TrailingAngleBracketLoc), PlaceholderTy(PlaceholderTy), ExpansionTyR(ExpansionTyR), SemanticExpr(nullptr) { @@ -4685,6 +4688,9 @@ public: SourceRange getSourceRange() const { return Loc; } TypeLoc &getTypeLoc() { return PlaceholderTy; } TypeLoc getTypeLoc() const { return PlaceholderTy; } + SourceLoc getTrailingAngleBracketLoc() const { + return TrailingAngleBracketLoc; + } /// The TypeRepr to be considered for placeholder expansion. TypeRepr *getTypeForExpansion() const { return ExpansionTyR; } diff --git a/lib/AST/ASTDumper.cpp b/lib/AST/ASTDumper.cpp index ceb92a5432c..2a205bcd845 100644 --- a/lib/AST/ASTDumper.cpp +++ b/lib/AST/ASTDumper.cpp @@ -2635,7 +2635,19 @@ public: PrintWithColorRAII(OS, ParenthesisColor) << ')'; } void visitEditorPlaceholderExpr(EditorPlaceholderExpr *E) { - printCommon(E, "editor_placeholder_expr") << '\n'; + printCommon(E, "editor_placeholder_expr") << ' '; + + // Print the trailing angle bracket location + if (auto Ty = GetTypeOfExpr(E)) { + auto &Ctx = Ty->getASTContext(); + auto TABL = E->getTrailingAngleBracketLoc(); + if (TABL.isValid()) { + PrintWithColorRAII(OS, LocationColor) << " trailing_angle_bracket_loc="; + TABL.print(PrintWithColorRAII(OS, LocationColor).getOS(), + Ctx.SourceMgr); + } + } + OS << '\n'; auto *TyR = E->getTypeLoc().getTypeRepr(); auto *ExpTyR = E->getTypeForExpansion(); if (TyR) diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp index 8ac1515c5da..8c4a2e6da67 100644 --- a/lib/Parse/ParseExpr.cpp +++ b/lib/Parse/ParseExpr.cpp @@ -2385,6 +2385,7 @@ Expr *Parser::parseExprEditorPlaceholder(Token PlaceholderTok, parseTypeForPlaceholder(TyLoc, ExpansionTyR); return new (Context) EditorPlaceholderExpr(PlaceholderId, PlaceholderTok.getLoc(), + PlaceholderTok.getRange().getEnd(), TyLoc, ExpansionTyR); } diff --git a/test/Parse/source_locs.swift b/test/Parse/source_locs.swift index c1553fccebb..7be28e76c12 100644 --- a/test/Parse/source_locs.swift +++ b/test/Parse/source_locs.swift @@ -2,7 +2,10 @@ func string_interpolation() { "\("abc")" + <#Int#> } -// RUN: %target-swift-frontend -dump-ast %s | %FileCheck %s +// RUN: not %target-swift-frontend -dump-ast %s | %FileCheck %s // CHECK: (interpolated_string_literal_expr {{.*}} trailing_quote_loc=SOURCE_DIR{{/|\\}}test{{/|\\}}Parse{{/|\\}}source_locs.swift:4:12 {{.*}} +// CHECK: (editor_placeholder_expr type='()' {{.*}} trailing_angle_bracket_loc=SOURCE_DIR{{/|\\}}test{{/|\\}}Parse{{/|\\}}source_locs.swift:5:10 + From ed097f865cf7b303d415ad9bcf1aaa4c2ccfec69 Mon Sep 17 00:00:00 2001 From: David Ungar Date: Wed, 29 May 2019 11:50:11 -0700 Subject: [PATCH 2/3] Compute instead of store trailing angle bracket location. --- include/swift/AST/Expr.h | 5 +---- lib/Parse/ParseExpr.cpp | 1 - test/Parse/source_locs.swift | 2 +- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/include/swift/AST/Expr.h b/include/swift/AST/Expr.h index 3b63f1c191f..e6af2df8196 100644 --- a/include/swift/AST/Expr.h +++ b/include/swift/AST/Expr.h @@ -4666,19 +4666,16 @@ public: class EditorPlaceholderExpr : public Expr { Identifier Placeholder; SourceLoc Loc; - SourceLoc TrailingAngleBracketLoc; TypeLoc PlaceholderTy; TypeRepr *ExpansionTyR; Expr *SemanticExpr; public: EditorPlaceholderExpr(Identifier Placeholder, SourceLoc Loc, - SourceLoc TrailingAngleBracketLoc, TypeLoc PlaceholderTy, TypeRepr *ExpansionTyR) : Expr(ExprKind::EditorPlaceholder, /*Implicit=*/false), Placeholder(Placeholder), Loc(Loc), - TrailingAngleBracketLoc(TrailingAngleBracketLoc), PlaceholderTy(PlaceholderTy), ExpansionTyR(ExpansionTyR), SemanticExpr(nullptr) { @@ -4689,7 +4686,7 @@ public: TypeLoc &getTypeLoc() { return PlaceholderTy; } TypeLoc getTypeLoc() const { return PlaceholderTy; } SourceLoc getTrailingAngleBracketLoc() const { - return TrailingAngleBracketLoc; + return Loc.getAdvancedLoc(Placeholder.getLength() - 1); } /// The TypeRepr to be considered for placeholder expansion. diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp index 8c4a2e6da67..8ac1515c5da 100644 --- a/lib/Parse/ParseExpr.cpp +++ b/lib/Parse/ParseExpr.cpp @@ -2385,7 +2385,6 @@ Expr *Parser::parseExprEditorPlaceholder(Token PlaceholderTok, parseTypeForPlaceholder(TyLoc, ExpansionTyR); return new (Context) EditorPlaceholderExpr(PlaceholderId, PlaceholderTok.getLoc(), - PlaceholderTok.getRange().getEnd(), TyLoc, ExpansionTyR); } diff --git a/test/Parse/source_locs.swift b/test/Parse/source_locs.swift index 7be28e76c12..98e96eb76a4 100644 --- a/test/Parse/source_locs.swift +++ b/test/Parse/source_locs.swift @@ -7,5 +7,5 @@ func string_interpolation() { // RUN: not %target-swift-frontend -dump-ast %s | %FileCheck %s // CHECK: (interpolated_string_literal_expr {{.*}} trailing_quote_loc=SOURCE_DIR{{/|\\}}test{{/|\\}}Parse{{/|\\}}source_locs.swift:4:12 {{.*}} -// CHECK: (editor_placeholder_expr type='()' {{.*}} trailing_angle_bracket_loc=SOURCE_DIR{{/|\\}}test{{/|\\}}Parse{{/|\\}}source_locs.swift:5:10 +// CHECK: (editor_placeholder_expr type='()' {{.*}} trailing_angle_bracket_loc=SOURCE_DIR{{/|\\}}test{{/|\\}}Parse{{/|\\}}source_locs.swift:5:9 From ec1ab21325f3903364fc8a4ee87888aae36f049f Mon Sep 17 00:00:00 2001 From: Michael Gottesman Date: Wed, 29 May 2019 14:24:37 -0700 Subject: [PATCH 3/3] [build-script-impl] When skipping building LLVM in toolchain only mode, do not include FileCheck and not. The reason why is that we will not generate targets for them causing the build to fail. --- utils/build-script-impl | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/utils/build-script-impl b/utils/build-script-impl index 0528bee76fb..c6ae5d6425c 100755 --- a/utils/build-script-impl +++ b/utils/build-script-impl @@ -2150,8 +2150,18 @@ for host in "${ALL_HOSTS[@]}"; do fi if [ "${SKIP_BUILD_LLVM}" ] ; then # We can't skip the build completely because the standalone - # build of Swift depend on these for testing etc. - build_targets=(llvm-tblgen clang-headers intrinsics_gen clang-tablegen-targets FileCheck not) + # build of Swift depend on these for building and testing. + build_targets=(llvm-tblgen clang-headers intrinsics_gen clang-tablegen-targets) + # If we are not performing a toolchain only build, then we + # also want to include FileCheck and not for testing + # purposes. + if [[ ! "${BUILD_TOOLCHAIN_ONLY}" ]] ; then + build_targets=( + "${build_targets[@]}" + FileCheck + not + ) + fi fi if [ "${HOST_LIBTOOL}" ] ; then