Skip to content

Commit

Permalink
Fix some Clang-tidy modernize warnings, other minor fixes.
Browse files Browse the repository at this point in the history
Fixed warnings are: modernize-use-override, modernize-use-nullptr and modernize-redundant-void-arg.

Differential revision: http://reviews.llvm.org/D14312


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252087 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
EugeneZelenko committed Nov 4, 2015
1 parent 32968f1 commit 4e036ff
Show file tree
Hide file tree
Showing 17 changed files with 82 additions and 89 deletions.
17 changes: 8 additions & 9 deletions include/llvm-c/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ typedef enum {
LLVMCleanupPad = 65,
LLVMCatchEndPad = 66,
LLVMCleanupEndPad = 67

} LLVMOpcode;

typedef enum {
Expand Down Expand Up @@ -436,7 +435,6 @@ void LLVMInitializeCore(LLVMPassRegistryRef R);
@see ManagedStatic */
void LLVMShutdown(void);


/*===-- Error handling ----------------------------------------------------===*/

char *LLVMCreateMessage(const char *Message);
Expand Down Expand Up @@ -816,6 +814,7 @@ LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C);
LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C);
LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C);
LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C);
LLVMTypeRef LLVMInt128TypeInContext(LLVMContextRef C);
LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits);

/**
Expand All @@ -827,6 +826,7 @@ LLVMTypeRef LLVMInt8Type(void);
LLVMTypeRef LLVMInt16Type(void);
LLVMTypeRef LLVMInt32Type(void);
LLVMTypeRef LLVMInt64Type(void);
LLVMTypeRef LLVMInt128Type(void);
LLVMTypeRef LLVMIntType(unsigned NumBits);
unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy);

Expand Down Expand Up @@ -1030,7 +1030,6 @@ LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy);
* @}
*/


/**
* @defgroup LLVMCCoreTypeSequential Sequential Types
*
Expand Down Expand Up @@ -1211,7 +1210,7 @@ LLVMTypeRef LLVMX86MMXType(void);
macro(InsertElementInst) \
macro(InsertValueInst) \
macro(LandingPadInst) \
macro(CleanupPadInst) \
macro(CleanupPadInst) \
macro(PHINode) \
macro(SelectInst) \
macro(ShuffleVectorInst) \
Expand All @@ -1226,9 +1225,9 @@ LLVMTypeRef LLVMX86MMXType(void);
macro(ResumeInst) \
macro(CleanupReturnInst) \
macro(CatchReturnInst) \
macro(CatchPadInst) \
macro(TerminatePadInst) \
macro(CatchEndPadInst) \
macro(CatchPadInst) \
macro(TerminatePadInst) \
macro(CatchEndPadInst) \
macro(CleanupEndPadInst) \
macro(UnaryInstruction) \
macro(AllocaInst) \
Expand Down Expand Up @@ -3037,6 +3036,6 @@ LLVMBool LLVMIsMultithreaded(void);

#ifdef __cplusplus
}
#endif /* !defined(__cplusplus) */
#endif

#endif /* !defined(LLVM_C_CORE_H) */
#endif /* LLVM_C_CORE_H */
7 changes: 4 additions & 3 deletions include/llvm/ProfileData/SampleProf.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// sample profile data.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_PROFILEDATA_SAMPLEPROF_H_
#define LLVM_PROFILEDATA_SAMPLEPROF_H_

Expand Down Expand Up @@ -245,7 +246,7 @@ class FunctionSamples {
findFunctionSamplesAt(const CallsiteLocation &Loc) const {
auto iter = CallsiteSamples.find(Loc);
if (iter == CallsiteSamples.end()) {
return NULL;
return nullptr;
} else {
return &iter->second;
}
Expand Down Expand Up @@ -322,8 +323,8 @@ class FunctionSamples {
CallsiteSampleMap CallsiteSamples;
};

} // End namespace sampleprof
} // end namespace sampleprof

} // End namespace llvm
} // end namespace llvm

