Skip to content

Commit aeb9283

Browse files
author
David Ungar
authored
Merge pull request #15328 from davidungar/PR-18-12-file_types
Renamed swift::types to swift::file_types.
2 parents 5b6285f + 807dd58 commit aeb9283

20 files changed

+572
-567
lines changed

include/swift/Driver/Action.h

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#include "swift/Basic/LLVM.h"
1717
#include "swift/Driver/Util.h"
18-
#include "swift/Frontend/Types.h"
18+
#include "swift/Frontend/FileTypes.h"
1919
#include "llvm/ADT/ArrayRef.h"
2020
#include "llvm/ADT/Optional.h"
2121
#include "llvm/ADT/StringSwitch.h"
@@ -67,8 +67,7 @@ class Action {
6767
void *operator new(size_t size) { return ::operator new(size); };
6868

6969
protected:
70-
Action(ActionClass Kind, types::ID Type)
71-
: Kind(Kind), Type(Type) {
70+
Action(ActionClass Kind, file_types::ID Type) : Kind(Kind), Type(Type) {
7271
assert(Kind == getKind() && "not enough bits");
7372
assert(Type == getType() && "not enough bits");
7473
}
@@ -79,15 +78,15 @@ class Action {
7978
const char *getClassName() const { return Action::getClassName(getKind()); }
8079

8180
ActionClass getKind() const { return static_cast<ActionClass>(Kind); }
82-
types::ID getType() const { return static_cast<types::ID>(Type); }
81+
file_types::ID getType() const { return static_cast<file_types::ID>(Type); }
8382
};
8483

8584
class InputAction : public Action {
8685
virtual void anchor();
8786
const llvm::opt::Arg &Input;
8887

8988
public:
90-
InputAction(const llvm::opt::Arg &Input, types::ID Type)
89+
InputAction(const llvm::opt::Arg &Input, file_types::ID Type)
9190
: Action(Action::Input, Type), Input(Input) {}
9291
const llvm::opt::Arg &getInputArg() const { return Input; }
9392

@@ -100,7 +99,8 @@ class JobAction : public Action {
10099
TinyPtrVector<const Action *> Inputs;
101100
virtual void anchor();
102101
protected:
103-
JobAction(ActionClass Kind, ArrayRef<const Action *> Inputs, types::ID Type)
102+
JobAction(ActionClass Kind, ArrayRef<const Action *> Inputs,
103+
file_types::ID Type)
104104
: Action(Kind, Type), Inputs(Inputs) {}
105105

106106
public:
@@ -151,13 +151,11 @@ class CompileJobAction : public JobAction {
151151
InputInfo inputInfo;
152152

153153
public:
154-
CompileJobAction(types::ID OutputType)
154+
CompileJobAction(file_types::ID OutputType)
155155
: JobAction(Action::CompileJob, None, OutputType), inputInfo() {}
156156

157-
CompileJobAction(Action *Input, types::ID OutputType,
158-
InputInfo info)
159-
: JobAction(Action::CompileJob, Input, OutputType),
160-
inputInfo(info) {}
157+
CompileJobAction(Action *Input, file_types::ID OutputType, InputInfo info)
158+
: JobAction(Action::CompileJob, Input, OutputType), inputInfo(info) {}
161159

162160
InputInfo getInputInfo() const {
163161
return inputInfo;
@@ -174,7 +172,7 @@ class InterpretJobAction : public JobAction {
174172

175173
public:
176174
explicit InterpretJobAction()
177-
: JobAction(Action::InterpretJob, llvm::None, types::TY_Nothing) {}
175+
: JobAction(Action::InterpretJob, llvm::None, file_types::TY_Nothing) {}
178176

179177
static bool classof(const Action *A) {
180178
return A->getKind() == Action::InterpretJob;
@@ -190,7 +188,8 @@ class BackendJobAction : public JobAction {
190188
// This index specifies which of the files to select for the input.
191189
size_t InputIndex;
192190
public:
193-
BackendJobAction(const Action *Input, types::ID OutputType, size_t InputIndex)
191+
BackendJobAction(const Action *Input, file_types::ID OutputType,
192+
size_t InputIndex)
194193
: JobAction(Action::BackendJob, Input, OutputType),
195194
InputIndex(InputIndex) {}
196195
static bool classof(const Action *A) {
@@ -212,8 +211,8 @@ class REPLJobAction : public JobAction {
212211
Mode RequestedMode;
213212
public:
214213
REPLJobAction(Mode mode)
215-
: JobAction(Action::REPLJob, llvm::None, types::TY_Nothing),
216-
RequestedMode(mode) {}
214+
: JobAction(Action::REPLJob, llvm::None, file_types::TY_Nothing),
215+
RequestedMode(mode) {}
217216

218217
Mode getRequestedMode() const { return RequestedMode; }
219218

@@ -226,7 +225,8 @@ class MergeModuleJobAction : public JobAction {
226225
virtual void anchor();
227226
public:
228227
MergeModuleJobAction(ArrayRef<const Action *> Inputs)
229-
: JobAction(Action::MergeModuleJob, Inputs, types::TY_SwiftModuleFile) {}
228+
: JobAction(Action::MergeModuleJob, Inputs,
229+
file_types::TY_SwiftModuleFile) {}
230230

231231
static bool classof(const Action *A) {
232232
return A->getKind() == Action::MergeModuleJob;
@@ -237,7 +237,7 @@ class ModuleWrapJobAction : public JobAction {
237237
virtual void anchor();
238238
public:
239239
ModuleWrapJobAction(ArrayRef<const Action *> Inputs)
240-
: JobAction(Action::ModuleWrapJob, Inputs, types::TY_Object) {}
240+
: JobAction(Action::ModuleWrapJob, Inputs, file_types::TY_Object) {}
241241

242242
static bool classof(const Action *A) {
243243
return A->getKind() == Action::ModuleWrapJob;
@@ -248,7 +248,8 @@ class AutolinkExtractJobAction : public JobAction {
248248
virtual void anchor();
249249
public:
250250
AutolinkExtractJobAction(ArrayRef<const Action *> Inputs)
251-
: JobAction(Action::AutolinkExtractJob, Inputs, types::TY_AutolinkFile) {}
251+
: JobAction(Action::AutolinkExtractJob, Inputs,
252+
file_types::TY_AutolinkFile) {}
252253

253254
static bool classof(const Action *A) {
254255
return A->getKind() == Action::AutolinkExtractJob;
@@ -259,7 +260,7 @@ class GenerateDSYMJobAction : public JobAction {
259260
virtual void anchor();
260261
public:
261262
explicit GenerateDSYMJobAction(const Action *Input)
262-
: JobAction(Action::GenerateDSYMJob, Input, types::TY_dSYM) {}
263+
: JobAction(Action::GenerateDSYMJob, Input, file_types::TY_dSYM) {}
263264

264265
static bool classof(const Action *A) {
265266
return A->getKind() == Action::GenerateDSYMJob;
@@ -270,7 +271,7 @@ class VerifyDebugInfoJobAction : public JobAction {
270271
virtual void anchor();
271272
public:
272273
explicit VerifyDebugInfoJobAction(const Action *Input)
273-
: JobAction(Action::VerifyDebugInfoJob, Input, types::TY_Nothing) {}
274+
: JobAction(Action::VerifyDebugInfoJob, Input, file_types::TY_Nothing) {}
274275

275276
static bool classof(const Action *A) {
276277
return A->getKind() == Action::VerifyDebugInfoJob;
@@ -283,9 +284,10 @@ class GeneratePCHJobAction : public JobAction {
283284
virtual void anchor();
284285
public:
285286
GeneratePCHJobAction(const Action *Input, StringRef persistentPCHDir)
286-
: JobAction(Action::GeneratePCHJob, Input,
287-
persistentPCHDir.empty() ? types::TY_PCH : types::TY_Nothing),
288-
PersistentPCHDir(persistentPCHDir) {}
287+
: JobAction(Action::GeneratePCHJob, Input,
288+
persistentPCHDir.empty() ? file_types::TY_PCH
289+
: file_types::TY_Nothing),
290+
PersistentPCHDir(persistentPCHDir) {}
289291

290292
bool isPersistentPCH() const { return !PersistentPCHDir.empty(); }
291293
StringRef getPersistentPCHDir() const { return PersistentPCHDir; }
@@ -301,7 +303,7 @@ class LinkJobAction : public JobAction {
301303

302304
public:
303305
LinkJobAction(ArrayRef<const Action *> Inputs, LinkKind K)
304-
: JobAction(Action::LinkJob, Inputs, types::TY_Image), Kind(K) {
306+
: JobAction(Action::LinkJob, Inputs, file_types::TY_Image), Kind(K) {
305307
assert(Kind != LinkKind::None);
306308
}
307309

include/swift/Driver/Driver.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
#include "swift/Basic/OptionSet.h"
2323
#include "swift/Basic/Sanitizers.h"
2424
#include "swift/Driver/Util.h"
25+
#include "swift/Frontend/FileTypes.h"
2526
#include "swift/Frontend/OutputFileMap.h"
26-
#include "swift/Frontend/Types.h"
2727
#include "llvm/ADT/DenseMap.h"
2828
#include "llvm/ADT/StringMap.h"
2929
#include "llvm/ADT/StringRef.h"
@@ -78,7 +78,7 @@ class OutputInfo {
7878
Mode CompilerMode = Mode::StandardCompile;
7979

8080
/// The output type which should be used for compile actions.
81-
types::ID CompilerOutputType = types::ID::TY_INVALID;
81+
file_types::ID CompilerOutputType = file_types::ID::TY_INVALID;
8282

8383
/// Describes if and how the output of compile actions should be
8484
/// linked together.

include/swift/Driver/Job.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
#include "swift/Basic/LLVM.h"
1717
#include "swift/Driver/Action.h"
1818
#include "swift/Driver/Util.h"
19+
#include "swift/Frontend/FileTypes.h"
1920
#include "swift/Frontend/OutputFileMap.h"
20-
#include "swift/Frontend/Types.h"
2121
#include "llvm/ADT/ArrayRef.h"
2222
#include "llvm/ADT/DenseMap.h"
2323
#include "llvm/ADT/PointerIntPair.h"
@@ -109,15 +109,15 @@ class CommandOutput {
109109

110110
/// A CommandOutput designates one type of output as primary, though there
111111
/// may be multiple outputs of that type.
112-
types::ID PrimaryOutputType;
112+
file_types::ID PrimaryOutputType;
113113

114114
/// A CommandOutput also restricts its attention regarding additional-outputs
115115
/// to a subset of the PrimaryOutputs associated with its PrimaryInputs;
116116
/// sometimes multiple commands operate on the same PrimaryInput, in different
117117
/// phases (eg. autolink-extract and link both operate on the same .o file),
118118
/// so Jobs cannot _just_ rely on the presence of a primary output in the
119119
/// DerivedOutputFileMap.
120-
llvm::SmallSet<types::ID, 4> AdditionalOutputTypes;
120+
llvm::SmallSet<file_types::ID, 4> AdditionalOutputTypes;
121121

122122
/// The list of inputs for this \c CommandOutput. Each input in the list has
123123
/// two names (often but not always the same), of which the second (\c
@@ -135,23 +135,21 @@ class CommandOutput {
135135
// If there is an entry in the DerivedOutputMap for a given (\p
136136
// PrimaryInputFile, \p Type) pair, return a nonempty StringRef, otherwise
137137
// return an empty StringRef.
138-
StringRef
139-
getOutputForInputAndType(StringRef PrimaryInputFile, types::ID Type) const;
138+
StringRef getOutputForInputAndType(StringRef PrimaryInputFile,
139+
file_types::ID Type) const;
140140

141141
/// Add an entry to the \c DerivedOutputMap if it doesn't exist. If an entry
142142
/// already exists for \p PrimaryInputFile of type \p type, then either
143143
/// overwrite the entry (if \p overwrite is \c true) or assert that it has
144144
/// the same value as \p OutputFile.
145-
void ensureEntry(StringRef PrimaryInputFile,
146-
types::ID Type,
147-
StringRef OutputFile,
148-
bool Overwrite);
145+
void ensureEntry(StringRef PrimaryInputFile, file_types::ID Type,
146+
StringRef OutputFile, bool Overwrite);
149147

150148
public:
151-
CommandOutput(types::ID PrimaryOutputType, OutputFileMap &Derived);
149+
CommandOutput(file_types::ID PrimaryOutputType, OutputFileMap &Derived);
152150

153151
/// Return the primary output type for this CommandOutput.
154-
types::ID getPrimaryOutputType() const;
152+
file_types::ID getPrimaryOutputType() const;
155153

156154
/// Associate a new \p PrimaryOutputFile (of type \c getPrimaryOutputType())
157155
/// with the provided \p Input pair of Base and Primary inputs.
@@ -186,12 +184,13 @@ class CommandOutput {
186184
/// an additional output named \p OutputFilename of type \p type with the
187185
/// first primary input. If the provided \p type is the primary output type,
188186
/// overwrite the existing entry assocaited with the first primary input.
189-
void setAdditionalOutputForType(types::ID type, StringRef OutputFilename);
187+
void setAdditionalOutputForType(file_types::ID type,
188+
StringRef OutputFilename);
190189

191190
/// Assuming (and asserting) that there are one or more input pairs, return
192191
/// the _additional_ (not primary) output of type \p type associated with the
193192
/// first primary input.
194-
StringRef getAdditionalOutputForType(types::ID type) const;
193+
StringRef getAdditionalOutputForType(file_types::ID type) const;
195194

196195
/// Return a vector of additional (not primary) outputs of type \p type
197196
/// associated with the primary inputs.
@@ -202,12 +201,13 @@ class CommandOutput {
202201
/// length is _either_ zero, one, or equal to the size of the set of inputs,
203202
/// as these are the only valid arity relationships between primary and
204203
/// additional outputs.
205-
SmallVector<StringRef, 16> getAdditionalOutputsForType(types::ID type) const;
204+
SmallVector<StringRef, 16>
205+
getAdditionalOutputsForType(file_types::ID type) const;
206206

207207
/// Assuming (and asserting) that there is only one input pair, return any
208208
/// output -- primary or additional -- of type \p type associated with that
209209
/// the sole primary input.
210-
StringRef getAnyOutputForType(types::ID type) const;
210+
StringRef getAnyOutputForType(file_types::ID type) const;
211211

212212
/// Return the whole derived output map.
213213
const OutputFileMap &getDerivedOutputMap() const;

include/swift/Driver/PrettyStackTrace.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#ifndef SWIFT_DRIVER_PRETTYSTACKTRACE_H
1414
#define SWIFT_DRIVER_PRETTYSTACKTRACE_H
1515

16-
#include "swift/Frontend/Types.h"
16+
#include "swift/Frontend/FileTypes.h"
1717
#include "llvm/Support/PrettyStackTrace.h"
1818

1919
namespace swift {
@@ -57,14 +57,15 @@ class PrettyStackTraceDriverCommandOutputAddition
5757
: public llvm::PrettyStackTraceEntry {
5858
const CommandOutput *TheCommandOutput;
5959
StringRef PrimaryInput;
60-
types::ID NewOutputType;
60+
file_types::ID NewOutputType;
6161
StringRef NewOutputName;
6262
const char *Description;
6363

6464
public:
6565
PrettyStackTraceDriverCommandOutputAddition(const char *desc,
6666
const CommandOutput *A,
67-
StringRef Primary, types::ID type,
67+
StringRef Primary,
68+
file_types::ID type,
6869
StringRef New)
6970
: TheCommandOutput(A), PrimaryInput(Primary), NewOutputType(type),
7071
NewOutputName(New), Description(desc) {}

include/swift/Driver/ToolChain.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#include "swift/Basic/LLVM.h"
1717
#include "swift/Driver/Action.h"
18-
#include "swift/Frontend/Types.h"
18+
#include "swift/Frontend/FileTypes.h"
1919
#include "llvm/ADT/Triple.h"
2020
#include "llvm/Option/Option.h"
2121

@@ -224,7 +224,7 @@ class ToolChain {
224224
/// Return the default language type to use for the given extension.
225225
/// If the extension is empty or is otherwise not recognized, return
226226
/// the invalid type \c TY_INVALID.
227-
virtual types::ID lookupTypeForExtension(StringRef Ext) const;
227+
virtual file_types::ID lookupTypeForExtension(StringRef Ext) const;
228228

229229
/// Check whether a clang library with a given name exists.
230230
///

include/swift/Driver/Util.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#define SWIFT_DRIVER_UTIL_H
1515

1616
#include "swift/Basic/LLVM.h"
17-
#include "swift/Frontend/Types.h"
17+
#include "swift/Frontend/FileTypes.h"
1818
#include "llvm/ADT/SmallVector.h"
1919

2020
namespace llvm {
@@ -27,7 +27,7 @@ namespace swift {
2727

2828
namespace driver {
2929
/// An input argument from the command line and its inferred type.
30-
typedef std::pair<types::ID, const llvm::opt::Arg *> InputPair;
30+
typedef std::pair<file_types::ID, const llvm::opt::Arg *> InputPair;
3131
/// Type used for a list of input arguments.
3232
typedef SmallVector<InputPair, 16> InputFileList;
3333

@@ -55,7 +55,7 @@ namespace driver {
5555
};
5656

5757
StringRef path;
58-
types::ID type;
58+
file_types::ID type;
5959
WhichFiles whichFiles;
6060
};
6161

0 commit comments

Comments
 (0)