[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:
Eugene Zelenko 2017-06-21 23:19:47 +00:00
parent bb561ec060
commit dfaebc43c9
18 changed files with 369 additions and 310 deletions

View File

@ -411,9 +411,11 @@ public:
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.
@ -430,6 +432,7 @@ class CoverageMapping {
unsigned MismatchedFunctionCount = 0;
CoverageMapping() = default;
/// \brief Add a function record corresponding to \p Record.
Error loadFunctionRecord(const CoverageMappingRecord &Record,
IndexedInstrProfReader &ProfileReader);
@ -607,13 +610,13 @@ enum CovMapVersion {
};
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
@ -622,6 +625,7 @@ template <class IntPtrT> struct CovMapTraits<CovMapVersion::Version1, IntPtrT> {
template<> struct DenseMapInfo<coverage::CounterExpression> {
static inline coverage::CounterExpression getEmptyKey() {
using namespace coverage;
return CounterExpression(CounterExpression::ExprKind::Subtract,
Counter::getCounter(~0U),
Counter::getCounter(~0U));
@ -629,6 +633,7 @@ template<> struct DenseMapInfo<coverage::CounterExpression> {
static inline coverage::CounterExpression getTombstoneKey() {
using namespace coverage;
return CounterExpression(CounterExpression::ExprKind::Add,
Counter::getCounter(~0U),
Counter::getCounter(~0U));

View File

@ -410,7 +410,7 @@ uint64_t ComputeHash(StringRef K);
/// 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;
@ -599,7 +599,7 @@ struct InstrProfRecord {
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.
@ -673,8 +673,8 @@ struct InstrProfRecord {
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:
@ -878,6 +878,11 @@ struct Summary {
// 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);
@ -916,11 +921,6 @@ struct Summary {
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) {

View File

@ -92,6 +92,7 @@ public:
protected:
std::unique_ptr<InstrProfSymtab> Symtab;
/// Set the current error and return same.
Error error(instrprof_error Err) {
LastError = Err;
@ -202,7 +203,7 @@ private:
public:
RawInstrProfReader(std::unique_ptr<MemoryBuffer> DataBuffer)
: DataBuffer(std::move(DataBuffer)) { }
: DataBuffer(std::move(DataBuffer)) {}
RawInstrProfReader(const RawInstrProfReader &) = delete;
RawInstrProfReader &operator=(const RawInstrProfReader &) = delete;
@ -268,8 +269,8 @@ private:
}
};
typedef RawInstrProfReader<uint32_t> RawInstrProfReader32;
typedef RawInstrProfReader<uint64_t> RawInstrProfReader64;
using RawInstrProfReader32 = RawInstrProfReader<uint32_t>;
using RawInstrProfReader64 = RawInstrProfReader<uint64_t>;
namespace IndexedInstrProf {
@ -292,12 +293,12 @@ public:
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; }
@ -346,12 +347,11 @@ struct InstrProfReaderIndexBase {
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;

View File

@ -29,10 +29,11 @@ namespace llvm {
/// 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:

View File

@ -125,7 +125,7 @@ raw_ostream &operator<<(raw_ostream &OS, const LineLocation &Loc);
/// will be a list of one or more functions.
class SampleRecord {
public:
typedef StringMap<uint64_t> CallTargetMap;
using CallTargetMap = StringMap<uint64_t>;
SampleRecord() = default;
@ -182,10 +182,11 @@ private:
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.
///
@ -398,8 +399,8 @@ raw_ostream &operator<<(raw_ostream &OS, const FunctionSamples &FS);
/// 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)

View File

@ -350,7 +350,7 @@ public:
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;
@ -388,10 +388,10 @@ protected:
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;
@ -403,7 +403,7 @@ private:
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.

View File

@ -271,8 +271,8 @@ struct GCOVEdge {
/// 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) {}
@ -321,7 +321,7 @@ class GCOVBlock {
};
public:
typedef SmallVectorImpl<GCOVEdge *>::const_iterator EdgeIterator;
using EdgeIterator = SmallVectorImpl<GCOVEdge *>::const_iterator;
GCOVBlock(GCOVFunction &P, uint32_t N) : Parent(P), Number(N) {}
~GCOVBlock();
@ -381,10 +381,10 @@ class FileInfo {
// 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;
@ -448,8 +448,8 @@ private:
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;

View File

@ -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
//
@ -24,30 +24,40 @@
#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);
@ -57,11 +67,11 @@ class GraphWriter {
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,
@ -346,6 +356,6 @@ void ViewGraph(const GraphType &G, const Twine &Name,
DisplayGraph(Filename, false, Program);
}
} // End llvm namespace
} // end namespace llvm
#endif
#endif // LLVM_SUPPORT_GRAPHWRITER_H

View File

@ -54,6 +54,7 @@ class MCSymbolizer;
class MCTargetAsmParser;
class MCTargetOptions;
class MCTargetStreamer;
class raw_ostream;
class raw_pwrite_stream;
class TargetMachine;
class TargetOptions;
@ -96,75 +97,75 @@ class Target {
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);

View File

@ -1,4 +1,4 @@
//===--- YAMLParser.h - Simple YAML parser --------------------------------===//
//===- YAMLParser.h - Simple YAML parser ------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@ -41,20 +41,25 @@
#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;
@ -87,6 +92,7 @@ public:
document_iterator end();
void skip();
bool failed();
bool validate() {
skip();
return !failed();
@ -95,10 +101,10 @@ public:
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.
@ -119,6 +125,18 @@ public:
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; }
@ -146,22 +164,10 @@ public:
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:
@ -268,8 +274,7 @@ class KeyValueNode final : public Node {
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.
///
@ -296,8 +301,8 @@ public:
}
private:
Node *Key;
Node *Value;
Node *Key = nullptr;
Node *Value = nullptr;
};
/// \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
: 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 {
@ -358,7 +363,7 @@ public:
}
private:
BaseT *Base;
BaseT *Base = nullptr;
};
// 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,
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 &);
@ -419,9 +425,9 @@ public:
private:
MappingType Type;
bool IsAtBeginning;
bool IsAtEnd;
KeyValueNode *CurrentEntry;
bool IsAtBeginning = true;
bool IsAtEnd = false;
KeyValueNode *CurrentEntry = nullptr;
void increment();
};
@ -453,13 +459,12 @@ public:
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 &);
@ -477,10 +482,10 @@ public:
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.
@ -507,11 +512,11 @@ private:
/// 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();
@ -564,7 +569,7 @@ private:
/// \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) {
@ -593,11 +598,11 @@ public:
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

View File

@ -26,6 +26,7 @@
#include <cctype>
#include <cstddef>
#include <cstdint>
#include <map>
#include <memory>
#include <new>
#include <string>
@ -226,7 +227,7 @@ struct MissingTrait;
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>*);
@ -243,7 +244,7 @@ public:
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>*);
@ -259,9 +260,9 @@ public:
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> *,
@ -280,8 +281,8 @@ public:
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> *,
@ -297,7 +298,7 @@ public:
// 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>*);
@ -312,7 +313,7 @@ public:
// 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> *);
@ -325,7 +326,7 @@ public:
// 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>*);
@ -340,7 +341,7 @@ public:
// 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> *);
@ -355,7 +356,7 @@ public:
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>*);
@ -371,7 +372,7 @@ public:
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>*);
@ -422,7 +423,7 @@ struct has_SequenceTraits : public std::integral_constant<bool,
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>*);
@ -537,7 +538,7 @@ struct unvalidatedMappingTraits
// Base class for Input and Output.
class IO {
public:
IO(void *Ctxt=nullptr);
IO(void *Ctxt = nullptr);
virtual ~IO();
virtual bool outputting() = 0;
@ -638,6 +639,7 @@ public:
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);
@ -773,7 +775,7 @@ typename std::enable_if<has_ScalarTraits<T>::value, void>::type
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));
@ -783,7 +785,7 @@ yamlize(IO &io, T &Val, bool, EmptyContext &Ctx) {
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));
}
}
}
@ -793,7 +795,7 @@ typename std::enable_if<has_BlockScalarTraits<T>::value, void>::type
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);
@ -803,7 +805,7 @@ yamlize(IO &YamlIO, T &Val, bool, EmptyContext &Ctx) {
StringRef Result =
BlockScalarTraits<T>::input(Str, YamlIO.getContext(), Val);
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()) {
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");
}
}
@ -871,7 +873,7 @@ yamlize(IO &io, T &Val, bool, EmptyContext &Ctx) {
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) {
@ -899,92 +901,92 @@ yamlize(IO &io, T &Seq, bool, Context &Ctx) {
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; }
};
@ -994,12 +996,11 @@ struct ScalarTraits<double> {
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);
}
@ -1039,7 +1040,7 @@ struct MappingNormalization {
TNorm* operator->() { return BufPtr; }
private:
typedef llvm::AlignedCharArrayUnion<TNorm> Storage;
using Storage = AlignedCharArrayUnion<TNorm>;
Storage Buffer;
IO &io;
@ -1051,9 +1052,8 @@ private:
// 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);
}
@ -1077,11 +1077,11 @@ struct MappingNormalizationHeap {
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;
};
@ -1197,10 +1197,10 @@ private:
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 {
@ -1232,14 +1232,14 @@ public:
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;
};
@ -1249,7 +1249,7 @@ private:
///
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
@ -1312,17 +1312,17 @@ private:
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
@ -1345,7 +1345,7 @@ private:
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; \
};
///
@ -1359,29 +1359,29 @@ LLVM_YAML_STRONG_TYPEDEF(uint64_t, Hex64)
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; }
};
@ -1545,8 +1545,10 @@ operator<<(Output &yout, T &seq) {
}
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);
@ -1556,10 +1558,12 @@ template <typename T> struct SequenceTraitsImpl {
/// 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);
@ -1637,7 +1641,7 @@ template <typename T> struct StdMapStringCustomMappingTraitsImpl {
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; } \
}; \

