Skip to content

Commit d3a6c89

Browse files
committedFeb 11, 2017
[MC] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 294813
1 parent a2eb926 commit d3a6c89

21 files changed

+261
-240
lines changed
 

‎llvm/include/llvm/MC/MCAsmInfo.h

+82-58
Large diffs are not rendered by default.

‎llvm/include/llvm/MC/MCAsmInfoCOFF.h

+23-19
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- MCAsmInfoCOFF.h - COFF asm properties -------------------*- C++ -*-===//
1+
//===- MCAsmInfoCOFF.h - COFF asm properties --------------------*- C++ -*-===//
22
//
33
// The LLVM Compiler Infrastructure
44
//
@@ -13,24 +13,28 @@
1313
#include "llvm/MC/MCAsmInfo.h"
1414

1515
namespace llvm {
16-
class MCAsmInfoCOFF : public MCAsmInfo {
17-
virtual void anchor();
18-
protected:
19-
explicit MCAsmInfoCOFF();
20-
};
21-
22-
class MCAsmInfoMicrosoft : public MCAsmInfoCOFF {
23-
void anchor() override;
24-
protected:
25-
explicit MCAsmInfoMicrosoft();
26-
};
27-
28-
class MCAsmInfoGNUCOFF : public MCAsmInfoCOFF {
29-
void anchor() override;
30-
protected:
31-
explicit MCAsmInfoGNUCOFF();
32-
};
33-
}
3416

17+
class MCAsmInfoCOFF : public MCAsmInfo {
18+
virtual void anchor();
19+
20+
protected:
21+
explicit MCAsmInfoCOFF();
22+
};
23+
24+
class MCAsmInfoMicrosoft : public MCAsmInfoCOFF {
25+
void anchor() override;
26+
27+
protected:
28+
explicit MCAsmInfoMicrosoft();
29+
};
30+
31+
class MCAsmInfoGNUCOFF : public MCAsmInfoCOFF {
32+
void anchor() override;
33+
34+
protected:
35+
explicit MCAsmInfoGNUCOFF();
36+
};
37+
38+
} // end namespace llvm
3539

3640
#endif // LLVM_MC_MCASMINFOCOFF_H

‎llvm/include/llvm/MC/MCAsmInfoDarwin.h

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===---- MCAsmInfoDarwin.h - Darwin asm properties -------------*- C++ -*-===//
1+
//===- MCAsmInfoDarwin.h - Darwin asm properties ----------------*- C++ -*-===//
22
//
33
// The LLVM Compiler Infrastructure
44
//
@@ -18,12 +18,14 @@
1818
#include "llvm/MC/MCAsmInfo.h"
1919

2020
namespace llvm {
21-
class MCAsmInfoDarwin : public MCAsmInfo {
22-
public:
23-
explicit MCAsmInfoDarwin();
24-
bool isSectionAtomizableBySymbols(const MCSection &Section) const override;
25-
};
26-
}
2721

22+
class MCAsmInfoDarwin : public MCAsmInfo {
23+
public:
24+
explicit MCAsmInfoDarwin();
25+
26+
bool isSectionAtomizableBySymbols(const MCSection &Section) const override;
27+
};
28+
29+
} // end namespace llvm
2830

2931
#endif // LLVM_MC_MCASMINFODARWIN_H

‎llvm/include/llvm/MC/MCAsmInfoELF.h

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- llvm/MC/MCAsmInfoELF.h - ELF Asm info -------------------*- C++ -*-===//
1+
//===- llvm/MC/MCAsmInfoELF.h - ELF Asm info --------------------*- C++ -*-===//
22
//
33
// The LLVM Compiler Infrastructure
44
//
@@ -13,17 +13,19 @@
1313
#include "llvm/MC/MCAsmInfo.h"
1414

