[ADT, Support, TableGen] Fix some Clang-tidy modernize-use-default and Include What You Use warnings; other minor fixes (NFC).

llvm-svn: 288424
This commit is contained in:
Eugene Zelenko 2016-12-01 22:13:24 +00:00
parent 4aa8175a92
commit f65e4ce2c4
12 changed files with 319 additions and 162 deletions

View File

@ -15,12 +15,13 @@
#ifndef LLVM_ADT_SPARSEBITVECTOR_H
#define LLVM_ADT_SPARSEBITVECTOR_H
#include "llvm/Support/DataTypes.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include <cassert>
#include <climits>
#include <cstring>
#include <iterator>
#include <list>
namespace llvm {
@ -52,6 +53,7 @@ private:
// Index of Element in terms of where first bit starts.
unsigned ElementIndex;
BitWord Bits[BITWORDS_PER_ELEMENT];
SparseBitVectorElement() {
ElementIndex = ~0U;
memset(&Bits[0], 0, sizeof (BitWord) * BITWORDS_PER_ELEMENT);
@ -79,7 +81,7 @@ public:
// Return the bits that make up word Idx in our element.
BitWord word(unsigned Idx) const {
assert (Idx < BITWORDS_PER_ELEMENT);
assert(Idx < BITWORDS_PER_ELEMENT);
return Bits[Idx];
}
@ -139,8 +141,8 @@ public:
unsigned WordPos = Curr / BITWORD_SIZE;
unsigned BitPos = Curr % BITWORD_SIZE;
BitWord Copy = Bits[WordPos];
assert (WordPos <= BITWORDS_PER_ELEMENT
&& "Word Position outside of element");
assert(WordPos <= BITWORDS_PER_ELEMENT
&& "Word Position outside of element");
// Mask off previous bits.
Copy &= ~0UL << BitPos;
@ -289,7 +291,7 @@ class SparseBitVector {
private:
bool AtEnd;
const SparseBitVector<ElementSize> *BitVector;
const SparseBitVector<ElementSize> *BitVector = nullptr;
// Current element inside of bitmap.
ElementListConstIter Iter;
@ -359,7 +361,20 @@ class SparseBitVector {
}
}
}
public:
SparseBitVectorIterator() = default;
SparseBitVectorIterator(const SparseBitVector<ElementSize> *RHS,
bool end = false):BitVector(RHS) {
Iter = BitVector->Elements.begin();
BitNumber = 0;
Bits = 0;
WordNumber = ~0;
AtEnd = end;
AdvanceToFirstNonZero();
}
// Preincrement.
inline SparseBitVectorIterator& operator++() {
++BitNumber;
@ -392,29 +407,16 @@ class SparseBitVector {
bool operator!=(const SparseBitVectorIterator &RHS) const {
return !(*this == RHS);
}
SparseBitVectorIterator(): BitVector(nullptr) {
}
SparseBitVectorIterator(const SparseBitVector<ElementSize> *RHS,
bool end = false):BitVector(RHS) {
Iter = BitVector->Elements.begin();
BitNumber = 0;
Bits = 0;
WordNumber = ~0;
AtEnd = end;
AdvanceToFirstNonZero();
}
};
public:
typedef SparseBitVectorIterator iterator;
SparseBitVector () {
CurrElementIter = Elements.begin ();
SparseBitVector() {
CurrElementIter = Elements.begin();
}
~SparseBitVector() {
}
~SparseBitVector() = default;
// SparseBitVector copy ctor.
SparseBitVector(const SparseBitVector &RHS) {
@ -511,7 +513,7 @@ public:
ElementIter->set(Idx % ElementSize);
}
bool test_and_set (unsigned Idx) {
bool test_and_set(unsigned Idx) {
bool old = test(Idx);
if (!old) {
set(Idx);
@ -780,6 +782,7 @@ public:
return BitCount;
}
iterator begin() const {
return iterator(this);
}
@ -860,6 +863,7 @@ void dump(const SparseBitVector<ElementSize> &LHS, raw_ostream &out) {
}
out << "]\n";
}
} // end namespace llvm
#endif // LLVM_ADT_SPARSEBITVECTOR_H

View File

@ -11,8 +11,13 @@
#define LLVM_ADT_TINYPTRVECTOR_H
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/None.h"
#include "llvm/ADT/PointerUnion.h"
#include "llvm/ADT/SmallVector.h"
#include <cassert>
#include <cstddef>
#include <iterator>
#include <type_traits>
namespace llvm {
@ -25,15 +30,16 @@ namespace llvm {
template <typename EltTy>
class TinyPtrVector {
public:
typedef llvm::SmallVector<EltTy, 4> VecTy;
typedef SmallVector<EltTy, 4> VecTy;
typedef typename VecTy::value_type value_type;
typedef llvm::PointerUnion<EltTy, VecTy *> PtrUnion;
typedef PointerUnion<EltTy, VecTy *> PtrUnion;
private:
PtrUnion Val;
public:
TinyPtrVector() {}
TinyPtrVector() = default;
~TinyPtrVector() {
if (VecTy *V = Val.template dyn_cast<VecTy*>())
delete V;
@ -43,6 +49,7 @@ public:
if (VecTy *V = Val.template dyn_cast<VecTy*>())
Val = new VecTy(*V);
}
TinyPtrVector &operator=(const TinyPtrVector &RHS) {
if (this == &RHS)
return *this;
@ -74,6 +81,7 @@ public:
TinyPtrVector(TinyPtrVector &&RHS) : Val(RHS.Val) {
RHS.Val = (EltTy)nullptr;
}
TinyPtrVector &operator=(TinyPtrVector &&RHS) {
if (this == &RHS)
return *this;
@ -170,6 +178,7 @@ public:
return Val.template get<VecTy *>()->begin();
}
iterator end() {
if (Val.template is<EltTy>())
return begin() + (Val.isNull() ? 0 : 1);
@ -187,9 +196,11 @@ public:
reverse_iterator rbegin() { return reverse_iterator(end()); }
reverse_iterator rend() { return reverse_iterator(begin()); }
const_reverse_iterator rbegin() const {
return const_reverse_iterator(end());
}
const_reverse_iterator rend() const {
return const_reverse_iterator(begin());
}
@ -329,6 +340,7 @@ public:
return Val.template get<VecTy*>()->insert(begin() + Offset, From, To);
}
};
} // end namespace llvm
#endif
#endif // LLVM_ADT_TINYPTRVECTOR_H

View File

@ -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 <cassert>
#include <climits>
#include <cstdarg>
#include <utility>
#include <cstddef>
#include <initializer_list>
#include <string>
#include <type_traits>
#include <vector>
namespace llvm {
@ -159,6 +162,7 @@ class OptionCategory {
private:
StringRef const Name;
StringRef const Description;
void registerCategory();
public:
@ -167,6 +171,7 @@ public:
: Name(Name), Description(Description) {
registerCategory();
}
StringRef getName() const { return Name; }
StringRef getDescription() const { return Description; }
};
@ -191,7 +196,7 @@ public:
: Name(Name), Description(Description) {
registerSubCommand();
}
SubCommand() {}
SubCommand() = default;
void reset();
@ -216,7 +221,6 @@ extern ManagedStatic<SubCommand> AllSubCommands;
//===----------------------------------------------------------------------===//
// Option Base class
//
class alias;
class Option {
friend class alias;
@ -258,15 +262,19 @@ public:
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 @@ public:
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 @@ protected:
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 @@ public:
// 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 @@ public:
// 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 @@ struct desc {
// 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 <class Ty> initializer<Ty> init(const Ty &Val) {
//
template <class Ty> struct LocationClass {
Ty &Loc;
LocationClass(Ty &L) : Loc(L) {}
template <class Opt> void apply(Opt &O) const { O.setLocation(O, Loc); }
@ -400,6 +415,7 @@ template <class Ty> LocationClass<Ty> location(Ty &L) {
// to.
struct cat {
OptionCategory &Category;
cat(OptionCategory &c) : Category(c) {}
template <class Opt> void apply(Opt &O) const { O.setCategory(Category); }
@ -408,6 +424,7 @@ struct cat {
// sub - Specify the subcommand that this option belongs to.
struct sub {
SubCommand &Sub;
sub(SubCommand &S) : Sub(S) {}
template <class Opt> void apply(Opt &O) const { O.addSubCommand(Sub); }
@ -421,9 +438,9 @@ struct GenericOptionValue {
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 @@ protected:
// Simple copy of the option value.
template <class DataType> 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 @@ struct OptionValueBase<DataType, false> : OptionValueCopy<DataType> {
typedef DataType WrapperType;
protected:
~OptionValueBase() = default;
OptionValueBase() = default;
OptionValueBase(const OptionValueBase&) = default;
~OptionValueBase() = default;
OptionValueBase &operator=(const OptionValueBase&) = default;
};
@ -511,6 +528,7 @@ struct OptionValue final
OptionValue() = default;
OptionValue(const DataType &V) { this->setValue(V); }
// Some options may take their value from a different data type.
template <class DT> OptionValue<DataType> &operator=(const DT &V) {
this->setValue(V);
@ -525,9 +543,10 @@ struct OptionValue<cl::boolOrDefault> final
: OptionValueCopy<cl::boolOrDefault> {
typedef cl::boolOrDefault WrapperType;
OptionValue() {}
OptionValue() = default;
OptionValue(const cl::boolOrDefault &V) { this->setValue(V); }
OptionValue<cl::boolOrDefault> &operator=(const cl::boolOrDefault &V) {
setValue(V);
return *this;
@ -541,9 +560,10 @@ template <>
struct OptionValue<std::string> final : OptionValueCopy<std::string> {
typedef StringRef WrapperType;
OptionValue() {}
OptionValue() = default;
OptionValue(const std::string &V) { this->setValue(V); }
OptionValue<std::string> &operator=(const std::string &V) {
setValue(V);
return *this;
@ -620,7 +640,8 @@ protected:
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 @@ class basic_parser_impl { // non-template implementation of basic_parser<t>
public:
basic_parser_impl(Option &) {}
enum ValueExpected getValueExpectedFlagDefault() const {
return ValueRequired;
}
@ -800,6 +820,7 @@ public:
protected:
~basic_parser_impl() = default;
// A helper for basic_parser::printOptionDiff.
void printOptionName(const Option &O, size_t GlobalWidth) const;
};
@ -810,12 +831,13 @@ protected:
template <class DataType> class basic_parser : public basic_parser_impl {
public:
basic_parser(Option &O) : basic_parser_impl(O) {}
typedef DataType parser_data_type;
typedef OptionValue<DataType> OptVal;
protected:
// Workaround Clang PR22793
~basic_parser() {}
~basic_parser() = default;
};
//--------------------------------------------------
@ -1112,15 +1134,19 @@ template <> struct applicator<NumOccurrencesFlag> {
O.setNumOccurrencesFlag(N);
}
};
template <> struct applicator<ValueExpected> {
static void opt(ValueExpected VE, Option &O) { O.setValueExpectedFlag(VE); }
};
template <> struct applicator<OptionHidden> {
static void opt(OptionHidden OH, Option &O) { O.setHiddenFlag(OH); }
};
template <> struct applicator<FormattingFlags> {
static void opt(FormattingFlags FF, Option &O) { O.setFormattingFlag(FF); }
};
template <> struct applicator<MiscFlags> {
static void opt(MiscFlags MF, Option &O) { O.setMiscFlag(MF); }
};
@ -1145,7 +1171,7 @@ template <class Opt, class Mod> void apply(Opt *O, const Mod &M) {
//
template <class DataType, bool ExternalStorage, bool isClass>
class opt_storage {
DataType *Location; // Where to store the object...
DataType *Location = nullptr; // Where to store the object...
OptionValue<DataType> Default;
void check_location() const {
@ -1155,7 +1181,7 @@ class opt_storage {
}
public:
opt_storage() : Location(nullptr) {}
opt_storage() = default;
bool setLocation(Option &O, DataType &L) {
if (Location)
@ -1284,11 +1310,11 @@ class opt : public Option,
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 @@ extern template class opt<bool>;
// cl::location(x) modifier.
//
template <class DataType, class StorageClass> 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 @@ class list : public Option, public list_storage<DataType, StorageClass> {
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 @@ struct multi_val {
// cl::location(x) modifier.
//
template <class DataType, class StorageClass> class bits_storage {
unsigned *Location; // Where to store the bits...
unsigned *Location = nullptr; // Where to store the bits...
template <class T> static unsigned Bit(const T &V) {
unsigned BitPos = reinterpret_cast<unsigned>(V);
@ -1505,7 +1531,7 @@ template <class DataType, class StorageClass> class bits_storage {
}
public:
bits_storage() : Location(nullptr) {}
bits_storage() = default;
bool setLocation(Option &O, unsigned &L) {
if (Location)
@ -1593,11 +1619,11 @@ class bits : public Option, public bits_storage<DataType, Storage> {
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 @@ public:
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 @@ class alias : public Option {
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 @@ public:
// 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 @@ struct aliasopt {
// exit is called.
struct extrahelp {
StringRef morehelp;
explicit extrahelp(StringRef help);
};
@ -1841,8 +1873,7 @@ void ResetAllOptionOccurrences();
/// where no options are supported.
void ResetCommandLineParser();
} // End namespace cl
} // end namespace cl
} // end namespace llvm
} // End namespace llvm
#endif
#endif // LLVM_SUPPORT_COMMANDLINE_H

View File

@ -14,27 +14,38 @@
#ifndef LLVM_SUPPORT_ERROR_H
#define LLVM_SUPPORT_ERROR_H
#include "llvm/ADT/PointerIntPair.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Config/abi-breaking.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 <algorithm>
#include <cassert>
#include <cstdint>
#include <cstdlib>
#include <functional>
#include <memory>
#include <new>
#include <string>
#include <system_error>
#include <type_traits>
#include <utility>
#include <vector>
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;
@ -69,6 +80,7 @@ public:
private:
virtual void anchor();
static char ID;
};
@ -138,7 +150,6 @@ private:
/// 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;
@ -315,7 +326,6 @@ public:
/// Special ErrorInfo subclass representing a list of ErrorInfos.
/// Instances of this class are constructed by joinError.
class ErrorList final : public ErrorInfo<ErrorList> {
// handleErrors needs to be able to iterate the payload list of an
// ErrorList.
template <typename... HandlerTs>
@ -601,6 +611,7 @@ public:
if (Err)
(void)!!*Err;
}
~ErrorAsOutParameter() {
// Clear the checked bit.
if (Err && !*Err)
@ -854,6 +865,7 @@ private:
/// std::error_codes.
class ECError : public ErrorInfo<ECError> {
friend Error errorCodeToError(std::error_code);
public:
void setErrorCode(std::error_code EC) { this->EC = EC; }
std::error_code convertToErrorCode() const override { return EC; }
@ -865,6 +877,7 @@ public:
protected:
ECError() = default;
ECError(std::error_code EC) : EC(EC) {}
std::error_code EC;
};
@ -907,9 +920,12 @@ template <typename T> ErrorOr<T> expectedToErrorOr(Expected<T> &&E) {
class StringError : public ErrorInfo<StringError> {
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;
@ -969,6 +985,6 @@ private:
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err,
bool gen_crash_diag = true);
} // namespace llvm
} // end namespace llvm
#endif // LLVM_SUPPORT_ERROR_H

View File

@ -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 <cassert>
@ -125,6 +124,7 @@ class UniqueID {
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 @@ public:
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; }
};
@ -674,10 +675,6 @@ ErrorOr<space_info> disk_space(const Twine &Path);
/// 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.
@ -693,6 +690,10 @@ private:
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.
@ -733,7 +734,7 @@ public:
: Path(path.str())
, Status(st) {}
directory_entry() {}
directory_entry() = default;
void assign(const Twine &path, file_status st = file_status()) {
Path = path.str();
@ -831,7 +832,7 @@ namespace detail {
: Level(0)
, HasNoPushRequest(false) {}
std::stack<directory_iterator, std::vector<directory_iterator> > Stack;
std::stack<directory_iterator, std::vector<directory_iterator>> Stack;
uint16_t Level;
bool HasNoPushRequest;
};
@ -843,13 +844,14 @@ class recursive_directory_iterator {
IntrusiveRefCntPtr<detail::RecDirIterState> 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;

View File

@ -26,17 +26,18 @@
#ifndef LLVM_SUPPORT_FORMATVARIADIC_H
#define LLVM_SUPPORT_FORMATVARIADIC_H
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/DataTypes.h"
#include "llvm/Support/FormatCommon.h"
#include "llvm/Support/FormatProviders.h"
#include "llvm/Support/FormatVariadicDetails.h"
#include "llvm/Support/raw_ostream.h"
#include <cstddef>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
namespace llvm {
@ -44,13 +45,14 @@ namespace llvm {
enum class ReplacementType { Empty, Format, Literal };
struct ReplacementItem {
ReplacementItem() {}
ReplacementItem() = default;
explicit ReplacementItem(StringRef Literal)
: Type(ReplacementType::Literal), Spec(Literal) {}
ReplacementItem(StringRef Spec, size_t Index, size_t Align, AlignStyle Where,
char Pad, StringRef Options)
: Type(ReplacementType::Format), Spec(Spec), Index(Index), Align(Align),
Where(Where), Pad(Pad), Options(Options) {}
ReplacementType Type = ReplacementType::Empty;
StringRef Spec;
size_t Index = 0;
@ -90,7 +92,6 @@ public:
formatv_object_base(StringRef Fmt, std::size_t ParamCount)
: Fmt(Fmt), Replacements(parseFormatString(Fmt)) {
Wrappers.reserve(ParamCount);
return;
}
void format(raw_ostream &S) const {
@ -124,7 +125,7 @@ public:
return Result;
}
template <unsigned N> llvm::SmallString<N> sstr() const {
template <unsigned N> SmallString<N> sstr() const {
SmallString<N> Result;
raw_svector_ostream Stream(Result);
Stream << *this;
@ -243,4 +244,4 @@ inline auto formatv(const char *Fmt, Ts &&... Vals) -> formatv_object<decltype(
} // end namespace llvm
#endif
#endif // LLVM_SUPPORT_FORMATVARIADIC_H

View File

@ -46,6 +46,7 @@ protected:
mutable const ManagedStaticBase *Next;
void RegisterManagedStatic(void *(*creator)(), void (*deleter)(void*)) const;
public:
/// isConstructed - Return true if this object has not been created yet.
bool isConstructed() const { return Ptr != nullptr; }
@ -89,10 +90,10 @@ void llvm_shutdown();
/// llvm_shutdown_obj - This is a simple helper class that calls
/// llvm_shutdown() when it is destroyed.
struct llvm_shutdown_obj {
llvm_shutdown_obj() { }
llvm_shutdown_obj() = default;
~llvm_shutdown_obj() { llvm_shutdown(); }
};
}
} // end namespace llvm
#endif
#endif // LLVM_SUPPORT_MANAGEDSTATIC_H

View File

@ -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 <memory>
#include <cstddef>
#include <cstdint>
namespace llvm {
class MemoryBufferRef;
/// This interface provides simple read-only access to a block of memory, and
@ -37,13 +41,15 @@ class MemoryBuffer {
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;
MemoryBuffer &operator=(const MemoryBuffer &) = delete;
virtual ~MemoryBuffer();
const char *getBufferStart() const { return BufferStart; }
@ -154,7 +160,7 @@ class MemoryBufferRef {
StringRef Identifier;
public:
MemoryBufferRef() {}
MemoryBufferRef() = default;
MemoryBufferRef(MemoryBuffer& Buffer)
: Buffer(Buffer.getBuffer()), Identifier(Buffer.getBufferIdentifier()) {}
MemoryBufferRef(StringRef Buffer, StringRef Identifier)
@ -174,4 +180,4 @@ DEFINE_SIMPLE_CONVERSION_FUNCTIONS(MemoryBuffer, LLVMMemoryBufferRef)
} // end namespace llvm
#endif
#endif // LLVM_SUPPORT_MEMORYBUFFER_H

View File

@ -11,19 +11,27 @@
#define LLVM_SUPPORT_YAMLTRAITS_H
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/STLExtras.h"
#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 <cassert>
#include <cctype>
#include <cstddef>
#include <cstdint>
#include <memory>
#include <new>
#include <string>
#include <system_error>
#include <type_traits>
#include <vector>
namespace llvm {
namespace yaml {
@ -139,7 +147,6 @@ struct ScalarTraits {
//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 +179,7 @@ struct BlockScalarTraits {
/// to/from a YAML sequence. For example:
///
/// template<>
/// struct SequenceTraits< std::vector<MyType> > {
/// struct SequenceTraits< std::vector<MyType>> {
/// static size_t size(IO &io, std::vector<MyType> &seq) {
/// return seq.size();
/// }
@ -220,7 +227,7 @@ struct has_ScalarEnumerationTraits
public:
static bool const value =
(sizeof(test<ScalarEnumerationTraits<T> >(nullptr)) == 1);
(sizeof(test<ScalarEnumerationTraits<T>>(nullptr)) == 1);
};
// Test if ScalarBitSetTraits<T> is defined on type T.
@ -236,7 +243,7 @@ struct has_ScalarBitSetTraits
static double test(...);
public:
static bool const value = (sizeof(test<ScalarBitSetTraits<T> >(nullptr)) == 1);
static bool const value = (sizeof(test<ScalarBitSetTraits<T>>(nullptr)) == 1);
};
// Test if ScalarTraits<T> is defined on type T.
@ -348,7 +355,7 @@ struct has_SequenceMethodTraits
static double test(...);
public:
static bool const value = (sizeof(test<SequenceTraits<T> >(nullptr)) == 1);
static bool const value = (sizeof(test<SequenceTraits<T>>(nullptr)) == 1);
};
// has_FlowTraits<int> will cause an error with some compilers because
@ -398,7 +405,7 @@ struct has_DocumentListTraits
static double test(...);
public:
static bool const value = (sizeof(test<DocumentListTraits<T> >(nullptr))==1);
static bool const value = (sizeof(test<DocumentListTraits<T>>(nullptr))==1);
};
inline bool isNumber(StringRef S) {
@ -503,7 +510,6 @@ struct unvalidatedMappingTraits
// Base class for Input and Output.
class IO {
public:
IO(void *Ctxt=nullptr);
virtual ~IO();
@ -701,6 +707,7 @@ private:
};
namespace detail {
template <typename T, typename Context>
void doMapping(IO &io, T &Val, Context &Ctx) {
MappingContextTraits<T, Context>::mapping(io, Val, Ctx);
@ -709,7 +716,8 @@ void doMapping(IO &io, T &Val, Context &Ctx) {
template <typename T> void doMapping(IO &io, T &Val, EmptyContext &Ctx) {
MappingTraits<T>::mapping(io, Val);
}
}
} // end namespace detail
template <typename T>
typename std::enable_if<has_ScalarEnumerationTraits<T>::value, void>::type
@ -950,6 +958,7 @@ struct ScalarTraits<support::detail::packed_endian_specific_integral<
llvm::raw_ostream &Stream) {
ScalarTraits<value_type>::output(static_cast<value_type>(E), Ctx, Stream);
}
static StringRef input(StringRef Str, void *Ctx, endian_type &E) {
value_type V;
auto R = ScalarTraits<value_type>::input(Str, Ctx, V);
@ -1089,9 +1098,11 @@ private:
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 +1110,20 @@ private:
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 +1133,9 @@ private:
return ScalarNode::classof(n->_node) ||
BlockScalarNode::classof(n->_node);
}
static inline bool classof(const ScalarHNode *) { return true; }
protected:
StringRef _value;
};
@ -1132,6 +1149,7 @@ private:
static inline bool classof(const HNode *n) {
return MappingNode::classof(n->_node);
}
static inline bool classof(const MapHNode *) { return true; }
typedef llvm::StringMap<std::unique_ptr<HNode>> NameToNode;
@ -1151,6 +1169,7 @@ private:
static inline bool classof(const HNode *n) {
return SequenceNode::classof(n->_node);
}
static inline bool classof(const SequenceHNode *) { return true; }
std::vector<std::unique_ptr<HNode>> Entries;
@ -1217,7 +1236,7 @@ public:
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 +1283,10 @@ private:
/// Based on BOOST_STRONG_TYPEDEF
#define LLVM_YAML_STRONG_TYPEDEF(_base, _type) \
struct _type { \
_type() { } \
_type(const _base v) : value(v) { } \
_type(const _type &v) : value(v.value) {} \
_type &operator=(const _type &rhs) { value = rhs.value; return *this; }\
_type() = default; \
_type(const _base v) : value(v) {} \
_type(const _type &v) = default; \
_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 +1476,8 @@ template <typename T> struct SequenceTraitsImpl {
}
};
} // 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.

View File

@ -16,22 +16,26 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/DataTypes.h"
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <string>
#include <system_error>
namespace llvm {
class formatv_object_base;
class format_object_base;
class FormattedString;
class FormattedNumber;
class FormattedBytes;
template <typename T> class SmallVectorImpl;
namespace sys {
namespace fs {
enum OpenFlags : unsigned;
}
}
} // end namespace fs
} // end namespace sys
/// This class implements an extremely fast bulk output stream that can *only*
/// output to a stream. It does not support seeking, reopening, rewinding, line
@ -39,9 +43,6 @@ enum OpenFlags : unsigned;
/// a chunk at a time.
class raw_ostream {
private:
void operator=(const raw_ostream &) = delete;
raw_ostream(const raw_ostream &) = delete;
/// The buffer is handled in such a way that the buffer is
/// uninitialized, unbuffered, or out of space when OutBufCur >=
/// OutBufEnd. Thus a single comparison suffices to determine if we
@ -71,7 +72,7 @@ private:
public:
// color order matches ANSI escape sequence, don't change
enum Colors {
BLACK=0,
BLACK = 0,
RED,
GREEN,
YELLOW,
@ -88,6 +89,9 @@ public:
OutBufStart = OutBufEnd = OutBufCur = nullptr;
}
raw_ostream(const raw_ostream &) = delete;
void operator=(const raw_ostream &) = delete;
virtual ~raw_ostream();
/// tell - Return the current offset with the file.
@ -186,7 +190,7 @@ public:
return write(Str.data(), Str.length());
}
raw_ostream &operator<<(const llvm::SmallVectorImpl<char> &Str) {
raw_ostream &operator<<(const SmallVectorImpl<char> &Str) {
return write(Str.data(), Str.size());
}
@ -195,6 +199,7 @@ public:
raw_ostream &operator<<(unsigned long long N);
raw_ostream &operator<<(long long N);
raw_ostream &operator<<(const void *P);
raw_ostream &operator<<(unsigned int N) {
return this->operator<<(static_cast<unsigned long>(N));
}
@ -501,7 +506,8 @@ public:
explicit raw_svector_ostream(SmallVectorImpl<char> &O) : OS(O) {
SetUnbuffered();
}
~raw_svector_ostream() override {}
~raw_svector_ostream() override = default;
void flush() = delete;
@ -520,7 +526,7 @@ class raw_null_ostream : public raw_pwrite_stream {
uint64_t current_pos() const override;
public:
explicit raw_null_ostream() {}
explicit raw_null_ostream() = default;
~raw_null_ostream() override;
};
@ -533,6 +539,6 @@ public:
~buffer_ostream() override { OS << str(); }
};
} // end llvm namespace
} // end namespace llvm
#endif // LLVM_SUPPORT_RAW_OSTREAM_H

View File

@ -18,13 +18,22 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/PointerIntPair.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/DataTypes.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/SMLoc.h"
#include "llvm/Support/TrailingObjects.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <map>
#include <memory>
#include <string>
#include <utility>
#include <vector>
namespace llvm {
@ -57,10 +66,10 @@ private:
std::unique_ptr<ListRecTy> ListTy;
public:
RecTyKind getRecTyKind() const { return Kind; }
RecTy(RecTyKind K) : Kind(K) {}
virtual ~RecTy() {}
virtual ~RecTy() = default;
RecTyKind getRecTyKind() const { return Kind; }
virtual std::string getAsString() const = 0;
void print(raw_ostream &OS) const { OS << getAsString(); }
@ -83,6 +92,7 @@ inline raw_ostream &operator<<(raw_ostream &OS, const RecTy &Ty) {
///
class BitRecTy : public RecTy {
static BitRecTy Shared;
BitRecTy() : RecTy(BitRecTyKind) {}
public:
@ -101,6 +111,7 @@ public:
///
class BitsRecTy : public RecTy {
unsigned Size;
explicit BitsRecTy(unsigned Sz) : RecTy(BitsRecTyKind), Size(Sz) {}
public:
@ -121,6 +132,7 @@ public:
///
class CodeRecTy : public RecTy {
static CodeRecTy Shared;
CodeRecTy() : RecTy(CodeRecTyKind) {}
public:
@ -137,6 +149,7 @@ public:
///
class IntRecTy : public RecTy {
static IntRecTy Shared;
IntRecTy() : RecTy(IntRecTyKind) {}
public:
@ -155,6 +168,7 @@ public:
///
class StringRecTy : public RecTy {
static StringRecTy Shared;
StringRecTy() : RecTy(StringRecTyKind) {}
public:
@ -173,7 +187,9 @@ public:
///
class ListRecTy : public RecTy {
RecTy *Ty;
explicit ListRecTy(RecTy *T) : RecTy(ListRecTyKind), Ty(T) {}
friend ListRecTy *RecTy::getListTy();
public:
@ -193,6 +209,7 @@ public:
///
class DagRecTy : public RecTy {
static DagRecTy Shared;
DagRecTy() : RecTy(DagRecTyKind) {}
public:
@ -210,7 +227,9 @@ public:
///
class RecordRecTy : public RecTy {
Record *Rec;
explicit RecordRecTy(Record *R) : RecTy(RecordRecTyKind), Rec(R) {}
friend class Record;
public:
@ -276,11 +295,11 @@ protected:
private:
const InitKind Kind;
protected:
uint8_t Opc; // Used by UnOpInit, BinOpInit, and TernOpInit
private:
Init(const Init &) = delete;
Init &operator=(const Init &) = delete;
virtual void anchor();
public:
@ -290,7 +309,9 @@ protected:
explicit Init(InitKind K, uint8_t Opc = 0) : Kind(K), Opc(Opc) {}
public:
virtual ~Init() {}
Init(const Init &) = delete;
Init &operator=(const Init &) = delete;
virtual ~Init() = default;
/// This virtual method should be overridden by values that may
/// not be completely specified yet.
@ -384,9 +405,6 @@ inline raw_ostream &operator<<(raw_ostream &OS, const Init &I) {
class TypedInit : public Init {
RecTy *Ty;
TypedInit(const TypedInit &Other) = delete;
TypedInit &operator=(const TypedInit &Other) = delete;
protected:
explicit TypedInit(InitKind K, RecTy *T, uint8_t Opc = 0)
: Init(K, Opc), Ty(T) {}
@ -397,10 +415,14 @@ protected:
}
public:
TypedInit(const TypedInit &Other) = delete;
TypedInit &operator=(const TypedInit &Other) = delete;
static bool classof(const Init *I) {
return I->getKind() >= IK_FirstTypedInit &&
I->getKind() <= IK_LastTypedInit;
}
RecTy *getType() const { return Ty; }
Init *convertInitializerTo(RecTy *Ty) const override;
@ -427,13 +449,15 @@ public:
///
class UnsetInit : public Init {
UnsetInit() : Init(IK_UnsetInit) {}
public:
UnsetInit(const UnsetInit &) = delete;
UnsetInit &operator=(const UnsetInit &Other) = delete;
public:
static bool classof(const Init *I) {
return I->getKind() == IK_UnsetInit;
}
static UnsetInit *get();
Init *convertInitializerTo(RecTy *Ty) const override;
@ -452,13 +476,15 @@ class BitInit : public Init {
bool Value;
explicit BitInit(bool V) : Init(IK_BitInit), Value(V) {}
public:
BitInit(const BitInit &Other) = delete;
BitInit &operator=(BitInit &Other) = delete;
public:
static bool classof(const Init *I) {
return I->getKind() == IK_BitInit;
}
static BitInit *get(bool V);
bool getValue() const { return Value; }
@ -483,16 +509,17 @@ class BitsInit final : public TypedInit, public FoldingSetNode,
BitsInit(unsigned N)
: TypedInit(IK_BitsInit, BitsRecTy::get(N)), NumBits(N) {}
public:
BitsInit(const BitsInit &Other) = delete;
BitsInit &operator=(const BitsInit &Other) = delete;
public:
// Do not use sized deallocation due to trailing objects.
void operator delete(void *p) { ::operator delete(p); }
static bool classof(const Init *I) {
return I->getKind() == IK_BitsInit;
}
static BitsInit *get(ArrayRef<Init *> Range);
void Profile(FoldingSetNodeID &ID) const;
@ -508,11 +535,13 @@ public:
if (!getBit(i)->isComplete()) return false;
return true;
}
bool allInComplete() const {
for (unsigned i = 0; i != getNumBits(); ++i)
if (getBit(i)->isComplete()) return false;
return true;
}
std::string getAsString() const override;
/// This method is used to implement
@ -539,13 +568,14 @@ class IntInit : public TypedInit {
explicit IntInit(int64_t V)
: TypedInit(IK_IntInit, IntRecTy::get()), Value(V) {}
public:
IntInit(const IntInit &Other) = delete;
IntInit &operator=(const IntInit &Other) = delete;
public:
static bool classof(const Init *I) {
return I->getKind() == IK_IntInit;
}
static IntInit *get(int64_t V);
int64_t getValue() const { return Value; }
@ -577,13 +607,14 @@ class StringInit : public TypedInit {
explicit StringInit(StringRef V)
: TypedInit(IK_StringInit, StringRecTy::get()), Value(V) {}
public:
StringInit(const StringInit &Other) = delete;
StringInit &operator=(const StringInit &Other) = delete;
public:
static bool classof(const Init *I) {
return I->getKind() == IK_StringInit;
}
static StringInit *get(StringRef);
const std::string &getValue() const { return Value; }
@ -614,13 +645,14 @@ class CodeInit : public TypedInit {
: TypedInit(IK_CodeInit, static_cast<RecTy *>(CodeRecTy::get())),
Value(V) {}
public:
CodeInit(const StringInit &Other) = delete;
CodeInit &operator=(const StringInit &Other) = delete;
public:
static bool classof(const Init *I) {
return I->getKind() == IK_CodeInit;
}
static CodeInit *get(StringRef);
const std::string &getValue() const { return Value; }
@ -659,10 +691,10 @@ private:
explicit ListInit(unsigned N, RecTy *EltTy)
: TypedInit(IK_ListInit, ListRecTy::get(EltTy)), NumValues(N) {}
public:
ListInit(const ListInit &Other) = delete;
ListInit &operator=(const ListInit &Other) = delete;
public:
// Do not use sized deallocation due to trailing objects.
void operator delete(void *p) { ::operator delete(p); }
@ -718,18 +750,19 @@ public:
/// Base class for operators
///
class OpInit : public TypedInit {
OpInit(const OpInit &Other) = delete;
OpInit &operator=(OpInit &Other) = delete;
protected:
explicit OpInit(InitKind K, RecTy *Type, uint8_t Opc)
: TypedInit(K, Type, Opc) {}
public:
OpInit(const OpInit &Other) = delete;
OpInit &operator=(OpInit &Other) = delete;
static bool classof(const Init *I) {
return I->getKind() >= IK_FirstOpInit &&
I->getKind() <= IK_LastOpInit;
}
// Clone - Clone this operator, replacing arguments with the new list
virtual OpInit *clone(std::vector<Init *> &Operands) const = 0;
@ -758,13 +791,14 @@ private:
UnOpInit(UnaryOp opc, Init *lhs, RecTy *Type)
: OpInit(IK_UnOpInit, Type, opc), LHS(lhs) {}
public:
UnOpInit(const UnOpInit &Other) = delete;
UnOpInit &operator=(const UnOpInit &Other) = delete;
public:
static bool classof(const Init *I) {
return I->getKind() == IK_UnOpInit;
}
static UnOpInit *get(UnaryOp opc, Init *lhs, RecTy *Type);
void Profile(FoldingSetNodeID &ID) const;
@ -777,6 +811,7 @@ public:
}
unsigned getNumOperands() const override { return 1; }
Init *getOperand(unsigned i) const override {
assert(i == 0 && "Invalid operand id for unary operator");
return getOperand();
@ -807,13 +842,14 @@ private:
BinOpInit(BinaryOp opc, Init *lhs, Init *rhs, RecTy *Type) :
OpInit(IK_BinOpInit, Type, opc), LHS(lhs), RHS(rhs) {}
public:
BinOpInit(const BinOpInit &Other) = delete;
BinOpInit &operator=(const BinOpInit &Other) = delete;
public:
static bool classof(const Init *I) {
return I->getKind() == IK_BinOpInit;
}
static BinOpInit *get(BinaryOp opc, Init *lhs, Init *rhs,
RecTy *Type);
@ -861,13 +897,14 @@ private:
RecTy *Type) :
OpInit(IK_TernOpInit, Type, opc), LHS(lhs), MHS(mhs), RHS(rhs) {}
public:
TernOpInit(const TernOpInit &Other) = delete;
TernOpInit &operator=(const TernOpInit &Other) = delete;
public:
static bool classof(const Init *I) {
return I->getKind() == IK_TernOpInit;
}
static TernOpInit *get(TernaryOp opc, Init *lhs,
Init *mhs, Init *rhs,
RecTy *Type);
@ -916,18 +953,20 @@ class VarInit : public TypedInit {
explicit VarInit(Init *VN, RecTy *T)
: TypedInit(IK_VarInit, T), VarName(VN) {}
public:
VarInit(const VarInit &Other) = delete;
VarInit &operator=(const VarInit &Other) = delete;
public:
static bool classof(const Init *I) {
return I->getKind() == IK_VarInit;
}
static VarInit *get(const std::string &VN, RecTy *T);
static VarInit *get(Init *VN, RecTy *T);
const std::string &getName() const;
Init *getNameInit() const { return VarName; }
std::string getNameInitAsString() const {
return getNameInit()->getAsUnquotedString();
}
@ -965,13 +1004,14 @@ class VarBitInit : public Init {
"Illegal VarBitInit expression!");
}
public:
VarBitInit(const VarBitInit &Other) = delete;
VarBitInit &operator=(const VarBitInit &Other) = delete;
public:
static bool classof(const Init *I) {
return I->getKind() == IK_VarBitInit;
}
static VarBitInit *get(TypedInit *T, unsigned B);
Init *convertInitializerTo(RecTy *Ty) const override;
@ -1002,13 +1042,14 @@ class VarListElementInit : public TypedInit {
"Illegal VarBitInit expression!");
}
public:
VarListElementInit(const VarListElementInit &Other) = delete;
void operator=(const VarListElementInit &Other) = delete;
public:
static bool classof(const Init *I) {
return I->getKind() == IK_VarListElementInit;
}
static VarListElementInit *get(TypedInit *T, unsigned E);
TypedInit *getVariable() const { return TI; }
@ -1032,15 +1073,17 @@ class DefInit : public TypedInit {
Record *Def;
DefInit(Record *D, RecordRecTy *T) : TypedInit(IK_DefInit, T), Def(D) {}
friend class Record;
public:
DefInit(const DefInit &Other) = delete;
DefInit &operator=(const DefInit &Other) = delete;
public:
static bool classof(const Init *I) {
return I->getKind() == IK_DefInit;
}
static DefInit *get(Record*);
Init *convertInitializerTo(RecTy *Ty) const override;
@ -1079,13 +1122,14 @@ class FieldInit : public TypedInit {
assert(getType() && "FieldInit with non-record type!");
}
public:
FieldInit(const FieldInit &Other) = delete;
FieldInit &operator=(const FieldInit &Other) = delete;
public:
static bool classof(const Init *I) {
return I->getKind() == IK_FieldInit;
}
static FieldInit *get(Init *R, const std::string &FN);
Init *getBit(unsigned Bit) const override;
@ -1117,19 +1161,19 @@ class DagInit : public TypedInit, public FoldingSetNode {
Args(ArgRange.begin(), ArgRange.end()),
ArgNames(NameRange.begin(), NameRange.end()) {}
public:
DagInit(const DagInit &Other) = delete;
DagInit &operator=(const DagInit &Other) = delete;
public:
static bool classof(const Init *I) {
return I->getKind() == IK_DagInit;
}
static DagInit *get(Init *V, const std::string &VN,
ArrayRef<Init *> ArgRange,
ArrayRef<std::string> NameRange);
static DagInit *get(Init *V, const std::string &VN,
const std::vector<
std::pair<Init*, std::string> > &args);
const std::vector<std::pair<Init*, std::string>> &args);
void Profile(FoldingSetNodeID &ID) const;
@ -1193,6 +1237,7 @@ public:
const std::string &getName() const;
const Init *getNameInit() const { return NameAndPrefix.getPointer(); }
std::string getNameInitAsString() const {
return getNameInit()->getAsUnquotedString();
}
@ -1263,11 +1308,11 @@ public:
ID(LastID++), IsAnonymous(Anonymous), ResolveFirst(false) {
init();
}
explicit Record(const std::string &N, ArrayRef<SMLoc> locs,
RecordKeeper &records, bool Anonymous = false)
: Record(StringInit::get(N), locs, records, Anonymous) {}
// When copy-constructing a Record, we must still guarantee a globally unique
// ID number. Don't copy TheInit either since it's owned by the original
// record. All other fields can be copied normally.
@ -1285,6 +1330,7 @@ public:
Init *getNameInit() const {
return Name;
}
const std::string getNameInitAsString() const {
return getNameInit()->getAsUnquotedString();
}
@ -1300,7 +1346,9 @@ public:
ArrayRef<Init *> getTemplateArgs() const {
return TemplateArgs;
}
ArrayRef<RecordVal> getValues() const { return Values; }
ArrayRef<std::pair<Record *, SMRange>> getSuperClasses() const {
return SuperClasses;
}
@ -1310,6 +1358,7 @@ public:
if (TA == Name) return true;
return false;
}
bool isTemplateArg(StringRef Name) const {
return isTemplateArg(StringInit::get(Name));
}
@ -1319,14 +1368,17 @@ public:
if (Val.getNameInit() == Name) return &Val;
return nullptr;
}
const RecordVal *getValue(StringRef Name) const {
return getValue(StringInit::get(Name));
}
RecordVal *getValue(const Init *Name) {
for (RecordVal &Val : Values)
if (Val.getNameInit() == Name) return &Val;
return nullptr;
}
RecordVal *getValue(StringRef Name) {
return getValue(StringInit::get(Name));
}
@ -1335,6 +1387,7 @@ public:
assert(!isTemplateArg(Name) && "Template arg already defined!");
TemplateArgs.push_back(Name);
}
void addTemplateArg(StringRef Name) {
addTemplateArg(StringInit::get(Name));
}
@ -1522,16 +1575,19 @@ public:
auto I = Classes.find(Name);
return I == Classes.end() ? nullptr : I->second.get();
}
Record *getDef(const std::string &Name) const {
auto I = Defs.find(Name);
return I == Defs.end() ? nullptr : I->second.get();
}
void addClass(std::unique_ptr<Record> R) {
bool Ins = Classes.insert(std::make_pair(R->getName(),
std::move(R))).second;
(void)Ins;
assert(Ins && "Class already exists");
}
void addDef(std::unique_ptr<Record> R) {
bool Ins = Defs.insert(std::make_pair(R->getName(),
std::move(R))).second;
@ -1669,6 +1725,6 @@ Init *QualifyName(Record &CurRec, MultiClass *CurMultiClass,
Init *QualifyName(Record &CurRec, MultiClass *CurMultiClass,
const std::string &Name, const std::string &Scoper);
} // end llvm namespace
} // end namespace llvm
#endif // LLVM_TABLEGEN_RECORD_H

View File

@ -50,8 +50,10 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/SMLoc.h"
#include <map>
#include <memory>
#include <vector>
namespace llvm {
@ -68,13 +70,14 @@ public:
/// Operator - A callback representing a DAG operator.
class Operator {
virtual void anchor();
public:
virtual ~Operator() {}
virtual ~Operator() = default;
/// apply - Apply this operator to Expr's arguments and insert the result
/// in Elts.
virtual void apply(SetTheory&, DagInit *Expr, RecSet &Elts,
ArrayRef<SMLoc> Loc) =0;
ArrayRef<SMLoc> Loc) = 0;
};
/// Expander - A callback function that can transform a Record representing a
@ -82,10 +85,11 @@ public:
/// users to define named sets that can be used in DAG expressions.
class Expander {
virtual void anchor();
public:
virtual ~Expander() {}
virtual void expand(SetTheory&, Record*, RecSet &Elts) =0;
public:
virtual ~Expander() = default;
virtual void expand(SetTheory&, Record*, RecSet &Elts) = 0;
};
private:
@ -138,5 +142,4 @@ public:
} // end namespace llvm
#endif
#endif // LLVM_TABLEGEN_SETTHEORY_H