llvm/llvm-project

llvm/lib/CodeGen/LiveRangeUtils.h:40: Iterators applied to wrong data structure ?

Open

#122,937 opened on 2025年1月14日

GitHub で見る
 (8 comments) (0 reactions) (2 assignees)C++ (10,782 forks)batch import
code-qualitygood first issuellvm:codegen

Repository metrics

Stars
 (26,378 stars)
PR merge metrics
 (平均マージ 1d 2h) (30d で 1,000 merged PRs)

説明

Static analyser cppcheck says:

llvm/lib/CodeGen/LiveRangeUtils.h:40:6: error: Same iterator is used with different containers 'LR' and 'LR.segments'. [iterators1]

Source code is

typename LiveRangeT::iterator J = LR.begin(), E = LR.end(); // ... LR.segments.erase(J, E);

So J and E are iterators for LR, but get used on LR.segments.

I am surprised this compiles.

コントリビューターガイド