1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 12:12:47 +01:00

Fix Clang-tidy modernize-use-nullptr and modernize-use-override warnings; other minor fixes.

Differential revision: reviews.llvm.org/D16568

llvm-svn: 258831
This commit is contained in:
Eugene Zelenko 2016-01-26 18:48:36 +00:00
parent 90ba1bcb73
commit 966902f532
21 changed files with 106 additions and 123 deletions

View File

@ -16,7 +16,6 @@
#include <vector> #include <vector>
namespace llvm { namespace llvm {
/// ArrayRef - Represent a constant reference to an array (0 or more elements /// ArrayRef - Represent a constant reference to an array (0 or more elements
/// consecutively in memory), i.e. a start pointer and a length. It allows /// consecutively in memory), i.e. a start pointer and a length. It allows
/// various APIs to take consecutive elements easily and conveniently. /// various APIs to take consecutive elements easily and conveniently.
@ -92,19 +91,20 @@ namespace llvm {
/// Construct an ArrayRef<const T*> from ArrayRef<T*>. This uses SFINAE to /// Construct an ArrayRef<const T*> from ArrayRef<T*>. This uses SFINAE to
/// ensure that only ArrayRefs of pointers can be converted. /// ensure that only ArrayRefs of pointers can be converted.
template <typename U> template <typename U>
ArrayRef(const ArrayRef<U *> &A, ArrayRef(
const ArrayRef<U *> &A,
typename std::enable_if< typename std::enable_if<
std::is_convertible<U *const *, T const *>::value>::type* = 0) std::is_convertible<U *const *, T const *>::value>::type * = nullptr)
: Data(A.data()), Length(A.size()) {} : Data(A.data()), Length(A.size()) {}
/// Construct an ArrayRef<const T*> from a SmallVector<T*>. This is /// Construct an ArrayRef<const T*> from a SmallVector<T*>. This is
/// templated in order to avoid instantiating SmallVectorTemplateCommon<T> /// templated in order to avoid instantiating SmallVectorTemplateCommon<T>
/// whenever we copy-construct an ArrayRef. /// whenever we copy-construct an ArrayRef.
template<typename U, typename DummyT> template<typename U, typename DummyT>
/*implicit*/ ArrayRef(const SmallVectorTemplateCommon<U*, DummyT> &Vec, /*implicit*/ ArrayRef(
const SmallVectorTemplateCommon<U *, DummyT> &Vec,
typename std::enable_if< typename std::enable_if<
std::is_convertible<U *const *, std::is_convertible<U *const *, T const *>::value>::type * = nullptr)
T const *>::value>::type* = 0)
: Data(Vec.data()), Length(Vec.size()) { : Data(Vec.data()), Length(Vec.size()) {
} }
@ -379,6 +379,6 @@ namespace llvm {
template <typename T> hash_code hash_value(ArrayRef<T> S) { template <typename T> hash_code hash_value(ArrayRef<T> S) {
return hash_combine_range(S.begin(), S.end()); return hash_combine_range(S.begin(), S.end());
} }
} } // end namespace llvm
#endif #endif // LLVM_ADT_ARRAYREF_H

View File

@ -66,7 +66,6 @@ namespace llvm {
bool isPoisoned() const { return (reinterpret_cast<intptr_t>(mi) & 0x1) == 0x1; } bool isPoisoned() const { return (reinterpret_cast<intptr_t>(mi) & 0x1) == 0x1; }
#endif // EXPENSIVE_CHECKS #endif // EXPENSIVE_CHECKS
}; };
template <> template <>
@ -308,7 +307,6 @@ namespace llvm {
SlotIndex getPrevIndex() const { SlotIndex getPrevIndex() const {
return SlotIndex(&*--listEntry()->getIterator(), getSlot()); return SlotIndex(&*--listEntry()->getIterator(), getSlot());
} }
}; };
template <> struct isPodLike<SlotIndex> { static const bool value = true; }; template <> struct isPodLike<SlotIndex> { static const bool value = true; };
@ -382,7 +380,7 @@ namespace llvm {
initializeSlotIndexesPass(*PassRegistry::getPassRegistry()); initializeSlotIndexesPass(*PassRegistry::getPassRegistry());
} }
~SlotIndexes() { ~SlotIndexes() override {
// The indexList's nodes are all allocated in the BumpPtrAllocator. // The indexList's nodes are all allocated in the BumpPtrAllocator.
indexList.clearAndLeakNodesUnsafely(); indexList.clearAndLeakNodesUnsafely();
} }
@ -709,15 +707,13 @@ namespace llvm {
indexList.erase(entry); indexList.erase(entry);
#endif #endif
} }
}; };
// Specialize IntervalMapInfo for half-open slot index intervals. // Specialize IntervalMapInfo for half-open slot index intervals.
template <> template <>
struct IntervalMapInfo<SlotIndex> : IntervalMapHalfOpenInfo<SlotIndex> { struct IntervalMapInfo<SlotIndex> : IntervalMapHalfOpenInfo<SlotIndex> {
}; };
} } // end namespace llvm
#endif // LLVM_CODEGEN_SLOTINDEXES_H #endif // LLVM_CODEGEN_SLOTINDEXES_H

View File

@ -56,13 +56,14 @@ public:
} }
private: private:
virtual TypeIndex writeRecord(llvm::StringRef Data) override; TypeIndex writeRecord(llvm::StringRef Data) override;
private: private:
std::vector<std::unique_ptr<Record>> Records; std::vector<std::unique_ptr<Record>> Records;
std::unordered_map<llvm::StringRef, TypeIndex, RecordHash> HashedRecords; std::unordered_map<llvm::StringRef, TypeIndex, RecordHash> HashedRecords;
}; };
}
}
#endif } // end namespace codeview
} // end namespace llvm
#endif // LLVM_DEBUGINFO_CODEVIEW_MEMORYTYPETABLEBUILDER_H

View File

