Fix Clang-tidy modernize-use-nullptr and modernize-use-override warnings; other minor fixes.
Differential revision: reviews.llvm.org/D16568
llvm-svn: 258831
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 59e736c..36650db 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -35,6 +35,7 @@
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/raw_ostream.h"
#include <deque>
+
using namespace llvm;
namespace {
@@ -497,7 +498,7 @@
std::error_code initStreamFromBuffer();
std::error_code initLazyStream(std::unique_ptr<DataStreamer> Streamer);
};
-} // namespace
+} // end anonymous namespace
BitcodeDiagnosticInfo::BitcodeDiagnosticInfo(std::error_code EC,
DiagnosticSeverity Severity,
@@ -872,7 +873,7 @@
/// Provide fast operand accessors
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
};
-}
+} // end anonymous namespace
// FIXME: can we inherit this from ConstantExpr?
template <>
@@ -880,7 +881,7 @@
public FixedNumOperandTraits<ConstantPlaceHolder, 1> {
};
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ConstantPlaceHolder, Value)
-}
+} // end namespace llvm
void BitcodeReaderValueList::assignValue(Value *V, unsigned Idx) {
if (Idx == size()) {
@@ -908,11 +909,8 @@
OldV->replaceAllUsesWith(V);
delete PrevVal;
}
-
- return;
}
-
Constant *BitcodeReaderValueList::getConstantFwdRef(unsigned Idx,
Type *Ty) {
if (Idx >= size())
@@ -1129,7 +1127,6 @@
return Ret;
}
-
//===----------------------------------------------------------------------===//
// Functions for parsing blocks from the bitcode file
//===----------------------------------------------------------------------===//
@@ -2178,7 +2175,7 @@
getMDOrNull(Record[9]), getMDOrNull(Record[10]),
getMDOrNull(Record[11]), getMDOrNull(Record[12]),
getMDOrNull(Record[13]),
- Record.size() <= 15 ? 0 : getMDOrNull(Record[15]),
+ Record.size() <= 15 ? nullptr : getMDOrNull(Record[15]),
Record.size() <= 14 ? 0 : Record[14]),
NextMetadataNo++);
break;
@@ -2701,7 +2698,6 @@
}
break;
}
-
case bitc::CST_CODE_CE_BINOP: { // CE_BINOP: [opcode, opval, opval]
if (Record.size() < 3)
return error("Invalid record");
@@ -3375,7 +3371,6 @@
break;
}
-
// Read a record.
auto BitCode = Stream.readRecord(Entry.ID, Record);
switch (BitCode) {
@@ -5816,7 +5811,7 @@
llvm_unreachable("Unknown error type!");
}
};
-}
+} // end anonymous namespace
static ManagedStatic<BitcodeErrorCategoryType> ErrorCategory;
diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp
index 8482b18..00deec6 100644
--- a/llvm/lib/ProfileData/InstrProf.cpp
+++ b/llvm/lib/ProfileData/InstrProf.cpp
@@ -65,7 +65,7 @@
llvm_unreachable("A value of instrprof_error has no message.");
}
};
-}
+} // end anonymous namespace
static ManagedStatic<InstrProfErrorCategoryType> ErrorCategory;
@@ -443,12 +443,12 @@
}
static ValueProfRecordClosure InstrProfRecordClosure = {
- 0,
+ nullptr,
getNumValueKindsInstrProf,
getNumValueSitesInstrProf,
getNumValueDataInstrProf,
getNumValueDataForSiteInstrProf,
- 0,
+ nullptr,
getValueForSiteInstrProf,
allocValueProfDataInstrProf};
@@ -638,7 +638,6 @@
ProfileSummaryEntry PSE = {Cutoff, Count, BlocksSeen};
DetailedSummary.push_back(PSE);
}
- return;
}
-}
+} // end namespace llvm
diff --git a/llvm/lib/Support/Unix/Memory.inc b/llvm/lib/Support/Unix/Memory.inc
index d703191..f3463e5 100644
--- a/llvm/lib/Support/Unix/Memory.inc
+++ b/llvm/lib/Support/Unix/Memory.inc
@@ -73,7 +73,7 @@
return PROT_NONE;
}
-} // namespace
+} // anonymous namespace
namespace llvm {
namespace sys {
@@ -265,7 +265,7 @@
}
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);
#if defined(__APPLE__) && (defined(__arm__) || defined(__arm64__))
kern_return_t kr = vm_protect(mach_task_self(), (vm_address_t)M.Address,
diff --git a/llvm/lib/Target/X86/X86ISelLowering.h b/llvm/lib/Target/X86/X86ISelLowering.h
index 3f87a49..6e48a2d 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.h
+++ b/llvm/lib/Target/X86/X86ISelLowering.h
@@ -556,7 +556,7 @@
// have memop! In fact, starting from ATOMADD64_DAG all opcodes will be
// thought as target memory ops!
};
- }
+ } // end namespace X86ISD
/// Define some predicates that are used for node matching.
namespace X86 {
@@ -608,13 +608,12 @@
bool isOffsetSuitableForCodeModel(int64_t Offset, CodeModel::Model M,
bool hasSymbolicDisplacement = true);
-
/// Determines whether the callee is required to pop its
/// own arguments. Callee pop is necessary to support tail calls.
bool isCalleePop(CallingConv::ID CallingConv,
bool is64Bit, bool IsVarArg, bool GuaranteeTCO);
- }
+ } // end namespace X86
//===--------------------------------------------------------------------===//
// X86 Implementation of the TargetLowering interface
@@ -685,9 +684,9 @@
/// 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
/// to be custom lowered after all.
- virtual void LowerOperationWrapper(SDNode *N,
- SmallVectorImpl<SDValue> &Results,
- SelectionDAG &DAG) const override;
+ void LowerOperationWrapper(SDNode *N,
+ SmallVectorImpl<SDValue> &Results,
+ SelectionDAG &DAG) const override;
/// Replace the results of node with an illegal result
/// type with new values built out of custom code.
@@ -695,7 +694,6 @@
void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue>&Results,
SelectionDAG &DAG) const override;
-
SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;
/// Return true if the target has native support for
@@ -1180,7 +1178,7 @@
namespace X86 {
FastISel *createFastISel(FunctionLoweringInfo &funcInfo,
const TargetLibraryInfo *libInfo);
- }
-}
+ } // end namespace X86
+} // end namespace llvm
-#endif // X86ISELLOWERING_H
+#endif // LLVM_LIB_TARGET_X86_X86ISELLOWERING_H
diff --git a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
index 64aa94f..f9e421d 100644
--- a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
+++ b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
@@ -257,7 +257,7 @@
if (CreateGlobalVar)
FuncNameVar = createPGOFuncNameVar(F, FuncName);
- };
+ }
};
// Compute Hash value for the CFG: the lower 32 bits are CRC32 of the index
@@ -690,7 +690,7 @@
const PGOUseEdge *E = BBCountInfo.OutEdges[s];
const BasicBlock *SrcBB = E->SrcBB;
const BasicBlock *DestBB = E->DestBB;
- if (DestBB == 0)
+ if (DestBB == nullptr)
continue;
unsigned SuccNum = GetSuccessorNumber(SrcBB, DestBB);
uint64_t EdgeCount = E->CountValue;
diff --git a/llvm/lib/Transforms/Utils/AddDiscriminators.cpp b/llvm/lib/Transforms/Utils/AddDiscriminators.cpp
index 0262358..3e585c6 100644
--- a/llvm/lib/Transforms/Utils/AddDiscriminators.cpp
+++ b/llvm/lib/Transforms/Utils/AddDiscriminators.cpp
@@ -80,7 +80,7 @@
bool runOnFunction(Function &F) override;
};
-}
+} // end anonymous namespace
char AddDiscriminators::ID = 0;
INITIALIZE_PASS_BEGIN(AddDiscriminators, "add-discriminators",
@@ -217,7 +217,7 @@
// Sample base profile needs to distinguish different function calls within
// a same source line for correct profile annotation.
for (BasicBlock &B : F) {
- const DILocation *FirstDIL = NULL;
+ const DILocation *FirstDIL = nullptr;
for (auto &I : B.getInstList()) {
CallInst *Current = dyn_cast<CallInst>(&I);
if (!Current || isa<DbgInfoIntrinsic>(&I))
diff --git a/llvm/lib/Transforms/Utils/SanitizerStats.cpp b/llvm/lib/Transforms/Utils/SanitizerStats.cpp
index af3df2f..9afd175 100644
--- a/llvm/lib/Transforms/Utils/SanitizerStats.cpp
+++ b/llvm/lib/Transforms/Utils/SanitizerStats.cpp
@@ -27,7 +27,7 @@
EmptyModuleStatsTy = makeModuleStatsTy();
ModuleStatsGV = new GlobalVariable(*M, EmptyModuleStatsTy, false,
- GlobalValue::InternalLinkage, 0);
+ GlobalValue::InternalLinkage, nullptr);
}
ArrayType *SanitizerStatReport::makeModuleStatsArrayTy() {