Skip to content

Commit 2a14cf8

Browse files
author
David Ungar
committed
Move FrontendArgsToOptionsConverter into separate files & rename to ArgsToFrontendOptionsConverter.
1 parent 81eac3b commit 2a14cf8

File tree

5 files changed

+770
-708
lines changed

5 files changed

+770
-708
lines changed
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
//===--- ArgsToFrontendOptionsConverter.h ---------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2017 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 ArgsToFrontendOptionsConverter_h
14+
#define 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+
using namespace swift;
25+
using namespace llvm::opt;
26+
27+
namespace swift {
28+
29+
class ArgsToFrontendOptionsConverter {
30+
private:
31+
DiagnosticEngine &Diags;
32+
const llvm::opt::ArgList &Args;
33+
FrontendOptions &Opts;
34+
35+
Optional<const std::vector<std::string>>
36+
cachedOutputFilenamesFromCommandLineOrFilelist;
37+
38+
void handleDebugCrashGroupArguments();
39+
40+
void computeDebugTimeOptions();
41+
bool computeFallbackModuleName();
42+
bool computeModuleName();
43+
bool computeOutputFilenames();
44+
void computeDumpScopeMapLocations();
45+
void computeHelpOptions();
46+
void computeImplicitImportModuleNames();
47+
void computeImportObjCHeaderOptions();
48+
void computeLLVMArgs();
49+
void computePlaygroundOptions();
50+
void computePrintStatsOptions();
51+
void computeTBDOptions();
52+
53+
void setUnsignedIntegerArgument(options::ID optionID, unsigned max,
54+
unsigned &valueToSet);
55+
56+
FrontendOptions::ActionType determineRequestedAction() const;
57+
58+
bool setUpForSILOrLLVM();
59+
60+
/// Determine the correct output filename when none was specified.
61+
///
62+
/// Such an absence should only occur when invoking the frontend
63+
/// without the driver,
64+
/// because the driver will always pass -o with an appropriate filename
65+
/// if output is required for the requested action.
66+
bool deriveOutputFilenameFromInputFile();
67+
68+
/// Determine the correct output filename when a directory was specified.
69+
///
70+
/// Such a specification should only occur when invoking the frontend
71+
/// directly, because the driver will always pass -o with an appropriate
72+
/// filename if output is required for the requested action.
73+
bool deriveOutputFilenameForDirectory(StringRef outputDir);
74+
75+
std::string determineBaseNameOfOutput() const;
76+
77+
void deriveOutputFilenameFromParts(StringRef dir, StringRef base);
78+
79+
void determineSupplementaryOutputFilenames();
80+
81+
/// Returns the output filenames on the command line or in the output
82+
/// filelist. If there
83+
/// were neither -o's nor an output filelist, returns an empty vector.
84+
ArrayRef<std::string> getOutputFilenamesFromCommandLineOrFilelist();
85+
86+
bool checkForUnusedOutputPaths() const;
87+
88+
std::vector<std::string> readOutputFileList(StringRef filelistPath) const;
89+
90+
public:
91+
ArgsToFrontendOptionsConverter(DiagnosticEngine &Diags,
92+
const llvm::opt::ArgList &Args,
93+
FrontendOptions &Opts)
94+
: Diags(Diags), Args(Args), Opts(Opts) {}
95+
96+
bool convert();
97+
};
98+
99+
} // namespace swift
100+
101+
#endif /* ArgsToFrontendOptionsConverter_h */

include/swift/Frontend/FrontendOptions.h

Lines changed: 3 additions & 3 deletions
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;
@@ -319,8 +319,6 @@ class FrontendOptions {
319319
}
320320

321321
private:
322-
static const char *suffixForPrincipalOutputFileForAction(ActionType);
323-
324322
bool hasUnusedDependenciesFilePath() const;
325323
static bool canActionEmitDependencies(ActionType);
326324
bool hasUnusedObjCHeaderOutputPath() const;
@@ -332,9 +330,11 @@ class FrontendOptions {
332330
bool hasUnusedModuleDocOutputPath() const;
333331
static bool canActionEmitModuleDoc(ActionType);
334332

333+
public:
335334
static bool doesActionProduceOutput(ActionType);
336335
static bool doesActionProduceTextualOutput(ActionType);
337336
static bool needsProperModuleName(ActionType);
337+
static const char *suffixForPrincipalOutputFileForAction(ActionType);
338338
};
339339

340340
}

0 commit comments

Comments
 (0)