Files
carbon-lang/toolchain/driver/driver_main.cpp
T
Jon Ross-Perkins 551a6d385e Augment the file_test framework to allow per-file fail checks. (#3747)
This handles toolchain failures per-file. The intent is to allow placing
both "success" and "fail" tests in the same file, using splits. However,
this PR only adds support and updates existing tests to continue
passing.
2024-03-08 20:28:25 +00:00

32 lines
964 B
C++

// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#include <cstdlib>
#include "common/bazel_working_dir.h"
#include "common/init_llvm.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "toolchain/driver/driver.h"
auto main(int argc, char** argv) -> int {
Carbon::InitLLVM init_llvm(argc, argv);
if (argc < 1) {
return EXIT_FAILURE;
}
Carbon::SetWorkingDirForBazel();
// Printing to stderr should flush stdout. This is most noticeable when stderr
// is piped to stdout.
llvm::errs().tie(&llvm::outs());
llvm::SmallVector<llvm::StringRef> args(argv + 1, argv + argc);
auto fs = llvm::vfs::getRealFileSystem();
Carbon::Driver driver(*fs, llvm::outs(), llvm::errs());
bool success = driver.RunCommand(args).success;
return success ? EXIT_SUCCESS : EXIT_FAILURE;
}