@@ -2852,44 +2852,44 @@ static std::string getJsonOutputFilePath(llvm::Triple Triple, bool ABI) {
2852
2852
exit (1 );
2853
2853
}
2854
2854
2855
- int swift_api_digester_main (ArrayRef<const char *> Args, const char *Argv0,
2856
- void *MainAddr) {
2857
- INITIALIZE_LLVM ();
2858
-
2859
- // LLVM Command Line parsing expects to trim off argv[0].
2860
- SmallVector<const char *, 8 > ArgsWithArgv0{Argv0};
2861
- ArgsWithArgv0.append (Args.begin (), Args.end ());
2862
-
2863
- std::string MainExecutablePath = fs::getMainExecutable (Argv0, MainAddr);
2864
-
2865
- llvm::cl::HideUnrelatedOptions (options::Category);
2866
- llvm::cl::ParseCommandLineOptions (ArgsWithArgv0.size (),
2867
- llvm::makeArrayRef (ArgsWithArgv0).data (),
2868
- " Swift SDK Digester\n " );
2869
- CompilerInvocation InitInvok;
2855
+ class SwiftAPIDigesterInvocation {
2856
+ private:
2857
+ std::string MainExecutablePath;
2870
2858
2871
- llvm::StringSet<> Modules;
2872
- std::vector<std::string> PrintApis;
2873
- llvm::StringSet<> IgnoredUsrs;
2874
- readIgnoredUsrs (IgnoredUsrs);
2875
- CheckerOptions Opts = getCheckOpts (Args);
2876
- for (auto Name : options::ApisPrintUsrs)
2877
- PrintApis.push_back (Name);
2878
- switch (options::Action) {
2879
- case ActionType::DumpSDK:
2880
- return (prepareForDump (MainExecutablePath, InitInvok, Modules))
2881
- ? 1
2882
- : dumpSDKContent (
2883
- InitInvok, Modules,
2884
- getJsonOutputFilePath (InitInvok.getLangOptions ().Target ,
2885
- Opts.ABI ),
2886
- Opts);
2887
- case ActionType::MigratorGen:
2888
- case ActionType::DiagnoseSDKs: {
2889
- ComparisonInputMode Mode = checkComparisonInputMode ();
2890
- llvm::StringSet<> protocolAllowlist;
2891
- if (!options::ProtReqAllowList.empty ()) {
2892
- if (readFileLineByLine (options::ProtReqAllowList, protocolAllowlist))
2859
+ public:
2860
+ SwiftAPIDigesterInvocation (const std::string &ExecPath)
2861
+ : MainExecutablePath(ExecPath) {}
2862
+
2863
+ int parseArgs (ArrayRef<const char *> Args) { return 0 ; }
2864
+
2865
+ int run (ArrayRef<const char *> Args) {
2866
+ llvm::cl::HideUnrelatedOptions (options::Category);
2867
+ llvm::cl::ParseCommandLineOptions (
2868
+ Args.size (), llvm::makeArrayRef (Args).data (), " Swift SDK Digester\n " );
2869
+ CompilerInvocation InitInvok;
2870
+
2871
+ llvm::StringSet<> Modules;
2872
+ std::vector<std::string> PrintApis;
2873
+ llvm::StringSet<> IgnoredUsrs;
2874
+ readIgnoredUsrs (IgnoredUsrs);
2875
+ CheckerOptions Opts = getCheckOpts (Args);
2876
+ for (auto Name : options::ApisPrintUsrs)
2877
+ PrintApis.push_back (Name);
2878
+ switch (options::Action) {
2879
+ case ActionType::DumpSDK:
2880
+ return (prepareForDump (MainExecutablePath, InitInvok, Modules))
2881
+ ? 1
2882
+ : dumpSDKContent (
2883
+ InitInvok, Modules,
2884
+ getJsonOutputFilePath (InitInvok.getLangOptions ().Target ,
2885
+ Opts.ABI ),
2886
+ Opts);
2887
+ case ActionType::MigratorGen:
2888
+ case ActionType::DiagnoseSDKs: {
2889
+ ComparisonInputMode Mode = checkComparisonInputMode ();
2890
+ llvm::StringSet<> protocolAllowlist;
2891
+ if (!options::ProtReqAllowList.empty ()) {
2892
+ if (readFileLineByLine (options::ProtReqAllowList, protocolAllowlist))
2893
2893
return 1 ;
2894
2894
}
2895
2895
if (options::Action == ActionType::MigratorGen) {
@@ -2962,4 +2962,24 @@ int swift_api_digester_main(ArrayRef<const char *> Args, const char *Argv0,
2962
2962
llvm::cl::PrintHelpMessage ();
2963
2963
return 1 ;
2964
2964
}
2965
+ }
2966
+ };
2967
+
2968
+ int swift_api_digester_main (ArrayRef<const char *> Args, const char *Argv0,
2969
+ void *MainAddr) {
2970
+ INITIALIZE_LLVM ();
2971
+
2972
+ // LLVM Command Line parsing expects to trim off argv[0].
2973
+ SmallVector<const char *, 8 > ArgsWithArgv0{Argv0};
2974
+ ArgsWithArgv0.append (Args.begin (), Args.end ());
2975
+
2976
+ std::string MainExecutablePath = fs::getMainExecutable (Argv0, MainAddr);
2977
+ SwiftAPIDigesterInvocation Invocation (MainExecutablePath);
2978
+ if (Invocation.parseArgs (ArgsWithArgv0) != 0 )
2979
+ return EXIT_FAILURE;
2980
+
2981
+ if (Invocation.run (ArgsWithArgv0) != 0 )
2982
+ return EXIT_FAILURE;
2983
+
2984
+ return EXIT_SUCCESS;
2965
2985
}
0 commit comments