Skip to content

Commit

Permalink
Fix Clang-tidy modernize-use-nullptr and modernize-use-override warni…
Browse files Browse the repository at this point in the history
…ngs; other minor fixes.

Differential revision: reviews.llvm.org/D16568


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@258831 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
EugeneZelenko committed Jan 26, 2016
1 parent a2fd503 commit 51ecde1
Show file tree
Hide file tree
Showing 21 changed files with 106 additions and 123 deletions.
20 changes: 10 additions & 10 deletions include/llvm/ADT/ArrayRef.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include <vector>

namespace llvm {

/// 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
/// various APIs to take consecutive elements easily and conveniently.
Expand Down Expand Up @@ -92,19 +91,20 @@ namespace llvm {
/// Construct an ArrayRef<const T*> from ArrayRef<T*>. This uses SFINAE to
/// ensure that only ArrayRefs of pointers can be converted.
template <typename U>
ArrayRef(const ArrayRef<U *> &A,
typename std::enable_if<
std::is_convertible<U *const *, T const *>::value>::type* = 0)
ArrayRef(
const ArrayRef<U *> &A,
typename std::enable_if<
std::is_convertible<U *const *, T const *>::value>::type * = nullptr)
: Data(A.data()), Length(A.size()) {}

/// Construct an ArrayRef<const T*> from a SmallVector<T*>. This is
/// templated in order to avoid instantiating SmallVectorTemplateCommon<T>
/// whenever we copy-construct an ArrayRef.
template<typename U, typename DummyT>
/*implicit*/ ArrayRef(const SmallVectorTemplateCommon<U*, DummyT> &Vec,
typename std::enable_if<
std::is_convertible<U *const *,
T const *>::value>::type* = 0)
/*implicit*/ ArrayRef(
const SmallVectorTemplateCommon<U *, DummyT> &Vec,
typename std::enable_if<
std::is_convertible<U *const *, T const *>::value>::type * = nullptr)
: Data(Vec.data()), Length(Vec.size()) {
}

Expand Down Expand Up @@ -379,6 +379,6 @@ namespace llvm {
template <typename T> hash_code hash_value(ArrayRef<T> S) {
return hash_combine_range(S.begin(), S.end());
}
}
} // end namespace llvm

#endif
#endif // LLVM_ADT_ARRAYREF_H
8 changes: 2 additions & 6 deletions include/llvm/CodeGen/SlotIndexes.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ namespace llvm {

bool isPoisoned() const { return (reinterpret_cast<intptr_t>(mi) & 0x1) == 0x1; }
#endif // EXPENSIVE_CHECKS

};

template <>
Expand Down Expand Up @@ -308,7 +307,6 @@ namespace llvm {
SlotIndex getPrevIndex() const {
return SlotIndex(&*--listEntry()->getIterator(), getSlot());
}

};

template <> struct isPodLike<SlotIndex> { static const bool value = true; };
Expand Down Expand Up @@ -382,7 +380,7 @@ namespace llvm {
initializeSlotIndexesPass(*PassRegistry::getPassRegistry());
}

~SlotIndexes() {
~SlotIndexes() override {
// The indexList's nodes are all allocated in the BumpPtrAllocator.
indexList.clearAndLeakNodesUnsafely();
}
Expand Down Expand Up @@ -709,15 +707,13 @@ namespace llvm {
indexList.erase(entry);
#endif
}

};


// Specialize IntervalMapInfo for half-open slot index intervals.
template <>
struct IntervalMapInfo<SlotIndex> : IntervalMapHalfOpenInfo<SlotIndex> {
};

}
} // end namespace llvm

#endif // LLVM_CODEGEN_SLOTINDEXES_H
9 changes: 5 additions & 4 deletions include/llvm/DebugInfo/CodeView/MemoryTypeTableBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,14 @@ class MemoryTypeTableBuilder : public TypeTableBuilder {
}

private:
virtual TypeIndex writeRecord(llvm::StringRef Data) override;
TypeIndex writeRecord(llvm::StringRef Data) override;

private:
std::vector<std::unique_ptr<Record>> Records;
std::unordered_map<llvm::StringRef, TypeIndex, RecordHash> HashedRecords;
};
}
}

#endif
} // end namespace codeview
} // end namespace llvm