1515
namespace llvm {
16+
1617
class MCAsmInfoELF : public MCAsmInfo {
1718
virtual void anchor();
1819
MCSection *getNonexecutableStackSection(MCContext &Ctx) const final;
1920

2021
protected:
2122
/// Targets which have non-executable stacks by default can set this to false
2223
/// to disable the special section which requests a non-executable stack.
23-
bool UsesNonexecutableStackSection;
24+
bool UsesNonexecutableStackSection = true;
2425

2526
MCAsmInfoELF();
2627
};
27-
}
2828

29-
#endif
29+
} // end namespace llvm
30+
31+
#endif // LLVM_MC_MCASMINFOELF_H

‎llvm/include/llvm/MC/MCInst.h

+20-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- llvm/MC/MCInst.h - MCInst class -------------------------*- C++ -*-===//
1+
//===- llvm/MC/MCInst.h - MCInst class --------------------------*- C++ -*-===//
22
//
33
// The LLVM Compiler Infrastructure
44
//
@@ -18,15 +18,17 @@
1818

1919
#include "llvm/ADT/SmallVector.h"
2020
#include "llvm/ADT/StringRef.h"
21-
#include "llvm/Support/DataTypes.h"
2221
#include "llvm/Support/SMLoc.h"
22+
#include <cassert>
23+
#include <cstddef>
24+
#include <cstdint>
2325

