Skip to content

Commit f2306b6

Browse files
[llvm] Replace LLVM_ATTRIBUTE_UNUSED with [[maybe_unused]] (NFC) (#163507)
This patch replaces LLVM_ATTRIBUTE_UNUSED with [[maybe_unused]]. Note that this patch adjusts the placement of [[maybe_unused]] to comply with the C++17 language.
1 parent 4ff8f11 commit f2306b6

File tree

23 files changed

+59
-76
lines changed

23 files changed

+59
-76
lines changed

llvm/include/llvm/Analysis/TargetLibraryInfo.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,12 +373,10 @@ class TargetLibraryInfo {
373373
/// Disables all builtins.
374374
///
375375
/// This can be used for options like -fno-builtin.
376-
void disableAllFunctions() LLVM_ATTRIBUTE_UNUSED {
377-
OverrideAsUnavailable.set();
378-
}
376+
[[maybe_unused]] void disableAllFunctions() { OverrideAsUnavailable.set(); }
379377

380378
/// Forces a function to be marked as unavailable.
381-
void setUnavailable(LibFunc F) LLVM_ATTRIBUTE_UNUSED {
379+
[[maybe_unused]] void setUnavailable(LibFunc F) {
382380
assert(F < OverrideAsUnavailable.size() && "out-of-bounds LibFunc");
383381
OverrideAsUnavailable.set(F);
384382
}

llvm/include/llvm/CodeGen/LiveRangeCalc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ class LiveRangeCalc {
259259
/// jointly dominated by the blocks corresponding to the slot indices
260260
/// in @p Defs. This function is mainly for use in self-verification
261261
/// checks.
262-
LLVM_ABI LLVM_ATTRIBUTE_UNUSED static bool
262+
[[maybe_unused]] LLVM_ABI static bool
263263
isJointlyDominated(const MachineBasicBlock *MBB, ArrayRef<SlotIndex> Defs,
264264
const SlotIndexes &Indexes);
265265
};

llvm/include/llvm/Support/DebugLog.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,10 @@ constexpr ::llvm::StringRef strip_quotes(const char *Str) {
221221
#define LDBG_GET_DEBUG_TYPE_STR() LDBG_GET_DEBUG_TYPE_STR_(DEBUG_TYPE)
222222

223223
/// Helper to call isCurrentDebugType with a StringRef.
224-
static LLVM_ATTRIBUTE_UNUSED bool ldbgIsCurrentDebugType(StringRef Type,
225-
int Level) {
224+
[[maybe_unused]] static bool ldbgIsCurrentDebugType(StringRef Type, int Level) {
226225
return ::llvm::isCurrentDebugType(Type.str().c_str(), Level);
227226
}
228-
static LLVM_ATTRIBUTE_UNUSED bool ldbgIsCurrentDebugType(int Level,
229-
StringRef Type) {
227+
[[maybe_unused]] static bool ldbgIsCurrentDebugType(int Level, StringRef Type) {
230228
return ::llvm::isCurrentDebugType(Type.str().c_str(), Level);
231229
}
232230

@@ -302,7 +300,7 @@ class RAIINewLineStream final : public raw_ostream {
302300
};
303301

304302
/// Remove the path prefix from the file name.
305-
static LLVM_ATTRIBUTE_UNUSED constexpr const char *
303+
[[maybe_unused]] static constexpr const char *
306304
getShortFileName(const char *path) {
307305
const char *filename = path;
308306
for (const char *p = path; *p != '\0'; ++p) {
@@ -315,7 +313,7 @@ getShortFileName(const char *path) {
315313
/// Compute the prefix for the debug log in the form of:
316314
/// "[DebugType] File:Line "
317315
/// Where the File is the file name without the path prefix.
318-
static LLVM_ATTRIBUTE_UNUSED std::string
316+
[[maybe_unused]] static std::string
319317
computePrefix(StringRef DebugType, const char *File, int Line, int Level) {
320318
std::string Prefix;
321319
raw_string_ostream OsPrefix(Prefix);
@@ -326,7 +324,7 @@ computePrefix(StringRef DebugType, const char *File, int Line, int Level) {
326324
return OsPrefix.str();
327325
}
328326
/// Overload allowing to swap the order of the DebugType and Level arguments.
329-
static LLVM_ATTRIBUTE_UNUSED std::string
327+
[[maybe_unused]] static std::string
330328
computePrefix(int Level, const char *File, int Line, StringRef DebugType) {
331329
return computePrefix(DebugType, File, Line, Level);
332330
}

llvm/lib/CodeGen/CodeGenPrepare.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ void CodeGenPrepare::removeAllAssertingVHReferences(Value *V) {
819819
}
820820

821821
// Verify BFI has been updated correctly by recomputing BFI and comparing them.
822-
void LLVM_ATTRIBUTE_UNUSED CodeGenPrepare::verifyBFIUpdates(Function &F) {
822+
[[maybe_unused]] void CodeGenPrepare::verifyBFIUpdates(Function &F) {
823823
DominatorTree NewDT(F);
824824
LoopInfo NewLI(NewDT);
825825
BranchProbabilityInfo NewBPI(F, NewLI, TLInfo);

llvm/lib/CodeGen/MachineCopyPropagation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1257,7 +1257,7 @@ void MachineCopyPropagation::BackwardCopyPropagateBlock(
12571257
Tracker.clear();
12581258
}
12591259

1260-
static void LLVM_ATTRIBUTE_UNUSED printSpillReloadChain(
1260+
[[maybe_unused]] static void printSpillReloadChain(
12611261
DenseMap<MachineInstr *, SmallVector<MachineInstr *>> &SpillChain,
12621262
DenseMap<MachineInstr *, SmallVector<MachineInstr *>> &ReloadChain,
12631263
MachineInstr *Leader) {

llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ DWARFDebugFrame::DWARFDebugFrame(Triple::ArchType Arch,
181181

182182
DWARFDebugFrame::~DWARFDebugFrame() = default;
183183

184-
static void LLVM_ATTRIBUTE_UNUSED dumpDataAux(DataExtractor Data,
185-
uint64_t Offset, int Length) {
184+
[[maybe_unused]] static void dumpDataAux(DataExtractor Data, uint64_t Offset,
185+
int Length) {
186186
errs() << "DUMP: ";
187187
for (int i = 0; i < Length; ++i) {
188188
uint8_t c = Data.getU8(&Offset);

llvm/lib/ProfileData/InstrProf.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ void ProfOStream::patch(ArrayRef<PatchItem> P) {
302302

303303
std::string getPGOFuncName(StringRef Name, GlobalValue::LinkageTypes Linkage,
304304
StringRef FileName,
305-
uint64_t Version LLVM_ATTRIBUTE_UNUSED) {
305+
[[maybe_unused]] uint64_t Version) {
306306
// Value names may be prefixed with a binary '1' to indicate
307307
// that the backend should not modify the symbols due to any platform
308308
// naming convention. Do not include that '1' in the PGO profile name.

llvm/lib/Support/PrettyStackTrace.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ extern "C" const char *__crashreporter_info__
141141
asm(".desc ___crashreporter_info__, 0x10");
142142
#endif
143143

144-
static void setCrashLogMessage(const char *msg) LLVM_ATTRIBUTE_UNUSED;
144+
[[maybe_unused]] static void setCrashLogMessage(const char *msg);
145145
static void setCrashLogMessage(const char *msg) {
146146
#ifdef HAVE_CRASHREPORTERCLIENT_H
147147
(void)CRSetCrashLogMessage(msg);

llvm/lib/Target/ARM/ARMExpandPseudoInsts.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ namespace {
161161
friend bool operator<(const NEONLdStTableEntry &TE, unsigned PseudoOpc) {
162162
return TE.PseudoOpc < PseudoOpc;
163163
}
164-
friend bool LLVM_ATTRIBUTE_UNUSED operator<(unsigned PseudoOpc,
165-
const NEONLdStTableEntry &TE) {
164+
[[maybe_unused]] friend bool operator<(unsigned PseudoOpc,
165+
const NEONLdStTableEntry &TE) {
166166
return PseudoOpc < TE.PseudoOpc;
167167
}
168168
};

llvm/lib/Target/Hexagon/HexagonBitSimplify.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ namespace {
174174
const TargetRegisterInfo *TRI;
175175
};
176176

177-
raw_ostream &operator<< (raw_ostream &OS, const PrintRegSet &P)
178-
LLVM_ATTRIBUTE_UNUSED;
177+
[[maybe_unused]] raw_ostream &operator<<(raw_ostream &OS,
178+
const PrintRegSet &P);
179179
raw_ostream &operator<< (raw_ostream &OS, const PrintRegSet &P) {
180180
OS << '{';
181181
for (unsigned R = P.RS.find_first(); R; R = P.RS.find_next(R))

0 commit comments

Comments
 (0)