Skip to content

Commit a70ba0a

Browse files
author
David Ungar
committed
Split out ArgsToFrontenfOptionsConverter.
1 parent 68bda74 commit a70ba0a

File tree

5 files changed

+766
-706
lines changed

5 files changed

+766
-706
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
//===------ArgsToFrontendOptionsConverter.h-- --------------------*-C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef SWIFT_FRONTEND_ARGSTOFRONTENDOPTIONSCONVERTER_H
14+
#define SWIFT_FRONTEND_ARGSTOFRONTENDOPTIONSCONVERTER_H
15+
16+
#include "swift/AST/DiagnosticConsumer.h"
17+
#include "swift/AST/DiagnosticEngine.h"
18+
#include "swift/Frontend/FrontendOptions.h"
19+
#include "swift/Option/Options.h"
20+
#include "llvm/Option/ArgList.h"
21+
22+
#include <vector>
23+
24+
namespace swift {
25+
26+
class ArgsToFrontendOptionsConverter {
27+
private:
28+
DiagnosticEngine &Diags;
29+
const llvm::opt::ArgList &Args;
30+
FrontendOptions &Opts;
31+
32+
Optional<const std::vector<std::string>>
33+
cachedOutputFilenamesFromCommandLineOrFilelist;
34+
35+
void handleDebugCrashGroupArguments();
36+
37+
void computeDebugTimeOptions();
38+
bool computeFallbackModuleName();
39+
bool computeModuleName();
40+
bool computeOutputFilenames();
41+
void computeDumpScopeMapLocations();
42+
void computeHelpOptions();
43+
void computeImplicitImportModuleNames();
44+
void computeImportObjCHeaderOptions();
45+
void computeLLVMArgs();
46+
void computePlaygroundOptions();
47+
void computePrintStatsOptions();
48+
void computeTBDOptions();
49+
50+
void setUnsignedIntegerArgument(options::ID optionID, unsigned max,
51+
unsigned &valueToSet);
52+
53+
FrontendOptions::ActionType determineRequestedAction() const;
54+
55+
bool setUpForSILOrLLVM();
56+
57+
/// Determine the correct output filename when none was specified.
58+
///
59+
/// Such an absence should only occur when invoking the frontend
60+
/// without the driver,
61+
/// because the driver will always pass -o with an appropriate filename
62+
/// if output is required for the requested action.
63+
bool deriveOutputFilenameFromInputFile();
64+
65+
/// Determine the correct output filename when a directory was specified.
66+
///
67+
/// Such a specification should only occur when invoking the frontend
68+
/// directly, because the driver will always pass -o with an appropriate
69+
/// filename if output is required for the requested action.
70+
bool deriveOutputFilenameForDirectory(StringRef outputDir);
71+
72+
std::string determineBaseNameOfOutput() const;
73+
74+
void deriveOutputFilenameFromParts(StringRef dir, StringRef base);
75+
76+
void determineSupplementaryOutputFilenames();
77+
78+
/// Returns the output filenames on the command line or in the output
79+
/// filelist. If there
80+
/// were neither -o's nor an output filelist, returns an empty vector.
81+
ArrayRef<std::string> getOutputFilenamesFromCommandLineOrFilelist();
82+
83+
bool checkForUnusedOutputPaths() const;
84+
85+
std::vector<std::string> readOutputFileList(StringRef filelistPath) const;
86+
87+
public:
88+
ArgsToFrontendOptionsConverter(DiagnosticEngine &Diags,
89+
const llvm::opt::ArgList &Args,
90+
FrontendOptions &Opts)
91+
: Diags(Diags), Args(Args), Opts(Opts) {}
92+
93+
bool convert();
94+
};
95+
96+
} // namespace swift
97+
98+
#endif /* SWIFT_FRONTEND_ARGSTOFRONTENDOPTIONSCONVERTER_H */

include/swift/Frontend/FrontendOptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace swift {
3030

3131
/// Options for controlling the behavior of the frontend.
3232
class FrontendOptions {
33-
friend class FrontendArgsToOptionsConverter;
33+
friend class ArgsToFrontendOptionsConverter;
3434

3535
public:
3636
FrontendInputs Inputs;

0 commit comments

Comments
 (0)