[PATCH] D95321: [NFC] Fixing build warning with llvm-mca
Puyan Lotfi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 24 16:12:01 PST 2021
plotfi created this revision.
plotfi added a reviewer: wolfgangp.
Herald added a subscriber: gbedwell.
Herald added a reviewer: andreadb.
plotfi requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Warning is generated because the range based for-loop is always copying by value but uses a ref &:
[4083/4581] Building CXX object tools/llvm-mca/CMakeFiles/llvm-mca.dir/Views/InstructionInfoView.cpp.o
/path/to/Projects/llvm-project/llvm/tools/llvm-mca/Views/InstructionInfoView.cpp:96:20: warning: loop variable 'I' is always a copy because the range of type 'detail::zippy<detail::zip_shortest, ArrayRef<MCInst>, MutableArrayRef<InstructionInfoViewData> &>' does not return a reference [-Wrange-loop-analysis]
for (const auto &I : zip(getSource(), IIVD)) {
^
/path/to/Projects/llvm-project/llvm/tools/llvm-mca/Views/InstructionInfoView.cpp:96:8: note: use non-reference type 'std::__1::tuple<const llvm::MCInst &, llvm::mca::InstructionInfoView::InstructionInfoViewData &>'
for (const auto &I : zip(getSource(), IIVD)) {
^~~~~~~~~~~~~~~
1 warning generated.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D95321
Files:
llvm/tools/llvm-mca/Views/InstructionInfoView.cpp
Index: llvm/tools/llvm-mca/Views/InstructionInfoView.cpp
===================================================================
--- llvm/tools/llvm-mca/Views/InstructionInfoView.cpp
+++ llvm/tools/llvm-mca/Views/InstructionInfoView.cpp
@@ -93,7 +93,7 @@
MutableArrayRef<InstructionInfoViewData> IIVD) const {
const llvm::MCSubtargetInfo &STI = getSubTargetInfo();
const MCSchedModel &SM = STI.getSchedModel();
- for (const auto &I : zip(getSource(), IIVD)) {
+ for (const auto I : zip(getSource(), IIVD)) {
const MCInst &Inst = std::get<0>(I);
InstructionInfoViewData &IIVDEntry = std::get<1>(I);
const MCInstrDesc &MCDesc = MCII.get(Inst.getOpcode());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95321.318874.patch
Type: text/x-patch
Size: 678 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210125/0efff828/attachment.bin>
More information about the llvm-commits
mailing list