@ -57,7 +57,7 @@ public:
return *this; return *this;
} }
~RCMemoryManager() { ~RCMemoryManager() override {
Client.destroyRemoteAllocator(Id); Client.destroyRemoteAllocator(Id);
DEBUG(dbgs() << "Destroyed remote allocator " << Id << "\n"); DEBUG(dbgs() << "Destroyed remote allocator " << Id << "\n");
} }
@ -355,7 +355,9 @@ public:
ResourceIdMgr::ResourceId Id) ResourceIdMgr::ResourceId Id)
: Remote(Remote), Id(Id) {} : Remote(Remote), Id(Id) {}
~RCIndirectStubsManager() { Remote.destroyIndirectStubsManager(Id); } ~RCIndirectStubsManager() override {
Remote.destroyIndirectStubsManager(Id);
}
std::error_code createStub(StringRef StubName, TargetAddress StubAddr, std::error_code createStub(StringRef StubName, TargetAddress StubAddr,
JITSymbolFlags StubFlags) override { JITSymbolFlags StubFlags) override {
@ -479,7 +481,7 @@ public:
} }
private: private:
void grow() { void grow() override {
TargetAddress BlockAddr = 0; TargetAddress BlockAddr = 0;
uint32_t NumTrampolines = 0; uint32_t NumTrampolines = 0;
auto EC = Remote.emitTrampolineBlock(BlockAddr, NumTrampolines); auto EC = Remote.emitTrampolineBlock(BlockAddr, NumTrampolines);
@ -797,4 +799,4 @@ private:
#undef DEBUG_TYPE #undef DEBUG_TYPE
#endif #endif // LLVM_EXECUTIONENGINE_ORC_ORCREMOTETARGETCLIENT_H

View File

@ -1,4 +1,4 @@
//=-- InstrProf.h - Instrumented profiling format support ---------*- C++ -*-=// //===-- InstrProf.h - Instrumented profiling format support -----*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
@ -13,8 +13,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#ifndef LLVM_PROFILEDATA_INSTRPROF_H_ #ifndef LLVM_PROFILEDATA_INSTRPROF_H
#define LLVM_PROFILEDATA_INSTRPROF_H_ #define LLVM_PROFILEDATA_INSTRPROF_H
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringRef.h"
@ -413,10 +413,10 @@ struct InstrProfRecord {
/// Return the array of profiled values at \p Site. /// Return the array of profiled values at \p Site.
inline std::unique_ptr<InstrProfValueData[]> inline std::unique_ptr<InstrProfValueData[]>
getValueForSite(uint32_t ValueKind, uint32_t Site, getValueForSite(uint32_t ValueKind, uint32_t Site,
uint64_t (*ValueMapper)(uint32_t, uint64_t) = 0) const; uint64_t (*ValueMapper)(uint32_t, uint64_t) = nullptr) const;
inline void inline void
getValueForSite(InstrProfValueData Dest[], uint32_t ValueKind, uint32_t Site, getValueForSite(InstrProfValueData Dest[], uint32_t ValueKind, uint32_t Site,
uint64_t (*ValueMapper)(uint32_t, uint64_t) = 0) const; uint64_t (*ValueMapper)(uint32_t, uint64_t) = nullptr) const;
/// Reserve space for NumValueSites sites. /// Reserve space for NumValueSites sites.
inline void reserveSites(uint32_t ValueKind, uint32_t NumValueSites); inline void reserveSites(uint32_t ValueKind, uint32_t NumValueSites);
/// Add ValueData for ValueKind at value Site. /// Add ValueData for ValueKind at value Site.
@ -746,4 +746,4 @@ template <>
struct is_error_code_enum<llvm::instrprof_error> : std::true_type {}; struct is_error_code_enum<llvm::instrprof_error> : std::true_type {};
} }
#endif // LLVM_PROFILEDATA_INSTRPROF_H_ #endif // LLVM_PROFILEDATA_INSTRPROF_H

View File

@ -554,18 +554,18 @@ int initializeValueProfRuntimeRecord(ValueProfRuntimeRecord *RuntimeRecord,
for (I = 0; I <= IPVK_Last; I++) { for (I = 0; I <= IPVK_Last; I++) {
uint16_t N = NumValueSites[I]; uint16_t N = NumValueSites[I];
if (!N) { if (!N) {
RuntimeRecord->SiteCountArray[I] = 0; RuntimeRecord->SiteCountArray[I] = nullptr;
continue; continue;
} }
NumValueKinds++; NumValueKinds++;
RuntimeRecord->SiteCountArray[I] = (uint8_t *)calloc(N, 1); RuntimeRecord->SiteCountArray[I] = (uint8_t *)calloc(N, 1);
if (!RuntimeRecord->SiteCountArray[I]) if (!RuntimeRecord->SiteCountArray[I])
return 1; return 1;
RuntimeRecord->NodesKind[I] = Nodes ? &Nodes[S] : NULL; RuntimeRecord->NodesKind[I] = Nodes ? &Nodes[S] : nullptr;
for (J = 0; J < N; J++) { for (J = 0; J < N; J++) {
/* Compute value count for each site. */ /* Compute value count for each site. */
uint32_t C = 0; uint32_t C = 0;
ValueProfNode *Site = Nodes ? RuntimeRecord->NodesKind[I][J] : NULL; ValueProfNode *Site = Nodes ? RuntimeRecord->NodesKind[I][J] : nullptr;
while (Site) { while (Site) {
C++; C++;
Site = Site->Next; Site = Site->Next;
@ -606,7 +606,7 @@ uint32_t getNumValueDataForSiteRT(const void *R, uint32_t VK, uint32_t S) {
uint32_t getNumValueDataRT(const void *R, uint32_t VK) { uint32_t getNumValueDataRT(const void *R, uint32_t VK) {
unsigned I, S = 0; unsigned I, S = 0;
const ValueProfRuntimeRecord *Record = (const ValueProfRuntimeRecord *)R; const ValueProfRuntimeRecord *Record = (const ValueProfRuntimeRecord *)R;
if (Record->SiteCountArray[VK] == 0) if (Record->SiteCountArray[VK] == nullptr)
return 0; return 0;
for (I = 0; I < Record->NumValueSites[VK]; I++) for (I = 0; I < Record->NumValueSites[VK]; I++)
S += Record->SiteCountArray[VK][I]; S += Record->SiteCountArray[VK][I];
@ -631,12 +631,12 @@ ValueProfData *allocValueProfDataRT(size_t TotalSizeInBytes) {
return (ValueProfData *)calloc(TotalSizeInBytes, 1); return (ValueProfData *)calloc(TotalSizeInBytes, 1);
} }
static ValueProfRecordClosure RTRecordClosure = {0, static ValueProfRecordClosure RTRecordClosure = {nullptr,
getNumValueKindsRT, getNumValueKindsRT,
getNumValueSitesRT, getNumValueSitesRT,
getNumValueDataRT, getNumValueDataRT,
getNumValueDataForSiteRT, getNumValueDataForSiteRT,
0, nullptr,
getValueForSiteRT, getValueForSiteRT,
allocValueProfDataRT}; allocValueProfDataRT};
@ -663,17 +663,15 @@ serializeValueProfDataFromRT(const ValueProfRuntimeRecord *Record,
return serializeValueProfDataFrom(&RTRecordClosure, DstData); return serializeValueProfDataFrom(&RTRecordClosure, DstData);
} }
#undef INSTR_PROF_COMMON_API_IMPL #undef INSTR_PROF_COMMON_API_IMPL
#endif /* INSTR_PROF_COMMON_API_IMPL */ #endif /* INSTR_PROF_COMMON_API_IMPL */
/*============================================================================*/ /*============================================================================*/
#ifndef INSTR_PROF_DATA_DEFINED #ifndef INSTR_PROF_DATA_DEFINED
#ifndef INSTR_PROF_DATA_INC_ #ifndef INSTR_PROF_DATA_INC
#define INSTR_PROF_DATA_INC_ #define INSTR_PROF_DATA_INC
/* Helper macros. */ /* Helper macros. */
#define INSTR_PROF_SIMPLE_QUOTE(x) #x #define INSTR_PROF_SIMPLE_QUOTE(x) #x
@ -760,7 +758,7 @@ typedef struct ValueProfNode {
struct ValueProfNode *Next; struct ValueProfNode *Next;
} ValueProfNode; } ValueProfNode;
#endif /* INSTR_PROF_DATA_INC_ */ #endif /* INSTR_PROF_DATA_INC */
#else #else
#undef INSTR_PROF_DATA_DEFINED #undef INSTR_PROF_DATA_DEFINED

View File

@ -38,7 +38,7 @@ struct AlignmentCalcImpl {
#endif #endif
T t; T t;
private: private:
AlignmentCalcImpl() {} // Never instantiate. AlignmentCalcImpl() = delete;
}; };
// Abstract base class helper, this will have the minimal alignment and size // Abstract base class helper, this will have the minimal alignment and size
@ -55,7 +55,7 @@ struct AlignmentCalcImplBase {
// of type T. // of type T.
template <typename T> template <typename T>
struct AlignmentCalcImpl<T, true> : AlignmentCalcImplBase, T { struct AlignmentCalcImpl<T, true> : AlignmentCalcImplBase, T {
virtual ~AlignmentCalcImpl() = 0; ~AlignmentCalcImpl() override = 0;
}; };
} // End detail namespace. } // End detail namespace.
@ -223,7 +223,7 @@ template <typename T1,
class AlignerImpl { class AlignerImpl {
T1 t1; T2 t2; T3 t3; T4 t4; T5 t5; T6 t6; T7 t7; T8 t8; T9 t9; T10 t10; T1 t1; T2 t2; T3 t3; T4 t4; T5 t5; T6 t6; T7 t7; T8 t8; T9 t9; T10 t10;
AlignerImpl(); // Never defined or instantiated. AlignerImpl() = delete;
}; };
template <typename T1, template <typename T1,
@ -255,4 +255,5 @@ struct AlignedCharArrayUnion : llvm::AlignedCharArray<
T6, T7, T8, T9, T10>)> { T6, T7, T8, T9, T10>)> {
}; };
} // end namespace llvm } // end namespace llvm
#endif
#endif // LLVM_SUPPORT_ALIGNOF_H

View File

@ -98,7 +98,7 @@ public:
ErrorOr(E ErrorCode, ErrorOr(E ErrorCode,
typename std::enable_if<std::is_error_code_enum<E>::value || typename std::enable_if<std::is_error_code_enum<E>::value ||
std::is_error_condition_enum<E>::value, std::is_error_condition_enum<E>::value,
void *>::type = 0) void *>::type = nullptr)
: HasError(true) { : HasError(true) {
new (getErrorStorage()) std::error_code(make_error_code(ErrorCode)); new (getErrorStorage()) std::error_code(make_error_code(ErrorCode));
} }
@ -278,7 +278,6 @@ private:
return const_cast<ErrorOr<T> *>(this)->getErrorStorage(); return const_cast<ErrorOr<T> *>(this)->getErrorStorage();
} }
union { union {
AlignedCharArrayUnion<storage_type> TStorage; AlignedCharArrayUnion<storage_type> TStorage;
AlignedCharArrayUnion<std::error_code> ErrorStorage; AlignedCharArrayUnion<std::error_code> ErrorStorage;
@ -295,4 +294,4 @@ operator==(const ErrorOr<T> &Err, E Code) {
} }
} // end namespace llvm } // end namespace llvm
#endif #endif // LLVM_SUPPORT_ERROROR_H

View File

@ -35,6 +35,7 @@
#include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
#include <deque> #include <deque>
using namespace llvm; using namespace llvm;
namespace { namespace {
@ -497,7 +498,7 @@ private:
std::error_code initStreamFromBuffer(); std::error_code initStreamFromBuffer();
std::error_code initLazyStream(std::unique_ptr<DataStreamer> Streamer); std::error_code initLazyStream(std::unique_ptr<DataStreamer> Streamer);
}; };
} // namespace } // end anonymous namespace
BitcodeDiagnosticInfo::BitcodeDiagnosticInfo(std::error_code EC, BitcodeDiagnosticInfo::BitcodeDiagnosticInfo(std::error_code EC,
DiagnosticSeverity Severity, DiagnosticSeverity Severity,
@ -872,7 +873,7 @@ public:
/// Provide fast operand accessors /// Provide fast operand accessors
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
}; };
} } // end anonymous namespace
// FIXME: can we inherit this from ConstantExpr? // FIXME: can we inherit this from ConstantExpr?
template <> template <>
@ -880,7 +881,7 @@ struct OperandTraits<ConstantPlaceHolder> :
public FixedNumOperandTraits<ConstantPlaceHolder, 1> { public FixedNumOperandTraits<ConstantPlaceHolder, 1> {
}; };
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ConstantPlaceHolder, Value) DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ConstantPlaceHolder, Value)
} } // end namespace llvm
void BitcodeReaderValueList::assignValue(Value *V, unsigned Idx) { void BitcodeReaderValueList::assignValue(Value *V, unsigned Idx) {
if (Idx == size()) { if (Idx == size()) {
@ -908,11 +909,8 @@ void BitcodeReaderValueList::assignValue(Value *V, unsigned Idx) {
OldV->replaceAllUsesWith(V); OldV->replaceAllUsesWith(V);
delete PrevVal; delete PrevVal;
} }
return;
} }
Constant *BitcodeReaderValueList::getConstantFwdRef(unsigned Idx, Constant *BitcodeReaderValueList::getConstantFwdRef(unsigned Idx,
Type *Ty) { Type *Ty) {
if (Idx >= size()) if (Idx >= size())
@ -1129,7 +1127,6 @@ StructType *BitcodeReader::createIdentifiedStructType(LLVMContext &Context) {
return Ret; return Ret;
} }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// Functions for parsing blocks from the bitcode file // Functions for parsing blocks from the bitcode file
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -2178,7 +2175,7 @@ std::error_code BitcodeReader::parseMetadata(bool ModuleLevel) {
getMDOrNull(Record[9]), getMDOrNull(Record[10]), getMDOrNull(Record[9]), getMDOrNull(Record[10]),
getMDOrNull(Record[11]), getMDOrNull(Record[12]), getMDOrNull(Record[11]), getMDOrNull(Record[12]),
getMDOrNull(Record[13]), getMDOrNull(Record[13]),
Record.size() <= 15 ? 0 : getMDOrNull(Record[15]), Record.size() <= 15 ? nullptr : getMDOrNull(Record[15]),
Record.size() <= 14 ? 0 : Record[14]), Record.size() <= 14 ? 0 : Record[14]),
NextMetadataNo++); NextMetadataNo++);
break; break;
@ -2701,7 +2698,6 @@ std::error_code BitcodeReader::parseConstants() {
} }
break; break;
} }
case bitc::CST_CODE_CE_BINOP: { // CE_BINOP: [opcode, opval, opval] case bitc::CST_CODE_CE_BINOP: { // CE_BINOP: [opcode, opval, opval]
if (Record.size() < 3) if (Record.size() < 3)
return error("Invalid record"); return error("Invalid record");
@ -3375,7 +3371,6 @@ std::error_code BitcodeReader::parseModule(uint64_t ResumeBit,
break; break;
} }
// Read a record. // Read a record.
auto BitCode = Stream.readRecord(Entry.ID, Record); auto BitCode = Stream.readRecord(Entry.ID, Record);
switch (BitCode) { switch (BitCode) {
@ -5816,7 +5811,7 @@ class BitcodeErrorCategoryType : public std::error_category {
llvm_unreachable("Unknown error type!"); llvm_unreachable("Unknown error type!");
} }
}; };
} } // end anonymous namespace
static ManagedStatic<BitcodeErrorCategoryType> ErrorCategory; static ManagedStatic<BitcodeErrorCategoryType> ErrorCategory;

