|
15 | 15 | //
|
16 | 16 | //===----------------------------------------------------------------------===//
|
17 | 17 |
|
18 |
| -#include "swift/Subsystems.h" |
19 | 18 | #include "swift/AST/DiagnosticsFrontend.h"
|
20 | 19 | #include "swift/AST/SILOptions.h"
|
21 | 20 | #include "swift/Basic/FileTypes.h"
|
22 |
| -#include "swift/Basic/LLVMInitialize.h" |
23 | 21 | #include "swift/Basic/InitializeSwiftModules.h"
|
| 22 | +#include "swift/Basic/LLVMInitialize.h" |
24 | 23 | #include "swift/Basic/QuotedString.h"
|
25 | 24 | #include "swift/Frontend/DiagnosticVerifier.h"
|
26 | 25 | #include "swift/Frontend/Frontend.h"
|
27 | 26 | #include "swift/Frontend/PrintingDiagnosticConsumer.h"
|
| 27 | +#include "swift/IRGen/IRGenPublic.h" |
| 28 | +#include "swift/IRGen/IRGenSILPasses.h" |
| 29 | +#include "swift/Parse/ParseVersion.h" |
28 | 30 | #include "swift/SIL/SILRemarkStreamer.h"
|
29 | 31 | #include "swift/SILOptimizer/Analysis/Analysis.h"
|
30 |
| -#include "swift/SILOptimizer/PassManager/Passes.h" |
31 | 32 | #include "swift/SILOptimizer/PassManager/PassManager.h"
|
| 33 | +#include "swift/SILOptimizer/PassManager/Passes.h" |
| 34 | +#include "swift/Serialization/SerializationOptions.h" |
32 | 35 | #include "swift/Serialization/SerializedModuleLoader.h"
|
33 | 36 | #include "swift/Serialization/SerializedSILLoader.h"
|
34 |
| -#include "swift/Serialization/SerializationOptions.h" |
| 37 | +#include "swift/Subsystems.h" |
35 | 38 | #include "swift/SymbolGraphGen/SymbolGraphOptions.h"
|
36 |
| -#include "swift/IRGen/IRGenPublic.h" |
37 |
| -#include "swift/IRGen/IRGenSILPasses.h" |
38 | 39 | #include "llvm/ADT/Statistic.h"
|
39 | 40 | #include "llvm/Support/CommandLine.h"
|
40 | 41 | #include "llvm/Support/FileSystem.h"
|
@@ -363,6 +364,12 @@ struct SILOptOptions {
|
363 | 364 | llvm::cl::desc("verify diagnostics against expected-"
|
364 | 365 | "{error|warning|note} annotations"));
|
365 | 366 |
|
| 367 | + llvm::cl::list<std::string> VerifyAdditionalPrefixes = |
| 368 | + llvm::cl::list<std::string>( |
| 369 | + "verify-additional-prefix", |
| 370 | + llvm::cl::desc("Check for diagnostics with the prefix " |
| 371 | + "expected-<PREFIX> as well as expected-")); |
| 372 | + |
366 | 373 | llvm::cl::opt<unsigned>
|
367 | 374 | AssertConfId = llvm::cl::opt<unsigned>("assert-conf-id", llvm::cl::Hidden,
|
368 | 375 | llvm::cl::init(0));
|
@@ -542,6 +549,11 @@ struct SILOptOptions {
|
542 | 549 | llvm::cl::opt<bool>(
|
543 | 550 | "disable-region-based-isolation-with-strict-concurrency",
|
544 | 551 | llvm::cl::init(false));
|
| 552 | + |
| 553 | + llvm::cl::opt<std::string> SwiftVersionString = llvm::cl::opt<std::string>( |
| 554 | + "swift-version", |
| 555 | + llvm::cl::desc( |
| 556 | + "The swift version to assume AST declarations correspond to")); |
545 | 557 | };
|
546 | 558 |
|
547 | 559 | /// Regular expression corresponding to the value given in one of the
|
@@ -641,6 +653,23 @@ int sil_opt_main(ArrayRef<const char *> argv, void *MainAddr) {
|
641 | 653 | // cache.
|
642 | 654 | Invocation.getClangImporterOptions().ModuleCachePath = options.ModuleCachePath;
|
643 | 655 | Invocation.setParseStdlib();
|
| 656 | + if (options.SwiftVersionString.size()) { |
| 657 | + auto vers = VersionParser::parseVersionString(options.SwiftVersionString, |
| 658 | + SourceLoc(), nullptr); |
| 659 | + bool isValid = false; |
| 660 | + if (vers.has_value()) { |
| 661 | + if (auto effectiveVers = vers.value().getEffectiveLanguageVersion()) { |
| 662 | + Invocation.getLangOptions().EffectiveLanguageVersion = |
| 663 | + effectiveVers.value(); |
| 664 | + isValid = true; |
| 665 | + } |
| 666 | + } |
| 667 | + if (!isValid) { |
| 668 | + llvm::errs() << "error: invalid swift version " |
| 669 | + << options.SwiftVersionString << '\n'; |
| 670 | + exit(-1); |
| 671 | + } |
| 672 | + } |
644 | 673 | Invocation.getLangOptions().DisableAvailabilityChecking = true;
|
645 | 674 | Invocation.getLangOptions().EnableAccessControl = false;
|
646 | 675 | Invocation.getLangOptions().EnableObjCAttrRequiresFoundation = false;
|
@@ -716,7 +745,12 @@ int sil_opt_main(ArrayRef<const char *> argv, void *MainAddr) {
|
716 | 745 | }
|
717 | 746 |
|
718 | 747 | Invocation.getDiagnosticOptions().VerifyMode =
|
719 |
| - options.VerifyMode ? DiagnosticOptions::Verify : DiagnosticOptions::NoVerify; |
| 748 | + options.VerifyMode ? DiagnosticOptions::Verify |
| 749 | + : DiagnosticOptions::NoVerify; |
| 750 | + for (auto &additionalPrefixes : options.VerifyAdditionalPrefixes) { |
| 751 | + Invocation.getDiagnosticOptions() |
| 752 | + .AdditionalDiagnosticVerifierPrefixes.push_back(additionalPrefixes); |
| 753 | + } |
720 | 754 |
|
721 | 755 | ClangImporterOptions &clangImporterOptions =
|
722 | 756 | Invocation.getClangImporterOptions();
|
|
0 commit comments