llvm-project/libcxx
Eric Fiselier 292617e700 [libc++] Fix PR20855 -- libc++ incorrectly diagnoses illegal reference binding in std::tuple.
Summary:
See https://bugs.llvm.org/show_bug.cgi?id=20855

Libc++ goes out of it's way to diagnose `std::tuple` constructions which are UB due to lifetime bugs caused by reference creation. For example:

```
// The 'const std::string&' is created *inside* the tuple constructor, and its lifetime is over before the end of the constructor call.
std::tuple<int, const std::string&> t(std::make_tuple(42, "abc"));
```

However, we are over-aggressive and we incorrectly diagnose cases such as:

```
void foo(std::tuple<int const&, int const&> const&);
foo(std::make_tuple(42, 42));
```

This patch fixes the incorrectly diagnosed cases, as well as converting the diagnostic to use the newly added Clang trait `__reference_binds_to_temporary`. The new trait allows us to diagnose cases we previously couldn't such as:

```
std::tuple<int, const std::string&> t(42, "abc");
```

Reviewers: rsmith, mclow.lists

Reviewed By: rsmith

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D41977

llvm-svn: 323380
2018-01-24 22:14:01 +00:00
..
benchmarks Update Google Benchmark library 2018-01-18 04:23:01 +00:00
cmake [cmake] Always respect existing CMAKE_REQUIRED_FLAGS when adding additional ones. 2018-01-23 03:30:23 +00:00
docs [cmake] Add a config option LIBCXX_HAS_WIN32_THREAD_API for enforcing win32 threads 2018-01-05 20:48:29 +00:00
fuzzing Wrote my own version of is_permutation; that was dominating the timings 2018-01-19 03:17:45 +00:00
include [libc++] Fix PR20855 -- libc++ incorrectly diagnoses illegal reference binding in std::tuple. 2018-01-24 22:14:01 +00:00
lib [libc++] Create install-stripped targets 2017-12-06 21:03:42 +00:00
src libcxx: Rename vasprintf function to __libcpp_vasprintf. 2018-01-23 18:53:33 +00:00
test [libc++] Fix PR20855 -- libc++ incorrectly diagnoses illegal reference binding in std::tuple. 2018-01-24 22:14:01 +00:00
utils Update Google Benchmark library 2018-01-18 04:23:01 +00:00
www Update cxx2a status 2018-01-22 23:17:20 +00:00
.arcconfig [libcxx] Set up .arcconfig to point to new Diffusion CXX repository 2017-12-04 17:55:28 +00:00
.clang-format
.gitignore
CMakeLists.txt [cmake] [libcxx] Fix find_path() problems when cross compiling. 2018-01-22 19:26:38 +00:00
CREDITS.TXT Try again, this time with the correct address 2017-12-29 19:26:53 +00:00
LICENSE.TXT
NOTES.TXT
TODO.TXT
appveyor-reqs-install.cmd Update Appveyor LLVM install link to be current and non-broken 2017-11-15 01:37:11 +00:00
appveyor.yml