Skip to content

Commit dd5341f

Browse files
committed
Re-commit "[IR] Add NODISCARD to attribute functions"
Now that https://reviews.llvm.org/D55435 is committed, https://reviews.llvm.org/D55217 can be committed once again -- all warnings are now fixed. llvm-svn: 348733
1 parent b963c51 commit dd5341f

File tree

1 file changed

+64
-53
lines changed

1 file changed

+64
-53
lines changed

llvm/include/llvm/IR/Attributes.h

Lines changed: 64 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -230,29 +230,33 @@ class AttributeSet {
230230

231231
/// Add an argument attribute. Returns a new set because attribute sets are
232232
/// immutable.
233-
AttributeSet addAttribute(LLVMContext &C, Attribute::AttrKind Kind) const;
233+
LLVM_NODISCARD AttributeSet addAttribute(LLVMContext &C,
234+
Attribute::AttrKind Kind) const;
234235

235236
/// Add a target-dependent attribute. Returns a new set because attribute sets
236237
/// are immutable.
237-
AttributeSet addAttribute(LLVMContext &C, StringRef Kind,
238-
StringRef Value = StringRef()) const;
238+
LLVM_NODISCARD AttributeSet addAttribute(LLVMContext &C, StringRef Kind,
239+
StringRef Value = StringRef()) const;
239240

240241
/// Add attributes to the attribute set. Returns a new set because attribute
241242
/// sets are immutable.
242-
AttributeSet addAttributes(LLVMContext &C, AttributeSet AS) const;
243+
LLVM_NODISCARD AttributeSet addAttributes(LLVMContext &C,
244+
AttributeSet AS) const;
243245

244246
/// Remove the specified attribute from this set. Returns a new set because
245247
/// attribute sets are immutable.
246-
AttributeSet removeAttribute(LLVMContext &C, Attribute::AttrKind Kind) const;
248+
LLVM_NODISCARD AttributeSet removeAttribute(LLVMContext &C,
249+
Attribute::AttrKind Kind) const;
247250

248251
/// Remove the specified attribute from this set. Returns a new set because
249252
/// attribute sets are immutable.
250-
AttributeSet removeAttribute(LLVMContext &C, StringRef Kind) const;
253+
LLVM_NODISCARD AttributeSet removeAttribute(LLVMContext &C,
254+
StringRef Kind) const;
251255

252256
/// Remove the specified attributes from this set. Returns a new set because
253257
/// attribute sets are immutable.
254-
AttributeSet removeAttributes(LLVMContext &C,
255-
const AttrBuilder &AttrsToRemove) const;
258+
LLVM_NODISCARD AttributeSet
259+
removeAttributes(LLVMContext &C, const AttrBuilder &AttrsToRemove) const;
256260

257261
/// Return the number of attributes in this set.
258262
unsigned getNumAttributes() const;
@@ -375,133 +379,140 @@ class AttributeList {
375379

376380
/// Add an attribute to the attribute set at the given index.
377381
/// Returns a new list because attribute lists are immutable.
378-
AttributeList addAttribute(LLVMContext &C, unsigned Index,
379-
Attribute::AttrKind Kind) const;
382+
LLVM_NODISCARD AttributeList addAttribute(LLVMContext &C, unsigned Index,
383+
Attribute::AttrKind Kind) const;
380384

381385
/// Add an attribute to the attribute set at the given index.
382386
/// Returns a new list because attribute lists are immutable.
383-
AttributeList addAttribute(LLVMContext &C, unsigned Index, StringRef Kind,
384-
StringRef Value = StringRef()) const;
387+
LLVM_NODISCARD AttributeList
388+
addAttribute(LLVMContext &C, unsigned Index, StringRef Kind,
389+
StringRef Value = StringRef()) const;
385390

386391
/// Add an attribute to the attribute set at the given index.
387392
/// Returns a new list because attribute lists are immutable.
388-
AttributeList addAttribute(LLVMContext &C, unsigned Index, Attribute A) const;
393+
LLVM_NODISCARD AttributeList addAttribute(LLVMContext &C, unsigned Index,
394+
Attribute A) const;
389395

390396
/// Add attributes to the attribute set at the given index.
391397
/// Returns a new list because attribute lists are immutable.
392-
AttributeList addAttributes(LLVMContext &C, unsigned Index,
393-
const AttrBuilder &B) const;
398+
LLVM_NODISCARD AttributeList addAttributes(LLVMContext &C, unsigned Index,
399+
const AttrBuilder &B) const;
394400

395401
/// Add an argument attribute to the list. Returns a new list because
396402
/// attribute lists are immutable.
397-
AttributeList addParamAttribute(LLVMContext &C, unsigned ArgNo,
398-
Attribute::AttrKind Kind) const {
403+
LLVM_NODISCARD AttributeList addParamAttribute(
404+
LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const {
399405
return addAttribute(C, ArgNo + FirstArgIndex, Kind);
400406
}
401407

402408
/// Add an argument attribute to the list. Returns a new list because
403409
/// attribute lists are immutable.
404-
AttributeList addParamAttribute(LLVMContext &C, unsigned ArgNo,
405-
StringRef Kind,
406-
StringRef Value = StringRef()) const {
410+
LLVM_NODISCARD AttributeList
411+
addParamAttribute(LLVMContext &C, unsigned ArgNo, StringRef Kind,
412+
StringRef Value = StringRef()) const {
407413
return addAttribute(C, ArgNo + FirstArgIndex, Kind, Value);
408414
}
409415

410416
/// Add an attribute to the attribute list at the given arg indices. Returns a
411417
/// new list because attribute lists are immutable.
412-
AttributeList addParamAttribute(LLVMContext &C, ArrayRef<unsigned> ArgNos,
413-
Attribute A) const;
418+
LLVM_NODISCARD AttributeList addParamAttribute(LLVMContext &C,
419+
ArrayRef<unsigned> ArgNos,
420+
Attribute A) const;
414421

415422
/// Add an argument attribute to the list. Returns a new list because
416423
/// attribute lists are immutable.
417-
AttributeList addParamAttributes(LLVMContext &C, unsigned ArgNo,
418-
const AttrBuilder &B) const {
424+
LLVM_NODISCARD AttributeList addParamAttributes(LLVMContext &C,
425+
unsigned ArgNo,
426+
const AttrBuilder &B) const {
419427
return addAttributes(C, ArgNo + FirstArgIndex, B);
420428
}
421429

422430
/// Remove the specified attribute at the specified index from this
423431
/// attribute list. Returns a new list because attribute lists are immutable.
424-
AttributeList removeAttribute(LLVMContext &C, unsigned Index,
425-
Attribute::AttrKind Kind) const;
432+
LLVM_NODISCARD AttributeList removeAttribute(LLVMContext &C, unsigned Index,
433+
Attribute::AttrKind Kind) const;
426434

427435
/// Remove the specified attribute at the specified index from this
428436
/// attribute list. Returns a new list because attribute lists are immutable.
429-
AttributeList removeAttribute(LLVMContext &C, unsigned Index,
430-
StringRef Kind) const;
437+
LLVM_NODISCARD AttributeList removeAttribute(LLVMContext &C, unsigned Index,
438+
StringRef Kind) const;
431439

432440
/// Remove the specified attributes at the specified index from this
433441
/// attribute list. Returns a new list because attribute lists are immutable.
434-
AttributeList removeAttributes(LLVMContext &C, unsigned Index,
435-
const AttrBuilder &AttrsToRemove) const;
442+
LLVM_NODISCARD AttributeList removeAttributes(
443+
LLVMContext &C, unsigned Index, const AttrBuilder &AttrsToRemove) const;
436444

437445
/// Remove all attributes at the specified index from this
438446
/// attribute list. Returns a new list because attribute lists are immutable.
439-
AttributeList removeAttributes(LLVMContext &C, unsigned Index) const;
447+
LLVM_NODISCARD AttributeList removeAttributes(LLVMContext &C,
448+
unsigned Index) const;
440449

441450
/// Remove the specified attribute at the specified arg index from this
442451
/// attribute list. Returns a new list because attribute lists are immutable.
443-
AttributeList removeParamAttribute(LLVMContext &C, unsigned ArgNo,
444-
Attribute::AttrKind Kind) const {
452+
LLVM_NODISCARD AttributeList removeParamAttribute(
453+
LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const {
445454
return removeAttribute(C, ArgNo + FirstArgIndex, Kind);
446455
}
447456

448457
/// Remove the specified attribute at the specified arg index from this
449458
/// attribute list. Returns a new list because attribute lists are immutable.
450-
AttributeList removeParamAttribute(LLVMContext &C, unsigned ArgNo,
451-
StringRef Kind) const {
459+
LLVM_NODISCARD AttributeList removeParamAttribute(LLVMContext &C,
460+
unsigned ArgNo,
461+
StringRef Kind) const {
452462
return removeAttribute(C, ArgNo + FirstArgIndex, Kind);
453463
}
454464

455465
/// Remove the specified attribute at the specified arg index from this
456466
/// attribute list. Returns a new list because attribute lists are immutable.
457-
AttributeList removeParamAttributes(LLVMContext &C, unsigned ArgNo,
458-
const AttrBuilder &AttrsToRemove) const {
467+
LLVM_NODISCARD AttributeList removeParamAttributes(
468+
LLVMContext &C, unsigned ArgNo, const AttrBuilder &AttrsToRemove) const {
459469
return removeAttributes(C, ArgNo + FirstArgIndex, AttrsToRemove);
460470
}
461471

462472
/// Remove all attributes at the specified arg index from this
463473
/// attribute list. Returns a new list because attribute lists are immutable.
464-
AttributeList removeParamAttributes(LLVMContext &C, unsigned ArgNo) const {
474+
LLVM_NODISCARD AttributeList removeParamAttributes(LLVMContext &C,
475+
unsigned ArgNo) const {
465476
return removeAttributes(C, ArgNo + FirstArgIndex);
466477
}
467478

468479
/// \brief Add the dereferenceable attribute to the attribute set at the given
469480
/// index. Returns a new list because attribute lists are immutable.
470-
AttributeList addDereferenceableAttr(LLVMContext &C, unsigned Index,
471-
uint64_t Bytes) const;
481+
LLVM_NODISCARD AttributeList addDereferenceableAttr(LLVMContext &C,
482+
unsigned Index,
483+
uint64_t Bytes) const;
472484

473485
/// \brief Add the dereferenceable attribute to the attribute set at the given
474486
/// arg index. Returns a new list because attribute lists are immutable.
475-
AttributeList addDereferenceableParamAttr(LLVMContext &C, unsigned ArgNo,
476-
uint64_t Bytes) const {
487+
LLVM_NODISCARD AttributeList addDereferenceableParamAttr(
488+
LLVMContext &C, unsigned ArgNo, uint64_t Bytes) const {
477489
return addDereferenceableAttr(C, ArgNo + FirstArgIndex, Bytes);
478490
}
479491

480492
/// Add the dereferenceable_or_null attribute to the attribute set at
481493
/// the given index. Returns a new list because attribute lists are immutable.
482-
AttributeList addDereferenceableOrNullAttr(LLVMContext &C, unsigned Index,
483-
uint64_t Bytes) const;
494+
LLVM_NODISCARD AttributeList addDereferenceableOrNullAttr(
495+
LLVMContext &C, unsigned Index, uint64_t Bytes) const;
484496

485497
/// Add the dereferenceable_or_null attribute to the attribute set at
486498
/// the given arg index. Returns a new list because attribute lists are
487499
/// immutable.
488-
AttributeList addDereferenceableOrNullParamAttr(LLVMContext &C,
489-
unsigned ArgNo,
490-
uint64_t Bytes) const {
500+
LLVM_NODISCARD AttributeList addDereferenceableOrNullParamAttr(
501+
LLVMContext &C, unsigned ArgNo, uint64_t Bytes) const {
491502
return addDereferenceableOrNullAttr(C, ArgNo + FirstArgIndex, Bytes);
492503
}
493504

494505
/// Add the allocsize attribute to the attribute set at the given index.
495506
/// Returns a new list because attribute lists are immutable.
496-
AttributeList addAllocSizeAttr(LLVMContext &C, unsigned Index,
497-
unsigned ElemSizeArg,
498-
const Optional<unsigned> &NumElemsArg);
507+
LLVM_NODISCARD AttributeList
508+
addAllocSizeAttr(LLVMContext &C, unsigned Index, unsigned ElemSizeArg,
509+
const Optional<unsigned> &NumElemsArg);
499510

500511
/// Add the allocsize attribute to the attribute set at the given arg index.
501512
/// Returns a new list because attribute lists are immutable.
502-
AttributeList addAllocSizeParamAttr(LLVMContext &C, unsigned ArgNo,
503-
unsigned ElemSizeArg,
504-
const Optional<unsigned> &NumElemsArg) {
513+
LLVM_NODISCARD AttributeList
514+
addAllocSizeParamAttr(LLVMContext &C, unsigned ArgNo, unsigned ElemSizeArg,
515+
const Optional<unsigned> &NumElemsArg) {
505516
return addAllocSizeAttr(C, ArgNo + FirstArgIndex, ElemSizeArg, NumElemsArg);
506517
}
507518

0 commit comments

Comments
 (0)