_CheckUniquePtr presubmit does not handle well custom deleters |
|||
Issue descriptionThe following code currently issues a presubmit error: auto p = std::unique_ptr<T, D>(new T(), D()); ...suggesting that std::make_unique should be used, but std::make_unique doesn't support deleters, and neither does base::WrapUnique(). Specifically, I'd trying to use base::OnTaskRunnerDeleter. Perhaps WrapUnique() should be extended, but that seems orthogonal and a longer shot (absl also doesn't support that).
,
Jul 26
Same story :)
,
Aug 28
Back from vacation, https://crrev.com/c/1193945
,
Aug 30
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/b7fadb6925ab81a27cf6718e78759cdb1a9cd1cb commit b7fadb6925ab81a27cf6718e78759cdb1a9cd1cb Author: Vaclav Brozek <vabr@chromium.org> Date: Thu Aug 30 06:39:53 2018 Allow std::unique_ptr<T, D>(...) in presubmit The _CheckUniquePtr presubmit check has the following false-positive: it flags auto p = std::unique_ptr<T, D>(new T(), D()); as needing a rewrite using std::make_unique. However, there seems to be no way to pass the second template argument to std::make_unique, so cases like this need to be exempt from the presubmit check. Note that the check still needs to capture cases with count the nesting of the angle brackets. Hence, this check cannot be captured by a regular expression and needs just a counting loop. std: :unique_ptr<T<U, V>>, so when looking for the comma, one has to Bug: 867823 Change-Id: Ie21067fa83aae17dd6701b0f69b902605c797e67 Reviewed-on: https://chromium-review.googlesource.com/1193945 Commit-Queue: Vaclav Brozek <vabr@chromium.org> Reviewed-by: Dirk Pranke <dpranke@chromium.org> Cr-Commit-Position: refs/heads/master@{#587463} [modify] https://crrev.com/b7fadb6925ab81a27cf6718e78759cdb1a9cd1cb/PRESUBMIT.py [modify] https://crrev.com/b7fadb6925ab81a27cf6718e78759cdb1a9cd1cb/PRESUBMIT_test.py
,
Aug 30
r587463 says: Have fun using custom deleters without presubmit alarms! :) |
|||
►
Sign in to add a comment |
|||
Comment 1 by vabr@chromium.org
, Jul 26