std::vector<CoverageSegment>::const_iterator begin() const {
return Segments.begin();
}
+
std::vector<CoverageSegment>::const_iterator end() const {
return Segments.end();
}
+
bool empty() const { return Segments.empty(); }
/// \brief Expansions that can be further processed.
unsigned MismatchedFunctionCount = 0;
CoverageMapping() = default;
+
/// \brief Add a function record corresponding to \p Record.
Error loadFunctionRecord(const CoverageMappingRecord &Record,
IndexedInstrProfReader &ProfileReader);
};
template <int CovMapVersion, class IntPtrT> struct CovMapTraits {
- typedef CovMapFunctionRecord CovMapFuncRecordType;
- typedef uint64_t NameRefType;
+ using CovMapFuncRecordType = CovMapFunctionRecord;
+ using NameRefType = uint64_t;
};
template <class IntPtrT> struct CovMapTraits<CovMapVersion::Version1, IntPtrT> {
- typedef CovMapFunctionRecordV1<IntPtrT> CovMapFuncRecordType;
- typedef IntPtrT NameRefType;
+ using CovMapFuncRecordType = CovMapFunctionRecordV1<IntPtrT>;
+ using NameRefType = IntPtrT;
};
} // end namespace coverage
template<> struct DenseMapInfo<coverage::CounterExpression> {
static inline coverage::CounterExpression getEmptyKey() {
using namespace coverage;
+
return CounterExpression(CounterExpression::ExprKind::Subtract,
Counter::getCounter(~0U),
Counter::getCounter(~0U));
static inline coverage::CounterExpression getTombstoneKey() {
using namespace coverage;
+
return CounterExpression(CounterExpression::ExprKind::Add,
Counter::getCounter(~0U),
Counter::getCounter(~0U));
/// on how PGO name is formed.
class InstrProfSymtab {
public:
- typedef std::vector<std::pair<uint64_t, uint64_t>> AddrHashMap;
+ using AddrHashMap = std::vector<std::pair<uint64_t, uint64_t>>;
private:
StringRef Data;
InstrProfRecord(StringRef Name, uint64_t Hash, std::vector<uint64_t> 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
/// of profile sites.
private:
std::vector<InstrProfValueSiteRecord> IndirectCallSites;
std::vector<InstrProfValueSiteRecord> MemOPSizes;
- const std::vector<InstrProfValueSiteRecord> &
+ const std::vector<InstrProfValueSiteRecord> &
getValueSitesForKind(uint32_t ValueKind) const {
switch (ValueKind) {
case IPVK_IndirectCallTarget:
// The number of Cutoff Entries (Summary::Entry) following summary fields.
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) {
return sizeof(Summary) + NumCutoffEntries * sizeof(Entry) +
NumSumFields * sizeof(uint64_t);
ER.MinBlockCount = E.MinCount;
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) {
protected:
std::unique_ptr<InstrProfSymtab> Symtab;
+
/// Set the current error and return same.
Error error(instrprof_error Err) {
LastError = Err;
public:
RawInstrProfReader(std::unique_ptr<MemoryBuffer> DataBuffer)
- : DataBuffer(std::move(DataBuffer)) { }
+ : DataBuffer(std::move(DataBuffer)) {}
RawInstrProfReader(const RawInstrProfReader &) = delete;
RawInstrProfReader &operator=(const RawInstrProfReader &) = delete;
}
};
-typedef RawInstrProfReader<uint32_t> RawInstrProfReader32;
-typedef RawInstrProfReader<uint64_t> RawInstrProfReader64;
+using RawInstrProfReader32 = RawInstrProfReader<uint32_t>;
+using RawInstrProfReader64 = RawInstrProfReader<uint64_t>;
namespace IndexedInstrProf {
InstrProfLookupTrait(IndexedInstrProf::HashT HashType, unsigned FormatVersion)
: HashType(HashType), FormatVersion(FormatVersion) {}
- typedef ArrayRef<InstrProfRecord> data_type;
+ using data_type = ArrayRef<InstrProfRecord>;
- typedef StringRef internal_key_type;
- typedef StringRef external_key_type;
- typedef uint64_t hash_value_type;
- typedef uint64_t offset_type;
+ using internal_key_type = StringRef;
+ using external_key_type = StringRef;
+ using hash_value_type = uint64_t;
+ using offset_type = uint64_t;
static bool EqualKey(StringRef A, StringRef B) { return A == B; }
static StringRef GetInternalKey(StringRef K) { return K; }
virtual Error populateSymtab(InstrProfSymtab &) = 0;
};
-typedef OnDiskIterableChainedHashTable<InstrProfLookupTrait>
- OnDiskHashTableImplV3;
+using OnDiskHashTableImplV3 =
+ OnDiskIterableChainedHashTable<InstrProfLookupTrait>;
template <typename HashTableImpl>
class InstrProfReaderIndex : public InstrProfReaderIndexBase {
-
private:
std::unique_ptr<HashTableImpl> HashTable;
typename HashTableImpl::data_iterator RecordIterator;
/// Writer for instrumentation based profile data.
class InstrProfRecordWriterTrait;
class ProfOStream;
+class raw_fd_ostream;
class InstrProfWriter {
public:
- typedef SmallDenseMap<uint64_t, InstrProfRecord, 1> ProfilingData;
+ using ProfilingData = SmallDenseMap<uint64_t, InstrProfRecord, 1>;
enum ProfKind { PF_Unknown = 0, PF_FE, PF_IRLevel };
private:
/// will be a list of one or more functions.
class SampleRecord {
public:
- typedef StringMap<uint64_t> CallTargetMap;
+ using CallTargetMap = StringMap<uint64_t>;
SampleRecord() = default;
raw_ostream &operator<<(raw_ostream &OS, const SampleRecord &Sample);
-typedef std::map<LineLocation, SampleRecord> BodySampleMap;
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.
///
/// order of LocationT.
template <class LocationT, class SampleT> class SampleSorter {
public:
- typedef std::pair<const LocationT, SampleT> SamplesWithLoc;
- typedef SmallVector<const SamplesWithLoc *, 20> SamplesWithLocList;
+ using SamplesWithLoc = std::pair<const LocationT, SampleT>;
+ using SamplesWithLocList = SmallVector<const SamplesWithLoc *, 20>;
SampleSorter(const std::map<LocationT, SampleT> &Samples) {
for (const auto &I : Samples)
class SampleProfileReaderBinary : public SampleProfileReader {
public:
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.
std::error_code readHeader() override;
std::error_code readProfile(FunctionSamples &FProfile);
/// \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.
- const uint8_t *End;
+ const uint8_t *End = nullptr;
/// Function name table.
std::vector<StringRef> NameTable;
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
// call target histograms.
/// GCOVFunction - Collects function information.
class GCOVFunction {
public:
- typedef pointee_iterator<SmallVectorImpl<
- std::unique_ptr<GCOVBlock>>::const_iterator> BlockIterator;
+ using BlockIterator = pointee_iterator<SmallVectorImpl<
+ std::unique_ptr<GCOVBlock>>::const_iterator>;
GCOVFunction(GCOVFile &P) : Parent(P) {}
};
public:
- typedef SmallVectorImpl<GCOVEdge *>::const_iterator EdgeIterator;
+ using EdgeIterator = SmallVectorImpl<GCOVEdge *>::const_iterator;
GCOVBlock(GCOVFunction &P, uint32_t N) : Parent(P), Number(N) {}
~GCOVBlock();
// Therefore this typedef allows LineData.Functions to store multiple
// functions
// per instance. This is rare, however, so optimize for the common case.
- typedef SmallVector<const GCOVFunction *, 1> FunctionVector;
- typedef DenseMap<uint32_t, FunctionVector> FunctionLines;
- typedef SmallVector<const GCOVBlock *, 4> BlockVector;
- typedef DenseMap<uint32_t, BlockVector> BlockLines;
+ using FunctionVector = SmallVector<const GCOVFunction *, 1>;
+ using FunctionLines = DenseMap<uint32_t, FunctionVector>;
+ using BlockVector = SmallVector<const GCOVBlock *, 4>;
+ using BlockLines = DenseMap<uint32_t, BlockVector>;
struct LineData {
LineData() = default;
uint32_t RunCount = 0;
uint32_t ProgramCount = 0;
- typedef SmallVector<std::pair<std::string, GCOVCoverage>, 4> FileCoverageList;
- typedef MapVector<const GCOVFunction *, GCOVCoverage> FuncCoverageMap;
+ using FileCoverageList = SmallVector<std::pair<std::string, GCOVCoverage>, 4>;
+ using FuncCoverageMap = MapVector<const GCOVFunction *, GCOVCoverage>;
FileCoverageList FileCoverages;
FuncCoverageMap FuncCoverages;
-//===-- 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
//
#define LLVM_SUPPORT_GRAPHWRITER_H
#include "llvm/ADT/GraphTraits.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/DOTGraphTraits.h"
#include "llvm/Support/raw_ostream.h"
+#include <algorithm>
+#include <cstddef>
+#include <iterator>
+#include <string>
+#include <type_traits>
#include <vector>
namespace llvm {
namespace DOT { // Private functions...
- std::string EscapeString(const std::string &Label);
- /// \brief Get a color string for this node number. Simply round-robin selects
- /// from a reasonable number of colors.
- StringRef getColorString(unsigned NodeNumber);
-}
+std::string EscapeString(const std::string &Label);
+
+/// \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 {
- enum Name {
- DOT,
- FDP,
- NEATO,
- TWOPI,
- CIRCO
- };
-}
+
+enum Name {
+ DOT,
+ FDP,
+ NEATO,
+ TWOPI,
+ CIRCO
+};
+
+} // end namespace GraphProgram
bool DisplayGraph(StringRef Filename, bool wait = true,
GraphProgram::Name program = GraphProgram::DOT);
raw_ostream &O;
const GraphType &G;
- typedef DOTGraphTraits<GraphType> DOTTraits;
- typedef GraphTraits<GraphType> GTraits;
- typedef typename GTraits::NodeRef NodeRef;
- typedef typename GTraits::nodes_iterator node_iterator;
- typedef typename GTraits::ChildIteratorType child_iterator;
+ using DOTTraits = DOTGraphTraits<GraphType>;
+ using GTraits = GraphTraits<GraphType>;
+ using NodeRef = typename GTraits::NodeRef;
+ using node_iterator = typename GTraits::nodes_iterator;
+ using child_iterator = typename GTraits::ChildIteratorType;
DOTTraits DTraits;
static_assert(std::is_pointer<NodeRef>::value,
DisplayGraph(Filename, false, Program);
}
-} // End llvm namespace
+} // end namespace llvm
-#endif
+#endif // LLVM_SUPPORT_GRAPHWRITER_H
class MCTargetAsmParser;
class MCTargetOptions;
class MCTargetStreamer;
+class raw_ostream;
class raw_pwrite_stream;
class TargetMachine;
class TargetOptions;
public:
friend struct TargetRegistry;
- typedef bool (*ArchMatchFnTy)(Triple::ArchType Arch);
+ using ArchMatchFnTy = bool (*)(Triple::ArchType Arch);
- typedef MCAsmInfo *(*MCAsmInfoCtorFnTy)(const MCRegisterInfo &MRI,
- const Triple &TT);
- typedef void (*MCAdjustCodeGenOptsFnTy)(const Triple &TT, Reloc::Model RM,
- CodeModel::Model &CM);
+ using MCAsmInfoCtorFnTy = MCAsmInfo *(*)(const MCRegisterInfo &MRI,
+ const Triple &TT);
+ using MCAdjustCodeGenOptsFnTy = void (*)(const Triple &TT, Reloc::Model RM,
+ CodeModel::Model &CM);
- typedef MCInstrInfo *(*MCInstrInfoCtorFnTy)(void);
- typedef MCInstrAnalysis *(*MCInstrAnalysisCtorFnTy)(const MCInstrInfo *Info);
- typedef MCRegisterInfo *(*MCRegInfoCtorFnTy)(const Triple &TT);
- typedef MCSubtargetInfo *(*MCSubtargetInfoCtorFnTy)(const Triple &TT,
- StringRef CPU,
- StringRef Features);
- typedef TargetMachine *(*TargetMachineCtorTy)(
+ using MCInstrInfoCtorFnTy = MCInstrInfo *(*)();
+ using MCInstrAnalysisCtorFnTy = MCInstrAnalysis *(*)(const MCInstrInfo *Info);
+ using MCRegInfoCtorFnTy = MCRegisterInfo *(*)(const Triple &TT);
+ using MCSubtargetInfoCtorFnTy = MCSubtargetInfo *(*)(const Triple &TT,
+ StringRef CPU,
+ StringRef Features);
+ using TargetMachineCtorTy = TargetMachine *(*)(
const Target &T, const Triple &TT, StringRef CPU, StringRef Features,
const TargetOptions &Options, Optional<Reloc::Model> RM,
CodeModel::Model CM, CodeGenOpt::Level OL);
// 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
// reference.
- typedef AsmPrinter *(*AsmPrinterCtorTy)(
+ using AsmPrinterCtorTy = AsmPrinter *(*)(
TargetMachine &TM, std::unique_ptr<MCStreamer> &&Streamer);
- typedef MCAsmBackend *(*MCAsmBackendCtorTy)(const Target &T,
- const MCRegisterInfo &MRI,
- const Triple &TT, StringRef CPU,
- const MCTargetOptions &Options);
- typedef MCTargetAsmParser *(*MCAsmParserCtorTy)(
+ using MCAsmBackendCtorTy = MCAsmBackend *(*)(const Target &T,
+ const MCRegisterInfo &MRI,
+ const Triple &TT, StringRef CPU,
+ const MCTargetOptions &Options);
+ using MCAsmParserCtorTy = MCTargetAsmParser *(*)(
const MCSubtargetInfo &STI, MCAsmParser &P, const MCInstrInfo &MII,
const MCTargetOptions &Options);
- typedef MCDisassembler *(*MCDisassemblerCtorTy)(const Target &T,
- const MCSubtargetInfo &STI,
- MCContext &Ctx);
- typedef MCInstPrinter *(*MCInstPrinterCtorTy)(const Triple &T,
- unsigned SyntaxVariant,
- const MCAsmInfo &MAI,
- const MCInstrInfo &MII,
- const MCRegisterInfo &MRI);
- typedef MCCodeEmitter *(*MCCodeEmitterCtorTy)(const MCInstrInfo &II,
- const MCRegisterInfo &MRI,
- MCContext &Ctx);
- typedef MCStreamer *(*ELFStreamerCtorTy)(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,
+ using MCDisassemblerCtorTy = MCDisassembler *(*)(const Target &T,
+ const MCSubtargetInfo &STI,
+ MCContext &Ctx);
+ using MCInstPrinterCtorTy = MCInstPrinter *(*)(const Triple &T,
+ unsigned SyntaxVariant,
+ const MCAsmInfo &MAI,
+ const MCInstrInfo &MII,
+ const MCRegisterInfo &MRI);
+ using MCCodeEmitterCtorTy = MCCodeEmitter *(*)(const MCInstrInfo &II,
+ const MCRegisterInfo &MRI,
+ MCContext &Ctx);
+ using ELFStreamerCtorTy = MCStreamer *(*)(const Triple &T, MCContext &Ctx,
MCAsmBackend &TAB,
raw_pwrite_stream &OS,
MCCodeEmitter *Emitter,
bool RelaxAll);
- typedef MCTargetStreamer *(*NullTargetStreamerCtorTy)(MCStreamer &S);
- typedef MCTargetStreamer *(*AsmTargetStreamerCtorTy)(
+ using MachOStreamerCtorTy = MCStreamer *(*)(MCContext &Ctx, MCAsmBackend &TAB,
+ 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,
bool IsVerboseAsm);
- typedef MCTargetStreamer *(*ObjectTargetStreamerCtorTy)(
+ using ObjectTargetStreamerCtorTy = MCTargetStreamer *(*)(
MCStreamer &S, const MCSubtargetInfo &STI);
- typedef MCRelocationInfo *(*MCRelocationInfoCtorTy)(const Triple &TT,
- MCContext &Ctx);
- typedef MCSymbolizer *(*MCSymbolizerCtorTy)(
+ using MCRelocationInfoCtorTy = MCRelocationInfo *(*)(const Triple &TT,
+ MCContext &Ctx);
+ using MCSymbolizerCtorTy = MCSymbolizer *(*)(
const Triple &TT, LLVMOpInfoCallback GetOpInfo,
LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo, MCContext *Ctx,
std::unique_ptr<MCRelocationInfo> &&RelInfo);
-//===--- YAMLParser.h - Simple YAML parser --------------------------------===//
+//===- YAMLParser.h - Simple YAML parser ------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/SMLoc.h"
+#include <cassert>
+#include <cstddef>
+#include <iterator>
#include <map>
+#include <memory>
+#include <string>
#include <system_error>
-#include <utility>
namespace llvm {
+
class MemoryBufferRef;
class SourceMgr;
-class Twine;
class raw_ostream;
+class Twine;
namespace yaml {
-class document_iterator;
class Document;
+class document_iterator;
class Node;
class Scanner;
struct Token;
document_iterator end();
void skip();
bool failed();
+
bool validate() {
skip();
return !failed();
void printError(Node *N, const Twine &Msg);
private:
+ friend class Document;
+
std::unique_ptr<Scanner> scanner;
std::unique_ptr<Document> CurrentDoc;
-
- friend class Document;
};
/// \brief Abstract base class for all Nodes.
Node(unsigned int Type, std::unique_ptr<Document> &, StringRef Anchor,
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
/// have one, getAnchor().size() will be 0.
StringRef getAnchor() const { return Anchor; }
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:
std::unique_ptr<Document> &Doc;
SMRange SourceRange;
- void operator delete(void *) noexcept = delete;
-
~Node() = default;
private:
public:
KeyValueNode(std::unique_ptr<Document> &D)
- : Node(NK_KeyValue, D, StringRef(), StringRef()), Key(nullptr),
- Value(nullptr) {}
+ : Node(NK_KeyValue, D, StringRef(), StringRef()) {}
/// \brief Parse and return the key.
///
}
private:
- Node *Key;
- Node *Value;
+ Node *Key = nullptr;
+ Node *Value = nullptr;
};
/// \brief This is an iterator abstraction over YAML collections shared by both
class basic_collection_iterator
: public std::iterator<std::input_iterator_tag, ValueT> {
public:
- basic_collection_iterator() : Base(nullptr) {}
+ basic_collection_iterator() = default;
basic_collection_iterator(BaseT *B) : Base(B) {}
ValueT *operator->() const {
}
private:
- BaseT *Base;
+ BaseT *Base = nullptr;
};
// The following two templates are used for both MappingNode and Sequence Node.
MappingNode(std::unique_ptr<Document> &D, StringRef Anchor, StringRef Tag,
MappingType MT)
- : Node(NK_Mapping, D, Anchor, Tag), Type(MT), IsAtBeginning(true),
- IsAtEnd(false), CurrentEntry(nullptr) {}
+ : Node(NK_Mapping, D, Anchor, Tag), Type(MT) {}
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 void yaml::skip(T &);
private:
MappingType Type;
- bool IsAtBeginning;
- bool IsAtEnd;
- KeyValueNode *CurrentEntry;
+ bool IsAtBeginning = true;
+ bool IsAtEnd = false;
+ KeyValueNode *CurrentEntry = nullptr;
void increment();
};
SequenceNode(std::unique_ptr<Document> &D, StringRef Anchor, StringRef Tag,
SequenceType ST)
- : Node(NK_Sequence, D, Anchor, Tag), SeqType(ST), IsAtBeginning(true),
- IsAtEnd(false),
- WasPreviousTokenFlowEntry(true), // Start with an imaginary ','.
- CurrentEntry(nullptr) {}
+ : Node(NK_Sequence, D, Anchor, Tag), SeqType(ST) {}
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 void yaml::skip(T &);
private:
SequenceType SeqType;
- bool IsAtBeginning;
- bool IsAtEnd;
- bool WasPreviousTokenFlowEntry;
- Node *CurrentEntry;
+ bool IsAtBeginning = true;
+ bool IsAtEnd = false;
+ bool WasPreviousTokenFlowEntry = true; // Start with an imaginary ','.
+ Node *CurrentEntry = nullptr;
};
/// \brief Represents an alias to a Node with an anchor.
/// node.
class Document {
public:
+ Document(Stream &ParentStream);
+
/// \brief Root for parsing a node. Returns a single node.
Node *parseBlockNode();
- Document(Stream &ParentStream);
-
/// \brief Finish parsing the current document and return true if there are
/// more. Return false otherwise.
bool skip();
/// \brief Iterator abstraction for Documents over a Stream.
class document_iterator {
public:
- document_iterator() : Doc(nullptr) {}
+ document_iterator() = default;
document_iterator(std::unique_ptr<Document> &D) : Doc(&D) {}
bool operator==(const document_iterator &Other) {
private:
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
#include <cctype>
#include <cstddef>
#include <cstdint>
+#include <map>
#include <memory>
#include <new>
#include <string>
template <class T>
struct has_ScalarEnumerationTraits
{
- typedef void (*Signature_enumeration)(class IO&, T&);
+ using Signature_enumeration = void (*)(class IO&, T&);
template <typename U>
static char test(SameType<Signature_enumeration, &U::enumeration>*);
template <class T>
struct has_ScalarBitSetTraits
{
- typedef void (*Signature_bitset)(class IO&, T&);
+ using Signature_bitset = void (*)(class IO&, T&);
template <typename U>
static char test(SameType<Signature_bitset, &U::bitset>*);
template <class T>
struct has_ScalarTraits
{
- typedef StringRef (*Signature_input)(StringRef, void*, T&);
- typedef void (*Signature_output)(const T&, void*, llvm::raw_ostream&);
- typedef bool (*Signature_mustQuote)(StringRef);
+ using Signature_input = StringRef (*)(StringRef, void*, T&);
+ using Signature_output = void (*)(const T&, void*, raw_ostream&);
+ using Signature_mustQuote = bool (*)(StringRef);
template <typename U>
static char test(SameType<Signature_input, &U::input> *,
template <class T>
struct has_BlockScalarTraits
{
- typedef StringRef (*Signature_input)(StringRef, void *, T &);
- typedef void (*Signature_output)(const T &, void *, llvm::raw_ostream &);
+ using Signature_input = StringRef (*)(StringRef, void *, T &);
+ using Signature_output = void (*)(const T &, void *, raw_ostream &);
template <typename U>
static char test(SameType<Signature_input, &U::input> *,
// Test if MappingContextTraits<T> is defined on type T.
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>
static char test(SameType<Signature_mapping, &U::mapping>*);
// Test if MappingTraits<T> is defined on type T.
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>
static char test(SameType<Signature_mapping, &U::mapping> *);
// Test if MappingContextTraits<T>::validate() is defined on type T.
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>
static char test(SameType<Signature_validate, &U::validate>*);
// Test if MappingTraits<T>::validate() is defined on type T.
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>
static char test(SameType<Signature_validate, &U::validate> *);
template <class T>
struct has_SequenceMethodTraits
{
- typedef size_t (*Signature_size)(class IO&, T&);
+ using Signature_size = size_t (*)(class IO&, T&);
template <typename U>
static char test(SameType<Signature_size, &U::size>*);
template <class T>
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>
static char test(SameType<Signature_input, &U::inputOne>*);
template <class T>
struct has_DocumentListTraits
{
- typedef size_t (*Signature_size)(class IO&, T&);
+ using Signature_size = size_t (*)(class IO &, T &);
template <typename U>
static char test(SameType<Signature_size, &U::size>*);
// Base class for Input and Output.
class IO {
public:
- IO(void *Ctxt=nullptr);
+ IO(void *Ctxt = nullptr);
virtual ~IO();
virtual bool outputting() = 0;
EmptyContext Ctx;
this->processKey(Key, Val, true, Ctx);
}
+
template <typename T, typename Context>
void mapRequired(const char *Key, T &Val, Context &Ctx) {
this->processKey(Key, Val, true, Ctx);
yamlize(IO &io, T &Val, bool, EmptyContext &Ctx) {
if ( io.outputting() ) {
std::string Storage;
- llvm::raw_string_ostream Buffer(Storage);
+ raw_string_ostream Buffer(Storage);
ScalarTraits<T>::output(Val, io.getContext(), Buffer);
StringRef Str = Buffer.str();
io.scalarString(Str, ScalarTraits<T>::mustQuote(Str));
io.scalarString(Str, ScalarTraits<T>::mustQuote(Str));
StringRef Result = ScalarTraits<T>::input(Str, io.getContext(), Val);
if ( !Result.empty() ) {
- io.setError(llvm::Twine(Result));
+ io.setError(Twine(Result));
}
}
}
yamlize(IO &YamlIO, T &Val, bool, EmptyContext &Ctx) {
if (YamlIO.outputting()) {
std::string Storage;
- llvm::raw_string_ostream Buffer(Storage);
+ raw_string_ostream Buffer(Storage);
BlockScalarTraits<T>::output(Val, YamlIO.getContext(), Buffer);
StringRef Str = Buffer.str();
YamlIO.blockScalarString(Str);
StringRef Result =
BlockScalarTraits<T>::input(Str, YamlIO.getContext(), Val);
if (!Result.empty())
- YamlIO.setError(llvm::Twine(Result));
+ YamlIO.setError(Twine(Result));
}
}
if (io.outputting()) {
StringRef Err = MappingTraits<T>::validate(io, Val);
if (!Err.empty()) {
- llvm::errs() << Err << "\n";
+ errs() << Err << "\n";
assert(Err.empty() && "invalid struct trying to be written as yaml");
}
}
template <typename T, typename Context>
typename std::enable_if<has_SequenceTraits<T>::value, void>::type
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 count = io.outputting() ? SequenceTraits<T>::size(io, Seq) : incnt;
for(unsigned i=0; i < count; ++i) {
template<>
struct ScalarTraits<bool> {
- static void output(const bool &, void*, llvm::raw_ostream &);
- static StringRef input(StringRef, void*, bool &);
+ static void output(const bool &, void* , raw_ostream &);
+ static StringRef input(StringRef, void *, bool &);
static bool mustQuote(StringRef) { return false; }
};
template<>
struct ScalarTraits<StringRef> {
- static void output(const StringRef &, void*, llvm::raw_ostream &);
- static StringRef input(StringRef, void*, StringRef &);
+ static void output(const StringRef &, void *, raw_ostream &);
+ static StringRef input(StringRef, void *, StringRef &);
static bool mustQuote(StringRef S) { return needsQuotes(S); }
};
template<>
struct ScalarTraits<std::string> {
- static void output(const std::string &, void*, llvm::raw_ostream &);
- static StringRef input(StringRef, void*, std::string &);
+ static void output(const std::string &, void *, raw_ostream &);
+ static StringRef input(StringRef, void *, std::string &);
static bool mustQuote(StringRef S) { return needsQuotes(S); }
};
template<>
struct ScalarTraits<uint8_t> {
- static void output(const uint8_t &, void*, llvm::raw_ostream &);
- static StringRef input(StringRef, void*, uint8_t &);
+ static void output(const uint8_t &, void *, raw_ostream &);
+ static StringRef input(StringRef, void *, uint8_t &);
static bool mustQuote(StringRef) { return false; }
};
template<>
struct ScalarTraits<uint16_t> {
- static void output(const uint16_t &, void*, llvm::raw_ostream &);
- static StringRef input(StringRef, void*, uint16_t &);
+ static void output(const uint16_t &, void *, raw_ostream &);
+ static StringRef input(StringRef, void *, uint16_t &);
static bool mustQuote(StringRef) { return false; }
};
template<>
struct ScalarTraits<uint32_t> {
- static void output(const uint32_t &, void*, llvm::raw_ostream &);
- static StringRef input(StringRef, void*, uint32_t &);
+ static void output(const uint32_t &, void *, raw_ostream &);
+ static StringRef input(StringRef, void *, uint32_t &);
static bool mustQuote(StringRef) { return false; }
};
template<>
struct ScalarTraits<uint64_t> {
- static void output(const uint64_t &, void*, llvm::raw_ostream &);
- static StringRef input(StringRef, void*, uint64_t &);
+ static void output(const uint64_t &, void *, raw_ostream &);
+ static StringRef input(StringRef, void *, uint64_t &);
static bool mustQuote(StringRef) { return false; }
};
template<>
struct ScalarTraits<int8_t> {
- static void output(const int8_t &, void*, llvm::raw_ostream &);
- static StringRef input(StringRef, void*, int8_t &);
+ static void output(const int8_t &, void *, raw_ostream &);
+ static StringRef input(StringRef, void *, int8_t &);
static bool mustQuote(StringRef) { return false; }
};
template<>
struct ScalarTraits<int16_t> {
- static void output(const int16_t &, void*, llvm::raw_ostream &);
- static StringRef input(StringRef, void*, int16_t &);
+ static void output(const int16_t &, void *, raw_ostream &);
+ static StringRef input(StringRef, void *, int16_t &);
static bool mustQuote(StringRef) { return false; }
};
template<>
struct ScalarTraits<int32_t> {
- static void output(const int32_t &, void*, llvm::raw_ostream &);
- static StringRef input(StringRef, void*, int32_t &);
+ static void output(const int32_t &, void *, raw_ostream &);
+ static StringRef input(StringRef, void *, int32_t &);
static bool mustQuote(StringRef) { return false; }
};
template<>
struct ScalarTraits<int64_t> {
- static void output(const int64_t &, void*, llvm::raw_ostream &);
- static StringRef input(StringRef, void*, int64_t &);
+ static void output(const int64_t &, void *, raw_ostream &);
+ static StringRef input(StringRef, void *, int64_t &);
static bool mustQuote(StringRef) { return false; }
};
template<>
struct ScalarTraits<float> {
- static void output(const float &, void*, llvm::raw_ostream &);
- static StringRef input(StringRef, void*, float &);
+ static void output(const float &, void *, raw_ostream &);
+ static StringRef input(StringRef, void *, float &);
static bool mustQuote(StringRef) { return false; }
};
template<>
struct ScalarTraits<double> {
- static void output(const double &, void*, llvm::raw_ostream &);
- static StringRef input(StringRef, void*, double &);
+ static void output(const double &, void *, raw_ostream &);
+ static StringRef input(StringRef, void *, double &);
static bool mustQuote(StringRef) { return false; }
};
template <typename value_type, support::endianness endian, size_t alignment>
struct ScalarTraits<support::detail::packed_endian_specific_integral<
value_type, endian, alignment>> {
- typedef support::detail::packed_endian_specific_integral<value_type, endian,
- alignment>
- endian_type;
+ using endian_type =
+ support::detail::packed_endian_specific_integral<value_type, endian,
+ alignment>;
- static void output(const endian_type &E, void *Ctx,
- llvm::raw_ostream &Stream) {
+ static void output(const endian_type &E, void *Ctx, raw_ostream &Stream) {
ScalarTraits<value_type>::output(static_cast<value_type>(E), Ctx, Stream);
}
TNorm* operator->() { return BufPtr; }
private:
- typedef llvm::AlignedCharArrayUnion<TNorm> Storage;
+ using Storage = AlignedCharArrayUnion<TNorm>;
Storage Buffer;
IO &io;
// to [de]normalize an object for use with YAML conversion.
template <typename TNorm, typename TFinal>
struct MappingNormalizationHeap {
- MappingNormalizationHeap(IO &i_o, TFinal &Obj,
- llvm::BumpPtrAllocator *allocator)
- : io(i_o), BufPtr(nullptr), Result(Obj) {
+ MappingNormalizationHeap(IO &i_o, TFinal &Obj, BumpPtrAllocator *allocator)
+ : io(i_o), Result(Obj) {
if ( io.outputting() ) {
BufPtr = new (&Buffer) TNorm(io, Obj);
}
TNorm* operator->() { return BufPtr; }
private:
- typedef llvm::AlignedCharArrayUnion<TNorm> Storage;
+ using Storage = AlignedCharArrayUnion<TNorm>;
Storage Buffer;
IO &io;
- TNorm *BufPtr;
+ TNorm *BufPtr = nullptr;
TFinal &Result;
};
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;
- llvm::SmallVector<std::string, 6> ValidKeys;
+ NameToNode Mapping;
+ SmallVector<std::string, 6> ValidKeys;
};
class SequenceHNode : public HNode {
const Node *getCurrentNode() const;
private:
- llvm::SourceMgr SrcMgr; // must be before Strm
+ SourceMgr SrcMgr; // must be before Strm
std::unique_ptr<llvm::yaml::Stream> Strm;
std::unique_ptr<HNode> TopNode;
std::error_code EC;
- llvm::BumpPtrAllocator StringAllocator;
- llvm::yaml::document_iterator DocIterator;
+ BumpPtrAllocator StringAllocator;
+ document_iterator DocIterator;
std::vector<bool> BitValuesUsed;
- HNode *CurrentNode;
+ HNode *CurrentNode = nullptr;
bool ScalarMatchFound;
};
///
class Output : public IO {
public:
- Output(llvm::raw_ostream &, void *Ctxt = nullptr, int WrapColumn = 70);
+ Output(raw_ostream &, void *Ctxt = nullptr, int WrapColumn = 70);
~Output() override;
/// \brief Set whether or not to output optional values which are equal
inFlowMapOtherKey
};
- llvm::raw_ostream &Out;
- int WrapColumn;
- SmallVector<InState, 8> StateStack;
- int Column;
- int ColumnAtFlowStart;
- int ColumnAtMapFlowStart;
- bool NeedBitValueComma;
- bool NeedFlowSequenceComma;
- bool EnumerationMatchFound;
- bool NeedsNewLine;
- bool WriteDefaultValues;
+ raw_ostream &Out;
+ int WrapColumn;
+ SmallVector<InState, 8> StateStack;
+ int Column = 0;
+ int ColumnAtFlowStart = 0;
+ int ColumnAtMapFlowStart = 0;
+ bool NeedBitValueComma = false;
+ bool NeedFlowSequenceComma = false;
+ bool EnumerationMatchFound = false;
+ bool NeedsNewLine = false;
+ bool WriteDefaultValues = false;
};
/// YAML I/O does conversion based on types. But often native data types
bool operator==(const _base &rhs) const { return value == rhs; } \
bool operator<(const _type &rhs) const { return value < rhs.value; } \
_base value; \
- typedef _base BaseType; \
+ using BaseType = _base; \
};
///
template<>
struct ScalarTraits<Hex8> {
- static void output(const Hex8 &, void*, llvm::raw_ostream &);
- static StringRef input(StringRef, void*, Hex8 &);
+ static void output(const Hex8 &, void *, raw_ostream &);
+ static StringRef input(StringRef, void *, Hex8 &);
static bool mustQuote(StringRef) { return false; }
};
template<>
struct ScalarTraits<Hex16> {
- static void output(const Hex16 &, void*, llvm::raw_ostream &);
- static StringRef input(StringRef, void*, Hex16 &);
+ static void output(const Hex16 &, void *, raw_ostream &);
+ static StringRef input(StringRef, void *, Hex16 &);
static bool mustQuote(StringRef) { return false; }
};
template<>
struct ScalarTraits<Hex32> {
- static void output(const Hex32 &, void*, llvm::raw_ostream &);
- static StringRef input(StringRef, void*, Hex32 &);
+ static void output(const Hex32 &, void *, raw_ostream &);
+ static StringRef input(StringRef, void *, Hex32 &);
static bool mustQuote(StringRef) { return false; }
};
template<>
struct ScalarTraits<Hex64> {
- static void output(const Hex64 &, void*, llvm::raw_ostream &);
- static StringRef input(StringRef, void*, Hex64 &);
+ static void output(const Hex64 &, void *, raw_ostream &);
+ static StringRef input(StringRef, void *, Hex64 &);
static bool mustQuote(StringRef) { return false; }
};
}
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 _type &element(IO &io, T &seq, size_t index) {
if (index >= seq.size())
seq.resize(index + 1);
/// Implementation of CustomMappingTraits for std::map<std::string, T>.
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) {
io.mapRequired(key.str().c_str(), v[key]);
}
+
static void output(IO &io, map_type &v) {
for (auto &p : v)
io.mapRequired(p.first.c_str(), p.second);
namespace llvm { \
namespace yaml { \
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 bool mustQuote(StringRef) { return MustQuote; } \
}; \
-//===- CoverageMapping.cpp - Code coverage mapping support ------*- C++ -*-===//
+//===- CoverageMapping.cpp - Code coverage mapping support ----------------===//
//
// The LLVM Compiler Infrastructure
//
/// An instantiation set is a collection of functions that have the same source
/// code, ie, template functions specializations.
class FunctionInstantiationSetCollector {
- typedef DenseMap<std::pair<unsigned, unsigned>,
- std::vector<const FunctionRecord *>> MapT;
+ using MapT = DenseMap<std::pair<unsigned, unsigned>,
+ std::vector<const FunctionRecord *>>;
MapT InstantiatedFunctions;
public:
}
MapT::iterator begin() { return InstantiatedFunctions.begin(); }
-
MapT::iterator end() { return InstantiatedFunctions.end(); }
};
-//===- CoverageMappingReader.cpp - Code coverage mapping reader -*- C++ -*-===//
+//===- CoverageMappingReader.cpp - Code coverage mapping reader -----------===//
//
// The LLVM Compiler Infrastructure
//
}
Error RawCoverageReader::readULEB128(uint64_t &Result) {
- if (Data.size() < 1)
+ if (Data.empty())
return make_error<CoverageMapError>(coveragemap_error::truncated);
unsigned N = 0;
Result = decodeULEB128(reinterpret_cast<const uint8_t *>(Data.data()), &N);
// A class for reading coverage mapping function records for a module.
template <CovMapVersion Version, class IntPtrT, support::endianness Endian>
class VersionedCovMapFuncRecordReader : public CovMapFuncRecordReader {
- typedef typename CovMapTraits<
- Version, IntPtrT>::CovMapFuncRecordType FuncRecordType;
- typedef typename CovMapTraits<Version, IntPtrT>::NameRefType NameRefType;
+ using FuncRecordType =
+ typename CovMapTraits<Version, IntPtrT>::CovMapFuncRecordType;
+ using NameRefType = typename CovMapTraits<Version, IntPtrT>::NameRefType;
// Maps function's name references to the indexes of their records
// in \c Records.
Endian = support::endianness::little;
Data = Data.substr(StringRef(TestingFormatMagic).size());
- if (Data.size() < 1)
+ if (Data.empty())
return make_error<CoverageMapError>(coveragemap_error::truncated);
unsigned N = 0;
auto ProfileNamesSize =
if (N > Data.size())
return make_error<CoverageMapError>(coveragemap_error::malformed);
Data = Data.substr(N);
- if (Data.size() < 1)
+ if (Data.empty())
return make_error<CoverageMapError>(coveragemap_error::truncated);
N = 0;
uint64_t Address =
return E;
CoverageMapping = Data.substr(ProfileNamesSize);
// 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);
size_t Pad = alignmentAdjustment(CoverageMapping.data(), 8);
if (CoverageMapping.size() < Pad)
return IndexedInstrProf::ComputeHash(HashType, K);
}
-typedef InstrProfLookupTrait::data_type data_type;
-typedef InstrProfLookupTrait::offset_type offset_type;
+using data_type = InstrProfLookupTrait::data_type;
+using offset_type = InstrProfLookupTrait::offset_type;
bool InstrProfLookupTrait::readValueProfilingData(
const unsigned char *&D, const unsigned char *const End) {
for (unsigned I = 0; I < SummarySize / sizeof(uint64_t); I++)
Dst[I] = endian::byte_swap<uint64_t, little>(Src[I]);
- llvm::SummaryEntryVector DetailedSummary;
+ SummaryEntryVector DetailedSummary;
for (unsigned I = 0; I < SummaryData->NumCutoffEntries; I++) {
const IndexedInstrProf::Summary::Entry &Ent = SummaryData->getEntry(I);
DetailedSummary.emplace_back((uint32_t)Ent.Cutoff, Ent.MinBlockCount,
write(P[K].D[I]);
}
} else {
- raw_string_ostream &SOStream =
- static_cast<llvm::raw_string_ostream &>(OS);
+ raw_string_ostream &SOStream = static_cast<raw_string_ostream &>(OS);
std::string &Data = SOStream.str(); // with flush
for (int K = 0; K < NItems; K++) {
for (int I = 0; I < P[K].N; I++) {
class InstrProfRecordWriterTrait {
public:
- typedef StringRef key_type;
- typedef StringRef key_type_ref;
+ using key_type = StringRef;
+ using key_type_ref = StringRef;
- typedef const InstrProfWriter::ProfilingData *const data_type;
- typedef const InstrProfWriter::ProfilingData *const data_type_ref;
+ using data_type = const InstrProfWriter::ProfilingData *const;
+ using data_type_ref = const InstrProfWriter::ProfilingData *const;
- typedef uint64_t hash_value_type;
- typedef uint64_t offset_type;
+ using hash_value_type = uint64_t;
+ using offset_type = uint64_t;
support::endianness ValueProfDataEndianness = support::little;
InstrProfSummaryBuilder *SummaryBuilder;
-//===-- GraphWriter.cpp - Implements GraphWriter support routines ---------===//
+//===- GraphWriter.cpp - Implements GraphWriter support routines ----------===//
//
// The LLVM Compiler Infrastructure
//
//===----------------------------------------------------------------------===//
#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/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/Program.h"
+#include "llvm/Support/raw_ostream.h"
+#include <cassert>
+#include <system_error>
+#include <string>
+#include <vector>
+
using namespace llvm;
static cl::opt<bool> ViewBackground("view-background", cl::Hidden,
}
namespace {
+
struct GraphSession {
std::string LogBuffer;
+
bool TryFindProgram(StringRef Names, std::string &ProgramPath) {
raw_string_ostream Log(LogBuffer);
SmallVector<StringRef, 8> parts;
return false;
}
};
-} // namespace
+
+} // end anonymous namespace
static const char *getProgramName(GraphProgram::Name program) {
switch (program) {
-//===--- YAMLParser.cpp - Simple YAML parser ------------------------------===//
+//===- YAMLParser.cpp - Simple YAML parser --------------------------------===//
//
// The LLVM Compiler Infrastructure
//
#include "llvm/Support/YAMLParser.h"
#include "llvm/ADT/AllocatorList.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/None.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
+#include "llvm/Support/Compiler.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/SMLoc.h"
#include "llvm/Support/SourceMgr.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 yaml;
/// EncodingInfo - Holds the encoding type and length of the byte order mark if
/// 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
/// encoding form of \a Input.
/// @returns An EncodingInfo indicating the Unicode encoding form of the input
/// and how long the byte order mark is if one exists.
static EncodingInfo getUnicodeEncoding(StringRef Input) {
- if (Input.size() == 0)
+ if (Input.empty())
return std::make_pair(UEF_Unknown, 0);
switch (uint8_t(Input[0])) {
return std::make_pair(UEF_UTF8, 0);
}
-namespace llvm {
-namespace yaml {
/// Pin the vtables to this file.
void Node::anchor() {}
void NullNode::anchor() {}
void SequenceNode::anchor() {}
void AliasNode::anchor() {}
+namespace llvm {
+namespace yaml {
+
/// Token - A single YAML token.
struct Token {
enum TokenKind {
TK_Alias,
TK_Anchor,
TK_Tag
- } Kind;
+ } Kind = TK_Error;
/// A string of length 0 or more whose begin() points to the logical location
/// of the token in the input.
/// The value of a block scalar node.
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 {
+
/// @brief This struct is used to track simple keys.
///
/// Simple keys are handled by creating an entry in SimpleKeys for each Token
return Tok == Other.Tok;
}
};
-}
+
+} // end anonymous namespace
/// @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).
/// 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) {
StringRef::iterator Position= Range.begin();
namespace llvm {
namespace yaml {
+
/// @brief Scans YAML tokens from a MemoryBuffer.
class Scanner {
public:
/// ns-char.
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
/// returns its input.
///
}
bool yaml::scanTokens(StringRef Input) {
- llvm::SourceMgr SM;
- llvm::yaml::Scanner scanner(Input, SM);
- for (;;) {
- llvm::yaml::Token T = scanner.getNext();
+ SourceMgr SM;
+ Scanner scanner(Input, SM);
+ while (true) {
+ Token T = scanner.getNext();
if (T.Kind == Token::TK_StreamEnd)
break;
else if (T.Kind == Token::TK_Error)
std::error_code *EC)
: scanner(new Scanner(InputBuffer, SM, ShowColors, EC)), CurrentDoc() {}
-Stream::~Stream() {}
+Stream::~Stream() = default;
bool Stream::failed() { return scanner->failed(); }
return Doc->failed();
}
-
-
StringRef ScalarNode::getValue(SmallVectorImpl<char> &Storage) const {
// TODO: Handle newlines properly. We need to remove leading whitespace.
if (Value[0] == '"') { // Double quoted.
//===----------------------------------------------------------------------===//
#include "llvm/Support/YAMLTraits.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/LineIterator.h"
+#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/YAMLParser.h"
#include "llvm/Support/raw_ostream.h"
-#include <cctype>
+#include <algorithm>
+#include <cassert>
+#include <cstdint>
+#include <cstdlib>
#include <cstring>
+#include <string>
+#include <vector>
+
using namespace llvm;
using namespace yaml;
// IO
//===----------------------------------------------------------------------===//
-IO::IO(void *Context) : Ctxt(Context) {
-}
+IO::IO(void *Context) : Ctxt(Context) {}
-IO::~IO() {
-}
+IO::~IO() = default;
void *IO::getContext() {
return Ctxt;
Input::Input(StringRef InputContent, void *Ctxt,
SourceMgr::DiagHandlerTy DiagHandler, void *DiagHandlerCtxt)
- : IO(Ctxt), Strm(new Stream(InputContent, SrcMgr, false, &EC)),
- CurrentNode(nullptr) {
+ : IO(Ctxt), Strm(new Stream(InputContent, SrcMgr, false, &EC)) {
if (DiagHandler)
SrcMgr.setDiagHandler(DiagHandler, DiagHandlerCtxt);
DocIterator = Strm->begin();
}
-Input::~Input() {
-}
+Input::~Input() = default;
std::error_code Input::error() { return EC; }
//===----------------------------------------------------------------------===//
Output::Output(raw_ostream &yout, void *context, int WrapColumn)
- : IO(context), Out(yout), WrapColumn(WrapColumn), Column(0),
- ColumnAtFlowStart(0), ColumnAtMapFlowStart(0), NeedBitValueComma(false),
- NeedFlowSequenceComma(false), EnumerationMatchFound(false),
- NeedsNewLine(false), WriteDefaultValues(false) {}
+ : IO(context), Out(yout), WrapColumn(WrapColumn) {}
-Output::~Output() {
-}
+Output::~Output() = default;
bool Output::outputting() {
return true;