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