llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.1k stars 12.01k forks source link

DenseMap and StringMap can't be used in range for under c++20 #46968

Open llvmbot opened 4 years ago

llvmbot commented 4 years ago
Bugzilla Link 47624
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor
CC @dwblaikie

Extended Description

Using llvm::DenseMap and llvm::StringMap in external projects compiled with c++20 results in error when comparing their iterators

Iterating over a const DenseMap& causes no issues. However There are issues with iterating over a non const DenseMap. With StringMap there are issues no matter what kind of reference the StringMap is.

using clang-10 as the host compiler, warnings for StringMap can be supressed with -Wno-ambiguous-reversed-operator however this has no effect on supressing the DenseMap warnings. That has been addressed in clang-11 which will suppress all these warnings

See example here https://godbolt.org/z/Keqa1n Note this is compiling with a trunk build of clang so some of these warnings could change down the line, the warnings emitted for clang-10.0.1 will stay consistent though

dwblaikie commented 4 years ago

Does this patch address the problem? https://reviews.llvm.org/D78938