View File

@ -65,7 +65,7 @@ class InstrProfErrorCategoryType : public std::error_category {
llvm_unreachable("A value of instrprof_error has no message."); llvm_unreachable("A value of instrprof_error has no message.");
} }
}; };
} } // end anonymous namespace
static ManagedStatic<InstrProfErrorCategoryType> ErrorCategory; static ManagedStatic<InstrProfErrorCategoryType> ErrorCategory;
@ -443,12 +443,12 @@ ValueProfData *allocValueProfDataInstrProf(size_t TotalSizeInBytes) {
} }
static ValueProfRecordClosure InstrProfRecordClosure = { static ValueProfRecordClosure InstrProfRecordClosure = {
0, nullptr,
getNumValueKindsInstrProf, getNumValueKindsInstrProf,
getNumValueSitesInstrProf, getNumValueSitesInstrProf,
getNumValueDataInstrProf, getNumValueDataInstrProf,
getNumValueDataForSiteInstrProf, getNumValueDataForSiteInstrProf,
0, nullptr,
getValueForSiteInstrProf, getValueForSiteInstrProf,
allocValueProfDataInstrProf}; allocValueProfDataInstrProf};
@ -638,7 +638,6 @@ void ProfileSummary::computeDetailedSummary() {
ProfileSummaryEntry PSE = {Cutoff, Count, BlocksSeen}; ProfileSummaryEntry PSE = {Cutoff, Count, BlocksSeen};
DetailedSummary.push_back(PSE); DetailedSummary.push_back(PSE);
} }
return;
} }
} } // end namespace llvm

