Skip to content

Commit d8cd816

Browse files
kazutakahiratasivan-shani
authored andcommitted
[IPO] Teach AbstractAttribute::getName to return StringRef (NFC) (llvm#141313)
This patch addresses clang-tidy's readability-const-return-type by dropping const from the return type while switching to StringRef at the same time because these functions just return string constants.
1 parent fb885f6 commit d8cd816

File tree

4 files changed

+52
-57
lines changed

4 files changed

+52
-57
lines changed

llvm/include/llvm/Transforms/IPO/Attributor.h

Lines changed: 40 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,7 +1614,7 @@ struct Attributor {
16141614
// information, e.g., function -> call site.
16151615
{
16161616
TimeTraceScope TimeScope("initialize", [&]() {
1617-
return AA.getName() +
1617+
return AA.getName().str() +
16181618
std::to_string(AA.getIRPosition().getPositionKind());
16191619
});
16201620
++InitializationChainLength;
@@ -3385,7 +3385,7 @@ struct AbstractAttribute : public IRPosition, public AADepGraphNode {
33853385
virtual const std::string getAsStr(Attributor *A) const = 0;
33863386

33873387
/// This function should return the name of the AbstractAttribute
3388-
virtual const std::string getName() const = 0;
3388+
virtual StringRef getName() const = 0;
33893389

33903390
/// This function should return the address of the ID of the AbstractAttribute
33913391
virtual const char *getIdAddr() const = 0;
@@ -3499,7 +3499,7 @@ struct AANoUnwind
34993499
static AANoUnwind &createForPosition(const IRPosition &IRP, Attributor &A);
35003500

35013501
/// See AbstractAttribute::getName()
3502-
const std::string getName() const override { return "AANoUnwind"; }
3502+
StringRef getName() const override { return "AANoUnwind"; }
35033503

35043504
/// See AbstractAttribute::getIdAddr()
35053505
const char *getIdAddr() const override { return &ID; }
@@ -3582,7 +3582,7 @@ struct AANoSync
35823582
static AANoSync &createForPosition(const IRPosition &IRP, Attributor &A);
35833583

35843584
/// See AbstractAttribute::getName()
3585-
const std::string getName() const override { return "AANoSync"; }
3585+
StringRef getName() const override { return "AANoSync"; }
35863586

35873587
/// See AbstractAttribute::getIdAddr()
35883588
const char *getIdAddr() const override { return &ID; }
@@ -3623,7 +3623,7 @@ struct AAMustProgress
36233623
Attributor &A);
36243624

36253625
/// See AbstractAttribute::getName()
3626-
const std::string getName() const override { return "AAMustProgress"; }
3626+
StringRef getName() const override { return "AAMustProgress"; }
36273627

36283628
/// See AbstractAttribute::getIdAddr()
36293629
const char *getIdAddr() const override { return &ID; }
@@ -3675,7 +3675,7 @@ struct AANonNull
36753675
static AANonNull &createForPosition(const IRPosition &IRP, Attributor &A);
36763676

36773677
/// See AbstractAttribute::getName()
3678-
const std::string getName() const override { return "AANonNull"; }
3678+
StringRef getName() const override { return "AANonNull"; }
36793679

36803680
/// See AbstractAttribute::getIdAddr()
36813681
const char *getIdAddr() const override { return &ID; }
@@ -3706,7 +3706,7 @@ struct AANoRecurse
37063706
static AANoRecurse &createForPosition(const IRPosition &IRP, Attributor &A);
37073707

37083708
/// See AbstractAttribute::getName()
3709-
const std::string getName() const override { return "AANoRecurse"; }
3709+
StringRef getName() const override { return "AANoRecurse"; }
37103710

37113711
/// See AbstractAttribute::getIdAddr()
37123712
const char *getIdAddr() const override { return &ID; }
@@ -3770,7 +3770,7 @@ struct AAWillReturn
37703770
static AAWillReturn &createForPosition(const IRPosition &IRP, Attributor &A);
37713771

37723772
/// See AbstractAttribute::getName()
3773-
const std::string getName() const override { return "AAWillReturn"; }
3773+
StringRef getName() const override { return "AAWillReturn"; }
37743774

37753775
/// See AbstractAttribute::getIdAddr()
37763776
const char *getIdAddr() const override { return &ID; }
@@ -3807,7 +3807,7 @@ struct AAUndefinedBehavior
38073807
Attributor &A);
38083808

38093809
/// See AbstractAttribute::getName()
3810-
const std::string getName() const override { return "AAUndefinedBehavior"; }
3810+
StringRef getName() const override { return "AAUndefinedBehavior"; }
38113811

38123812
/// See AbstractAttribute::getIdAddr()
38133813
const char *getIdAddr() const override { return &ID; }
@@ -3840,7 +3840,7 @@ struct AAIntraFnReachability
38403840
Attributor &A);
38413841

38423842
/// See AbstractAttribute::getName()
3843-
const std::string getName() const override { return "AAIntraFnReachability"; }
3843+
StringRef getName() const override { return "AAIntraFnReachability"; }
38443844

38453845
/// See AbstractAttribute::getIdAddr()
38463846
const char *getIdAddr() const override { return &ID; }
@@ -3887,7 +3887,7 @@ struct AANoAlias
38873887
static AANoAlias &createForPosition(const IRPosition &IRP, Attributor &A);
38883888

38893889
/// See AbstractAttribute::getName()
3890-
const std::string getName() const override { return "AANoAlias"; }
3890+
StringRef getName() const override { return "AANoAlias"; }
38913891

38923892
/// See AbstractAttribute::getIdAddr()
38933893
const char *getIdAddr() const override { return &ID; }
@@ -3937,7 +3937,7 @@ struct AANoFree
39373937
static AANoFree &createForPosition(const IRPosition &IRP, Attributor &A);
39383938

39393939
/// See AbstractAttribute::getName()
3940-
const std::string getName() const override { return "AANoFree"; }
3940+
StringRef getName() const override { return "AANoFree"; }
39413941

39423942
/// See AbstractAttribute::getIdAddr()
39433943
const char *getIdAddr() const override { return &ID; }
@@ -3968,7 +3968,7 @@ struct AANoReturn
39683968
static AANoReturn &createForPosition(const IRPosition &IRP, Attributor &A);
39693969

39703970
/// See AbstractAttribute::getName()
3971-
const std::string getName() const override { return "AANoReturn"; }
3971+
StringRef getName() const override { return "AANoReturn"; }
39723972

39733973
/// See AbstractAttribute::getIdAddr()
39743974
const char *getIdAddr() const override { return &ID; }
@@ -4063,7 +4063,7 @@ struct AAIsDead
40634063
}
40644064

