Skip to content

Commit

Permalink
[NFC] Finish clang-tidy cleanup
Browse files Browse the repository at this point in the history
- Follow up on previous clang-tidy changes. Finish up clang-tidy changes
  of remaining project sources.
- Add support to enable clang-tidy checks on project source files
  by adding a new cmake variable viz., MCTOLL_CLANG_TIDY, that can be
  specified while configuring cmake.
- Update README.md
  • Loading branch information
bharadwajy committed Sep 22, 2022
1 parent 59290c9 commit 5c34f03
Show file tree
Hide file tree
Showing 30 changed files with 1,282 additions and 1,260 deletions.
4 changes: 2 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ ForEachMacros:
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
- Regex: '^"(llvm-|llvm|clang-c|clang)/'
Priority: 2
SortPriority: 0
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Expand Down Expand Up @@ -105,7 +105,7 @@ PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
ReflowComments: true
SortIncludes: CaseInsensitive
SortIncludes: CaseSensitive
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
Expand Down
2 changes: 1 addition & 1 deletion ARM/ARMArgumentRaiser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ bool ARMArgumentRaiser::raiseArgs() {
ArgIter != ArgEnd; ++ArgIter)
ArgIter->setName("arg." + std::to_string(ArgIdx++));

for (unsigned i = 0, End = RF->arg_size() + 1; i < End; ++i) {
for (unsigned Idx = 0, End = RF->arg_size() + 1; Idx < End; ++Idx) {
Align ALG(32);
MFI->CreateStackObject(32, ALG, false);
}
Expand Down
28 changes: 14 additions & 14 deletions ARM/ARMCreateJumpTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ MachineBasicBlock *ARMCreateJumpTable::checkJumptableBB(MachineFunction &MF) {
}
}

