llvm.org GIT mirror llvm / 82d16ec
Fix some Clang-tidy modernize-use-using and Include What You Use warnings. Differential revision: https://reviews.llvm.org/D23478 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278583 91177308-0d34-0410-b5e6-96231b3b80d8 Eugene Zelenko 3 years ago
6 changed file(s) with 121 addition(s) and 55 deletion(s). Raw diff Collapse all Expand all
1818 #include "llvm/Support/AlignOf.h"
1919 #include "llvm/Support/Compiler.h"
2020 #include "llvm/Support/MathExtras.h"
21 #include "llvm/Support/PointerLikeTypeTraits.h"
2221 #include "llvm/Support/type_traits.h"
2322 #include
2423 #include
25 #include
2624 #include
2725 #include
2826 #include
27 #include
2928 #include
3029 #include
3130
3231 namespace llvm {
3332
3433 namespace detail {
34
3535 // We extend a pair to allow users to override the bucket type with their own
3636 // implementation without requiring two members.
3737 template
4141 ValueT &getSecond() { return std::pair::second; }
4242 const ValueT &getSecond() const { return std::pair::second; }
4343 };
44 }
44
45 } // end namespace detail
4546
4647 template <
4748 typename KeyT, typename ValueT, typename KeyInfoT = DenseMapInfo,
237238 for (; I != E; ++I)
238239 insert(*I);
239240 }
240
241241
242242 bool erase(const KeyT &Val) {
243243 BucketT *TheBucket;
527527
528528 unsigned BucketNo = getHashValue(Val) & (NumBuckets-1);
529529 unsigned ProbeAmt = 1;
530 while (1) {
530 while (true) {
531531 const BucketT *ThisBucket = BucketsPtr + BucketNo;
532532 // Found Val's bucket? If so, return it.
533533 if (LLVM_LIKELY(KeyInfoT::isEqual(Val, ThisBucket->getFirst()))) {
965965 return NumEntries;
966966 }
967967 void setNumEntries(unsigned Num) {
968 assert(Num < INT_MAX && "Cannot support more than INT_MAX entries");
968 assert(Num < std::numeric_limits::max() &&
969 "Cannot support more than std::numeric_limits::max() entries");
969970 NumEntries = Num;
970971 }
971972
10391040 typedef value_type *pointer;
10401041 typedef value_type &reference;
10411042 typedef std::forward_iterator_tag iterator_category;
1043
10421044 private:
10431045 pointer Ptr, End;
1046
10441047 public:
10451048 DenseMapIterator() : Ptr(nullptr), End(nullptr) {}
10461049
11141117
11151118 } // end namespace llvm
11161119
1117 #endif
1120 #endif // LLVM_ADT_DENSEMAP_H
3131 #include
3232
3333 namespace llvm {
34
3435 class raw_ostream;
3536 class raw_fd_ostream;
3637
139140 TsanHappensAfter(this);
140141 return *this;
141142 }
143
142144 void RegisterStatistic();
143145 };
144146
145147 // STATISTIC - A macro to make definition of statistics really simple. This
146148 // automatically passes the DEBUG_TYPE of the file into the statistic.
147149 #define STATISTIC(VARNAME, DESC) \
148 static llvm::Statistic VARNAME = {DEBUG_TYPE, #VARNAME, DESC, {0}, 0}
150 static llvm::Statistic VARNAME = {DEBUG_TYPE, #VARNAME, DESC, {0}, false}
149151
150152 /// \brief Enable the collection and printing of statistics.
151153 void EnableStatistics();
165167 /// Print statistics in JSON format.
166168 void PrintStatisticsJSON(raw_ostream &OS);
167169
168 } // end llvm namespace
170 } // end namespace llvm
169171
170172 #endif // LLVM_ADT_STATISTIC_H
7272 // Validate an integral value which isn't known to fit within the enum's range
7373 // is a valid AtomicOrdering.
7474 template static inline bool isValidAtomicOrdering(Int I) {
75 return (Int)AtomicOrdering::NotAtomic <= I &&
76 I <= (Int)AtomicOrdering::SequentiallyConsistent;
75 return static_cast(AtomicOrdering::NotAtomic) <= I &&
76 I <= static_cast(AtomicOrdering::SequentiallyConsistent);
7777 }
7878
7979 /// String used by LLVM IR to represent atomic ordering.
8181 static const char *names[8] = {"not_atomic", "unordered", "monotonic",
8282 "consume", "acquire", "release",
8383 "acq_rel", "seq_cst"};
84 return names[(size_t)ao];
84 return names[static_cast(ao)];
8585 }
8686
8787 /// Returns true if ao is stronger than other as defined by the AtomicOrdering
8888 /// lattice, which is based on C++'s definition.
8989 static inline bool isStrongerThan(AtomicOrdering ao, AtomicOrdering other) {
9090 static const bool lookup[8][8] = {
91 // NA UN RX CO AC RE AR SC
92 /* NotAtomic */ {0, 0, 0, 0, 0, 0, 0, 0},
93 /* Unordered */ {1, 0, 0, 0, 0, 0, 0, 0},
94 /* relaxed */ {1, 1, 0, 0, 0, 0, 0, 0},
95 /* consume */ {1, 1, 1, 0, 0, 0, 0, 0},
96 /* acquire */ {1, 1, 1, 1, 0, 0, 0, 0},
97 /* release */ {1, 1, 1, 0, 0, 0, 0, 0},
98 /* acq_rel */ {1, 1, 1, 1, 1, 1, 0, 0},
99 /* seq_cst */ {1, 1, 1, 1, 1, 1, 1, 0},
91 // NA UN RX CO AC RE AR SC
92 /* NotAtomic */ {false, false, false, false, false, false, false, false},
93 /* Unordered */ { true, false, false, false, false, false, false, false},
94 /* relaxed */ { true, true, false, false, false, false, false, false},
95 /* consume */ { true, true, true, false, false, false, false, false},
96 /* acquire */ { true, true, true, true, false, false, false, false},
97 /* release */ { true, true, true, false, false, false, false, false},
98 /* acq_rel */ { true, true, true, true, true, true, false, false},
99 /* seq_cst */ { true, true, true, true, true, true, true, false},
100100 };
101 return lookup[(size_t)ao][(size_t)other];
101 return lookup[static_cast(ao)][static_cast(other)];
102102 }
103103
104104 static inline bool isAtLeastOrStrongerThan(AtomicOrdering ao,
105105 AtomicOrdering other) {
106106 static const bool lookup[8][8] = {
107 // NA UN RX CO AC RE AR SC
108 /* NotAtomic */ {1, 0, 0, 0, 0, 0, 0, 0},
109 /* Unordered */ {1, 1, 0, 0, 0, 0, 0, 0},
110 /* relaxed */ {1, 1, 1, 0, 0, 0, 0, 0},
111 /* consume */ {1, 1, 1, 1, 0, 0, 0, 0},
112 /* acquire */ {1, 1, 1, 1, 1, 0, 0, 0},
113 /* release */ {1, 1, 1, 0, 0, 1, 0, 0},
114 /* acq_rel */ {1, 1, 1, 1, 1, 1, 1, 0},
115 /* seq_cst */ {1, 1, 1, 1, 1, 1, 1, 1},
107 // NA UN RX CO AC RE AR SC
108 /* NotAtomic */ { true, false, false, false, false, false, false, false},
109 /* Unordered */ { true, true, false, false, false, false, false, false},
110 /* relaxed */ { true, true, true, false, false, false, false, false},
111 /* consume */ { true, true, true, true, false, false, false, false},
112 /* acquire */ { true, true, true, true, true, false, false, false},
113 /* release */ { true, true, true, false, false, true, false, false},
114 /* acq_rel */ { true, true, true, true, true, true, true, false},
115 /* seq_cst */ { true, true, true, true, true, true, true, true},
116116 };
117 return lookup[(size_t)ao][(size_t)other];
117 return lookup[static_cast(ao)][static_cast(other)];
118118 }
119119
120120 static inline bool isStrongerThanUnordered(AtomicOrdering ao) {
144144 /* acq_rel */ AtomicOrderingCABI::acq_rel,
145145 /* seq_cst */ AtomicOrderingCABI::seq_cst,
146146 };
147 return lookup[(size_t)ao];
147 return lookup[static_cast(ao)];
148148 }
149149
150150 } // end namespace llvm
2828 #define LLVM_SUPPORT_DEBUG_H
2929
3030 namespace llvm {
31
3132 class raw_ostream;
3233
3334 #ifndef NDEBUG
6061 /// is not specified, or is specified as "bitset".
6162 #define DEBUG_WITH_TYPE(TYPE, X) \
6263 do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType(TYPE)) { X; } \
63 } while (0)
64 } while (false)
6465
6566 #else
6667 #define isCurrentDebugType(X) (false)
6768 #define setCurrentDebugType(X)
68 #define DEBUG_WITH_TYPE(TYPE, X) do { } while (0)
69 #define DEBUG_WITH_TYPE(TYPE, X) do { } while (false)
6970 #endif
7071
7172 /// EnableDebugBuffering - This defaults to false. If true, the debug
9091 //
9192 #define DEBUG(X) DEBUG_WITH_TYPE(DEBUG_TYPE, X)
9293
93 } // End llvm namespace
94 } // end namespace llvm
9495
95 #endif
96 #endif // LLVM_SUPPORT_DEBUG_H
3434 //===----------------------------------------------------------------------===//
3535
3636 #include "llvm/Analysis/Lint.h"
37 #include "llvm/ADT/STLExtras.h"
38 #include "llvm/ADT/SmallSet.h"
37 #include "llvm/ADT/APInt.h"
38 #include "llvm/ADT/ArrayRef.h"
39 #include "llvm/ADT/SmallPtrSet.h"
40 #include "llvm/ADT/Twine.h"
3941 #include "llvm/Analysis/AliasAnalysis.h"
4042 #include "llvm/Analysis/AssumptionCache.h"
4143 #include "llvm/Analysis/ConstantFolding.h"
4244 #include "llvm/Analysis/InstructionSimplify.h"
4345 #include "llvm/Analysis/Loads.h"
46 #include "llvm/Analysis/MemoryLocation.h"
4447 #include "llvm/Analysis/Passes.h"
4548 #include "llvm/Analysis/TargetLibraryInfo.h"
4649 #include "llvm/Analysis/ValueTracking.h"
50 #include "llvm/IR/Argument.h"
51 #include "llvm/IR/BasicBlock.h"
4752 #include "llvm/IR/CallSite.h"
53 #include "llvm/IR/Constant.h"
54 #include "llvm/IR/Constants.h"
4855 #include "llvm/IR/DataLayout.h"
56 #include "llvm/IR/DerivedTypes.h"
4957 #include "llvm/IR/Dominators.h"
5058 #include "llvm/IR/Function.h"
59 #include "llvm/IR/GlobalVariable.h"
5160 #include "llvm/IR/Module.h"
5261 #include "llvm/IR/InstVisitor.h"
62 #include "llvm/IR/InstrTypes.h"
63 #include "llvm/IR/Instruction.h"
64 #include "llvm/IR/Instructions.h"
5365 #include "llvm/IR/IntrinsicInst.h"
5466 #include "llvm/IR/LegacyPassManager.h"
67 #include "llvm/IR/Type.h"
68 #include "llvm/IR/Value.h"
5569 #include "llvm/Pass.h"
70 #include "llvm/Support/Casting.h"
5671 #include "llvm/Support/Debug.h"
72 #include "llvm/Support/MathExtras.h"
5773 #include "llvm/Support/raw_ostream.h"
74 #include
75 #include
76 #include
77 #include
78
5879 using namespace llvm;
5980
6081 namespace {
6384 static const unsigned Write = 2;
6485 static const unsigned Callee = 4;
6586 static const unsigned Branchee = 8;
66 }
87 } // end namespace MemRef
6788
6889 class Lint : public FunctionPass, public InstVisitor {
6990 friend class InstVisitor;
158179 WriteValues({V1, Vs...});
159180 }
160181 };
161 }
182 } // end anonymous namespace
162183
163184 char Lint::ID = 0;
164185 INITIALIZE_PASS_BEGIN(Lint, "lint", "Statically lint-checks LLVM IR",
172193
173194 // Assert - We know that cond should be true, if not print an error message.
174195 #define Assert(C, ...) \
175 do { if (!(C)) { CheckFailed(__VA_ARGS__); return; } } while (0)
196 do { if (!(C)) { CheckFailed(__VA_ARGS__); return; } } while (false)
176197
177198 // Lint::run - This is the main Analysis entry point for a
178199 // function.
4444 //===----------------------------------------------------------------------===//
4545
4646 #include "llvm/IR/Verifier.h"
47 #include "llvm/ADT/APFloat.h"
48 #include "llvm/ADT/APInt.h"
49 #include "llvm/ADT/ArrayRef.h"
50 #include "llvm/ADT/DenseMap.h"
51 #include "llvm/ADT/ilist.h"
4752 #include "llvm/ADT/MapVector.h"
53 #include "llvm/ADT/Optional.h"
4854 #include "llvm/ADT/STLExtras.h"
49 #include "llvm/ADT/SetVector.h"
5055 #include "llvm/ADT/SmallPtrSet.h"
56 #include "llvm/ADT/SmallSet.h"
5157 #include "llvm/ADT/SmallVector.h"
52 #include "llvm/ADT/StringExtras.h"
58 #include "llvm/ADT/StringMap.h"
59 #include "llvm/ADT/StringRef.h"
60 #include "llvm/ADT/Twine.h"
61 #include "llvm/IR/Argument.h"
62 #include "llvm/IR/Attributes.h"
63 #include "llvm/IR/BasicBlock.h"
5364 #include "llvm/IR/CFG.h"
5465 #include "llvm/IR/CallSite.h"
5566 #include "llvm/IR/CallingConv.h"
67 #include "llvm/IR/Comdat.h"
68 #include "llvm/IR/Constant.h"
5669 #include "llvm/IR/ConstantRange.h"
5770 #include "llvm/IR/Constants.h"
5871 #include "llvm/IR/DataLayout.h"
5972 #include "llvm/IR/DebugInfo.h"
73 #include "llvm/IR/DebugInfoMetadata.h"
74 #include "llvm/IR/DebugLoc.h"
6075 #include "llvm/IR/DerivedTypes.h"
6176 #include "llvm/IR/DiagnosticInfo.h"
6277 #include "llvm/IR/Dominators.h"
78 #include "llvm/IR/Function.h"
79 #include "llvm/IR/GlobalAlias.h"
80 #include "llvm/IR/GlobalValue.h"
81 #include "llvm/IR/GlobalVariable.h"
6382 #include "llvm/IR/InlineAsm.h"
64 #include "llvm/IR/InstIterator.h"
83 #include "llvm/IR/InstrTypes.h"
84 #include "llvm/IR/Instruction.h"
85 #include "llvm/IR/Instructions.h"
6586 #include "llvm/IR/InstVisitor.h"
6687 #include "llvm/IR/IntrinsicInst.h"
88 #include "llvm/IR/Intrinsics.h"
6789 #include "llvm/IR/LLVMContext.h"
6890 #include "llvm/IR/Metadata.h"
6991 #include "llvm/IR/Module.h"
7092 #include "llvm/IR/ModuleSlotTracker.h"
7193 #include "llvm/IR/PassManager.h"
7294 #include "llvm/IR/Statepoint.h"
95 #include "llvm/IR/Type.h"
96 #include "llvm/IR/Use.h"
97 #include "llvm/IR/User.h"
98 #include "llvm/IR/Value.h"
7399 #include "llvm/Pass.h"
100 #include "llvm/Support/AtomicOrdering.h"
101 #include "llvm/Support/Casting.h"
74102 #include "llvm/Support/CommandLine.h"
75103 #include "llvm/Support/Debug.h"
104 #include "llvm/Support/Dwarf.h"
76105 #include "llvm/Support/ErrorHandling.h"
106 #include "llvm/Support/MathExtras.h"
77107 #include "llvm/Support/raw_ostream.h"
78108 #include
79 #include stdarg>
109 #include assert>
110 #include
111 #include
112 #include
113 #include
114
80115 using namespace llvm;
81116
82117 static cl::opt VerifyDebugInfo("verify-debug-info", cl::init(true));
83118
84119 namespace {
120
85121 struct VerifierSupport {
86122 raw_ostream *OS;
87123 const Module &M;
119155 *OS << '\n';
120156 }
121157 }
158
122159 void Write(ImmutableCallSite CS) {
123160 Write(CS.getInstruction());
124161 }
457494 /// declarations share the same calling convention.
458495 void verifyDeoptimizeCallingConvs();
459496 };
460 } // End anonymous namespace
497
498 } // end anonymous namespace
461499
462500 /// We know that cond should be true, if not print an error message.
463501 #define Assert(C, ...) \
464 do { if (!(C)) { CheckFailed(__VA_ARGS__); return; } } while (0)
502 do { if (!(C)) { CheckFailed(__VA_ARGS__); return; } } while (false)
465503
466504 /// We know that a debug info condition should be true, if not print
467505 /// an error message.
468506 #define AssertDI(C, ...) \
469 do { if (!(C)) { DebugInfoCheckFailed(__VA_ARGS__); return; } } while (0)
470
507 do { if (!(C)) { DebugInfoCheckFailed(__VA_ARGS__); return; } } while (false)
471508
472509 void Verifier::visit(Instruction &I) {
473510 for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i)
927964 for (Metadata *Op : N.getRetainedTypes()->operands()) {
928965 AssertDI(Op && (isa(Op) ||
929966 (isa(Op) &&
930 cast(Op)->isDefinition() == false)),
967 !cast(Op)->isDefinition())),
931968 "invalid retained type", &N, Op);
932969 }
933970 }
20362073 if (F.getIntrinsicID() && F.getParent()->isMaterialized()) {
20372074 const User *U;
20382075 if (F.hasAddressTaken(&U))
2039 Assert(0, "Invalid user of intrinsic instruction!", U);
2076 Assert(false, "Invalid user of intrinsic instruction!", U);
20402077 }
20412078
20422079 Assert(!F.hasDLLImportStorageClass() ||
22192256 /// a pass, if any exist, it's an error.
22202257 ///
22212258 void Verifier::visitUserOp1(Instruction &I) {
2222 Assert(0, "User-defined operators should not live outside of a pass!", &I);
2259 Assert(false, "User-defined operators should not live outside of a pass!", &I);
22232260 }
22242261
22252262 void Verifier::visitTruncInst(TruncInst &I) {
36653702 // Check to make sure that only first-class-values are operands to
36663703 // instructions.
36673704 if (!I.getOperand(i)->getType()->isFirstClassType()) {
3668 Assert(0, "Instruction operands must be first-class values!", &I);
3705 Assert(false, "Instruction operands must be first-class values!", &I);
36693706 }
36703707
36713708 if (Function *F = dyn_cast(I.getOperand(i))) {
43554392 }
43564393
43574394 namespace {
4395
43584396 struct VerifierLegacyPass : public FunctionPass {
43594397 static char ID;
43604398
44104448 AU.setPreservesAll();
44114449 }
44124450 };
4413 }
4451
4452 } // end anonymous namespace
44144453
44154454 char VerifierLegacyPass::ID = 0;
44164455 INITIALIZE_PASS(VerifierLegacyPass, "verify", "Module Verifier", false, false)