40654065
/// See AbstractAttribute::getName()
4066-
const std::string getName() const override { return "AAIsDead"; }
4066+
StringRef getName() const override { return "AAIsDead"; }
40674067

40684068
/// See AbstractAttribute::getIdAddr()
40694069
const char *getIdAddr() const override { return &ID; }
@@ -4259,7 +4259,7 @@ struct AADereferenceable
42594259
Attributor &A);
42604260

42614261
/// See AbstractAttribute::getName()
4262-
const std::string getName() const override { return "AADereferenceable"; }
4262+
StringRef getName() const override { return "AADereferenceable"; }
42634263

42644264
/// See AbstractAttribute::getIdAddr()
42654265
const char *getIdAddr() const override { return &ID; }
@@ -4297,7 +4297,7 @@ struct AAAlign
42974297
Align getKnownAlign() const { return Align(getKnown()); }
42984298

42994299
/// See AbstractAttribute::getName()
4300-
const std::string getName() const override { return "AAAlign"; }
4300+
StringRef getName() const override { return "AAAlign"; }
43014301

43024302
/// See AbstractAttribute::getIdAddr()
43034303
const char *getIdAddr() const override { return &ID; }
@@ -4339,7 +4339,7 @@ struct AAInstanceInfo : public StateWrapper<BooleanState, AbstractAttribute> {
43394339
Attributor &A);
43404340

