Skip to content

Commit d1a4791

Browse files
authored
[Clang][TableGen] Use const pointers for various Init * pointers in SA checker emitter (#112321)
Use const pointers for various Init objects in SA checker emitter. This is a part of effort to have better const correctness in TableGen backends: https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089
1 parent 2a46e5d commit d1a4791

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

clang/utils/TableGen/ClangSACheckersEmitter.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static std::string getPackageFullName(const Record *R, StringRef Sep = ".");
2929
static std::string getParentPackageFullName(const Record *R,
3030
StringRef Sep = ".") {
3131
std::string name;
32-
if (DefInit *DI = dyn_cast<DefInit>(R->getValueInit("ParentPackage")))
32+
if (const DefInit *DI = dyn_cast<DefInit>(R->getValueInit("ParentPackage")))
3333
name = getPackageFullName(DI->getDef(), Sep);
3434
return name;
3535
}
@@ -53,7 +53,7 @@ static std::string getCheckerFullName(const Record *R, StringRef Sep = ".") {
5353
}
5454

5555
static std::string getStringValue(const Record &R, StringRef field) {
56-
if (StringInit *SI = dyn_cast<StringInit>(R.getValueInit(field)))
56+
if (const StringInit *SI = dyn_cast<StringInit>(R.getValueInit(field)))
5757
return std::string(SI->getValue());
5858
return std::string();
5959
}
@@ -94,7 +94,7 @@ static std::string getCheckerDocs(const Record &R) {
9494
/// the class itself has to be modified for adding a new option type in
9595
/// CheckerBase.td.
9696
static std::string getCheckerOptionType(const Record &R) {
97-
if (BitsInit *BI = R.getValueAsBitsInit("Type")) {
97+
if (const BitsInit *BI = R.getValueAsBitsInit("Type")) {
9898
switch(getValueFromBitsInit(BI, R)) {
9999
case 0:
100100
return "int";
@@ -111,7 +111,7 @@ static std::string getCheckerOptionType(const Record &R) {
111111
}
112112

113113
static std::string getDevelopmentStage(const Record &R) {
114-
if (BitsInit *BI = R.getValueAsBitsInit("DevelopmentStage")) {
114+
if (const BitsInit *BI = R.getValueAsBitsInit("DevelopmentStage")) {
115115
switch(getValueFromBitsInit(BI, R)) {
116116
case 0:
117117
return "alpha";
@@ -131,7 +131,7 @@ static bool isHidden(const Record *R) {
131131
return true;
132132

133133
// Not declared as hidden, check the parent package if it is hidden.
134-
if (DefInit *DI = dyn_cast<DefInit>(R->getValueInit("ParentPackage")))
134+
if (const DefInit *DI = dyn_cast<DefInit>(R->getValueInit("ParentPackage")))
135135
return isHidden(DI->getDef());
136136

137137
return false;

0 commit comments

Comments
 (0)