41 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8///9/// \file10/// This file implements \c vfs::OutputBackend class methods.11///12//===----------------------------------------------------------------------===//13 14#include "llvm/Support/VirtualOutputBackend.h"15#include "llvm/ADT/SmallString.h"16#include "llvm/Support/VirtualOutputError.h"17 18using namespace llvm;19using namespace llvm::vfs;20 21void OutputBackend::anchor() {}22 23Expected<OutputFile>24OutputBackend::createFile(const Twine &Path,25 std::optional<OutputConfig> Config) {26 SmallString<128> PathStorage;27 Path.toVector(PathStorage);28 29 if (Config) {30 // Check for invalid configs.31 if (!Config->getText() && Config->getCRLF())32 return make_error<OutputConfigError>(*Config, PathStorage);33 }34 35 std::unique_ptr<OutputFileImpl> Impl;36 if (Error E = createFileImpl(PathStorage, Config).moveInto(Impl))37 return std::move(E);38 assert(Impl && "Expected valid Impl or Error");39 return OutputFile(PathStorage, std::move(Impl));40}41