43414341
/// See AbstractAttribute::getName()
4342-
const std::string getName() const override { return "AAInstanceInfo"; }
4342+
StringRef getName() const override { return "AAInstanceInfo"; }
43434343

43444344
/// See AbstractAttribute::getIdAddr()
43454345
const char *getIdAddr() const override { return &ID; }
@@ -4421,7 +4421,7 @@ struct AANoCapture
44214421
static AANoCapture &createForPosition(const IRPosition &IRP, Attributor &A);
44224422

44234423
/// See AbstractAttribute::getName()
4424-
const std::string getName() const override { return "AANoCapture"; }
4424+
StringRef getName() const override { return "AANoCapture"; }
44254425

44264426
/// See AbstractAttribute::getIdAddr()
44274427
const char *getIdAddr() const override { return &ID; }
@@ -4521,7 +4521,7 @@ struct AAValueSimplify
45214521
Attributor &A);
45224522

45234523
/// See AbstractAttribute::getName()
4524-
const std::string getName() const override { return "AAValueSimplify"; }
4524+
StringRef getName() const override { return "AAValueSimplify"; }
45254525

45264526
/// See AbstractAttribute::getIdAddr()
45274527
const char *getIdAddr() const override { return &ID; }
@@ -4562,7 +4562,7 @@ struct AAHeapToStack : public StateWrapper<BooleanState, AbstractAttribute> {
45624562
static AAHeapToStack &createForPosition(const IRPosition &IRP, Attributor &A);
45634563

45644564
/// See AbstractAttribute::getName()
4565-
const std::string getName() const override { return "AAHeapToStack"; }
4565+
StringRef getName() const override { return "AAHeapToStack"; }
45664566

45674567
/// See AbstractAttribute::getIdAddr()
45684568
const char *getIdAddr() const override { return &ID; }
@@ -4617,7 +4617,7 @@ struct AAPrivatizablePtr
46174617
Attributor &A);
46184618

46194619
/// See AbstractAttribute::getName()
4620-
const std::string getName() const override { return "AAPrivatizablePtr"; }
4620+
StringRef getName() const override { return "AAPrivatizablePtr"; }
46214621

46224622
/// See AbstractAttribute::getIdAddr()
46234623
const char *getIdAddr() const override { return &ID; }
@@ -4691,7 +4691,7 @@ struct AAMemoryBehavior
46914691
Attributor &A);
46924692

46934693
/// See AbstractAttribute::getName()
4694-
const std::string getName() const override { return "AAMemoryBehavior"; }
4694+
StringRef getName() const override { return "AAMemoryBehavior"; }
46954695

46964696
/// See AbstractAttribute::getIdAddr()
46974697
const char *getIdAddr() const override { return &ID; }
@@ -4876,7 +4876,7 @@ struct AAMemoryLocation
48764876
}
48774877

48784878
/// See AbstractAttribute::getName()
4879-
const std::string getName() const override { return "AAMemoryLocation"; }
4879+
StringRef getName() const override { return "AAMemoryLocation"; }
48804880

48814881
/// See AbstractAttribute::getIdAddr()
48824882
const char *getIdAddr() const override { return &ID; }
@@ -4944,7 +4944,7 @@ struct AAValueConstantRange
49444944
}
49454945

49464946
/// See AbstractAttribute::getName()
4947-
const std::string getName() const override { return "AAValueConstantRange"; }
4947+
StringRef getName() const override { return "AAValueConstantRange"; }
49484948

49494949
/// See AbstractAttribute::getIdAddr()
49504950
const char *getIdAddr() const override { return &ID; }
@@ -5296,9 +5296,7 @@ struct AAPotentialConstantValues
52965296
}
52975297

