Move main outputs to FrontendInputsAndOutputs and InputFile

This commit is contained in:
David Ungar
2018-01-29 16:43:19 -08:00
parent e006825d88
commit 614006bc4f
19 changed files with 656 additions and 251 deletions

View File

@@ -33,17 +33,24 @@ enum class InputFileKind {
class InputFile {
std::string Filename;
bool IsPrimary;
/// Null if the contents are not overridden.
/// Points to a buffer overriding the file's contents, or nullptr if there is
/// none.
llvm::MemoryBuffer *Buffer;
/// Contains the name of the main output file, that is, the .o file for this
/// input. If there is no such file, contains an empty string. If the output
/// is to be written to stdout, contains "-".
std::string OutputFilename;
public:
/// Does not take ownership of \p buffer. Does take ownership of (copy) a
/// string.
InputFile(StringRef name, bool isPrimary,
llvm::MemoryBuffer *buffer = nullptr)
llvm::MemoryBuffer *buffer = nullptr,
StringRef outputFilename = StringRef())
: Filename(
convertBufferNameFromLLVM_getFileOrSTDIN_toSwiftConventions(name)),
IsPrimary(isPrimary), Buffer(buffer) {
IsPrimary(isPrimary), Buffer(buffer), OutputFilename(outputFilename) {
assert(!name.empty());
}
@@ -60,6 +67,12 @@ public:
StringRef filename) {
return filename.equals("<stdin>") ? "-" : filename;
}
const std::string &outputFilename() const { return OutputFilename; }
void setOutputFilename(StringRef outputFilename) {
OutputFilename = outputFilename;
}
};
} // namespace swift