Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit dc6cb60

Browse files
committed
[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
1 parent 78f7d49 commit dc6cb60

File tree

13 files changed

+265
-149
lines changed

13 files changed

+265
-149
lines changed

include/llvm/IR/DerivedTypes.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- llvm/DerivedTypes.h - Classes for handling data types ---*- C++ -*-===//
1+
//===- llvm/DerivedTypes.h - Classes for handling data types ----*- C++ -*-===//
22
//
33
// The LLVM Compiler Infrastructure
44
//
@@ -123,7 +123,8 @@ class FunctionType : public Type {
123123
bool isVarArg() const { return getSubclassData()!=0; }
124124
Type *getReturnType() const { return ContainedTys[0]; }
125125

126-
typedef Type::subtype_iterator param_iterator;
126+
using param_iterator = Type::subtype_iterator;
127+
127128
param_iterator param_begin() const { return ContainedTys + 1; }
128129
param_iterator param_end() const { return &ContainedTys[NumContainedTys]; }
129130
ArrayRef<Type *> params() const {
@@ -198,8 +199,7 @@ class CompositeType : public Type {
198199
/// generator for a target expects).
199200
///
200201
class StructType : public CompositeType {
201-
StructType(LLVMContext &C)
202-
: CompositeType(C, StructTyID), SymbolTableEntry(nullptr) {}
202+
StructType(LLVMContext &C) : CompositeType(C, StructTyID) {}
203203

204204
enum {
205205
/// This is the contents of the SubClassData field.
@@ -213,7 +213,7 @@ class StructType : public CompositeType {
213213
/// symbol table entry (maintained by LLVMContext) for the struct.
214214
/// This is null if the type is an literal struct or if it is a identified
215215
/// type that has an empty name.
216-
void *SymbolTableEntry;
216+
void *SymbolTableEntry = nullptr;
217217

218218
public:
219219
StructType(const StructType &) = delete;
@@ -298,7 +298,8 @@ class StructType : public CompositeType {
298298
static bool isValidElementType(Type *ElemTy);
299299

300300
// Iterator access to the elements.
301-
typedef Type::subtype_iterator element_iterator;
301+
using element_iterator = Type::subtype_iterator;
302+
302303
element_iterator element_begin() const { return ContainedTys; }
303304
element_iterator element_end() const { return &ContainedTys[NumContainedTys];}
304305
ArrayRef<Type *> const elements() const {

include/llvm/IR/Function.h

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- llvm/Function.h - Class to represent a single function --*- C++ -*-===//
1+
//===- llvm/Function.h - Class to represent a single function ---*- C++ -*-===//
22
//
33
// The LLVM Compiler Infrastructure
44
//
@@ -22,15 +22,19 @@
2222
#include "llvm/ADT/ilist_node.h"
2323
#include "llvm/ADT/iterator_range.h"
2424
#include "llvm/ADT/StringRef.h"
25+
#include "llvm/ADT/Twine.h"
2526
#include "llvm/IR/Argument.h"
2627
#include "llvm/IR/Attributes.h"
2728
#include "llvm/IR/BasicBlock.h"
2829
#include "llvm/IR/CallingConv.h"
30+
#include "llvm/IR/DerivedTypes.h"
2931
#include "llvm/IR/GlobalObject.h"
32+
#include "llvm/IR/GlobalValue.h"
3033
#include "llvm/IR/Intrinsics.h"
3134
#include "llvm/IR/OperandTraits.h"
3235
#include "llvm/IR/SymbolTableListTraits.h"
3336
#include "llvm/IR/Value.h"
37+
#include "llvm/Support/Casting.h"
3438
#include "llvm/Support/Compiler.h"
3539
#include <cassert>
3640
#include <cstddef>
@@ -40,27 +44,31 @@
4044

4145
namespace llvm {
4246

43-
template <typename T> class Optional;
4447
class AssemblyAnnotationWriter;
45-
class FunctionType;
46-
class LLVMContext;
48+
class Constant;
4749
class DISubprogram;
50+
class LLVMContext;
51+
class Module;
52+
template <typename T> class Optional;
53+
class raw_ostream;
54+
class Type;
55+
class User;
4856

4957
class Function : public GlobalObject, public ilist_node<Function> {
5058
public:
51-
typedef SymbolTableList<BasicBlock> BasicBlockListType;
59+
using BasicBlockListType = SymbolTableList<BasicBlock>;
5260

5361
// BasicBlock iterators...
54-
typedef BasicBlockListType::iterator iterator;
55-
typedef BasicBlockListType::const_iterator const_iterator;
62+
using iterator = BasicBlockListType::iterator;
63+
using const_iterator = BasicBlockListType::const_iterator;
5664

57-
typedef Argument *arg_iterator;
58-
typedef const Argument *const_arg_iterator;
65+
using arg_iterator = Argument *;
66+
using const_arg_iterator = const Argument *;
5967

6068
private:
6169
// Important things that make up a function!
62-
BasicBlockListType BasicBlocks; ///< The basic blocks
63-
mutable Argument *Arguments; ///< The formal arguments
70+
BasicBlockListType BasicBlocks; ///< The basic blocks
71+
mutable Argument *Arguments = nullptr; ///< The formal arguments
6472
size_t NumArgs;
6573
std::unique_ptr<ValueSymbolTable>
6674
SymTab; ///< Symbol table of args/instructions
@@ -124,10 +132,12 @@ class Function : public GlobalObject, public ilist_node<Function> {
124132

125133
// Provide fast operand accessors.
126134
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
135+
127136
/// Returns the FunctionType for me.
128137
FunctionType *getFunctionType() const {
129138
return cast<FunctionType>(getValueType());
130139
}
140+
131141
/// Returns the type of the ret val.
132142
Type *getReturnType() const { return getFunctionType()->getReturnType(); }
133143

include/llvm/IR/GetElementPtrTypeIterator.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,23 @@
2121
#include "llvm/IR/Operator.h"
2222
#include "llvm/IR/User.h"
2323
#include "llvm/Support/Casting.h"
24+
#include <cassert>
2425
#include <cstddef>
26+
#include <cstdint>
2527
#include <iterator>
2628

2729
namespace llvm {
2830

2931
template<typename ItTy = User::const_op_iterator>
3032
class generic_gep_type_iterator
3133
: public std::iterator<std::forward_iterator_tag, Type *, ptrdiff_t> {
32-
typedef std::iterator<std::forward_iterator_tag,
33-
Type *, ptrdiff_t> super;
34+
using super = std::iterator<std::forward_iterator_tag, Type *, ptrdiff_t>;
3435

3536
ItTy OpIt;
3637
PointerUnion<StructType *, Type *> CurTy;
3738
enum : uint64_t { Unbounded = -1ull };
3839
uint64_t NumElements = Unbounded;
40+
3941
generic_gep_type_iterator() = default;
4042

4143
public:
@@ -121,7 +123,7 @@ namespace llvm {
121123
}
122124
};
123125

124-
typedef generic_gep_type_iterator<> gep_type_iterator;
126+
using gep_type_iterator = generic_gep_type_iterator<>;
125127

126128
inline gep_type_iterator gep_type_begin(const User *GEP) {
127129
auto *GEPOp = cast<GEPOperator>(GEP);

0 commit comments

Comments
 (0)