#endif // LLVM_DEBUGINFO_CODEVIEW_MEMORYTYPETABLEBUILDER_H
10 changes: 6 additions & 4 deletions include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class OrcRemoteTargetClient : public OrcRemoteTargetRPCAPI {
return *this;
}

~RCMemoryManager() {
~RCMemoryManager() override {
Client.destroyRemoteAllocator(Id);
DEBUG(dbgs() << "Destroyed remote allocator " << Id << "\n");
}
Expand Down Expand Up @@ -355,7 +355,9 @@ class OrcRemoteTargetClient : public OrcRemoteTargetRPCAPI {
ResourceIdMgr::ResourceId Id)
: Remote(Remote), Id(Id) {}

~RCIndirectStubsManager() { Remote.destroyIndirectStubsManager(Id); }
~RCIndirectStubsManager() override {
Remote.destroyIndirectStubsManager(Id);
}

std::error_code createStub(StringRef StubName, TargetAddress StubAddr,
JITSymbolFlags StubFlags) override {
Expand Down Expand Up @@ -479,7 +481,7 @@ class OrcRemoteTargetClient : public OrcRemoteTargetRPCAPI {
}

private:
void grow() {
void grow() override {
TargetAddress BlockAddr = 0;
uint32_t NumTrampolines = 0;
auto EC = Remote.emitTrampolineBlock(BlockAddr, NumTrampolines);
Expand Down Expand Up @@ -797,4 +799,4 @@ class OrcRemoteTargetClient : public OrcRemoteTargetRPCAPI {

#undef DEBUG_TYPE

#endif
#endif // LLVM_EXECUTIONENGINE_ORC_ORCREMOTETARGETCLIENT_H
14 changes: 7 additions & 7 deletions include/llvm/ProfileData/InstrProf.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//=-- InstrProf.h - Instrumented profiling format support ---------*- C++ -*-=//
//===-- InstrProf.h - Instrumented profiling format support -----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
Expand All @@ -13,8 +13,8 @@
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_PROFILEDATA_INSTRPROF_H_
#define LLVM_PROFILEDATA_INSTRPROF_H_
#ifndef LLVM_PROFILEDATA_INSTRPROF_H
#define LLVM_PROFILEDATA_INSTRPROF_H

#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
Expand Down Expand Up @@ -413,10 +413,10 @@ struct InstrProfRecord {
/// Return the array of profiled values at \p Site.
inline std::unique_ptr<InstrProfValueData[]>
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
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.
inline void reserveSites(uint32_t ValueKind, uint32_t NumValueSites);
/// Add ValueData for ValueKind at value Site.
Expand Down Expand Up @@ -737,7 +737,7 @@ struct Header {
#include "llvm/ProfileData/InstrProfData.inc"
};

} // end namespace RawInstrProf
} // end namespace RawInstrProf

} // end namespace llvm

Expand All @@ -746,4 +746,4 @@ template <>
struct is_error_code_enum<llvm::instrprof_error> : std::true_type {};
}

#endif // LLVM_PROFILEDATA_INSTRPROF_H_
#endif // LLVM_PROFILEDATA_INSTRPROF_H
20 changes: 9 additions & 11 deletions include/llvm/ProfileData/InstrProfData.inc
Original file line number Diff line number Diff line change
Expand Up @@ -554,18 +554,18 @@ int initializeValueProfRuntimeRecord(ValueProfRuntimeRecord *RuntimeRecord,
for (I = 0; I <= IPVK_Last; I++) {
uint16_t N = NumValueSites[I];
if (!N) {
RuntimeRecord->SiteCountArray[I] = 0;
RuntimeRecord->SiteCountArray[I] = nullptr;
continue;
}
NumValueKinds++;
RuntimeRecord->SiteCountArray[I] = (uint8_t *)calloc(N, 1);
if (!RuntimeRecord->SiteCountArray[I])
return 1;
RuntimeRecord->NodesKind[I] = Nodes ? &Nodes[S] : NULL;
RuntimeRecord->NodesKind[I] = Nodes ? &Nodes[S] : nullptr;
for (J = 0; J < N; J++) {
/* Compute value count for each site. */
uint32_t C = 0;
ValueProfNode *Site = Nodes ? RuntimeRecord->NodesKind[I][J] : NULL;
ValueProfNode *Site = Nodes ? RuntimeRecord->NodesKind[I][J] : nullptr;
while (Site) {
C++;
Site = Site->Next;
Expand Down Expand Up @@ -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) {
unsigned I, S = 0;
const ValueProfRuntimeRecord *Record = (const ValueProfRuntimeRecord *)R;
if (Record->SiteCountArray[VK] == 0)
if (Record->SiteCountArray[VK] == nullptr)
return 0;
for (I = 0; I < Record->NumValueSites[VK]; I++)
S += Record->SiteCountArray[VK][I];
Expand All @@ -631,12 +631,12 @@ ValueProfData *allocValueProfDataRT(size_t TotalSizeInBytes) {
return (ValueProfData *)calloc(TotalSizeInBytes, 1);
}

static ValueProfRecordClosure RTRecordClosure = {0,
static ValueProfRecordClosure RTRecordClosure = {nullptr,
getNumValueKindsRT,
getNumValueSitesRT,
getNumValueDataRT,
getNumValueDataForSiteRT,
0,
nullptr,
getValueForSiteRT,
allocValueProfDataRT};

Expand All @@ -663,17 +663,15 @@ serializeValueProfDataFromRT(const ValueProfRuntimeRecord *Record,
return serializeValueProfDataFrom(&RTRecordClosure, DstData);
}


#undef INSTR_PROF_COMMON_API_IMPL
#endif /* INSTR_PROF_COMMON_API_IMPL */

/*============================================================================*/


#ifndef INSTR_PROF_DATA_DEFINED

#ifndef INSTR_PROF_DATA_INC_
#define INSTR_PROF_DATA_INC_
#ifndef INSTR_PROF_DATA_INC
#define INSTR_PROF_DATA_INC

/* Helper macros. */
#define INSTR_PROF_SIMPLE_QUOTE(x) #x
Expand Down Expand Up @@ -760,7 +758,7 @@ typedef struct ValueProfNode {
struct ValueProfNode *Next;
} ValueProfNode;

#endif /* INSTR_PROF_DATA_INC_ */
#endif /* INSTR_PROF_DATA_INC */

#else
#undef INSTR_PROF_DATA_DEFINED
Expand Down
9 changes: 5 additions & 4 deletions include/llvm/Support/AlignOf.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct AlignmentCalcImpl {
#endif
T t;
private:
AlignmentCalcImpl() {} // Never instantiate.
AlignmentCalcImpl() = delete;
};

// Abstract base class helper, this will have the minimal alignment and size
Expand All @@ -55,7 +55,7 @@ struct AlignmentCalcImplBase {
// of type T.
template <typename T>
struct AlignmentCalcImpl<T, true> : AlignmentCalcImplBase, T {
virtual ~AlignmentCalcImpl() = 0;
~AlignmentCalcImpl() override = 0;
};

} // End detail namespace.
Expand Down Expand Up @@ -223,7 +223,7 @@ template <typename T1,
class AlignerImpl {
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,
Expand Down Expand Up @@ -255,4 +255,5 @@ struct AlignedCharArrayUnion : llvm::AlignedCharArray<
T6, T7, T8, T9, T10>)> {
};
} // end namespace llvm
#endif

#endif // LLVM_SUPPORT_ALIGNOF_H
5 changes: 2 additions & 3 deletions include/llvm/Support/ErrorOr.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class ErrorOr {
ErrorOr(E ErrorCode,
typename std::enable_if<std::is_error_code_enum<E>::value ||
std::is_error_condition_enum<E>::value,
void *>::type = 0)
void *>::type = nullptr)
: HasError(true) {
new (getErrorStorage()) std::error_code(make_error_code(ErrorCode));
}
Expand Down Expand Up @@ -278,7 +278,6 @@ class ErrorOr {
return const_cast<ErrorOr<T> *>(this)->getErrorStorage();
}


union {
AlignedCharArrayUnion<storage_type> TStorage;
AlignedCharArrayUnion<std::error_code> ErrorStorage;
Expand All @@ -295,4 +294,4 @@ operator==(const ErrorOr<T> &Err, E Code) {
}
} // end namespace llvm

#endif
#endif // LLVM_SUPPORT_ERROROR_H
Loading

0 comments on commit 51ecde1

Please sign in to comment.