[all-commits] [llvm/llvm-project] 70d94c: [libc++] __bit_iterator mustn't rely on deprecated...

Quuxplusone via All-commits all-commits at lists.llvm.org
Mon Apr 26 13:23:43 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 70d94c3f2cae71ade2ceacdceb3d2e9899d2289a
      https://github.com/llvm/llvm-project/commit/70d94c3f2cae71ade2ceacdceb3d2e9899d2289a
  Author: Arthur O'Dwyer <arthur.j.odwyer at gmail.com>
  Date:   2021-04-26 (Mon, 26 Apr 2021)

  Changed paths:
    M libcxx/include/__bit_reference
    M libcxx/utils/libcxx/test/params.py

  Log Message:
  -----------
  [libc++] __bit_iterator mustn't rely on deprecated SMF generation.

This allows us to turn -Wdeprecated-copy back on. We turned it off
in 3b71de41cc7c7 because Clang's implementation became more stringent
and started diagnosing the old code here.

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


  Commit: e87479b00fcc852a54b79d2fd7f8d779e2b75f68
      https://github.com/llvm/llvm-project/commit/e87479b00fcc852a54b79d2fd7f8d779e2b75f68
  Author: Arthur O'Dwyer <arthur.j.odwyer at gmail.com>
  Date:   2021-04-26 (Mon, 26 Apr 2021)

  Changed paths:
    M libcxx/include/filesystem
    M libcxx/include/iterator
    M libcxx/include/string
    R libcxx/test/libcxx/iterators/trivial_iterators.pass.cpp
    R libcxx/test/libcxx/strings/iterators.exceptions.pass.cpp
    R libcxx/test/libcxx/strings/iterators.noexcept.pass.cpp
    A libcxx/test/std/strings/basic.string/string.modifiers/robust_against_adl.pass.cpp
    M libcxx/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp
    M libcxx/test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp
    M libcxx/test/std/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp
    M libcxx/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_iter_iter.pass.cpp

  Log Message:
  -----------
  [libc++] Remove the special logic for "noexcept iterators" in basic_string.

This reverts a large chunk of http://reviews.llvm.org/D15862 ,
and also fixes bugs in `insert`, `append`, and `assign`, which are now regression-tested.
(Thanks to Tim Song for pointing out the bug in `append`!)

Before this patch, we did a special dance in `append`, `assign`, and `insert`
(but not `replace`). All of these require the strong exception guarantee,
even when the user-provided InputIterator might have throwing operations.

The naive way to accomplish this is to construct a temporary string and
then append/assign/insert from the temporary; i.e., finish all the potentially
throwing and self-inspecting InputIterator operations *before* starting to
modify self. But this is slow, so we'd like to skip it when possible.

The old code (D15682) attempted to check that specific iterator operations
were nothrow: it assumed that if the iterator operations didn't throw, then
it was safe to iterate the input range multiple times and therefore it was
safe to use the fast-path non-naive version. This was wrong for two reasons:
(1) the old code checked the wrong operations (e.g. checked noexceptness of `==`,
but the code that ran used `!=`), and (2) the conversion of value_type to char
could still throw, or inspect the contents of self.

The new code is much simpler, although still much more complicated than it
really could be. We'll likely revisit this codepath at some point, but for now
this patch suffices to get it passing all the new regression tests.

The added tests all fail before this patch, and succeed afterward.
See https://quuxplusone.github.io/blog/2021/04/17/pathological-string-appends/

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


  Commit: 036b80fcbbccee8199851158fd349230aa77d75e
      https://github.com/llvm/llvm-project/commit/036b80fcbbccee8199851158fd349230aa77d75e
  Author: Arthur O'Dwyer <arthur.j.odwyer at gmail.com>
  Date:   2021-04-26 (Mon, 26 Apr 2021)

  Changed paths:
    M libcxx/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp
    M libcxx/test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp
    M libcxx/test/std/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp
    M libcxx/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_iter_iter.pass.cpp

  Log Message:
  -----------
  [libc++] [test] Improve test_exceptions() in each string.modifiers test.

When checking the strong exception guarantee, also check that
iterators haven't been invalidated.

Reviewed as part of https://reviews.llvm.org/D98573


  Commit: 0fcb898f10267dc132609eee3730ace4b3b40670
      https://github.com/llvm/llvm-project/commit/0fcb898f10267dc132609eee3730ace4b3b40670
  Author: Arthur O'Dwyer <arthur.j.odwyer at gmail.com>
  Date:   2021-04-26 (Mon, 26 Apr 2021)

  Changed paths:
    M libcxx/utils/libcxx/test/params.py

  Log Message:
  -----------
  [libc++] [test] Fix a Python warning.

params.py:106: SyntaxWarning: "is" with a literal. Did you mean "=="?


Compare: https://github.com/llvm/llvm-project/compare/5529878f8ec6...0fcb898f1026


More information about the All-commits mailing list