[IR] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

llvm-svn: 295383
This commit is contained in:
Eugene Zelenko 2017-02-17 00:00:09 +00:00
parent 7b327d051b
commit deaf695138
15 changed files with 228 additions and 151 deletions

View File

@ -1,4 +1,4 @@
//===-- llvm/Attributes.h - Container for Attributes ------------*- C++ -*-===//
//===- llvm/Attributes.h - Container for Attributes -------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@ -18,14 +18,17 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/ADT/Optional.h"
#include "llvm/Support/Compiler.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/PointerLikeTypeTraits.h"
#include "llvm-c/Types.h"
#include <bitset>
#include <cassert>
#include <cstdint>
#include <map>
#include <string>
#include <utility>
namespace llvm {
@ -33,7 +36,6 @@ class AttrBuilder;
class AttributeImpl;
class AttributeSetImpl;
class AttributeSetNode;
class Constant;
template<typename T> struct DenseMapInfo;
class Function;
class LLVMContext;
@ -73,11 +75,12 @@ public:
};
private:
AttributeImpl *pImpl;
AttributeImpl *pImpl = nullptr;
Attribute(AttributeImpl *A) : pImpl(A) {}
public:
Attribute() : pImpl(nullptr) {}
Attribute() = default;
//===--------------------------------------------------------------------===//
// Attribute Construction
@ -211,30 +214,31 @@ private:
friend class AttrBuilder;
friend class AttributeSetImpl;
friend class AttributeSetNode;
template <typename Ty> friend struct DenseMapInfo;
/// \brief The attributes that we are managing. This can be null to represent
/// the empty attributes list.
AttributeSetImpl *pImpl;
AttributeSetImpl *pImpl = nullptr;
/// \brief The attributes for the specified index are returned.
AttributeSetNode *getAttributes(unsigned Index) const;
/// \brief Create an AttributeSet with the specified parameters in it.
static AttributeSet get(LLVMContext &C,
ArrayRef<std::pair<unsigned, Attribute> > Attrs);
ArrayRef<std::pair<unsigned, Attribute>> Attrs);
static AttributeSet get(LLVMContext &C,
ArrayRef<std::pair<unsigned,
AttributeSetNode*> > Attrs);
AttributeSetNode*>> Attrs);
static AttributeSet getImpl(LLVMContext &C,
ArrayRef<std::pair<unsigned,
AttributeSetNode*> > Attrs);
AttributeSetNode*>> Attrs);
explicit AttributeSet(AttributeSetImpl *LI) : pImpl(LI) {}
public:
AttributeSet() : pImpl(nullptr) {}
AttributeSet() = default;
//===--------------------------------------------------------------------===//
// AttributeSet Construction and Mutation
@ -424,15 +428,18 @@ template<> struct DenseMapInfo<AttributeSet> {
Val <<= PointerLikeTypeTraits<void*>::NumLowBitsAvailable;
return AttributeSet(reinterpret_cast<AttributeSetImpl*>(Val));
}
static inline AttributeSet getTombstoneKey() {
uintptr_t Val = static_cast<uintptr_t>(-2);
Val <<= PointerLikeTypeTraits<void*>::NumLowBitsAvailable;
return AttributeSet(reinterpret_cast<AttributeSetImpl*>(Val));
}
static unsigned getHashValue(AttributeSet AS) {
return (unsigned((uintptr_t)AS.pImpl) >> 4) ^
(unsigned((uintptr_t)AS.pImpl) >> 9);
}
static bool isEqual(AttributeSet LHS, AttributeSet RHS) { return LHS == RHS; }
};
@ -445,19 +452,15 @@ template<> struct DenseMapInfo<AttributeSet> {
class AttrBuilder {
std::bitset<Attribute::EndAttrKinds> Attrs;
std::map<std::string, std::string> TargetDepAttrs;
uint64_t Alignment;
uint64_t StackAlignment;
uint64_t DerefBytes;
uint64_t DerefOrNullBytes;
uint64_t AllocSizeArgs;
uint64_t Alignment = 0;
uint64_t StackAlignment = 0;
uint64_t DerefBytes = 0;
uint64_t DerefOrNullBytes = 0;
uint64_t AllocSizeArgs = 0;
public:
AttrBuilder()
: Attrs(0), Alignment(0), StackAlignment(0), DerefBytes(0),
DerefOrNullBytes(0), AllocSizeArgs(0) {}
AttrBuilder(const Attribute &A)
: Attrs(0), Alignment(0), StackAlignment(0), DerefBytes(0),
DerefOrNullBytes(0), AllocSizeArgs(0) {
AttrBuilder() = default;
AttrBuilder(const Attribute &A) {
addAttribute(A);
}
AttrBuilder(AttributeSet AS, unsigned Idx);
@ -562,8 +565,8 @@ public:
typedef std::pair<std::string, std::string> td_type;
typedef std::map<std::string, std::string>::iterator td_iterator;
typedef std::map<std::string, std::string>::const_iterator td_const_iterator;
typedef llvm::iterator_range<td_iterator> td_range;
typedef llvm::iterator_range<td_const_iterator> td_const_range;
typedef iterator_range<td_iterator> td_range;
typedef iterator_range<td_const_iterator> td_const_range;
td_iterator td_begin() { return TargetDepAttrs.begin(); }
td_iterator td_end() { return TargetDepAttrs.end(); }
@ -600,4 +603,4 @@ void mergeAttributesForInlining(Function &Caller, const Function &Callee);
} // end llvm namespace
#endif
#endif // LLVM_IR_ATTRIBUTES_H

View File

@ -1,4 +1,4 @@
//===-- llvm/IR/Comdat.h - Comdat definitions -------------------*- C++ -*-===//
//===- llvm/IR/Comdat.h - Comdat definitions --------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@ -51,8 +51,8 @@ private:
Comdat();
// Points to the map in Module.
StringMapEntry<Comdat> *Name;
SelectionKind SK;
StringMapEntry<Comdat> *Name = nullptr;
SelectionKind SK = Any;
};
inline raw_ostream &operator<<(raw_ostream &OS, const Comdat &C) {

View File

@ -1,4 +1,4 @@
//===-- llvm/InlineAsm.h - Class to represent inline asm strings-*- C++ -*-===//
//===- llvm/InlineAsm.h - Class to represent inline asm strings -*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@ -102,12 +102,14 @@ public:
/// input constraint is required to match it (e.g. "0"). The value is the
/// constraint number that matches this one (for example, if this is
/// constraint #0 and constraint #4 has the value "0", this will be 4).
signed char MatchingInput;
signed char MatchingInput = -1;
/// Code - The constraint code, either the register name (in braces) or the
/// constraint letter/number.
ConstraintCodeVector Codes;
/// Default constructor.
SubConstraintInfo() : MatchingInput(-1) {}
SubConstraintInfo() = default;
};
typedef std::vector<SubConstraintInfo> SubConstraintInfoVector;
@ -117,17 +119,17 @@ public:
struct ConstraintInfo {
/// Type - The basic type of the constraint: input/output/clobber
///
ConstraintPrefix Type;
ConstraintPrefix Type = isInput;
/// isEarlyClobber - "&": output operand writes result before inputs are all
/// read. This is only ever set for an output operand.
bool isEarlyClobber;
bool isEarlyClobber = false;
/// MatchingInput - If this is not -1, this is an output constraint where an
/// input constraint is required to match it (e.g. "0"). The value is the
/// constraint number that matches this one (for example, if this is
/// constraint #0 and constraint #4 has the value "0", this will be 4).
signed char MatchingInput;
signed char MatchingInput = -1;
/// hasMatchingInput - Return true if this is an output constraint that has
/// a matching input constraint.
@ -135,30 +137,30 @@ public:
/// isCommutative - This is set to true for a constraint that is commutative
/// with the next operand.
bool isCommutative;
bool isCommutative = false;
/// isIndirect - True if this operand is an indirect operand. This means
/// that the address of the source or destination is present in the call
/// instruction, instead of it being returned or passed in explicitly. This
/// is represented with a '*' in the asm string.
bool isIndirect;
bool isIndirect = false;
/// Code - The constraint code, either the register name (in braces) or the
/// constraint letter/number.
ConstraintCodeVector Codes;
/// isMultipleAlternative - '|': has multiple-alternative constraints.
bool isMultipleAlternative;
bool isMultipleAlternative = false;
/// multipleAlternatives - If there are multiple alternative constraints,
/// this array will contain them. Otherwise it will be empty.
SubConstraintInfoVector multipleAlternatives;
/// The currently selected alternative constraint index.
unsigned currentAlternativeIndex;
unsigned currentAlternativeIndex = 0;
/// Default constructor.
ConstraintInfo();
ConstraintInfo() = default;
/// Parse - Analyze the specified string (e.g. "=*&{eax}") and fill in the
/// fields in this structure. If the constraint string is not understood,

View File

@ -269,12 +269,11 @@ public:
private:
LLVMContext &Context;
uint64_t NextIndex;
uint64_t NextIndex = 0;
SmallDenseMap<void *, std::pair<OwnerTy, uint64_t>, 4> UseMap;
public:
ReplaceableMetadataImpl(LLVMContext &Context)
: Context(Context), NextIndex(0) {}
ReplaceableMetadataImpl(LLVMContext &Context) : Context(Context) {}
~ReplaceableMetadataImpl() {
assert(UseMap.empty() && "Cannot destroy in-use replaceable metadata");
@ -586,8 +585,9 @@ dyn_extract_or_null(Y &&MD) {
class MDString : public Metadata {
friend class StringMapEntry<MDString>;
StringMapEntry<MDString> *Entry;
MDString() : Metadata(MDStringKind, Uniqued), Entry(nullptr) {}
StringMapEntry<MDString> *Entry = nullptr;
MDString() : Metadata(MDStringKind, Uniqued) {}
public:
MDString(const MDString &) = delete;
@ -1062,7 +1062,6 @@ public:
static MDNode *getMostGenericRange(MDNode *A, MDNode *B);
static MDNode *getMostGenericAliasScope(MDNode *A, MDNode *B);
static MDNode *getMostGenericAlignmentOrDereferenceable(MDNode *A, MDNode *B);
};
/// \brief Tuple of metadata.
@ -1284,7 +1283,7 @@ class NamedMDNode : public ilist_node<NamedMDNode> {
friend class Module;
std::string Name;
Module *Parent;
Module *Parent = nullptr;
void *Operands; // SmallVector<TrackingMDRef, 4>
void setParent(Module *M) { Parent = M; }

View File

@ -1,4 +1,4 @@
//===-- llvm/SymbolTableListTraits.h - Traits for iplist --------*- C++ -*-===//
//===- llvm/SymbolTableListTraits.h - Traits for iplist ---------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@ -26,8 +26,19 @@
#define LLVM_IR_SYMBOLTABLELISTTRAITS_H
#include "llvm/ADT/ilist.h"
#include "llvm/ADT/simple_ilist.h"
#include <cstddef>
namespace llvm {
class Argument;
class BasicBlock;
class Function;
class GlobalAlias;
class GlobalIFunc;
class GlobalVariable;
class Instruction;
class Module;
class ValueSymbolTable;
/// Template metafunction to get the parent type for a symbol table list.
@ -35,14 +46,7 @@ class ValueSymbolTable;
/// Implementations create a typedef called \c type so that we only need a
/// single template parameter for the list and traits.
template <typename NodeTy> struct SymbolTableListParentType {};
class Argument;
class BasicBlock;
class Function;
class Instruction;
class GlobalVariable;
class GlobalAlias;
class GlobalIFunc;
class Module;
#define DEFINE_SYMBOL_TABLE_PARENT_TYPE(NODE, PARENT) \
template <> struct SymbolTableListParentType<NODE> { typedef PARENT type; };
DEFINE_SYMBOL_TABLE_PARENT_TYPE(Instruction, BasicBlock)
@ -67,7 +71,7 @@ class SymbolTableListTraits : public ilist_alloc_traits<ValueSubClass> {
typename SymbolTableListParentType<ValueSubClass>::type ItemParentClass;
public:
SymbolTableListTraits() {}
SymbolTableListTraits() = default;
private:
/// getListOwner - Return the object that owns this list. If this is a list
@ -109,6 +113,6 @@ template <class T>
class SymbolTableList
: public iplist_impl<simple_ilist<T>, SymbolTableListTraits<T>> {};
} // End llvm namespace
} // end namespace llvm
#endif
#endif // LLVM_IR_SYMBOLTABLELISTTRAITS_H

View File

@ -15,6 +15,8 @@
#define LLVM_IR_TRACKINGMDREF_H
#include "llvm/IR/Metadata.h"
#include <algorithm>
#include <cassert>
namespace llvm {
@ -22,14 +24,15 @@ namespace llvm {
///
/// This class behaves like \a TrackingVH, but for metadata.
class TrackingMDRef {
Metadata *MD;
Metadata *MD = nullptr;
public:
TrackingMDRef() : MD(nullptr) {}
TrackingMDRef() = default;
explicit TrackingMDRef(Metadata *MD) : MD(MD) { track(); }
TrackingMDRef(TrackingMDRef &&X) : MD(X.MD) { retrack(X); }
TrackingMDRef(const TrackingMDRef &X) : MD(X.MD) { track(); }
TrackingMDRef &operator=(TrackingMDRef &&X) {
if (&X == this)
return *this;
@ -39,6 +42,7 @@ public:
retrack(X);
return *this;
}
TrackingMDRef &operator=(const TrackingMDRef &X) {
if (&X == this)
return *this;
@ -48,6 +52,7 @@ public:
track();
return *this;
}
~TrackingMDRef() { untrack(); }
Metadata *get() const { return MD; }
@ -80,10 +85,12 @@ private:
if (MD)
MetadataTracking::track(MD);
}
void untrack() {
if (MD)
MetadataTracking::untrack(MD);
}
void retrack(TrackingMDRef &X) {
assert(MD == X.MD && "Expected values to match");
if (X.MD) {
@ -101,15 +108,17 @@ template <class T> class TypedTrackingMDRef {
TrackingMDRef Ref;
public:
TypedTrackingMDRef() {}
TypedTrackingMDRef() = default;
explicit TypedTrackingMDRef(T *MD) : Ref(static_cast<Metadata *>(MD)) {}
TypedTrackingMDRef(TypedTrackingMDRef &&X) : Ref(std::move(X.Ref)) {}
TypedTrackingMDRef(const TypedTrackingMDRef &X) : Ref(X.Ref) {}
TypedTrackingMDRef &operator=(TypedTrackingMDRef &&X) {
Ref = std::move(X.Ref);
return *this;
}
TypedTrackingMDRef &operator=(const TypedTrackingMDRef &X) {
Ref = X.Ref;
return *this;
@ -162,4 +171,4 @@ template <class T> struct simplify_type<const TypedTrackingMDRef<T>> {
} // end namespace llvm
#endif
#endif // LLVM_IR_TRACKINGMDREF_H

View File

@ -1,4 +1,4 @@
//===-- llvm/IR/TypeFinder.h - Class to find used struct types --*- C++ -*-===//
//===- llvm/IR/TypeFinder.h - Class to find used struct types ---*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@ -15,8 +15,7 @@
#define LLVM_IR_TYPEFINDER_H
#include "llvm/ADT/DenseSet.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Type.h"
#include <cstddef>
#include <vector>
namespace llvm {
@ -24,6 +23,7 @@ namespace llvm {
class MDNode;
class Module;
class StructType;
class Type;
class Value;
/// TypeFinder - Walk over a module, identifying all of the types that are
@ -36,10 +36,10 @@ class TypeFinder {
DenseSet<Type*> VisitedTypes;
std::vector<StructType*> StructTypes;
bool OnlyNamed;
bool OnlyNamed = false;
public:
TypeFinder() : OnlyNamed(false) {}
TypeFinder() = default;
void run(const Module &M, bool onlyNamed);
void clear();
@ -77,6 +77,6 @@ private:
void incorporateMDNode(const MDNode *V);
};
} // end llvm namespace
} // end namespace llvm
#endif
#endif // LLVM_IR_TYPEFINDER_H

View File

@ -20,20 +20,19 @@
namespace llvm {
class Module;
class Function;
class Value;
/// \brief Structure to hold a use-list order.
struct UseListOrder {
const Value *V;
const Function *F;
const Value *V = nullptr;
const Function *F = nullptr;
std::vector<unsigned> Shuffle;
UseListOrder(const Value *V, const Function *F, size_t ShuffleSize)
: V(V), F(F), Shuffle(ShuffleSize) {}
UseListOrder() : V(nullptr), F(nullptr) {}
UseListOrder() = default;
UseListOrder(UseListOrder &&) = default;
UseListOrder &operator=(UseListOrder &&) = default;
};

View File

@ -1,4 +1,4 @@
//===-- llvm/ValueSymbolTable.h - Implement a Value Symtab ------*- C++ -*-===//
//===- llvm/ValueSymbolTable.h - Implement a Value Symtab -------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@ -15,31 +15,36 @@
#define LLVM_IR_VALUESYMBOLTABLE_H
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/IR/Value.h"
#include "llvm/Support/DataTypes.h"
#include <cstdint>
namespace llvm {
template <typename ValueSubClass> class SymbolTableListTraits;
template <unsigned InternalLen> class SmallString;
class BasicBlock;
class Function;
class NamedMDNode;
class Module;
class StringRef;
class Argument;
class BasicBlock;
class Function;
class GlobalAlias;
class GlobalIFunc;
class GlobalVariable;
class Instruction;
template <unsigned InternalLen> class SmallString;
template <typename ValueSubClass> class SymbolTableListTraits;
/// This class provides a symbol table of name/value pairs. It is essentially
/// a std::map<std::string,Value*> but has a controlled interface provided by
/// LLVM as well as ensuring uniqueness of names.
///
class ValueSymbolTable {
friend class Value;
friend class SymbolTableListTraits<Argument>;
friend class SymbolTableListTraits<BasicBlock>;
friend class SymbolTableListTraits<Instruction>;
friend class SymbolTableListTraits<Function>;
friend class SymbolTableListTraits<GlobalVariable>;
friend class SymbolTableListTraits<GlobalAlias>;
friend class SymbolTableListTraits<GlobalIFunc>;
friend class SymbolTableListTraits<GlobalVariable>;
friend class SymbolTableListTraits<Instruction>;
friend class Value;
/// @name Types
/// @{
public:
@ -55,14 +60,14 @@ public:
/// @}
/// @name Constructors
/// @{
public:
ValueSymbolTable() : vmap(0), LastUnique(0) {}
ValueSymbolTable() : vmap(0) {}
~ValueSymbolTable();
/// @}
/// @name Accessors
/// @{
public:
/// This method finds the value with the given \p Name in the
/// the symbol table.
/// @returns the value associated with the \p Name
@ -84,7 +89,7 @@ public:
/// @}
/// @name Iteration
/// @{
public:
/// @brief Get an iterator that from the beginning of the symbol table.
inline iterator begin() { return vmap.begin(); }
@ -122,13 +127,13 @@ private:
/// @}
/// @name Internal Data
/// @{
private:
ValueMap vmap; ///< The map that holds the symbol table.
mutable uint32_t LastUnique; ///< Counter for tracking unique names
mutable uint32_t LastUnique = 0; ///< Counter for tracking unique names
/// @}
};
} // End llvm namespace
} // end namespace llvm
#endif
#endif // LLVM_IR_VALUESYMBOLTABLE_H

View File

@ -1,4 +1,4 @@
//===-- Attributes.cpp - Implement AttributesList -------------------------===//
//===- Attributes.cpp - Implement AttributesList --------------------------===//
//
// The LLVM Compiler Infrastructure
//
@ -13,19 +13,35 @@
//
//===----------------------------------------------------------------------===//
#include "llvm/IR/Attributes.h"
#include "llvm/IR/Function.h"
#include "AttributeImpl.h"
#include "AttributeSetNode.h"
#include "LLVMContextImpl.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Type.h"
#include "llvm/Support/Atomic.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/Mutex.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <limits>
#include <map>
#include <string>
#include <tuple>
#include <utility>
using namespace llvm;
//===----------------------------------------------------------------------===//
@ -411,9 +427,12 @@ bool Attribute::operator<(Attribute A) const {
//===----------------------------------------------------------------------===//
// Pin the vtables to this file.
AttributeImpl::~AttributeImpl() {}
AttributeImpl::~AttributeImpl() = default;
void EnumAttributeImpl::anchor() {}
void IntAttributeImpl::anchor() {}
void StringAttributeImpl::anchor() {}
bool AttributeImpl::hasAttribute(Attribute::AttrKind A) const {
@ -593,7 +612,7 @@ LLVM_DUMP_METHOD void AttributeSetImpl::dump() const {
AttributeSet
AttributeSet::getImpl(LLVMContext &C,
ArrayRef<std::pair<unsigned, AttributeSetNode*> > Attrs) {
ArrayRef<std::pair<unsigned, AttributeSetNode*>> Attrs) {
LLVMContextImpl *pImpl = C.pImpl;
FoldingSetNodeID ID;
AttributeSetImpl::Profile(ID, Attrs);
@ -616,7 +635,7 @@ AttributeSet::getImpl(LLVMContext &C,
}
AttributeSet AttributeSet::get(LLVMContext &C,
ArrayRef<std::pair<unsigned, Attribute> > Attrs){
ArrayRef<std::pair<unsigned, Attribute>> Attrs) {
// If there are no attributes then return a null AttributesList pointer.
if (Attrs.empty())
return AttributeSet();
@ -635,7 +654,7 @@ AttributeSet AttributeSet::get(LLVMContext &C,
// Create a vector if (unsigned, AttributeSetNode*) pairs from the attributes
// list.
SmallVector<std::pair<unsigned, AttributeSetNode*>, 8> AttrPairVec;
for (ArrayRef<std::pair<unsigned, Attribute> >::iterator I = Attrs.begin(),
for (ArrayRef<std::pair<unsigned, Attribute>>::iterator I = Attrs.begin(),
E = Attrs.end(); I != E; ) {
unsigned Index = I->first;
SmallVector<Attribute, 4> AttrVec;
@ -652,7 +671,7 @@ AttributeSet AttributeSet::get(LLVMContext &C,
AttributeSet AttributeSet::get(LLVMContext &C,
ArrayRef<std::pair<unsigned,
AttributeSetNode*> > Attrs) {
AttributeSetNode*>> Attrs) {
// If there are no attributes then return a null AttributesList pointer.
if (Attrs.empty())
return AttributeSet();
@ -760,7 +779,7 @@ AttributeSet AttributeSet::addAttribute(LLVMContext &C, unsigned Index,
AttributeSet AttributeSet::addAttribute(LLVMContext &C, unsigned Index,
StringRef Kind, StringRef Value) const {
llvm::AttrBuilder B;
AttrBuilder B;
B.addAttribute(Kind, Value);
return addAttributes(C, Index, AttributeSet::get(C, Index, B));
}
@ -937,7 +956,7 @@ AttributeSet AttributeSet::removeAttributes(LLVMContext &C, unsigned Index,
AttributeSet AttributeSet::addDereferenceableAttr(LLVMContext &C, unsigned Index,
uint64_t Bytes) const {
llvm::AttrBuilder B;
AttrBuilder B;
B.addDereferenceableAttr(Bytes);
return addAttributes(C, Index, AttributeSet::get(C, Index, B));
}
@ -945,7 +964,7 @@ AttributeSet AttributeSet::addDereferenceableAttr(LLVMContext &C, unsigned Index
AttributeSet AttributeSet::addDereferenceableOrNullAttr(LLVMContext &C,
unsigned Index,
uint64_t Bytes) const {
llvm::AttrBuilder B;
AttrBuilder B;
B.addDereferenceableOrNullAttr(Bytes);
return addAttributes(C, Index, AttributeSet::get(C, Index, B));
}
@ -954,7 +973,7 @@ AttributeSet
AttributeSet::addAllocSizeAttr(LLVMContext &C, unsigned Index,
unsigned ElemSizeArg,
const Optional<unsigned> &NumElemsArg) {
llvm::AttrBuilder B;
AttrBuilder B;
B.addAllocSizeAttr(ElemSizeArg, NumElemsArg);
return addAttributes(C, Index, AttributeSet::get(C, Index, B));
}
@ -970,7 +989,7 @@ LLVMContext &AttributeSet::getContext() const {
AttributeSet AttributeSet::getParamAttributes(unsigned Index) const {
return pImpl && hasAttributes(Index) ?
AttributeSet::get(pImpl->getContext(),
ArrayRef<std::pair<unsigned, AttributeSetNode*> >(
ArrayRef<std::pair<unsigned, AttributeSetNode*>>(
std::make_pair(Index, getAttributes(Index)))) :
AttributeSet();
}
@ -978,7 +997,7 @@ AttributeSet AttributeSet::getParamAttributes(unsigned Index) const {
AttributeSet AttributeSet::getRetAttributes() const {
return pImpl && hasAttributes(ReturnIndex) ?
AttributeSet::get(pImpl->getContext(),
ArrayRef<std::pair<unsigned, AttributeSetNode*> >(
ArrayRef<std::pair<unsigned, AttributeSetNode*>>(
std::make_pair(ReturnIndex,
getAttributes(ReturnIndex)))) :
AttributeSet();
@ -987,7 +1006,7 @@ AttributeSet AttributeSet::getRetAttributes() const {
AttributeSet AttributeSet::getFnAttributes() const {
return pImpl && hasAttributes(FunctionIndex) ?
AttributeSet::get(pImpl->getContext(),
ArrayRef<std::pair<unsigned, AttributeSetNode*> >(
ArrayRef<std::pair<unsigned, AttributeSetNode*>>(
std::make_pair(FunctionIndex,
getAttributes(FunctionIndex)))) :
AttributeSet();
@ -1139,9 +1158,7 @@ LLVM_DUMP_METHOD void AttributeSet::dump() const {
// AttrBuilder Method Implementations
//===----------------------------------------------------------------------===//
AttrBuilder::AttrBuilder(AttributeSet AS, unsigned Index)
: Attrs(0), Alignment(0), StackAlignment(0), DerefBytes(0),
DerefOrNullBytes(0), AllocSizeArgs(0) {
AttrBuilder::AttrBuilder(AttributeSet AS, unsigned Index) {
AttributeSetImpl *pImpl = AS.pImpl;
if (!pImpl) return;
@ -1514,7 +1531,6 @@ bool AttributeFuncs::areInlineCompatible(const Function &Caller,
return hasCompatibleFnAttrs(Caller, Callee);
}
void AttributeFuncs::mergeAttributesForInlining(Function &Caller,
const Function &Callee) {
mergeFnAttrs(Caller, Callee);

View File

@ -1,4 +1,4 @@
//===-- Comdat.cpp - Implement Metadata classes --------------------------===//
//===- Comdat.cpp - Implement Metadata classes ----------------------------===//
//
// The LLVM Compiler Infrastructure
//
@ -11,12 +11,14 @@
//
//===----------------------------------------------------------------------===//
#include "llvm/IR/Comdat.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/IR/Comdat.h"
using namespace llvm;
Comdat::Comdat(Comdat &&C) : Name(C.Name), SK(C.SK) {}
Comdat::Comdat() : Name(nullptr), SK(Comdat::Any) {}
Comdat::Comdat() = default;
StringRef Comdat::getName() const { return Name->first(); }

View File

@ -1,4 +1,4 @@
//===-- InlineAsm.cpp - Implement the InlineAsm class ---------------------===//
//===- InlineAsm.cpp - Implement the InlineAsm class ----------------------===//
//
// The LLVM Compiler Infrastructure
//
@ -11,18 +11,38 @@
//
//===----------------------------------------------------------------------===//
#include "llvm/IR/InlineAsm.h"
#include "ConstantsContext.h"
#include "LLVMContextImpl.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/InlineAsm.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Value.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Compiler.h"
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstddef>
#include <cstdlib>
using namespace llvm;
InlineAsm::InlineAsm(FunctionType *FTy, const std::string &asmString,
const std::string &constraints, bool hasSideEffects,
bool isAlignStack, AsmDialect asmDialect)
: Value(PointerType::getUnqual(FTy), Value::InlineAsmVal),
AsmString(asmString), Constraints(constraints), FTy(FTy),
HasSideEffects(hasSideEffects), IsAlignStack(isAlignStack),
Dialect(asmDialect) {
// Do various checks on the constraint string and type.
assert(Verify(getFunctionType(), constraints) &&
"Function type not legal for constraints!");
}
// Implement the first virtual method in this class in this file so the
// InlineAsm vtable is emitted here.
InlineAsm::~InlineAsm() {
}
InlineAsm::~InlineAsm() = default;
InlineAsm *InlineAsm::get(FunctionType *FTy, StringRef AsmString,
StringRef Constraints, bool hasSideEffects,
@ -33,19 +53,6 @@ InlineAsm *InlineAsm::get(FunctionType *FTy, StringRef AsmString,
return pImpl->InlineAsms.getOrCreate(PointerType::getUnqual(FTy), Key);
}
InlineAsm::InlineAsm(FunctionType *FTy, const std::string &asmString,
const std::string &constraints, bool hasSideEffects,
bool isAlignStack, AsmDialect asmDialect)
: Value(PointerType::getUnqual(FTy), Value::InlineAsmVal),
AsmString(asmString), Constraints(constraints), FTy(FTy),
HasSideEffects(hasSideEffects), IsAlignStack(isAlignStack),
Dialect(asmDialect) {
// Do various checks on the constraint string and type.
assert(Verify(getFunctionType(), constraints) &&
"Function type not legal for constraints!");
}
void InlineAsm::destroyConstant() {
getType()->getContext().pImpl->InlineAsms.remove(this);
delete this;
@ -55,14 +62,6 @@ FunctionType *InlineAsm::getFunctionType() const {
return FTy;
}
///Default constructor.
InlineAsm::ConstraintInfo::ConstraintInfo() :
Type(isInput), isEarlyClobber(false),
MatchingInput(-1), isCommutative(false),
isIndirect(false), isMultipleAlternative(false),
currentAlternativeIndex(0) {
}
/// Parse - Analyze the specified string (e.g. "==&{eax}") and fill in the
/// fields in this structure. If the constraint string is not understood,
/// return true, otherwise return false.

View File

@ -11,20 +11,50 @@
//
//===----------------------------------------------------------------------===//
#include "llvm/IR/Metadata.h"
#include "LLVMContextImpl.h"
#include "MetadataImpl.h"
#include "SymbolTableListTraitsImpl.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/None.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/IR/Argument.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/ConstantRange.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalObject.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/TrackingMDRef.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Value.h"
#include "llvm/IR/ValueHandle.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <iterator>
#include <tuple>
#include <utility>
#include <vector>
using namespace llvm;
@ -1027,8 +1057,7 @@ static SmallVector<TrackingMDRef, 4> &getNMDOps(void *Operands) {
}
NamedMDNode::NamedMDNode(const Twine &N)
: Name(N.str()), Parent(nullptr),
Operands(new SmallVector<TrackingMDRef, 4>()) {}
: Name(N.str()), Operands(new SmallVector<TrackingMDRef, 4>()) {}
NamedMDNode::~NamedMDNode() {
dropAllReferences();
@ -1446,7 +1475,7 @@ void GlobalObject::addTypeMetadata(unsigned Offset, Metadata *TypeID) {
addMetadata(
LLVMContext::MD_type,
*MDTuple::get(getContext(),
{llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
{ConstantAsMetadata::get(llvm::ConstantInt::get(
Type::getInt64Ty(getContext()), Offset)),
TypeID}));
}

View File

@ -1,4 +1,4 @@
//===-- TypeFinder.cpp - Implement the TypeFinder class -------------------===//
//===- TypeFinder.cpp - Implement the TypeFinder class --------------------===//
//
// The LLVM Compiler Infrastructure
//
@ -11,13 +11,22 @@
//
//===----------------------------------------------------------------------===//
#include "llvm/IR/TypeFinder.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/TypeFinder.h"
#include "llvm/IR/Use.h"
#include "llvm/IR/User.h"
#include "llvm/IR/Value.h"
#include "llvm/Support/Casting.h"
#include <utility>
using namespace llvm;
void TypeFinder::run(const Module &M, bool onlyNamed) {

View File

@ -1,4 +1,4 @@
//===-- ValueSymbolTable.cpp - Implement the ValueSymbolTable class -------===//
//===- ValueSymbolTable.cpp - Implement the ValueSymbolTable class --------===//
//
// The LLVM Compiler Infrastructure
//
@ -11,10 +11,11 @@
//
//===----------------------------------------------------------------------===//
#include "llvm/IR/ValueSymbolTable.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Value.h"
#include "llvm/IR/ValueSymbolTable.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"