View File

@ -73,7 +73,7 @@ int getPosixProtectionFlags(unsigned Flags) {
return PROT_NONE; return PROT_NONE;
} }
} // namespace } // anonymous namespace
namespace llvm { namespace llvm {
namespace sys { namespace sys {
@ -265,7 +265,7 @@ bool Memory::setWritable (MemoryBlock &M, std::string *ErrMsg) {
} }
bool Memory::setExecutable (MemoryBlock &M, std::string *ErrMsg) { bool Memory::setExecutable (MemoryBlock &M, std::string *ErrMsg) {
if (M.Address == 0 || M.Size == 0) return false; if (M.Address == nullptr || M.Size == 0) return false;
Memory::InvalidateInstructionCache(M.Address, M.Size); Memory::InvalidateInstructionCache(M.Address, M.Size);
#if defined(__APPLE__) && (defined(__arm__) || defined(__arm64__)) #if defined(__APPLE__) && (defined(__arm__) || defined(__arm64__))
kern_return_t kr = vm_protect(mach_task_self(), (vm_address_t)M.Address, kern_return_t kr = vm_protect(mach_task_self(), (vm_address_t)M.Address,

View File

@ -556,7 +556,7 @@ namespace llvm {
// have memop! In fact, starting from ATOMADD64_DAG all opcodes will be // have memop! In fact, starting from ATOMADD64_DAG all opcodes will be
// thought as target memory ops! // thought as target memory ops!
}; };
} } // end namespace X86ISD
/// Define some predicates that are used for node matching. /// Define some predicates that are used for node matching.
namespace X86 { namespace X86 {
@ -608,13 +608,12 @@ namespace llvm {
bool isOffsetSuitableForCodeModel(int64_t Offset, CodeModel::Model M, bool isOffsetSuitableForCodeModel(int64_t Offset, CodeModel::Model M,
bool hasSymbolicDisplacement = true); bool hasSymbolicDisplacement = true);
/// Determines whether the callee is required to pop its /// Determines whether the callee is required to pop its
/// own arguments. Callee pop is necessary to support tail calls. /// own arguments. Callee pop is necessary to support tail calls.
bool isCalleePop(CallingConv::ID CallingConv, bool isCalleePop(CallingConv::ID CallingConv,
bool is64Bit, bool IsVarArg, bool GuaranteeTCO); bool is64Bit, bool IsVarArg, bool GuaranteeTCO);
} } // end namespace X86
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
// X86 Implementation of the TargetLowering interface // X86 Implementation of the TargetLowering interface
@ -685,7 +684,7 @@ namespace llvm {
/// and types must exactly match those of the original return values of /// and types must exactly match those of the original return values of
/// the node), or leaves Results empty, which indicates that the node is not /// the node), or leaves Results empty, which indicates that the node is not
/// to be custom lowered after all. /// to be custom lowered after all.
virtual void LowerOperationWrapper(SDNode *N, void LowerOperationWrapper(SDNode *N,
SmallVectorImpl<SDValue> &Results, SmallVectorImpl<SDValue> &Results,
SelectionDAG &DAG) const override; SelectionDAG &DAG) const override;
@ -695,7 +694,6 @@ namespace llvm {
void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue>&Results, void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue>&Results,
SelectionDAG &DAG) const override; SelectionDAG &DAG) const override;
SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override; SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;
/// Return true if the target has native support for /// Return true if the target has native support for
@ -1180,7 +1178,7 @@ namespace llvm {
namespace X86 { namespace X86 {
FastISel *createFastISel(FunctionLoweringInfo &funcInfo, FastISel *createFastISel(FunctionLoweringInfo &funcInfo,
const TargetLibraryInfo *libInfo); const TargetLibraryInfo *libInfo);
} } // end namespace X86
} } // end namespace llvm
#endif // X86ISELLOWERING_H #endif // LLVM_LIB_TARGET_X86_X86ISELLOWERING_H

View File

@ -257,7 +257,7 @@ public:
if (CreateGlobalVar) if (CreateGlobalVar)
FuncNameVar = createPGOFuncNameVar(F, FuncName); FuncNameVar = createPGOFuncNameVar(F, FuncName);
}; }
}; };
// Compute Hash value for the CFG: the lower 32 bits are CRC32 of the index // Compute Hash value for the CFG: the lower 32 bits are CRC32 of the index
@ -690,7 +690,7 @@ void PGOUseFunc::setBranchWeights() {
const PGOUseEdge *E = BBCountInfo.OutEdges[s]; const PGOUseEdge *E = BBCountInfo.OutEdges[s];
const BasicBlock *SrcBB = E->SrcBB; const BasicBlock *SrcBB = E->SrcBB;
const BasicBlock *DestBB = E->DestBB; const BasicBlock *DestBB = E->DestBB;
if (DestBB == 0) if (DestBB == nullptr)
continue; continue;
unsigned SuccNum = GetSuccessorNumber(SrcBB, DestBB); unsigned SuccNum = GetSuccessorNumber(SrcBB, DestBB);
uint64_t EdgeCount = E->CountValue; uint64_t EdgeCount = E->CountValue;

View File

@ -80,7 +80,7 @@ struct AddDiscriminators : public FunctionPass {
bool runOnFunction(Function &F) override; bool runOnFunction(Function &F) override;
}; };
} } // end anonymous namespace
char AddDiscriminators::ID = 0; char AddDiscriminators::ID = 0;
INITIALIZE_PASS_BEGIN(AddDiscriminators, "add-discriminators", INITIALIZE_PASS_BEGIN(AddDiscriminators, "add-discriminators",
@ -217,7 +217,7 @@ bool AddDiscriminators::runOnFunction(Function &F) {
// Sample base profile needs to distinguish different function calls within // Sample base profile needs to distinguish different function calls within
// a same source line for correct profile annotation. // a same source line for correct profile annotation.
for (BasicBlock &B : F) { for (BasicBlock &B : F) {
const DILocation *FirstDIL = NULL; const DILocation *FirstDIL = nullptr;
for (auto &I : B.getInstList()) { for (auto &I : B.getInstList()) {
CallInst *Current = dyn_cast<CallInst>(&I); CallInst *Current = dyn_cast<CallInst>(&I);
if (!Current || isa<DbgInfoIntrinsic>(&I)) if (!Current || isa<DbgInfoIntrinsic>(&I))

View File

@ -27,7 +27,7 @@ SanitizerStatReport::SanitizerStatReport(Module *M) : M(M) {
EmptyModuleStatsTy = makeModuleStatsTy(); EmptyModuleStatsTy = makeModuleStatsTy();
ModuleStatsGV = new GlobalVariable(*M, EmptyModuleStatsTy, false, ModuleStatsGV = new GlobalVariable(*M, EmptyModuleStatsTy, false,
GlobalValue::InternalLinkage, 0); GlobalValue::InternalLinkage, nullptr);
} }
ArrayType *SanitizerStatReport::makeModuleStatsArrayTy() { ArrayType *SanitizerStatReport::makeModuleStatsArrayTy() {

View File

@ -51,12 +51,12 @@ const char *ReadModule(char SizeofPtr, const char *Begin, const char *End) {
while (Begin != End && *Begin) while (Begin != End && *Begin)
++Begin; ++Begin;
if (Begin == End) if (Begin == End)
return 0; return nullptr;
StringRef Filename(FilenameBegin, Begin - FilenameBegin); StringRef Filename(FilenameBegin, Begin - FilenameBegin);
++Begin; ++Begin;
if (Begin == End) if (Begin == End)
return 0; return nullptr;
symbolize::LLVMSymbolizer::Options SymbolizerOptions; symbolize::LLVMSymbolizer::Options SymbolizerOptions;
SymbolizerOptions.Demangle = ClDemangle; SymbolizerOptions.Demangle = ClDemangle;
@ -70,11 +70,11 @@ const char *ReadModule(char SizeofPtr, const char *Begin, const char *End) {
Begin += SizeofPtr; Begin += SizeofPtr;
if (Begin > End) if (Begin > End)
return 0; return nullptr;
if (Addr == 0 && Data == 0) if (Addr == 0 && Data == 0)
return Begin; return Begin;
if (Begin == End) if (Begin == End)
return 0; return nullptr;
ErrorOr<DILineInfo> LineInfo = Symbolizer.symbolizeCode(Filename, Addr); ErrorOr<DILineInfo> LineInfo = Symbolizer.symbolizeCode(Filename, Addr);
if (LineInfo) { if (LineInfo) {
@ -129,7 +129,7 @@ int main(int argc, char **argv) {
char SizeofPtr = *Begin++; char SizeofPtr = *Begin++;
while (Begin != End) { while (Begin != End) {
Begin = ReadModule(SizeofPtr, Begin, End); Begin = ReadModule(SizeofPtr, Begin, End);
if (Begin == 0) { if (Begin == nullptr) {
errs() << argv[0] << ": " << ClInputFile << ": short read\n"; errs() << argv[0] << ": " << ClInputFile << ": short read\n";
return 1; return 1;
} }

View File

@ -37,14 +37,13 @@ public:
return SectionMemoryManager::needsToReserveAllocationSpace(); return SectionMemoryManager::needsToReserveAllocationSpace();
} }
bool finalizeMemory(std::string *ErrMsg = 0) override { bool finalizeMemory(std::string *ErrMsg = nullptr) override {
++FinalizationCount; ++FinalizationCount;
return SectionMemoryManager::finalizeMemory(ErrMsg); return SectionMemoryManager::finalizeMemory(ErrMsg);
} }
}; };
TEST(ObjectLinkingLayerTest, TestSetProcessAllSections) { TEST(ObjectLinkingLayerTest, TestSetProcessAllSections) {
class SectionMemoryManagerWrapper : public SectionMemoryManager { class SectionMemoryManagerWrapper : public SectionMemoryManager {
public: public:
SectionMemoryManagerWrapper(bool &DebugSeen) : DebugSeen(DebugSeen) {} SectionMemoryManagerWrapper(bool &DebugSeen) : DebugSeen(DebugSeen) {}
@ -113,9 +112,7 @@ TEST(ObjectLinkingLayerTest, TestSetProcessAllSections) {
} }
} }
TEST_F(ObjectLinkingLayerExecutionTest, NoDuplicateFinalization) { TEST_F(ObjectLinkingLayerExecutionTest, NoDuplicateFinalization) {
if (!TM) if (!TM)
return; return;
@ -187,7 +184,6 @@ TEST_F(ObjectLinkingLayerExecutionTest, NoDuplicateFinalization) {
} }
TEST_F(ObjectLinkingLayerExecutionTest, NoPrematureAllocation) { TEST_F(ObjectLinkingLayerExecutionTest, NoPrematureAllocation) {
if (!TM) if (!TM)
return; return;
@ -250,4 +246,4 @@ TEST_F(ObjectLinkingLayerExecutionTest, NoPrematureAllocation) {
"(multiple unrelated objects loaded prior to finalization)"; "(multiple unrelated objects loaded prior to finalization)";
} }
} } // end anonymous namespace

View File

@ -1,4 +1,4 @@
//===- llvm/unittest/IR/VerifierTest.cpp - Verifier unit tests ------------===// //===- llvm/unittest/IR/VerifierTest.cpp - Verifier unit tests --*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
@ -126,7 +126,8 @@ TEST(VerifierTest, CrossModuleMetadataRef) {
Module M2("M2", C); Module M2("M2", C);
GlobalVariable *newGV = GlobalVariable *newGV =
new GlobalVariable(M1, Type::getInt8Ty(C), false, new GlobalVariable(M1, Type::getInt8Ty(C), false,
GlobalVariable::ExternalLinkage, NULL, "Some Global"); GlobalVariable::ExternalLinkage, nullptr,
"Some Global");
DIBuilder dbuilder(M2); DIBuilder dbuilder(M2);
auto CU = dbuilder.createCompileUnit(dwarf::DW_LANG_Julia, "test.jl", ".", auto CU = dbuilder.createCompileUnit(dwarf::DW_LANG_Julia, "test.jl", ".",
@ -143,5 +144,5 @@ TEST(VerifierTest, CrossModuleMetadataRef) {
EXPECT_TRUE(StringRef(ErrorOS.str()) EXPECT_TRUE(StringRef(ErrorOS.str())
.startswith("Referencing global in another module!")); .startswith("Referencing global in another module!"));
} }
} } // end anonymous namespace
} } // end namespace llvm

View File

@ -14,7 +14,6 @@
#include "llvm/ProfileData/InstrProfWriter.h" #include "llvm/ProfileData/InstrProfWriter.h"
#include "llvm/Support/Compression.h" #include "llvm/Support/Compression.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include <cstdarg> #include <cstdarg>
using namespace llvm; using namespace llvm;
@ -490,22 +489,24 @@ ValueProfNode Site1Values[5] = {{{uint64_t("callee1"), 400}, &Site1Values[1]},
{{uint64_t("callee2"), 1000}, &Site1Values[2]}, {{uint64_t("callee2"), 1000}, &Site1Values[2]},
{{uint64_t("callee3"), 500}, &Site1Values[3]}, {{uint64_t("callee3"), 500}, &Site1Values[3]},
{{uint64_t("callee4"), 300}, &Site1Values[4]}, {{uint64_t("callee4"), 300}, &Site1Values[4]},
{{uint64_t("callee5"), 100}, 0}}; {{uint64_t("callee5"), 100}, nullptr}};
ValueProfNode Site2Values[4] = {{{uint64_t("callee5"), 800}, &Site2Values[1]}, ValueProfNode Site2Values[4] = {{{uint64_t("callee5"), 800}, &Site2Values[1]},
{{uint64_t("callee3"), 1000}, &Site2Values[2]}, {{uint64_t("callee3"), 1000}, &Site2Values[2]},
{{uint64_t("callee2"), 2500}, &Site2Values[3]}, {{uint64_t("callee2"), 2500}, &Site2Values[3]},
{{uint64_t("callee1"), 1300}, 0}}; {{uint64_t("callee1"), 1300}, nullptr}};
ValueProfNode Site3Values[3] = {{{uint64_t("callee6"), 800}, &Site3Values[1]}, ValueProfNode Site3Values[3] = {{{uint64_t("callee6"), 800}, &Site3Values[1]},
{{uint64_t("callee3"), 1000}, &Site3Values[2]}, {{uint64_t("callee3"), 1000}, &Site3Values[2]},
{{uint64_t("callee4"), 5500}, 0}}; {{uint64_t("callee4"), 5500}, nullptr}};
ValueProfNode Site4Values[2] = {{{uint64_t("callee2"), 1800}, &Site4Values[1]}, ValueProfNode Site4Values[2] = {{{uint64_t("callee2"), 1800}, &Site4Values[1]},
{{uint64_t("callee3"), 2000}, 0}}; {{uint64_t("callee3"), 2000}, nullptr}};
static ValueProfNode *ValueProfNodes[5] = {&Site1Values[0], &Site2Values[0], static ValueProfNode *ValueProfNodes[5] = {&Site1Values[0], &Site2Values[0],
&Site3Values[0], &Site4Values[0], 0}; &Site3Values[0], &Site4Values[0],
nullptr};
static uint16_t NumValueSites[IPVK_Last + 1] = {5}; static uint16_t NumValueSites[IPVK_Last + 1] = {5};
TEST_F(InstrProfTest, runtime_value_prof_data_read_write) { TEST_F(InstrProfTest, runtime_value_prof_data_read_write) {
ValueProfRuntimeRecord RTRecord; ValueProfRuntimeRecord RTRecord;
@ -516,7 +517,7 @@ TEST_F(InstrProfTest, runtime_value_prof_data_read_write) {
InstrProfRecord Record("caller", 0x1234, {1ULL << 31, 2}); InstrProfRecord Record("caller", 0x1234, {1ULL << 31, 2});
VPData->deserializeTo(Record, 0); VPData->deserializeTo(Record, nullptr);
// Now read data from Record and sanity check the data // Now read data from Record and sanity check the data
ASSERT_EQ(5U, Record.getNumValueSites(IPVK_IndirectCallTarget)); ASSERT_EQ(5U, Record.getNumValueSites(IPVK_IndirectCallTarget));
@ -687,7 +688,7 @@ TEST_F(InstrProfTest, instr_prof_symtab_module_test) {
for (unsigned I = 0; I < sizeof(Funcs) / sizeof(*Funcs); I++) { for (unsigned I = 0; I < sizeof(Funcs) / sizeof(*Funcs); I++) {
Function *F = M->getFunction(Funcs[I]); Function *F = M->getFunction(Funcs[I]);
ASSERT_TRUE(F != NULL); ASSERT_TRUE(F != nullptr);
std::string PGOName = getPGOFuncName(*F); std::string PGOName = getPGOFuncName(*F);
uint64_t Key = IndexedInstrProf::ComputeHash(PGOName); uint64_t Key = IndexedInstrProf::ComputeHash(PGOName);
ASSERT_EQ(StringRef(PGOName), ASSERT_EQ(StringRef(PGOName),

View File

@ -1,4 +1,4 @@
//=== - llvm/unittest/Support/AlignOfTest.cpp - Alignment utility tests ----===// //=== - llvm/unittest/Support/AlignOfTest.cpp - Alignment utility tests ---===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
@ -90,14 +90,14 @@ V7::~V7() {}
V8::~V8() {} V8::~V8() {}
struct Abstract1 { struct Abstract1 {
virtual ~Abstract1() {} virtual ~Abstract1() = default;
virtual void method() = 0; virtual void method() = 0;
char c; char c;
}; };
struct Abstract2 : Abstract1 { struct Abstract2 : Abstract1 {
virtual ~Abstract2() {} ~Abstract2() override = default;
double d; double d;
}; };
@ -354,4 +354,4 @@ TEST(AlignOfTest, BasicAlignedArray) {
EXPECT_EQ(2u, sizeof(AlignedCharArray<2, 2>)); EXPECT_EQ(2u, sizeof(AlignedCharArray<2, 2>));
EXPECT_EQ(16u, sizeof(AlignedCharArray<2, 16>)); EXPECT_EQ(16u, sizeof(AlignedCharArray<2, 16>));
} }
} } // end anonymous namespace

View File

@ -1,4 +1,4 @@
//===- DFAPacketizerEmitter.cpp - Packetization DFA for a VLIW machine-----===// //===- DFAPacketizerEmitter.cpp - Packetization DFA for a VLIW machine ----===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
@ -28,6 +28,7 @@
#include <map> #include <map>
#include <string> #include <string>
#include <queue> #include <queue>
using namespace llvm; using namespace llvm;
// -------------------------------------------------------------------- // --------------------------------------------------------------------
@ -73,7 +74,8 @@ namespace {
InsnInput = addDFAFuncUnits(InsnInput, U); InsnInput = addDFAFuncUnits(InsnInput, U);
return InsnInput; return InsnInput;
} }
} } // end anonymous namespace
// -------------------------------------------------------------------- // --------------------------------------------------------------------
#ifndef NDEBUG #ifndef NDEBUG
@ -149,7 +151,7 @@ public:
void run(raw_ostream &OS); void run(raw_ostream &OS);
}; };
} // End anonymous namespace. } // end anonymous namespace
// //
// //
@ -234,7 +236,7 @@ class State {
// //
bool hasTransition(std::vector<unsigned> InsnClass) const; bool hasTransition(std::vector<unsigned> InsnClass) const;
}; };
} // End anonymous namespace. } // end anonymous namespace
// //
// class DFA: deterministic finite automaton for processor resource tracking. // class DFA: deterministic finite automaton for processor resource tracking.
@ -262,7 +264,7 @@ public:
int numInsnClasses = 0, int numInsnClasses = 0,
int maxResources = 0, int numCombos = 0, int maxStages = 0); int maxResources = 0, int numCombos = 0, int maxStages = 0);
}; };
} // End anonymous namespace. } // end anonymous namespace
#ifndef NDEBUG #ifndef NDEBUG
// To enable debugging, run llvm-tblgen with: "-debug-only dfa-emitter". // To enable debugging, run llvm-tblgen with: "-debug-only dfa-emitter".
@ -305,7 +307,7 @@ void dbgsIndent(unsigned indent) {
DEBUG(dbgs() << " "); DEBUG(dbgs() << " ");
} }
} }
#endif #endif // NDEBUG
// //
// Constructors and destructors for State and DFA // Constructors and destructors for State and DFA
@ -454,7 +456,6 @@ void State::AddInsnClassStages(std::vector<unsigned> &InsnClass,
} }
} }
// //
// canMaybeAddInsnClass - Quickly verifies if an instruction of type InsnClass // canMaybeAddInsnClass - Quickly verifies if an instruction of type InsnClass
// may be a valid transition from this state i.e., can an instruction of type // may be a valid transition from this state i.e., can an instruction of type
@ -505,7 +506,6 @@ bool State::canMaybeAddInsnClass(std::vector<unsigned> &InsnClass,
return false; return false;
} }
const State &DFA::newState() { const State &DFA::newState() {
auto IterPair = states.insert(State()); auto IterPair = states.insert(State());
assert(IterPair.second && "State already exists"); assert(IterPair.second && "State already exists");
@ -518,7 +518,6 @@ DFAPacketizerEmitter::DFAPacketizerEmitter(RecordKeeper &R):
TargetName(CodeGenTarget(R).getName()), TargetName(CodeGenTarget(R).getName()),
allInsnClasses(), Records(R) {} allInsnClasses(), Records(R) {}
// //
// writeTableAndAPI - Print out a table representing the DFA and the // writeTableAndAPI - Print out a table representing the DFA and the
// associated API to create a DFA packetizer. // associated API to create a DFA packetizer.
@ -626,7 +625,6 @@ void DFA::writeTableAndAPI(raw_ostream &OS, const std::string &TargetName,
OS << "};\n"; OS << "};\n";
OS << "} // namespace\n"; OS << "} // namespace\n";
// //
// Emit DFA Packetizer tables if the target is a VLIW machine. // Emit DFA Packetizer tables if the target is a VLIW machine.
// //
@ -640,7 +638,6 @@ void DFA::writeTableAndAPI(raw_ostream &OS, const std::string &TargetName,
OS << "} // End llvm namespace \n"; OS << "} // End llvm namespace \n";
} }
// //
// collectAllFuncUnits - Construct a map of function unit names to bits. // collectAllFuncUnits - Construct a map of function unit names to bits.
// //
@ -735,7 +732,6 @@ int DFAPacketizerEmitter::collectAllComboFuncs(
return numCombos; return numCombos;
} }
// //
// collectOneInsnClass - Populate allInsnClasses with one instruction class // collectOneInsnClass - Populate allInsnClasses with one instruction class
// //
@ -940,7 +936,7 @@ void DFAPacketizerEmitter::run(raw_ostream &OS) {
// //
if (!current->hasTransition(InsnClass) && if (!current->hasTransition(InsnClass) &&
current->canMaybeAddInsnClass(InsnClass, ComboBitToBitsMap)) { current->canMaybeAddInsnClass(InsnClass, ComboBitToBitsMap)) {
const State *NewState = NULL; const State *NewState = nullptr;
current->AddInsnClass(InsnClass, ComboBitToBitsMap, NewStateResources); current->AddInsnClass(InsnClass, ComboBitToBitsMap, NewStateResources);
if (NewStateResources.size() == 0) { if (NewStateResources.size() == 0) {
DEBUG(dbgs() << " Skipped - no new states generated\n"); DEBUG(dbgs() << " Skipped - no new states generated\n");
@ -994,4 +990,4 @@ void EmitDFAPacketizer(RecordKeeper &RK, raw_ostream &OS) {
DFAPacketizerEmitter(RK).run(OS); DFAPacketizerEmitter(RK).run(OS);
} }
} // End llvm namespace } // end namespaec llvm