View File

@ -1,4 +1,4 @@
//===- CoverageMapping.cpp - Code coverage mapping support ------*- C++ -*-===//
//===- CoverageMapping.cpp - Code coverage mapping support ----------------===//
//
// The LLVM Compiler Infrastructure
//
@ -303,8 +303,8 @@ namespace {
/// 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:
@ -318,7 +318,6 @@ public:
}
MapT::iterator begin() { return InstantiatedFunctions.begin(); }
MapT::iterator end() { return InstantiatedFunctions.end(); }
};

View File

@ -1,4 +1,4 @@
//===- CoverageMappingReader.cpp - Code coverage mapping reader -*- C++ -*-===//
//===- CoverageMappingReader.cpp - Code coverage mapping reader -----------===//
//
// The LLVM Compiler Infrastructure
//
@ -62,7 +62,7 @@ void CoverageMappingIterator::increment() {
}
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);
@ -392,9 +392,9 @@ struct CovMapFuncRecordReader {
// 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.
@ -576,7 +576,7 @@ static Error loadTestingFormat(StringRef Data, InstrProfSymtab &ProfileNames,
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 =
@ -584,7 +584,7 @@ static Error loadTestingFormat(StringRef Data, InstrProfSymtab &ProfileNames,
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 =
@ -598,7 +598,7 @@ static Error loadTestingFormat(StringRef Data, InstrProfSymtab &ProfileNames,
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)

View File

@ -484,8 +484,8 @@ InstrProfLookupTrait::ComputeHash(StringRef K) {
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) {
@ -622,7 +622,7 @@ IndexedInstrProfReader::readSummary(IndexedInstrProf::ProfVersion Version,
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,

View File

@ -69,8 +69,7 @@ public:
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++) {
@ -91,14 +90,14 @@ public:
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;

View File

@ -1,4 +1,4 @@
//===-- GraphWriter.cpp - Implements GraphWriter support routines ---------===//
//===- GraphWriter.cpp - Implements GraphWriter support routines ----------===//
//
// The LLVM Compiler Infrastructure
//
@ -12,10 +12,22 @@
//===----------------------------------------------------------------------===//
#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,
@ -99,8 +111,10 @@ static bool ExecGraphViewer(StringRef ExecPath, std::vector<const char *> &args,
}
namespace {
struct GraphSession {
std::string LogBuffer;
bool TryFindProgram(StringRef Names, std::string &ProgramPath) {
raw_string_ostream Log(LogBuffer);
SmallVector<StringRef, 8> parts;
@ -115,7 +129,8 @@ struct GraphSession {
return false;
}
};
} // namespace
} // end anonymous namespace
static const char *getProgramName(GraphProgram::Name program) {
switch (program) {

View File

@ -1,4 +1,4 @@
//===--- YAMLParser.cpp - Simple YAML parser ------------------------------===//
//===- YAMLParser.cpp - Simple YAML parser --------------------------------===//
//
// The LLVM Compiler Infrastructure
//
@ -13,15 +13,29 @@
#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;
@ -37,7 +51,7 @@ enum UnicodeEncodingForm {
/// 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.
@ -46,7 +60,7 @@ typedef std::pair<UnicodeEncodingForm, unsigned> EncodingInfo;
/// @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])) {
@ -95,8 +109,6 @@ static EncodingInfo getUnicodeEncoding(StringRef Input) {
return std::make_pair(UEF_UTF8, 0);
}
namespace llvm {
namespace yaml {
/// Pin the vtables to this file.
void Node::anchor() {}
void NullNode::anchor() {}
@ -107,6 +119,9 @@ void MappingNode::anchor() {}
void SequenceNode::anchor() {}
void AliasNode::anchor() {}
namespace llvm {
namespace yaml {
/// Token - A single YAML token.
struct Token {
enum TokenKind {
@ -133,7 +148,7 @@ struct Token {
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.
@ -142,14 +157,16 @@ struct Token {
/// 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
@ -170,12 +187,13 @@ struct SimpleKey {
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();
@ -229,6 +247,7 @@ static UTF8Decoded decodeUTF8(StringRef Range) {
namespace llvm {
namespace yaml {
/// @brief Scans YAML tokens from a MemoryBuffer.
class Scanner {
public:
@ -350,7 +369,8 @@ private:
/// 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.
///
@ -655,10 +675,10 @@ bool yaml::dumpTokens(StringRef Input, raw_ostream &OS) {
}
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)
@ -1744,7 +1764,7 @@ Stream::Stream(MemoryBufferRef InputBuffer, SourceMgr &SM, bool ShowColors,
std::error_code *EC)
: scanner(new Scanner(InputBuffer, SM, ShowColors, EC)), CurrentDoc() {}
Stream::~Stream() {}
Stream::~Stream() = default;
bool Stream::failed() { return scanner->failed(); }
@ -1851,8 +1871,6 @@ bool Node::failed() const {
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.

View File

@ -8,17 +8,26 @@
//===----------------------------------------------------------------------===//
#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;
@ -26,11 +35,9 @@ 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;
@ -46,15 +53,13 @@ void IO::setContext(void *Context) {
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; }
@ -398,13 +403,9 @@ bool Input::canElideEmptySequence() {
//===----------------------------------------------------------------------===//
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;