1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

[IR] Fix some Clang-tidy modernize-use-using warnings; other minor fixes (NFC).

llvm-svn: 302744
This commit is contained in:
Eugene Zelenko 2017-05-10 23:41:30 +00:00
parent 7287db86c5
commit 12fae43a94
13 changed files with 266 additions and 150 deletions

View File

@ -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
//
@ -123,7 +123,8 @@ public:
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 {
@ -198,8 +199,7 @@ public:
/// 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.
@ -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;
@ -298,7 +298,8 @@ public:
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 {

View File

@ -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
//
@ -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>
@ -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
@ -124,10 +132,12 @@ public:
// 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(); }

View File

@ -21,7 +21,9 @@
#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 {
@ -29,13 +31,13 @@ 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:
@ -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);

View File

@ -1,4 +1,4 @@
//===-- llvm/Module.h - C++ class to represent a VM module ------*- C++ -*-===//
//===- llvm/Module.h - C++ class to represent a VM module -------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@ -16,6 +16,10 @@
#define LLVM_IR_MODULE_H
#include "llvm/ADT/iterator_range.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/Comdat.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Function.h"
@ -23,20 +27,27 @@
#include "llvm/IR/GlobalIFunc.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/SymbolTableListTraits.h"
#include "llvm/Support/CBindingWrapping.h"
#include "llvm/Support/CodeGen.h"
#include "llvm/Support/DataTypes.h"
#include "llvm-c/Types.h"
#include <cstddef>
#include <cstdint>
#include <iterator>
#include <memory>
#include <string>
#include <vector>
namespace llvm {
template <typename T> class Optional;
class Error;
class FunctionType;
class GVMaterializer;
class LLVMContext;
class MemoryBuffer;
class RandomNumberGenerator;
class StructType;
template <class PtrType> class SmallPtrSetImpl;
class StructType;
/// A Module instance is used to store all the information related to an
/// LLVM module. Modules are the top level container of all other LLVM
@ -54,47 +65,47 @@ class Module {
/// @{
public:
/// The type for the list of global variables.
typedef SymbolTableList<GlobalVariable> GlobalListType;
using GlobalListType = SymbolTableList<GlobalVariable>;
/// The type for the list of functions.
typedef SymbolTableList<Function> FunctionListType;
using FunctionListType = SymbolTableList<Function>;
/// The type for the list of aliases.
typedef SymbolTableList<GlobalAlias> AliasListType;
using AliasListType = SymbolTableList<GlobalAlias>;
/// The type for the list of ifuncs.
typedef SymbolTableList<GlobalIFunc> IFuncListType;
using IFuncListType = SymbolTableList<GlobalIFunc>;
/// The type for the list of named metadata.
typedef ilist<NamedMDNode> NamedMDListType;
using NamedMDListType = ilist<NamedMDNode>;
/// The type of the comdat "symbol" table.
typedef StringMap<Comdat> ComdatSymTabType;
using ComdatSymTabType = StringMap<Comdat>;
/// The Global Variable iterator.
typedef GlobalListType::iterator global_iterator;
using global_iterator = GlobalListType::iterator;
/// The Global Variable constant iterator.
typedef GlobalListType::const_iterator const_global_iterator;
using const_global_iterator = GlobalListType::const_iterator;
/// The Function iterators.
typedef FunctionListType::iterator iterator;
using iterator = FunctionListType::iterator;
/// The Function constant iterator
typedef FunctionListType::const_iterator const_iterator;
using const_iterator = FunctionListType::const_iterator;
/// The Function reverse iterator.
typedef FunctionListType::reverse_iterator reverse_iterator;
using reverse_iterator = FunctionListType::reverse_iterator;
/// The Function constant reverse iterator.
typedef FunctionListType::const_reverse_iterator const_reverse_iterator;
using const_reverse_iterator = FunctionListType::const_reverse_iterator;
/// The Global Alias iterators.
typedef AliasListType::iterator alias_iterator;
using alias_iterator = AliasListType::iterator;
/// The Global Alias constant iterator
typedef AliasListType::const_iterator const_alias_iterator;
using const_alias_iterator = AliasListType::const_iterator;
/// The Global IFunc iterators.
typedef IFuncListType::iterator ifunc_iterator;
using ifunc_iterator = IFuncListType::iterator;
/// The Global IFunc constant iterator
typedef IFuncListType::const_iterator const_ifunc_iterator;
using const_ifunc_iterator = IFuncListType::const_iterator;
/// The named metadata iterators.
typedef NamedMDListType::iterator named_metadata_iterator;
using named_metadata_iterator = NamedMDListType::iterator;
/// The named metadata constant iterators.
typedef NamedMDListType::const_iterator const_named_metadata_iterator;
using const_named_metadata_iterator = NamedMDListType::const_iterator;
/// This enumeration defines the supported behaviors of module flags.
enum ModFlagBehavior {
@ -141,6 +152,7 @@ public:
ModFlagBehavior Behavior;
MDString *Key;
Metadata *Val;
ModuleFlagEntry(ModFlagBehavior B, MDString *K, Metadata *V)
: Behavior(B), Key(K), Val(V) {}
};
@ -483,9 +495,11 @@ public:
const GlobalListType &getGlobalList() const { return GlobalList; }
/// Get the Module's list of global variables.
GlobalListType &getGlobalList() { return GlobalList; }
static GlobalListType Module::*getSublistAccess(GlobalVariable*) {
return &Module::GlobalList;
}
/// Get the Module's list of functions (constant).
const FunctionListType &getFunctionList() const { return FunctionList; }
/// Get the Module's list of functions.
@ -493,31 +507,39 @@ public:
static FunctionListType Module::*getSublistAccess(Function*) {
return &Module::FunctionList;
}
/// Get the Module's list of aliases (constant).
const AliasListType &getAliasList() const { return AliasList; }
/// Get the Module's list of aliases.
AliasListType &getAliasList() { return AliasList; }
static AliasListType Module::*getSublistAccess(GlobalAlias*) {
return &Module::AliasList;
}
/// Get the Module's list of ifuncs (constant).
const IFuncListType &getIFuncList() const { return IFuncList; }
/// Get the Module's list of ifuncs.
IFuncListType &getIFuncList() { return IFuncList; }
static IFuncListType Module::*getSublistAccess(GlobalIFunc*) {
return &Module::IFuncList;
}
/// Get the Module's list of named metadata (constant).
const NamedMDListType &getNamedMDList() const { return NamedMDList; }
/// Get the Module's list of named metadata.
NamedMDListType &getNamedMDList() { return NamedMDList; }
static NamedMDListType Module::*getSublistAccess(NamedMDNode*) {
return &Module::NamedMDList;
}
/// Get the symbol table of global variable and function identifiers
const ValueSymbolTable &getValueSymbolTable() const { return *ValSymTab; }
/// Get the Module's symbol table of global variable and function identifiers.
ValueSymbolTable &getValueSymbolTable() { return *ValSymTab; }
/// Get the Module's symbol table for COMDATs (constant).
const ComdatSymTabType &getComdatSymbolTable() const { return ComdatSymTab; }
/// Get the Module's symbol table for COMDATs.
@ -602,11 +624,11 @@ public:
/// @name Convenience iterators
/// @{
typedef concat_iterator<GlobalObject, iterator, global_iterator>
global_object_iterator;
typedef concat_iterator<const GlobalObject, const_iterator,
const_global_iterator>
const_global_object_iterator;
using global_object_iterator =
concat_iterator<GlobalObject, iterator, global_iterator>;
using const_global_object_iterator =
concat_iterator<const GlobalObject, const_iterator,
const_global_iterator>;
iterator_range<global_object_iterator> global_objects() {
return concat<GlobalObject>(functions(), globals());
@ -627,13 +649,12 @@ public:
return global_objects().end();
}
typedef concat_iterator<GlobalValue, iterator, global_iterator,
alias_iterator, ifunc_iterator>
global_value_iterator;
typedef concat_iterator<const GlobalValue, const_iterator,
const_global_iterator, const_alias_iterator,
const_ifunc_iterator>
const_global_value_iterator;
using global_value_iterator =
concat_iterator<GlobalValue, iterator, global_iterator, alias_iterator,
ifunc_iterator>;
using const_global_value_iterator =
concat_iterator<const GlobalValue, const_iterator, const_global_iterator,
const_alias_iterator, const_ifunc_iterator>;
iterator_range<global_value_iterator> global_values() {
return concat<GlobalValue>(functions(), globals(), aliases(), ifuncs());
@ -682,28 +703,35 @@ public:
: public std::iterator<std::input_iterator_tag, DICompileUnit *> {
NamedMDNode *CUs;
unsigned Idx;
void SkipNoDebugCUs();
public:
explicit debug_compile_units_iterator(NamedMDNode *CUs, unsigned Idx)
: CUs(CUs), Idx(Idx) {
SkipNoDebugCUs();
}
debug_compile_units_iterator &operator++() {
++Idx;
SkipNoDebugCUs();
return *this;
}
debug_compile_units_iterator operator++(int) {
debug_compile_units_iterator T(*this);
++Idx;
return T;
}
bool operator==(const debug_compile_units_iterator &I) const {
return Idx == I.Idx;
}
bool operator!=(const debug_compile_units_iterator &I) const {
return Idx != I.Idx;
}
DICompileUnit *operator*() const;
DICompileUnit *operator->() const;
};
@ -833,6 +861,6 @@ inline Module *unwrap(LLVMModuleProviderRef MP) {
return reinterpret_cast<Module*>(MP);
}
} // End llvm namespace
} // end namespace llvm
#endif
#endif // LLVM_IR_MODULE_H

View File

@ -1,4 +1,4 @@
//===-- llvm/Use.h - Definition of the Use class ----------------*- C++ -*-===//
//===- llvm/Use.h - Definition of the Use class -----------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@ -27,14 +27,14 @@
#include "llvm/ADT/PointerIntPair.h"
#include "llvm/Support/CBindingWrapping.h"
#include "llvm/Support/Compiler.h"
#include "llvm-c/Types.h"
namespace llvm {
class Value;
class User;
class Use;
template <typename> struct simplify_type;
class User;
class Value;
/// \brief A Use represents the edge between a Value definition and its users.
///
@ -65,23 +65,27 @@ public:
/// use the LSB regardless of pointer alignment on different targets.
struct UserRefPointerTraits {
static inline void *getAsVoidPointer(User *P) { return P; }
static inline User *getFromVoidPointer(void *P) {
return (User *)P;
}
enum { NumLowBitsAvailable = 1 };
};
// A type for the word following an array of hung-off Uses in memory, which is
// a pointer back to their User with the bottom bit set.
typedef PointerIntPair<User *, 1, unsigned, UserRefPointerTraits> UserRef;
using UserRef = PointerIntPair<User *, 1, unsigned, UserRefPointerTraits>;
/// Pointer traits for the Prev PointerIntPair. This ensures we always use
/// the two LSBs regardless of pointer alignment on different targets.
struct PrevPointerTraits {
static inline void *getAsVoidPointer(Use **P) { return P; }
static inline Use **getFromVoidPointer(void *P) {
return (Use **)P;
}
enum { NumLowBitsAvailable = 2 };
};
@ -95,9 +99,11 @@ private:
enum PrevPtrTag { zeroDigitTag, oneDigitTag, stopTag, fullStopTag };
/// Constructor
Use(PrevPtrTag tag) : Val(nullptr) { Prev.setInt(tag); }
Use(PrevPtrTag tag) { Prev.setInt(tag); }
public:
friend class Value;
operator Value *() const { return Val; }
Value *get() const { return Val; }
@ -133,7 +139,7 @@ public:
private:
const Use *getImpliedUser() const LLVM_READONLY;
Value *Val;
Value *Val = nullptr;
Use *Next;
PointerIntPair<Use **, 2, PrevPtrTag, PrevPointerTraits> Prev;
@ -153,18 +159,18 @@ private:
if (Next)
Next->setPrev(StrippedPrev);
}
friend class Value;
};
/// \brief Allow clients to treat uses just like values when using
/// casting operators.
template <> struct simplify_type<Use> {
typedef Value *SimpleType;
using SimpleType = Value *;
static SimpleType getSimplifiedValue(Use &Val) { return Val.get(); }
};
template <> struct simplify_type<const Use> {
typedef /*const*/ Value *SimpleType;
using SimpleType = /*const*/ Value *;
static SimpleType getSimplifiedValue(const Use &Val) { return Val.get(); }
};

View File

@ -37,7 +37,7 @@ struct UseListOrder {
UseListOrder &operator=(UseListOrder &&) = default;
};
typedef std::vector<UseListOrder> UseListOrderStack;
using UseListOrderStack = std::vector<UseListOrder>;
} // end namespace llvm