52985298
/// See AbstractAttribute::getName()
5299-
const std::string getName() const override {
5300-
return "AAPotentialConstantValues";
5301-
}
5299+
StringRef getName() const override { return "AAPotentialConstantValues"; }
53025300

53035301
/// See AbstractAttribute::getIdAddr()
53045302
const char *getIdAddr() const override { return &ID; }
@@ -5335,7 +5333,7 @@ struct AAPotentialValues
53355333
SmallVectorImpl<AA::ValueAndContext> &Values);
53365334

53375335
/// See AbstractAttribute::getName()
5338-
const std::string getName() const override { return "AAPotentialValues"; }
5336+
StringRef getName() const override { return "AAPotentialValues"; }
53395337

53405338
/// See AbstractAttribute::getIdAddr()
53415339
const char *getIdAddr() const override { return &ID; }
@@ -5385,7 +5383,7 @@ struct AANoUndef
53855383
static AANoUndef &createForPosition(const IRPosition &IRP, Attributor &A);
53865384

53875385
/// See AbstractAttribute::getName()
5388-
const std::string getName() const override { return "AANoUndef"; }
5386+
StringRef getName() const override { return "AANoUndef"; }
53895387

53905388
/// See AbstractAttribute::getIdAddr()
53915389
const char *getIdAddr() const override { return &ID; }
@@ -5436,7 +5434,7 @@ struct AANoFPClass
54365434
static AANoFPClass &createForPosition(const IRPosition &IRP, Attributor &A);
54375435

54385436
/// See AbstractAttribute::getName()
5439-
const std::string getName() const override { return "AANoFPClass"; }
5437+
StringRef getName() const override { return "AANoFPClass"; }
54405438

54415439
/// See AbstractAttribute::getIdAddr()
54425440
const char *getIdAddr() const override { return &ID; }
@@ -5525,7 +5523,7 @@ struct AACallEdges : public StateWrapper<BooleanState, AbstractAttribute>,
55255523
static AACallEdges &createForPosition(const IRPosition &IRP, Attributor &A);
55265524

55275525
/// See AbstractAttribute::getName()
5528-
const std::string getName() const override { return "AACallEdges"; }
5526+
StringRef getName() const override { return "AACallEdges"; }
55295527

55305528
/// See AbstractAttribute::getIdAddr()
55315529
const char *getIdAddr() const override { return &ID; }
@@ -5647,7 +5645,7 @@ struct AAExecutionDomain
56475645
Attributor &A);
56485646

56495647
/// See AbstractAttribute::getName().
5650-
const std::string getName() const override { return "AAExecutionDomain"; }
5648+
StringRef getName() const override { return "AAExecutionDomain"; }
56515649

56525650
/// See AbstractAttribute::getIdAddr().
56535651
const char *getIdAddr() const override { return &ID; }
@@ -5713,7 +5711,7 @@ struct AAInterFnReachability
57135711
Attributor &A);
57145712

57155713
/// See AbstractAttribute::getName()
5716-
const std::string getName() const override { return "AAInterFnReachability"; }
5714+
StringRef getName() const override { return "AAInterFnReachability"; }
57175715

