llvm.org GIT mirror llvm / dfaebc4
[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 Eugene Zelenko 2 years ago
18 changed file(s) with 385 addition(s) and 326 deletion(s). Raw diff Collapse all Expand all
410410 std::vector::const_iterator begin() const {
411411 return Segments.begin();
412412 }
413
413414 std::vector::const_iterator end() const {
414415 return Segments.end();
415416 }
417
416418 bool empty() const { return Segments.empty(); }
417419
418420 /// \brief Expansions that can be further processed.
429431 unsigned MismatchedFunctionCount = 0;
430432
431433 CoverageMapping() = default;
434
432435 /// \brief Add a function record corresponding to \p Record.
433436 Error loadFunctionRecord(const CoverageMappingRecord &Record,
434437 IndexedInstrProfReader &ProfileReader);
606609 };
607610
608611 template struct CovMapTraits {
609 typedef CovMapFunctionRecord CovMapFuncRecordType;
610 typedef uint64_t NameRefType;
612 using CovMapFuncRecordType = CovMapFunctionRecord;
613 using NameRefType = uint64_t;
611614 };
612615
613616 template struct CovMapTraits {
614 typedef CovMapFunctionRecordV1 CovMapFuncRecordType;
615 typedef IntPtrT NameRefType;
617 using CovMapFuncRecordType = CovMapFunctionRecordV1;
618 using NameRefType = IntPtrT;
616619 };
617620
618621 } // end namespace coverage
621624 template<> struct DenseMapInfo {
622625 static inline coverage::CounterExpression getEmptyKey() {
623626 using namespace coverage;
627
624628 return CounterExpression(CounterExpression::ExprKind::Subtract,
625629 Counter::getCounter(~0U),
626630 Counter::getCounter(~0U));
628632
629633 static inline coverage::CounterExpression getTombstoneKey() {
630634 using namespace coverage;
635
631636 return CounterExpression(CounterExpression::ExprKind::Add,
632637 Counter::getCounter(~0U),
633638 Counter::getCounter(~0U));
409409 /// on how PGO name is formed.
410410 class InstrProfSymtab {
411411 public:
412 typedef std::vector> AddrHashMap;
412 using AddrHashMap = std::vector>;
413413
414414 private:
415415 StringRef Data;
598598 InstrProfRecord(StringRef Name, uint64_t Hash, std::vector Counts)
599599 : Name(Name), Hash(Hash), Counts(std::move(Counts)) {}
600600
601 typedef std::vector> ValueMapType;
601 using ValueMapType = std::vector>;
602602
603603 /// Return the number of value profile kinds with non-zero number
604604 /// of profile sites.
672672 private:
673673 std::vector IndirectCallSites;
674674 std::vector MemOPSizes;
675
675676 const std::vector &
676
677677 getValueSitesForKind(uint32_t ValueKind) const {
678678 switch (ValueKind) {
679679 case IPVK_IndirectCallTarget:
877877 // The number of Cutoff Entries (Summary::Entry) following summary fields.
878878 uint64_t NumCutoffEntries;
879879
880 Summary() = delete;
881 Summary(uint32_t Size) { memset(this, 0, Size); }
882
883 void operator delete(void *ptr) { ::operator delete(ptr); }
884
880885 static uint32_t getSize(uint32_t NumSumFields, uint32_t NumCutoffEntries) {
881886 return sizeof(Summary) + NumCutoffEntries * sizeof(Entry) +
882887 NumSumFields * sizeof(uint64_t);
915920 ER.MinBlockCount = E.MinCount;
916921 ER.NumBlocks = E.NumCounts;
917922 }
918
919 Summary(uint32_t Size) { memset(this, 0, Size); }
920 void operator delete(void *ptr) { ::operator delete(ptr); }
921
922 Summary() = delete;
923923 };
924924
925925 inline std::unique_ptr allocSummary(uint32_t TotalSize) {
9191
9292 protected:
9393 std::unique_ptr Symtab;
94
9495 /// Set the current error and return same.
9596 Error error(instrprof_error Err) {
9697 LastError = Err;
201202
202203 public:
203204 RawInstrProfReader(std::unique_ptr DataBuffer)
204 : DataBuffer(std::move(DataBuffer)) { }
205 : DataBuffer(std::move(DataBuffer)) {}
205206 RawInstrProfReader(const RawInstrProfReader &) = delete;
206207 RawInstrProfReader &operator=(const RawInstrProfReader &) = delete;
207208
267268 }
268269 };
269270
270 typedef RawInstrProfReader RawInstrProfReader32;
271 typedef RawInstrProfReader RawInstrProfReader64;
271 using RawInstrProfReader32 = RawInstrProfReader;
272 using RawInstrProfReader64 = RawInstrProfReader;
272273
273274 namespace IndexedInstrProf {
274275
291292 InstrProfLookupTrait(IndexedInstrProf::HashT HashType, unsigned FormatVersion)
292293 : HashType(HashType), FormatVersion(FormatVersion) {}
293294
294 typedef ArrayRef data_type;
295
296 typedef StringRef internal_key_type;
297 typedef StringRef external_key_type;
298 typedef uint64_t hash_value_type;
299 typedef uint64_t offset_type;
295 using data_type = ArrayRef;
296
297 using internal_key_type = StringRef;
298 using external_key_type = StringRef;
299 using hash_value_type = uint64_t;
300 using offset_type = uint64_t;
300301
301302 static bool EqualKey(StringRef A, StringRef B) { return A == B; }
302303 static StringRef GetInternalKey(StringRef K) { return K; }
345346 virtual Error populateSymtab(InstrProfSymtab &) = 0;
346347 };
347348
348 typedef OnDiskIterableChainedHashTable
349 OnDiskHashTableImplV3;
349 using OnDiskHashTableImplV3 =
350 OnDiskIterableChainedHashTable;
350351
351352 template
352353 class InstrProfReaderIndex : public InstrProfReaderIndexBase {
353
354354 private:
355355 std::unique_ptr HashTable;
356356 typename HashTableImpl::data_iterator RecordIterator;
2828 /// Writer for instrumentation based profile data.
2929 class InstrProfRecordWriterTrait;
3030 class ProfOStream;
31 class raw_fd_ostream;
3132
3233 class InstrProfWriter {
3334 public:
34 typedef SmallDenseMap ProfilingData;
35 using ProfilingData = SmallDenseMap;
3536 enum ProfKind { PF_Unknown = 0, PF_FE, PF_IRLevel };
3637
3738 private:
124124 /// will be a list of one or more functions.
125125 class SampleRecord {
126126 public:
127 typedef StringMap CallTargetMap;
127 using CallTargetMap = StringMap;
128128
129129 SampleRecord() = default;
130130
181181
182182 raw_ostream &operator<<(raw_ostream &OS, const SampleRecord &Sample);
183183
184 typedef std::map BodySampleMap;
185184 class FunctionSamples;
186 typedef StringMap FunctionSamplesMap;
187 typedef std::map CallsiteSampleMap;
185
186 using BodySampleMap = std::map;
187 using FunctionSamplesMap = StringMap;
188 using CallsiteSampleMap = std::map;
188189
189190 /// Representation of the samples collected for a function.
190191 ///
397398 /// order of LocationT.
398399 template class SampleSorter {
399400 public:
400 typedef std::pair SamplesWithLoc;
401 typedef SmallVector SamplesWithLocList;
401 using SamplesWithLoc = std::pair;
402 using SamplesWithLocList = SmallVector;
402403
403404 SampleSorter(const std::map &Samples) {
404405 for (const auto &I : Samples)
349349 class SampleProfileReaderBinary : public SampleProfileReader {
350350 public:
351351 SampleProfileReaderBinary(std::unique_ptr B, LLVMContext &C)
352 : SampleProfileReader(std::move(B), C), Data(nullptr), End(nullptr) {}
352 : SampleProfileReader(std::move(B), C) {}
353353
354354 /// \brief Read and validate the file header.
355355 std::error_code readHeader() override;
387387 std::error_code readProfile(FunctionSamples &FProfile);
388388
389389 /// \brief Points to the current location in the buffer.
390 const uint8_t *Data;
390 const uint8_t *Data = nullptr;
391391
392392 /// \brief Points to the end of the buffer.
393 const uint8_t *End;
393 const uint8_t *End = nullptr;
394394
395395 /// Function name table.
396396 std::vector NameTable;
402402 std::error_code readSummary();
403403 };
404404
405 typedef SmallVector InlineCallStack;
405 using InlineCallStack = SmallVector;
406406
407407 // Supported histogram types in GCC. Currently, we only need support for
408408 // call target histograms.
270270 /// GCOVFunction - Collects function information.
271271 class GCOVFunction {
272272 public:
273 typedef pointee_iterator
274 std::unique_ptr>::const_iterator> BlockIterator;
273 using BlockIterator = pointee_iterator
274 std::unique_ptr>::const_iterator>;
275275
276276 GCOVFunction(GCOVFile &P) : Parent(P) {}
277277
320320 };
321321
322322 public:
323 typedef SmallVectorImpl::const_iterator EdgeIterator;
323 using EdgeIterator = SmallVectorImpl::const_iterator;
324324
325325 GCOVBlock(GCOVFunction &P, uint32_t N) : Parent(P), Number(N) {}
326326 ~GCOVBlock();
380380 // Therefore this typedef allows LineData.Functions to store multiple
381381 // functions
382382 // per instance. This is rare, however, so optimize for the common case.
383 typedef SmallVector FunctionVector;
384 typedef DenseMap FunctionLines;
385 typedef SmallVector BlockVector;
386 typedef DenseMap BlockLines;
383 using FunctionVector = SmallVector;
384 using FunctionLines = DenseMap;
385 using BlockVector = SmallVector;
386 using BlockLines = DenseMap;
387387
388388 struct LineData {
389389 LineData() = default;
447447 uint32_t RunCount = 0;
448448 uint32_t ProgramCount = 0;
449449
450 typedef SmallVector, 4> FileCoverageList;
451 typedef MapVector FuncCoverageMap;
450 using FileCoverageList = SmallVector, 4>;
451 using FuncCoverageMap = MapVector;
452452
453453 FileCoverageList FileCoverages;
454454 FuncCoverageMap FuncCoverages;
None //===-- llvm/Support/GraphWriter.h - Write graph to a .dot file -*- C++ -*-===//
0 //===- llvm/Support/GraphWriter.h - Write graph to a .dot file --*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
2323 #define LLVM_SUPPORT_GRAPHWRITER_H
2424
2525 #include "llvm/ADT/GraphTraits.h"
26 #include "llvm/ADT/StringRef.h"
2627 #include "llvm/ADT/Twine.h"
2728 #include "llvm/Support/DOTGraphTraits.h"
2829 #include "llvm/Support/raw_ostream.h"
30 #include
31 #include
32 #include
33 #include
34 #include
2935 #include
3036
3137 namespace llvm {
3238
3339 namespace DOT { // Private functions...
34 std::string EscapeString(const std::string &Label);
35
36 /// \brief Get a color string for this node number. Simply round-robin selects
37 /// from a reasonable number of colors.
38 StringRef getColorString(unsigned NodeNumber);
39 }
40
41 std::string EscapeString(const std::string &Label);
42
43 /// \brief Get a color string for this node number. Simply round-robin selects
44 /// from a reasonable number of colors.
45 StringRef getColorString(unsigned NodeNumber);
46
47 } // end namespace DOT
4048
4149 namespace GraphProgram {
42 enum Name {
43 DOT,
44 FDP,
45 NEATO,
46 TWOPI,
47 CIRCO
48 };
49 }
50
51 enum Name {
52 DOT,
53 FDP,
54 NEATO,
55 TWOPI,
56 CIRCO
57 };
58
59 } // end namespace GraphProgram
5060
5161 bool DisplayGraph(StringRef Filename, bool wait = true,
5262 GraphProgram::Name program = GraphProgram::DOT);
5666 raw_ostream &O;
5767 const GraphType &G;
5868
59 typedef DOTGraphTraits DOTTraits;
60 typedef GraphTraits GTraits;
61 typedef typename GTraits::NodeRef NodeRef;
62 typedef typename GTraits::nodes_iterator node_iterator;
63 typedef typename GTraits::ChildIteratorType child_iterator;
69 using DOTTraits = DOTGraphTraits;
70 using GTraits = GraphTraits;
71 using NodeRef = typename GTraits::NodeRef;
72 using node_iterator = typename GTraits::nodes_iterator;
73 using child_iterator = typename GTraits::ChildIteratorType;
6474 DOTTraits DTraits;
6575
6676 static_assert(std::is_pointer::value,
345355 DisplayGraph(Filename, false, Program);
346356 }
347357
348 } // End llvm namespace
349
350 #endif
358 } // end namespace llvm
359
360 #endif // LLVM_SUPPORT_GRAPHWRITER_H
5353 class MCTargetAsmParser;
5454 class MCTargetOptions;
5555 class MCTargetStreamer;
56 class raw_ostream;
5657 class raw_pwrite_stream;
5758 class TargetMachine;
5859 class TargetOptions;
9596 public:
9697 friend struct TargetRegistry;
9798
98 typedef bool (*ArchMatchFnTy)(Triple::ArchType Arch);
99
100 typedef MCAsmInfo *(*MCAsmInfoCtorFnTy)(const MCRegisterInfo &MRI,
101 const Triple &TT);
102 typedef void (*MCAdjustCodeGenOptsFnTy)(const Triple &TT, Reloc::Model RM,
103 CodeModel::Model &CM);
104
105 typedef MCInstrInfo *(*MCInstrInfoCtorFnTy)(void);
106 typedef MCInstrAnalysis *(*MCInstrAnalysisCtorFnTy)(const MCInstrInfo *Info);
107 typedef MCRegisterInfo *(*MCRegInfoCtorFnTy)(const Triple &TT);
108 typedef MCSubtargetInfo *(*MCSubtargetInfoCtorFnTy)(const Triple &TT,
109 StringRef CPU,
110 StringRef Features);
111 typedef TargetMachine *(*TargetMachineCtorTy)(
99 using ArchMatchFnTy = bool (*)(Triple::ArchType Arch);
100
101 using MCAsmInfoCtorFnTy = MCAsmInfo *(*)(const MCRegisterInfo &MRI,
102 const Triple &TT);
103 using MCAdjustCodeGenOptsFnTy = void (*)(const Triple &TT, Reloc::Model RM,
104 CodeModel::Model &CM);
105
106 using MCInstrInfoCtorFnTy = MCInstrInfo *(*)();
107 using MCInstrAnalysisCtorFnTy = MCInstrAnalysis *(*)(const MCInstrInfo *Info);
108 using MCRegInfoCtorFnTy = MCRegisterInfo *(*)(const Triple &TT);
109 using MCSubtargetInfoCtorFnTy = MCSubtargetInfo *(*)(const Triple &TT,
110 StringRef CPU,
111 StringRef Features);
112 using TargetMachineCtorTy = TargetMachine *(*)(
112113 const Target &T, const Triple &TT, StringRef CPU, StringRef Features,
113114 const TargetOptions &Options, Optional RM,
114115 CodeModel::Model CM, CodeGenOpt::Level OL);
115116 // If it weren't for layering issues (this header is in llvm/Support, but
116117 // depends on MC?) this should take the Streamer by value rather than rvalue
117118 // reference.
118 typedef AsmPrinter *(*AsmPrinterCtorTy)(
119 using AsmPrinterCtorTy = AsmPrinter *(*)(
119120 TargetMachine &TM, std::unique_ptr &&Streamer);
120 typedef MCAsmBackend *(*MCAsmBackendCtorTy)(const Target &T,
121 const MCRegisterInfo &MRI,
122 const Triple &TT, StringRef CPU,
123 const MCTargetOptions &Options);
124 typedef MCTargetAsmParser *(*MCAsmParserCtorTy)(
121 using MCAsmBackendCtorTy = MCAsmBackend *(*)(const Target &T,
122 const MCRegisterInfo &MRI,
123 const Triple &TT, StringRef CPU,
124 const MCTargetOptions &Options);
125 using MCAsmParserCtorTy = MCTargetAsmParser *(*)(
125126 const MCSubtargetInfo &STI, MCAsmParser &P, const MCInstrInfo &MII,
126127 const MCTargetOptions &Options);
127 typedef MCDisassembler *(*MCDisassemblerCtorTy)(const Target &T,
128 const MCSubtargetInfo &STI,
129 MCContext &Ctx);
130 typedef MCInstPrinter *(*MCInstPrinterCtorTy)(const Triple &T,
131 unsigned SyntaxVariant,
132 const MCAsmInfo &MAI,
133 const MCInstrInfo &MII,
134 const MCRegisterInfo &MRI);
135 typedef MCCodeEmitter *(*MCCodeEmitterCtorTy)(const MCInstrInfo &II,
136 const MCRegisterInfo &MRI,
137 MCContext &Ctx);
138 typedef MCStreamer *(*ELFStreamerCtorTy)(const Triple &T, MCContext &Ctx,
139 MCAsmBackend &TAB,
140 raw_pwrite_stream &OS,
141 MCCodeEmitter *Emitter,
142 bool RelaxAll);
143 typedef MCStreamer *(*MachOStreamerCtorTy)(MCContext &Ctx, MCAsmBackend &TAB,
144 raw_pwrite_stream &OS,
145 MCCodeEmitter *Emitter,
146 bool RelaxAll,
147 bool DWARFMustBeAtTheEnd);
148 typedef MCStreamer *(*COFFStreamerCtorTy)(MCContext &Ctx, MCAsmBackend &TAB,
149 raw_pwrite_stream &OS,
150 MCCodeEmitter *Emitter,
151 bool RelaxAll,
152 bool IncrementalLinkerCompatible);
153 typedef MCStreamer *(*WasmStreamerCtorTy)(const Triple &T, MCContext &Ctx,
128 using MCDisassemblerCtorTy = MCDisassembler *(*)(const Target &T,
129 const MCSubtargetInfo &STI,
130 MCContext &Ctx);
131 using MCInstPrinterCtorTy = MCInstPrinter *(*)(const Triple &T,
132 unsigned SyntaxVariant,
133 const MCAsmInfo &MAI,
134 const MCInstrInfo &MII,
135 const MCRegisterInfo &MRI);
136 using MCCodeEmitterCtorTy = MCCodeEmitter *(*)(const MCInstrInfo &II,
137 const MCRegisterInfo &MRI,
138 MCContext &Ctx);
139 using ELFStreamerCtorTy = MCStreamer *(*)(const Triple &T, MCContext &Ctx,
154140 MCAsmBackend &TAB,
155141 raw_pwrite_stream &OS,
156142 MCCodeEmitter *Emitter,
157143 bool RelaxAll);
158 typedef MCTargetStreamer *(*NullTargetStreamerCtorTy)(MCStreamer &S);
159 typedef MCTargetStreamer *(*AsmTargetStreamerCtorTy)(
144 using MachOStreamerCtorTy = MCStreamer *(*)(MCContext &Ctx, MCAsmBackend &TAB,
145 raw_pwrite_stream &OS,
146 MCCodeEmitter *Emitter,
147 bool RelaxAll,
148 bool DWARFMustBeAtTheEnd);
149 using COFFStreamerCtorTy = MCStreamer *(*)(MCContext &Ctx, MCAsmBackend &TAB,
150 raw_pwrite_stream &OS,
151 MCCodeEmitter *Emitter,
152 bool RelaxAll,
153 bool IncrementalLinkerCompatible);
154 using WasmStreamerCtorTy = MCStreamer *(*)(const Triple &T, MCContext &Ctx,
155 MCAsmBackend &TAB,
156 raw_pwrite_stream &OS,
157 MCCodeEmitter *Emitter,
158 bool RelaxAll);
159 using NullTargetStreamerCtorTy = MCTargetStreamer *(*)(MCStreamer &S);
160 using AsmTargetStreamerCtorTy = MCTargetStreamer *(*)(
160161 MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint,
161162 bool IsVerboseAsm);
162 typedef MCTargetStreamer *(*ObjectTargetStreamerCtorTy)(
163 using ObjectTargetStreamerCtorTy = MCTargetStreamer *(*)(
163164 MCStreamer &S, const MCSubtargetInfo &STI);
164 typedef MCRelocationInfo *(*MCRelocationInfoCtorTy)(const Triple &TT,
165 MCContext &Ctx);
166 typedef MCSymbolizer *(*MCSymbolizerCtorTy)(
165 using MCRelocationInfoCtorTy = MCRelocationInfo *(*)(const Triple &TT,
166 MCContext &Ctx);
167 using MCSymbolizerCtorTy = MCSymbolizer *(*)(
167168 const Triple &TT, LLVMOpInfoCallback GetOpInfo,
168169 LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo, MCContext *Ctx,
169170 std::unique_ptr &&RelInfo);
None //===--- YAMLParser.h - Simple YAML parser --------------------------------===//
0 //===- YAMLParser.h - Simple YAML parser ------------------------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
4040 #include "llvm/ADT/StringRef.h"
4141 #include "llvm/Support/Allocator.h"
4242 #include "llvm/Support/SMLoc.h"
43 #include
44 #include
45 #include
4346 #include
47 #include
48 #include
4449 #include
45 #include
4650
4751 namespace llvm {
52
4853 class MemoryBufferRef;
4954 class SourceMgr;
55 class raw_ostream;
5056 class Twine;
51 class raw_ostream;
5257
5358 namespace yaml {
5459
60 class Document;
5561 class document_iterator;
56 class Document;
5762 class Node;
5863 class Scanner;
5964 struct Token;
8691 document_iterator end();
8792 void skip();
8893 bool failed();
94
8995 bool validate() {
9096 skip();
9197 return !failed();
94100 void printError(Node *N, const Twine &Msg);
95101
96102 private:
103 friend class Document;
104
97105 std::unique_ptr scanner;
98106 std::unique_ptr CurrentDoc;
99
100 friend class Document;
101107 };
102108
103109 /// \brief Abstract base class for all Nodes.
118124 Node(unsigned int Type, std::unique_ptr &, StringRef Anchor,
119125 StringRef Tag);
120126
127 void *operator new(size_t Size, BumpPtrAllocator &Alloc,
128 size_t Alignment = 16) noexcept {
129 return Alloc.Allocate(Size, Alignment);
130 }
131
132 void operator delete(void *Ptr, BumpPtrAllocator &Alloc,
133 size_t Size) noexcept {
134 Alloc.Deallocate(Ptr, Size);
135 }
136
137 void operator delete(void *) noexcept = delete;
138
121139 /// \brief Get the value of the anchor attached to this node. If it does not
122140 /// have one, getAnchor().size() will be 0.
123141 StringRef getAnchor() const { return Anchor; }
145163
146164 unsigned int getType() const { return TypeID; }
147165
148 void *operator new(size_t Size, BumpPtrAllocator &Alloc,
149 size_t Alignment = 16) noexcept {
150 return Alloc.Allocate(Size, Alignment);
151 }
152
153 void operator delete(void *Ptr, BumpPtrAllocator &Alloc,
154 size_t Size) noexcept {
155 Alloc.Deallocate(Ptr, Size);
156 }
157
158166 protected:
159167 std::unique_ptr &Doc;
160168 SMRange SourceRange;
161
162 void operator delete(void *) noexcept = delete;
163169
164170 ~Node() = default;
165171
267273
268274 public:
269275 KeyValueNode(std::unique_ptr &D)
270 : Node(NK_KeyValue, D, StringRef(), StringRef()), Key(nullptr),
271 Value(nullptr) {}
276 : Node(NK_KeyValue, D, StringRef(), StringRef()) {}
272277
273278 /// \brief Parse and return the key.
274279 ///
295300 }
296301
297302 private:
298 Node *Key;
299 Node *Value;
303 Node *Key = nullptr;
304 Node *Value = nullptr;
300305 };
301306
302307 /// \brief This is an iterator abstraction over YAML collections shared by both
308313 class basic_collection_iterator
309314 : public std::iterator {
310315 public:
311 basic_collection_iterator() : Base(nullptr) {}
316 basic_collection_iterator() = default;
312317 basic_collection_iterator(BaseT *B) : Base(B) {}
313318
314319 ValueT *operator->() const {
357362 }
358363
359364 private:
360 BaseT *Base;
365 BaseT *Base = nullptr;
361366 };
362367
363368 // The following two templates are used for both MappingNode and Sequence Node.
398403
399404 MappingNode(std::unique_ptr &D, StringRef Anchor, StringRef Tag,
400405 MappingType MT)
401 : Node(NK_Mapping, D, Anchor, Tag), Type(MT), IsAtBeginning(true),
402 IsAtEnd(false), CurrentEntry(nullptr) {}
406 : Node(NK_Mapping, D, Anchor, Tag), Type(MT) {}
403407
404408 friend class basic_collection_iterator;
405 typedef basic_collection_iterator iterator;
409
410 using iterator = basic_collection_iterator;
411
406412 template friend typename T::iterator yaml::begin(T &);
407413 template friend void yaml::skip(T &);
408414
418424
419425 private:
420426 MappingType Type;
421 bool IsAtBeginning;
422 bool IsAtEnd;
423 KeyValueNode *CurrentEntry;
427 bool IsAtBeginning = true;
428 bool IsAtEnd = false;
429 KeyValueNode *CurrentEntry = nullptr;
424430
425431 void increment();
426432 };
452458
453459 SequenceNode(std::unique_ptr &D, StringRef Anchor, StringRef Tag,
454460 SequenceType ST)
455 : Node(NK_Sequence, D, Anchor, Tag), SeqType(ST), IsAtBeginning(true),
456 IsAtEnd(false),
457 WasPreviousTokenFlowEntry(true), // Start with an imaginary ','.
458 CurrentEntry(nullptr) {}
461 : Node(NK_Sequence, D, Anchor, Tag), SeqType(ST) {}
459462
460463 friend class basic_collection_iterator;
461 typedef basic_collection_iterator iterator;
464
465 using iterator = basic_collection_iterator;
466
462467 template friend typename T::iterator yaml::begin(T &);
463468 template friend void yaml::skip(T &);
464469
476481
477482 private:
478483 SequenceType SeqType;
479 bool IsAtBeginning;
480 bool IsAtEnd;
481 bool WasPreviousTokenFlowEntry;
482 Node *CurrentEntry;
484 bool IsAtBeginning = true;
485 bool IsAtEnd = false;
486 bool WasPreviousTokenFlowEntry = true; // Start with an imaginary ','.
487 Node *CurrentEntry = nullptr;
483488 };
484489
485490 /// \brief Represents an alias to a Node with an anchor.
506511 /// node.
507512 class Document {
508513 public:
514 Document(Stream &ParentStream);
515
509516 /// \brief Root for parsing a node. Returns a single node.
510517 Node *parseBlockNode();
511
512 Document(Stream &ParentStream);
513518
514519 /// \brief Finish parsing the current document and return true if there are
515520 /// more. Return false otherwise.
563568 /// \brief Iterator abstraction for Documents over a Stream.
564569 class document_iterator {
565570 public:
566 document_iterator() : Doc(nullptr) {}
571 document_iterator() = default;
567572 document_iterator(std::unique_ptr &D) : Doc(&D) {}
568573
569574 bool operator==(const document_iterator &Other) {
592597 private:
593598 bool isAtEnd() const { return !Doc || !*Doc; }
594599
595 std::unique_ptr *Doc;
596 };
597
598 } // End namespace yaml.
599
600 } // End namespace llvm.
601
602 #endif
600 std::unique_ptr *Doc = nullptr;
601 };
602
603 } // end namespace yaml
604
605 } // end namespace llvm
606
607 #endif // LLVM_SUPPORT_YAMLPARSER_H
2525 #include
2626 #include
2727 #include
28 #include
2829 #include
2930 #include
3031 #include
225226 template
226227 struct has_ScalarEnumerationTraits
227228 {
228 typedef void (*Signature_enumeration)(class IO&, T&);
229 using Signature_enumeration = void (*)(class IO&, T&);
229230
230231 template
231232 static char test(SameType*);
242243 template
243244 struct has_ScalarBitSetTraits
244245 {
245 typedef void (*Signature_bitset)(class IO&, T&);
246 using Signature_bitset = void (*)(class IO&, T&);
246247
247248 template
248249 static char test(SameType*);
258259 template
259260 struct has_ScalarTraits
260261 {
261 typedef StringRef (*Signature_input)(StringRef, void*, T&);
262 typedef void (*Signature_output)(const T&, void*, llvm::raw_ostream&);
263 typedef bool (*Signature_mustQuote)(StringRef);
262 using Signature_input = StringRef (*)(StringRef, void*, T&);
263 using Signature_output = void (*)(const T&, void*, raw_ostream&);
264 using Signature_mustQuote = bool (*)(StringRef);
264265
265266 template
266267 static char test(SameType *,
279280 template
280281 struct has_BlockScalarTraits
281282 {
282 typedef StringRef (*Signature_input)(StringRef, void *, T &);
283 typedef void (*Signature_output)(const T &, void *, llvm::raw_ostream &);
283 using Signature_input = StringRef (*)(StringRef, void *, T &);
284 using Signature_output = void (*)(const T &, void *, raw_ostream &);
284285
285286 template
286287 static char test(SameType *,
296297
297298 // Test if MappingContextTraits is defined on type T.
298299 template struct has_MappingTraits {
299 typedef void (*Signature_mapping)(class IO &, T &, Context &);
300 using Signature_mapping = void (*)(class IO &, T &, Context &);
300301
301302 template
302303 static char test(SameType*);
311312
312313 // Test if MappingTraits is defined on type T.
313314 template struct has_MappingTraits {
314 typedef void (*Signature_mapping)(class IO &, T &);
315 using Signature_mapping = void (*)(class IO &, T &);
315316
316317 template
317318 static char test(SameType *);
324325
325326 // Test if MappingContextTraits::validate() is defined on type T.
326327 template struct has_MappingValidateTraits {
327 typedef StringRef (*Signature_validate)(class IO &, T &, Context &);
328 using Signature_validate = StringRef (*)(class IO &, T &, Context &);
328329
329330 template
330331 static char test(SameType*);
339340
340341 // Test if MappingTraits::validate() is defined on type T.
341342 template struct has_MappingValidateTraits {
342 typedef StringRef (*Signature_validate)(class IO &, T &);
343 using Signature_validate = StringRef (*)(class IO &, T &);
343344
344345 template
345346 static char test(SameType *);
354355 template
355356 struct has_SequenceMethodTraits
356357 {
357 typedef size_t (*Signature_size)(class IO&, T&);
358 using Signature_size = size_t (*)(class IO&, T&);
358359
359360 template
360361 static char test(SameType*);
370371 template
371372 struct has_CustomMappingTraits
372373 {
373 typedef void (*Signature_input)(IO &io, StringRef key, T &v);
374 using Signature_input = void (*)(IO &io, StringRef key, T &v);
374375
375376 template
376377 static char test(SameType*);
421422 template
422423 struct has_DocumentListTraits
423424 {
424 typedef size_t (*Signature_size)(class IO&, T&);
425 using Signature_size = size_t (*)(class IO &, T &);
425426
426427 template
427428 static char test(SameType*);
536537 // Base class for Input and Output.
537538 class IO {
538539 public:
539 IO(void *Ctxt=nullptr);
540 IO(void *Ctxt = nullptr);
540541 virtual ~IO();
541542
542543 virtual bool outputting() = 0;
637638 EmptyContext Ctx;
638639 this->processKey(Key, Val, true, Ctx);
639640 }
641
640642 template
641643 void mapRequired(const char *Key, T &Val, Context &Ctx) {
642644 this->processKey(Key, Val, true, Ctx);
772774 yamlize(IO &io, T &Val, bool, EmptyContext &Ctx) {
773775 if ( io.outputting() ) {
774776 std::string Storage;
775 llvm::raw_string_ostream Buffer(Storage);
777 raw_string_ostream Buffer(Storage);
776778 ScalarTraits::output(Val, io.getContext(), Buffer);
777779 StringRef Str = Buffer.str();
778780 io.scalarString(Str, ScalarTraits::mustQuote(Str));
782784 io.scalarString(Str, ScalarTraits::mustQuote(Str));
783785 StringRef Result = ScalarTraits::input(Str, io.getContext(), Val);
784786 if ( !Result.empty() ) {
785 io.setError(llvm::Twine(Result));
787 io.setError(Twine(Result));
786788 }
787789 }
788790 }
792794 yamlize(IO &YamlIO, T &Val, bool, EmptyContext &Ctx) {
793795 if (YamlIO.outputting()) {
794796 std::string Storage;
795 llvm::raw_string_ostream Buffer(Storage);
797 raw_string_ostream Buffer(Storage);
796798 BlockScalarTraits::output(Val, YamlIO.getContext(), Buffer);
797799 StringRef Str = Buffer.str();
798800 YamlIO.blockScalarString(Str);
802804 StringRef Result =
803805 BlockScalarTraits::input(Str, YamlIO.getContext(), Val);
804806 if (!Result.empty())
805 YamlIO.setError(llvm::Twine(Result));
807 YamlIO.setError(Twine(Result));
806808 }
807809 }
808810
816818 if (io.outputting()) {
817819 StringRef Err = MappingTraits::validate(io, Val);
818820 if (!Err.empty()) {
819 llvm::errs() << Err << "\n";
821 errs() << Err << "\n";
820822 assert(Err.empty() && "invalid struct trying to be written as yaml");
821823 }
822824 }
870872 template
871873 typename std::enable_if::value, void>::type
872874 yamlize(IO &io, T &Seq, bool, Context &Ctx) {
873 if ( has_FlowTraits< SequenceTraits >::value ) {
875 if ( has_FlowTraits< SequenceTraits>::value ) {
874876 unsigned incnt = io.beginFlowSequence();
875877 unsigned count = io.outputting() ? SequenceTraits::size(io, Seq) : incnt;
876878 for(unsigned i=0; i < count; ++i) {
898900
899901 template<>
900902 struct ScalarTraits {
901 static void output(const bool &, void*, llvm::raw_ostream &);
902 static StringRef input(StringRef, void*, bool &);
903 static void output(const bool &, void* , raw_ostream &);
904 static StringRef input(StringRef, void *, bool &);
903905 static bool mustQuote(StringRef) { return false; }
904906 };
905907
906908 template<>
907909 struct ScalarTraits {
908 static void output(const StringRef &, void*, llvm::raw_ostream &);
909 static StringRef input(StringRef, void*, StringRef &);
910 static void output(const StringRef &, void *, raw_ostream &);
911 static StringRef input(StringRef, void *, StringRef &);
910912 static bool mustQuote(StringRef S) { return needsQuotes(S); }
911913 };
912914
913915 template<>
914916 struct ScalarTraits {
915 static void output(const std::string &, void*, llvm::raw_ostream &);
916 static StringRef input(StringRef, void*, std::string &);
917 static void output(const std::string &, void *, raw_ostream &);
918 static StringRef input(StringRef, void *, std::string &);
917919 static bool mustQuote(StringRef S) { return needsQuotes(S); }
918920 };
919921
920922 template<>
921923 struct ScalarTraits {
922 static void output(const uint8_t &, void*, llvm::raw_ostream &);
923 static StringRef input(StringRef, void*, uint8_t &);
924 static void output(const uint8_t &, void *, raw_ostream &);
925 static StringRef input(StringRef, void *, uint8_t &);
924926 static bool mustQuote(StringRef) { return false; }
925927 };
926928
927929 template<>
928930 struct ScalarTraits {
929 static void output(const uint16_t &, void*, llvm::raw_ostream &);
930 static StringRef input(StringRef, void*, uint16_t &);
931 static void output(const uint16_t &, void *, raw_ostream &);
932 static StringRef input(StringRef, void *, uint16_t &);
931933 static bool mustQuote(StringRef) { return false; }
932934 };
933935
934936 template<>
935937 struct ScalarTraits {
936 static void output(const uint32_t &, void*, llvm::raw_ostream &);
937 static StringRef input(StringRef, void*, uint32_t &);
938 static void output(const uint32_t &, void *, raw_ostream &);
939 static StringRef input(StringRef, void *, uint32_t &);
938940 static bool mustQuote(StringRef) { return false; }
939941 };
940942
941943 template<>
942944 struct ScalarTraits {
943 static void output(const uint64_t &, void*, llvm::raw_ostream &);
944 static StringRef input(StringRef, void*, uint64_t &);
945 static void output(const uint64_t &, void *, raw_ostream &);
946 static StringRef input(StringRef, void *, uint64_t &);
945947 static bool mustQuote(StringRef) { return false; }
946948 };
947949
948950 template<>
949951 struct ScalarTraits {
950 static void output(const int8_t &, void*, llvm::raw_ostream &);
951 static StringRef input(StringRef, void*, int8_t &);
952 static void output(const int8_t &, void *, raw_ostream &);
953 static StringRef input(StringRef, void *, int8_t &);
952954 static bool mustQuote(StringRef) { return false; }
953955 };
954956
955957 template<>
956958 struct ScalarTraits {
957 static void output(const int16_t &, void*, llvm::raw_ostream &);
958 static StringRef input(StringRef, void*, int16_t &);
959 static void output(const int16_t &, void *, raw_ostream &);
960 static StringRef input(StringRef, void *, int16_t &);
959961 static bool mustQuote(StringRef) { return false; }
960962 };
961963
962964 template<>
963965 struct ScalarTraits {
964 static void output(const int32_t &, void*, llvm::raw_ostream &);
965 static StringRef input(StringRef, void*, int32_t &);
966 static void output(const int32_t &, void *, raw_ostream &);
967 static StringRef input(StringRef, void *, int32_t &);
966968 static bool mustQuote(StringRef) { return false; }
967969 };
968970
969971 template<>
970972 struct ScalarTraits {
971 static void output(const int64_t &, void*, llvm::raw_ostream &);
972 static StringRef input(StringRef, void*, int64_t &);
973 static void output(const int64_t &, void *, raw_ostream &);
974 static StringRef input(StringRef, void *, int64_t &);
973975 static bool mustQuote(StringRef) { return false; }
974976 };
975977
976978 template<>
977979 struct ScalarTraits {
978 static void output(const float &, void*, llvm::raw_ostream &);
979 static StringRef input(StringRef, void*, float &);
980 static void output(const float &, void *, raw_ostream &);
981 static StringRef input(StringRef, void *, float &);
980982 static bool mustQuote(StringRef) { return false; }
981983 };
982984
983985 template<>
984986 struct ScalarTraits {
985 static void output(const double &, void*, llvm::raw_ostream &);
986 static StringRef input(StringRef, void*, double &);
987 static void output(const double &, void *, raw_ostream &);
988 static StringRef input(StringRef, void *, double &);
987989 static bool mustQuote(StringRef) { return false; }
988990 };
989991
993995 template
994996 struct ScalarTraits
995997 value_type, endian, alignment>> {
996 typedef support::detail::packed_endian_specific_integral
997 alignment>
998 endian_type;
999
1000 static void output(const endian_type &E, void *Ctx,
1001 llvm::raw_ostream &Stream) {
998 using endian_type =
999 support::detail::packed_endian_specific_integral
1000 alignment>;
1001
1002 static void output(const endian_type &E, void *Ctx, raw_ostream &Stream) {
10021003 ScalarTraits::output(static_cast(E), Ctx, Stream);
10031004 }
10041005
10381039 TNorm* operator->() { return BufPtr; }
10391040
10401041 private:
1041 typedef llvm::AlignedCharArrayUnion Storage;
1042 using Storage = AlignedCharArrayUnion;
10421043
10431044 Storage Buffer;
10441045 IO &io;
10501051 // to [de]normalize an object for use with YAML conversion.
10511052 template
10521053 struct MappingNormalizationHeap {
1053 MappingNormalizationHeap(IO &i_o, TFinal &Obj,
1054 llvm::BumpPtrAllocator *allocator)
1055 : io(i_o), BufPtr(nullptr), Result(Obj) {
1054 MappingNormalizationHeap(IO &i_o, TFinal &Obj, BumpPtrAllocator *allocator)
1055 : io(i_o), Result(Obj) {
10561056 if ( io.outputting() ) {
10571057 BufPtr = new (&Buffer) TNorm(io, Obj);
10581058 }
10761076 TNorm* operator->() { return BufPtr; }
10771077
10781078 private:
1079 typedef llvm::AlignedCharArrayUnion Storage;
1079 using Storage = AlignedCharArrayUnion;
10801080
10811081 Storage Buffer;
10821082 IO &io;
1083 TNorm *BufPtr;
1083 TNorm *BufPtr = nullptr;
10841084 TFinal &Result;
10851085 };
10861086
11961196
11971197 static inline bool classof(const MapHNode *) { return true; }
11981198
1199 typedef llvm::StringMap> NameToNode;
1200
1201 NameToNode Mapping;
1202 llvm::SmallVector ValidKeys;
1199 using NameToNode = StringMap>;
1200
1201 NameToNode Mapping;
1202 SmallVector ValidKeys;
12031203 };
12041204
12051205 class SequenceHNode : public HNode {
12311231 const Node *getCurrentNode() const;
12321232
12331233 private:
1234 llvm::SourceMgr SrcMgr; // must be before Strm
1234 SourceMgr SrcMgr; // must be before Strm
12351235 std::unique_ptr Strm;
12361236 std::unique_ptr TopNode;
12371237 std::error_code EC;
1238 llvm::BumpPtrAllocator StringAllocator;
1239 llvm::yaml::document_iterator DocIterator;
1238 BumpPtrAllocator StringAllocator;
1239 document_iterator DocIterator;
12401240 std::vector BitValuesUsed;
1241 HNode *CurrentNode;
1241 HNode *CurrentNode = nullptr;
12421242 bool ScalarMatchFound;
12431243 };
12441244
12481248 ///
12491249 class Output : public IO {
12501250 public:
1251 Output(llvm::raw_ostream &, void *Ctxt = nullptr, int WrapColumn = 70);
1251 Output(raw_ostream &, void *Ctxt = nullptr, int WrapColumn = 70);
12521252 ~Output() override;
12531253
12541254 /// \brief Set whether or not to output optional values which are equal
13111311 inFlowMapOtherKey
13121312 };
13131313
1314 llvm::raw_ostream &Out;
1315 int WrapColumn;
1316 SmallVector StateStack;
1317 int Column;
1318 int ColumnAtFlowStart;
1319 int ColumnAtMapFlowStart;
1320 bool NeedBitValueComma;
1321 bool NeedFlowSequenceComma;
1322 bool EnumerationMatchFound;
1323 bool NeedsNewLine;
1324 bool WriteDefaultValues;
1314 raw_ostream &Out;
1315 int WrapColumn;
1316 SmallVector StateStack;
1317 int Column = 0;
1318 int ColumnAtFlowStart = 0;
1319 int ColumnAtMapFlowStart = 0;
1320 bool NeedBitValueComma = false;
1321 bool NeedFlowSequenceComma = false;
1322 bool EnumerationMatchFound = false;
1323 bool NeedsNewLine = false;
1324 bool WriteDefaultValues = false;
13251325 };
13261326
13271327 /// YAML I/O does conversion based on types. But often native data types
13441344 bool operator==(const _base &rhs) const { return value == rhs; } \
13451345 bool operator<(const _type &rhs) const { return value < rhs.value; } \
13461346 _base value; \
1347 typedef _base BaseType; \
1347 using BaseType = _base; \
13481348 };
13491349
13501350 ///
13581358
13591359 template<>
13601360 struct ScalarTraits {
1361 static void output(const Hex8 &, void*, llvm::raw_ostream &);
1362 static StringRef input(StringRef, void*, Hex8 &);
1361 static void output(const Hex8 &, void *, raw_ostream &);
1362 static StringRef input(StringRef, void *, Hex8 &);
13631363 static bool mustQuote(StringRef) { return false; }
13641364 };
13651365
13661366 template<>
13671367 struct ScalarTraits {
1368 static void output(const Hex16 &, void*, llvm::raw_ostream &);
1369 static StringRef input(StringRef, void*, Hex16 &);
1368 static void output(const Hex16 &, void *, raw_ostream &);
1369 static StringRef input(StringRef, void *, Hex16 &);
13701370 static bool mustQuote(StringRef) { return false; }
13711371 };
13721372
13731373 template<>
13741374 struct ScalarTraits {
1375 static void output(const Hex32 &, void*, llvm::raw_ostream &);
1376 static StringRef input(StringRef, void*, Hex32 &);
1375 static void output(const Hex32 &, void *, raw_ostream &);
1376 static StringRef input(StringRef, void *, Hex32 &);
13771377 static bool mustQuote(StringRef) { return false; }
13781378 };
13791379
13801380 template<>
13811381 struct ScalarTraits {
1382 static void output(const Hex64 &, void*, llvm::raw_ostream &);
1383 static StringRef input(StringRef, void*, Hex64 &);
1382 static void output(const Hex64 &, void *, raw_ostream &);
1383 static StringRef input(StringRef, void *, Hex64 &);
13841384 static bool mustQuote(StringRef) { return false; }
13851385 };
13861386
15441544 }
15451545
15461546 template struct SequenceTraitsImpl {
1547 typedef typename T::value_type _type;
1547 using _type = typename T::value_type;
1548
15481549 static size_t size(IO &io, T &seq) { return seq.size(); }
1550
15491551 static _type &element(IO &io, T &seq, size_t index) {
15501552 if (index >= seq.size())
15511553 seq.resize(index + 1);
15551557
15561558 /// Implementation of CustomMappingTraits for std::map.
15571559 template struct StdMapStringCustomMappingTraitsImpl {
1558 typedef std::map map_type;
1560 using map_type = std::map;
1561
15591562 static void inputOne(IO &io, StringRef key, map_type &v) {
15601563 io.mapRequired(key.str().c_str(), v[key]);
15611564 }
1565
15621566 static void output(IO &io, map_type &v) {
15631567 for (auto &p : v)
15641568 io.mapRequired(p.first.c_str(), p.second);
16361640 namespace llvm { \
16371641 namespace yaml { \
16381642 template <> struct ScalarTraits { \
1639 static void output(const Type &Value, void *ctx, llvm::raw_ostream &Out); \
1643 static void output(const Type &Value, void *ctx, raw_ostream &Out); \
16401644 static StringRef input(StringRef Scalar, void *ctxt, Type &Value); \
16411645 static bool mustQuote(StringRef) { return MustQuote; } \
16421646 }; \
None //===- CoverageMapping.cpp - Code coverage mapping support ------*- C++ -*-===//
0 //===- CoverageMapping.cpp - Code coverage mapping support ----------------===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
302302 /// An instantiation set is a collection of functions that have the same source
303303 /// code, ie, template functions specializations.
304304 class FunctionInstantiationSetCollector {
305 typedef DenseMap,
306 std::vector> MapT;
305 using MapT = DenseMap,
306 std::vector>;
307307 MapT InstantiatedFunctions;
308308
309309 public:
317317 }
318318
319319 MapT::iterator begin() { return InstantiatedFunctions.begin(); }
320
321320 MapT::iterator end() { return InstantiatedFunctions.end(); }
322321 };
323322
None //===- CoverageMappingReader.cpp - Code coverage mapping reader -*- C++ -*-===//
0 //===- CoverageMappingReader.cpp - Code coverage mapping reader -----------===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
6161 }
6262
6363 Error RawCoverageReader::readULEB128(uint64_t &Result) {
64 if (Data.size() < 1)
64 if (Data.empty())
6565 return make_error(coveragemap_error::truncated);
6666 unsigned N = 0;
6767 Result = decodeULEB128(reinterpret_cast(Data.data()), &N);
391391 // A class for reading coverage mapping function records for a module.
392392 template
393393 class VersionedCovMapFuncRecordReader : public CovMapFuncRecordReader {
394 typedef typename CovMapTraits<
395 Version, IntPtrT>::CovMapFuncRecordType FuncRecordType;
396 typedef typename CovMapTraits::NameRefType NameRefType;
394 using FuncRecordType =
395 typename CovMapTraits::CovMapFuncRecordType;
396 using NameRefType = typename CovMapTraits::NameRefType;
397397
398398 // Maps function's name references to the indexes of their records
399399 // in \c Records.
575575 Endian = support::endianness::little;
576576
577577 Data = Data.substr(StringRef(TestingFormatMagic).size());
578 if (Data.size() < 1)
578 if (Data.empty())
579579 return make_error(coveragemap_error::truncated);
580580 unsigned N = 0;
581581 auto ProfileNamesSize =
583583 if (N > Data.size())
584584 return make_error(coveragemap_error::malformed);
585585 Data = Data.substr(N);
586 if (Data.size() < 1)
586 if (Data.empty())
587587 return make_error(coveragemap_error::truncated);
588588 N = 0;
589589 uint64_t Address =
597597 return E;
598598 CoverageMapping = Data.substr(ProfileNamesSize);
599599 // Skip the padding bytes because coverage map data has an alignment of 8.
600 if (CoverageMapping.size() < 1)
600 if (CoverageMapping.empty())
601601 return make_error(coveragemap_error::truncated);
602602 size_t Pad = alignmentAdjustment(CoverageMapping.data(), 8);
603603 if (CoverageMapping.size() < Pad)
483483 return IndexedInstrProf::ComputeHash(HashType, K);
484484 }
485485
486 typedef InstrProfLookupTrait::data_type data_type;
487 typedef InstrProfLookupTrait::offset_type offset_type;
486 using data_type = InstrProfLookupTrait::data_type;
487 using offset_type = InstrProfLookupTrait::offset_type;
488488
489489 bool InstrProfLookupTrait::readValueProfilingData(
490490 const unsigned char *&D, const unsigned char *const End) {
621621 for (unsigned I = 0; I < SummarySize / sizeof(uint64_t); I++)
622622 Dst[I] = endian::byte_swap(Src[I]);
623623
624 llvm::SummaryEntryVector DetailedSummary;
624 SummaryEntryVector DetailedSummary;
625625 for (unsigned I = 0; I < SummaryData->NumCutoffEntries; I++) {
626626 const IndexedInstrProf::Summary::Entry &Ent = SummaryData->getEntry(I);
627627 DetailedSummary.emplace_back((uint32_t)Ent.Cutoff, Ent.MinBlockCount,
6868 write(P[K].D[I]);
6969 }
7070 } else {
71 raw_string_ostream &SOStream =
72 static_castraw_string_ostream &>(OS);
71 raw_string_ostream &SOStream = static_cast<raw_string_ostream &>(OS);
7372 std::string &Data = SOStream.str(); // with flush
7473 for (int K = 0; K < NItems; K++) {
7574 for (int I = 0; I < P[K].N; I++) {
9089
9190 class InstrProfRecordWriterTrait {
9291 public:
93 typedef StringRef key_type;
94 typedef StringRef key_type_ref;
95
96 typedef const InstrProfWriter::ProfilingData *const data_type;
97 typedef const InstrProfWriter::ProfilingData *const data_type_ref;
98
99 typedef uint64_t hash_value_type;
100 typedef uint64_t offset_type;
92 using key_type = StringRef;
93 using key_type_ref = StringRef;
94
95 using data_type = const InstrProfWriter::ProfilingData *const;
96 using data_type_ref = const InstrProfWriter::ProfilingData *const;
97
98 using hash_value_type = uint64_t;
99 using offset_type = uint64_t;
101100
102101 support::endianness ValueProfDataEndianness = support::little;
103102 InstrProfSummaryBuilder *SummaryBuilder;
None //===-- GraphWriter.cpp - Implements GraphWriter support routines ---------===//
0 //===- GraphWriter.cpp - Implements GraphWriter support routines ----------===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1111 //===----------------------------------------------------------------------===//
1212
1313 #include "llvm/Support/GraphWriter.h"
14 #include "llvm/ADT/SmallString.h"
15 #include "llvm/ADT/SmallVector.h"
16 #include "llvm/ADT/StringRef.h"
1417 #include "llvm/Config/config.h"
1518 #include "llvm/Support/CommandLine.h"
19 #include "llvm/Support/Compiler.h"
20 #include "llvm/Support/ErrorHandling.h"
21 #include "llvm/Support/ErrorOr.h"
1622 #include "llvm/Support/FileSystem.h"
1723 #include "llvm/Support/Program.h"
24 #include "llvm/Support/raw_ostream.h"
25 #include
26 #include
27 #include
28 #include
29
1830 using namespace llvm;
1931
2032 static cl::opt ViewBackground("view-background", cl::Hidden,
98110 }
99111
100112 namespace {
113
101114 struct GraphSession {
102115 std::string LogBuffer;
116
103117 bool TryFindProgram(StringRef Names, std::string &ProgramPath) {
104118 raw_string_ostream Log(LogBuffer);
105119 SmallVector parts;
114128 return false;
115129 }
116130 };
117 } // namespace
131
132 } // end anonymous namespace
118133
119134 static const char *getProgramName(GraphProgram::Name program) {
120135 switch (program) {
None //===--- YAMLParser.cpp - Simple YAML parser ------------------------------===//
0 //===- YAMLParser.cpp - Simple YAML parser --------------------------------===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1212
1313 #include "llvm/Support/YAMLParser.h"
1414 #include "llvm/ADT/AllocatorList.h"
15 #include "llvm/ADT/ArrayRef.h"
16 #include "llvm/ADT/None.h"
1517 #include "llvm/ADT/STLExtras.h"
1618 #include "llvm/ADT/SmallString.h"
1719 #include "llvm/ADT/SmallVector.h"
1820 #include "llvm/ADT/StringExtras.h"
21 #include "llvm/ADT/StringRef.h"
1922 #include "llvm/ADT/Twine.h"
23 #include "llvm/Support/Compiler.h"
2024 #include "llvm/Support/ErrorHandling.h"
2125 #include "llvm/Support/MemoryBuffer.h"
26 #include "llvm/Support/SMLoc.h"
2227 #include "llvm/Support/SourceMgr.h"
2328 #include "llvm/Support/raw_ostream.h"
29 #include
30 #include
31 #include
32 #include
33 #include
34 #include
35 #include
36 #include
37 #include
2438
2539 using namespace llvm;
2640 using namespace yaml;
3650
3751 /// EncodingInfo - Holds the encoding type and length of the byte order mark if
3852 /// it exists. Length is in {0, 2, 3, 4}.
39 typedef std::pair EncodingInfo;
53 using EncodingInfo = std::pair;
4054
4155 /// getUnicodeEncoding - Reads up to the first 4 bytes to determine the Unicode
4256 /// encoding form of \a Input.
4559 /// @returns An EncodingInfo indicating the Unicode encoding form of the input
4660 /// and how long the byte order mark is if one exists.
4761 static EncodingInfo getUnicodeEncoding(StringRef Input) {
48 if (Input.size() == 0)
62 if (Input.empty())
4963 return std::make_pair(UEF_Unknown, 0);
5064
5165 switch (uint8_t(Input[0])) {
94108 return std::make_pair(UEF_UTF8, 0);
95109 }
96110
97 namespace llvm {
98 namespace yaml {
99111 /// Pin the vtables to this file.
100112 void Node::anchor() {}
101113 void NullNode::anchor() {}
105117 void MappingNode::anchor() {}
106118 void SequenceNode::anchor() {}
107119 void AliasNode::anchor() {}
120
121 namespace llvm {
122 namespace yaml {
108123
109124 /// Token - A single YAML token.
110125 struct Token {
132147 TK_Alias,
133148 TK_Anchor,
134149 TK_Tag
135 } Kind;
150 } Kind = TK_Error;
136151
137152 /// A string of length 0 or more whose begin() points to the logical location
138153 /// of the token in the input.
141156 /// The value of a block scalar node.
142157 std::string Value;
143158
144 Token() : Kind(TK_Error) {}
159 Token() = default;
145160 };
146 }
147 }
148
149 typedef llvm::BumpPtrList TokenQueueT;
161
162 } // end namespace yaml
163 } // end namespace llvm
164
165 using TokenQueueT = BumpPtrList;
150166
151167 namespace {
168
152169 /// @brief This struct is used to track simple keys.
153170 ///
154171 /// Simple keys are handled by creating an entry in SimpleKeys for each Token
169186 return Tok == Other.Tok;
170187 }
171188 };
172 }
189
190 } // end anonymous namespace
173191
174192 /// @brief The Unicode scalar value of a UTF-8 minimal well-formed code unit
175193 /// subsequence and the subsequence's length in code units (uint8_t).
176194 /// A length of 0 represents an error.
177 typedef std::pair UTF8Decoded;
195 using UTF8Decoded = std::pair;
178196
179197 static UTF8Decoded decodeUTF8(StringRef Range) {
180198 StringRef::iterator Position= Range.begin();
228246
229247 namespace llvm {
230248 namespace yaml {
249
231250 /// @brief Scans YAML tokens from a MemoryBuffer.
232251 class Scanner {
233252 public:
349368 /// ns-char.
350369 StringRef::iterator skip_ns_char(StringRef::iterator Position);
351370
352 typedef StringRef::iterator (Scanner::*SkipWhileFunc)(StringRef::iterator);
371 using SkipWhileFunc = StringRef::iterator (Scanner::*)(StringRef::iterator);
372
353373 /// @brief Skip minimal well-formed code unit subsequences until Func
354374 /// returns its input.
355375 ///
654674 }
655675
656676 bool yaml::scanTokens(StringRef Input) {
657 llvm::SourceMgr SM;
658 llvm::yaml::Scanner scanner(Input, SM);
659 for (;;) {
660 llvm::yaml::Token T = scanner.getNext();
677 SourceMgr SM;
678 Scanner scanner(Input, SM);
679 while (true) {
680 Token T = scanner.getNext();
661681 if (T.Kind == Token::TK_StreamEnd)
662682 break;
663683 else if (T.Kind == Token::TK_Error)
17431763 std::error_code *EC)
17441764 : scanner(new Scanner(InputBuffer, SM, ShowColors, EC)), CurrentDoc() {}
17451765
1746 Stream::~Stream() {}
1766 Stream::~Stream() = default;
17471767
17481768 bool Stream::failed() { return scanner->failed(); }
17491769
18491869 bool Node::failed() const {
18501870 return Doc->failed();
18511871 }
1852
1853
18541872
18551873 StringRef ScalarNode::getValue(SmallVectorImpl &Storage) const {
18561874 // TODO: Handle newlines properly. We need to remove leading whitespace.
77 //===----------------------------------------------------------------------===//
88
99 #include "llvm/Support/YAMLTraits.h"
10 #include "llvm/ADT/STLExtras.h"
1011 #include "llvm/ADT/SmallString.h"
12 #include "llvm/ADT/StringRef.h"
1113 #include "llvm/ADT/Twine.h"
1214 #include "llvm/Support/Casting.h"
1315 #include "llvm/Support/Errc.h"
1416 #include "llvm/Support/ErrorHandling.h"
1517 #include "llvm/Support/Format.h"
1618 #include "llvm/Support/LineIterator.h"
19 #include "llvm/Support/MemoryBuffer.h"
1720 #include "llvm/Support/YAMLParser.h"
1821 #include "llvm/Support/raw_ostream.h"
19 #include <cctype>
22 #include <algorithm>
23 #include
24 #include
25 #include
2026 #include
27 #include
28 #include
29
2130 using namespace llvm;
2231 using namespace yaml;
2332
2534 // IO
2635 //===----------------------------------------------------------------------===//
2736
28 IO::IO(void *Context) : Ctxt(Context) {
29 }
30
31 IO::~IO() {
32 }
37 IO::IO(void *Context) : Ctxt(Context) {}
38
39 IO::~IO() = default;
3340
3441 void *IO::getContext() {
3542 return Ctxt;
4552
4653 Input::Input(StringRef InputContent, void *Ctxt,
4754 SourceMgr::DiagHandlerTy DiagHandler, void *DiagHandlerCtxt)
48 : IO(Ctxt), Strm(new Stream(InputContent, SrcMgr, false, &EC)),
49 CurrentNode(nullptr) {
55 : IO(Ctxt), Strm(new Stream(InputContent, SrcMgr, false, &EC)) {
5056 if (DiagHandler)
5157 SrcMgr.setDiagHandler(DiagHandler, DiagHandlerCtxt);
5258 DocIterator = Strm->begin();
5359 }
5460
55 Input::~Input() {
56 }
61 Input::~Input() = default;
5762
5863 std::error_code Input::error() { return EC; }
5964
397402 //===----------------------------------------------------------------------===//
398403
399404 Output::Output(raw_ostream &yout, void *context, int WrapColumn)
400 : IO(context), Out(yout), WrapColumn(WrapColumn), Column(0),
401 ColumnAtFlowStart(0), ColumnAtMapFlowStart(0), NeedBitValueComma(false),
402 NeedFlowSequenceComma(false), EnumerationMatchFound(false),
403 NeedsNewLine(false), WriteDefaultValues(false) {}
404
405 Output::~Output() {
406 }
405 : IO(context), Out(yout), WrapColumn(WrapColumn) {}
406
407 Output::~Output() = default;
407408
408409 bool Output::outputting() {
409410 return true;