Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libcxx] improves diagnostics for containers with bad value types #106296

Open
wants to merge 31 commits into
base: main
Choose a base branch
from

Commits on Aug 27, 2024

  1. [libcxx] improves diagnostics for containers with bad value types

    `std::vector<int&>` generates nearly 170 lines of diagnostic, most of
    which are redundant, and it's only helpful if you are already familiar
    with the rule that containers can't hold reference types. This commit
    reduces it to only a handful of lines, all of which are dedicated to
    clearly communicating the problem. It also applies this to all the
    other containers, and for all non-cv-qualified and non-object types.
    
    These static_asserts are placed at the very top of each container
    because they short-circuit further instantiation errors, thereby
    leading a smaller set of diagnostics for the programmer. Placing them
    in `std::allocator` (which is the common denominator for all containers)
    doesn't do the short circuiting, and we thus end up with several
    unhelpful diagnostics after the helpful one.
    
    This commit only cleans up things that are already diagnosed as
    compile-time errors. In particular, `map<int&&, int>` should be
    ill-formed, per [associative.reqmts.general]/p8. libc++ and libstdc++
    currently permit that, but not `map<int&, int>`. As such, this
    commit only adds a static assert for `map<K&, V>`, and defers diagnosing
    valid productions that should be ill-formed to a future commit.
    cjdb committed Aug 27, 2024
    Configuration menu
    Copy the full SHA
    5529499 View commit details
    Browse the repository at this point in the history

Commits on Aug 29, 2024

  1. Configuration menu
    Copy the full SHA
    1e6b81b View commit details
    Browse the repository at this point in the history
  2. formats files

    cjdb committed Aug 29, 2024
    Configuration menu
    Copy the full SHA
    6c1e1e3 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    938299d View commit details
    Browse the repository at this point in the history
  4. more include sorting

    cjdb committed Aug 29, 2024
    Configuration menu
    Copy the full SHA
    65346a3 View commit details
    Browse the repository at this point in the history
  5. more formatting, with a successful git clang-format

    I think the best way to enact `git clang-format` might be to use `git
    clang-format <hash-before-your-commit-first>` instead of `git
    clang-format HEAD~n`. This ensures that all commits in a PR are
    formatted, instead of just the last n (which one might miscount, like I
    probably did).
    cjdb committed Aug 29, 2024
    Configuration menu
    Copy the full SHA
    472ffcf View commit details
    Browse the repository at this point in the history
  6. excludes <array> test from C++03

    cjdb committed Aug 29, 2024
    Configuration menu
    Copy the full SHA
    7596a2e View commit details
    Browse the repository at this point in the history
  7. suppresses irrelevant diagnostic

    cjdb committed Aug 29, 2024
    Configuration menu
    Copy the full SHA
    25e999f View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    5a1b902 View commit details
    Browse the repository at this point in the history
  9. applies Louis' request

    cjdb committed Aug 29, 2024
    Configuration menu
    Copy the full SHA
    99a4509 View commit details
    Browse the repository at this point in the history
  10. finally gets git-clang-format on side

    The trick is to run
    
    ```
    $ git-clang-format --diff <base-hash> --extensions ,cpp,h | patch -p1
    ```
    cjdb committed Aug 29, 2024
    Configuration menu
    Copy the full SHA
    45c85d6 View commit details
    Browse the repository at this point in the history

