|
|
@@ -86,7 +86,7 @@ The input Carbon source file to compile.
|
|
|
},
|
|
|
[&](auto& arg_b) {
|
|
|
arg_b.Required(true);
|
|
|
- arg_b.Append(&input_file_names);
|
|
|
+ arg_b.Append(&input_filenames);
|
|
|
});
|
|
|
|
|
|
b.AddOneOfOption(
|
|
|
@@ -128,7 +128,7 @@ Passing `--output=-` will write the output to stdout. In that case, the flag
|
|
|
object output can be forced by enabling `--force-obj-output`.
|
|
|
)""",
|
|
|
},
|
|
|
- [&](auto& arg_b) { arg_b.Set(&output_file_name); });
|
|
|
+ [&](auto& arg_b) { arg_b.Set(&output_filename); });
|
|
|
|
|
|
b.AddStringOption(
|
|
|
{
|
|
|
@@ -262,8 +262,8 @@ Dump the generated assembly to stdout after codegen.
|
|
|
std::string host = llvm::sys::getDefaultTargetTriple();
|
|
|
llvm::StringRef target;
|
|
|
|
|
|
- llvm::StringRef output_file_name;
|
|
|
- llvm::SmallVector<llvm::StringRef> input_file_names;
|
|
|
+ llvm::StringRef output_filename;
|
|
|
+ llvm::SmallVector<llvm::StringRef> input_filenames;
|
|
|
|
|
|
bool asm_output = false;
|
|
|
bool force_obj_output = false;
|
|
|
@@ -395,10 +395,10 @@ auto Driver::ValidateCompileOptions(const CompileOptions& options) const
|
|
|
class Driver::CompilationUnit {
|
|
|
public:
|
|
|
explicit CompilationUnit(Driver* driver, const CompileOptions& options,
|
|
|
- llvm::StringRef input_file_name)
|
|
|
+ llvm::StringRef input_filename)
|
|
|
: driver_(driver),
|
|
|
options_(options),
|
|
|
- input_file_name_(input_file_name),
|
|
|
+ input_filename_(input_filename),
|
|
|
vlog_stream_(driver_->vlog_stream_),
|
|
|
stream_consumer_(driver_->error_stream_) {
|
|
|
if (vlog_stream_ != nullptr || options_.stream_errors) {
|
|
|
@@ -412,10 +412,10 @@ class Driver::CompilationUnit {
|
|
|
// Loads source and lexes it. Returns true on success.
|
|
|
auto RunLex() -> void {
|
|
|
LogCall("SourceBuffer::MakeFromFile", [&] {
|
|
|
- if (input_file_name_ == "-") {
|
|
|
+ if (input_filename_ == "-") {
|
|
|
source_ = SourceBuffer::MakeFromStdin(*consumer_);
|
|
|
} else {
|
|
|
- source_ = SourceBuffer::MakeFromFile(driver_->fs_, input_file_name_,
|
|
|
+ source_ = SourceBuffer::MakeFromFile(driver_->fs_, input_filename_,
|
|
|
*consumer_);
|
|
|
}
|
|
|
});
|
|
|
@@ -501,7 +501,7 @@ class Driver::CompilationUnit {
|
|
|
|
|
|
LogCall("Lower::LowerToLLVM", [&] {
|
|
|
llvm_context_ = std::make_unique<llvm::LLVMContext>();
|
|
|
- module_ = Lower::LowerToLLVM(*llvm_context_, input_file_name_, *sem_ir_,
|
|
|
+ module_ = Lower::LowerToLLVM(*llvm_context_, input_filename_, *sem_ir_,
|
|
|
vlog_stream_);
|
|
|
});
|
|
|
if (vlog_stream_) {
|
|
|
@@ -526,10 +526,10 @@ class Driver::CompilationUnit {
|
|
|
|
|
|
auto PrintSharedValues() const -> void {
|
|
|
Yaml::Print(driver_->output_stream_,
|
|
|
- value_stores_.OutputYaml(input_file_name_));
|
|
|
+ value_stores_.OutputYaml(input_filename_));
|
|
|
}
|
|
|
|
|
|
- auto input_file_name() -> llvm::StringRef { return input_file_name_; }
|
|
|
+ auto input_filename() -> llvm::StringRef { return input_filename_; }
|
|
|
auto success() -> bool { return success_; }
|
|
|
auto has_source() -> bool { return source_.has_value(); }
|
|
|
|
|
|
@@ -546,7 +546,7 @@ class Driver::CompilationUnit {
|
|
|
codegen->EmitAssembly(*vlog_stream_);
|
|
|
}
|
|
|
|
|
|
- if (options_.output_file_name == "-") {
|
|
|
+ if (options_.output_filename == "-") {
|
|
|
// TODO: the output file name, forcing object output, and requesting
|
|
|
// textual assembly output are all somewhat linked flags. We should add
|
|
|
// some validation that they are used correctly.
|
|
|
@@ -560,17 +560,17 @@ class Driver::CompilationUnit {
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- llvm::SmallString<256> output_file_name = options_.output_file_name;
|
|
|
- if (output_file_name.empty()) {
|
|
|
+ llvm::SmallString<256> output_filename = options_.output_filename;
|
|
|
+ if (output_filename.empty()) {
|
|
|
if (!source_->is_regular_file()) {
|
|
|
// Don't invent file names like `-.o` or `/dev/stdin.o`.
|
|
|
driver_->error_stream_
|
|
|
<< "ERROR: Output file name must be specified for input '"
|
|
|
- << input_file_name_ << "' that is not a regular file.\n";
|
|
|
+ << input_filename_ << "' that is not a regular file.\n";
|
|
|
return false;
|
|
|
}
|
|
|
- output_file_name = input_file_name_;
|
|
|
- llvm::sys::path::replace_extension(output_file_name,
|
|
|
+ output_filename = input_filename_;
|
|
|
+ llvm::sys::path::replace_extension(output_filename,
|
|
|
options_.asm_output ? ".s" : ".o");
|
|
|
} else {
|
|
|
// TODO: Handle the case where multiple input files were specified
|
|
|
@@ -579,14 +579,14 @@ class Driver::CompilationUnit {
|
|
|
// Currently each unit overwrites the output from the previous one in
|
|
|
// this case.
|
|
|
}
|
|
|
- CARBON_VLOG() << "Writing output to: " << output_file_name << "\n";
|
|
|
+ CARBON_VLOG() << "Writing output to: " << output_filename << "\n";
|
|
|
|
|
|
std::error_code ec;
|
|
|
- llvm::raw_fd_ostream output_file(output_file_name, ec,
|
|
|
+ llvm::raw_fd_ostream output_file(output_filename, ec,
|
|
|
llvm::sys::fs::OF_None);
|
|
|
if (ec) {
|
|
|
driver_->error_stream_ << "ERROR: Could not open output file '"
|
|
|
- << output_file_name << "': " << ec.message()
|
|
|
+ << output_filename << "': " << ec.message()
|
|
|
<< "\n";
|
|
|
return false;
|
|
|
}
|
|
|
@@ -606,7 +606,7 @@ class Driver::CompilationUnit {
|
|
|
// Wraps a call with log statements to indicate start and end.
|
|
|
auto LogCall(llvm::StringLiteral label, llvm::function_ref<void()> fn)
|
|
|
-> void {
|
|
|
- CARBON_VLOG() << "*** " << label << ": " << input_file_name_ << " ***\n";
|
|
|
+ CARBON_VLOG() << "*** " << label << ": " << input_filename_ << " ***\n";
|
|
|
fn();
|
|
|
CARBON_VLOG() << "*** " << label << " done ***\n";
|
|
|
}
|
|
|
@@ -614,7 +614,7 @@ class Driver::CompilationUnit {
|
|
|
Driver* driver_;
|
|
|
SharedValueStores value_stores_;
|
|
|
const CompileOptions& options_;
|
|
|
- llvm::StringRef input_file_name_;
|
|
|
+ llvm::StringRef input_filename_;
|
|
|
|
|
|
// Copied from driver_ for CARBON_VLOG.
|
|
|
llvm::raw_pwrite_stream* vlog_stream_;
|
|
|
@@ -646,7 +646,7 @@ auto Driver::Compile(const CompileOptions& options) -> RunResult {
|
|
|
for (const auto& unit : units) {
|
|
|
result.success &= unit->success();
|
|
|
result.per_file_success.push_back(
|
|
|
- {unit->input_file_name(), unit->success()});
|
|
|
+ {unit->input_filename(), unit->success()});
|
|
|
}
|
|
|
return result;
|
|
|
};
|
|
|
@@ -666,9 +666,9 @@ auto Driver::Compile(const CompileOptions& options) -> RunResult {
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
- for (const auto& input_file_name : options.input_file_names) {
|
|
|
+ for (const auto& input_filename : options.input_filenames) {
|
|
|
units.push_back(
|
|
|
- std::make_unique<CompilationUnit>(this, options, input_file_name));
|
|
|
+ std::make_unique<CompilationUnit>(this, options, input_filename));
|
|
|
}
|
|
|
|
|
|
// Lex.
|