View File

@ -1,4 +1,4 @@
//===-- llvm/User.h - User class definition ---------------------*- C++ -*-===//
//===- llvm/User.h - User class definition ----------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@ -114,6 +114,7 @@ protected:
? OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]
: OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
}
template <int Idx> Use &Op() {
return OpFrom<Idx>(this);
}
@ -205,10 +206,10 @@ public:
// ---------------------------------------------------------------------------
// Operand Iterator interface...
//
typedef Use* op_iterator;
typedef const Use* const_op_iterator;
typedef iterator_range<op_iterator> op_range;
typedef iterator_range<const_op_iterator> const_op_range;
using op_iterator = Use*;
using const_op_iterator = const Use*;
using op_range = iterator_range<op_iterator>;
using const_op_range = iterator_range<const_op_iterator>;
op_iterator op_begin() { return getOperandList(); }
const_op_iterator op_begin() const { return getOperandList(); }
@ -252,6 +253,7 @@ public:
ptrdiff_t, const Value *, const Value *> {
explicit const_value_op_iterator(const Use *U = nullptr) :
iterator_adaptor_base(U) {}
const Value *operator*() const { return *I; }
const Value *operator->() const { return operator*(); }
};
@ -290,6 +292,7 @@ public:
return isa<Instruction>(V) || isa<Constant>(V);
}
};
// Either Use objects, or a Use pointer can be prepended to User.
static_assert(alignof(Use) >= alignof(User),
"Alignment is insufficient after objects prepended to User");
@ -297,13 +300,15 @@ static_assert(alignof(Use *) >= alignof(User),
"Alignment is insufficient after objects prepended to User");
template<> struct simplify_type<User::op_iterator> {
typedef Value* SimpleType;
using SimpleType = Value*;
static SimpleType getSimplifiedValue(User::op_iterator &Val) {
return Val->get();
}
};
template<> struct simplify_type<User::const_op_iterator> {
typedef /*const*/ Value* SimpleType;
using SimpleType = /*const*/ Value*;
static SimpleType getSimplifiedValue(User::const_op_iterator &Val) {
return Val->get();
}

View File

@ -1,4 +1,4 @@
//===-- llvm/Value.h - Definition of the Value class ------------*- C++ -*-===//
//===- llvm/Value.h - Definition of the Value class -------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@ -44,12 +44,12 @@ class LLVMContext;
class Module;
class ModuleSlotTracker;
class raw_ostream;
template<typename ValueTy> class StringMapEntry;
class StringRef;
class Twine;
class Type;
template<typename ValueTy> class StringMapEntry;
typedef StringMapEntry<Value*> ValueName;
using ValueName = StringMapEntry<Value*>;
//===----------------------------------------------------------------------===//
// Value Class
@ -120,12 +120,14 @@ private:
template <typename UseT> // UseT == 'Use' or 'const Use'
class use_iterator_impl
: public std::iterator<std::forward_iterator_tag, UseT *> {
UseT *U;
explicit use_iterator_impl(UseT *u) : U(u) {}
friend class Value;
UseT *U = nullptr;
explicit use_iterator_impl(UseT *u) : U(u) {}
public:
use_iterator_impl() : U() {}
use_iterator_impl() = default;
bool operator==(const use_iterator_impl &x) const { return U == x.U; }
bool operator!=(const use_iterator_impl &x) const { return !operator==(x); }
@ -157,10 +159,12 @@ private:
template <typename UserTy> // UserTy == 'User' or 'const User'
class user_iterator_impl
: public std::iterator<std::forward_iterator_tag, UserTy *> {
use_iterator_impl<Use> UI;
explicit user_iterator_impl(Use *U) : UI(U) {}
friend class Value;
use_iterator_impl<Use> UI;
explicit user_iterator_impl(Use *U) : UI(U) {}
public:
user_iterator_impl() = default;
@ -309,8 +313,8 @@ public:
return UseList == nullptr;
}
typedef use_iterator_impl<Use> use_iterator;
typedef use_iterator_impl<const Use> const_use_iterator;
using use_iterator = use_iterator_impl<Use>;
using const_use_iterator = use_iterator_impl<const Use>;
use_iterator materialized_use_begin() { return use_iterator(UseList); }
const_use_iterator materialized_use_begin() const {
return const_use_iterator(UseList);
@ -345,8 +349,8 @@ public:
return UseList == nullptr;
}
typedef user_iterator_impl<User> user_iterator;
typedef user_iterator_impl<const User> const_user_iterator;
using user_iterator = user_iterator_impl<User>;
using const_user_iterator = user_iterator_impl<const User>;
user_iterator materialized_user_begin() { return user_iterator(UseList); }
const_user_iterator materialized_user_begin() const {
return const_user_iterator(UseList);
@ -560,7 +564,6 @@ public:
/// block.
const Value *DoPHITranslation(const BasicBlock *CurBB,
const BasicBlock *PredBB) const;
Value *DoPHITranslation(const BasicBlock *CurBB, const BasicBlock *PredBB) {
return const_cast<Value *>(
static_cast<const Value *>(this)->DoPHITranslation(CurBB, PredBB));
@ -606,7 +609,7 @@ private:
Use *Merged;
Use **Next = &Merged;
for (;;) {
while (true) {
if (!L) {
*Next = R;
break;

View File

@ -17,10 +17,10 @@
#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/ADT/PointerIntPair.h"
#include "llvm/IR/Value.h"
#include "llvm/Support/Casting.h"
#include <cassert>
namespace llvm {
class ValueHandleBase;
template<typename From> struct simplify_type;
/// \brief This is the common base class of value handles.
///
@ -29,6 +29,7 @@ template<typename From> struct simplify_type;
/// below for details.
class ValueHandleBase {
friend class Value;
protected:
/// \brief This indicates what sub class the handle actually is.
///
@ -40,24 +41,23 @@ protected:
: ValueHandleBase(RHS.PrevPair.getInt(), RHS) {}
ValueHandleBase(HandleBaseKind Kind, const ValueHandleBase &RHS)
: PrevPair(nullptr, Kind), Next(nullptr), Val(RHS.getValPtr()) {
: PrevPair(nullptr, Kind), Val(RHS.getValPtr()) {
if (isValid(getValPtr()))
AddToExistingUseList(RHS.getPrevPtr());
}
private:
PointerIntPair<ValueHandleBase**, 2, HandleBaseKind> PrevPair;
ValueHandleBase *Next;
Value *Val;
ValueHandleBase *Next = nullptr;
Value *Val = nullptr;
void setValPtr(Value *V) { Val = V; }
public:
explicit ValueHandleBase(HandleBaseKind Kind)
: PrevPair(nullptr, Kind), Next(nullptr), Val(nullptr) {}
: PrevPair(nullptr, Kind) {}
ValueHandleBase(HandleBaseKind Kind, Value *V)
: PrevPair(nullptr, Kind), Next(nullptr), Val(V) {
: PrevPair(nullptr, Kind), Val(V) {
if (isValid(getValPtr()))
AddToUseList();
}
@ -162,11 +162,13 @@ public:
// Specialize simplify_type to allow WeakVH to participate in
// dyn_cast, isa, etc.
template <> struct simplify_type<WeakVH> {
typedef Value *SimpleType;
using SimpleType = Value *;
static SimpleType getSimplifiedValue(WeakVH &WVH) { return WVH; }
};
template <> struct simplify_type<const WeakVH> {
typedef Value *SimpleType;
using SimpleType = Value *;
static SimpleType getSimplifiedValue(const WeakVH &WVH) { return WVH; }
};
@ -205,11 +207,13 @@ public:
// Specialize simplify_type to allow WeakTrackingVH to participate in
// dyn_cast, isa, etc.
template <> struct simplify_type<WeakTrackingVH> {
typedef Value *SimpleType;
using SimpleType = Value *;
static SimpleType getSimplifiedValue(WeakTrackingVH &WVH) { return WVH; }
};
template <> struct simplify_type<const WeakTrackingVH> {
typedef Value *SimpleType;
using SimpleType = Value *;
static SimpleType getSimplifiedValue(const WeakTrackingVH &WVH) {
return WVH;
}
@ -236,7 +240,7 @@ class AssertingVH
: public ValueHandleBase
#endif
{
friend struct DenseMapInfo<AssertingVH<ValueTy> >;
friend struct DenseMapInfo<AssertingVH<ValueTy>>;
#ifndef NDEBUG
Value *getRawValPtr() const { return ValueHandleBase::getValPtr(); }
@ -282,20 +286,23 @@ public:
// Specialize DenseMapInfo to allow AssertingVH to participate in DenseMap.
template<typename T>
struct DenseMapInfo<AssertingVH<T> > {
struct DenseMapInfo<AssertingVH<T>> {
static inline AssertingVH<T> getEmptyKey() {
AssertingVH<T> Res;
Res.setRawValPtr(DenseMapInfo<Value *>::getEmptyKey());
return Res;
}
static inline AssertingVH<T> getTombstoneKey() {
AssertingVH<T> Res;
Res.setRawValPtr(DenseMapInfo<Value *>::getTombstoneKey());
return Res;
}
static unsigned getHashValue(const AssertingVH<T> &Val) {
return DenseMapInfo<Value *>::getHashValue(Val.getRawValPtr());
}
static bool isEqual(const AssertingVH<T> &LHS, const AssertingVH<T> &RHS) {
return DenseMapInfo<Value *>::isEqual(LHS.getRawValPtr(),
RHS.getRawValPtr());
@ -303,7 +310,7 @@ struct DenseMapInfo<AssertingVH<T> > {
};
template <typename T>
struct isPodLike<AssertingVH<T> > {
struct isPodLike<AssertingVH<T>> {
#ifdef NDEBUG
static const bool value = true;
#else
@ -356,7 +363,7 @@ public:
static Value *GetAsValue(const Value *V) { return const_cast<Value*>(V); }
public:
TrackingVH() {}
TrackingVH() = default;
TrackingVH(ValueTy *P) { setValPtr(P); }
operator ValueTy*() const {
@ -495,10 +502,12 @@ public:
PoisoningVH(ValueTy *P) : CallbackVH(GetAsValue(P)) {}
PoisoningVH(const PoisoningVH &RHS)
: CallbackVH(RHS), Poisoned(RHS.Poisoned) {}
~PoisoningVH() {
if (Poisoned)
clearValPtr();
}
PoisoningVH &operator=(const PoisoningVH &RHS) {
if (Poisoned)
clearValPtr();
@ -523,14 +532,17 @@ template <typename T> struct DenseMapInfo<PoisoningVH<T>> {
Res.setRawValPtr(DenseMapInfo<Value *>::getEmptyKey());
return Res;
}
static inline PoisoningVH<T> getTombstoneKey() {
PoisoningVH<T> Res;
Res.setRawValPtr(DenseMapInfo<Value *>::getTombstoneKey());
return Res;
}
static unsigned getHashValue(const PoisoningVH<T> &Val) {
return DenseMapInfo<Value *>::getHashValue(Val.getRawValPtr());
}
static bool isEqual(const PoisoningVH<T> &LHS, const PoisoningVH<T> &RHS) {
return DenseMapInfo<Value *>::isEqual(LHS.getRawValPtr(),
RHS.getRawValPtr());
@ -545,6 +557,6 @@ template <typename T> struct isPodLike<PoisoningVH<T>> {
#endif
};
} // End llvm namespace
} // end namespace llvm
#endif
#endif // LLVM_IR_VALUEHANDLE_H

View File

@ -46,7 +46,6 @@ namespace llvm {
template<typename KeyT, typename ValueT, typename Config>
class ValueMapCallbackVH;
template<typename DenseMapT, typename KeyT>
class ValueMapIterator;
template<typename DenseMapT, typename KeyT>
@ -57,7 +56,7 @@ class ValueMapConstIterator;
/// as possible with future versions of ValueMap.
template<typename KeyT, typename MutexT = sys::Mutex>
struct ValueMapConfig {
typedef MutexT mutex_type;
using mutex_type = MutexT;
/// If FollowRAUW is true, the ValueMap will update mappings on RAUW. If it's
/// false, the ValueMap will leave the original mapping in place.
@ -87,21 +86,21 @@ template<typename KeyT, typename ValueT, typename Config =ValueMapConfig<KeyT>>
class ValueMap {
friend class ValueMapCallbackVH<KeyT, ValueT, Config>;
typedef ValueMapCallbackVH<KeyT, ValueT, Config> ValueMapCVH;
typedef DenseMap<ValueMapCVH, ValueT, DenseMapInfo<ValueMapCVH>> MapT;
typedef DenseMap<const Metadata *, TrackingMDRef> MDMapT;
typedef typename Config::ExtraData ExtraData;
using ValueMapCVH = ValueMapCallbackVH<KeyT, ValueT, Config>;
using MapT = DenseMap<ValueMapCVH, ValueT, DenseMapInfo<ValueMapCVH>>;
using MDMapT = DenseMap<const Metadata *, TrackingMDRef>;
using ExtraData = typename Config::ExtraData;
MapT Map;
Optional<MDMapT> MDMap;
ExtraData Data;
bool MayMapMetadata = true;
public:
typedef KeyT key_type;
typedef ValueT mapped_type;
typedef std::pair<KeyT, ValueT> value_type;
typedef unsigned size_type;
using key_type = KeyT;
using mapped_type = ValueT;
using value_type = std::pair<KeyT, ValueT>;
using size_type = unsigned;
explicit ValueMap(unsigned NumInitBuckets = 64)
: Map(NumInitBuckets), Data() {}
@ -132,8 +131,9 @@ public:
return Where->second.get();
}
typedef ValueMapIterator<MapT, KeyT> iterator;
typedef ValueMapConstIterator<MapT, KeyT> const_iterator;
using iterator = ValueMapIterator<MapT, KeyT>;
using const_iterator = ValueMapConstIterator<MapT, KeyT>;
inline iterator begin() { return iterator(Map.begin()); }
inline iterator end() { return iterator(Map.end()); }
inline const_iterator begin() const { return const_iterator(Map.begin()); }
@ -244,8 +244,8 @@ class ValueMapCallbackVH final : public CallbackVH {
friend class ValueMap<KeyT, ValueT, Config>;
friend struct DenseMapInfo<ValueMapCallbackVH>;
typedef ValueMap<KeyT, ValueT, Config> ValueMapT;
typedef typename std::remove_pointer<KeyT>::type KeySansPointerT;
using ValueMapT = ValueMap<KeyT, ValueT, Config>;
using KeySansPointerT = typename std::remove_pointer<KeyT>::type;
ValueMapT *Map;
@ -298,7 +298,7 @@ public:
template<typename KeyT, typename ValueT, typename Config>
struct DenseMapInfo<ValueMapCallbackVH<KeyT, ValueT, Config>> {
typedef ValueMapCallbackVH<KeyT, ValueT, Config> VH;
using VH = ValueMapCallbackVH<KeyT, ValueT, Config>;
static inline VH getEmptyKey() {
return VH(DenseMapInfo<Value *>::getEmptyKey());
@ -330,8 +330,8 @@ class ValueMapIterator :
public std::iterator<std::forward_iterator_tag,
std::pair<KeyT, typename DenseMapT::mapped_type>,
ptrdiff_t> {
typedef typename DenseMapT::iterator BaseT;
typedef typename DenseMapT::mapped_type ValueT;
using BaseT = typename DenseMapT::iterator;
using ValueT = typename DenseMapT::mapped_type;
BaseT I;
@ -344,7 +344,9 @@ public:
struct ValueTypeProxy {
const KeyT first;
ValueT& second;
ValueTypeProxy *operator->() { return this; }
operator std::pair<KeyT, ValueT>() const {
return std::make_pair(first, second);
}
@ -380,8 +382,8 @@ class ValueMapConstIterator :
public std::iterator<std::forward_iterator_tag,
std::pair<KeyT, typename DenseMapT::mapped_type>,
ptrdiff_t> {
typedef typename DenseMapT::const_iterator BaseT;
typedef typename DenseMapT::mapped_type ValueT;
using BaseT = typename DenseMapT::const_iterator;
using ValueT = typename DenseMapT::mapped_type;
BaseT I;

View File

@ -49,13 +49,13 @@ class ValueSymbolTable {
/// @{
public:
/// @brief A mapping of names to values.
typedef StringMap<Value*> ValueMap;
using ValueMap = StringMap<Value*>;
/// @brief An iterator over a ValueMap.
typedef ValueMap::iterator iterator;
using iterator = ValueMap::iterator;
/// @brief A const_iterator over a ValueMap.
typedef ValueMap::const_iterator const_iterator;
using const_iterator = ValueMap::const_iterator;
/// @}
/// @name Constructors

View File

@ -1,4 +1,4 @@
//===-- Function.cpp - Implement the Global object classes ----------------===//
//===- Function.cpp - Implement the Global object classes -----------------===//
//
// The LLVM Compiler Infrastructure
//
@ -11,21 +11,51 @@
//
//===----------------------------------------------------------------------===//
#include "llvm/IR/Function.h"
#include "LLVMContextImpl.h"
#include "SymbolTableListTraitsImpl.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/None.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/CodeGen/ValueTypes.h"
#include "llvm/IR/Argument.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/InstIterator.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/MDBuilder.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/SymbolTableListTraits.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Use.h"
#include "llvm/IR/User.h"
#include "llvm/IR/Value.h"
#include "llvm/IR/ValueSymbolTable.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/ErrorHandling.h"
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <string>
using namespace llvm;
// Explicit instantiations of SymbolTableListTraits since some of the methods
@ -36,7 +66,7 @@ template class llvm::SymbolTableListTraits<BasicBlock>;
// Argument Implementation
//===----------------------------------------------------------------------===//
void Argument::anchor() { }
void Argument::anchor() {}
Argument::Argument(Type *Ty, const Twine &Name, Function *Par, unsigned ArgNo)
: Value(Ty, Value::ArgumentVal), Parent(Par), ArgNo(ArgNo) {
@ -186,7 +216,7 @@ Function::Function(FunctionType *Ty, LinkageTypes Linkage, const Twine &name,
Module *ParentModule)
: GlobalObject(Ty, Value::FunctionVal,
OperandTraits<Function>::op_begin(this), 0, Linkage, name),
Arguments(nullptr), NumArgs(Ty->getNumParams()) {
NumArgs(Ty->getNumParams()) {
assert(FunctionType::isValidReturnType(getReturnType()) &&
"invalid return type");
setGlobalObjectSubClassData(0);
@ -486,10 +516,10 @@ void Function::recalculateIntrinsicID() {
static std::string getMangledTypeStr(Type* Ty) {
std::string Result;
if (PointerType* PTyp = dyn_cast<PointerType>(Ty)) {
Result += "p" + llvm::utostr(PTyp->getAddressSpace()) +
Result += "p" + utostr(PTyp->getAddressSpace()) +
getMangledTypeStr(PTyp->getElementType());
} else if (ArrayType* ATyp = dyn_cast<ArrayType>(Ty)) {
Result += "a" + llvm::utostr(ATyp->getNumElements()) +
Result += "a" + utostr(ATyp->getNumElements()) +
getMangledTypeStr(ATyp->getElementType());
} else if (StructType *STyp = dyn_cast<StructType>(Ty)) {
if (!STyp->isLiteral()) {
@ -534,7 +564,6 @@ std::string Intrinsic::getName(ID id, ArrayRef<Type*> Tys) {
return Result;
}
/// IIT_Info - These are enumerators that describe the entries returned by the
/// getIntrinsicInfoTableEntries function.
///
@ -585,9 +614,10 @@ enum IIT_Info {
static void DecodeIITType(unsigned &NextElt, ArrayRef<unsigned char> Infos,
SmallVectorImpl<Intrinsic::IITDescriptor> &OutputTable) {
using namespace Intrinsic;
IIT_Info Info = IIT_Info(Infos[NextElt++]);
unsigned StructElts = 2;
using namespace Intrinsic;
switch (Info) {
case IIT_Done:
@ -742,7 +772,6 @@ static void DecodeIITType(unsigned &NextElt, ArrayRef<unsigned char> Infos,
llvm_unreachable("unhandled");
}
#define GET_INTRINSIC_GENERATOR_GLOBAL
#include "llvm/IR/Intrinsics.gen"
#undef GET_INTRINSIC_GENERATOR_GLOBAL
@ -780,10 +809,10 @@ void Intrinsic::getIntrinsicInfoTableEntries(ID id,
DecodeIITType(NextElt, IITEntries, T);
}
static Type *DecodeFixedType(ArrayRef<Intrinsic::IITDescriptor> &Infos,
ArrayRef<Type*> Tys, LLVMContext &Context) {
using namespace Intrinsic;
IITDescriptor D = Infos.front();
Infos = Infos.slice(1);
@ -855,12 +884,10 @@ static Type *DecodeFixedType(ArrayRef<Intrinsic::IITDescriptor> &Infos,
case IITDescriptor::VecOfAnyPtrsToElt:
// Return the overloaded type (which determines the pointers address space)
return Tys[D.getOverloadArgNumber()];
}
}
llvm_unreachable("unhandled");
}
FunctionType *Intrinsic::getType(LLVMContext &Context,
ID id, ArrayRef<Type*> Tys) {
SmallVector<IITDescriptor, 8> Table;

View File

@ -1,4 +1,4 @@
//===-- Module.cpp - Implement the Module class ---------------------------===//
//===- Module.cpp - Implement the Module class ----------------------------===//
//
// The LLVM Compiler Infrastructure
//
@ -11,26 +11,46 @@
//
//===----------------------------------------------------------------------===//
#include "llvm/IR/Module.h"
#include "SymbolTableListTraitsImpl.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/Comdat.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalAlias.h"
#include "llvm/IR/GlobalIFunc.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/GVMaterializer.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/SymbolTableListTraits.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/TypeFinder.h"
#include "llvm/Support/Dwarf.h"
#include "llvm/IR/Value.h"
#include "llvm/IR/ValueSymbolTable.h"
#include "llvm/Pass.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CodeGen.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/RandomNumberGenerator.h"
#include <algorithm>
#include <cstdlib>
#include <cassert>
#include <cstdint>
#include <memory>
#include <utility>
#include <vector>
using namespace llvm;