Index: include/llvm/IR/DebugInfoMetadata.h =================================================================== --- include/llvm/IR/DebugInfoMetadata.h +++ include/llvm/IR/DebugInfoMetadata.h @@ -14,9 +14,21 @@ #ifndef LLVM_IR_DEBUGINFOMETADATA_H #define LLVM_IR_DEBUGINFOMETADATA_H +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/BitmaskEnum.h" +#include "llvm/ADT/None.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringRef.h" #include "llvm/IR/Metadata.h" +#include "llvm/Support/Casting.h" #include "llvm/Support/Dwarf.h" +#include +#include +#include +#include +#include +#include +#include // Helper macros for defining get() overrides. #define DEFINE_MDNODE_GET_UNPACK_IMPL(...) __VA_ARGS__ @@ -109,16 +121,20 @@ public: iterator() = default; explicit iterator(MDNode::op_iterator I) : I(I) {} + DITypeRef operator*() const { return DITypeRef(*I); } + iterator &operator++() { ++I; return *this; } + iterator operator++(int) { iterator Temp(*this); ++I; return Temp; } + bool operator==(const iterator &X) const { return I == X.I; } bool operator!=(const iterator &X) const { return I != X.I; } }; @@ -985,6 +1001,7 @@ class DICompileUnit : public DIScope { friend class LLVMContextImpl; friend class MDNode; + public: enum DebugEmissionKind : unsigned { NoDebug = 0, @@ -992,6 +1009,7 @@ LineTablesOnly, LastEmissionKind = LineTablesOnly }; + static Optional getEmissionKind(StringRef Str); static const char *EmissionKindString(DebugEmissionKind EK); @@ -1050,10 +1068,10 @@ getMacros(), DWOId, getSplitDebugInlining()); } +public: static void get() = delete; static void getIfExists() = delete; -public: DEFINE_MDNODE_GET_DISTINCT_TEMPORARY( DICompileUnit, (unsigned SourceLanguage, DIFile *File, StringRef Producer, @@ -1210,10 +1228,10 @@ getRawInlinedAt()); } +public: // Disallow replacing operands. void replaceOperandWith(unsigned I, Metadata *New) = delete; -public: DEFINE_MDNODE_GET(DILocation, (unsigned Line, unsigned Column, Metadata *Scope, Metadata *InlinedAt = nullptr), @@ -1694,7 +1712,7 @@ DIModule(LLVMContext &Context, StorageType Storage, ArrayRef Ops) : DIScope(Context, DIModuleKind, Storage, dwarf::DW_TAG_module, Ops) {} - ~DIModule() {} + ~DIModule() = default; static DIModule *getImpl(LLVMContext &Context, DIScope *Scope, StringRef Name, StringRef ConfigurationMacros, @@ -2519,4 +2537,4 @@ #undef DEFINE_MDNODE_GET_UNPACK #undef DEFINE_MDNODE_GET -#endif +#endif // LLVM_IR_DEBUGINFOMETADATA_H Index: include/llvm/Support/CommandLine.h =================================================================== --- include/llvm/Support/CommandLine.h +++ include/llvm/Support/CommandLine.h @@ -21,17 +21,20 @@ #define LLVM_SUPPORT_COMMANDLINE_H #include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/iterator_range.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringMap.h" +#include "llvm/ADT/StringRef.h" #include "llvm/ADT/Twine.h" -#include "llvm/Support/Compiler.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ManagedStatic.h" #include -#include -#include -#include +#include +#include +#include +#include #include namespace llvm { @@ -159,6 +162,7 @@ private: StringRef const Name; StringRef const Description; + void registerCategory(); public: @@ -167,6 +171,7 @@ : Name(Name), Description(Description) { registerCategory(); } + StringRef getName() const { return Name; } StringRef getDescription() const { return Description; } }; @@ -191,7 +196,7 @@ : Name(Name), Description(Description) { registerSubCommand(); } - SubCommand() {} + SubCommand() = default; void reset(); @@ -216,7 +221,6 @@ //===----------------------------------------------------------------------===// // Option Base class // -class alias; class Option { friend class alias; @@ -258,15 +262,19 @@ inline enum NumOccurrencesFlag getNumOccurrencesFlag() const { return (enum NumOccurrencesFlag)Occurrences; } + inline enum ValueExpected getValueExpectedFlag() const { return Value ? ((enum ValueExpected)Value) : getValueExpectedFlagDefault(); } + inline enum OptionHidden getOptionHiddenFlag() const { return (enum OptionHidden)HiddenFlag; } + inline enum FormattingFlags getFormattingFlag() const { return (enum FormattingFlags)Formatting; } + inline unsigned getMiscFlags() const { return Misc; } inline unsigned getPosition() const { return Position; } inline unsigned getNumAdditionalVals() const { return AdditionalVals; } @@ -275,9 +283,11 @@ bool hasArgStr() const { return !ArgStr.empty(); } bool isPositional() const { return getFormattingFlag() == cl::Positional; } bool isSink() const { return getMiscFlags() & cl::Sink; } + bool isConsumeAfter() const { return getNumOccurrencesFlag() == cl::ConsumeAfter; } + bool isInAllSubCommands() const { return any_of(Subs, [](const SubCommand *SC) { return SC == &*AllSubCommands; @@ -310,6 +320,8 @@ inline void setNumAdditionalVals(unsigned n) { AdditionalVals = n; } public: + virtual ~Option() = default; + // addArgument - Register this argument with the commandline system. // void addArgument(); @@ -340,10 +352,8 @@ // Prints option name followed by message. Always returns true. bool error(const Twine &Message, StringRef ArgName = StringRef()); -public: inline int getNumOccurrences() const { return NumOccurrences; } inline void reset() { NumOccurrences = 0; } - virtual ~Option() {} }; //===----------------------------------------------------------------------===// @@ -354,7 +364,9 @@ // desc - Modifier to set the description shown in the -help output... struct desc { StringRef Desc; + desc(StringRef Str) : Desc(Str) {} + void apply(Option &O) const { O.setDescription(Desc); } }; @@ -362,7 +374,9 @@ // output... struct value_desc { StringRef Desc; + value_desc(StringRef Str) : Desc(Str) {} + void apply(Option &O) const { O.setValueStr(Desc); } }; @@ -387,6 +401,7 @@ // template struct LocationClass { Ty &Loc; + LocationClass(Ty &L) : Loc(L) {} template void apply(Opt &O) const { O.setLocation(O, Loc); } @@ -400,6 +415,7 @@ // to. struct cat { OptionCategory &Category; + cat(OptionCategory &c) : Category(c) {} template void apply(Opt &O) const { O.setCategory(Category); } @@ -408,6 +424,7 @@ // sub - Specify the subcommand that this option belongs to. struct sub { SubCommand ⋐ + sub(SubCommand &S) : Sub(S) {} template void apply(Opt &O) const { O.addSubCommand(Sub); } @@ -421,9 +438,9 @@ virtual bool compare(const GenericOptionValue &V) const = 0; protected: - ~GenericOptionValue() = default; GenericOptionValue() = default; GenericOptionValue(const GenericOptionValue&) = default; + ~GenericOptionValue() = default; GenericOptionValue &operator=(const GenericOptionValue &) = default; private: @@ -459,15 +476,15 @@ // Simple copy of the option value. template class OptionValueCopy : public GenericOptionValue { DataType Value; - bool Valid; + bool Valid = false; protected: - ~OptionValueCopy() = default; OptionValueCopy(const OptionValueCopy&) = default; + ~OptionValueCopy() = default; OptionValueCopy &operator=(const OptionValueCopy&) = default; public: - OptionValueCopy() : Valid(false) {} + OptionValueCopy() = default; bool hasValue() const { return Valid; } @@ -498,9 +515,9 @@ typedef DataType WrapperType; protected: - ~OptionValueBase() = default; OptionValueBase() = default; OptionValueBase(const OptionValueBase&) = default; + ~OptionValueBase() = default; OptionValueBase &operator=(const OptionValueBase&) = default; }; @@ -511,6 +528,7 @@ OptionValue() = default; OptionValue(const DataType &V) { this->setValue(V); } + // Some options may take their value from a different data type. template OptionValue &operator=(const DT &V) { this->setValue(V); @@ -525,9 +543,10 @@ : OptionValueCopy { typedef cl::boolOrDefault WrapperType; - OptionValue() {} + OptionValue() = default; OptionValue(const cl::boolOrDefault &V) { this->setValue(V); } + OptionValue &operator=(const cl::boolOrDefault &V) { setValue(V); return *this; @@ -541,9 +560,10 @@ struct OptionValue final : OptionValueCopy { typedef StringRef WrapperType; - OptionValue() {} + OptionValue() = default; OptionValue(const std::string &V) { this->setValue(V); } + OptionValue &operator=(const std::string &V) { setValue(V); return *this; @@ -620,7 +640,8 @@ public: generic_parser_base(Option &O) : Owner(O) {} - virtual ~generic_parser_base() {} // Base class should have virtual-dtor + virtual ~generic_parser_base() = default; + // Base class should have virtual-destructor // getNumOptions - Virtual function implemented by generic subclass to // indicate how many entries are in Values. @@ -771,7 +792,6 @@ public: basic_parser_impl(Option &) {} - enum ValueExpected getValueExpectedFlagDefault() const { return ValueRequired; } @@ -800,6 +820,7 @@ protected: ~basic_parser_impl() = default; + // A helper for basic_parser::printOptionDiff. void printOptionName(const Option &O, size_t GlobalWidth) const; }; @@ -810,12 +831,13 @@ template class basic_parser : public basic_parser_impl { public: basic_parser(Option &O) : basic_parser_impl(O) {} + typedef DataType parser_data_type; typedef OptionValue OptVal; protected: // Workaround Clang PR22793 - ~basic_parser() {} + ~basic_parser() = default; }; //-------------------------------------------------- @@ -1112,15 +1134,19 @@ O.setNumOccurrencesFlag(N); } }; + template <> struct applicator { static void opt(ValueExpected VE, Option &O) { O.setValueExpectedFlag(VE); } }; + template <> struct applicator { static void opt(OptionHidden OH, Option &O) { O.setHiddenFlag(OH); } }; + template <> struct applicator { static void opt(FormattingFlags FF, Option &O) { O.setFormattingFlag(FF); } }; + template <> struct applicator { static void opt(MiscFlags MF, Option &O) { O.setMiscFlag(MF); } }; @@ -1145,7 +1171,7 @@ // template class opt_storage { - DataType *Location; // Where to store the object... + DataType *Location = nullptr; // Where to store the object... OptionValue Default; void check_location() const { @@ -1155,7 +1181,7 @@ } public: - opt_storage() : Location(nullptr) {} + opt_storage() = default; bool setLocation(Option &O, DataType &L) { if (Location) @@ -1284,11 +1310,11 @@ Parser.initialize(); } +public: // Command line options should not be copyable opt(const opt &) = delete; opt &operator=(const opt &) = delete; -public: // setInitialValue - Used by the cl::init modifier... void setInitialValue(const DataType &V) { this->setValue(V, true); } @@ -1321,10 +1347,10 @@ // cl::location(x) modifier. // template class list_storage { - StorageClass *Location; // Where to store the object... + StorageClass *Location = nullptr; // Where to store the object... public: - list_storage() : Location(0) {} + list_storage() = default; bool setLocation(Option &O, StorageClass &L) { if (Location) @@ -1454,11 +1480,11 @@ Parser.initialize(); } +public: // Command line options should not be copyable list(const list &) = delete; list &operator=(const list &) = delete; -public: ParserClass &getParser() { return Parser; } unsigned getPosition(unsigned optnum) const { @@ -1495,7 +1521,7 @@ // cl::location(x) modifier. // template class bits_storage { - unsigned *Location; // Where to store the bits... + unsigned *Location = nullptr; // Where to store the bits... template static unsigned Bit(const T &V) { unsigned BitPos = reinterpret_cast(V); @@ -1505,7 +1531,7 @@ } public: - bits_storage() : Location(nullptr) {} + bits_storage() = default; bool setLocation(Option &O, unsigned &L) { if (Location) @@ -1593,11 +1619,11 @@ Parser.initialize(); } +public: // Command line options should not be copyable bits(const bits &) = delete; bits &operator=(const bits &) = delete; -public: ParserClass &getParser() { return Parser; } unsigned getPosition(unsigned optnum) const { @@ -1619,14 +1645,17 @@ class alias : public Option { Option *AliasFor; + bool handleOccurrence(unsigned pos, StringRef /*ArgName*/, StringRef Arg) override { return AliasFor->handleOccurrence(pos, AliasFor->ArgStr, Arg); } + bool addOccurrence(unsigned pos, StringRef /*ArgName*/, StringRef Value, bool MultiArg = false) override { return AliasFor->addOccurrence(pos, AliasFor->ArgStr, Value, MultiArg); } + // Handle printing stuff... size_t getOptionWidth() const override; void printOptionInfo(size_t GlobalWidth) const override; @@ -1648,11 +1677,11 @@ addArgument(); } +public: // Command line options should not be copyable alias(const alias &) = delete; alias &operator=(const alias &) = delete; -public: void setAliasFor(Option &O) { if (AliasFor) error("cl::alias must only have one cl::aliasopt(...) specified!"); @@ -1670,7 +1699,9 @@ // aliasfor - Modifier to set the option an alias aliases. struct aliasopt { Option &Opt; + explicit aliasopt(Option &O) : Opt(O) {} + void apply(alias &A) const { A.setAliasFor(Opt); } }; @@ -1680,6 +1711,7 @@ // exit is called. struct extrahelp { StringRef morehelp; + explicit extrahelp(StringRef help); }; @@ -1841,8 +1873,7 @@ /// where no options are supported. void ResetCommandLineParser(); -} // End namespace cl - -} // End namespace llvm +} // end namespace cl +} // end namespace llvm -#endif +#endif // LLVM_SUPPORT_COMMANDLINE_H Index: include/llvm/Support/Error.h =================================================================== --- include/llvm/Support/Error.h +++ include/llvm/Support/Error.h @@ -14,26 +14,35 @@ #ifndef LLVM_SUPPORT_ERROR_H #define LLVM_SUPPORT_ERROR_H -#include "llvm/ADT/PointerIntPair.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/Twine.h" +#include "llvm/Support/AlignOf.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorOr.h" #include "llvm/Support/raw_ostream.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include namespace llvm { -class Error; -class ErrorList; class ErrorSuccess; /// Base class for error info classes. Do not extend this directly: Extend /// the ErrorInfo template subclass instead. class ErrorInfoBase { public: - virtual ~ErrorInfoBase() {} + virtual ~ErrorInfoBase() = default; /// Print an error message to an output stream. virtual void log(raw_ostream &OS) const = 0; @@ -68,6 +77,7 @@ private: virtual void anchor(); + static char ID; }; @@ -137,7 +147,6 @@ /// they're moved-assigned or constructed from Success values that have already /// been checked. This enforces checking through all levels of the call stack. class LLVM_NODISCARD Error { - // ErrorList needs to be able to yank ErrorInfoBase pointers out of this // class to add to the error list. friend class ErrorList; @@ -314,7 +323,6 @@ /// Special ErrorInfo subclass representing a list of ErrorInfos. /// Instances of this class are constructed by joinError. class ErrorList final : public ErrorInfo { - // handleErrors needs to be able to iterate the payload list of an // ErrorList. template @@ -600,6 +608,7 @@ if (Err) (void)!!*Err; } + ~ErrorAsOutParameter() { // Clear the checked bit. if (Err && !*Err) @@ -646,7 +655,6 @@ // consumed by a Debug build application. Unchecked(false) #endif - { assert(Err && "Cannot create Expected from Error success value."); new (getErrorStorage()) error_type(Err.takePayload()); @@ -860,6 +868,7 @@ /// std::error_codes. class ECError : public ErrorInfo { friend Error errorCodeToError(std::error_code); + public: void setErrorCode(std::error_code EC) { this->EC = EC; } std::error_code convertToErrorCode() const override { return EC; } @@ -871,6 +880,7 @@ protected: ECError() = default; ECError(std::error_code EC) : EC(EC) {} + std::error_code EC; }; @@ -913,9 +923,12 @@ class StringError : public ErrorInfo { public: static char ID; + StringError(const Twine &S, std::error_code EC); + void log(raw_ostream &OS) const override; std::error_code convertToErrorCode() const override; + private: std::string Msg; std::error_code EC; @@ -975,6 +988,6 @@ LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag = true); -} // namespace llvm +} // end namespace llvm #endif // LLVM_SUPPORT_ERROR_H Index: include/llvm/Support/FileSystem.h =================================================================== --- include/llvm/Support/FileSystem.h +++ include/llvm/Support/FileSystem.h @@ -32,7 +32,6 @@ #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Twine.h" #include "llvm/Support/Chrono.h" -#include "llvm/Support/DataTypes.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorOr.h" #include @@ -125,6 +124,7 @@ public: UniqueID() = default; UniqueID(uint64_t Device, uint64_t File) : Device(Device), File(File) {} + bool operator==(const UniqueID &Other) const { return Device == Other.Device && File == Other.File; } @@ -132,6 +132,7 @@ bool operator<(const UniqueID &Other) const { return std::tie(Device, File) < std::tie(Other.Device, Other.File); } + uint64_t getDevice() const { return Device; } uint64_t getFile() const { return File; } }; @@ -673,10 +674,6 @@ /// This class represents a memory mapped file. It is based on /// boost::iostreams::mapped_file. class mapped_file_region { - mapped_file_region() = delete; - mapped_file_region(mapped_file_region&) = delete; - mapped_file_region &operator =(mapped_file_region&) = delete; - public: enum mapmode { readonly, ///< May only access map via const_data as read only. @@ -692,6 +689,10 @@ std::error_code init(int FD, uint64_t Offset, mapmode Mode); public: + mapped_file_region() = delete; + mapped_file_region(mapped_file_region&) = delete; + mapped_file_region &operator =(mapped_file_region&) = delete; + /// \param fd An open file descriptor to map. mapped_file_region takes /// ownership if closefd is true. It must have been opended in the correct /// mode. @@ -732,7 +733,7 @@ : Path(path.str()) , Status(st) {} - directory_entry() {} + directory_entry() = default; void assign(const Twine &path, file_status st = file_status()) { Path = path.str(); @@ -830,7 +831,7 @@ : Level(0) , HasNoPushRequest(false) {} - std::stack > Stack; + std::stack> Stack; uint16_t Level; bool HasNoPushRequest; }; @@ -842,13 +843,14 @@ IntrusiveRefCntPtr State; public: - recursive_directory_iterator() {} + recursive_directory_iterator() = default; explicit recursive_directory_iterator(const Twine &path, std::error_code &ec) : State(new detail::RecDirIterState) { State->Stack.push(directory_iterator(path, ec)); if (State->Stack.top() == directory_iterator()) State.reset(); } + // No operator++ because we need error_code. recursive_directory_iterator &increment(std::error_code &ec) { const directory_iterator end_itr; Index: include/llvm/Support/MemoryBuffer.h =================================================================== --- include/llvm/Support/MemoryBuffer.h +++ include/llvm/Support/MemoryBuffer.h @@ -14,13 +14,17 @@ #ifndef LLVM_SUPPORT_MEMORYBUFFER_H #define LLVM_SUPPORT_MEMORYBUFFER_H +#include "llvm/ADT/StringRef.h" #include "llvm/ADT/Twine.h" #include "llvm/Support/CBindingWrapping.h" -#include "llvm/Support/DataTypes.h" #include "llvm/Support/ErrorOr.h" +#include "llvm-c/Types.h" #include +#include +#include namespace llvm { + class MemoryBufferRef; /// This interface provides simple read-only access to a block of memory, and @@ -37,14 +41,16 @@ const char *BufferStart; // Start of the buffer. const char *BufferEnd; // End of the buffer. - MemoryBuffer(const MemoryBuffer &) = delete; - MemoryBuffer &operator=(const MemoryBuffer &) = delete; + protected: - MemoryBuffer() {} + MemoryBuffer() = default; + void init(const char *BufStart, const char *BufEnd, bool RequiresNullTerminator); public: + MemoryBuffer(const MemoryBuffer &) = delete; virtual ~MemoryBuffer(); + MemoryBuffer &operator=(const MemoryBuffer &) = delete; const char *getBufferStart() const { return BufferStart; } const char *getBufferEnd() const { return BufferEnd; } @@ -154,7 +160,7 @@ StringRef Identifier; public: - MemoryBufferRef() {} + MemoryBufferRef() = default; MemoryBufferRef(MemoryBuffer& Buffer) : Buffer(Buffer.getBuffer()), Identifier(Buffer.getBufferIdentifier()) {} MemoryBufferRef(StringRef Buffer, StringRef Identifier) @@ -174,4 +180,4 @@ } // end namespace llvm -#endif +#endif // LLVM_SUPPORT_MEMORYBUFFER_H Index: include/llvm/Support/YAMLTraits.h =================================================================== --- include/llvm/Support/YAMLTraits.h +++ include/llvm/Support/YAMLTraits.h @@ -15,15 +15,24 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" -#include "llvm/ADT/StringSwitch.h" #include "llvm/ADT/Twine.h" -#include "llvm/Support/Compiler.h" +#include "llvm/Support/AlignOf.h" +#include "llvm/Support/Allocator.h" #include "llvm/Support/Endian.h" #include "llvm/Support/Regex.h" #include "llvm/Support/SourceMgr.h" #include "llvm/Support/YAMLParser.h" #include "llvm/Support/raw_ostream.h" +#include +#include +#include +#include +#include +#include +#include #include +#include +#include namespace llvm { namespace yaml { @@ -139,7 +148,6 @@ //static bool mustQuote(StringRef); }; - /// This class should be specialized by type that requires custom conversion /// to/from a YAML literal block scalar. For example: /// @@ -172,7 +180,7 @@ /// to/from a YAML sequence. For example: /// /// template<> -/// struct SequenceTraits< std::vector > { +/// struct SequenceTraits< std::vector> { /// static size_t size(IO &io, std::vector &seq) { /// return seq.size(); /// } @@ -220,7 +228,7 @@ public: static bool const value = - (sizeof(test >(nullptr)) == 1); + (sizeof(test>(nullptr)) == 1); }; // Test if ScalarBitSetTraits is defined on type T. @@ -236,7 +244,7 @@ static double test(...); public: - static bool const value = (sizeof(test >(nullptr)) == 1); + static bool const value = (sizeof(test>(nullptr)) == 1); }; // Test if ScalarTraits is defined on type T. @@ -348,7 +356,7 @@ static double test(...); public: - static bool const value = (sizeof(test >(nullptr)) == 1); + static bool const value = (sizeof(test>(nullptr)) == 1); }; // has_FlowTraits will cause an error with some compilers because @@ -398,7 +406,7 @@ static double test(...); public: - static bool const value = (sizeof(test >(nullptr))==1); + static bool const value = (sizeof(test>(nullptr))==1); }; inline bool isNumber(StringRef S) { @@ -503,7 +511,6 @@ // Base class for Input and Output. class IO { public: - IO(void *Ctxt=nullptr); virtual ~IO(); @@ -701,6 +708,7 @@ }; namespace detail { + template void doMapping(IO &io, T &Val, Context &Ctx) { MappingContextTraits::mapping(io, Val, Ctx); @@ -709,7 +717,8 @@ template void doMapping(IO &io, T &Val, EmptyContext &Ctx) { MappingTraits::mapping(io, Val); } -} + +} // end namespace detail template typename std::enable_if::value, void>::type @@ -950,6 +959,7 @@ llvm::raw_ostream &Stream) { ScalarTraits::output(static_cast(E), Ctx, Stream); } + static StringRef input(StringRef Str, void *Ctx, endian_type &E) { value_type V; auto R = ScalarTraits::input(Str, Ctx, V); @@ -1089,9 +1099,11 @@ class HNode { virtual void anchor(); + public: HNode(Node *n) : _node(n) { } - virtual ~HNode() { } + virtual ~HNode() = default; + static inline bool classof(const HNode *) { return true; } Node *_node; @@ -1099,16 +1111,20 @@ class EmptyHNode : public HNode { void anchor() override; + public: EmptyHNode(Node *n) : HNode(n) { } + static inline bool classof(const HNode *n) { return NullNode::classof(n->_node); } + static inline bool classof(const EmptyHNode *) { return true; } }; class ScalarHNode : public HNode { void anchor() override; + public: ScalarHNode(Node *n, StringRef s) : HNode(n), _value(s) { } @@ -1118,7 +1134,9 @@ return ScalarNode::classof(n->_node) || BlockScalarNode::classof(n->_node); } + static inline bool classof(const ScalarHNode *) { return true; } + protected: StringRef _value; }; @@ -1132,6 +1150,7 @@ static inline bool classof(const HNode *n) { return MappingNode::classof(n->_node); } + static inline bool classof(const MapHNode *) { return true; } typedef llvm::StringMap> NameToNode; @@ -1151,6 +1170,7 @@ static inline bool classof(const HNode *n) { return SequenceNode::classof(n->_node); } + static inline bool classof(const SequenceHNode *) { return true; } std::vector> Entries; @@ -1217,7 +1237,7 @@ void blockScalarString(StringRef &) override; void setError(const Twine &message) override; bool canElideEmptySequence() override; -public: + // These are only used by operator<<. They could be private // if that templated operator could be made a friend. void beginDocuments(); @@ -1264,10 +1284,10 @@ /// Based on BOOST_STRONG_TYPEDEF #define LLVM_YAML_STRONG_TYPEDEF(_base, _type) \ struct _type { \ - _type() { } \ - _type(const _base v) : value(v) { } \ + _type() = default; \ + _type(const _base v) : value(v) {} \ _type(const _type &v) : value(v.value) {} \ - _type &operator=(const _type &rhs) { value = rhs.value; return *this; }\ + _type &operator=(const _type &rhs) = default; \ _type &operator=(const _base &rhs) { value = rhs; return *this; } \ operator const _base & () const { return value; } \ bool operator==(const _type &rhs) const { return value == rhs.value; } \ @@ -1457,8 +1477,8 @@ } }; -} // namespace yaml -} // namespace llvm +} // end namespace yaml +} // end namespace llvm /// Utility for declaring that a std::vector of a particular type /// should be considered a YAML sequence.