mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-30 15:10:33 +00:00
[ProfileData, Support] Fix some Clang-tidy modernize-use-using and Include What You Use warnings; other minor fixes (NFC).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305969 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
bb561ec060
commit
dfaebc43c9
@ -411,9 +411,11 @@ public:
|
|||||||
std::vector<CoverageSegment>::const_iterator begin() const {
|
std::vector<CoverageSegment>::const_iterator begin() const {
|
||||||
return Segments.begin();
|
return Segments.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<CoverageSegment>::const_iterator end() const {
|
std::vector<CoverageSegment>::const_iterator end() const {
|
||||||
return Segments.end();
|
return Segments.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool empty() const { return Segments.empty(); }
|
bool empty() const { return Segments.empty(); }
|
||||||
|
|
||||||
/// \brief Expansions that can be further processed.
|
/// \brief Expansions that can be further processed.
|
||||||
@ -430,6 +432,7 @@ class CoverageMapping {
|
|||||||
unsigned MismatchedFunctionCount = 0;
|
unsigned MismatchedFunctionCount = 0;
|
||||||
|
|
||||||
CoverageMapping() = default;
|
CoverageMapping() = default;
|
||||||
|
|
||||||
/// \brief Add a function record corresponding to \p Record.
|
/// \brief Add a function record corresponding to \p Record.
|
||||||
Error loadFunctionRecord(const CoverageMappingRecord &Record,
|
Error loadFunctionRecord(const CoverageMappingRecord &Record,
|
||||||
IndexedInstrProfReader &ProfileReader);
|
IndexedInstrProfReader &ProfileReader);
|
||||||
@ -607,13 +610,13 @@ enum CovMapVersion {
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <int CovMapVersion, class IntPtrT> struct CovMapTraits {
|
template <int CovMapVersion, class IntPtrT> struct CovMapTraits {
|
||||||
typedef CovMapFunctionRecord CovMapFuncRecordType;
|
using CovMapFuncRecordType = CovMapFunctionRecord;
|
||||||
typedef uint64_t NameRefType;
|
using NameRefType = uint64_t;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class IntPtrT> struct CovMapTraits<CovMapVersion::Version1, IntPtrT> {
|
template <class IntPtrT> struct CovMapTraits<CovMapVersion::Version1, IntPtrT> {
|
||||||
typedef CovMapFunctionRecordV1<IntPtrT> CovMapFuncRecordType;
|
using CovMapFuncRecordType = CovMapFunctionRecordV1<IntPtrT>;
|
||||||
typedef IntPtrT NameRefType;
|
using NameRefType = IntPtrT;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace coverage
|
} // end namespace coverage
|
||||||
@ -622,6 +625,7 @@ template <class IntPtrT> struct CovMapTraits<CovMapVersion::Version1, IntPtrT> {
|
|||||||
template<> struct DenseMapInfo<coverage::CounterExpression> {
|
template<> struct DenseMapInfo<coverage::CounterExpression> {
|
||||||
static inline coverage::CounterExpression getEmptyKey() {
|
static inline coverage::CounterExpression getEmptyKey() {
|
||||||
using namespace coverage;
|
using namespace coverage;
|
||||||
|
|
||||||
return CounterExpression(CounterExpression::ExprKind::Subtract,
|
return CounterExpression(CounterExpression::ExprKind::Subtract,
|
||||||
Counter::getCounter(~0U),
|
Counter::getCounter(~0U),
|
||||||
Counter::getCounter(~0U));
|
Counter::getCounter(~0U));
|
||||||
@ -629,6 +633,7 @@ template<> struct DenseMapInfo<coverage::CounterExpression> {
|
|||||||
|
|
||||||
static inline coverage::CounterExpression getTombstoneKey() {
|
static inline coverage::CounterExpression getTombstoneKey() {
|
||||||
using namespace coverage;
|
using namespace coverage;
|
||||||
|
|
||||||
return CounterExpression(CounterExpression::ExprKind::Add,
|
return CounterExpression(CounterExpression::ExprKind::Add,
|
||||||
Counter::getCounter(~0U),
|
Counter::getCounter(~0U),
|
||||||
Counter::getCounter(~0U));
|
Counter::getCounter(~0U));
|
||||||
|
@ -410,7 +410,7 @@ uint64_t ComputeHash(StringRef K);
|
|||||||
/// on how PGO name is formed.
|
/// on how PGO name is formed.
|
||||||
class InstrProfSymtab {
|
class InstrProfSymtab {
|
||||||
public:
|
public:
|
||||||
typedef std::vector<std::pair<uint64_t, uint64_t>> AddrHashMap;
|
using AddrHashMap = std::vector<std::pair<uint64_t, uint64_t>>;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
StringRef Data;
|
StringRef Data;
|
||||||
@ -599,7 +599,7 @@ struct InstrProfRecord {
|
|||||||
InstrProfRecord(StringRef Name, uint64_t Hash, std::vector<uint64_t> Counts)
|
InstrProfRecord(StringRef Name, uint64_t Hash, std::vector<uint64_t> Counts)
|
||||||
: Name(Name), Hash(Hash), Counts(std::move(Counts)) {}
|
: Name(Name), Hash(Hash), Counts(std::move(Counts)) {}
|
||||||
|
|
||||||
typedef std::vector<std::pair<uint64_t, uint64_t>> ValueMapType;
|
using ValueMapType = std::vector<std::pair<uint64_t, uint64_t>>;
|
||||||
|
|
||||||
/// Return the number of value profile kinds with non-zero number
|
/// Return the number of value profile kinds with non-zero number
|
||||||
/// of profile sites.
|
/// of profile sites.
|
||||||
@ -673,8 +673,8 @@ struct InstrProfRecord {
|
|||||||
private:
|
private:
|
||||||
std::vector<InstrProfValueSiteRecord> IndirectCallSites;
|
std::vector<InstrProfValueSiteRecord> IndirectCallSites;
|
||||||
std::vector<InstrProfValueSiteRecord> MemOPSizes;
|
std::vector<InstrProfValueSiteRecord> MemOPSizes;
|
||||||
const std::vector<InstrProfValueSiteRecord> &
|
|
||||||
|
|
||||||
|
const std::vector<InstrProfValueSiteRecord> &
|
||||||
getValueSitesForKind(uint32_t ValueKind) const {
|
getValueSitesForKind(uint32_t ValueKind) const {
|
||||||
switch (ValueKind) {
|
switch (ValueKind) {
|
||||||
case IPVK_IndirectCallTarget:
|
case IPVK_IndirectCallTarget:
|
||||||
@ -878,6 +878,11 @@ struct Summary {
|
|||||||
// The number of Cutoff Entries (Summary::Entry) following summary fields.
|
// The number of Cutoff Entries (Summary::Entry) following summary fields.
|
||||||
uint64_t NumCutoffEntries;
|
uint64_t NumCutoffEntries;
|
||||||
|
|
||||||
|
Summary() = delete;
|
||||||
|
Summary(uint32_t Size) { memset(this, 0, Size); }
|
||||||
|
|
||||||
|
void operator delete(void *ptr) { ::operator delete(ptr); }
|
||||||
|
|
||||||
static uint32_t getSize(uint32_t NumSumFields, uint32_t NumCutoffEntries) {
|
static uint32_t getSize(uint32_t NumSumFields, uint32_t NumCutoffEntries) {
|
||||||
return sizeof(Summary) + NumCutoffEntries * sizeof(Entry) +
|
return sizeof(Summary) + NumCutoffEntries * sizeof(Entry) +
|
||||||
NumSumFields * sizeof(uint64_t);
|
NumSumFields * sizeof(uint64_t);
|
||||||
@ -916,11 +921,6 @@ struct Summary {
|
|||||||
ER.MinBlockCount = E.MinCount;
|
ER.MinBlockCount = E.MinCount;
|
||||||
ER.NumBlocks = E.NumCounts;
|
ER.NumBlocks = E.NumCounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
Summary(uint32_t Size) { memset(this, 0, Size); }
|
|
||||||
void operator delete(void *ptr) { ::operator delete(ptr); }
|
|
||||||
|
|
||||||
Summary() = delete;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::unique_ptr<Summary> allocSummary(uint32_t TotalSize) {
|
inline std::unique_ptr<Summary> allocSummary(uint32_t TotalSize) {
|
||||||
|
@ -92,6 +92,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::unique_ptr<InstrProfSymtab> Symtab;
|
std::unique_ptr<InstrProfSymtab> Symtab;
|
||||||
|
|
||||||
/// Set the current error and return same.
|
/// Set the current error and return same.
|
||||||
Error error(instrprof_error Err) {
|
Error error(instrprof_error Err) {
|
||||||
LastError = Err;
|
LastError = Err;
|
||||||
@ -202,7 +203,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
RawInstrProfReader(std::unique_ptr<MemoryBuffer> DataBuffer)
|
RawInstrProfReader(std::unique_ptr<MemoryBuffer> DataBuffer)
|
||||||
: DataBuffer(std::move(DataBuffer)) { }
|
: DataBuffer(std::move(DataBuffer)) {}
|
||||||
RawInstrProfReader(const RawInstrProfReader &) = delete;
|
RawInstrProfReader(const RawInstrProfReader &) = delete;
|
||||||
RawInstrProfReader &operator=(const RawInstrProfReader &) = delete;
|
RawInstrProfReader &operator=(const RawInstrProfReader &) = delete;
|
||||||
|
|
||||||
@ -268,8 +269,8 @@ private:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef RawInstrProfReader<uint32_t> RawInstrProfReader32;
|
using RawInstrProfReader32 = RawInstrProfReader<uint32_t>;
|
||||||
typedef RawInstrProfReader<uint64_t> RawInstrProfReader64;
|
using RawInstrProfReader64 = RawInstrProfReader<uint64_t>;
|
||||||
|
|
||||||
namespace IndexedInstrProf {
|
namespace IndexedInstrProf {
|
||||||
|
|
||||||
@ -292,12 +293,12 @@ public:
|
|||||||
InstrProfLookupTrait(IndexedInstrProf::HashT HashType, unsigned FormatVersion)
|
InstrProfLookupTrait(IndexedInstrProf::HashT HashType, unsigned FormatVersion)
|
||||||
: HashType(HashType), FormatVersion(FormatVersion) {}
|
: HashType(HashType), FormatVersion(FormatVersion) {}
|
||||||
|
|
||||||
typedef ArrayRef<InstrProfRecord> data_type;
|
using data_type = ArrayRef<InstrProfRecord>;
|
||||||
|
|
||||||
typedef StringRef internal_key_type;
|
using internal_key_type = StringRef;
|
||||||
typedef StringRef external_key_type;
|
using external_key_type = StringRef;
|
||||||
typedef uint64_t hash_value_type;
|
using hash_value_type = uint64_t;
|
||||||
typedef uint64_t offset_type;
|
using offset_type = uint64_t;
|
||||||
|
|
||||||
static bool EqualKey(StringRef A, StringRef B) { return A == B; }
|
static bool EqualKey(StringRef A, StringRef B) { return A == B; }
|
||||||
static StringRef GetInternalKey(StringRef K) { return K; }
|
static StringRef GetInternalKey(StringRef K) { return K; }
|
||||||
@ -346,12 +347,11 @@ struct InstrProfReaderIndexBase {
|
|||||||
virtual Error populateSymtab(InstrProfSymtab &) = 0;
|
virtual Error populateSymtab(InstrProfSymtab &) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef OnDiskIterableChainedHashTable<InstrProfLookupTrait>
|
using OnDiskHashTableImplV3 =
|
||||||
OnDiskHashTableImplV3;
|
OnDiskIterableChainedHashTable<InstrProfLookupTrait>;
|
||||||
|
|
||||||
template <typename HashTableImpl>
|
template <typename HashTableImpl>
|
||||||
class InstrProfReaderIndex : public InstrProfReaderIndexBase {
|
class InstrProfReaderIndex : public InstrProfReaderIndexBase {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<HashTableImpl> HashTable;
|
std::unique_ptr<HashTableImpl> HashTable;
|
||||||
typename HashTableImpl::data_iterator RecordIterator;
|
typename HashTableImpl::data_iterator RecordIterator;
|
||||||
|
@ -29,10 +29,11 @@ namespace llvm {
|
|||||||
/// Writer for instrumentation based profile data.
|
/// Writer for instrumentation based profile data.
|
||||||
class InstrProfRecordWriterTrait;
|
class InstrProfRecordWriterTrait;
|
||||||
class ProfOStream;
|
class ProfOStream;
|
||||||
|
class raw_fd_ostream;
|
||||||
|
|
||||||
class InstrProfWriter {
|
class InstrProfWriter {
|
||||||
public:
|
public:
|
||||||
typedef SmallDenseMap<uint64_t, InstrProfRecord, 1> ProfilingData;
|
using ProfilingData = SmallDenseMap<uint64_t, InstrProfRecord, 1>;
|
||||||
enum ProfKind { PF_Unknown = 0, PF_FE, PF_IRLevel };
|
enum ProfKind { PF_Unknown = 0, PF_FE, PF_IRLevel };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -125,7 +125,7 @@ raw_ostream &operator<<(raw_ostream &OS, const LineLocation &Loc);
|
|||||||
/// will be a list of one or more functions.
|
/// will be a list of one or more functions.
|
||||||
class SampleRecord {
|
class SampleRecord {
|
||||||
public:
|
public:
|
||||||
typedef StringMap<uint64_t> CallTargetMap;
|
using CallTargetMap = StringMap<uint64_t>;
|
||||||
|
|
||||||
SampleRecord() = default;
|
SampleRecord() = default;
|
||||||
|
|
||||||
@ -182,10 +182,11 @@ private:
|
|||||||
|
|
||||||
raw_ostream &operator<<(raw_ostream &OS, const SampleRecord &Sample);
|
raw_ostream &operator<<(raw_ostream &OS, const SampleRecord &Sample);
|
||||||
|
|
||||||
typedef std::map<LineLocation, SampleRecord> BodySampleMap;
|
|
||||||
class FunctionSamples;
|
class FunctionSamples;
|
||||||
typedef StringMap<FunctionSamples> FunctionSamplesMap;
|
|
||||||
typedef std::map<LineLocation, FunctionSamplesMap> CallsiteSampleMap;
|
using BodySampleMap = std::map<LineLocation, SampleRecord>;
|
||||||
|
using FunctionSamplesMap = StringMap<FunctionSamples>;
|
||||||
|
using CallsiteSampleMap = std::map<LineLocation, FunctionSamplesMap>;
|
||||||
|
|
||||||
/// Representation of the samples collected for a function.
|
/// Representation of the samples collected for a function.
|
||||||
///
|
///
|
||||||
@ -398,8 +399,8 @@ raw_ostream &operator<<(raw_ostream &OS, const FunctionSamples &FS);
|
|||||||
/// order of LocationT.
|
/// order of LocationT.
|
||||||
template <class LocationT, class SampleT> class SampleSorter {
|
template <class LocationT, class SampleT> class SampleSorter {
|
||||||
public:
|
public:
|
||||||
typedef std::pair<const LocationT, SampleT> SamplesWithLoc;
|
using SamplesWithLoc = std::pair<const LocationT, SampleT>;
|
||||||
typedef SmallVector<const SamplesWithLoc *, 20> SamplesWithLocList;
|
using SamplesWithLocList = SmallVector<const SamplesWithLoc *, 20>;
|
||||||
|
|
||||||
SampleSorter(const std::map<LocationT, SampleT> &Samples) {
|
SampleSorter(const std::map<LocationT, SampleT> &Samples) {
|
||||||
for (const auto &I : Samples)
|
for (const auto &I : Samples)
|
||||||
|
@ -350,7 +350,7 @@ public:
|
|||||||
class SampleProfileReaderBinary : public SampleProfileReader {
|
class SampleProfileReaderBinary : public SampleProfileReader {
|
||||||
public:
|
public:
|
||||||
SampleProfileReaderBinary(std::unique_ptr<MemoryBuffer> B, LLVMContext &C)
|
SampleProfileReaderBinary(std::unique_ptr<MemoryBuffer> B, LLVMContext &C)
|
||||||
: SampleProfileReader(std::move(B), C), Data(nullptr), End(nullptr) {}
|
: SampleProfileReader(std::move(B), C) {}
|
||||||
|
|
||||||
/// \brief Read and validate the file header.
|
/// \brief Read and validate the file header.
|
||||||
std::error_code readHeader() override;
|
std::error_code readHeader() override;
|
||||||
@ -388,10 +388,10 @@ protected:
|
|||||||
std::error_code readProfile(FunctionSamples &FProfile);
|
std::error_code readProfile(FunctionSamples &FProfile);
|
||||||
|
|
||||||
/// \brief Points to the current location in the buffer.
|
/// \brief Points to the current location in the buffer.
|
||||||
const uint8_t *Data;
|
const uint8_t *Data = nullptr;
|
||||||
|
|
||||||
/// \brief Points to the end of the buffer.
|
/// \brief Points to the end of the buffer.
|
||||||
const uint8_t *End;
|
const uint8_t *End = nullptr;
|
||||||
|
|
||||||
/// Function name table.
|
/// Function name table.
|
||||||
std::vector<StringRef> NameTable;
|
std::vector<StringRef> NameTable;
|
||||||
@ -403,7 +403,7 @@ private:
|
|||||||
std::error_code readSummary();
|
std::error_code readSummary();
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef SmallVector<FunctionSamples *, 10> InlineCallStack;
|
using InlineCallStack = SmallVector<FunctionSamples *, 10>;
|
||||||
|
|
||||||
// Supported histogram types in GCC. Currently, we only need support for
|
// Supported histogram types in GCC. Currently, we only need support for
|
||||||
// call target histograms.
|
// call target histograms.
|
||||||
|
@ -271,8 +271,8 @@ struct GCOVEdge {
|
|||||||
/// GCOVFunction - Collects function information.
|
/// GCOVFunction - Collects function information.
|
||||||
class GCOVFunction {
|
class GCOVFunction {
|
||||||
public:
|
public:
|
||||||
typedef pointee_iterator<SmallVectorImpl<
|
using BlockIterator = pointee_iterator<SmallVectorImpl<
|
||||||
std::unique_ptr<GCOVBlock>>::const_iterator> BlockIterator;
|
std::unique_ptr<GCOVBlock>>::const_iterator>;
|
||||||
|
|
||||||
GCOVFunction(GCOVFile &P) : Parent(P) {}
|
GCOVFunction(GCOVFile &P) : Parent(P) {}
|
||||||
|
|
||||||
@ -321,7 +321,7 @@ class GCOVBlock {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef SmallVectorImpl<GCOVEdge *>::const_iterator EdgeIterator;
|
using EdgeIterator = SmallVectorImpl<GCOVEdge *>::const_iterator;
|
||||||
|
|
||||||
GCOVBlock(GCOVFunction &P, uint32_t N) : Parent(P), Number(N) {}
|
GCOVBlock(GCOVFunction &P, uint32_t N) : Parent(P), Number(N) {}
|
||||||
~GCOVBlock();
|
~GCOVBlock();
|
||||||
@ -381,10 +381,10 @@ class FileInfo {
|
|||||||
// Therefore this typedef allows LineData.Functions to store multiple
|
// Therefore this typedef allows LineData.Functions to store multiple
|
||||||
// functions
|
// functions
|
||||||
// per instance. This is rare, however, so optimize for the common case.
|
// per instance. This is rare, however, so optimize for the common case.
|
||||||
typedef SmallVector<const GCOVFunction *, 1> FunctionVector;
|
using FunctionVector = SmallVector<const GCOVFunction *, 1>;
|
||||||
typedef DenseMap<uint32_t, FunctionVector> FunctionLines;
|
using FunctionLines = DenseMap<uint32_t, FunctionVector>;
|
||||||
typedef SmallVector<const GCOVBlock *, 4> BlockVector;
|
using BlockVector = SmallVector<const GCOVBlock *, 4>;
|
||||||
typedef DenseMap<uint32_t, BlockVector> BlockLines;
|
using BlockLines = DenseMap<uint32_t, BlockVector>;
|
||||||
|
|
||||||
struct LineData {
|
struct LineData {
|
||||||
LineData() = default;
|
LineData() = default;
|
||||||
@ -448,8 +448,8 @@ private:
|
|||||||
uint32_t RunCount = 0;
|
uint32_t RunCount = 0;
|
||||||
uint32_t ProgramCount = 0;
|
uint32_t ProgramCount = 0;
|
||||||
|
|
||||||
typedef SmallVector<std::pair<std::string, GCOVCoverage>, 4> FileCoverageList;
|
using FileCoverageList = SmallVector<std::pair<std::string, GCOVCoverage>, 4>;
|
||||||
typedef MapVector<const GCOVFunction *, GCOVCoverage> FuncCoverageMap;
|
using FuncCoverageMap = MapVector<const GCOVFunction *, GCOVCoverage>;
|
||||||
|
|
||||||
FileCoverageList FileCoverages;
|
FileCoverageList FileCoverages;
|
||||||
FuncCoverageMap FuncCoverages;
|
FuncCoverageMap FuncCoverages;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//===-- llvm/Support/GraphWriter.h - Write graph to a .dot file -*- C++ -*-===//
|
//===- llvm/Support/GraphWriter.h - Write graph to a .dot file --*- C++ -*-===//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
@ -24,30 +24,40 @@
|
|||||||
#define LLVM_SUPPORT_GRAPHWRITER_H
|
#define LLVM_SUPPORT_GRAPHWRITER_H
|
||||||
|
|
||||||
#include "llvm/ADT/GraphTraits.h"
|
#include "llvm/ADT/GraphTraits.h"
|
||||||
|
#include "llvm/ADT/StringRef.h"
|
||||||
#include "llvm/ADT/Twine.h"
|
#include "llvm/ADT/Twine.h"
|
||||||
#include "llvm/Support/DOTGraphTraits.h"
|
#include "llvm/Support/DOTGraphTraits.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cstddef>
|
||||||
|
#include <iterator>
|
||||||
|
#include <string>
|
||||||
|
#include <type_traits>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
namespace DOT { // Private functions...
|
namespace DOT { // Private functions...
|
||||||
std::string EscapeString(const std::string &Label);
|
|
||||||
|
|
||||||
/// \brief Get a color string for this node number. Simply round-robin selects
|
std::string EscapeString(const std::string &Label);
|
||||||
/// from a reasonable number of colors.
|
|
||||||
StringRef getColorString(unsigned NodeNumber);
|
/// \brief Get a color string for this node number. Simply round-robin selects
|
||||||
}
|
/// from a reasonable number of colors.
|
||||||
|
StringRef getColorString(unsigned NodeNumber);
|
||||||
|
|
||||||
|
} // end namespace DOT
|
||||||
|
|
||||||
namespace GraphProgram {
|
namespace GraphProgram {
|
||||||
enum Name {
|
|
||||||
DOT,
|
enum Name {
|
||||||
FDP,
|
DOT,
|
||||||
NEATO,
|
FDP,
|
||||||
TWOPI,
|
NEATO,
|
||||||
CIRCO
|
TWOPI,
|
||||||
};
|
CIRCO
|
||||||
}
|
};
|
||||||
|
|
||||||
|
} // end namespace GraphProgram
|
||||||
|
|
||||||
bool DisplayGraph(StringRef Filename, bool wait = true,
|
bool DisplayGraph(StringRef Filename, bool wait = true,
|
||||||
GraphProgram::Name program = GraphProgram::DOT);
|
GraphProgram::Name program = GraphProgram::DOT);
|
||||||
@ -57,11 +67,11 @@ class GraphWriter {
|
|||||||
raw_ostream &O;
|
raw_ostream &O;
|
||||||
const GraphType &G;
|
const GraphType &G;
|
||||||
|
|
||||||
typedef DOTGraphTraits<GraphType> DOTTraits;
|
using DOTTraits = DOTGraphTraits<GraphType>;
|
||||||
typedef GraphTraits<GraphType> GTraits;
|
using GTraits = GraphTraits<GraphType>;
|
||||||
typedef typename GTraits::NodeRef NodeRef;
|
using NodeRef = typename GTraits::NodeRef;
|
||||||
typedef typename GTraits::nodes_iterator node_iterator;
|
using node_iterator = typename GTraits::nodes_iterator;
|
||||||
typedef typename GTraits::ChildIteratorType child_iterator;
|
using child_iterator = typename GTraits::ChildIteratorType;
|
||||||
DOTTraits DTraits;
|
DOTTraits DTraits;
|
||||||
|
|
||||||
static_assert(std::is_pointer<NodeRef>::value,
|
static_assert(std::is_pointer<NodeRef>::value,
|
||||||
@ -346,6 +356,6 @@ void ViewGraph(const GraphType &G, const Twine &Name,
|
|||||||
DisplayGraph(Filename, false, Program);
|
DisplayGraph(Filename, false, Program);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // End llvm namespace
|
} // end namespace llvm
|
||||||
|
|
||||||
#endif
|
#endif // LLVM_SUPPORT_GRAPHWRITER_H
|
||||||
|
@ -54,6 +54,7 @@ class MCSymbolizer;
|
|||||||
class MCTargetAsmParser;
|
class MCTargetAsmParser;
|
||||||
class MCTargetOptions;
|
class MCTargetOptions;
|
||||||
class MCTargetStreamer;
|
class MCTargetStreamer;
|
||||||
|
class raw_ostream;
|
||||||
class raw_pwrite_stream;
|
class raw_pwrite_stream;
|
||||||
class TargetMachine;
|
class TargetMachine;
|
||||||
class TargetOptions;
|
class TargetOptions;
|
||||||
@ -96,75 +97,75 @@ class Target {
|
|||||||
public:
|
public:
|
||||||
friend struct TargetRegistry;
|
friend struct TargetRegistry;
|
||||||
|
|
||||||
typedef bool (*ArchMatchFnTy)(Triple::ArchType Arch);
|
using ArchMatchFnTy = bool (*)(Triple::ArchType Arch);
|
||||||
|
|
||||||
typedef MCAsmInfo *(*MCAsmInfoCtorFnTy)(const MCRegisterInfo &MRI,
|
using MCAsmInfoCtorFnTy = MCAsmInfo *(*)(const MCRegisterInfo &MRI,
|
||||||
const Triple &TT);
|
const Triple &TT);
|
||||||
typedef void (*MCAdjustCodeGenOptsFnTy)(const Triple &TT, Reloc::Model RM,
|
using MCAdjustCodeGenOptsFnTy = void (*)(const Triple &TT, Reloc::Model RM,
|
||||||
CodeModel::Model &CM);
|
CodeModel::Model &CM);
|
||||||
|
|
||||||
typedef MCInstrInfo *(*MCInstrInfoCtorFnTy)(void);
|
using MCInstrInfoCtorFnTy = MCInstrInfo *(*)();
|
||||||
typedef MCInstrAnalysis *(*MCInstrAnalysisCtorFnTy)(const MCInstrInfo *Info);
|
using MCInstrAnalysisCtorFnTy = MCInstrAnalysis *(*)(const MCInstrInfo *Info);
|
||||||
typedef MCRegisterInfo *(*MCRegInfoCtorFnTy)(const Triple &TT);
|
using MCRegInfoCtorFnTy = MCRegisterInfo *(*)(const Triple &TT);
|
||||||
typedef MCSubtargetInfo *(*MCSubtargetInfoCtorFnTy)(const Triple &TT,
|
using MCSubtargetInfoCtorFnTy = MCSubtargetInfo *(*)(const Triple &TT,
|
||||||
StringRef CPU,
|
StringRef CPU,
|
||||||
StringRef Features);
|
StringRef Features);
|
||||||
typedef TargetMachine *(*TargetMachineCtorTy)(
|
using TargetMachineCtorTy = TargetMachine *(*)(
|
||||||
const Target &T, const Triple &TT, StringRef CPU, StringRef Features,
|
const Target &T, const Triple &TT, StringRef CPU, StringRef Features,
|
||||||
const TargetOptions &Options, Optional<Reloc::Model> RM,
|
const TargetOptions &Options, Optional<Reloc::Model> RM,
|
||||||
CodeModel::Model CM, CodeGenOpt::Level OL);
|
CodeModel::Model CM, CodeGenOpt::Level OL);
|
||||||
// If it weren't for layering issues (this header is in llvm/Support, but
|
// If it weren't for layering issues (this header is in llvm/Support, but
|
||||||
// depends on MC?) this should take the Streamer by value rather than rvalue
|
// depends on MC?) this should take the Streamer by value rather than rvalue
|
||||||
// reference.
|
// reference.
|
||||||
typedef AsmPrinter *(*AsmPrinterCtorTy)(
|
using AsmPrinterCtorTy = AsmPrinter *(*)(
|
||||||
TargetMachine &TM, std::unique_ptr<MCStreamer> &&Streamer);
|
TargetMachine &TM, std::unique_ptr<MCStreamer> &&Streamer);
|
||||||
typedef MCAsmBackend *(*MCAsmBackendCtorTy)(const Target &T,
|
using MCAsmBackendCtorTy = MCAsmBackend *(*)(const Target &T,
|
||||||
const MCRegisterInfo &MRI,
|
const MCRegisterInfo &MRI,
|
||||||
const Triple &TT, StringRef CPU,
|
const Triple &TT, StringRef CPU,
|
||||||
const MCTargetOptions &Options);
|
const MCTargetOptions &Options);
|
||||||
typedef MCTargetAsmParser *(*MCAsmParserCtorTy)(
|
using MCAsmParserCtorTy = MCTargetAsmParser *(*)(
|
||||||
const MCSubtargetInfo &STI, MCAsmParser &P, const MCInstrInfo &MII,
|
const MCSubtargetInfo &STI, MCAsmParser &P, const MCInstrInfo &MII,
|
||||||
const MCTargetOptions &Options);
|
const MCTargetOptions &Options);
|
||||||
typedef MCDisassembler *(*MCDisassemblerCtorTy)(const Target &T,
|
using MCDisassemblerCtorTy = MCDisassembler *(*)(const Target &T,
|
||||||
const MCSubtargetInfo &STI,
|
const MCSubtargetInfo &STI,
|
||||||
MCContext &Ctx);
|
MCContext &Ctx);
|
||||||
typedef MCInstPrinter *(*MCInstPrinterCtorTy)(const Triple &T,
|
using MCInstPrinterCtorTy = MCInstPrinter *(*)(const Triple &T,
|
||||||
unsigned SyntaxVariant,
|
unsigned SyntaxVariant,
|
||||||
const MCAsmInfo &MAI,
|
const MCAsmInfo &MAI,
|
||||||
const MCInstrInfo &MII,
|
const MCInstrInfo &MII,
|
||||||
const MCRegisterInfo &MRI);
|
const MCRegisterInfo &MRI);
|
||||||
typedef MCCodeEmitter *(*MCCodeEmitterCtorTy)(const MCInstrInfo &II,
|
using MCCodeEmitterCtorTy = MCCodeEmitter *(*)(const MCInstrInfo &II,
|
||||||
const MCRegisterInfo &MRI,
|
const MCRegisterInfo &MRI,
|
||||||
MCContext &Ctx);
|
MCContext &Ctx);
|
||||||
typedef MCStreamer *(*ELFStreamerCtorTy)(const Triple &T, MCContext &Ctx,
|
using ELFStreamerCtorTy = MCStreamer *(*)(const Triple &T, MCContext &Ctx,
|
||||||
MCAsmBackend &TAB,
|
|
||||||
raw_pwrite_stream &OS,
|
|
||||||
MCCodeEmitter *Emitter,
|
|
||||||
bool RelaxAll);
|
|
||||||
typedef MCStreamer *(*MachOStreamerCtorTy)(MCContext &Ctx, MCAsmBackend &TAB,
|
|
||||||
raw_pwrite_stream &OS,
|
|
||||||
MCCodeEmitter *Emitter,
|
|
||||||
bool RelaxAll,
|
|
||||||
bool DWARFMustBeAtTheEnd);
|
|
||||||
typedef MCStreamer *(*COFFStreamerCtorTy)(MCContext &Ctx, MCAsmBackend &TAB,
|
|
||||||
raw_pwrite_stream &OS,
|
|
||||||
MCCodeEmitter *Emitter,
|
|
||||||
bool RelaxAll,
|
|
||||||
bool IncrementalLinkerCompatible);
|
|
||||||
typedef MCStreamer *(*WasmStreamerCtorTy)(const Triple &T, MCContext &Ctx,
|
|
||||||
MCAsmBackend &TAB,
|
MCAsmBackend &TAB,
|
||||||
raw_pwrite_stream &OS,
|
raw_pwrite_stream &OS,
|
||||||
MCCodeEmitter *Emitter,
|
MCCodeEmitter *Emitter,
|
||||||
bool RelaxAll);
|
bool RelaxAll);
|
||||||
typedef MCTargetStreamer *(*NullTargetStreamerCtorTy)(MCStreamer &S);
|
using MachOStreamerCtorTy = MCStreamer *(*)(MCContext &Ctx, MCAsmBackend &TAB,
|
||||||
typedef MCTargetStreamer *(*AsmTargetStreamerCtorTy)(
|
raw_pwrite_stream &OS,
|
||||||
|
MCCodeEmitter *Emitter,
|
||||||
|
bool RelaxAll,
|
||||||
|
bool DWARFMustBeAtTheEnd);
|
||||||
|
using COFFStreamerCtorTy = MCStreamer *(*)(MCContext &Ctx, MCAsmBackend &TAB,
|
||||||
|
raw_pwrite_stream &OS,
|
||||||
|
MCCodeEmitter *Emitter,
|
||||||
|
bool RelaxAll,
|
||||||
|
bool IncrementalLinkerCompatible);
|
||||||
|
using WasmStreamerCtorTy = MCStreamer *(*)(const Triple &T, MCContext &Ctx,
|
||||||
|
MCAsmBackend &TAB,
|
||||||
|
raw_pwrite_stream &OS,
|
||||||
|
MCCodeEmitter *Emitter,
|
||||||
|
bool RelaxAll);
|
||||||
|
using NullTargetStreamerCtorTy = MCTargetStreamer *(*)(MCStreamer &S);
|
||||||
|
using AsmTargetStreamerCtorTy = MCTargetStreamer *(*)(
|
||||||
MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint,
|
MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint,
|
||||||
bool IsVerboseAsm);
|
bool IsVerboseAsm);
|
||||||
typedef MCTargetStreamer *(*ObjectTargetStreamerCtorTy)(
|
using ObjectTargetStreamerCtorTy = MCTargetStreamer *(*)(
|
||||||
MCStreamer &S, const MCSubtargetInfo &STI);
|
MCStreamer &S, const MCSubtargetInfo &STI);
|
||||||
typedef MCRelocationInfo *(*MCRelocationInfoCtorTy)(const Triple &TT,
|
using MCRelocationInfoCtorTy = MCRelocationInfo *(*)(const Triple &TT,
|
||||||
MCContext &Ctx);
|
MCContext &Ctx);
|
||||||
typedef MCSymbolizer *(*MCSymbolizerCtorTy)(
|
using MCSymbolizerCtorTy = MCSymbolizer *(*)(
|
||||||
const Triple &TT, LLVMOpInfoCallback GetOpInfo,
|
const Triple &TT, LLVMOpInfoCallback GetOpInfo,
|
||||||
LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo, MCContext *Ctx,
|
LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo, MCContext *Ctx,
|
||||||
std::unique_ptr<MCRelocationInfo> &&RelInfo);
|
std::unique_ptr<MCRelocationInfo> &&RelInfo);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//===--- YAMLParser.h - Simple YAML parser --------------------------------===//
|
//===- YAMLParser.h - Simple YAML parser ------------------------*- C++ -*-===//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
@ -41,20 +41,25 @@
|
|||||||
#include "llvm/ADT/StringRef.h"
|
#include "llvm/ADT/StringRef.h"
|
||||||
#include "llvm/Support/Allocator.h"
|
#include "llvm/Support/Allocator.h"
|
||||||
#include "llvm/Support/SMLoc.h"
|
#include "llvm/Support/SMLoc.h"
|
||||||
|
#include <cassert>
|
||||||
|
#include <cstddef>
|
||||||
|
#include <iterator>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
#include <system_error>
|
#include <system_error>
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
class MemoryBufferRef;
|
class MemoryBufferRef;
|
||||||
class SourceMgr;
|
class SourceMgr;
|
||||||
class Twine;
|
|
||||||
class raw_ostream;
|
class raw_ostream;
|
||||||
|
class Twine;
|
||||||
|
|
||||||
namespace yaml {
|
namespace yaml {
|
||||||
|
|
||||||
class document_iterator;
|
|
||||||
class Document;
|
class Document;
|
||||||
|
class document_iterator;
|
||||||
class Node;
|
class Node;
|
||||||
class Scanner;
|
class Scanner;
|
||||||
struct Token;
|
struct Token;
|
||||||
@ -87,6 +92,7 @@ public:
|
|||||||
document_iterator end();
|
document_iterator end();
|
||||||
void skip();
|
void skip();
|
||||||
bool failed();
|
bool failed();
|
||||||
|
|
||||||
bool validate() {
|
bool validate() {
|
||||||
skip();
|
skip();
|
||||||
return !failed();
|
return !failed();
|
||||||
@ -95,10 +101,10 @@ public:
|
|||||||
void printError(Node *N, const Twine &Msg);
|
void printError(Node *N, const Twine &Msg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
friend class Document;
|
||||||
|
|
||||||
std::unique_ptr<Scanner> scanner;
|
std::unique_ptr<Scanner> scanner;
|
||||||
std::unique_ptr<Document> CurrentDoc;
|
std::unique_ptr<Document> CurrentDoc;
|
||||||
|
|
||||||
friend class Document;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \brief Abstract base class for all Nodes.
|
/// \brief Abstract base class for all Nodes.
|
||||||
@ -119,6 +125,18 @@ public:
|
|||||||
Node(unsigned int Type, std::unique_ptr<Document> &, StringRef Anchor,
|
Node(unsigned int Type, std::unique_ptr<Document> &, StringRef Anchor,
|
||||||
StringRef Tag);
|
StringRef Tag);
|
||||||
|
|
||||||
|
void *operator new(size_t Size, BumpPtrAllocator &Alloc,
|
||||||
|
size_t Alignment = 16) noexcept {
|
||||||
|
return Alloc.Allocate(Size, Alignment);
|
||||||
|
}
|
||||||
|
|
||||||
|
void operator delete(void *Ptr, BumpPtrAllocator &Alloc,
|
||||||
|
size_t Size) noexcept {
|
||||||
|
Alloc.Deallocate(Ptr, Size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void operator delete(void *) noexcept = delete;
|
||||||
|
|
||||||
/// \brief Get the value of the anchor attached to this node. If it does not
|
/// \brief Get the value of the anchor attached to this node. If it does not
|
||||||
/// have one, getAnchor().size() will be 0.
|
/// have one, getAnchor().size() will be 0.
|
||||||
StringRef getAnchor() const { return Anchor; }
|
StringRef getAnchor() const { return Anchor; }
|
||||||
@ -146,22 +164,10 @@ public:
|
|||||||
|
|
||||||
unsigned int getType() const { return TypeID; }
|
unsigned int getType() const { return TypeID; }
|
||||||
|
|
||||||
void *operator new(size_t Size, BumpPtrAllocator &Alloc,
|
|
||||||
size_t Alignment = 16) noexcept {
|
|
||||||
return Alloc.Allocate(Size, Alignment);
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator delete(void *Ptr, BumpPtrAllocator &Alloc,
|
|
||||||
size_t Size) noexcept {
|
|
||||||
Alloc.Deallocate(Ptr, Size);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::unique_ptr<Document> &Doc;
|
std::unique_ptr<Document> &Doc;
|
||||||
SMRange SourceRange;
|
SMRange SourceRange;
|
||||||
|
|
||||||
void operator delete(void *) noexcept = delete;
|
|
||||||
|
|
||||||
~Node() = default;
|
~Node() = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -268,8 +274,7 @@ class KeyValueNode final : public Node {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
KeyValueNode(std::unique_ptr<Document> &D)
|
KeyValueNode(std::unique_ptr<Document> &D)
|
||||||
: Node(NK_KeyValue, D, StringRef(), StringRef()), Key(nullptr),
|
: Node(NK_KeyValue, D, StringRef(), StringRef()) {}
|
||||||
Value(nullptr) {}
|
|
||||||
|
|
||||||
/// \brief Parse and return the key.
|
/// \brief Parse and return the key.
|
||||||
///
|
///
|
||||||
@ -296,8 +301,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Node *Key;
|
Node *Key = nullptr;
|
||||||
Node *Value;
|
Node *Value = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \brief This is an iterator abstraction over YAML collections shared by both
|
/// \brief This is an iterator abstraction over YAML collections shared by both
|
||||||
@ -309,7 +314,7 @@ template <class BaseT, class ValueT>
|
|||||||
class basic_collection_iterator
|
class basic_collection_iterator
|
||||||
: public std::iterator<std::input_iterator_tag, ValueT> {
|
: public std::iterator<std::input_iterator_tag, ValueT> {
|
||||||
public:
|
public:
|
||||||
basic_collection_iterator() : Base(nullptr) {}
|
basic_collection_iterator() = default;
|
||||||
basic_collection_iterator(BaseT *B) : Base(B) {}
|
basic_collection_iterator(BaseT *B) : Base(B) {}
|
||||||
|
|
||||||
ValueT *operator->() const {
|
ValueT *operator->() const {
|
||||||
@ -358,7 +363,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BaseT *Base;
|
BaseT *Base = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
// The following two templates are used for both MappingNode and Sequence Node.
|
// The following two templates are used for both MappingNode and Sequence Node.
|
||||||
@ -399,11 +404,12 @@ public:
|
|||||||
|
|
||||||
MappingNode(std::unique_ptr<Document> &D, StringRef Anchor, StringRef Tag,
|
MappingNode(std::unique_ptr<Document> &D, StringRef Anchor, StringRef Tag,
|
||||||
MappingType MT)
|
MappingType MT)
|
||||||
: Node(NK_Mapping, D, Anchor, Tag), Type(MT), IsAtBeginning(true),
|
: Node(NK_Mapping, D, Anchor, Tag), Type(MT) {}
|
||||||
IsAtEnd(false), CurrentEntry(nullptr) {}
|
|
||||||
|
|
||||||
friend class basic_collection_iterator<MappingNode, KeyValueNode>;
|
friend class basic_collection_iterator<MappingNode, KeyValueNode>;
|
||||||
typedef basic_collection_iterator<MappingNode, KeyValueNode> iterator;
|
|
||||||
|
using iterator = basic_collection_iterator<MappingNode, KeyValueNode>;
|
||||||
|
|
||||||
template <class T> friend typename T::iterator yaml::begin(T &);
|
template <class T> friend typename T::iterator yaml::begin(T &);
|
||||||
template <class T> friend void yaml::skip(T &);
|
template <class T> friend void yaml::skip(T &);
|
||||||
|
|
||||||
@ -419,9 +425,9 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
MappingType Type;
|
MappingType Type;
|
||||||
bool IsAtBeginning;
|
bool IsAtBeginning = true;
|
||||||
bool IsAtEnd;
|
bool IsAtEnd = false;
|
||||||
KeyValueNode *CurrentEntry;
|
KeyValueNode *CurrentEntry = nullptr;
|
||||||
|
|
||||||
void increment();
|
void increment();
|
||||||
};
|
};
|
||||||
@ -453,13 +459,12 @@ public:
|
|||||||
|
|
||||||
SequenceNode(std::unique_ptr<Document> &D, StringRef Anchor, StringRef Tag,
|
SequenceNode(std::unique_ptr<Document> &D, StringRef Anchor, StringRef Tag,
|
||||||
SequenceType ST)
|
SequenceType ST)
|
||||||
: Node(NK_Sequence, D, Anchor, Tag), SeqType(ST), IsAtBeginning(true),
|
: Node(NK_Sequence, D, Anchor, Tag), SeqType(ST) {}
|
||||||
IsAtEnd(false),
|
|
||||||
WasPreviousTokenFlowEntry(true), // Start with an imaginary ','.
|
|
||||||
CurrentEntry(nullptr) {}
|
|
||||||
|
|
||||||
friend class basic_collection_iterator<SequenceNode, Node>;
|
friend class basic_collection_iterator<SequenceNode, Node>;
|
||||||
typedef basic_collection_iterator<SequenceNode, Node> iterator;
|
|
||||||
|
using iterator = basic_collection_iterator<SequenceNode, Node>;
|
||||||
|
|
||||||
template <class T> friend typename T::iterator yaml::begin(T &);
|
template <class T> friend typename T::iterator yaml::begin(T &);
|
||||||
template <class T> friend void yaml::skip(T &);
|
template <class T> friend void yaml::skip(T &);
|
||||||
|
|
||||||
@ -477,10 +482,10 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
SequenceType SeqType;
|
SequenceType SeqType;
|
||||||
bool IsAtBeginning;
|
bool IsAtBeginning = true;
|
||||||
bool IsAtEnd;
|
bool IsAtEnd = false;
|
||||||
bool WasPreviousTokenFlowEntry;
|
bool WasPreviousTokenFlowEntry = true; // Start with an imaginary ','.
|
||||||
Node *CurrentEntry;
|
Node *CurrentEntry = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \brief Represents an alias to a Node with an anchor.
|
/// \brief Represents an alias to a Node with an anchor.
|
||||||
@ -507,11 +512,11 @@ private:
|
|||||||
/// node.
|
/// node.
|
||||||
class Document {
|
class Document {
|
||||||
public:
|
public:
|
||||||
|
Document(Stream &ParentStream);
|
||||||
|
|
||||||
/// \brief Root for parsing a node. Returns a single node.
|
/// \brief Root for parsing a node. Returns a single node.
|
||||||
Node *parseBlockNode();
|
Node *parseBlockNode();
|
||||||
|
|
||||||
Document(Stream &ParentStream);
|
|
||||||
|
|
||||||
/// \brief Finish parsing the current document and return true if there are
|
/// \brief Finish parsing the current document and return true if there are
|
||||||
/// more. Return false otherwise.
|
/// more. Return false otherwise.
|
||||||
bool skip();
|
bool skip();
|
||||||
@ -564,7 +569,7 @@ private:
|
|||||||
/// \brief Iterator abstraction for Documents over a Stream.
|
/// \brief Iterator abstraction for Documents over a Stream.
|
||||||
class document_iterator {
|
class document_iterator {
|
||||||
public:
|
public:
|
||||||
document_iterator() : Doc(nullptr) {}
|
document_iterator() = default;
|
||||||
document_iterator(std::unique_ptr<Document> &D) : Doc(&D) {}
|
document_iterator(std::unique_ptr<Document> &D) : Doc(&D) {}
|
||||||
|
|
||||||
bool operator==(const document_iterator &Other) {
|
bool operator==(const document_iterator &Other) {
|
||||||
@ -593,11 +598,11 @@ public:
|
|||||||
private:
|
private:
|
||||||
bool isAtEnd() const { return !Doc || !*Doc; }
|
bool isAtEnd() const { return !Doc || !*Doc; }
|
||||||
|
|
||||||
std::unique_ptr<Document> *Doc;
|
std::unique_ptr<Document> *Doc = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End namespace yaml.
|
} // end namespace yaml
|
||||||
|
|
||||||
} // End namespace llvm.
|
} // end namespace llvm
|
||||||
|
|
||||||
#endif
|
#endif // LLVM_SUPPORT_YAMLPARSER_H
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <new>
|
#include <new>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -226,7 +227,7 @@ struct MissingTrait;
|
|||||||
template <class T>
|
template <class T>
|
||||||
struct has_ScalarEnumerationTraits
|
struct has_ScalarEnumerationTraits
|
||||||
{
|
{
|
||||||
typedef void (*Signature_enumeration)(class IO&, T&);
|
using Signature_enumeration = void (*)(class IO&, T&);
|
||||||
|
|
||||||
template <typename U>
|
template <typename U>
|
||||||
static char test(SameType<Signature_enumeration, &U::enumeration>*);
|
static char test(SameType<Signature_enumeration, &U::enumeration>*);
|
||||||
@ -243,7 +244,7 @@ public:
|
|||||||
template <class T>
|
template <class T>
|
||||||
struct has_ScalarBitSetTraits
|
struct has_ScalarBitSetTraits
|
||||||
{
|
{
|
||||||
typedef void (*Signature_bitset)(class IO&, T&);
|
using Signature_bitset = void (*)(class IO&, T&);
|
||||||
|
|
||||||
template <typename U>
|
template <typename U>
|
||||||
static char test(SameType<Signature_bitset, &U::bitset>*);
|
static char test(SameType<Signature_bitset, &U::bitset>*);
|
||||||
@ -259,9 +260,9 @@ public:
|
|||||||
template <class T>
|
template <class T>
|
||||||
struct has_ScalarTraits
|
struct has_ScalarTraits
|
||||||
{
|
{
|
||||||
typedef StringRef (*Signature_input)(StringRef, void*, T&);
|
using Signature_input = StringRef (*)(StringRef, void*, T&);
|
||||||
typedef void (*Signature_output)(const T&, void*, llvm::raw_ostream&);
|
using Signature_output = void (*)(const T&, void*, raw_ostream&);
|
||||||
typedef bool (*Signature_mustQuote)(StringRef);
|
using Signature_mustQuote = bool (*)(StringRef);
|
||||||
|
|
||||||
template <typename U>
|
template <typename U>
|
||||||
static char test(SameType<Signature_input, &U::input> *,
|
static char test(SameType<Signature_input, &U::input> *,
|
||||||
@ -280,8 +281,8 @@ public:
|
|||||||
template <class T>
|
template <class T>
|
||||||
struct has_BlockScalarTraits
|
struct has_BlockScalarTraits
|
||||||
{
|
{
|
||||||
typedef StringRef (*Signature_input)(StringRef, void *, T &);
|
using Signature_input = StringRef (*)(StringRef, void *, T &);
|
||||||
typedef void (*Signature_output)(const T &, void *, llvm::raw_ostream &);
|
using Signature_output = void (*)(const T &, void *, raw_ostream &);
|
||||||
|
|
||||||
template <typename U>
|
template <typename U>
|
||||||
static char test(SameType<Signature_input, &U::input> *,
|
static char test(SameType<Signature_input, &U::input> *,
|
||||||
@ -297,7 +298,7 @@ public:
|
|||||||
|
|
||||||
// Test if MappingContextTraits<T> is defined on type T.
|
// Test if MappingContextTraits<T> is defined on type T.
|
||||||
template <class T, class Context> struct has_MappingTraits {
|
template <class T, class Context> struct has_MappingTraits {
|
||||||
typedef void (*Signature_mapping)(class IO &, T &, Context &);
|
using Signature_mapping = void (*)(class IO &, T &, Context &);
|
||||||
|
|
||||||
template <typename U>
|
template <typename U>
|
||||||
static char test(SameType<Signature_mapping, &U::mapping>*);
|
static char test(SameType<Signature_mapping, &U::mapping>*);
|
||||||
@ -312,7 +313,7 @@ public:
|
|||||||
|
|
||||||
// Test if MappingTraits<T> is defined on type T.
|
// Test if MappingTraits<T> is defined on type T.
|
||||||
template <class T> struct has_MappingTraits<T, EmptyContext> {
|
template <class T> struct has_MappingTraits<T, EmptyContext> {
|
||||||
typedef void (*Signature_mapping)(class IO &, T &);
|
using Signature_mapping = void (*)(class IO &, T &);
|
||||||
|
|
||||||
template <typename U>
|
template <typename U>
|
||||||
static char test(SameType<Signature_mapping, &U::mapping> *);
|
static char test(SameType<Signature_mapping, &U::mapping> *);
|
||||||
@ -325,7 +326,7 @@ public:
|
|||||||
|
|
||||||
// Test if MappingContextTraits<T>::validate() is defined on type T.
|
// Test if MappingContextTraits<T>::validate() is defined on type T.
|
||||||
template <class T, class Context> struct has_MappingValidateTraits {
|
template <class T, class Context> struct has_MappingValidateTraits {
|
||||||
typedef StringRef (*Signature_validate)(class IO &, T &, Context &);
|
using Signature_validate = StringRef (*)(class IO &, T &, Context &);
|
||||||
|
|
||||||
template <typename U>
|
template <typename U>
|
||||||
static char test(SameType<Signature_validate, &U::validate>*);
|
static char test(SameType<Signature_validate, &U::validate>*);
|
||||||
@ -340,7 +341,7 @@ public:
|
|||||||
|
|
||||||
// Test if MappingTraits<T>::validate() is defined on type T.
|
// Test if MappingTraits<T>::validate() is defined on type T.
|
||||||
template <class T> struct has_MappingValidateTraits<T, EmptyContext> {
|
template <class T> struct has_MappingValidateTraits<T, EmptyContext> {
|
||||||
typedef StringRef (*Signature_validate)(class IO &, T &);
|
using Signature_validate = StringRef (*)(class IO &, T &);
|
||||||
|
|
||||||
template <typename U>
|
template <typename U>
|
||||||
static char test(SameType<Signature_validate, &U::validate> *);
|
static char test(SameType<Signature_validate, &U::validate> *);
|
||||||
@ -355,7 +356,7 @@ public:
|
|||||||
template <class T>
|
template <class T>
|
||||||
struct has_SequenceMethodTraits
|
struct has_SequenceMethodTraits
|
||||||
{
|
{
|
||||||
typedef size_t (*Signature_size)(class IO&, T&);
|
using Signature_size = size_t (*)(class IO&, T&);
|
||||||
|
|
||||||
template <typename U>
|
template <typename U>
|
||||||
static char test(SameType<Signature_size, &U::size>*);
|
static char test(SameType<Signature_size, &U::size>*);
|
||||||
@ -371,7 +372,7 @@ public:
|
|||||||
template <class T>
|
template <class T>
|
||||||
struct has_CustomMappingTraits
|
struct has_CustomMappingTraits
|
||||||
{
|
{
|
||||||
typedef void (*Signature_input)(IO &io, StringRef key, T &v);
|
using Signature_input = void (*)(IO &io, StringRef key, T &v);
|
||||||
|
|
||||||
template <typename U>
|
template <typename U>
|
||||||
static char test(SameType<Signature_input, &U::inputOne>*);
|
static char test(SameType<Signature_input, &U::inputOne>*);
|
||||||
@ -422,7 +423,7 @@ struct has_SequenceTraits : public std::integral_constant<bool,
|
|||||||
template <class T>
|
template <class T>
|
||||||
struct has_DocumentListTraits
|
struct has_DocumentListTraits
|
||||||
{
|
{
|
||||||
typedef size_t (*Signature_size)(class IO&, T&);
|
using Signature_size = size_t (*)(class IO &, T &);
|
||||||
|
|
||||||
template <typename U>
|
template <typename U>
|
||||||
static char test(SameType<Signature_size, &U::size>*);
|
static char test(SameType<Signature_size, &U::size>*);
|
||||||
@ -537,7 +538,7 @@ struct unvalidatedMappingTraits
|
|||||||
// Base class for Input and Output.
|
// Base class for Input and Output.
|
||||||
class IO {
|
class IO {
|
||||||
public:
|
public:
|
||||||
IO(void *Ctxt=nullptr);
|
IO(void *Ctxt = nullptr);
|
||||||
virtual ~IO();
|
virtual ~IO();
|
||||||
|
|
||||||
virtual bool outputting() = 0;
|
virtual bool outputting() = 0;
|
||||||
@ -638,6 +639,7 @@ public:
|
|||||||
EmptyContext Ctx;
|
EmptyContext Ctx;
|
||||||
this->processKey(Key, Val, true, Ctx);
|
this->processKey(Key, Val, true, Ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename Context>
|
template <typename T, typename Context>
|
||||||
void mapRequired(const char *Key, T &Val, Context &Ctx) {
|
void mapRequired(const char *Key, T &Val, Context &Ctx) {
|
||||||
this->processKey(Key, Val, true, Ctx);
|
this->processKey(Key, Val, true, Ctx);
|
||||||
@ -773,7 +775,7 @@ typename std::enable_if<has_ScalarTraits<T>::value, void>::type
|
|||||||
yamlize(IO &io, T &Val, bool, EmptyContext &Ctx) {
|
yamlize(IO &io, T &Val, bool, EmptyContext &Ctx) {
|
||||||
if ( io.outputting() ) {
|
if ( io.outputting() ) {
|
||||||
std::string Storage;
|
std::string Storage;
|
||||||
llvm::raw_string_ostream Buffer(Storage);
|
raw_string_ostream Buffer(Storage);
|
||||||
ScalarTraits<T>::output(Val, io.getContext(), Buffer);
|
ScalarTraits<T>::output(Val, io.getContext(), Buffer);
|
||||||
StringRef Str = Buffer.str();
|
StringRef Str = Buffer.str();
|
||||||
io.scalarString(Str, ScalarTraits<T>::mustQuote(Str));
|
io.scalarString(Str, ScalarTraits<T>::mustQuote(Str));
|
||||||
@ -783,7 +785,7 @@ yamlize(IO &io, T &Val, bool, EmptyContext &Ctx) {
|
|||||||
io.scalarString(Str, ScalarTraits<T>::mustQuote(Str));
|
io.scalarString(Str, ScalarTraits<T>::mustQuote(Str));
|
||||||
StringRef Result = ScalarTraits<T>::input(Str, io.getContext(), Val);
|
StringRef Result = ScalarTraits<T>::input(Str, io.getContext(), Val);
|
||||||
if ( !Result.empty() ) {
|
if ( !Result.empty() ) {
|
||||||
io.setError(llvm::Twine(Result));
|
io.setError(Twine(Result));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -793,7 +795,7 @@ typename std::enable_if<has_BlockScalarTraits<T>::value, void>::type
|
|||||||
yamlize(IO &YamlIO, T &Val, bool, EmptyContext &Ctx) {
|
yamlize(IO &YamlIO, T &Val, bool, EmptyContext &Ctx) {
|
||||||
if (YamlIO.outputting()) {
|
if (YamlIO.outputting()) {
|
||||||
std::string Storage;
|
std::string Storage;
|
||||||
llvm::raw_string_ostream Buffer(Storage);
|
raw_string_ostream Buffer(Storage);
|
||||||
BlockScalarTraits<T>::output(Val, YamlIO.getContext(), Buffer);
|
BlockScalarTraits<T>::output(Val, YamlIO.getContext(), Buffer);
|
||||||
StringRef Str = Buffer.str();
|
StringRef Str = Buffer.str();
|
||||||
YamlIO.blockScalarString(Str);
|
YamlIO.blockScalarString(Str);
|
||||||
@ -803,7 +805,7 @@ yamlize(IO &YamlIO, T &Val, bool, EmptyContext &Ctx) {
|
|||||||
StringRef Result =
|
StringRef Result =
|
||||||
BlockScalarTraits<T>::input(Str, YamlIO.getContext(), Val);
|
BlockScalarTraits<T>::input(Str, YamlIO.getContext(), Val);
|
||||||
if (!Result.empty())
|
if (!Result.empty())
|
||||||
YamlIO.setError(llvm::Twine(Result));
|
YamlIO.setError(Twine(Result));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -817,7 +819,7 @@ yamlize(IO &io, T &Val, bool, Context &Ctx) {
|
|||||||
if (io.outputting()) {
|
if (io.outputting()) {
|
||||||
StringRef Err = MappingTraits<T>::validate(io, Val);
|
StringRef Err = MappingTraits<T>::validate(io, Val);
|
||||||
if (!Err.empty()) {
|
if (!Err.empty()) {
|
||||||
llvm::errs() << Err << "\n";
|
errs() << Err << "\n";
|
||||||
assert(Err.empty() && "invalid struct trying to be written as yaml");
|
assert(Err.empty() && "invalid struct trying to be written as yaml");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -871,7 +873,7 @@ yamlize(IO &io, T &Val, bool, EmptyContext &Ctx) {
|
|||||||
template <typename T, typename Context>
|
template <typename T, typename Context>
|
||||||
typename std::enable_if<has_SequenceTraits<T>::value, void>::type
|
typename std::enable_if<has_SequenceTraits<T>::value, void>::type
|
||||||
yamlize(IO &io, T &Seq, bool, Context &Ctx) {
|
yamlize(IO &io, T &Seq, bool, Context &Ctx) {
|
||||||
if ( has_FlowTraits< SequenceTraits<T> >::value ) {
|
if ( has_FlowTraits< SequenceTraits<T>>::value ) {
|
||||||
unsigned incnt = io.beginFlowSequence();
|
unsigned incnt = io.beginFlowSequence();
|
||||||
unsigned count = io.outputting() ? SequenceTraits<T>::size(io, Seq) : incnt;
|
unsigned count = io.outputting() ? SequenceTraits<T>::size(io, Seq) : incnt;
|
||||||
for(unsigned i=0; i < count; ++i) {
|
for(unsigned i=0; i < count; ++i) {
|
||||||
@ -899,92 +901,92 @@ yamlize(IO &io, T &Seq, bool, Context &Ctx) {
|
|||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct ScalarTraits<bool> {
|
struct ScalarTraits<bool> {
|
||||||
static void output(const bool &, void*, llvm::raw_ostream &);
|
static void output(const bool &, void* , raw_ostream &);
|
||||||
static StringRef input(StringRef, void*, bool &);
|
static StringRef input(StringRef, void *, bool &);
|
||||||
static bool mustQuote(StringRef) { return false; }
|
static bool mustQuote(StringRef) { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct ScalarTraits<StringRef> {
|
struct ScalarTraits<StringRef> {
|
||||||
static void output(const StringRef &, void*, llvm::raw_ostream &);
|
static void output(const StringRef &, void *, raw_ostream &);
|
||||||
static StringRef input(StringRef, void*, StringRef &);
|
static StringRef input(StringRef, void *, StringRef &);
|
||||||
static bool mustQuote(StringRef S) { return needsQuotes(S); }
|
static bool mustQuote(StringRef S) { return needsQuotes(S); }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct ScalarTraits<std::string> {
|
struct ScalarTraits<std::string> {
|
||||||
static void output(const std::string &, void*, llvm::raw_ostream &);
|
static void output(const std::string &, void *, raw_ostream &);
|
||||||
static StringRef input(StringRef, void*, std::string &);
|
static StringRef input(StringRef, void *, std::string &);
|
||||||
static bool mustQuote(StringRef S) { return needsQuotes(S); }
|
static bool mustQuote(StringRef S) { return needsQuotes(S); }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct ScalarTraits<uint8_t> {
|
struct ScalarTraits<uint8_t> {
|
||||||
static void output(const uint8_t &, void*, llvm::raw_ostream &);
|
static void output(const uint8_t &, void *, raw_ostream &);
|
||||||
static StringRef input(StringRef, void*, uint8_t &);
|
static StringRef input(StringRef, void *, uint8_t &);
|
||||||
static bool mustQuote(StringRef) { return false; }
|
static bool mustQuote(StringRef) { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct ScalarTraits<uint16_t> {
|
struct ScalarTraits<uint16_t> {
|
||||||
static void output(const uint16_t &, void*, llvm::raw_ostream &);
|
static void output(const uint16_t &, void *, raw_ostream &);
|
||||||
static StringRef input(StringRef, void*, uint16_t &);
|
static StringRef input(StringRef, void *, uint16_t &);
|
||||||
static bool mustQuote(StringRef) { return false; }
|
static bool mustQuote(StringRef) { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct ScalarTraits<uint32_t> {
|
struct ScalarTraits<uint32_t> {
|
||||||
static void output(const uint32_t &, void*, llvm::raw_ostream &);
|
static void output(const uint32_t &, void *, raw_ostream &);
|
||||||
static StringRef input(StringRef, void*, uint32_t &);
|
static StringRef input(StringRef, void *, uint32_t &);
|
||||||
static bool mustQuote(StringRef) { return false; }
|
static bool mustQuote(StringRef) { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct ScalarTraits<uint64_t> {
|
struct ScalarTraits<uint64_t> {
|
||||||
static void output(const uint64_t &, void*, llvm::raw_ostream &);
|
static void output(const uint64_t &, void *, raw_ostream &);
|
||||||
static StringRef input(StringRef, void*, uint64_t &);
|
static StringRef input(StringRef, void *, uint64_t &);
|
||||||
static bool mustQuote(StringRef) { return false; }
|
static bool mustQuote(StringRef) { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct ScalarTraits<int8_t> {
|
struct ScalarTraits<int8_t> {
|
||||||
static void output(const int8_t &, void*, llvm::raw_ostream &);
|
static void output(const int8_t &, void *, raw_ostream &);
|
||||||
static StringRef input(StringRef, void*, int8_t &);
|
static StringRef input(StringRef, void *, int8_t &);
|
||||||
static bool mustQuote(StringRef) { return false; }
|
static bool mustQuote(StringRef) { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct ScalarTraits<int16_t> {
|
struct ScalarTraits<int16_t> {
|
||||||
static void output(const int16_t &, void*, llvm::raw_ostream &);
|
static void output(const int16_t &, void *, raw_ostream &);
|
||||||
static StringRef input(StringRef, void*, int16_t &);
|
static StringRef input(StringRef, void *, int16_t &);
|
||||||
static bool mustQuote(StringRef) { return false; }
|
static bool mustQuote(StringRef) { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct ScalarTraits<int32_t> {
|
struct ScalarTraits<int32_t> {
|
||||||
static void output(const int32_t &, void*, llvm::raw_ostream &);
|
static void output(const int32_t &, void *, raw_ostream &);
|
||||||
static StringRef input(StringRef, void*, int32_t &);
|
static StringRef input(StringRef, void *, int32_t &);
|
||||||
static bool mustQuote(StringRef) { return false; }
|
static bool mustQuote(StringRef) { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct ScalarTraits<int64_t> {
|
struct ScalarTraits<int64_t> {
|
||||||
static void output(const int64_t &, void*, llvm::raw_ostream &);
|
static void output(const int64_t &, void *, raw_ostream &);
|
||||||
static StringRef input(StringRef, void*, int64_t &);
|
static StringRef input(StringRef, void *, int64_t &);
|
||||||
static bool mustQuote(StringRef) { return false; }
|
static bool mustQuote(StringRef) { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct ScalarTraits<float> {
|
struct ScalarTraits<float> {
|
||||||
static void output(const float &, void*, llvm::raw_ostream &);
|
static void output(const float &, void *, raw_ostream &);
|
||||||
static StringRef input(StringRef, void*, float &);
|
static StringRef input(StringRef, void *, float &);
|
||||||
static bool mustQuote(StringRef) { return false; }
|
static bool mustQuote(StringRef) { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct ScalarTraits<double> {
|
struct ScalarTraits<double> {
|
||||||
static void output(const double &, void*, llvm::raw_ostream &);
|
static void output(const double &, void *, raw_ostream &);
|
||||||
static StringRef input(StringRef, void*, double &);
|
static StringRef input(StringRef, void *, double &);
|
||||||
static bool mustQuote(StringRef) { return false; }
|
static bool mustQuote(StringRef) { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -994,12 +996,11 @@ struct ScalarTraits<double> {
|
|||||||
template <typename value_type, support::endianness endian, size_t alignment>
|
template <typename value_type, support::endianness endian, size_t alignment>
|
||||||
struct ScalarTraits<support::detail::packed_endian_specific_integral<
|
struct ScalarTraits<support::detail::packed_endian_specific_integral<
|
||||||
value_type, endian, alignment>> {
|
value_type, endian, alignment>> {
|
||||||
typedef support::detail::packed_endian_specific_integral<value_type, endian,
|
using endian_type =
|
||||||
alignment>
|
support::detail::packed_endian_specific_integral<value_type, endian,
|
||||||
endian_type;
|
alignment>;
|
||||||
|
|
||||||
static void output(const endian_type &E, void *Ctx,
|
static void output(const endian_type &E, void *Ctx, raw_ostream &Stream) {
|
||||||
llvm::raw_ostream &Stream) {
|
|
||||||
ScalarTraits<value_type>::output(static_cast<value_type>(E), Ctx, Stream);
|
ScalarTraits<value_type>::output(static_cast<value_type>(E), Ctx, Stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1039,7 +1040,7 @@ struct MappingNormalization {
|
|||||||
TNorm* operator->() { return BufPtr; }
|
TNorm* operator->() { return BufPtr; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef llvm::AlignedCharArrayUnion<TNorm> Storage;
|
using Storage = AlignedCharArrayUnion<TNorm>;
|
||||||
|
|
||||||
Storage Buffer;
|
Storage Buffer;
|
||||||
IO &io;
|
IO &io;
|
||||||
@ -1051,9 +1052,8 @@ private:
|
|||||||
// to [de]normalize an object for use with YAML conversion.
|
// to [de]normalize an object for use with YAML conversion.
|
||||||
template <typename TNorm, typename TFinal>
|
template <typename TNorm, typename TFinal>
|
||||||
struct MappingNormalizationHeap {
|
struct MappingNormalizationHeap {
|
||||||
MappingNormalizationHeap(IO &i_o, TFinal &Obj,
|
MappingNormalizationHeap(IO &i_o, TFinal &Obj, BumpPtrAllocator *allocator)
|
||||||
llvm::BumpPtrAllocator *allocator)
|
: io(i_o), Result(Obj) {
|
||||||
: io(i_o), BufPtr(nullptr), Result(Obj) {
|
|
||||||
if ( io.outputting() ) {
|
if ( io.outputting() ) {
|
||||||
BufPtr = new (&Buffer) TNorm(io, Obj);
|
BufPtr = new (&Buffer) TNorm(io, Obj);
|
||||||
}
|
}
|
||||||
@ -1077,11 +1077,11 @@ struct MappingNormalizationHeap {
|
|||||||
TNorm* operator->() { return BufPtr; }
|
TNorm* operator->() { return BufPtr; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef llvm::AlignedCharArrayUnion<TNorm> Storage;
|
using Storage = AlignedCharArrayUnion<TNorm>;
|
||||||
|
|
||||||
Storage Buffer;
|
Storage Buffer;
|
||||||
IO &io;
|
IO &io;
|
||||||
TNorm *BufPtr;
|
TNorm *BufPtr = nullptr;
|
||||||
TFinal &Result;
|
TFinal &Result;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1197,10 +1197,10 @@ private:
|
|||||||
|
|
||||||
static inline bool classof(const MapHNode *) { return true; }
|
static inline bool classof(const MapHNode *) { return true; }
|
||||||
|
|
||||||
typedef llvm::StringMap<std::unique_ptr<HNode>> NameToNode;
|
using NameToNode = StringMap<std::unique_ptr<HNode>>;
|
||||||
|
|
||||||
NameToNode Mapping;
|
NameToNode Mapping;
|
||||||
llvm::SmallVector<std::string, 6> ValidKeys;
|
SmallVector<std::string, 6> ValidKeys;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SequenceHNode : public HNode {
|
class SequenceHNode : public HNode {
|
||||||
@ -1232,14 +1232,14 @@ public:
|
|||||||
const Node *getCurrentNode() const;
|
const Node *getCurrentNode() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
llvm::SourceMgr SrcMgr; // must be before Strm
|
SourceMgr SrcMgr; // must be before Strm
|
||||||
std::unique_ptr<llvm::yaml::Stream> Strm;
|
std::unique_ptr<llvm::yaml::Stream> Strm;
|
||||||
std::unique_ptr<HNode> TopNode;
|
std::unique_ptr<HNode> TopNode;
|
||||||
std::error_code EC;
|
std::error_code EC;
|
||||||
llvm::BumpPtrAllocator StringAllocator;
|
BumpPtrAllocator StringAllocator;
|
||||||
llvm::yaml::document_iterator DocIterator;
|
document_iterator DocIterator;
|
||||||
std::vector<bool> BitValuesUsed;
|
std::vector<bool> BitValuesUsed;
|
||||||
HNode *CurrentNode;
|
HNode *CurrentNode = nullptr;
|
||||||
bool ScalarMatchFound;
|
bool ScalarMatchFound;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1249,7 +1249,7 @@ private:
|
|||||||
///
|
///
|
||||||
class Output : public IO {
|
class Output : public IO {
|
||||||
public:
|
public:
|
||||||
Output(llvm::raw_ostream &, void *Ctxt = nullptr, int WrapColumn = 70);
|
Output(raw_ostream &, void *Ctxt = nullptr, int WrapColumn = 70);
|
||||||
~Output() override;
|
~Output() override;
|
||||||
|
|
||||||
/// \brief Set whether or not to output optional values which are equal
|
/// \brief Set whether or not to output optional values which are equal
|
||||||
@ -1312,17 +1312,17 @@ private:
|
|||||||
inFlowMapOtherKey
|
inFlowMapOtherKey
|
||||||
};
|
};
|
||||||
|
|
||||||
llvm::raw_ostream &Out;
|
raw_ostream &Out;
|
||||||
int WrapColumn;
|
int WrapColumn;
|
||||||
SmallVector<InState, 8> StateStack;
|
SmallVector<InState, 8> StateStack;
|
||||||
int Column;
|
int Column = 0;
|
||||||
int ColumnAtFlowStart;
|
int ColumnAtFlowStart = 0;
|
||||||
int ColumnAtMapFlowStart;
|
int ColumnAtMapFlowStart = 0;
|
||||||
bool NeedBitValueComma;
|
bool NeedBitValueComma = false;
|
||||||
bool NeedFlowSequenceComma;
|
bool NeedFlowSequenceComma = false;
|
||||||
bool EnumerationMatchFound;
|
bool EnumerationMatchFound = false;
|
||||||
bool NeedsNewLine;
|
bool NeedsNewLine = false;
|
||||||
bool WriteDefaultValues;
|
bool WriteDefaultValues = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// YAML I/O does conversion based on types. But often native data types
|
/// YAML I/O does conversion based on types. But often native data types
|
||||||
@ -1345,7 +1345,7 @@ private:
|
|||||||
bool operator==(const _base &rhs) const { return value == rhs; } \
|
bool operator==(const _base &rhs) const { return value == rhs; } \
|
||||||
bool operator<(const _type &rhs) const { return value < rhs.value; } \
|
bool operator<(const _type &rhs) const { return value < rhs.value; } \
|
||||||
_base value; \
|
_base value; \
|
||||||
typedef _base BaseType; \
|
using BaseType = _base; \
|
||||||
};
|
};
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -1359,29 +1359,29 @@ LLVM_YAML_STRONG_TYPEDEF(uint64_t, Hex64)
|
|||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct ScalarTraits<Hex8> {
|
struct ScalarTraits<Hex8> {
|
||||||
static void output(const Hex8 &, void*, llvm::raw_ostream &);
|
static void output(const Hex8 &, void *, raw_ostream &);
|
||||||
static StringRef input(StringRef, void*, Hex8 &);
|
static StringRef input(StringRef, void *, Hex8 &);
|
||||||
static bool mustQuote(StringRef) { return false; }
|
static bool mustQuote(StringRef) { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct ScalarTraits<Hex16> {
|
struct ScalarTraits<Hex16> {
|
||||||
static void output(const Hex16 &, void*, llvm::raw_ostream &);
|
static void output(const Hex16 &, void *, raw_ostream &);
|
||||||
static StringRef input(StringRef, void*, Hex16 &);
|
static StringRef input(StringRef, void *, Hex16 &);
|
||||||
static bool mustQuote(StringRef) { return false; }
|
static bool mustQuote(StringRef) { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct ScalarTraits<Hex32> {
|
struct ScalarTraits<Hex32> {
|
||||||
static void output(const Hex32 &, void*, llvm::raw_ostream &);
|
static void output(const Hex32 &, void *, raw_ostream &);
|
||||||
static StringRef input(StringRef, void*, Hex32 &);
|
static StringRef input(StringRef, void *, Hex32 &);
|
||||||
static bool mustQuote(StringRef) { return false; }
|
static bool mustQuote(StringRef) { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct ScalarTraits<Hex64> {
|
struct ScalarTraits<Hex64> {
|
||||||
static void output(const Hex64 &, void*, llvm::raw_ostream &);
|
static void output(const Hex64 &, void *, raw_ostream &);
|
||||||
static StringRef input(StringRef, void*, Hex64 &);
|
static StringRef input(StringRef, void *, Hex64 &);
|
||||||
static bool mustQuote(StringRef) { return false; }
|
static bool mustQuote(StringRef) { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1545,8 +1545,10 @@ operator<<(Output &yout, T &seq) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T> struct SequenceTraitsImpl {
|
template <typename T> struct SequenceTraitsImpl {
|
||||||
typedef typename T::value_type _type;
|
using _type = typename T::value_type;
|
||||||
|
|
||||||
static size_t size(IO &io, T &seq) { return seq.size(); }
|
static size_t size(IO &io, T &seq) { return seq.size(); }
|
||||||
|
|
||||||
static _type &element(IO &io, T &seq, size_t index) {
|
static _type &element(IO &io, T &seq, size_t index) {
|
||||||
if (index >= seq.size())
|
if (index >= seq.size())
|
||||||
seq.resize(index + 1);
|
seq.resize(index + 1);
|
||||||
@ -1556,10 +1558,12 @@ template <typename T> struct SequenceTraitsImpl {
|
|||||||
|
|
||||||
/// Implementation of CustomMappingTraits for std::map<std::string, T>.
|
/// Implementation of CustomMappingTraits for std::map<std::string, T>.
|
||||||
template <typename T> struct StdMapStringCustomMappingTraitsImpl {
|
template <typename T> struct StdMapStringCustomMappingTraitsImpl {
|
||||||
typedef std::map<std::string, T> map_type;
|
using map_type = std::map<std::string, T>;
|
||||||
|
|
||||||
static void inputOne(IO &io, StringRef key, map_type &v) {
|
static void inputOne(IO &io, StringRef key, map_type &v) {
|
||||||
io.mapRequired(key.str().c_str(), v[key]);
|
io.mapRequired(key.str().c_str(), v[key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void output(IO &io, map_type &v) {
|
static void output(IO &io, map_type &v) {
|
||||||
for (auto &p : v)
|
for (auto &p : v)
|
||||||
io.mapRequired(p.first.c_str(), p.second);
|
io.mapRequired(p.first.c_str(), p.second);
|
||||||
@ -1637,7 +1641,7 @@ template <typename T> struct StdMapStringCustomMappingTraitsImpl {
|
|||||||
namespace llvm { \
|
namespace llvm { \
|
||||||
namespace yaml { \
|
namespace yaml { \
|
||||||
template <> struct ScalarTraits<Type> { \
|
template <> struct ScalarTraits<Type> { \
|
||||||
static void output(const Type &Value, void *ctx, llvm::raw_ostream &Out); \
|
static void output(const Type &Value, void *ctx, raw_ostream &Out); \
|
||||||
static StringRef input(StringRef Scalar, void *ctxt, Type &Value); \
|
static StringRef input(StringRef Scalar, void *ctxt, Type &Value); \
|
||||||
static bool mustQuote(StringRef) { return MustQuote; } \
|
static bool mustQuote(StringRef) { return MustQuote; } \
|
||||||
}; \
|
}; \
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//===- CoverageMapping.cpp - Code coverage mapping support ------*- C++ -*-===//
|
//===- CoverageMapping.cpp - Code coverage mapping support ----------------===//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
@ -303,8 +303,8 @@ namespace {
|
|||||||
/// An instantiation set is a collection of functions that have the same source
|
/// An instantiation set is a collection of functions that have the same source
|
||||||
/// code, ie, template functions specializations.
|
/// code, ie, template functions specializations.
|
||||||
class FunctionInstantiationSetCollector {
|
class FunctionInstantiationSetCollector {
|
||||||
typedef DenseMap<std::pair<unsigned, unsigned>,
|
using MapT = DenseMap<std::pair<unsigned, unsigned>,
|
||||||
std::vector<const FunctionRecord *>> MapT;
|
std::vector<const FunctionRecord *>>;
|
||||||
MapT InstantiatedFunctions;
|
MapT InstantiatedFunctions;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -318,7 +318,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
MapT::iterator begin() { return InstantiatedFunctions.begin(); }
|
MapT::iterator begin() { return InstantiatedFunctions.begin(); }
|
||||||
|
|
||||||
MapT::iterator end() { return InstantiatedFunctions.end(); }
|
MapT::iterator end() { return InstantiatedFunctions.end(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//===- CoverageMappingReader.cpp - Code coverage mapping reader -*- C++ -*-===//
|
//===- CoverageMappingReader.cpp - Code coverage mapping reader -----------===//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
@ -62,7 +62,7 @@ void CoverageMappingIterator::increment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Error RawCoverageReader::readULEB128(uint64_t &Result) {
|
Error RawCoverageReader::readULEB128(uint64_t &Result) {
|
||||||
if (Data.size() < 1)
|
if (Data.empty())
|
||||||
return make_error<CoverageMapError>(coveragemap_error::truncated);
|
return make_error<CoverageMapError>(coveragemap_error::truncated);
|
||||||
unsigned N = 0;
|
unsigned N = 0;
|
||||||
Result = decodeULEB128(reinterpret_cast<const uint8_t *>(Data.data()), &N);
|
Result = decodeULEB128(reinterpret_cast<const uint8_t *>(Data.data()), &N);
|
||||||
@ -392,9 +392,9 @@ struct CovMapFuncRecordReader {
|
|||||||
// A class for reading coverage mapping function records for a module.
|
// A class for reading coverage mapping function records for a module.
|
||||||
template <CovMapVersion Version, class IntPtrT, support::endianness Endian>
|
template <CovMapVersion Version, class IntPtrT, support::endianness Endian>
|
||||||
class VersionedCovMapFuncRecordReader : public CovMapFuncRecordReader {
|
class VersionedCovMapFuncRecordReader : public CovMapFuncRecordReader {
|
||||||
typedef typename CovMapTraits<
|
using FuncRecordType =
|
||||||
Version, IntPtrT>::CovMapFuncRecordType FuncRecordType;
|
typename CovMapTraits<Version, IntPtrT>::CovMapFuncRecordType;
|
||||||
typedef typename CovMapTraits<Version, IntPtrT>::NameRefType NameRefType;
|
using NameRefType = typename CovMapTraits<Version, IntPtrT>::NameRefType;
|
||||||
|
|
||||||
// Maps function's name references to the indexes of their records
|
// Maps function's name references to the indexes of their records
|
||||||
// in \c Records.
|
// in \c Records.
|
||||||
@ -576,7 +576,7 @@ static Error loadTestingFormat(StringRef Data, InstrProfSymtab &ProfileNames,
|
|||||||
Endian = support::endianness::little;
|
Endian = support::endianness::little;
|
||||||
|
|
||||||
Data = Data.substr(StringRef(TestingFormatMagic).size());
|
Data = Data.substr(StringRef(TestingFormatMagic).size());
|
||||||
if (Data.size() < 1)
|
if (Data.empty())
|
||||||
return make_error<CoverageMapError>(coveragemap_error::truncated);
|
return make_error<CoverageMapError>(coveragemap_error::truncated);
|
||||||
unsigned N = 0;
|
unsigned N = 0;
|
||||||
auto ProfileNamesSize =
|
auto ProfileNamesSize =
|
||||||
@ -584,7 +584,7 @@ static Error loadTestingFormat(StringRef Data, InstrProfSymtab &ProfileNames,
|
|||||||
if (N > Data.size())
|
if (N > Data.size())
|
||||||
return make_error<CoverageMapError>(coveragemap_error::malformed);
|
return make_error<CoverageMapError>(coveragemap_error::malformed);
|
||||||
Data = Data.substr(N);
|
Data = Data.substr(N);
|
||||||
if (Data.size() < 1)
|
if (Data.empty())
|
||||||
return make_error<CoverageMapError>(coveragemap_error::truncated);
|
return make_error<CoverageMapError>(coveragemap_error::truncated);
|
||||||
N = 0;
|
N = 0;
|
||||||
uint64_t Address =
|
uint64_t Address =
|
||||||
@ -598,7 +598,7 @@ static Error loadTestingFormat(StringRef Data, InstrProfSymtab &ProfileNames,
|
|||||||
return E;
|
return E;
|
||||||
CoverageMapping = Data.substr(ProfileNamesSize);
|
CoverageMapping = Data.substr(ProfileNamesSize);
|
||||||
// Skip the padding bytes because coverage map data has an alignment of 8.
|
// Skip the padding bytes because coverage map data has an alignment of 8.
|
||||||
if (CoverageMapping.size() < 1)
|
if (CoverageMapping.empty())
|
||||||
return make_error<CoverageMapError>(coveragemap_error::truncated);
|
return make_error<CoverageMapError>(coveragemap_error::truncated);
|
||||||
size_t Pad = alignmentAdjustment(CoverageMapping.data(), 8);
|
size_t Pad = alignmentAdjustment(CoverageMapping.data(), 8);
|
||||||
if (CoverageMapping.size() < Pad)
|
if (CoverageMapping.size() < Pad)
|
||||||
|
@ -484,8 +484,8 @@ InstrProfLookupTrait::ComputeHash(StringRef K) {
|
|||||||
return IndexedInstrProf::ComputeHash(HashType, K);
|
return IndexedInstrProf::ComputeHash(HashType, K);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef InstrProfLookupTrait::data_type data_type;
|
using data_type = InstrProfLookupTrait::data_type;
|
||||||
typedef InstrProfLookupTrait::offset_type offset_type;
|
using offset_type = InstrProfLookupTrait::offset_type;
|
||||||
|
|
||||||
bool InstrProfLookupTrait::readValueProfilingData(
|
bool InstrProfLookupTrait::readValueProfilingData(
|
||||||
const unsigned char *&D, const unsigned char *const End) {
|
const unsigned char *&D, const unsigned char *const End) {
|
||||||
@ -622,7 +622,7 @@ IndexedInstrProfReader::readSummary(IndexedInstrProf::ProfVersion Version,
|
|||||||
for (unsigned I = 0; I < SummarySize / sizeof(uint64_t); I++)
|
for (unsigned I = 0; I < SummarySize / sizeof(uint64_t); I++)
|
||||||
Dst[I] = endian::byte_swap<uint64_t, little>(Src[I]);
|
Dst[I] = endian::byte_swap<uint64_t, little>(Src[I]);
|
||||||
|
|
||||||
llvm::SummaryEntryVector DetailedSummary;
|
SummaryEntryVector DetailedSummary;
|
||||||
for (unsigned I = 0; I < SummaryData->NumCutoffEntries; I++) {
|
for (unsigned I = 0; I < SummaryData->NumCutoffEntries; I++) {
|
||||||
const IndexedInstrProf::Summary::Entry &Ent = SummaryData->getEntry(I);
|
const IndexedInstrProf::Summary::Entry &Ent = SummaryData->getEntry(I);
|
||||||
DetailedSummary.emplace_back((uint32_t)Ent.Cutoff, Ent.MinBlockCount,
|
DetailedSummary.emplace_back((uint32_t)Ent.Cutoff, Ent.MinBlockCount,
|
||||||
|
@ -69,8 +69,7 @@ public:
|
|||||||
write(P[K].D[I]);
|
write(P[K].D[I]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
raw_string_ostream &SOStream =
|
raw_string_ostream &SOStream = static_cast<raw_string_ostream &>(OS);
|
||||||
static_cast<llvm::raw_string_ostream &>(OS);
|
|
||||||
std::string &Data = SOStream.str(); // with flush
|
std::string &Data = SOStream.str(); // with flush
|
||||||
for (int K = 0; K < NItems; K++) {
|
for (int K = 0; K < NItems; K++) {
|
||||||
for (int I = 0; I < P[K].N; I++) {
|
for (int I = 0; I < P[K].N; I++) {
|
||||||
@ -91,14 +90,14 @@ public:
|
|||||||
|
|
||||||
class InstrProfRecordWriterTrait {
|
class InstrProfRecordWriterTrait {
|
||||||
public:
|
public:
|
||||||
typedef StringRef key_type;
|
using key_type = StringRef;
|
||||||
typedef StringRef key_type_ref;
|
using key_type_ref = StringRef;
|
||||||
|
|
||||||
typedef const InstrProfWriter::ProfilingData *const data_type;
|
using data_type = const InstrProfWriter::ProfilingData *const;
|
||||||
typedef const InstrProfWriter::ProfilingData *const data_type_ref;
|
using data_type_ref = const InstrProfWriter::ProfilingData *const;
|
||||||
|
|
||||||
typedef uint64_t hash_value_type;
|
using hash_value_type = uint64_t;
|
||||||
typedef uint64_t offset_type;
|
using offset_type = uint64_t;
|
||||||
|
|
||||||
support::endianness ValueProfDataEndianness = support::little;
|
support::endianness ValueProfDataEndianness = support::little;
|
||||||
InstrProfSummaryBuilder *SummaryBuilder;
|
InstrProfSummaryBuilder *SummaryBuilder;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//===-- GraphWriter.cpp - Implements GraphWriter support routines ---------===//
|
//===- GraphWriter.cpp - Implements GraphWriter support routines ----------===//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
@ -12,10 +12,22 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "llvm/Support/GraphWriter.h"
|
#include "llvm/Support/GraphWriter.h"
|
||||||
|
#include "llvm/ADT/SmallString.h"
|
||||||
|
#include "llvm/ADT/SmallVector.h"
|
||||||
|
#include "llvm/ADT/StringRef.h"
|
||||||
#include "llvm/Config/config.h"
|
#include "llvm/Config/config.h"
|
||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
|
#include "llvm/Support/Compiler.h"
|
||||||
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
|
#include "llvm/Support/ErrorOr.h"
|
||||||
#include "llvm/Support/FileSystem.h"
|
#include "llvm/Support/FileSystem.h"
|
||||||
#include "llvm/Support/Program.h"
|
#include "llvm/Support/Program.h"
|
||||||
|
#include "llvm/Support/raw_ostream.h"
|
||||||
|
#include <cassert>
|
||||||
|
#include <system_error>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
static cl::opt<bool> ViewBackground("view-background", cl::Hidden,
|
static cl::opt<bool> ViewBackground("view-background", cl::Hidden,
|
||||||
@ -99,8 +111,10 @@ static bool ExecGraphViewer(StringRef ExecPath, std::vector<const char *> &args,
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
struct GraphSession {
|
struct GraphSession {
|
||||||
std::string LogBuffer;
|
std::string LogBuffer;
|
||||||
|
|
||||||
bool TryFindProgram(StringRef Names, std::string &ProgramPath) {
|
bool TryFindProgram(StringRef Names, std::string &ProgramPath) {
|
||||||
raw_string_ostream Log(LogBuffer);
|
raw_string_ostream Log(LogBuffer);
|
||||||
SmallVector<StringRef, 8> parts;
|
SmallVector<StringRef, 8> parts;
|
||||||
@ -115,7 +129,8 @@ struct GraphSession {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace
|
|
||||||
|
} // end anonymous namespace
|
||||||
|
|
||||||
static const char *getProgramName(GraphProgram::Name program) {
|
static const char *getProgramName(GraphProgram::Name program) {
|
||||||
switch (program) {
|
switch (program) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//===--- YAMLParser.cpp - Simple YAML parser ------------------------------===//
|
//===- YAMLParser.cpp - Simple YAML parser --------------------------------===//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
@ -13,15 +13,29 @@
|
|||||||
|
|
||||||
#include "llvm/Support/YAMLParser.h"
|
#include "llvm/Support/YAMLParser.h"
|
||||||
#include "llvm/ADT/AllocatorList.h"
|
#include "llvm/ADT/AllocatorList.h"
|
||||||
|
#include "llvm/ADT/ArrayRef.h"
|
||||||
|
#include "llvm/ADT/None.h"
|
||||||
#include "llvm/ADT/STLExtras.h"
|
#include "llvm/ADT/STLExtras.h"
|
||||||
#include "llvm/ADT/SmallString.h"
|
#include "llvm/ADT/SmallString.h"
|
||||||
#include "llvm/ADT/SmallVector.h"
|
#include "llvm/ADT/SmallVector.h"
|
||||||
#include "llvm/ADT/StringExtras.h"
|
#include "llvm/ADT/StringExtras.h"
|
||||||
|
#include "llvm/ADT/StringRef.h"
|
||||||
#include "llvm/ADT/Twine.h"
|
#include "llvm/ADT/Twine.h"
|
||||||
|
#include "llvm/Support/Compiler.h"
|
||||||
#include "llvm/Support/ErrorHandling.h"
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
#include "llvm/Support/MemoryBuffer.h"
|
#include "llvm/Support/MemoryBuffer.h"
|
||||||
|
#include "llvm/Support/SMLoc.h"
|
||||||
#include "llvm/Support/SourceMgr.h"
|
#include "llvm/Support/SourceMgr.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cassert>
|
||||||
|
#include <cstddef>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
#include <system_error>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
using namespace yaml;
|
using namespace yaml;
|
||||||
@ -37,7 +51,7 @@ enum UnicodeEncodingForm {
|
|||||||
|
|
||||||
/// EncodingInfo - Holds the encoding type and length of the byte order mark if
|
/// EncodingInfo - Holds the encoding type and length of the byte order mark if
|
||||||
/// it exists. Length is in {0, 2, 3, 4}.
|
/// it exists. Length is in {0, 2, 3, 4}.
|
||||||
typedef std::pair<UnicodeEncodingForm, unsigned> EncodingInfo;
|
using EncodingInfo = std::pair<UnicodeEncodingForm, unsigned>;
|
||||||
|
|
||||||
/// getUnicodeEncoding - Reads up to the first 4 bytes to determine the Unicode
|
/// getUnicodeEncoding - Reads up to the first 4 bytes to determine the Unicode
|
||||||
/// encoding form of \a Input.
|
/// encoding form of \a Input.
|
||||||
@ -46,7 +60,7 @@ typedef std::pair<UnicodeEncodingForm, unsigned> EncodingInfo;
|
|||||||
/// @returns An EncodingInfo indicating the Unicode encoding form of the input
|
/// @returns An EncodingInfo indicating the Unicode encoding form of the input
|
||||||
/// and how long the byte order mark is if one exists.
|
/// and how long the byte order mark is if one exists.
|
||||||
static EncodingInfo getUnicodeEncoding(StringRef Input) {
|
static EncodingInfo getUnicodeEncoding(StringRef Input) {
|
||||||
if (Input.size() == 0)
|
if (Input.empty())
|
||||||
return std::make_pair(UEF_Unknown, 0);
|
return std::make_pair(UEF_Unknown, 0);
|
||||||
|
|
||||||
switch (uint8_t(Input[0])) {
|
switch (uint8_t(Input[0])) {
|
||||||
@ -95,8 +109,6 @@ static EncodingInfo getUnicodeEncoding(StringRef Input) {
|
|||||||
return std::make_pair(UEF_UTF8, 0);
|
return std::make_pair(UEF_UTF8, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace llvm {
|
|
||||||
namespace yaml {
|
|
||||||
/// Pin the vtables to this file.
|
/// Pin the vtables to this file.
|
||||||
void Node::anchor() {}
|
void Node::anchor() {}
|
||||||
void NullNode::anchor() {}
|
void NullNode::anchor() {}
|
||||||
@ -107,6 +119,9 @@ void MappingNode::anchor() {}
|
|||||||
void SequenceNode::anchor() {}
|
void SequenceNode::anchor() {}
|
||||||
void AliasNode::anchor() {}
|
void AliasNode::anchor() {}
|
||||||
|
|
||||||
|
namespace llvm {
|
||||||
|
namespace yaml {
|
||||||
|
|
||||||
/// Token - A single YAML token.
|
/// Token - A single YAML token.
|
||||||
struct Token {
|
struct Token {
|
||||||
enum TokenKind {
|
enum TokenKind {
|
||||||
@ -133,7 +148,7 @@ struct Token {
|
|||||||
TK_Alias,
|
TK_Alias,
|
||||||
TK_Anchor,
|
TK_Anchor,
|
||||||
TK_Tag
|
TK_Tag
|
||||||
} Kind;
|
} Kind = TK_Error;
|
||||||
|
|
||||||
/// A string of length 0 or more whose begin() points to the logical location
|
/// A string of length 0 or more whose begin() points to the logical location
|
||||||
/// of the token in the input.
|
/// of the token in the input.
|
||||||
@ -142,14 +157,16 @@ struct Token {
|
|||||||
/// The value of a block scalar node.
|
/// The value of a block scalar node.
|
||||||
std::string Value;
|
std::string Value;
|
||||||
|
|
||||||
Token() : Kind(TK_Error) {}
|
Token() = default;
|
||||||
};
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef llvm::BumpPtrList<Token> TokenQueueT;
|
} // end namespace yaml
|
||||||
|
} // end namespace llvm
|
||||||
|
|
||||||
|
using TokenQueueT = BumpPtrList<Token>;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
/// @brief This struct is used to track simple keys.
|
/// @brief This struct is used to track simple keys.
|
||||||
///
|
///
|
||||||
/// Simple keys are handled by creating an entry in SimpleKeys for each Token
|
/// Simple keys are handled by creating an entry in SimpleKeys for each Token
|
||||||
@ -170,12 +187,13 @@ struct SimpleKey {
|
|||||||
return Tok == Other.Tok;
|
return Tok == Other.Tok;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
} // end anonymous namespace
|
||||||
|
|
||||||
/// @brief The Unicode scalar value of a UTF-8 minimal well-formed code unit
|
/// @brief The Unicode scalar value of a UTF-8 minimal well-formed code unit
|
||||||
/// subsequence and the subsequence's length in code units (uint8_t).
|
/// subsequence and the subsequence's length in code units (uint8_t).
|
||||||
/// A length of 0 represents an error.
|
/// A length of 0 represents an error.
|
||||||
typedef std::pair<uint32_t, unsigned> UTF8Decoded;
|
using UTF8Decoded = std::pair<uint32_t, unsigned>;
|
||||||
|
|
||||||
static UTF8Decoded decodeUTF8(StringRef Range) {
|
static UTF8Decoded decodeUTF8(StringRef Range) {
|
||||||
StringRef::iterator Position= Range.begin();
|
StringRef::iterator Position= Range.begin();
|
||||||
@ -229,6 +247,7 @@ static UTF8Decoded decodeUTF8(StringRef Range) {
|
|||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
namespace yaml {
|
namespace yaml {
|
||||||
|
|
||||||
/// @brief Scans YAML tokens from a MemoryBuffer.
|
/// @brief Scans YAML tokens from a MemoryBuffer.
|
||||||
class Scanner {
|
class Scanner {
|
||||||
public:
|
public:
|
||||||
@ -350,7 +369,8 @@ private:
|
|||||||
/// ns-char.
|
/// ns-char.
|
||||||
StringRef::iterator skip_ns_char(StringRef::iterator Position);
|
StringRef::iterator skip_ns_char(StringRef::iterator Position);
|
||||||
|
|
||||||
typedef StringRef::iterator (Scanner::*SkipWhileFunc)(StringRef::iterator);
|
using SkipWhileFunc = StringRef::iterator (Scanner::*)(StringRef::iterator);
|
||||||
|
|
||||||
/// @brief Skip minimal well-formed code unit subsequences until Func
|
/// @brief Skip minimal well-formed code unit subsequences until Func
|
||||||
/// returns its input.
|
/// returns its input.
|
||||||
///
|
///
|
||||||
@ -655,10 +675,10 @@ bool yaml::dumpTokens(StringRef Input, raw_ostream &OS) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool yaml::scanTokens(StringRef Input) {
|
bool yaml::scanTokens(StringRef Input) {
|
||||||
llvm::SourceMgr SM;
|
SourceMgr SM;
|
||||||
llvm::yaml::Scanner scanner(Input, SM);
|
Scanner scanner(Input, SM);
|
||||||
for (;;) {
|
while (true) {
|
||||||
llvm::yaml::Token T = scanner.getNext();
|
Token T = scanner.getNext();
|
||||||
if (T.Kind == Token::TK_StreamEnd)
|
if (T.Kind == Token::TK_StreamEnd)
|
||||||
break;
|
break;
|
||||||
else if (T.Kind == Token::TK_Error)
|
else if (T.Kind == Token::TK_Error)
|
||||||
@ -1744,7 +1764,7 @@ Stream::Stream(MemoryBufferRef InputBuffer, SourceMgr &SM, bool ShowColors,
|
|||||||
std::error_code *EC)
|
std::error_code *EC)
|
||||||
: scanner(new Scanner(InputBuffer, SM, ShowColors, EC)), CurrentDoc() {}
|
: scanner(new Scanner(InputBuffer, SM, ShowColors, EC)), CurrentDoc() {}
|
||||||
|
|
||||||
Stream::~Stream() {}
|
Stream::~Stream() = default;
|
||||||
|
|
||||||
bool Stream::failed() { return scanner->failed(); }
|
bool Stream::failed() { return scanner->failed(); }
|
||||||
|
|
||||||
@ -1851,8 +1871,6 @@ bool Node::failed() const {
|
|||||||
return Doc->failed();
|
return Doc->failed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
StringRef ScalarNode::getValue(SmallVectorImpl<char> &Storage) const {
|
StringRef ScalarNode::getValue(SmallVectorImpl<char> &Storage) const {
|
||||||
// TODO: Handle newlines properly. We need to remove leading whitespace.
|
// TODO: Handle newlines properly. We need to remove leading whitespace.
|
||||||
if (Value[0] == '"') { // Double quoted.
|
if (Value[0] == '"') { // Double quoted.
|
||||||
|
@ -8,17 +8,26 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "llvm/Support/YAMLTraits.h"
|
#include "llvm/Support/YAMLTraits.h"
|
||||||
|
#include "llvm/ADT/STLExtras.h"
|
||||||
#include "llvm/ADT/SmallString.h"
|
#include "llvm/ADT/SmallString.h"
|
||||||
|
#include "llvm/ADT/StringRef.h"
|
||||||
#include "llvm/ADT/Twine.h"
|
#include "llvm/ADT/Twine.h"
|
||||||
#include "llvm/Support/Casting.h"
|
#include "llvm/Support/Casting.h"
|
||||||
#include "llvm/Support/Errc.h"
|
#include "llvm/Support/Errc.h"
|
||||||
#include "llvm/Support/ErrorHandling.h"
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
#include "llvm/Support/Format.h"
|
#include "llvm/Support/Format.h"
|
||||||
#include "llvm/Support/LineIterator.h"
|
#include "llvm/Support/LineIterator.h"
|
||||||
|
#include "llvm/Support/MemoryBuffer.h"
|
||||||
#include "llvm/Support/YAMLParser.h"
|
#include "llvm/Support/YAMLParser.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include <cctype>
|
#include <algorithm>
|
||||||
|
#include <cassert>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
using namespace yaml;
|
using namespace yaml;
|
||||||
|
|
||||||
@ -26,11 +35,9 @@ using namespace yaml;
|
|||||||
// IO
|
// IO
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
IO::IO(void *Context) : Ctxt(Context) {
|
IO::IO(void *Context) : Ctxt(Context) {}
|
||||||
}
|
|
||||||
|
|
||||||
IO::~IO() {
|
IO::~IO() = default;
|
||||||
}
|
|
||||||
|
|
||||||
void *IO::getContext() {
|
void *IO::getContext() {
|
||||||
return Ctxt;
|
return Ctxt;
|
||||||
@ -46,15 +53,13 @@ void IO::setContext(void *Context) {
|
|||||||
|
|
||||||
Input::Input(StringRef InputContent, void *Ctxt,
|
Input::Input(StringRef InputContent, void *Ctxt,
|
||||||
SourceMgr::DiagHandlerTy DiagHandler, void *DiagHandlerCtxt)
|
SourceMgr::DiagHandlerTy DiagHandler, void *DiagHandlerCtxt)
|
||||||
: IO(Ctxt), Strm(new Stream(InputContent, SrcMgr, false, &EC)),
|
: IO(Ctxt), Strm(new Stream(InputContent, SrcMgr, false, &EC)) {
|
||||||
CurrentNode(nullptr) {
|
|
||||||
if (DiagHandler)
|
if (DiagHandler)
|
||||||
SrcMgr.setDiagHandler(DiagHandler, DiagHandlerCtxt);
|
SrcMgr.setDiagHandler(DiagHandler, DiagHandlerCtxt);
|
||||||
DocIterator = Strm->begin();
|
DocIterator = Strm->begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
Input::~Input() {
|
Input::~Input() = default;
|
||||||
}
|
|
||||||
|
|
||||||
std::error_code Input::error() { return EC; }
|
std::error_code Input::error() { return EC; }
|
||||||
|
|
||||||
@ -398,13 +403,9 @@ bool Input::canElideEmptySequence() {
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
Output::Output(raw_ostream &yout, void *context, int WrapColumn)
|
Output::Output(raw_ostream &yout, void *context, int WrapColumn)
|
||||||
: IO(context), Out(yout), WrapColumn(WrapColumn), Column(0),
|
: IO(context), Out(yout), WrapColumn(WrapColumn) {}
|
||||||
ColumnAtFlowStart(0), ColumnAtMapFlowStart(0), NeedBitValueComma(false),
|
|
||||||
NeedFlowSequenceComma(false), EnumerationMatchFound(false),
|
|
||||||
NeedsNewLine(false), WriteDefaultValues(false) {}
|
|
||||||
|
|
||||||
Output::~Output() {
|
Output::~Output() = default;
|
||||||
}
|
|
||||||
|
|
||||||
bool Output::outputting() {
|
bool Output::outputting() {
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user