Commits on Sep 3, 2024

  1. unifies the containers' diagnostics

    A Clang pragma that lets us "hide" macro expansion from diagnostics so
    that users don't need to read implementation details would be a good
    thing to explore in the future.
    cjdb committed Sep 3, 2024
    Configuration menu
    Copy the full SHA
    dbf872a View commit details
    Browse the repository at this point in the history
  2. Update libcxx/include/__type_traits/diagnostic_utilities.h

    Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
    cjdb and ldionne committed Sep 3, 2024
    Configuration menu
    Copy the full SHA
    e596964 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    e2d65c0 View commit details
    Browse the repository at this point in the history
  4. applies clang-format

    cjdb committed Sep 3, 2024
    Configuration menu
    Copy the full SHA
    0487281 View commit details
    Browse the repository at this point in the history
  5. changes using is_array to is_bounded_array

    `std::llocator` apparently supports unbounded arrays prior to C++20, so
    we need to change the `is_array` check to only check for bounded arrays.
    cjdb committed Sep 3, 2024
    Configuration menu
    Copy the full SHA
    6d9ce9e View commit details
    Browse the repository at this point in the history

Commits on Sep 6, 2024

  1. reduces the number of trait instantiations

    Nikolas pointed out that checking all the traits in all cases will
    probably grind builds to a halt as we improve our diagnostics, so this
    commit makes a point of reducing the number of instantiations as much as
    possible, and preserves the highly specific messages.
    cjdb committed Sep 6, 2024
    Configuration menu
    Copy the full SHA
    c49b7e8 View commit details
    Browse the repository at this point in the history
  2. removes commented out code

    cjdb committed Sep 6, 2024
    Configuration menu
    Copy the full SHA
    eb2fd68 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    55a2e7a View commit details
    Browse the repository at this point in the history
  4. post-sync clang-format

    cjdb committed Sep 6, 2024
    Configuration menu
    Copy the full SHA
    d9043c4 View commit details
    Browse the repository at this point in the history
  5. responds to red CI

    cjdb committed Sep 6, 2024
    Configuration menu
    Copy the full SHA
    ab41024 View commit details
    Browse the repository at this point in the history
  6. responds to red CI

    cjdb committed Sep 6, 2024
    Configuration menu
    Copy the full SHA
    7bd03b3 View commit details
    Browse the repository at this point in the history
  7. responds to red CI

    cjdb committed Sep 6, 2024
    Configuration menu
    Copy the full SHA
    ef9d9c3 View commit details
    Browse the repository at this point in the history

Commits on Sep 7, 2024

  1. responds to red CI

    cjdb committed Sep 7, 2024
    Configuration menu
    Copy the full SHA
    f0f88d7 View commit details
    Browse the repository at this point in the history
  2. replaces TODOs

    cjdb committed Sep 7, 2024
    Configuration menu
    Copy the full SHA
    bb82c95 View commit details
    Browse the repository at this point in the history

Commits on Sep 8, 2024

  1. Revert "replaces TODOs"

    This reverts commit bb82c95.
    cjdb committed Sep 8, 2024
    Configuration menu
    Copy the full SHA
    33a452d View commit details
    Browse the repository at this point in the history

Commits on Sep 9, 2024

  1. Update libcxx/include/__type_traits/diagnostic_utilities.h

    Co-authored-by: Nikolas Klauser <nikolasklauser@berlin.de>
    cjdb and philnik777 committed Sep 9, 2024
    Configuration menu
    Copy the full SHA
    6981a2a View commit details
    Browse the repository at this point in the history
  2. Update libcxx/include/__type_traits/diagnostic_utilities.h

    Co-authored-by: Nikolas Klauser <nikolasklauser@berlin.de>
    cjdb and philnik777 committed Sep 9, 2024
    Configuration menu
    Copy the full SHA
    9fe3f4a View commit details
    Browse the repository at this point in the history

Commits on Sep 10, 2024

  1. Configuration menu
    Copy the full SHA
    b97942e View commit details
    Browse the repository at this point in the history

Commits on Sep 11, 2024

  1. fixes asan diagnostic

    cjdb committed Sep 11, 2024
    Configuration menu
    Copy the full SHA
    02ffa16 View commit details
    Browse the repository at this point in the history

Commits on Sep 16, 2024

  1. Configuration menu
    Copy the full SHA
    f75d1ae View commit details
    Browse the repository at this point in the history