brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · 4672a0d Raw
56 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 OutputConfig class methods.11///12//===----------------------------------------------------------------------===//13 14#include "llvm/Support/VirtualOutputConfig.h"15#include "llvm/Support/Debug.h"16#include "llvm/Support/FileSystem.h"17#include "llvm/Support/raw_ostream.h"18 19using namespace llvm;20using namespace llvm::vfs;21 22OutputConfig &OutputConfig::setOpenFlags(const sys::fs::OpenFlags &Flags) {23  // Ignore CRLF on its own as invalid.24  using namespace llvm::sys::fs;25  return Flags & OF_Text26             ? setText().setCRLF(Flags & OF_CRLF).setAppend(Flags & OF_Append)27             : setBinary().setAppend(Flags & OF_Append);28}29 30void OutputConfig::print(raw_ostream &OS) const {31  OS << "{";32  bool IsFirst = true;33  auto printFlag = [&](StringRef FlagName, bool Value) {34    if (IsFirst)35      IsFirst = false;36    else37      OS << ",";38    if (!Value)39      OS << "No";40    OS << FlagName;41  };42 43#define HANDLE_OUTPUT_CONFIG_FLAG(NAME, DEFAULT)                               \44  if (get##NAME() != DEFAULT)                                                  \45    printFlag(#NAME, get##NAME());46#include "llvm/Support/VirtualOutputConfig.def"47  OS << "}";48}49 50LLVM_DUMP_METHOD void OutputConfig::dump() const { print(dbgs()); }51 52raw_ostream &llvm::operator<<(raw_ostream &OS, OutputConfig Config) {53  Config.print(OS);54  return OS;55}56