Skip to content

Commit 146ef7a

Browse files
authored
[TableGen] Remove unnecessary const_cast and use range-based for loops. NFC (#130717)
In order to use a range-based loop, I reduced a needed const_cast to only the one line that needed it.
1 parent 83ec179 commit 146ef7a

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4139,23 +4139,19 @@ void CodeGenDAGPatterns::InferInstructionFlags() {
41394139

41404140
// If requested by the target, guess any undefined properties.
41414141
if (Target.guessInstructionProperties()) {
4142-
for (unsigned i = 0, e = Instructions.size(); i != e; ++i) {
4143-
CodeGenInstruction *InstInfo =
4144-
const_cast<CodeGenInstruction *>(Instructions[i]);
4142+
for (const CodeGenInstruction *InstInfo : Instructions) {
41454143
if (InstInfo->InferredFrom)
41464144
continue;
41474145
// The mayLoad and mayStore flags default to false.
41484146
// Conservatively assume hasSideEffects if it wasn't explicit.
41494147
if (InstInfo->hasSideEffects_Unset)
4150-
InstInfo->hasSideEffects = true;
4148+
const_cast<CodeGenInstruction *>(InstInfo)->hasSideEffects = true;
41514149
}
41524150
return;
41534151
}
41544152

41554153
// Complain about any flags that are still undefined.
4156-
for (unsigned i = 0, e = Instructions.size(); i != e; ++i) {
4157-
CodeGenInstruction *InstInfo =
4158-
const_cast<CodeGenInstruction *>(Instructions[i]);
4154+
for (const CodeGenInstruction *InstInfo : Instructions) {
41594155
if (InstInfo->InferredFrom)
41604156
continue;
41614157
if (InstInfo->hasSideEffects_Unset)

0 commit comments

Comments
 (0)