diff options
| author | Eugene Zelenko <eugene.zelenko@gmail.com> | 2017-06-21 23:19:47 +0000 |
|---|---|---|
| committer | Eugene Zelenko <eugene.zelenko@gmail.com> | 2017-06-21 23:19:47 +0000 |
| commit | 72208a822615d458220858a6264a62e64635fcc9 (patch) | |
| tree | f344dd4d8344fc79ee51056aa303e32908225f10 /llvm/include | |
| parent | 88d9e37ec84c86942284d69f3794b824a99e5fab (diff) | |
| download | bcm5719-llvm-72208a822615d458220858a6264a62e64635fcc9.tar.gz bcm5719-llvm-72208a822615d458220858a6264a62e64635fcc9.zip | |
[ProfileData, Support] Fix some Clang-tidy modernize-use-using and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 305969
Diffstat (limited to 'llvm/include')
| -rw-r--r-- | llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h | 13 | ||||
| -rw-r--r-- | llvm/include/llvm/ProfileData/InstrProf.h | 16 | ||||
| -rw-r--r-- | llvm/include/llvm/ProfileData/InstrProfReader.h | 22 | ||||
| -rw-r--r-- | llvm/include/llvm/ProfileData/InstrProfWriter.h | 3 | ||||
| -rw-r--r-- | llvm/include/llvm/ProfileData/SampleProf.h | 13 | ||||
| -rw-r--r-- | llvm/include/llvm/ProfileData/SampleProfReader.h | 8 | ||||
| -rw-r--r-- | llvm/include/llvm/Support/GCOV.h | 18 | ||||
| -rw-r--r-- | llvm/include/llvm/Support/GraphWriter.h | 52 | ||||
| -rw-r--r-- | llvm/include/llvm/Support/TargetRegistry.h | 103 | ||||
| -rw-r--r-- | llvm/include/llvm/Support/YAMLParser.h | 97 | ||||
| -rw-r--r-- | llvm/include/llvm/Support/YAMLTraits.h | 182 |
11 files changed, 277 insertions, 250 deletions
diff --git a/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h b/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h index b2f73fda2ba..0ba792e8dc4 100644 --- a/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h +++ b/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h @@ -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)); diff --git a/llvm/include/llvm/ProfileData/InstrProf.h b/llvm/include/llvm/ProfileData/InstrProf.h index 23b7366f5ce..573ea90cfd0 100644 --- a/llvm/include/llvm/ProfileData/InstrProf.h +++ b/llvm/include/llvm/ProfileData/InstrProf.h @@ -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) { diff --git a/llvm/include/llvm/ProfileData/InstrProfReader.h b/llvm/include/llvm/ProfileData/InstrProfReader.h index 19d478e94cf..8163ca15920 100644 --- a/llvm/include/llvm/ProfileData/InstrProfReader.h +++ b/llvm/include/llvm/ProfileData/InstrProfReader.h @@ -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; diff --git a/llvm/include/llvm/ProfileData/InstrProfWriter.h b/llvm/include/llvm/ProfileData/InstrProfWriter.h index 4d818bad51a..fff10af3029 100644 --- a/llvm/include/llvm/ProfileData/InstrProfWriter.h +++ b/llvm/include/llvm/ProfileData/InstrProfWriter.h @@ -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: diff --git a/llvm/include/llvm/ProfileData/SampleProf.h b/llvm/include/llvm/ProfileData/SampleProf.h index 7a705ca5416..7fc258831be 100644 --- a/llvm/include/llvm/ProfileData/SampleProf.h +++ b/llvm/include/llvm/ProfileData/SampleProf.h @@ -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) diff --git a/llvm/include/llvm/ProfileData/SampleProfReader.h b/llvm/include/llvm/ProfileData/SampleProfReader.h index 29e3aba3e0e..9c1f357cbbd 100644 --- a/llvm/include/llvm/ProfileData/SampleProfReader.h +++ b/llvm/include/llvm/ProfileData/SampleProfReader.h @@ -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. diff --git a/llvm/include/llvm/Support/GCOV.h b/llvm/include/llvm/Support/GCOV.h index 268c53c5025..02016e7dbd6 100644 --- a/llvm/include/llvm/Support/GCOV.h +++ b/llvm/include/llvm/Support/GCOV.h @@ -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; diff --git a/llvm/include/llvm/Support/GraphWriter.h b/llvm/include/llvm/Support/GraphWriter.h index c318fea5365..3df5c867f7d 100644 --- a/llvm/include/llvm/Support/GraphWriter.h +++ b/llvm/include/llvm/Support/GraphWriter.h @@ -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 diff --git a/llvm/include/llvm/Support/TargetRegistry.h b/llvm/include/llvm/Support/TargetRegistry.h index 9e9a91b0abd..90d6c084ee9 100644 --- a/llvm/include/llvm/Support/TargetRegistry.h +++ b/llvm/include/llvm/Support/TargetRegistry.h @@ -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); diff --git a/llvm/include/llvm/Support/YAMLParser.h b/llvm/include/llvm/Support/YAMLParser.h index b9e3fa47752..c196dd6c1dd 100644 --- a/llvm/include/llvm/Support/YAMLParser.h +++ b/llvm/include/llvm/Support/YAMLParser.h @@ -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 diff --git a/llvm/include/llvm/Support/YAMLTraits.h b/llvm/include/llvm/Support/YAMLTraits.h index 8949d69ce72..53618a56f85 100644 --- a/llvm/include/llvm/Support/YAMLTraits.h +++ b/llvm/include/llvm/Support/YAMLTraits.h @@ -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; } \ }; \ |

