llvm.org GIT mirror llvm / dc6cb60
[IR] Fix some Clang-tidy modernize-use-using warnings; other minor fixes (NFC). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302744 91177308-0d34-0410-b5e6-96231b3b80d8 Eugene Zelenko 3 years ago
13 changed file(s) with 269 addition(s) and 153 deletion(s). Raw diff Collapse all Expand all
None //===-- llvm/DerivedTypes.h - Classes for handling data types ---*- C++ -*-===//
0 //===- llvm/DerivedTypes.h - Classes for handling data types ----*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
122122 bool isVarArg() const { return getSubclassData()!=0; }
123123 Type *getReturnType() const { return ContainedTys[0]; }
124124
125 typedef Type::subtype_iterator param_iterator;
125 using param_iterator = Type::subtype_iterator;
126
126127 param_iterator param_begin() const { return ContainedTys + 1; }
127128 param_iterator param_end() const { return &ContainedTys[NumContainedTys]; }
128129 ArrayRef params() const {
197198 /// generator for a target expects).
198199 ///
199200 class StructType : public CompositeType {
200 StructType(LLVMContext &C)
201 : CompositeType(C, StructTyID), SymbolTableEntry(nullptr) {}
201 StructType(LLVMContext &C) : CompositeType(C, StructTyID) {}
202202
203203 enum {
204204 /// This is the contents of the SubClassData field.
212212 /// symbol table entry (maintained by LLVMContext) for the struct.
213213 /// This is null if the type is an literal struct or if it is a identified
214214 /// type that has an empty name.
215 void *SymbolTableEntry;
215 void *SymbolTableEntry = nullptr;
216216
217217 public:
218218 StructType(const StructType &) = delete;
297297 static bool isValidElementType(Type *ElemTy);
298298
299299 // Iterator access to the elements.
300 typedef Type::subtype_iterator element_iterator;
300 using element_iterator = Type::subtype_iterator;
301
301302 element_iterator element_begin() const { return ContainedTys; }
302303 element_iterator element_end() const { return &ContainedTys[NumContainedTys];}
303304 ArrayRef const elements() const {
None //===-- llvm/Function.h - Class to represent a single function --*- C++ -*-===//
0 //===- llvm/Function.h - Class to represent a single function ---*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
2121 #include "llvm/ADT/ilist_node.h"
2222 #include "llvm/ADT/iterator_range.h"
2323 #include "llvm/ADT/StringRef.h"
24 #include "llvm/ADT/Twine.h"
2425 #include "llvm/IR/Argument.h"
2526 #include "llvm/IR/Attributes.h"
2627 #include "llvm/IR/BasicBlock.h"
2728 #include "llvm/IR/CallingConv.h"
29 #include "llvm/IR/DerivedTypes.h"
2830 #include "llvm/IR/GlobalObject.h"
31 #include "llvm/IR/GlobalValue.h"
2932 #include "llvm/IR/Intrinsics.h"
3033 #include "llvm/IR/OperandTraits.h"
3134 #include "llvm/IR/SymbolTableListTraits.h"
3235 #include "llvm/IR/Value.h"
36 #include "llvm/Support/Casting.h"
3337 #include "llvm/Support/Compiler.h"
3438 #include
3539 #include
3943
4044 namespace llvm {
4145
46 class AssemblyAnnotationWriter;
47 class Constant;
48 class DISubprogram;
49 class LLVMContext;
50 class Module;
4251 template class Optional;
43 class AssemblyAnnotationWriter;
44 class FunctionType;
45 class LLVMContext;
46 class DISubprogram;
52 class raw_ostream;
53 class Type;
54 class User;
4755
4856 class Function : public GlobalObject, public ilist_node {
4957 public:
50 typedef SymbolTableList BasicBlockListType;
58 using BasicBlockListType = SymbolTableList;
5159
5260 // BasicBlock iterators...
53 typedef BasicBlockListType::iterator iterator;
54 typedef BasicBlockListType::const_iterator const_iterator;
55
56 typedef Argument *arg_iterator;
57 typedef const Argument *const_arg_iterator;
61 using iterator = BasicBlockListType::iterator;
62 using const_iterator = BasicBlockListType::const_iterator;
63
64 using arg_iterator = Argument *;
65 using const_arg_iterator = const Argument *;
5866
5967 private:
6068 // Important things that make up a function!
61 BasicBlockListType BasicBlocks; ///< The basic blocks
62 mutable Argument *Arguments; ///< The formal arguments
69 BasicBlockListType BasicBlocks; ///< The basic blocks
70 mutable Argument *Arguments = nullptr; ///< The formal arguments
6371 size_t NumArgs;
6472 std::unique_ptr
6573 SymTab; ///< Symbol table of args/instructions
123131
124132 // Provide fast operand accessors.
125133 DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
134
126135 /// Returns the FunctionType for me.
127136 FunctionType *getFunctionType() const {
128137 return cast(getValueType());
129138 }
139
130140 /// Returns the type of the ret val.
131141 Type *getReturnType() const { return getFunctionType()->getReturnType(); }
132142
2020 #include "llvm/IR/Operator.h"
2121 #include "llvm/IR/User.h"
2222 #include "llvm/Support/Casting.h"
23 #include
2324 #include
25 #include
2426 #include
2527
2628 namespace llvm {
2830 template
2931 class generic_gep_type_iterator
3032 : public std::iterator {
31 typedef std::iterator
32 Type *, ptrdiff_t> super;
33 using super = std::iterator;
3334
3435 ItTy OpIt;
3536 PointerUnion CurTy;
3637 enum : uint64_t { Unbounded = -1ull };
3738 uint64_t NumElements = Unbounded;
39
3840 generic_gep_type_iterator() = default;
3941
4042 public:
120122 }
121123 };
122124
123 typedef generic_gep_type_iterator<> gep_type_iterator;
125 using gep_type_iterator = generic_gep_type_iterator<>;
124126
125127 inline gep_type_iterator gep_type_begin(const User *GEP) {
126128 auto *GEPOp = cast(GEP);
None //===-- llvm/Module.h - C++ class to represent a VM module ------*- C++ -*-===//
0 //===- llvm/Module.h - C++ class to represent a VM module -------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1515 #define LLVM_IR_MODULE_H
1616
1717 #include "llvm/ADT/iterator_range.h"
18 #include "llvm/ADT/STLExtras.h"
19 #include "llvm/ADT/StringMap.h"
20 #include "llvm/ADT/StringRef.h"
21 #include "llvm/IR/Attributes.h"
1822 #include "llvm/IR/Comdat.h"
1923 #include "llvm/IR/DataLayout.h"
2024 #include "llvm/IR/Function.h"
2226 #include "llvm/IR/GlobalIFunc.h"
2327 #include "llvm/IR/GlobalVariable.h"
2428 #include "llvm/IR/Metadata.h"
29 #include "llvm/IR/SymbolTableListTraits.h"
2530 #include "llvm/Support/CBindingWrapping.h"
2631 #include "llvm/Support/CodeGen.h"
27 #include "llvm/Support/DataTypes.h"
32 #include "llvm-c/Types.h"
33 #include
34 #include
35 #include
36 #include
37 #include
38 #include
2839
2940 namespace llvm {
30 template class Optional;
41
3142 class Error;
3243 class FunctionType;
3344 class GVMaterializer;
3445 class LLVMContext;
3546 class MemoryBuffer;
3647 class RandomNumberGenerator;
48 template class SmallPtrSetImpl;
3749 class StructType;
38 template class SmallPtrSetImpl;
3950
4051 /// A Module instance is used to store all the information related to an
4152 /// LLVM module. Modules are the top level container of all other LLVM
5364 /// @{
5465 public:
5566 /// The type for the list of global variables.
56 typedef SymbolTableList GlobalListType;
67 using GlobalListType = SymbolTableList;
5768 /// The type for the list of functions.
58 typedef SymbolTableList FunctionListType;
69 using FunctionListType = SymbolTableList;
5970 /// The type for the list of aliases.
60 typedef SymbolTableList AliasListType;
71 using AliasListType = SymbolTableList;
6172 /// The type for the list of ifuncs.
62 typedef SymbolTableList IFuncListType;
73 using IFuncListType = SymbolTableList;
6374 /// The type for the list of named metadata.
64 typedef ilist NamedMDListType;
75 using NamedMDListType = ilist;
6576 /// The type of the comdat "symbol" table.
66 typedef StringMap ComdatSymTabType;
77 using ComdatSymTabType = StringMap;
6778
6879 /// The Global Variable iterator.
69 typedef GlobalListType::iterator global_iterator;
80 using global_iterator = GlobalListType::iterator;
7081 /// The Global Variable constant iterator.
71 typedef GlobalListType::const_iterator const_global_iterator;
82 using const_global_iterator = GlobalListType::const_iterator;
7283
7384 /// The Function iterators.
74 typedef FunctionListType::iterator iterator;
85 using iterator = FunctionListType::iterator;
7586 /// The Function constant iterator
76 typedef FunctionListType::const_iterator const_iterator;
87 using const_iterator = FunctionListType::const_iterator;
7788
7889 /// The Function reverse iterator.
79 typedef FunctionListType::reverse_iterator reverse_iterator;
90 using reverse_iterator = FunctionListType::reverse_iterator;
8091 /// The Function constant reverse iterator.
81 typedef FunctionListType::const_reverse_iterator const_reverse_iterator;
92 using const_reverse_iterator = FunctionListType::const_reverse_iterator;
8293
8394 /// The Global Alias iterators.
84 typedef AliasListType::iterator alias_iterator;
95 using alias_iterator = AliasListType::iterator;
8596 /// The Global Alias constant iterator
86 typedef AliasListType::const_iterator const_alias_iterator;
97 using const_alias_iterator = AliasListType::const_iterator;
8798
8899 /// The Global IFunc iterators.
89 typedef IFuncListType::iterator ifunc_iterator;
100 using ifunc_iterator = IFuncListType::iterator;
90101 /// The Global IFunc constant iterator
91 typedef IFuncListType::const_iterator const_ifunc_iterator;
102 using const_ifunc_iterator = IFuncListType::const_iterator;
92103
93104 /// The named metadata iterators.
94 typedef NamedMDListType::iterator named_metadata_iterator;
105 using named_metadata_iterator = NamedMDListType::iterator;
95106 /// The named metadata constant iterators.
96 typedef NamedMDListType::const_iterator const_named_metadata_iterator;
107 using const_named_metadata_iterator = NamedMDListType::const_iterator;
97108
98109 /// This enumeration defines the supported behaviors of module flags.
99110 enum ModFlagBehavior {
140151 ModFlagBehavior Behavior;
141152 MDString *Key;
142153 Metadata *Val;
154
143155 ModuleFlagEntry(ModFlagBehavior B, MDString *K, Metadata *V)
144156 : Behavior(B), Key(K), Val(V) {}
145157 };
482494 const GlobalListType &getGlobalList() const { return GlobalList; }
483495 /// Get the Module's list of global variables.
484496 GlobalListType &getGlobalList() { return GlobalList; }
497
485498 static GlobalListType Module::*getSublistAccess(GlobalVariable*) {
486499 return &Module::GlobalList;
487500 }
501
488502 /// Get the Module's list of functions (constant).
489503 const FunctionListType &getFunctionList() const { return FunctionList; }
490504 /// Get the Module's list of functions.
492506 static FunctionListType Module::*getSublistAccess(Function*) {
493507 return &Module::FunctionList;
494508 }
509
495510 /// Get the Module's list of aliases (constant).
496511 const AliasListType &getAliasList() const { return AliasList; }
497512 /// Get the Module's list of aliases.
498513 AliasListType &getAliasList() { return AliasList; }
514
499515 static AliasListType Module::*getSublistAccess(GlobalAlias*) {
500516 return &Module::AliasList;
501517 }
518
502519 /// Get the Module's list of ifuncs (constant).
503520 const IFuncListType &getIFuncList() const { return IFuncList; }
504521 /// Get the Module's list of ifuncs.
505522 IFuncListType &getIFuncList() { return IFuncList; }
523
506524 static IFuncListType Module::*getSublistAccess(GlobalIFunc*) {
507525 return &Module::IFuncList;
508526 }
527
509528 /// Get the Module's list of named metadata (constant).
510529 const NamedMDListType &getNamedMDList() const { return NamedMDList; }
511530 /// Get the Module's list of named metadata.
512531 NamedMDListType &getNamedMDList() { return NamedMDList; }
532
513533 static NamedMDListType Module::*getSublistAccess(NamedMDNode*) {
514534 return &Module::NamedMDList;
515535 }
536
516537 /// Get the symbol table of global variable and function identifiers
517538 const ValueSymbolTable &getValueSymbolTable() const { return *ValSymTab; }
518539 /// Get the Module's symbol table of global variable and function identifiers.
519540 ValueSymbolTable &getValueSymbolTable() { return *ValSymTab; }
541
520542 /// Get the Module's symbol table for COMDATs (constant).
521543 const ComdatSymTabType &getComdatSymbolTable() const { return ComdatSymTab; }
522544 /// Get the Module's symbol table for COMDATs.
601623 /// @name Convenience iterators
602624 /// @{
603625
604 typedef concat_iterator
605 global_object_iterator;
606 typedef concat_iterator
607 const_global_iterator>
608 const_global_object_iterator;
626 using global_object_iterator =
627 concat_iterator;
628 using const_global_object_iterator =
629 concat_iterator
630 const_global_iterator>;
609631
610632 iterator_range global_objects() {
611633 return concat(functions(), globals());
626648 return global_objects().end();
627649 }
628650
629 typedef concat_iterator
630 alias_iterator, ifunc_iterator>
631 global_value_iterator;
632 typedef concat_iterator
633 const_global_iterator, const_alias_iterator,
634 const_ifunc_iterator>
635 const_global_value_iterator;
651 using global_value_iterator =
652 concat_iterator
653 ifunc_iterator>;
654 using const_global_value_iterator =
655 concat_iterator
656 const_alias_iterator, const_ifunc_iterator>;
636657
637658 iterator_range global_values() {
638659 return concat(functions(), globals(), aliases(), ifuncs());
681702 : public std::iterator {
682703 NamedMDNode *CUs;
683704 unsigned Idx;
705
684706 void SkipNoDebugCUs();
707
685708 public:
686709 explicit debug_compile_units_iterator(NamedMDNode *CUs, unsigned Idx)
687710 : CUs(CUs), Idx(Idx) {
688711 SkipNoDebugCUs();
689712 }
713
690714 debug_compile_units_iterator &operator++() {
691715 ++Idx;
692716 SkipNoDebugCUs();
693717 return *this;
694718 }
719
695720 debug_compile_units_iterator operator++(int) {
696721 debug_compile_units_iterator T(*this);
697722 ++Idx;
698723 return T;
699724 }
725
700726 bool operator==(const debug_compile_units_iterator &I) const {
701727 return Idx == I.Idx;
702728 }
729
703730 bool operator!=(const debug_compile_units_iterator &I) const {
704731 return Idx != I.Idx;
705732 }
733
706734 DICompileUnit *operator*() const;
707735 DICompileUnit *operator->() const;
708736 };
832860 return reinterpret_cast(MP);
833861 }
834862
835 } // End llvm namespace
836
837 #endif
863 } // end namespace llvm
864
865 #endif // LLVM_IR_MODULE_H
None //===-- llvm/Use.h - Definition of the Use class ----------------*- C++ -*-===//
0 //===- llvm/Use.h - Definition of the Use class -----------------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
2626
2727 #include "llvm/ADT/PointerIntPair.h"
2828 #include "llvm/Support/CBindingWrapping.h"
29 #include "llvm/Support/Compiler.h"
2930 #include "llvm-c/Types.h"
3031
3132 namespace llvm {
3233
34 template struct simplify_type;
35 class User;
3336 class Value;
34 class User;
35 class Use;
36 template struct simplify_type;
3737
3838 /// \brief A Use represents the edge between a Value definition and its users.
3939 ///
6464 /// use the LSB regardless of pointer alignment on different targets.
6565 struct UserRefPointerTraits {
6666 static inline void *getAsVoidPointer(User *P) { return P; }
67
6768 static inline User *getFromVoidPointer(void *P) {
6869 return (User *)P;
6970 }
71
7072 enum { NumLowBitsAvailable = 1 };
7173 };
7274
7375 // A type for the word following an array of hung-off Uses in memory, which is
7476 // a pointer back to their User with the bottom bit set.
75 typedef PointerIntPair UserRef;
77 using UserRef = PointerIntPair;
7678
7779 /// Pointer traits for the Prev PointerIntPair. This ensures we always use
7880 /// the two LSBs regardless of pointer alignment on different targets.
7981 struct PrevPointerTraits {
8082 static inline void *getAsVoidPointer(Use **P) { return P; }
83
8184 static inline Use **getFromVoidPointer(void *P) {
8285 return (Use **)P;
8386 }
87
8488 enum { NumLowBitsAvailable = 2 };
8589 };
8690
9498 enum PrevPtrTag { zeroDigitTag, oneDigitTag, stopTag, fullStopTag };
9599
96100 /// Constructor
97 Use(PrevPtrTag tag) : Val(nullptr) { Prev.setInt(tag); }
101 Use(PrevPtrTag tag) { Prev.setInt(tag); }
98102
99103 public:
104 friend class Value;
105
100106 operator Value *() const { return Val; }
101107 Value *get() const { return Val; }
102108
132138 private:
133139 const Use *getImpliedUser() const LLVM_READONLY;
134140
135 Value *Val;
141 Value *Val = nullptr;
136142 Use *Next;
137143 PointerIntPair Prev;
138144
152158 if (Next)
153159 Next->setPrev(StrippedPrev);
154160 }
155
156 friend class Value;
157161 };
158162
159163 /// \brief Allow clients to treat uses just like values when using
160164 /// casting operators.
161165 template <> struct simplify_type {
162 typedef Value *SimpleType;
166 using SimpleType = Value *;
167
163168 static SimpleType getSimplifiedValue(Use &Val) { return Val.get(); }
164169 };
165170 template <> struct simplify_type {
166 typedef /*const*/ Value *SimpleType;
171 using SimpleType = /*const*/ Value *;
172
167173 static SimpleType getSimplifiedValue(const Use &Val) { return Val.get(); }
168174 };
169175
3636 UseListOrder &operator=(UseListOrder &&) = default;
3737 };
3838
39 typedef std::vector UseListOrderStack;
39 using UseListOrderStack = std::vector;
4040
4141 } // end namespace llvm
4242
None //===-- llvm/User.h - User class definition ---------------------*- C++ -*-===//
0 //===- llvm/User.h - User class definition ----------------------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
113113 ? OperandTraits::op_end(const_cast(that))[Idx]
114114 : OperandTraits::op_begin(const_cast(that))[Idx];
115115 }
116
116117 template Use &Op() {
117118 return OpFrom(this);
118119 }
204205 // ---------------------------------------------------------------------------
205206 // Operand Iterator interface...
206207 //
207 typedef Use* op_iterator;
208 typedef const Use* const_op_iterator;
209 typedef iterator_range op_range;
210 typedef iterator_range const_op_range;
208 using op_iterator = Use*;
209 using const_op_iterator = const Use*;
210 using op_range = iterator_range;
211 using const_op_range = iterator_range;
211212
212213 op_iterator op_begin() { return getOperandList(); }
213214 const_op_iterator op_begin() const { return getOperandList(); }
251252 ptrdiff_t, const Value *, const Value *> {
252253 explicit const_value_op_iterator(const Use *U = nullptr) :
253254 iterator_adaptor_base(U) {}
255
254256 const Value *operator*() const { return *I; }
255257 const Value *operator->() const { return operator*(); }
256258 };
289291 return isa(V) || isa(V);
290292 }
291293 };
294
292295 // Either Use objects, or a Use pointer can be prepended to User.
293296 static_assert(alignof(Use) >= alignof(User),
294297 "Alignment is insufficient after objects prepended to User");
296299 "Alignment is insufficient after objects prepended to User");
297300
298301 template<> struct simplify_type {
299 typedef Value* SimpleType;
302 using SimpleType = Value*;
303
300304 static SimpleType getSimplifiedValue(User::op_iterator &Val) {
301305 return Val->get();
302306 }
303307 };
304308 template<> struct simplify_type {
305 typedef /*const*/ Value* SimpleType;
309 using SimpleType = /*const*/ Value*;
310
306311 static SimpleType getSimplifiedValue(User::const_op_iterator &Val) {
307312 return Val->get();
308313 }
None //===-- llvm/Value.h - Definition of the Value class ------------*- C++ -*-===//
0 //===- llvm/Value.h - Definition of the Value class -------------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
4343 class Module;
4444 class ModuleSlotTracker;
4545 class raw_ostream;
46 template class StringMapEntry;
4647 class StringRef;
4748 class Twine;
4849 class Type;
4950
50 template class StringMapEntry;
51 typedef StringMapEntry ValueName;
51 using ValueName = StringMapEntry;
5252
5353 //===----------------------------------------------------------------------===//
5454 // Value Class
119119 template // UseT == 'Use' or 'const Use'
120120 class use_iterator_impl
121121 : public std::iterator {
122 UseT *U;
122 friend class Value;
123
124 UseT *U = nullptr;
125
123126 explicit use_iterator_impl(UseT *u) : U(u) {}
124 friend class Value;
125127
126128 public:
127 use_iterator_impl() : U() {}
129 use_iterator_impl() = default;
128130
129131 bool operator==(const use_iterator_impl &x) const { return U == x.U; }
130132 bool operator!=(const use_iterator_impl &x) const { return !operator==(x); }
156158 template // UserTy == 'User' or 'const User'
157159 class user_iterator_impl
158160 : public std::iterator {
161 friend class Value;
162
159163 use_iterator_impl UI;
164
160165 explicit user_iterator_impl(Use *U) : UI(U) {}
161 friend class Value;
162166
163167 public:
164168 user_iterator_impl() = default;
308312 return UseList == nullptr;
309313 }
310314
311 typedef use_iterator_impl use_iterator;
312 typedef use_iterator_impl const_use_iterator;
315 using use_iterator = use_iterator_impl;
316 using const_use_iterator = use_iterator_impl;
313317 use_iterator materialized_use_begin() { return use_iterator(UseList); }
314318 const_use_iterator materialized_use_begin() const {
315319 return const_use_iterator(UseList);
344348 return UseList == nullptr;
345349 }
346350
347 typedef user_iterator_impl user_iterator;
348 typedef user_iterator_impl const_user_iterator;
351 using user_iterator = user_iterator_impl;
352 using const_user_iterator = user_iterator_impl;
349353 user_iterator materialized_user_begin() { return user_iterator(UseList); }
350354 const_user_iterator materialized_user_begin() const {
351355 return const_user_iterator(UseList);
559563 /// block.
560564 const Value *DoPHITranslation(const BasicBlock *CurBB,
561565 const BasicBlock *PredBB) const;
562
563566 Value *DoPHITranslation(const BasicBlock *CurBB, const BasicBlock *PredBB) {
564567 return const_cast(
565568 static_cast(this)->DoPHITranslation(CurBB, PredBB));
605608 Use *Merged;
606609 Use **Next = &Merged;
607610
608 for (;;) {
611 while (true) {
609612 if (!L) {
610613 *Next = R;
611614 break;
1616 #include "llvm/ADT/DenseMapInfo.h"
1717 #include "llvm/ADT/PointerIntPair.h"
1818 #include "llvm/IR/Value.h"
19 #include "llvm/Support/Casting.h"
20 #include
1921
2022 namespace llvm {
21 class ValueHandleBase;
22 template struct simplify_type;
2323
2424 /// \brief This is the common base class of value handles.
2525 ///
2828 /// below for details.
2929 class ValueHandleBase {
3030 friend class Value;
31
3132 protected:
3233 /// \brief This indicates what sub class the handle actually is.
3334 ///
3940 : ValueHandleBase(RHS.PrevPair.getInt(), RHS) {}
4041
4142 ValueHandleBase(HandleBaseKind Kind, const ValueHandleBase &RHS)
42 : PrevPair(nullptr, Kind), Next(nullptr), Val(RHS.getValPtr()) {
43 : PrevPair(nullptr, Kind), Val(RHS.getValPtr()) {
4344 if (isValid(getValPtr()))
4445 AddToExistingUseList(RHS.getPrevPtr());
4546 }
4647
4748 private:
4849 PointerIntPair PrevPair;
49 ValueHandleBase *Next;
50
51 Value *Val;
50 ValueHandleBase *Next = nullptr;
51 Value *Val = nullptr;
5252
5353 void setValPtr(Value *V) { Val = V; }
5454
5555 public:
5656 explicit ValueHandleBase(HandleBaseKind Kind)
57 : PrevPair(nullptr, Kind), Next(nullptr), Val(nullptr) {}
57 : PrevPair(nullptr, Kind) {}
5858 ValueHandleBase(HandleBaseKind Kind, Value *V)
59 : PrevPair(nullptr, Kind), Next(nullptr), Val(V) {
59 : PrevPair(nullptr, Kind), Val(V) {
6060 if (isValid(getValPtr()))
6161 AddToUseList();
6262 }
161161 // Specialize simplify_type to allow WeakVH to participate in
162162 // dyn_cast, isa, etc.
163163 template <> struct simplify_type {
164 typedef Value *SimpleType;
164 using SimpleType = Value *;
165
165166 static SimpleType getSimplifiedValue(WeakVH &WVH) { return WVH; }
166167 };
167168 template <> struct simplify_type {
168 typedef Value *SimpleType;
169 using SimpleType = Value *;
170
169171 static SimpleType getSimplifiedValue(const WeakVH &WVH) { return WVH; }
170172 };
171173
204206 // Specialize simplify_type to allow WeakTrackingVH to participate in
205207 // dyn_cast, isa, etc.
206208 template <> struct simplify_type {
207 typedef Value *SimpleType;
209 using SimpleType = Value *;
210
208211 static SimpleType getSimplifiedValue(WeakTrackingVH &WVH) { return WVH; }
209212 };
210213 template <> struct simplify_type {
211 typedef Value *SimpleType;
214 using SimpleType = Value *;
215
212216 static SimpleType getSimplifiedValue(const WeakTrackingVH &WVH) {
213217 return WVH;
214218 }
235239 : public ValueHandleBase
236240 #endif
237241 {
238 friend struct DenseMapInfo >;
242 friend struct DenseMapInfo>;
239243
240244 #ifndef NDEBUG
241245 Value *getRawValPtr() const { return ValueHandleBase::getValPtr(); }
281285
282286 // Specialize DenseMapInfo to allow AssertingVH to participate in DenseMap.
283287 template
284 struct DenseMapInfo > {
288 struct DenseMapInfo> {
285289 static inline AssertingVH getEmptyKey() {
286290 AssertingVH Res;
287291 Res.setRawValPtr(DenseMapInfo::getEmptyKey());
288292 return Res;
289293 }
294
290295 static inline AssertingVH getTombstoneKey() {
291296 AssertingVH Res;
292297 Res.setRawValPtr(DenseMapInfo::getTombstoneKey());
293298 return Res;
294299 }
300
295301 static unsigned getHashValue(const AssertingVH &Val) {
296302 return DenseMapInfo::getHashValue(Val.getRawValPtr());
297303 }
304
298305 static bool isEqual(const AssertingVH &LHS, const AssertingVH &RHS) {
299306 return DenseMapInfo::isEqual(LHS.getRawValPtr(),
300307 RHS.getRawValPtr());
302309 };
303310
304311 template
305 struct isPodLike > {
312 struct isPodLike> {
306313 #ifdef NDEBUG
307314 static const bool value = true;
308315 #else
355362 static Value *GetAsValue(const Value *V) { return const_cast(V); }
356363
357364 public:
358 TrackingVH() {}
365 TrackingVH() = default;
359366 TrackingVH(ValueTy *P) { setValPtr(P); }
360367
361368 operator ValueTy*() const {
494501 PoisoningVH(ValueTy *P) : CallbackVH(GetAsValue(P)) {}
495502 PoisoningVH(const PoisoningVH &RHS)
496503 : CallbackVH(RHS), Poisoned(RHS.Poisoned) {}
504
497505 ~PoisoningVH() {
498506 if (Poisoned)
499507 clearValPtr();
500508 }
509
501510 PoisoningVH &operator=(const PoisoningVH &RHS) {
502511 if (Poisoned)
503512 clearValPtr();
522531 Res.setRawValPtr(DenseMapInfo::getEmptyKey());
523532 return Res;
524533 }
534
525535 static inline PoisoningVH getTombstoneKey() {
526536 PoisoningVH Res;
527537 Res.setRawValPtr(DenseMapInfo::getTombstoneKey());
528538 return Res;
529539 }
540
530541 static unsigned getHashValue(const PoisoningVH &Val) {
531542 return DenseMapInfo::getHashValue(Val.getRawValPtr());
532543 }
544
533545 static bool isEqual(const PoisoningVH &LHS, const PoisoningVH &RHS) {
534546 return DenseMapInfo::isEqual(LHS.getRawValPtr(),
535547 RHS.getRawValPtr());
544556 #endif
545557 };
546558
547 } // End llvm namespace
548
549 #endif
559 } // end namespace llvm
560
561 #endif // LLVM_IR_VALUEHANDLE_H
4545
4646 template
4747 class ValueMapCallbackVH;
48
4948 template
5049 class ValueMapIterator;
5150 template
5655 /// as possible with future versions of ValueMap.
5756 template
5857 struct ValueMapConfig {
59 typedef MutexT mutex_type;
58 using mutex_type = MutexT;
6059
6160 /// If FollowRAUW is true, the ValueMap will update mappings on RAUW. If it's
6261 /// false, the ValueMap will leave the original mapping in place.
8685 class ValueMap {
8786 friend class ValueMapCallbackVH;
8887
89 typedef ValueMapCallbackVH ValueMapCVH;
90 typedef DenseMap> MapT;
91 typedef DenseMap MDMapT;
92 typedef typename Config::ExtraData ExtraData;
88 using ValueMapCVH = ValueMapCallbackVH;
89 using MapT = DenseMap>;
90 using MDMapT = DenseMap;
91 using ExtraData = typename Config::ExtraData;
92
9393 MapT Map;
9494 Optional MDMap;
9595 ExtraData Data;
96
9796 bool MayMapMetadata = true;
9897
9998 public:
100 typedef KeyT key_type;
101 typedef ValueT mapped_type;
102 typedef std::pair value_type;
103 typedef unsigned size_type;
99 using key_type = KeyT;
100 using mapped_type = ValueT;
101 using value_type = std::pair;
102 using size_type = unsigned;
104103
105104 explicit ValueMap(unsigned NumInitBuckets = 64)
106105 : Map(NumInitBuckets), Data() {}
131130 return Where->second.get();
132131 }
133132
134 typedef ValueMapIterator iterator;
135 typedef ValueMapConstIterator const_iterator;
133 using iterator = ValueMapIterator;
134 using const_iterator = ValueMapConstIterator;
135
136136 inline iterator begin() { return iterator(Map.begin()); }
137137 inline iterator end() { return iterator(Map.end()); }
138138 inline const_iterator begin() const { return const_iterator(Map.begin()); }
243243 friend class ValueMap;
244244 friend struct DenseMapInfo;
245245
246 typedef ValueMap ValueMapT;
247 typedef typename std::remove_pointer::type KeySansPointerT;
246 using ValueMapT = ValueMap;
247 using KeySansPointerT = typename std::remove_pointer::type;
248248
249249 ValueMapT *Map;
250250
297297
298298 template
299299 struct DenseMapInfo> {
300 typedef ValueMapCallbackVH VH;
300 using VH = ValueMapCallbackVH;
301301
302302 static inline VH getEmptyKey() {
303303 return VH(DenseMapInfo::getEmptyKey());
329329 public std::iterator
330330 std::pair,
331331 ptrdiff_t> {
332 typedef typename DenseMapT::iterator BaseT;
333 typedef typename DenseMapT::mapped_type ValueT;
332 using BaseT = typename DenseMapT::iterator;
333 using ValueT = typename DenseMapT::mapped_type;
334334
335335 BaseT I;
336336
343343 struct ValueTypeProxy {
344344 const KeyT first;
345345 ValueT& second;
346
346347 ValueTypeProxy *operator->() { return this; }
348
347349 operator std::pair() const {
348350 return std::make_pair(first, second);
349351 }
379381 public std::iterator
380382 std::pair,
381383 ptrdiff_t> {
382 typedef typename DenseMapT::const_iterator BaseT;
383 typedef typename DenseMapT::mapped_type ValueT;
384 using BaseT = typename DenseMapT::const_iterator;
385 using ValueT = typename DenseMapT::mapped_type;
384386
385387 BaseT I;
386388
4848 /// @{
4949 public:
5050 /// @brief A mapping of names to values.
51 typedef StringMap ValueMap;
51 using ValueMap = StringMap;
5252
5353 /// @brief An iterator over a ValueMap.
54 typedef ValueMap::iterator iterator;
54 using iterator = ValueMap::iterator;
5555
5656 /// @brief A const_iterator over a ValueMap.
57 typedef ValueMap::const_iterator const_iterator;
57 using const_iterator = ValueMap::const_iterator;
5858
5959 /// @}
6060 /// @name Constructors
None //===-- Function.cpp - Implement the Global object classes ----------------===//
0 //===- Function.cpp - Implement the Global object classes -----------------===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1010 //
1111 //===----------------------------------------------------------------------===//
1212
13 #include "llvm/IR/Function.h"
1413 #include "LLVMContextImpl.h"
1514 #include "SymbolTableListTraitsImpl.h"
15 #include "llvm/ADT/ArrayRef.h"
16 #include "llvm/ADT/DenseSet.h"
17 #include "llvm/ADT/None.h"
18 #include "llvm/ADT/SmallString.h"
19 #include "llvm/ADT/SmallVector.h"
1620 #include "llvm/ADT/STLExtras.h"
1721 #include "llvm/ADT/StringExtras.h"
22 #include "llvm/ADT/StringRef.h"
1823 #include "llvm/CodeGen/ValueTypes.h"
24 #include "llvm/IR/Argument.h"
25 #include "llvm/IR/Attributes.h"
26 #include "llvm/IR/BasicBlock.h"
1927 #include "llvm/IR/CallSite.h"
28 #include "llvm/IR/Constant.h"
2029 #include "llvm/IR/Constants.h"
2130 #include "llvm/IR/DerivedTypes.h"
31 #include "llvm/IR/Function.h"
32 #include "llvm/IR/GlobalValue.h"
2233 #include "llvm/IR/InstIterator.h"
34 #include "llvm/IR/Instruction.h"
35 #include "llvm/IR/Instructions.h"
2336 #include "llvm/IR/IntrinsicInst.h"
37 #include "llvm/IR/Intrinsics.h"
2438 #include "llvm/IR/LLVMContext.h"
2539 #include "llvm/IR/MDBuilder.h"
2640 #include "llvm/IR/Metadata.h"
2741 #include "llvm/IR/Module.h"
42 #include "llvm/IR/SymbolTableListTraits.h"
43 #include "llvm/IR/Type.h"
44 #include "llvm/IR/Use.h"
45 #include "llvm/IR/User.h"
46 #include "llvm/IR/Value.h"
47 #include "llvm/IR/ValueSymbolTable.h"
48 #include "llvm/Support/Casting.h"
49 #include "llvm/Support/Compiler.h"
50 #include "llvm/Support/ErrorHandling.h"
51 #include
52 #include
53 #include
54 #include
55 #include
56 #include
57
2858 using namespace llvm;
2959
3060 // Explicit instantiations of SymbolTableListTraits since some of the methods
3565 // Argument Implementation
3666 //===----------------------------------------------------------------------===//
3767
38 void Argument::anchor() { }
68 void Argument::anchor() {}
3969
4070 Argument::Argument(Type *Ty, const Twine &Name, Function *Par, unsigned ArgNo)
4171 : Value(Ty, Value::ArgumentVal), Parent(Par), ArgNo(ArgNo) {
185215 Module *ParentModule)
186216 : GlobalObject(Ty, Value::FunctionVal,
187217 OperandTraits::op_begin(this), 0, Linkage, name),
188 Arguments(nullptr), NumArgs(Ty->getNumParams()) {
218 NumArgs(Ty->getNumParams()) {
189219 assert(FunctionType::isValidReturnType(getReturnType()) &&
190220 "invalid return type");
191221 setGlobalObjectSubClassData(0);
485515 static std::string getMangledTypeStr(Type* Ty) {
486516 std::string Result;
487517 if (PointerType* PTyp = dyn_cast(Ty)) {
488 Result += "p" + llvm::utostr(PTyp->getAddressSpace()) +
518 Result += "p" + utostr(PTyp->getAddressSpace()) +
489519 getMangledTypeStr(PTyp->getElementType());
490520 } else if (ArrayType* ATyp = dyn_cast(Ty)) {
491 Result += "a" + llvm::utostr(ATyp->getNumElements()) +
521 Result += "a" + utostr(ATyp->getNumElements()) +
492522 getMangledTypeStr(ATyp->getElementType());
493523 } else if (StructType *STyp = dyn_cast(Ty)) {
494524 if (!STyp->isLiteral()) {
533563 return Result;
534564 }
535565
536
537566 /// IIT_Info - These are enumerators that describe the entries returned by the
538567 /// getIntrinsicInfoTableEntries function.
539568 ///
584613
585614 static void DecodeIITType(unsigned &NextElt, ArrayRef Infos,
586615 SmallVectorImpl &OutputTable) {
616 using namespace Intrinsic;
617
587618 IIT_Info Info = IIT_Info(Infos[NextElt++]);
588619 unsigned StructElts = 2;
589 using namespace Intrinsic;
590620
591621 switch (Info) {
592622 case IIT_Done:
740770 }
741771 llvm_unreachable("unhandled");
742772 }
743
744773
745774 #define GET_INTRINSIC_GENERATOR_GLOBAL
746775 #include "llvm/IR/Intrinsics.gen"
779808 DecodeIITType(NextElt, IITEntries, T);
780809 }
781810
782
783811 static Type *DecodeFixedType(ArrayRef &Infos,
784812 ArrayRef Tys, LLVMContext &Context) {
785813 using namespace Intrinsic;
814
786815 IITDescriptor D = Infos.front();
787816 Infos = Infos.slice(1);
788817
854883 case IITDescriptor::VecOfAnyPtrsToElt:
855884 // Return the overloaded type (which determines the pointers address space)
856885 return Tys[D.getOverloadArgNumber()];
857 }
886 }
858887 llvm_unreachable("unhandled");
859888 }
860
861
862889
863890 FunctionType *Intrinsic::getType(LLVMContext &Context,
864891 ID id, ArrayRef Tys) {
None //===-- Module.cpp - Implement the Module class ---------------------------===//
0 //===- Module.cpp - Implement the Module class ----------------------------===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1010 //
1111 //===----------------------------------------------------------------------===//
1212
13 #include "llvm/IR/Module.h"
1413 #include "SymbolTableListTraitsImpl.h"
15 #include "llvm/ADT/STLExtras.h"
1614 #include "llvm/ADT/SmallPtrSet.h"
1715 #include "llvm/ADT/SmallString.h"
18 #include "llvm/ADT/StringExtras.h"
16 #include "llvm/ADT/SmallVector.h"
17 #include "llvm/ADT/StringMap.h"
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/ADT/Twine.h"
20 #include "llvm/IR/Attributes.h"
21 #include "llvm/IR/Comdat.h"
1922 #include "llvm/IR/Constants.h"
23 #include "llvm/IR/DataLayout.h"
2024 #include "llvm/IR/DerivedTypes.h"
2125 #include "llvm/IR/DebugInfoMetadata.h"
26 #include "llvm/IR/Function.h"
27 #include "llvm/IR/GlobalAlias.h"
28 #include "llvm/IR/GlobalIFunc.h"
29 #include "llvm/IR/GlobalValue.h"
30 #include "llvm/IR/GlobalVariable.h"
2231 #include "llvm/IR/GVMaterializer.h"
23 #include "llvm/IR/InstrTypes.h"
2432 #include "llvm/IR/LLVMContext.h"
33 #include "llvm/IR/Metadata.h"
34 #include "llvm/IR/Module.h"
35 #include "llvm/IR/SymbolTableListTraits.h"
36 #include "llvm/IR/Type.h"
2537 #include "llvm/IR/TypeFinder.h"
26 #include "llvm/Support/Dwarf.h"
38 #include "llvm/IR/Value.h"
39 #include "llvm/IR/ValueSymbolTable.h"
40 #include "llvm/Pass.h"
41 #include "llvm/Support/Casting.h"
42 #include "llvm/Support/CodeGen.h"
2743 #include "llvm/Support/Error.h"
2844 #include "llvm/Support/MemoryBuffer.h"
2945 #include "llvm/Support/Path.h"
3046 #include "llvm/Support/RandomNumberGenerator.h"
3147 #include
32 #include stdlib>
48 #include assert>
49 #include
50 #include
51 #include
52 #include
3353
3454 using namespace llvm;
3555