https://bugs.llvm.org/show_bug.cgi?id=46565

            Bug ID: 46565
           Summary: -Wrange-loop-analysis for algorithms
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangb...@nondot.org
          Reporter: tras...@gmail.com
                CC: htmldevelo...@gmail.com, llvm-bugs@lists.llvm.org,
                    neeil...@live.com, richard-l...@metafoo.co.uk

using Map = std::map<int, std::vector<std::string>>;
void wrong1(const Map& m)
{
    for (const std::pair<int, std::vector<std::string>>& p : m)
    {}
}
void wrong2(const Map& m)
{
    std::for_each(m.begin(), m.end(), [](const std::pair<int,
std::vector<std::string>> p){
    });
}

The warning catches the first case but not the second:
https://godbolt.org/z/E-LCJV
If that analysis is not too expensive it could also warn about iteration done
by various algorithms.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to