2426
namespace llvm {
25-
class raw_ostream;
26-
class MCAsmInfo;
27-
class MCInstPrinter;
27+
2828
class MCExpr;
2929
class MCInst;
30+
class MCInstPrinter;
31+
class raw_ostream;
3032

3133
/// \brief Instances of this class represent operands of the MCInst class.
3234
/// This is a simple discriminated union.
@@ -39,7 +41,7 @@ class MCOperand {
3941
kExpr, ///< Relocatable immediate operand.
4042
kInst ///< Sub-instruction operand.
4143
};
42-
MachineOperandType Kind;
44+
MachineOperandType Kind = kInvalid;
4345

4446
union {
4547
unsigned RegVal;
@@ -50,7 +52,7 @@ class MCOperand {
5052
};
5153

5254
public:
53-
MCOperand() : Kind(kInvalid), FPImmVal(0.0) {}
55+
MCOperand() : FPImmVal(0.0) {}
5456

5557
bool isValid() const { return Kind != kInvalid; }
5658
bool isReg() const { return Kind == kRegister; }
@@ -75,6 +77,7 @@ class MCOperand {
7577
assert(isImm() && "This is not an immediate");
7678
return ImmVal;
7779
}
80+
7881
void setImm(int64_t Val) {
7982
assert(isImm() && "This is not an immediate");
8083
ImmVal = Val;
@@ -94,6 +97,7 @@ class MCOperand {
9497
assert(isExpr() && "This is not an expression");
9598
return ExprVal;
9699
}
100+
97101
void setExpr(const MCExpr *Val) {
98102
assert(isExpr() && "This is not an expression");
99103
ExprVal = Val;
@@ -103,6 +107,7 @@ class MCOperand {
103107
assert(isInst() && "This is not a sub-instruction");
104108
return InstVal;
105109
}
110+
106111
void setInst(const MCInst *Val) {
107112
assert(isInst() && "This is not a sub-instruction");
108113
InstVal = Val;
@@ -114,24 +119,28 @@ class MCOperand {
114119
Op.RegVal = Reg;
115120
return Op;
116121
}
122+
117123
static MCOperand createImm(int64_t Val) {
118124
MCOperand Op;
119125
Op.Kind = kImmediate;
120126
Op.ImmVal = Val;
121127
return Op;
122128
}
129+
123130
static MCOperand createFPImm(double Val) {
124131
MCOperand Op;
125132
Op.Kind = kFPImmediate;
126133
Op.FPImmVal = Val;
127134
return Op;
128135
}
136+
129137
static MCOperand createExpr(const MCExpr *Val) {
130138
MCOperand Op;
131139
Op.Kind = kExpr;
132140
Op.ExprVal = Val;
133141
return Op;
134142
}
143+
135144
static MCOperand createInst(const MCInst *Val) {
136145
MCOperand Op;
137146
Op.Kind = kInst;
@@ -148,12 +157,12 @@ template <> struct isPodLike<MCOperand> { static const bool value = true; };
148157
/// \brief Instances of this class represent a single low-level machine
149158
/// instruction.
150159
class MCInst {
151-
unsigned Opcode;
160+
unsigned Opcode = 0;
152161
SMLoc Loc;
153162
SmallVector<MCOperand, 8> Operands;
154163

155164
public:
156-
MCInst() : Opcode(0) {}
165+
MCInst() = default;
157166

158167
void setOpcode(unsigned Op) { Opcode = Op; }
159168
unsigned getOpcode() const { return Opcode; }
@@ -176,6 +185,7 @@ class MCInst {
176185
const_iterator begin() const { return Operands.begin(); }
177186
iterator end() { return Operands.end(); }
178187
const_iterator end() const { return Operands.end(); }
188+
179189
iterator insert(iterator I, const MCOperand &Op) {
180190
return Operands.insert(I, Op);
181191
}
@@ -202,4 +212,4 @@ inline raw_ostream& operator<<(raw_ostream &OS, const MCInst &MI) {
202212

203213
} // end namespace llvm
204214

205-
#endif
215+
#endif // LLVM_MC_MCINST_H

‎llvm/include/llvm/MC/MCInstPrinter.h

+7-9
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
namespace llvm {
1717

1818
template <typename T> class ArrayRef;
19-
class MCInst;
20-
class raw_ostream;
2119
class MCAsmInfo;
20+
class MCInst;
2221
class MCInstrInfo;
2322
class MCRegisterInfo;
2423
class MCSubtargetInfo;
24+
class raw_ostream;
2525
class StringRef;
2626

2727
/// Convert `Bytes' to a hex string and output to `OS'
@@ -43,28 +43,26 @@ class MCInstPrinter {
4343
/// \brief A stream that comments can be emitted to if desired. Each comment
4444
/// must end with a newline. This will be null if verbose assembly emission
4545
/// is disable.
46-
raw_ostream *CommentStream;
46+
raw_ostream *CommentStream = nullptr;
4747
const MCAsmInfo &MAI;
4848
const MCInstrInfo &MII;
4949
const MCRegisterInfo &MRI;
5050

5151
/// True if we are printing marked up assembly.
52-
bool UseMarkup;
52+
bool UseMarkup = false;
5353

5454
/// True if we are printing immediates as hex.
55-
bool PrintImmHex;
55+
bool PrintImmHex = false;
5656

5757
/// Which style to use for printing hexadecimal values.
58-
HexStyle::Style PrintHexStyle;
58+
HexStyle::Style PrintHexStyle = HexStyle::C;
5959

6060
/// Utility function for printing annotations.
6161
void printAnnotation(raw_ostream &OS, StringRef Annot);
6262

6363
public:
6464
MCInstPrinter(const MCAsmInfo &mai, const MCInstrInfo &mii,
65-
const MCRegisterInfo &mri)
66-
: CommentStream(nullptr), MAI(mai), MII(mii), MRI(mri), UseMarkup(false),
67-
PrintImmHex(false), PrintHexStyle(HexStyle::C) {}
65+
const MCRegisterInfo &mri) : MAI(mai), MII(mii), MRI(mri) {}
6866

6967
virtual ~MCInstPrinter();
7068

‎llvm/include/llvm/MC/MCInstrAnalysis.h

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- llvm/MC/MCInstrAnalysis.h - InstrDesc target hooks ------*- C++ -*-===//
1+
//===- llvm/MC/MCInstrAnalysis.h - InstrDesc target hooks -------*- C++ -*-===//
22
//
33
// The LLVM Compiler Infrastructure
44
//
@@ -18,18 +18,19 @@
1818
#include "llvm/MC/MCInst.h"
1919
#include "llvm/MC/MCInstrDesc.h"
2020
#include "llvm/MC/MCInstrInfo.h"
21+
#include <cstdint>
2122

2223
namespace llvm {
2324

2425
class MCInstrAnalysis {
2526
protected:
2627
friend class Target;
28+
2729
const MCInstrInfo *Info;
2830

2931
public:
3032
MCInstrAnalysis(const MCInstrInfo *Info) : Info(Info) {}
31-
32-
virtual ~MCInstrAnalysis() {}
33+
virtual ~MCInstrAnalysis() = default;
3334

3435
virtual bool isBranch(const MCInst &Inst) const {
3536
return Info->get(Inst.getOpcode()).isBranch();
@@ -66,6 +67,6 @@ class MCInstrAnalysis {
6667
uint64_t &Target) const;
6768
};
6869

69-
} // End llvm namespace
70+
} // end namespace llvm
7071

71-
#endif
72+
#endif // LLVM_MC_MCINSTRANALYSIS_H

‎llvm/include/llvm/MC/MCInstrItineraries.h

+12-16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- llvm/MC/MCInstrItineraries.h - Scheduling ---------------*- C++ -*-===//
1+
//===- llvm/MC/MCInstrItineraries.h - Scheduling ----------------*- C++ -*-===//
22
//
33
// The LLVM Compiler Infrastructure
44
//
@@ -88,7 +88,6 @@ struct InstrStage {
8888
}
8989
};
9090

91-
9291
//===----------------------------------------------------------------------===//
9392
/// An itinerary represents the scheduling information for an instruction.
9493
/// This includes a set of stages occupied by the instruction and the pipeline
@@ -102,23 +101,20 @@ struct InstrItinerary {
102101
unsigned LastOperandCycle; ///< Index of last + 1 operand rd/wr
103102
};
104103

105-
106104
//===----------------------------------------------------------------------===//
107105
/// Itinerary data supplied by a subtarget to be used by a target.
108106
///
109107
class InstrItineraryData {
110108
public:
111-
MCSchedModel SchedModel; ///< Basic machine properties.
112-
const InstrStage *Stages; ///< Array of stages selected
113-
const unsigned *OperandCycles; ///< Array of operand cycles selected
114-
const unsigned *Forwardings; ///< Array of pipeline forwarding paths
115-
const InstrItinerary *Itineraries; ///< Array of itineraries selected
116-
117-
/// Ctors.
118-
InstrItineraryData() : SchedModel(MCSchedModel::GetDefaultSchedModel()),
119-
Stages(nullptr), OperandCycles(nullptr),
120-
Forwardings(nullptr), Itineraries(nullptr) {}
121-
109+
MCSchedModel SchedModel =
110+
MCSchedModel::GetDefaultSchedModel(); ///< Basic machine properties.
111+
const InstrStage *Stages = nullptr; ///< Array of stages selected
112+
const unsigned *OperandCycles = nullptr; ///< Array of operand cycles selected
113+
const unsigned *Forwardings = nullptr; ///< Array of pipeline forwarding paths
114+
const InstrItinerary *Itineraries =
115+
nullptr; ///< Array of itineraries selected
116+
117+
InstrItineraryData() = default;
122118
InstrItineraryData(const MCSchedModel &SM, const InstrStage *S,
123119
const unsigned *OS, const unsigned *F)
124120
: SchedModel(SM), Stages(S), OperandCycles(OS), Forwardings(F),
@@ -234,6 +230,6 @@ class InstrItineraryData {
234230
}
235231
};
236232

237-
} // End llvm namespace
233+
} // end namespace llvm
238234

239-
#endif
235+
#endif // LLVM_MC_MCINSTRITINERARIES_H

0 commit comments

Comments
 (0)
Please sign in to comment.