Skip to content

[Clang][TableGen] Use const pointers for various Init objects in Diagnostic Emitter #112318

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ getCategoryFromDiagGroup(const Record *Group,
static std::string getDiagnosticCategory(const Record *R,
DiagGroupParentMap &DiagGroupParents) {
// If the diagnostic is in a group, and that group has a category, use it.
if (DefInit *Group = dyn_cast<DefInit>(R->getValueInit("Group"))) {
if (const auto *Group = dyn_cast<DefInit>(R->getValueInit("Group"))) {
// Check the diagnostic's diag group for a category.
std::string CatName = getCategoryFromDiagGroup(Group->getDef(),
DiagGroupParents);
Expand Down Expand Up @@ -161,7 +161,7 @@ static void groupDiagnostics(ArrayRef<const Record *> Diags,

for (unsigned i = 0, e = Diags.size(); i != e; ++i) {
const Record *R = Diags[i];
DefInit *DI = dyn_cast<DefInit>(R->getValueInit("Group"));
const auto *DI = dyn_cast<DefInit>(R->getValueInit("Group"));
if (!DI)
continue;
assert(R->getValueAsDef("Class")->getName() != "CLASS_NOTE" &&
Expand Down Expand Up @@ -359,7 +359,7 @@ void InferPedantic::compute(VecOrSet DiagsInPedantic,
const Record *R = Diags[i];
if (isExtension(R) && isOffByDefault(R)) {
DiagsSet.insert(R);
if (DefInit *Group = dyn_cast<DefInit>(R->getValueInit("Group"))) {
if (const auto *Group = dyn_cast<DefInit>(R->getValueInit("Group"))) {
const Record *GroupRec = Group->getDef();
if (!isSubGroupOfGroup(GroupRec, "pedantic")) {
markGroup(GroupRec);
Expand All @@ -378,13 +378,13 @@ void InferPedantic::compute(VecOrSet DiagsInPedantic,
// Check if the group is implicitly in -Wpedantic. If so,
// the diagnostic should not be directly included in the -Wpedantic
// diagnostic group.
if (DefInit *Group = dyn_cast<DefInit>(R->getValueInit("Group")))
if (const auto *Group = dyn_cast<DefInit>(R->getValueInit("Group")))
if (groupInPedantic(Group->getDef()))
continue;

// The diagnostic is not included in a group that is (transitively) in
// -Wpedantic. Include it in -Wpedantic directly.
if (RecordVec *V = DiagsInPedantic.dyn_cast<RecordVec*>())
if (auto *V = DiagsInPedantic.dyn_cast<RecordVec *>())
V->push_back(R);
else {
DiagsInPedantic.get<RecordSet*>()->insert(R);
Expand Down Expand Up @@ -413,7 +413,7 @@ void InferPedantic::compute(VecOrSet DiagsInPedantic,
if (Parents.size() > 0 && AllParentsInPedantic)
continue;

if (RecordVec *V = GroupsInPedantic.dyn_cast<RecordVec*>())
if (auto *V = GroupsInPedantic.dyn_cast<RecordVec *>())
V->push_back(Group);
else {
GroupsInPedantic.get<RecordSet*>()->insert(Group);
Expand Down Expand Up @@ -1443,7 +1443,7 @@ void clang::EmitClangDiagsDefs(const RecordKeeper &Records, raw_ostream &OS,
// Check if this is an error that is accidentally in a warning
// group.
if (isError(R)) {
if (DefInit *Group = dyn_cast<DefInit>(R.getValueInit("Group"))) {
if (const auto *Group = dyn_cast<DefInit>(R.getValueInit("Group"))) {
const Record *GroupRec = Group->getDef();
const std::string &GroupName =
std::string(GroupRec->getValueAsString("GroupName"));
Expand Down Expand Up @@ -1478,7 +1478,7 @@ void clang::EmitClangDiagsDefs(const RecordKeeper &Records, raw_ostream &OS,

// Warning group associated with the diagnostic. This is stored as an index
// into the alphabetically sorted warning group table.
if (DefInit *DI = dyn_cast<DefInit>(R.getValueInit("Group"))) {
if (const auto *DI = dyn_cast<DefInit>(R.getValueInit("Group"))) {
std::map<std::string, GroupInfo>::iterator I = DiagsInGroup.find(
std::string(DI->getDef()->getValueAsString("GroupName")));
assert(I != DiagsInGroup.end());
Expand Down
Loading