From 146ef7a5f44af68e969dfb66918ae49810864aec Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Tue, 11 Mar 2025 09:21:10 -0700 Subject: [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. --- llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp') diff --git a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp index 59148a9..ed3ec92 100644 --- a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp +++ b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp @@ -4139,23 +4139,19 @@ void CodeGenDAGPatterns::InferInstructionFlags() { // If requested by the target, guess any undefined properties. if (Target.guessInstructionProperties()) { - for (unsigned i = 0, e = Instructions.size(); i != e; ++i) { - CodeGenInstruction *InstInfo = - const_cast(Instructions[i]); + for (const CodeGenInstruction *InstInfo : Instructions) { if (InstInfo->InferredFrom) continue; // The mayLoad and mayStore flags default to false. // Conservatively assume hasSideEffects if it wasn't explicit. if (InstInfo->hasSideEffects_Unset) - InstInfo->hasSideEffects = true; + const_cast(InstInfo)->hasSideEffects = true; } return; } // Complain about any flags that are still undefined. - for (unsigned i = 0, e = Instructions.size(); i != e; ++i) { - CodeGenInstruction *InstInfo = - const_cast(Instructions[i]); + for (const CodeGenInstruction *InstInfo : Instructions) { if (InstInfo->InferredFrom) continue; if (InstInfo->hasSideEffects_Unset) -- cgit v1.1