for (unsigned int i = 0; i < Instrs.size(); i++) {
MBB->erase(Instrs[i]);
for (unsigned int Idx = 0; Idx < Instrs.size(); Idx++) {
MBB->erase(Instrs[Idx]);
}
}
return JumpTableBB;
Expand All @@ -103,16 +103,16 @@ bool ARMCreateJumpTable::updatetheBranchInst(MachineBasicBlock &MBB) {
MachineInstr &CurMI = (*MIIter);

if (CurMI.getOpcode() == ARM::Bcc) {
for (unsigned int i = 0; i < CurMI.getNumOperands(); i++) {
LLVM_DEBUG(CurMI.getOperand(i).dump());
for (unsigned int Idx = 0; Idx < CurMI.getNumOperands(); Idx++) {
LLVM_DEBUG(CurMI.getOperand(Idx).dump());
}
BuildMI(&MBB, DebugLoc(), TII->get(ARM::B)).add(CurMI.getOperand(0));
Instrs.push_back(&CurMI);
}
}

for (unsigned int i = 0; i < Instrs.size(); i++) {
MBB.erase(Instrs[i]);
for (unsigned int Idx = 0; Idx < Instrs.size(); Idx++) {
MBB.erase(Instrs[Idx]);
}
return true;
}
Expand All @@ -122,8 +122,8 @@ bool ARMCreateJumpTable::raiseMaichineJumpTable(MachineFunction &MF) {
// A vector to record MBBs that need to be erased upon jump table creation.
std::vector<MachineBasicBlock *> MBBsToBeErased;

std::map<uint64_t, MCInstOrData> mcInstMapData;
MCInstRaiser::const_mcinst_iter iter_in;
std::map<uint64_t, MCInstOrData> MCInstMapData;
MCInstRaiser::const_mcinst_iter IterIn;

// Save the ADDri and Calculate the start address of data.
for (MachineBasicBlock &JmpTblBaseCalcMBB : MF) {
Expand Down Expand Up @@ -156,20 +156,20 @@ bool ARMCreateJumpTable::raiseMaichineJumpTable(MachineFunction &MF) {
assert(
MCIR != nullptr &&
"Current function machine instruction raiser wasn't initialized!");
for (iter_in = MCIR->const_mcinstr_begin();
iter_in != MCIR->const_mcinstr_end(); iter_in++) {
MCInstOrData mcInstorData = iter_in->second;
if (mcInstorData.isData() && mcInstorData.getData() > 0) {
for (IterIn = MCIR->const_mcinstr_begin();
IterIn != MCIR->const_mcinstr_end(); IterIn++) {
MCInstOrData MCInstorData = IterIn->second;
if (MCInstorData.isData() && MCInstorData.getData() > 0) {
// The 16 is 8 + 8. The first 8 is the PC offset, the second 8 is
// the immediate of current instruction.
// If the current library is position-independent, the offset should
// be CASE VALUE + PC + 8.
// If the current library is not position-independent, the offset
// should be CASE VALUE - text section address.
uint64_t Offset =
IsFPIC ? (mcInstorData.getData() +
IsFPIC ? (MCInstorData.getData() +
MCIR->getMCInstIndex(JmpTblOffsetCalcMI) + 16)
: (mcInstorData.getData() - MR->getTextSectionAddress());
: (MCInstorData.getData() - MR->getTextSectionAddress());
auto MBBNo = MCIR->getMBBNumberOfMCInstOffset(Offset, MF);
if (MBBNo != -1) {
MachineBasicBlock *MBB = MF.getBlockNumbered(MBBNo);
Expand Down
16 changes: 8 additions & 8 deletions ARM/ARMEliminatePrologEpilog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ bool ARMEliminatePrologEpilog::checkRegister(
for (; Iter < Instrs.end(); ++Iter) {
MachineInstr *MI = *Iter;
if (MI->mayStore()) {
for (unsigned i = 0; i < MI->getNumOperands(); i++) {
MachineOperand MO = MI->getOperand(i);
for (unsigned Idx = 0; Idx < MI->getNumOperands(); Idx++) {
MachineOperand MO = MI->getOperand(Idx);

// Compare the register number.
if (MO.isReg() && MO.getReg() == Reg)
Expand Down Expand Up @@ -136,8 +136,8 @@ bool ARMEliminatePrologEpilog::eliminateProlog(MachineFunction &MF) const {
const MCPhysReg *CSRegs = TRI->getCalleeSavedRegs(&MF);

std::vector<CalleeSavedInfo> CSI;
for (unsigned i = 0; CSRegs[i]; ++i) {
unsigned Reg = CSRegs[i];
for (unsigned Idx = 0; CSRegs[Idx]; ++Idx) {
unsigned Reg = CSRegs[Idx];

// Save register.
if (checkRegister(Reg, PrologInstrs)) {
Expand Down Expand Up @@ -201,8 +201,8 @@ bool ARMEliminatePrologEpilog::eliminateProlog(MachineFunction &MF) const {

// Eliminate the instructions identified in function prologue
unsigned int DelInstSz = PrologInstrs.size();
for (unsigned int i = 0; i < DelInstSz; i++) {
FrontMBB.erase(PrologInstrs[i]);
for (unsigned int Idx = 0; Idx < DelInstSz; Idx++) {
FrontMBB.erase(PrologInstrs[Idx]);
}

return true;
Expand Down Expand Up @@ -281,8 +281,8 @@ bool ARMEliminatePrologEpilog::eliminateEpilog(MachineFunction &MF) const {

// Eliminate the instructions identified in function epilogue
unsigned int DelInstSz = EpilogInstrs.size();
for (unsigned int i = 0; i < DelInstSz; i++) {
MBB.erase(EpilogInstrs[i]);
for (unsigned int Idx = 0; Idx < DelInstSz; Idx++) {
MBB.erase(EpilogInstrs[Idx]);
}
}

Expand Down
Loading

0 comments on commit 5c34f03

Please sign in to comment.