Skip to content

Commit

Permalink
[IR] Fix some Clang-tidy modernize-use-using warnings; other minor fi…
Browse files Browse the repository at this point in the history
…xes (NFC).
  • Loading branch information
EugeneZelenko committed May 10, 2017
1 parent 673794f commit 6c7b29e
Show file tree
Hide file tree
Showing 13 changed files with 265 additions and 149 deletions.
13 changes: 7 additions & 6 deletions llvm/include/llvm/IR/DerivedTypes.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- llvm/DerivedTypes.h - Classes for handling data types ---*- C++ -*-===//
//===- llvm/DerivedTypes.h - Classes for handling data types ----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
Expand Down Expand Up @@ -123,7 +123,8 @@ class FunctionType : public Type {
bool isVarArg() const { return getSubclassData()!=0; }
Type *getReturnType() const { return ContainedTys[0]; }

typedef Type::subtype_iterator param_iterator;
using param_iterator = Type::subtype_iterator;

param_iterator param_begin() const { return ContainedTys + 1; }
param_iterator param_end() const { return &ContainedTys[NumContainedTys]; }
ArrayRef<Type *> params() const {
Expand Down Expand Up @@ -198,8 +199,7 @@ class CompositeType : public Type {
/// generator for a target expects).
///
class StructType : public CompositeType {
StructType(LLVMContext &C)
: CompositeType(C, StructTyID), SymbolTableEntry(nullptr) {}
StructType(LLVMContext &C) : CompositeType(C, StructTyID) {}

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

public:
StructType(const StructType &) = delete;
Expand Down Expand Up @@ -298,7 +298,8 @@ class StructType : public CompositeType {
static bool isValidElementType(Type *ElemTy);

// Iterator access to the elements.
typedef Type::subtype_iterator element_iterator;
using element_iterator = Type::subtype_iterator;

element_iterator element_begin() const { return ContainedTys; }
element_iterator element_end() const { return &ContainedTys[NumContainedTys];}
ArrayRef<Type *> const elements() const {
Expand Down
32 changes: 21 additions & 11 deletions llvm/include/llvm/IR/Function.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- llvm/Function.h - Class to represent a single function --*- C++ -*-===//
//===- llvm/Function.h - Class to represent a single function ---*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
Expand All @@ -22,15 +22,19 @@
#include "llvm/ADT/ilist_node.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/IR/Argument.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/CallingConv.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/GlobalObject.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/OperandTraits.h"
#include "llvm/IR/SymbolTableListTraits.h"
#include "llvm/IR/Value.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Compiler.h"
#include <cassert>
#include <cstddef>
Expand All @@ -40,27 +44,31 @@

namespace llvm {

template <typename T> class Optional;
class AssemblyAnnotationWriter;
class FunctionType;
class LLVMContext;
class Constant;
class DISubprogram;
class LLVMContext;
class Module;
template <typename T> class Optional;
class raw_ostream;
class Type;
class User;

class Function : public GlobalObject, public ilist_node<Function> {
public:
typedef SymbolTableList<BasicBlock> BasicBlockListType;
using BasicBlockListType = SymbolTableList<BasicBlock>;

// BasicBlock iterators...
typedef BasicBlockListType::iterator iterator;
typedef BasicBlockListType::const_iterator const_iterator;
using iterator = BasicBlockListType::iterator;
using const_iterator = BasicBlockListType::const_iterator;

typedef Argument *arg_iterator;
typedef const Argument *const_arg_iterator;
using arg_iterator = Argument *;
using const_arg_iterator = const Argument *;

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

// Provide fast operand accessors.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);

/// Returns the FunctionType for me.
FunctionType *getFunctionType() const {
return cast<FunctionType>(getValueType());
}

/// Returns the type of the ret val.
Type *getReturnType() const { return getFunctionType()->getReturnType(); }

Expand Down
8 changes: 5 additions & 3 deletions llvm/include/llvm/IR/GetElementPtrTypeIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,23 @@
#include "llvm/IR/Operator.h"
#include "llvm/IR/User.h"
#include "llvm/Support/Casting.h"
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <iterator>

namespace llvm {

template<typename ItTy = User::const_op_iterator>
class generic_gep_type_iterator
: public std::iterator<std::forward_iterator_tag, Type *, ptrdiff_t> {
typedef std::iterator<std::forward_iterator_tag,
Type *, ptrdiff_t> super;
using super = std::iterator<std::forward_iterator_tag, Type *, ptrdiff_t>;

ItTy OpIt;
PointerUnion<StructType *, Type *> CurTy;
enum : uint64_t { Unbounded = -1ull };
uint64_t NumElements = Unbounded;

generic_gep_type_iterator() = default;

public:
Expand Down Expand Up @@ -121,7 +123,7 @@ namespace llvm {
}
};

typedef generic_gep_type_iterator<> gep_type_iterator;
using gep_type_iterator = generic_gep_type_iterator<>;

inline gep_type_iterator gep_type_begin(const User *GEP) {
auto *GEPOp = cast<GEPOperator>(GEP);
Expand Down
Loading

0 comments on commit 6c7b29e

Please sign in to comment.