[IR] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 295383
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp
index 2c1bc2b..92cb6de 100644
--- a/llvm/lib/IR/Attributes.cpp
+++ b/llvm/lib/IR/Attributes.cpp
@@ -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 @@
//===----------------------------------------------------------------------===//
// 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 @@
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 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 @@
// 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,
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,
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::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::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::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 @@
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::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::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 @@
// 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 @@
return hasCompatibleFnAttrs(Caller, Callee);
}
-
void AttributeFuncs::mergeAttributesForInlining(Function &Caller,
const Function &Callee) {
mergeFnAttrs(Caller, Callee);
diff --git a/llvm/lib/IR/Comdat.cpp b/llvm/lib/IR/Comdat.cpp
index fc1b48d..e27ecad 100644
--- a/llvm/lib/IR/Comdat.cpp
+++ b/llvm/lib/IR/Comdat.cpp
@@ -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(); }
diff --git a/llvm/lib/IR/InlineAsm.cpp b/llvm/lib/IR/InlineAsm.cpp
index 5a91185..8feeeb6 100644
--- a/llvm/lib/IR/InlineAsm.cpp
+++ b/llvm/lib/IR/InlineAsm.cpp
@@ -1,4 +1,4 @@
-//===-- InlineAsm.cpp - Implement the InlineAsm class ---------------------===//
+//===- InlineAsm.cpp - Implement the InlineAsm class ----------------------===//
//
// The LLVM Compiler Infrastructure
//
@@ -11,28 +11,23 @@
//
//===----------------------------------------------------------------------===//
-#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;
-// Implement the first virtual method in this class in this file so the
-// InlineAsm vtable is emitted here.
-InlineAsm::~InlineAsm() {
-}
-
-InlineAsm *InlineAsm::get(FunctionType *FTy, StringRef AsmString,
- StringRef Constraints, bool hasSideEffects,
- bool isAlignStack, AsmDialect asmDialect) {
- InlineAsmKeyType Key(AsmString, Constraints, FTy, hasSideEffects,
- isAlignStack, asmDialect);
- LLVMContextImpl *pImpl = FTy->getContext().pImpl;
- 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)
@@ -40,12 +35,24 @@
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() = default;
+
+InlineAsm *InlineAsm::get(FunctionType *FTy, StringRef AsmString,
+ StringRef Constraints, bool hasSideEffects,
+ bool isAlignStack, AsmDialect asmDialect) {
+ InlineAsmKeyType Key(AsmString, Constraints, FTy, hasSideEffects,
+ isAlignStack, asmDialect);
+ LLVMContextImpl *pImpl = FTy->getContext().pImpl;
+ return pImpl->InlineAsms.getOrCreate(PointerType::getUnqual(FTy), Key);
+}
+
void InlineAsm::destroyConstant() {
getType()->getContext().pImpl->InlineAsms.remove(this);
delete this;
@@ -55,14 +62,6 @@
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.
diff --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp
index 77787ed..ec96b0f 100644
--- a/llvm/lib/IR/Metadata.cpp
+++ b/llvm/lib/IR/Metadata.cpp
@@ -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 @@
}
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 @@
addMetadata(
LLVMContext::MD_type,
*MDTuple::get(getContext(),
- {llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
+ {ConstantAsMetadata::get(llvm::ConstantInt::get(
Type::getInt64Ty(getContext()), Offset)),
TypeID}));
}
diff --git a/llvm/lib/IR/TypeFinder.cpp b/llvm/lib/IR/TypeFinder.cpp
index dc4c1cf..a178b9e 100644
--- a/llvm/lib/IR/TypeFinder.cpp
+++ b/llvm/lib/IR/TypeFinder.cpp
@@ -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) {
diff --git a/llvm/lib/IR/ValueSymbolTable.cpp b/llvm/lib/IR/ValueSymbolTable.cpp
index 1eb2498..0c3946c 100644
--- a/llvm/lib/IR/ValueSymbolTable.cpp
+++ b/llvm/lib/IR/ValueSymbolTable.cpp
@@ -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"