llvm.org GIT mirror llvm / 9ed0c7a
[ADT, Support, TableGen] Fix some Clang-tidy modernize-use-default and Include What You Use warnings; other minor fixes (NFC). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288424 91177308-0d34-0410-b5e6-96231b3b80d8 Eugene Zelenko 3 years ago
12 changed file(s) with 352 addition(s) and 195 deletion(s). Raw diff Collapse all Expand all
1414 #ifndef LLVM_ADT_SPARSEBITVECTOR_H
1515 #define LLVM_ADT_SPARSEBITVECTOR_H
1616
17 #include "llvm/Support/DataTypes.h"
1817 #include "llvm/Support/ErrorHandling.h"
1918 #include "llvm/Support/MathExtras.h"
2019 #include "llvm/Support/raw_ostream.h"
2120 #include
2221 #include
22 #include
23 #include
2324 #include
2425
2526 namespace llvm {
5152 // Index of Element in terms of where first bit starts.
5253 unsigned ElementIndex;
5354 BitWord Bits[BITWORDS_PER_ELEMENT];
55
5456 SparseBitVectorElement() {
5557 ElementIndex = ~0U;
5658 memset(&Bits[0], 0, sizeof (BitWord) * BITWORDS_PER_ELEMENT);
7880
7981 // Return the bits that make up word Idx in our element.
8082 BitWord word(unsigned Idx) const {
81 assert (Idx < BITWORDS_PER_ELEMENT);
83 assert(Idx < BITWORDS_PER_ELEMENT);
8284 return Bits[Idx];
8385 }
8486
138140 unsigned WordPos = Curr / BITWORD_SIZE;
139141 unsigned BitPos = Curr % BITWORD_SIZE;
140142 BitWord Copy = Bits[WordPos];
141 assert (WordPos <= BITWORDS_PER_ELEMENT
142 && "Word Position outside of element");
143 assert(WordPos <= BITWORDS_PER_ELEMENT
144 && "Word Position outside of element");
143145
144146 // Mask off previous bits.
145147 Copy &= ~0UL << BitPos;
288290 private:
289291 bool AtEnd;
290292
291 const SparseBitVector *BitVector;
293 const SparseBitVector *BitVector = nullptr;
292294
293295 // Current element inside of bitmap.
294296 ElementListConstIter Iter;
358360 }
359361 }
360362 }
363
361364 public:
362 // Preincrement.
363 inline SparseBitVectorIterator& operator++() {
364 ++BitNumber;
365 Bits >>= 1;
366 AdvanceToNextNonZero();
367 return *this;
368 }
369
370 // Postincrement.
371 inline SparseBitVectorIterator operator++(int) {
372 SparseBitVectorIterator tmp = *this;
373 ++*this;
374 return tmp;
375 }
376
377 // Return the current set bit number.
378 unsigned operator*() const {
379 return BitNumber;
380 }
381
382 bool operator==(const SparseBitVectorIterator &RHS) const {
383 // If they are both at the end, ignore the rest of the fields.
384 if (AtEnd && RHS.AtEnd)
385 return true;
386 // Otherwise they are the same if they have the same bit number and
387 // bitmap.
388 return AtEnd == RHS.AtEnd && RHS.BitNumber == BitNumber;
389 }
390
391 bool operator!=(const SparseBitVectorIterator &RHS) const {
392 return !(*this == RHS);
393 }
394
395 SparseBitVectorIterator(): BitVector(nullptr) {
396 }
365 SparseBitVectorIterator() = default;
397366
398367 SparseBitVectorIterator(const SparseBitVector *RHS,
399368 bool end = false):BitVector(RHS) {
404373 AtEnd = end;
405374 AdvanceToFirstNonZero();
406375 }
376
377 // Preincrement.
378 inline SparseBitVectorIterator& operator++() {
379 ++BitNumber;
380 Bits >>= 1;
381 AdvanceToNextNonZero();
382 return *this;
383 }
384
385 // Postincrement.
386 inline SparseBitVectorIterator operator++(int) {
387 SparseBitVectorIterator tmp = *this;
388 ++*this;
389 return tmp;
390 }
391
392 // Return the current set bit number.
393 unsigned operator*() const {
394 return BitNumber;
395 }
396
397 bool operator==(const SparseBitVectorIterator &RHS) const {
398 // If they are both at the end, ignore the rest of the fields.
399 if (AtEnd && RHS.AtEnd)
400 return true;
401 // Otherwise they are the same if they have the same bit number and
402 // bitmap.
403 return AtEnd == RHS.AtEnd && RHS.BitNumber == BitNumber;
404 }
405
406 bool operator!=(const SparseBitVectorIterator &RHS) const {
407 return !(*this == RHS);
408 }
407409 };
410
408411 public:
409412 typedef SparseBitVectorIterator iterator;
410413
411 SparseBitVector () {
412 CurrElementIter = Elements.begin ();
413 }
414
415 ~SparseBitVector() {
416 }
414 SparseBitVector() {
415 CurrElementIter = Elements.begin();
416 }
417
418 ~SparseBitVector() = default;
417419
418420 // SparseBitVector copy ctor.
419421 SparseBitVector(const SparseBitVector &RHS) {
510512 ElementIter->set(Idx % ElementSize);
511513 }
512514
513 bool test_and_set (unsigned Idx) {
515 bool test_and_set(unsigned Idx) {
514516 bool old = test(Idx);
515517 if (!old) {
516518 set(Idx);
779781
780782 return BitCount;
781783 }
784
782785 iterator begin() const {
783786 return iterator(this);
784787 }
859862 }
860863 out << "]\n";
861864 }
865
862866 } // end namespace llvm
863867
864868 #endif // LLVM_ADT_SPARSEBITVECTOR_H
1010 #define LLVM_ADT_TINYPTRVECTOR_H
1111
1212 #include "llvm/ADT/ArrayRef.h"
13 #include "llvm/ADT/None.h"
1314 #include "llvm/ADT/PointerUnion.h"
1415 #include "llvm/ADT/SmallVector.h"
16 #include
17 #include
18 #include
19 #include
1520
1621 namespace llvm {
1722
2429 template
2530 class TinyPtrVector {
2631 public:
27 typedef llvm::SmallVector VecTy;
32 typedef SmallVector VecTy;
2833 typedef typename VecTy::value_type value_type;
29 typedef llvm::PointerUnion PtrUnion;
34 typedef PointerUnion PtrUnion;
3035
3136 private:
3237 PtrUnion Val;
3338
3439 public:
35 TinyPtrVector() {}
40 TinyPtrVector() = default;
41
3642 ~TinyPtrVector() {
3743 if (VecTy *V = Val.template dyn_cast())
3844 delete V;
4248 if (VecTy *V = Val.template dyn_cast())
4349 Val = new VecTy(*V);
4450 }
51
4552 TinyPtrVector &operator=(const TinyPtrVector &RHS) {
4653 if (this == &RHS)
4754 return *this;
7380 TinyPtrVector(TinyPtrVector &&RHS) : Val(RHS.Val) {
7481 RHS.Val = (EltTy)nullptr;
7582 }
83
7684 TinyPtrVector &operator=(TinyPtrVector &&RHS) {
7785 if (this == &RHS)
7886 return *this;
169177
170178 return Val.template get()->begin();
171179 }
180
172181 iterator end() {
173182 if (Val.template is())
174183 return begin() + (Val.isNull() ? 0 : 1);
186195
187196 reverse_iterator rbegin() { return reverse_iterator(end()); }
188197 reverse_iterator rend() { return reverse_iterator(begin()); }
198
189199 const_reverse_iterator rbegin() const {
190200 return const_reverse_iterator(end());
191201 }
202
192203 const_reverse_iterator rend() const {
193204 return const_reverse_iterator(begin());
194205 }
328339 return Val.template get()->insert(begin() + Offset, From, To);
329340 }
330341 };
342
331343 } // end namespace llvm
332344
333 #endif
345 #endif // LLVM_ADT_TINYPTRVECTOR_H
2020 #define LLVM_SUPPORT_COMMANDLINE_H
2121
2222 #include "llvm/ADT/ArrayRef.h"
23 #include "llvm/ADT/STLExtras.h"
23 #include "llvm/ADT/iterator_range.h"
2424 #include "llvm/ADT/SmallPtrSet.h"
2525 #include "llvm/ADT/SmallVector.h"
26 #include "llvm/ADT/STLExtras.h"
2627 #include "llvm/ADT/StringMap.h"
28 #include "llvm/ADT/StringRef.h"
2729 #include "llvm/ADT/Twine.h"
28 #include "llvm/Support/Compiler.h"
30 #include "llvm/Support/ErrorHandling.h"
2931 #include "llvm/Support/ManagedStatic.h"
3032 #include
31 #include
32 #include
33 #include <utility>
33 #include <cstddef>
34 #include
35 #include
36 #include
3437 #include
3538
3639 namespace llvm {
158161 private:
159162 StringRef const Name;
160163 StringRef const Description;
164
161165 void registerCategory();
162166
163167 public:
166170 : Name(Name), Description(Description) {
167171 registerCategory();
168172 }
173
169174 StringRef getName() const { return Name; }
170175 StringRef getDescription() const { return Description; }
171176 };
190195 : Name(Name), Description(Description) {
191196 registerSubCommand();
192197 }
193 SubCommand() {}
198 SubCommand() = default;
194199
195200 void reset();
196201
215220 //===----------------------------------------------------------------------===//
216221 // Option Base class
217222 //
218 class alias;
219223 class Option {
220224 friend class alias;
221225
257261 inline enum NumOccurrencesFlag getNumOccurrencesFlag() const {
258262 return (enum NumOccurrencesFlag)Occurrences;
259263 }
264
260265 inline enum ValueExpected getValueExpectedFlag() const {
261266 return Value ? ((enum ValueExpected)Value) : getValueExpectedFlagDefault();
262267 }
268
263269 inline enum OptionHidden getOptionHiddenFlag() const {
264270 return (enum OptionHidden)HiddenFlag;
265271 }
272
266273 inline enum FormattingFlags getFormattingFlag() const {
267274 return (enum FormattingFlags)Formatting;
268275 }
276
269277 inline unsigned getMiscFlags() const { return Misc; }
270278 inline unsigned getPosition() const { return Position; }
271279 inline unsigned getNumAdditionalVals() const { return AdditionalVals; }
274282 bool hasArgStr() const { return !ArgStr.empty(); }
275283 bool isPositional() const { return getFormattingFlag() == cl::Positional; }
276284 bool isSink() const { return getMiscFlags() & cl::Sink; }
285
277286 bool isConsumeAfter() const {
278287 return getNumOccurrencesFlag() == cl::ConsumeAfter;
279288 }
289
280290 bool isInAllSubCommands() const {
281291 return any_of(Subs, [](const SubCommand *SC) {
282292 return SC == &*AllSubCommands;
309319 inline void setNumAdditionalVals(unsigned n) { AdditionalVals = n; }
310320
311321 public:
322 virtual ~Option() = default;
323
312324 // addArgument - Register this argument with the commandline system.
313325 //
314326 void addArgument();
339351 // Prints option name followed by message. Always returns true.
340352 bool error(const Twine &Message, StringRef ArgName = StringRef());
341353
342 public:
343354 inline int getNumOccurrences() const { return NumOccurrences; }
344355 inline void reset() { NumOccurrences = 0; }
345 virtual ~Option() {}
346356 };
347357
348358 //===----------------------------------------------------------------------===//
353363 // desc - Modifier to set the description shown in the -help output...
354364 struct desc {
355365 StringRef Desc;
366
356367 desc(StringRef Str) : Desc(Str) {}
368
357369 void apply(Option &O) const { O.setDescription(Desc); }
358370 };
359371
361373 // output...
362374 struct value_desc {
363375 StringRef Desc;
376
364377 value_desc(StringRef Str) : Desc(Str) {}
378
365379 void apply(Option &O) const { O.setValueStr(Desc); }
366380 };
367381
386400 //
387401 template struct LocationClass {
388402 Ty &Loc;
403
389404 LocationClass(Ty &L) : Loc(L) {}
390405
391406 template void apply(Opt &O) const { O.setLocation(O, Loc); }
399414 // to.
400415 struct cat {
401416 OptionCategory &Category;
417
402418 cat(OptionCategory &c) : Category(c) {}
403419
404420 template void apply(Opt &O) const { O.setCategory(Category); }
407423 // sub - Specify the subcommand that this option belongs to.
408424 struct sub {
409425 SubCommand ⋐
426
410427 sub(SubCommand &S) : Sub(S) {}
411428
412429 template void apply(Opt &O) const { O.addSubCommand(Sub); }
420437 virtual bool compare(const GenericOptionValue &V) const = 0;
421438
422439 protected:
423 ~GenericOptionValue() = default;
424440 GenericOptionValue() = default;
425441 GenericOptionValue(const GenericOptionValue&) = default;
442 ~GenericOptionValue() = default;
426443 GenericOptionValue &operator=(const GenericOptionValue &) = default;
427444
428445 private:
458475 // Simple copy of the option value.
459476 template class OptionValueCopy : public GenericOptionValue {
460477 DataType Value;
461 bool Valid;
478 bool Valid = false;
462479
463480 protected:
481 OptionValueCopy(const OptionValueCopy&) = default;
464482 ~OptionValueCopy() = default;
465 OptionValueCopy(const OptionValueCopy&) = default;
466483 OptionValueCopy &operator=(const OptionValueCopy&) = default;
467484
468485 public:
469 OptionValueCopy() : Valid(false) {}
486 OptionValueCopy() = default;
470487
471488 bool hasValue() const { return Valid; }
472489
497514 typedef DataType WrapperType;
498515
499516 protected:
500 ~OptionValueBase() = default;
501517 OptionValueBase() = default;
502518 OptionValueBase(const OptionValueBase&) = default;
519 ~OptionValueBase() = default;
503520 OptionValueBase &operator=(const OptionValueBase&) = default;
504521 };
505522
510527 OptionValue() = default;
511528
512529 OptionValue(const DataType &V) { this->setValue(V); }
530
513531 // Some options may take their value from a different data type.
514532 template OptionValue &operator=(const DT &V) {
515533 this->setValue(V);
524542 : OptionValueCopy {
525543 typedef cl::boolOrDefault WrapperType;
526544
527 OptionValue() {}
545 OptionValue() = default;
528546
529547 OptionValue(const cl::boolOrDefault &V) { this->setValue(V); }
548
530549 OptionValue &operator=(const cl::boolOrDefault &V) {
531550 setValue(V);
532551 return *this;
540559 struct OptionValue final : OptionValueCopy {
541560 typedef StringRef WrapperType;
542561
543 OptionValue() {}
562 OptionValue() = default;
544563
545564 OptionValue(const std::string &V) { this->setValue(V); }
565
546566 OptionValue &operator=(const std::string &V) {
547567 setValue(V);
548568 return *this;
619639 public:
620640 generic_parser_base(Option &O) : Owner(O) {}
621641
622 virtual ~generic_parser_base() {} // Base class should have virtual-dtor
642 virtual ~generic_parser_base() = default;
643 // Base class should have virtual-destructor
623644
624645 // getNumOptions - Virtual function implemented by generic subclass to
625646 // indicate how many entries are in Values.
770791 public:
771792 basic_parser_impl(Option &) {}
772793
773
774794 enum ValueExpected getValueExpectedFlagDefault() const {
775795 return ValueRequired;
776796 }
799819
800820 protected:
801821 ~basic_parser_impl() = default;
822
802823 // A helper for basic_parser::printOptionDiff.
803824 void printOptionName(const Option &O, size_t GlobalWidth) const;
804825 };
809830 template class basic_parser : public basic_parser_impl {
810831 public:
811832 basic_parser(Option &O) : basic_parser_impl(O) {}
833
812834 typedef DataType parser_data_type;
813835 typedef OptionValue OptVal;
814836
815837 protected:
816838 // Workaround Clang PR22793
817 ~basic_parser() {}
839 ~basic_parser() = default;
818840 };
819841
820842 //--------------------------------------------------
11111133 O.setNumOccurrencesFlag(N);
11121134 }
11131135 };
1136
11141137 template <> struct applicator {
11151138 static void opt(ValueExpected VE, Option &O) { O.setValueExpectedFlag(VE); }
11161139 };
1140
11171141 template <> struct applicator {
11181142 static void opt(OptionHidden OH, Option &O) { O.setHiddenFlag(OH); }
11191143 };
1144
11201145 template <> struct applicator {
11211146 static void opt(FormattingFlags FF, Option &O) { O.setFormattingFlag(FF); }
11221147 };
1148
11231149 template <> struct applicator {
11241150 static void opt(MiscFlags MF, Option &O) { O.setMiscFlag(MF); }
11251151 };
11441170 //
11451171 template
11461172 class opt_storage {
1147 DataType *Location; // Where to store the object...
1173 DataType *Location = nullptr; // Where to store the object...
11481174 OptionValue Default;
11491175
11501176 void check_location() const {
11541180 }
11551181
11561182 public:
1157 opt_storage() : Location(nullptr) {}
1183 opt_storage() = default;
11581184
11591185 bool setLocation(Option &O, DataType &L) {
11601186 if (Location)
12831309 Parser.initialize();
12841310 }
12851311
1312 public:
12861313 // Command line options should not be copyable
12871314 opt(const opt &) = delete;
12881315 opt &operator=(const opt &) = delete;
12891316
1290 public:
12911317 // setInitialValue - Used by the cl::init modifier...
12921318 void setInitialValue(const DataType &V) { this->setValue(V, true); }
12931319
13201346 // cl::location(x) modifier.
13211347 //
13221348 template class list_storage {
1323 StorageClass *Location; // Where to store the object...
1324
1325 public:
1326 list_storage() : Location(0) {}
1349 StorageClass *Location = nullptr; // Where to store the object...
1350
1351 public:
1352 list_storage() = default;
13271353
13281354 bool setLocation(Option &O, StorageClass &L) {
13291355 if (Location)
14531479 Parser.initialize();
14541480 }
14551481
1482 public:
14561483 // Command line options should not be copyable
14571484 list(const list &) = delete;
14581485 list &operator=(const list &) = delete;
14591486
1460 public:
14611487 ParserClass &getParser() { return Parser; }
14621488
14631489 unsigned getPosition(unsigned optnum) const {
14941520 // cl::location(x) modifier.
14951521 //
14961522 template class bits_storage {
1497 unsigned *Location; // Where to store the bits...
1523 unsigned *Location = nullptr; // Where to store the bits...
14981524
14991525 template static unsigned Bit(const T &V) {
15001526 unsigned BitPos = reinterpret_cast(V);
15041530 }
15051531
15061532 public:
1507 bits_storage() : Location(nullptr) {}
1533 bits_storage() = default;
15081534
15091535 bool setLocation(Option &O, unsigned &L) {
15101536 if (Location)
15921618 Parser.initialize();
15931619 }
15941620
1621 public:
15951622 // Command line options should not be copyable
15961623 bits(const bits &) = delete;
15971624 bits &operator=(const bits &) = delete;
15981625
1599 public:
16001626 ParserClass &getParser() { return Parser; }
16011627
16021628 unsigned getPosition(unsigned optnum) const {
16181644
16191645 class alias : public Option {
16201646 Option *AliasFor;
1647
16211648 bool handleOccurrence(unsigned pos, StringRef /*ArgName*/,
16221649 StringRef Arg) override {
16231650 return AliasFor->handleOccurrence(pos, AliasFor->ArgStr, Arg);
16241651 }
1652
16251653 bool addOccurrence(unsigned pos, StringRef /*ArgName*/, StringRef Value,
16261654 bool MultiArg = false) override {
16271655 return AliasFor->addOccurrence(pos, AliasFor->ArgStr, Value, MultiArg);
16281656 }
1657
16291658 // Handle printing stuff...
16301659 size_t getOptionWidth() const override;
16311660 void printOptionInfo(size_t GlobalWidth) const override;
16471676 addArgument();
16481677 }
16491678
1679 public:
16501680 // Command line options should not be copyable
16511681 alias(const alias &) = delete;
16521682 alias &operator=(const alias &) = delete;
16531683
1654 public:
16551684 void setAliasFor(Option &O) {
16561685 if (AliasFor)
16571686 error("cl::alias must only have one cl::aliasopt(...) specified!");
16691698 // aliasfor - Modifier to set the option an alias aliases.
16701699 struct aliasopt {
16711700 Option &Opt;
1701
16721702 explicit aliasopt(Option &O) : Opt(O) {}
1703
16731704 void apply(alias &A) const { A.setAliasFor(Opt); }
16741705 };
16751706
16791710 // exit is called.
16801711 struct extrahelp {
16811712 StringRef morehelp;
1713
16821714 explicit extrahelp(StringRef help);
16831715 };
16841716
18401872 /// where no options are supported.
18411873 void ResetCommandLineParser();
18421874
1843 } // End namespace cl
1844
1845 } // End namespace llvm
1846
1847 #endif
1875 } // end namespace cl
1876 } // end namespace llvm
1877
1878 #endif // LLVM_SUPPORT_COMMANDLINE_H
1313 #ifndef LLVM_SUPPORT_ERROR_H
1414 #define LLVM_SUPPORT_ERROR_H
1515
16 #include "llvm/ADT/PointerIntPair.h"
16 #include "llvm/ADT/SmallVector.h"
1717 #include "llvm/ADT/STLExtras.h"
1818 #include "llvm/ADT/StringExtras.h"
1919 #include "llvm/ADT/Twine.h"
2020 #include "llvm/Config/abi-breaking.h"
21 #include "llvm/Support/AlignOf.h"
22 #include "llvm/Support/Compiler.h"
2123 #include "llvm/Support/Debug.h"
2224 #include "llvm/Support/ErrorOr.h"
2325 #include "llvm/Support/raw_ostream.h"
26 #include
27 #include
28 #include
29 #include
30 #include
31 #include
32 #include
33 #include
34 #include
35 #include
36 #include
2437 #include
2538
2639 namespace llvm {
2740
28 class Error;
29 class ErrorList;
3041 class ErrorSuccess;
3142
3243 /// Base class for error info classes. Do not extend this directly: Extend
3344 /// the ErrorInfo template subclass instead.
3445 class ErrorInfoBase {
3546 public:
36 virtual ~ErrorInfoBase() {}
47 virtual ~ErrorInfoBase() = default;
3748
3849 /// Print an error message to an output stream.
3950 virtual void log(raw_ostream &OS) const = 0;
6879
6980 private:
7081 virtual void anchor();
82
7183 static char ID;
7284 };
7385
137149 /// they're moved-assigned or constructed from Success values that have already
138150 /// been checked. This enforces checking through all levels of the call stack.
139151 class LLVM_NODISCARD Error {
140
141152 // ErrorList needs to be able to yank ErrorInfoBase pointers out of this
142153 // class to add to the error list.
143154 friend class ErrorList;
314325 /// Special ErrorInfo subclass representing a list of ErrorInfos.
315326 /// Instances of this class are constructed by joinError.
316327 class ErrorList final : public ErrorInfo {
317
318328 // handleErrors needs to be able to iterate the payload list of an
319329 // ErrorList.
320330 template
600610 if (Err)
601611 (void)!!*Err;
602612 }
613
603614 ~ErrorAsOutParameter() {
604615 // Clear the checked bit.
605616 if (Err && !*Err)
853864 /// std::error_codes.
854865 class ECError : public ErrorInfo {
855866 friend Error errorCodeToError(std::error_code);
867
856868 public:
857869 void setErrorCode(std::error_code EC) { this->EC = EC; }
858870 std::error_code convertToErrorCode() const override { return EC; }
864876 protected:
865877 ECError() = default;
866878 ECError(std::error_code EC) : EC(EC) {}
879
867880 std::error_code EC;
868881 };
869882
906919 class StringError : public ErrorInfo {
907920 public:
908921 static char ID;
922
909923 StringError(const Twine &S, std::error_code EC);
924
910925 void log(raw_ostream &OS) const override;
911926 std::error_code convertToErrorCode() const override;
927
912928 private:
913929 std::string Msg;
914930 std::error_code EC;
968984 LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err,
969985 bool gen_crash_diag = true);
970986
971 } // namespace llvm
987 } // end namespace llvm
972988
973989 #endif // LLVM_SUPPORT_ERROR_H
3131 #include "llvm/ADT/StringRef.h"
3232 #include "llvm/ADT/Twine.h"
3333 #include "llvm/Support/Chrono.h"
34 #include "llvm/Support/DataTypes.h"
3534 #include "llvm/Support/ErrorHandling.h"
3635 #include "llvm/Support/ErrorOr.h"
3736 #include
124123 public:
125124 UniqueID() = default;
126125 UniqueID(uint64_t Device, uint64_t File) : Device(Device), File(File) {}
126
127127 bool operator==(const UniqueID &Other) const {
128128 return Device == Other.Device && File == Other.File;
129129 }
131131 bool operator<(const UniqueID &Other) const {
132132 return std::tie(Device, File) < std::tie(Other.Device, Other.File);
133133 }
134
134135 uint64_t getDevice() const { return Device; }
135136 uint64_t getFile() const { return File; }
136137 };
673674 /// This class represents a memory mapped file. It is based on
674675 /// boost::iostreams::mapped_file.
675676 class mapped_file_region {
676 mapped_file_region() = delete;
677 mapped_file_region(mapped_file_region&) = delete;
678 mapped_file_region &operator =(mapped_file_region&) = delete;
679
680677 public:
681678 enum mapmode {
682679 readonly, ///< May only access map via const_data as read only.
692689 std::error_code init(int FD, uint64_t Offset, mapmode Mode);
693690
694691 public:
692 mapped_file_region() = delete;
693 mapped_file_region(mapped_file_region&) = delete;
694 mapped_file_region &operator =(mapped_file_region&) = delete;
695
695696 /// \param fd An open file descriptor to map. mapped_file_region takes
696697 /// ownership if closefd is true. It must have been opended in the correct
697698 /// mode.
732733 : Path(path.str())
733734 , Status(st) {}
734735
735 directory_entry() {}
736 directory_entry() = default;
736737
737738 void assign(const Twine &path, file_status st = file_status()) {
738739 Path = path.str();
830831 : Level(0)
831832 , HasNoPushRequest(false) {}
832833
833 std::stack > Stack;
834 std::stack> Stack;
834835 uint16_t Level;
835836 bool HasNoPushRequest;
836837 };
842843 IntrusiveRefCntPtr State;
843844
844845 public:
845 recursive_directory_iterator() {}
846 recursive_directory_iterator() = default;
846847 explicit recursive_directory_iterator(const Twine &path, std::error_code &ec)
847848 : State(new detail::RecDirIterState) {
848849 State->Stack.push(directory_iterator(path, ec));
849850 if (State->Stack.top() == directory_iterator())
850851 State.reset();
851852 }
853
852854 // No operator++ because we need error_code.
853855 recursive_directory_iterator &increment(std::error_code &ec) {
854856 const directory_iterator end_itr;
2525 #ifndef LLVM_SUPPORT_FORMATVARIADIC_H
2626 #define LLVM_SUPPORT_FORMATVARIADIC_H
2727
28 #include "llvm/ADT/Optional.h"
29 #include "llvm/ADT/SmallString.h"
2830 #include "llvm/ADT/STLExtras.h"
29 #include "llvm/ADT/SmallString.h"
3031 #include "llvm/ADT/StringRef.h"
31 #include "llvm/Support/DataTypes.h"
3232 #include "llvm/Support/FormatCommon.h"
3333 #include "llvm/Support/FormatProviders.h"
3434 #include "llvm/Support/FormatVariadicDetails.h"
3535 #include "llvm/Support/raw_ostream.h"
36
36 #include
3737 #include
3838 #include
39 #include
3940 #include
4041
4142 namespace llvm {
4344 enum class ReplacementType { Empty, Format, Literal };
4445
4546 struct ReplacementItem {
46 ReplacementItem() {}
47 ReplacementItem() = default;
4748 explicit ReplacementItem(StringRef Literal)
4849 : Type(ReplacementType::Literal), Spec(Literal) {}
4950 ReplacementItem(StringRef Spec, size_t Index, size_t Align, AlignStyle Where,
5051 char Pad, StringRef Options)
5152 : Type(ReplacementType::Format), Spec(Spec), Index(Index), Align(Align),
5253 Where(Where), Pad(Pad), Options(Options) {}
54
5355 ReplacementType Type = ReplacementType::Empty;
5456 StringRef Spec;
5557 size_t Index = 0;
8991 formatv_object_base(StringRef Fmt, std::size_t ParamCount)
9092 : Fmt(Fmt), Replacements(parseFormatString(Fmt)) {
9193 Wrappers.reserve(ParamCount);
92 return;
9394 }
9495
9596 void format(raw_ostream &S) const {
123124 return Result;
124125 }
125126
126 template llvm::SmallString sstr() const {
127 template SmallString sstr() const {
127128 SmallString Result;
128129 raw_svector_ostream Stream(Result);
129130 Stream << *this;
242243
243244 } // end namespace llvm
244245
245 #endif
246 #endif // LLVM_SUPPORT_FORMATVARIADIC_H
4545 mutable const ManagedStaticBase *Next;
4646
4747 void RegisterManagedStatic(void *(*creator)(), void (*deleter)(void*)) const;
48
4849 public:
4950 /// isConstructed - Return true if this object has not been created yet.
5051 bool isConstructed() const { return Ptr != nullptr; }
8889 /// llvm_shutdown_obj - This is a simple helper class that calls
8990 /// llvm_shutdown() when it is destroyed.
9091 struct llvm_shutdown_obj {
91 llvm_shutdown_obj() { }
92 llvm_shutdown_obj() = default;
9293 ~llvm_shutdown_obj() { llvm_shutdown(); }
9394 };
9495
95 }
96 } // end namespace llvm
9697
97 #endif
98 #endif // LLVM_SUPPORT_MANAGEDSTATIC_H
1313 #ifndef LLVM_SUPPORT_MEMORYBUFFER_H
1414 #define LLVM_SUPPORT_MEMORYBUFFER_H
1515
16 #include "llvm/ADT/StringRef.h"
1617 #include "llvm/ADT/Twine.h"
1718 #include "llvm/Support/CBindingWrapping.h"
18 #include "llvm/Support/DataTypes.h"
1919 #include "llvm/Support/ErrorOr.h"
20 #include "llvm-c/Types.h"
2021 #include
22 #include
23 #include
2124
2225 namespace llvm {
26
2327 class MemoryBufferRef;
2428
2529 /// This interface provides simple read-only access to a block of memory, and
3640 const char *BufferStart; // Start of the buffer.
3741 const char *BufferEnd; // End of the buffer.
3842
39 MemoryBuffer(const MemoryBuffer &) = delete;
40 MemoryBuffer &operator=(const MemoryBuffer &) = delete;
43
4144 protected:
42 MemoryBuffer() {}
45 MemoryBuffer() = default;
46
4347 void init(const char *BufStart, const char *BufEnd,
4448 bool RequiresNullTerminator);
4549 public:
50 MemoryBuffer(const MemoryBuffer &) = delete;
51 MemoryBuffer &operator=(const MemoryBuffer &) = delete;
4652 virtual ~MemoryBuffer();
4753
4854 const char *getBufferStart() const { return BufferStart; }
153159 StringRef Identifier;
154160
155161 public:
156 MemoryBufferRef() {}
162 MemoryBufferRef() = default;
157163 MemoryBufferRef(MemoryBuffer& Buffer)
158164 : Buffer(Buffer.getBuffer()), Identifier(Buffer.getBufferIdentifier()) {}
159165 MemoryBufferRef(StringRef Buffer, StringRef Identifier)
173179
174180 } // end namespace llvm
175181
176 #endif
182 #endif // LLVM_SUPPORT_MEMORYBUFFER_H
1010 #define LLVM_SUPPORT_YAMLTRAITS_H
1111
1212 #include "llvm/ADT/Optional.h"
13 #include "llvm/ADT/STLExtras.h"
1413 #include "llvm/ADT/SmallVector.h"
1514 #include "llvm/ADT/StringMap.h"
1615 #include "llvm/ADT/StringRef.h"
17 #include "llvm/ADT/StringSwitch.h"
1816 #include "llvm/ADT/Twine.h"
19 #include "llvm/Support/Compiler.h"
17 #include "llvm/Support/AlignOf.h"
18 #include "llvm/Support/Allocator.h"
2019 #include "llvm/Support/Endian.h"
2120 #include "llvm/Support/Regex.h"
2221 #include "llvm/Support/SourceMgr.h"
2322 #include "llvm/Support/YAMLParser.h"
2423 #include "llvm/Support/raw_ostream.h"
24 #include
25 #include
26 #include
27 #include
28 #include
29 #include
30 #include
2531 #include
32 #include
33 #include
2634
2735 namespace llvm {
2836 namespace yaml {
138146 //static bool mustQuote(StringRef);
139147 };
140148
141
142149 /// This class should be specialized by type that requires custom conversion
143150 /// to/from a YAML literal block scalar. For example:
144151 ///
171178 /// to/from a YAML sequence. For example:
172179 ///
173180 /// template<>
174 /// struct SequenceTraits< std::vector > {
181 /// struct SequenceTraits< std::vector> {
175182 /// static size_t size(IO &io, std::vector &seq) {
176183 /// return seq.size();
177184 /// }
219226
220227 public:
221228 static bool const value =
222 (sizeof(test >(nullptr)) == 1);
229 (sizeof(test>(nullptr)) == 1);
223230 };
224231
225232 // Test if ScalarBitSetTraits is defined on type T.
235242 static double test(...);
236243
237244 public:
238 static bool const value = (sizeof(test >(nullptr)) == 1);
245 static bool const value = (sizeof(test>(nullptr)) == 1);
239246 };
240247
241248 // Test if ScalarTraits is defined on type T.
347354 static double test(...);
348355
349356 public:
350 static bool const value = (sizeof(test >(nullptr)) == 1);
357 static bool const value = (sizeof(test>(nullptr)) == 1);
351358 };
352359
353360 // has_FlowTraits will cause an error with some compilers because
397404 static double test(...);
398405
399406 public:
400 static bool const value = (sizeof(test >(nullptr))==1);
407 static bool const value = (sizeof(test>(nullptr))==1);
401408 };
402409
403410 inline bool isNumber(StringRef S) {
502509 // Base class for Input and Output.
503510 class IO {
504511 public:
505
506512 IO(void *Ctxt=nullptr);
507513 virtual ~IO();
508514
700706 };
701707
702708 namespace detail {
709
703710 template
704711 void doMapping(IO &io, T &Val, Context &Ctx) {
705712 MappingContextTraits::mapping(io, Val, Ctx);
708715 template void doMapping(IO &io, T &Val, EmptyContext &Ctx) {
709716 MappingTraits::mapping(io, Val);
710717 }
711 }
718
719 } // end namespace detail
712720
713721 template
714722 typename std::enable_if::value, void>::type
949957 llvm::raw_ostream &Stream) {
950958 ScalarTraits::output(static_cast(E), Ctx, Stream);
951959 }
960
952961 static StringRef input(StringRef Str, void *Ctx, endian_type &E) {
953962 value_type V;
954963 auto R = ScalarTraits::input(Str, Ctx, V);
10881097
10891098 class HNode {
10901099 virtual void anchor();
1100
10911101 public:
10921102 HNode(Node *n) : _node(n) { }
1093 virtual ~HNode() { }
1103 virtual ~HNode() = default;
1104
10941105 static inline bool classof(const HNode *) { return true; }
10951106
10961107 Node *_node;
10981109
10991110 class EmptyHNode : public HNode {
11001111 void anchor() override;
1112
11011113 public:
11021114 EmptyHNode(Node *n) : HNode(n) { }
1115
11031116 static inline bool classof(const HNode *n) {
11041117 return NullNode::classof(n->_node);
11051118 }
1119
11061120 static inline bool classof(const EmptyHNode *) { return true; }
11071121 };
11081122
11091123 class ScalarHNode : public HNode {
11101124 void anchor() override;
1125
11111126 public:
11121127 ScalarHNode(Node *n, StringRef s) : HNode(n), _value(s) { }
11131128
11171132 return ScalarNode::classof(n->_node) ||
11181133 BlockScalarNode::classof(n->_node);
11191134 }
1135
11201136 static inline bool classof(const ScalarHNode *) { return true; }
1137
11211138 protected:
11221139 StringRef _value;
11231140 };
11311148 static inline bool classof(const HNode *n) {
11321149 return MappingNode::classof(n->_node);
11331150 }
1151
11341152 static inline bool classof(const MapHNode *) { return true; }
11351153
11361154 typedef llvm::StringMap> NameToNode;
11501168 static inline bool classof(const HNode *n) {
11511169 return SequenceNode::classof(n->_node);
11521170 }
1171
11531172 static inline bool classof(const SequenceHNode *) { return true; }
11541173
11551174 std::vector> Entries;
12161235 void blockScalarString(StringRef &) override;
12171236 void setError(const Twine &message) override;
12181237 bool canElideEmptySequence() override;
1219 public:
1238
12201239 // These are only used by operator<<. They could be private
12211240 // if that templated operator could be made a friend.
12221241 void beginDocuments();
12631282 /// Based on BOOST_STRONG_TYPEDEF
12641283 #define LLVM_YAML_STRONG_TYPEDEF(_base, _type) \
12651284 struct _type { \
1266 _type() { } \
1267 _type(const _base v) : value(v) { } \
1268 _type(const _type &v) : value(v.value) {} \
1269 _type &operator=(const _type &rhs) { value = rhs.value; return *this; }\
1285 _type() = default; \
1286 _type(const _base v) : value(v) {} \
1287 _type(const _type &v) = default; \
1288 _type &operator=(const _type &rhs) = default; \
12701289 _type &operator=(const _base &rhs) { value = rhs; return *this; } \
12711290 operator const _base & () const { return value; } \
12721291 bool operator==(const _type &rhs) const { return value == rhs.value; } \
14561475 }
14571476 };
14581477
1459 } // namespace yaml
1460 } // namespace llvm
1478 } // end namespace yaml
1479 } // end namespace llvm
14611480
14621481 /// Utility for declaring that a std::vector of a particular type
14631482 /// should be considered a YAML sequence.
1515
1616 #include "llvm/ADT/SmallVector.h"
1717 #include "llvm/ADT/StringRef.h"
18 #include "llvm/Support/DataTypes.h"
18 #include
19 #include
20 #include
21 #include
22 #include
1923 #include
2024
2125 namespace llvm {
26
2227 class formatv_object_base;
2328 class format_object_base;
2429 class FormattedString;
2530 class FormattedNumber;
2631 class FormattedBytes;
27 template class SmallVectorImpl;
2832
2933 namespace sys {
3034 namespace fs {
3135 enum OpenFlags : unsigned;
32 }
33 }
36 } // end namespace fs
37 } // end namespace sys
3438
3539 /// This class implements an extremely fast bulk output stream that can *only*
3640 /// output to a stream. It does not support seeking, reopening, rewinding, line
3842 /// a chunk at a time.
3943 class raw_ostream {
4044 private:
41 void operator=(const raw_ostream &) = delete;
42 raw_ostream(const raw_ostream &) = delete;
43
4445 /// The buffer is handled in such a way that the buffer is
4546 /// uninitialized, unbuffered, or out of space when OutBufCur >=
4647 /// OutBufEnd. Thus a single comparison suffices to determine if we
7071 public:
7172 // color order matches ANSI escape sequence, don't change
7273 enum Colors {
73 BLACK=0,
74 BLACK = 0,
7475 RED,
7576 GREEN,
7677 YELLOW,
8788 OutBufStart = OutBufEnd = OutBufCur = nullptr;
8889 }
8990
91 raw_ostream(const raw_ostream &) = delete;
92 void operator=(const raw_ostream &) = delete;
93
9094 virtual ~raw_ostream();
9195
9296 /// tell - Return the current offset with the file.
185189 return write(Str.data(), Str.length());
186190 }
187191
188 raw_ostream &operator<<(const llvm::SmallVectorImpl &Str) {
192 raw_ostream &operator<<(const SmallVectorImpl &Str) {
189193 return write(Str.data(), Str.size());
190194 }
191195
194198 raw_ostream &operator<<(unsigned long long N);
195199 raw_ostream &operator<<(long long N);
196200 raw_ostream &operator<<(const void *P);
201
197202 raw_ostream &operator<<(unsigned int N) {
198203 return this->operator<<(static_cast(N));
199204 }
500505 explicit raw_svector_ostream(SmallVectorImpl &O) : OS(O) {
501506 SetUnbuffered();
502507 }
503 ~raw_svector_ostream() override {}
508
509 ~raw_svector_ostream() override = default;
504510
505511 void flush() = delete;
506512
519525 uint64_t current_pos() const override;
520526
521527 public:
522 explicit raw_null_ostream() {}
528 explicit raw_null_ostream() = default;
523529 ~raw_null_ostream() override;
524530 };
525531
532538 ~buffer_ostream() override { OS << str(); }
533539 };
534540
535 } // end llvm namespace
541 } // end namespace llvm
536542
537543 #endif // LLVM_SUPPORT_RAW_OSTREAM_H
1717 #include "llvm/ADT/ArrayRef.h"
1818 #include "llvm/ADT/FoldingSet.h"
1919 #include "llvm/ADT/PointerIntPair.h"
20 #include "llvm/ADT/SmallVector.h"
21 #include "llvm/ADT/StringRef.h"
2022 #include "llvm/Support/Casting.h"
21 #include "llvm/Support/DataTypes.h"
2223 #include "llvm/Support/ErrorHandling.h"
2324 #include "llvm/Support/SMLoc.h"
2425 #include "llvm/Support/TrailingObjects.h"
2526 #include "llvm/Support/raw_ostream.h"
27 #include
28 #include
29 #include
30 #include
2631 #include
32 #include
33 #include
34 #include
35 #include
2736
2837 namespace llvm {
2938
5665 std::unique_ptr ListTy;
5766
5867 public:
68 RecTy(RecTyKind K) : Kind(K) {}
69 virtual ~RecTy() = default;
70
5971 RecTyKind getRecTyKind() const { return Kind; }
60
61 RecTy(RecTyKind K) : Kind(K) {}
62 virtual ~RecTy() {}
6372
6473 virtual std::string getAsString() const = 0;
6574 void print(raw_ostream &OS) const { OS << getAsString(); }
8291 ///
8392 class BitRecTy : public RecTy {
8493 static BitRecTy Shared;
94
8595 BitRecTy() : RecTy(BitRecTyKind) {}
8696
8797 public:
100110 ///
101111 class BitsRecTy : public RecTy {
102112 unsigned Size;
113
103114 explicit BitsRecTy(unsigned Sz) : RecTy(BitsRecTyKind), Size(Sz) {}
104115
105116 public:
120131 ///
121132 class CodeRecTy : public RecTy {
122133 static CodeRecTy Shared;
134
123135 CodeRecTy() : RecTy(CodeRecTyKind) {}
124136
125137 public:
136148 ///
137149 class IntRecTy : public RecTy {
138150 static IntRecTy Shared;
151
139152 IntRecTy() : RecTy(IntRecTyKind) {}
140153
141154 public:
154167 ///
155168 class StringRecTy : public RecTy {
156169 static StringRecTy Shared;
170
157171 StringRecTy() : RecTy(StringRecTyKind) {}
158172
159173 public:
172186 ///
173187 class ListRecTy : public RecTy {
174188 RecTy *Ty;
189
175190 explicit ListRecTy(RecTy *T) : RecTy(ListRecTyKind), Ty(T) {}
191
176192 friend ListRecTy *RecTy::getListTy();
177193
178194 public:
192208 ///
193209 class DagRecTy : public RecTy {
194210 static DagRecTy Shared;
211
195212 DagRecTy() : RecTy(DagRecTyKind) {}
196213
197214 public:
209226 ///
210227 class RecordRecTy : public RecTy {
211228 Record *Rec;
229
212230 explicit RecordRecTy(Record *R) : RecTy(RecordRecTyKind), Rec(R) {}
231
213232 friend class Record;
214233
215234 public:
275294
276295 private:
277296 const InitKind Kind;
297
278298 protected:
279299 uint8_t Opc; // Used by UnOpInit, BinOpInit, and TernOpInit
300
280301 private:
302 virtual void anchor();
303
304 public:
305 InitKind getKind() const { return Kind; }
306
307 protected:
308 explicit Init(InitKind K, uint8_t Opc = 0) : Kind(K), Opc(Opc) {}
309
310 public:
281311 Init(const Init &) = delete;
282312 Init &operator=(const Init &) = delete;
283 virtual void anchor();
284
285 public:
286 InitKind getKind() const { return Kind; }
287
288 protected:
289 explicit Init(InitKind K, uint8_t Opc = 0) : Kind(K), Opc(Opc) {}
290
291 public:
292 virtual ~Init() {}
313 virtual ~Init() = default;
293314
294315 /// This virtual method should be overridden by values that may
295316 /// not be completely specified yet.
383404 class TypedInit : public Init {
384405 RecTy *Ty;
385406
386 TypedInit(const TypedInit &Other) = delete;
387 TypedInit &operator=(const TypedInit &Other) = delete;
388
389407 protected:
390408 explicit TypedInit(InitKind K, RecTy *T, uint8_t Opc = 0)
391409 : Init(K, Opc), Ty(T) {}
396414 }
397415
398416 public:
417 TypedInit(const TypedInit &Other) = delete;
418 TypedInit &operator=(const TypedInit &Other) = delete;
419
399420 static bool classof(const Init *I) {
400421 return I->getKind() >= IK_FirstTypedInit &&
401422 I->getKind() <= IK_LastTypedInit;
402423 }
424
403425 RecTy *getType() const { return Ty; }
404426
405427 Init *convertInitializerTo(RecTy *Ty) const override;
426448 ///
427449 class UnsetInit : public Init {
428450 UnsetInit() : Init(IK_UnsetInit) {}
451
452 public:
429453 UnsetInit(const UnsetInit &) = delete;
430454 UnsetInit &operator=(const UnsetInit &Other) = delete;
431455
432 public:
433456 static bool classof(const Init *I) {
434457 return I->getKind() == IK_UnsetInit;
435458 }
459
436460 static UnsetInit *get();
437461
438462 Init *convertInitializerTo(RecTy *Ty) const override;
451475 bool Value;
452476
453477 explicit BitInit(bool V) : Init(IK_BitInit), Value(V) {}
478
479 public:
454480 BitInit(const BitInit &Other) = delete;
455481 BitInit &operator=(BitInit &Other) = delete;
456482
457 public:
458483 static bool classof(const Init *I) {
459484 return I->getKind() == IK_BitInit;
460485 }
486
461487 static BitInit *get(bool V);
462488
463489 bool getValue() const { return Value; }
482508 BitsInit(unsigned N)
483509 : TypedInit(IK_BitsInit, BitsRecTy::get(N)), NumBits(N) {}
484510
511 public:
485512 BitsInit(const BitsInit &Other) = delete;
486513 BitsInit &operator=(const BitsInit &Other) = delete;
487514
488 public:
489515 // Do not use sized deallocation due to trailing objects.
490516 void operator delete(void *p) { ::operator delete(p); }
491517
492518 static bool classof(const Init *I) {
493519 return I->getKind() == IK_BitsInit;
494520 }
521
495522 static BitsInit *get(ArrayRef Range);
496523
497524 void Profile(FoldingSetNodeID &ID) const;
507534 if (!getBit(i)->isComplete()) return false;
508535 return true;
509536 }
537
510538 bool allInComplete() const {
511539 for (unsigned i = 0; i != getNumBits(); ++i)
512540 if (getBit(i)->isComplete()) return false;
513541 return true;
514542 }
543
515544 std::string getAsString() const override;
516545
517546 /// This method is used to implement
538567 explicit IntInit(int64_t V)
539568 : TypedInit(IK_IntInit, IntRecTy::get()), Value(V) {}
540569
570 public:
541571 IntInit(const IntInit &Other) = delete;
542572 IntInit &operator=(const IntInit &Other) = delete;
543573
544 public:
545574 static bool classof(const Init *I) {
546575 return I->getKind() == IK_IntInit;
547576 }
577
548578 static IntInit *get(int64_t V);
549579
550580 int64_t getValue() const { return Value; }
576606 explicit StringInit(StringRef V)
577607 : TypedInit(IK_StringInit, StringRecTy::get()), Value(V) {}
578608
609 public:
579610 StringInit(const StringInit &Other) = delete;
580611 StringInit &operator=(const StringInit &Other) = delete;
581612
582 public:
583613 static bool classof(const Init *I) {
584614 return I->getKind() == IK_StringInit;
585615 }
616
586617 static StringInit *get(StringRef);
587618
588619 const std::string &getValue() const { return Value; }
613644 : TypedInit(IK_CodeInit, static_cast(CodeRecTy::get())),
614645 Value(V) {}
615646
647 public:
616648 CodeInit(const StringInit &Other) = delete;
617649 CodeInit &operator=(const StringInit &Other) = delete;
618650
619 public:
620651 static bool classof(const Init *I) {
621652 return I->getKind() == IK_CodeInit;
622653 }
654
623655 static CodeInit *get(StringRef);
624656
625657 const std::string &getValue() const { return Value; }
658690 explicit ListInit(unsigned N, RecTy *EltTy)
659691 : TypedInit(IK_ListInit, ListRecTy::get(EltTy)), NumValues(N) {}
660692
693 public:
661694 ListInit(const ListInit &Other) = delete;
662695 ListInit &operator=(const ListInit &Other) = delete;
663696
664 public:
665697 // Do not use sized deallocation due to trailing objects.
666698 void operator delete(void *p) { ::operator delete(p); }
667699
717749 /// Base class for operators
718750 ///
719751 class OpInit : public TypedInit {
720 OpInit(const OpInit &Other) = delete;
721 OpInit &operator=(OpInit &Other) = delete;
722
723752 protected:
724753 explicit OpInit(InitKind K, RecTy *Type, uint8_t Opc)
725754 : TypedInit(K, Type, Opc) {}
726755
727756 public:
757 OpInit(const OpInit &Other) = delete;
758 OpInit &operator=(OpInit &Other) = delete;
759
728760 static bool classof(const Init *I) {
729761 return I->getKind() >= IK_FirstOpInit &&
730762 I->getKind() <= IK_LastOpInit;
731763 }
764
732765 // Clone - Clone this operator, replacing arguments with the new list
733766 virtual OpInit *clone(std::vector &Operands) const = 0;
734767
757790 UnOpInit(UnaryOp opc, Init *lhs, RecTy *Type)
758791 : OpInit(IK_UnOpInit, Type, opc), LHS(lhs) {}
759792
793 public:
760794 UnOpInit(const UnOpInit &Other) = delete;
761795 UnOpInit &operator=(const UnOpInit &Other) = delete;
762796
763 public:
764797 static bool classof(const Init *I) {
765798 return I->getKind() == IK_UnOpInit;
766799 }
800
767801 static UnOpInit *get(UnaryOp opc, Init *lhs, RecTy *Type);
768802
769803 void Profile(FoldingSetNodeID &ID) const;
776810 }
777811
778812 unsigned getNumOperands() const override { return 1; }
813
779814 Init *getOperand(unsigned i) const override {
780815 assert(i == 0 && "Invalid operand id for unary operator");
781816 return getOperand();
806841 BinOpInit(BinaryOp opc, Init *lhs, Init *rhs, RecTy *Type) :
807842 OpInit(IK_BinOpInit, Type, opc), LHS(lhs), RHS(rhs) {}
808843
844 public:
809845 BinOpInit(const BinOpInit &Other) = delete;
810846 BinOpInit &operator=(const BinOpInit &Other) = delete;
811847
812 public:
813848 static bool classof(const Init *I) {
814849 return I->getKind() == IK_BinOpInit;
815850 }
851
816852 static BinOpInit *get(BinaryOp opc, Init *lhs, Init *rhs,
817853 RecTy *Type);
818854
860896 RecTy *Type) :
861897 OpInit(IK_TernOpInit, Type, opc), LHS(lhs), MHS(mhs), RHS(rhs) {}
862898
899 public:
863900 TernOpInit(const TernOpInit &Other) = delete;
864901 TernOpInit &operator=(const TernOpInit &Other) = delete;
865902
866 public:
867903 static bool classof(const Init *I) {
868904 return I->getKind() == IK_TernOpInit;
869905 }
906
870907 static TernOpInit *get(TernaryOp opc, Init *lhs,
871908 Init *mhs, Init *rhs,
872909 RecTy *Type);
915952 explicit VarInit(Init *VN, RecTy *T)
916953 : TypedInit(IK_VarInit, T), VarName(VN) {}
917954
955 public:
918956 VarInit(const VarInit &Other) = delete;
919957 VarInit &operator=(const VarInit &Other) = delete;
920958
921 public:
922959 static bool classof(const Init *I) {
923960 return I->getKind() == IK_VarInit;
924961 }
962
925963 static VarInit *get(const std::string &VN, RecTy *T);
926964 static VarInit *get(Init *VN, RecTy *T);
927965
928966 const std::string &getName() const;
929967 Init *getNameInit() const { return VarName; }
968
930969 std::string getNameInitAsString() const {
931970 return getNameInit()->getAsUnquotedString();
932971 }
9641003 "Illegal VarBitInit expression!");
9651004 }
9661005
1006 public:
9671007 VarBitInit(const VarBitInit &Other) = delete;
9681008 VarBitInit &operator=(const VarBitInit &Other) = delete;
9691009
970 public:
9711010 static bool classof(const Init *I) {
9721011 return I->getKind() == IK_VarBitInit;
9731012 }
1013
9741014 static VarBitInit *get(TypedInit *T, unsigned B);
9751015
9761016 Init *convertInitializerTo(RecTy *Ty) const override;
10011041 "Illegal VarBitInit expression!");
10021042 }
10031043
1044 public:
10041045 VarListElementInit(const VarListElementInit &Other) = delete;
10051046 void operator=(const VarListElementInit &Other) = delete;
10061047
1007 public:
10081048 static bool classof(const Init *I) {
10091049 return I->getKind() == IK_VarListElementInit;
10101050 }
1051
10111052 static VarListElementInit *get(TypedInit *T, unsigned E);
10121053
10131054 TypedInit *getVariable() const { return TI; }
10311072 Record *Def;
10321073
10331074 DefInit(Record *D, RecordRecTy *T) : TypedInit(IK_DefInit, T), Def(D) {}
1075
10341076 friend class Record;
10351077
1078 public:
10361079 DefInit(const DefInit &Other) = delete;
10371080 DefInit &operator=(const DefInit &Other) = delete;
10381081
1039 public:
10401082 static bool classof(const Init *I) {
10411083 return I->getKind() == IK_DefInit;
10421084 }
1085
10431086 static DefInit *get(Record*);
10441087
10451088 Init *convertInitializerTo(RecTy *Ty) const override;
10781121 assert(getType() && "FieldInit with non-record type!");
10791122 }
10801123
1124 public:
10811125 FieldInit(const FieldInit &Other) = delete;
10821126 FieldInit &operator=(const FieldInit &Other) = delete;
10831127
1084 public:
10851128 static bool classof(const Init *I) {
10861129 return I->getKind() == IK_FieldInit;
10871130 }
1131
10881132 static FieldInit *get(Init *R, const std::string &FN);
10891133
10901134 Init *getBit(unsigned Bit) const override;
11161160 Args(ArgRange.begin(), ArgRange.end()),
11171161 ArgNames(NameRange.begin(), NameRange.end()) {}
11181162
1163 public:
11191164 DagInit(const DagInit &Other) = delete;
11201165 DagInit &operator=(const DagInit &Other) = delete;
11211166
1122 public:
11231167 static bool classof(const Init *I) {
11241168 return I->getKind() == IK_DagInit;
11251169 }
1170
11261171 static DagInit *get(Init *V, const std::string &VN,
11271172 ArrayRef ArgRange,
11281173 ArrayRef NameRange);
11291174 static DagInit *get(Init *V, const std::string &VN,
1130 const std::vector<
1131 std::pair > &args);
1175 const std::vector> &args);
11321176
11331177 void Profile(FoldingSetNodeID &ID) const;
11341178
11921236
11931237 const std::string &getName() const;
11941238 const Init *getNameInit() const { return NameAndPrefix.getPointer(); }
1239
11951240 std::string getNameInitAsString() const {
11961241 return getNameInit()->getAsUnquotedString();
11971242 }
12621307 ID(LastID++), IsAnonymous(Anonymous), ResolveFirst(false) {
12631308 init();
12641309 }
1310
12651311 explicit Record(const std::string &N, ArrayRef locs,
12661312 RecordKeeper &records, bool Anonymous = false)
12671313 : Record(StringInit::get(N), locs, records, Anonymous) {}
1268
12691314
12701315 // When copy-constructing a Record, we must still guarantee a globally unique
12711316 // ID number. Don't copy TheInit either since it's owned by the original
12841329 Init *getNameInit() const {
12851330 return Name;
12861331 }
1332
12871333 const std::string getNameInitAsString() const {
12881334 return getNameInit()->getAsUnquotedString();
12891335 }
12991345 ArrayRef getTemplateArgs() const {
13001346 return TemplateArgs;
13011347 }
1348
13021349 ArrayRef getValues() const { return Values; }
1350
13031351 ArrayRef> getSuperClasses() const {
13041352 return SuperClasses;
13051353 }
13091357 if (TA == Name) return true;
13101358 return false;
13111359 }
1360
13121361 bool isTemplateArg(StringRef Name) const {
13131362 return isTemplateArg(StringInit::get(Name));
13141363 }
13181367 if (Val.getNameInit() == Name) return &Val;
13191368 return nullptr;
13201369 }
1370
13211371 const RecordVal *getValue(StringRef Name) const {
13221372 return getValue(StringInit::get(Name));
13231373 }
1374
13241375 RecordVal *getValue(const Init *Name) {
13251376 for (RecordVal &Val : Values)
13261377 if (Val.getNameInit() == Name) return &Val;
13271378 return nullptr;
13281379 }
1380
13291381 RecordVal *getValue(StringRef Name) {
13301382 return getValue(StringInit::get(Name));
13311383 }
13341386 assert(!isTemplateArg(Name) && "Template arg already defined!");
13351387 TemplateArgs.push_back(Name);
13361388 }
1389
13371390 void addTemplateArg(StringRef Name) {
13381391 addTemplateArg(StringInit::get(Name));
13391392 }
15211574 auto I = Classes.find(Name);
15221575 return I == Classes.end() ? nullptr : I->second.get();
15231576 }
1577
15241578 Record *getDef(const std::string &Name) const {
15251579 auto I = Defs.find(Name);
15261580 return I == Defs.end() ? nullptr : I->second.get();
15271581 }
1582
15281583 void addClass(std::unique_ptr R) {
15291584 bool Ins = Classes.insert(std::make_pair(R->getName(),
15301585 std::move(R))).second;
15311586 (void)Ins;
15321587 assert(Ins && "Class already exists");
15331588 }
1589
15341590 void addDef(std::unique_ptr R) {
15351591 bool Ins = Defs.insert(std::make_pair(R->getName(),
15361592 std::move(R))).second;
16681724 Init *QualifyName(Record &CurRec, MultiClass *CurMultiClass,
16691725 const std::string &Name, const std::string &Scoper);
16701726
1671 } // end llvm namespace
1727 } // end namespace llvm
16721728
16731729 #endif // LLVM_TABLEGEN_RECORD_H
4949 #include "llvm/ADT/ArrayRef.h"
5050 #include "llvm/ADT/SetVector.h"
5151 #include "llvm/ADT/StringMap.h"
52 #include "llvm/ADT/StringRef.h"
5253 #include "llvm/Support/SMLoc.h"
5354 #include
55 #include
5456 #include
5557
5658 namespace llvm {
6769 /// Operator - A callback representing a DAG operator.
6870 class Operator {
6971 virtual void anchor();
72
7073 public:
71 virtual ~Operator() {}
74 virtual ~Operator() = default;
7275
7376 /// apply - Apply this operator to Expr's arguments and insert the result
7477 /// in Elts.
7578 virtual void apply(SetTheory&, DagInit *Expr, RecSet &Elts,
76 ArrayRef Loc) =0;
79 ArrayRef Loc) = 0;
7780 };
7881
7982 /// Expander - A callback function that can transform a Record representing a
8184 /// users to define named sets that can be used in DAG expressions.
8285 class Expander {
8386 virtual void anchor();
87
8488 public:
85 virtual ~Expander() {}
89 virtual ~Expander() = default;
8690
87 virtual void expand(SetTheory&, Record*, RecSet &Elts) =0;
91 virtual void expand(SetTheory&, Record*, RecSet &Elts) = 0;
8892 };
8993
9094 private:
137141
138142 } // end namespace llvm
139143
140 #endif
141
144 #endif // LLVM_TABLEGEN_SETTHEORY_H