57185716
/// See AbstractAttribute::getIdAddr()
57195717
const char *getIdAddr() const override { return &ID; }
@@ -5745,7 +5743,7 @@ struct AANonConvergent : public StateWrapper<BooleanState, AbstractAttribute> {
57455743
bool isKnownNotConvergent() const { return getKnown(); }
57465744

57475745
/// See AbstractAttribute::getName()
5748-
const std::string getName() const override { return "AANonConvergent"; }
5746+
StringRef getName() const override { return "AANonConvergent"; }
57495747

57505748
/// See AbstractAttribute::getIdAddr()
57515749
const char *getIdAddr() const override { return &ID; }
@@ -6168,7 +6166,7 @@ struct AAPointerInfo : public AbstractAttribute {
61686166
static AAPointerInfo &createForPosition(const IRPosition &IRP, Attributor &A);
61696167

61706168
/// See AbstractAttribute::getName()
6171-
const std::string getName() const override { return "AAPointerInfo"; }
6169+
StringRef getName() const override { return "AAPointerInfo"; }
61726170

61736171
/// See AbstractAttribute::getIdAddr()
61746172
const char *getIdAddr() const override { return &ID; }
@@ -6234,7 +6232,7 @@ struct AAAssumptionInfo
62346232
Attributor &A);
62356233

62366234
/// See AbstractAttribute::getName()
6237-
const std::string getName() const override { return "AAAssumptionInfo"; }
6235+
StringRef getName() const override { return "AAAssumptionInfo"; }
62386236

62396237
/// See AbstractAttribute::getIdAddr()
62406238
const char *getIdAddr() const override { return &ID; }
@@ -6268,7 +6266,7 @@ struct AAUnderlyingObjects : AbstractAttribute {
62686266
Attributor &A);
62696267

62706268
/// See AbstractAttribute::getName()
6271-
const std::string getName() const override { return "AAUnderlyingObjects"; }
6269+
StringRef getName() const override { return "AAUnderlyingObjects"; }
62726270

62736271
/// See AbstractAttribute::getIdAddr()
62746272
const char *getIdAddr() const override { return &ID; }
@@ -6316,7 +6314,7 @@ struct AAAddressSpace : public StateWrapper<BooleanState, AbstractAttribute> {
63166314
Attributor &A);
63176315

63186316
/// See AbstractAttribute::getName()
6319-
const std::string getName() const override { return "AAAddressSpace"; }
6317+
StringRef getName() const override { return "AAAddressSpace"; }
63206318

63216319
/// See AbstractAttribute::getIdAddr()
63226320
const char *getIdAddr() const override { return &ID; }
@@ -6353,7 +6351,7 @@ struct AAAllocationInfo : public StateWrapper<BooleanState, AbstractAttribute> {
63536351
virtual std::optional<TypeSize> getAllocatedSize() const = 0;
63546352

63556353
/// See AbstractAttribute::getName()
6356-
const std::string getName() const override { return "AAAllocationInfo"; }
6354+
StringRef getName() const override { return "AAAllocationInfo"; }
63576355

63586356
/// See AbstractAttribute::getIdAddr()
63596357
const char *getIdAddr() const override { return &ID; }
@@ -6394,7 +6392,7 @@ struct AAGlobalValueInfo
63946392
virtual bool isPotentialUse(const Use &U) const = 0;
63956393

63966394
/// See AbstractAttribute::getName()
6397-
const std::string getName() const override { return "AAGlobalValueInfo"; }
6395+
StringRef getName() const override { return "AAGlobalValueInfo"; }
63986396

63996397
/// See AbstractAttribute::getIdAddr()
64006398
const char *getIdAddr() const override { return &ID; }
@@ -6433,7 +6431,7 @@ struct AAIndirectCallInfo
64336431
virtual bool foreachCallee(function_ref<bool(Function *)> CB) const = 0;
64346432

64356433
/// See AbstractAttribute::getName()
6436-
const std::string getName() const override { return "AAIndirectCallInfo"; }
6434+
StringRef getName() const override { return "AAIndirectCallInfo"; }
64376435

64386436
/// See AbstractAttribute::getIdAddr()
64396437
const char *getIdAddr() const override { return &ID; }
@@ -6463,7 +6461,7 @@ struct AADenormalFPMath
64636461
Attributor &A);
64646462

64656463
/// See AbstractAttribute::getName()
6466-
const std::string getName() const override { return "AADenormalFPMath"; }
6464+
StringRef getName() const override { return "AADenormalFPMath"; }
64676465

64686466
/// See AbstractAttribute::getIdAddr()
64696467
const char *getIdAddr() const override { return &ID; }

0 commit comments

Comments
 (0)