#endif // LLVM_PROFILEDATA_SAMPLEPROF_H_
2 changes: 1 addition & 1 deletion lib/CodeGen/AsmPrinter/DwarfAccelTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void DwarfAccelTable::AddName(DwarfStringPoolEntryRef Name, const DIE *die,
DIEs.Values.push_back(new (Allocator) HashDataContents(die, Flags));
}

void DwarfAccelTable::ComputeBucketCount(void) {
void DwarfAccelTable::ComputeBucketCount() {
// First get the number of unique hashes.
std::vector<uint32_t> uniques(Data.size());
for (size_t i = 0, e = Data.size(); i < e; ++i)
Expand Down
8 changes: 3 additions & 5 deletions lib/MC/MCAsmStreamer.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- lib/MC/MCAsmStreamer.cpp - Text Assembly Output --------------------===//
//===- lib/MC/MCAsmStreamer.cpp - Text Assembly Output ----------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
Expand Down Expand Up @@ -33,6 +33,7 @@
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/Path.h"
#include <cctype>

using namespace llvm;

namespace {
Expand Down Expand Up @@ -655,7 +656,6 @@ static void PrintQuotedString(StringRef Data, raw_ostream &OS) {
OS << '"';
}


void MCAsmStreamer::EmitBytes(StringRef Data) {
assert(getCurrentSection().first &&
"Cannot emit contents before setting section!");
Expand Down Expand Up @@ -777,7 +777,6 @@ void MCAsmStreamer::EmitGPRel32Value(const MCExpr *Value) {
EmitEOL();
}


/// EmitFill - Emit NumBytes bytes worth of the value specified by
/// FillValue. This implements directives such as '.space'.
void MCAsmStreamer::EmitFill(uint64_t NumBytes, uint8_t FillValue) {
Expand Down Expand Up @@ -867,7 +866,6 @@ bool MCAsmStreamer::EmitValueToOffset(const MCExpr *Offset,
return false;
}


void MCAsmStreamer::EmitFileDirective(StringRef Filename) {
assert(MAI->hasSingleParameterDotFile());
OS << "\t.file\t";
Expand Down Expand Up @@ -1230,7 +1228,7 @@ void MCAsmStreamer::EmitWinCFIPushFrame(bool Code) {
EmitEOL();
}

void MCAsmStreamer::EmitWinCFIEndProlog(void) {
void MCAsmStreamer::EmitWinCFIEndProlog() {
MCStreamer::EmitWinCFIEndProlog();

OS << "\t.seh_endprologue";
Expand Down
6 changes: 3 additions & 3 deletions lib/Support/TimeValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
#include "llvm/Config/config.h"

namespace llvm {

using namespace sys;

const TimeValue::SecondsType
TimeValue::PosixZeroTimeSeconds = -946684800;
const TimeValue::SecondsType
TimeValue::Win32ZeroTimeSeconds = -12591158400ULL;

void
TimeValue::normalize( void ) {
void TimeValue::normalize() {
if ( nanos_ >= NANOSECONDS_PER_SECOND ) {
do {
seconds_++;
Expand All @@ -45,7 +45,7 @@ TimeValue::normalize( void ) {
}
}

}
} // namespace llvm

/// Include the platform-specific portion of TimeValue class
#ifdef LLVM_ON_UNIX
Expand Down
26 changes: 12 additions & 14 deletions lib/Transforms/InstCombine/InstCombineAddSub.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- InstCombineAddSub.cpp ----------------------------------------------===//
//===- InstCombineAddSub.cpp ------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
Expand All @@ -17,6 +17,7 @@
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/GetElementPtrTypeIterator.h"
#include "llvm/IR/PatternMatch.h"

using namespace llvm;
using namespace PatternMatch;

Expand Down Expand Up @@ -67,17 +68,17 @@ namespace {

private:
bool insaneIntVal(int V) { return V > 4 || V < -4; }
APFloat *getFpValPtr(void)
APFloat *getFpValPtr()
{ return reinterpret_cast<APFloat*>(&FpValBuf.buffer[0]); }
const APFloat *getFpValPtr(void) const
const APFloat *getFpValPtr() const
{ return reinterpret_cast<const APFloat*>(&FpValBuf.buffer[0]); }

const APFloat &getFpVal(void) const {
const APFloat &getFpVal() const {
assert(IsFp && BufHasFpVal && "Incorret state");
return *getFpValPtr();
}

APFloat &getFpVal(void) {
APFloat &getFpVal() {
assert(IsFp && BufHasFpVal && "Incorret state");
return *getFpValPtr();
}
Expand All @@ -92,8 +93,8 @@ namespace {
// TODO: We should get rid of this function when APFloat can be constructed
// from an *SIGNED* integer.
APFloat createAPFloatFromInt(const fltSemantics &Sem, int Val);
private:

private:
bool IsFp;

// True iff FpValBuf contains an instance of APFloat.
Expand All @@ -114,10 +115,10 @@ namespace {
///
class FAddend {
public:
FAddend() { Val = nullptr; }
FAddend() : Val(nullptr) {}

Value *getSymVal (void) const { return Val; }
const FAddendCoef &getCoef(void) const { return Coeff; }
Value *getSymVal() const { return Val; }
const FAddendCoef &getCoef() const { return Coeff; }

bool isConstant() const { return Val == nullptr; }
bool isZero() const { return Coeff.isZero(); }
Expand Down Expand Up @@ -182,7 +183,6 @@ namespace {
InstCombiner::BuilderTy *Builder;
Instruction *Instr;

private:
// Debugging stuff are clustered here.
#ifndef NDEBUG
unsigned CreateInstrNum;
Expand All @@ -193,7 +193,8 @@ namespace {
void incCreateInstNum() {}
#endif
};
}

} // anonymous namespace

//===----------------------------------------------------------------------===//
//
Expand Down Expand Up @@ -602,7 +603,6 @@ Value *FAddCombine::simplify(Instruction *I) {
}

Value *FAddCombine::simplifyFAdd(AddendVect& Addends, unsigned InstrQuota) {

unsigned AddendNum = Addends.size();
assert(AddendNum <= 4 && "Too many addends");

Expand Down Expand Up @@ -1421,7 +1421,6 @@ Instruction *InstCombiner::visitFAdd(BinaryOperator &I) {
return Changed ? &I : nullptr;
}


/// Optimize pointer differences into the same array into a size. Consider:
/// &A[10] - &A[0]: we should compile this to "10". LHS/RHS are the pointer
/// operands to the ptrtoint instructions for the LHS/RHS of the subtract.
Expand Down Expand Up @@ -1589,7 +1588,6 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) {
}
}


{
Value *Y;
// X-(X+Y) == -Y X-(Y+X) == -Y
Expand Down
2 changes: 1 addition & 1 deletion lib/Transforms/Instrumentation/SafeStack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ Value *SafeStack::getOrCreateUnsafeStackPtr(IRBuilder<> &IRB, Function &F) {
// We use the initial-exec TLS model because we do not support the
// variable living anywhere other than in the main executable.
UnsafeStackPtr = new GlobalVariable(
M, StackPtrTy, false, GlobalValue::ExternalLinkage, 0,
M, StackPtrTy, false, GlobalValue::ExternalLinkage, nullptr,
UnsafeStackPtrVar, nullptr, GlobalValue::InitialExecTLSModel);
} else {
// The variable exists, check its type and attributes.
Expand Down
4 changes: 2 additions & 2 deletions lib/Transforms/Scalar/MergedLoadStoreMotion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class MergedLoadStoreMotion : public FunctionPass {

public:
static char ID; // Pass identification, replacement for typeid
explicit MergedLoadStoreMotion(void)
MergedLoadStoreMotion()
: FunctionPass(ID), MD(nullptr), MagicCompileTimeControl(250) {
initializeMergedLoadStoreMotionPass(*PassRegistry::getPassRegistry());
}
Expand Down Expand Up @@ -159,7 +159,7 @@ class MergedLoadStoreMotion : public FunctionPass {
};

char MergedLoadStoreMotion::ID = 0;
}
} // anonymous namespace

///
/// \brief createMergedLoadStoreMotionPass - The public interface to this file.
Expand Down
4 changes: 2 additions & 2 deletions tools/lli/RemoteTarget.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- RemoteTarget.cpp - LLVM Remote process JIT execution --------------===//
//===- RemoteTarget.cpp - LLVM Remote process JIT execution -----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
Expand Down Expand Up @@ -56,7 +56,7 @@ bool RemoteTarget::loadCode(uint64_t Address, const void *Data, size_t Size) {
}

bool RemoteTarget::executeCode(uint64_t Address, int &RetVal) {
int (*fn)(void) = (int(*)(void))Address;
int (*fn)() = (int(*)())Address;
RetVal = fn();
return true;
}
Expand Down
5 changes: 3 additions & 2 deletions tools/llvm-mc/llvm-mc.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- llvm-mc.cpp - Machine Code Hacking Driver -------------------------===//
//===-- llvm-mc.cpp - Machine Code Hacking Driver ---------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
Expand Down Expand Up @@ -39,6 +39,7 @@
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/ToolOutputFile.h"

using namespace llvm;

static cl::opt<std::string>
Expand Down Expand Up @@ -234,7 +235,7 @@ static void setDwarfDebugFlags(int argc, char **argv) {
}

static std::string DwarfDebugProducer;
static void setDwarfDebugProducer(void) {
static void setDwarfDebugProducer() {
if(!getenv("DEBUG_PRODUCER"))
return;
DwarfDebugProducer += getenv("DEBUG_PRODUCER");
Expand Down
5 changes: 3 additions & 2 deletions tools/llvm-size/llvm-size.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- llvm-size.cpp - Print the size of each object section -------------===//
//===-- llvm-size.cpp - Print the size of each object section ---*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
Expand Down Expand Up @@ -30,6 +30,7 @@
#include <algorithm>
#include <string>
#include <system_error>

using namespace llvm;
using namespace object;

Expand Down Expand Up @@ -98,7 +99,7 @@ static size_t getNumLengthAsString(uint64_t num) {
}

/// @brief Return the printing format for the Radix.
static const char *getRadixFmt(void) {
static const char *getRadixFmt() {
switch (Radix) {
case octal:
return PRIo64;
Expand Down
6 changes: 3 additions & 3 deletions unittests/ExecutionEngine/MCJIT/MCJITMultipleModuleTest.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- MCJITMultipeModuleTest.cpp - Unit tests for the MCJIT-----*- C++ -*-===//
//===- MCJITMultipeModuleTest.cpp - Unit tests for the MCJIT ----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
Expand Down Expand Up @@ -228,13 +228,13 @@ TEST_F(MCJITMultipleModuleTest, two_module_global_variables_case) {
uint64_t FBPtr = TheJIT->getFunctionAddress(FB->getName().str());
TheJIT->finalizeObject();
EXPECT_TRUE(0 != FBPtr);
int32_t(*FuncPtr)(void) = (int32_t(*)(void))FBPtr;
int32_t(*FuncPtr)() = (int32_t(*)())FBPtr;
EXPECT_EQ(initialNum, FuncPtr())
<< "Invalid value for global returned from JITted function in module B";

uint64_t FAPtr = TheJIT->getFunctionAddress(FA->getName().str());
EXPECT_TRUE(0 != FAPtr);
FuncPtr = (int32_t(*)(void))FAPtr;
FuncPtr = (int32_t(*)())FAPtr;
EXPECT_EQ(initialNum, FuncPtr())
<< "Invalid value for global returned from JITted function in module A";
}
Expand Down
Loading

0 comments on commit 4e036ff

Please sign in to comment.