LLVM 24.0.0git
YAMLTraits.cpp File Reference
#include "llvm/Support/YAMLTraits.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/LineIterator.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Unicode.h"
#include "llvm/Support/VersionTuple.h"
#include "llvm/Support/YAMLParser.h"
#include "llvm/Support/raw_ostream.h"
#include <cassert>
#include <cstdint>
#include <cstring>
#include <string>
#include <vector>

Go to the source code of this file.

Functions

static bool canUseBlockScalar (StringRef S)
 A literal block scalar has no escapes, so it can only hold printable characters, tab and line feed.

Function Documentation

◆ canUseBlockScalar()

bool canUseBlockScalar ( StringRef S)
static

A literal block scalar has no escapes, so it can only hold printable characters, tab and line feed.

That rules out C1 controls, and NEL, LS and PS, which YAML 1.1 readers take as line breaks. Invalid UTF-8 stays in the block, since yaml::escape would drop it. Readers take the indentation from the first non-empty line, so that line cannot start with a space.

Definition at line 762 of file YAMLTraits.cpp.

References llvm::StringRef::bytes_begin(), llvm::StringRef::bytes_end(), llvm::conversionOK, llvm::convertUTF8Sequence(), llvm::End, llvm::isASCII(), llvm::isPrint(), llvm::sys::unicode::isPrintable(), llvm::StringRef::ltrim(), llvm::StringRef::starts_with(), and llvm::strictConversion.

Referenced by llvm::yaml::Output::blockScalarString().