Skip to content

Commit a0b2948

Browse files
committed
Silence a warning on gcc 13
GCC 13 produced a warning that: .../llvm-dialects/lib/TableGen/Evaluator.cpp:653:31: warning: possibly dangling reference to a temporary [-Wdangling-reference] 653 | const ConstraintSystem &childSystem = logicOr->branches()[i]; | ^~~~~~~~~~~ .../llvm-dialects/lib/TableGen/Evaluator.cpp:653:66: note: the temporary was destroyed at the end of the full expression ‘logicOr->llvm_dialects::LogicOr::branches().llvm::ArrayRef<llvm_dialects::ConstraintSystem>::operator[](((size_t)i))’ 653 | const ConstraintSystem &childSystem = logicOr->branches()[i]; | ^ This warning seems wrong. The temporary ArrayRef returned by LogicOr::branches() is destroyed, yes, but the reference returned by operator[] isn't a reference into the ArrayRef itself, so it shouldn't matter. Oh well. Using a for-each loop is nicer anyway.
1 parent 93d7b5e commit a0b2948

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

lib/TableGen/Evaluator.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -643,14 +643,13 @@ bool Evaluator::checkLogicOr(bool writeErrs, const LogicOr *logicOr) {
643643
&m_fmt);
644644
}
645645

646-
for (unsigned i = 0; i < logicOr->branches().size(); ++i) {
646+
for (auto [i, childSystem] : llvm::enumerate(logicOr->branches())) {
647647
m_out << tgfmt(R"(
648648
$_errs << " failed option $0 ($1):\n";
649649
([&]() {
650650
)",
651651
&m_fmt, i, logicOr->branchInits()[i]->getAsString());
652652

653-
const ConstraintSystem &childSystem = logicOr->branches()[i];
654653
Assignment scopedAssignment{&m_assignment};
655654
Evaluator childEvaluator(*m_symbols, scopedAssignment, childSystem, m_out,
656655
m_fmt);

0 commit comments

Comments
 (0)