Fix another false-positive of _CheckUniquePtr
The false-positive was caused by an error in matching <...> after
unique_ptr. The old expression essentially said:
<.*?>\(
The "?", making "*" non-greedy, was meant to prevent ".*" from
matching more than one <...> block.
But that does not work -- . would still match the '>' which ended the
first block and carry on until an '>(' was found, if necessary.
So in the concrete example:
std::unique_ptr<T> result = std::make_unique<T>(
what the presubmit check "though" was the the type parameter was
"T> result = std::make_unique<T", instead of just "T".
A better way to ensure matching just one <...> block was already used
in the sibling check pattern (null_construct_pattern) -- splitting the
(possibly nested) <...> block into the part containing <s and the part
containing >s (note that a regular expression cannot check that both
parts have a matching number of < and >).
This CL just adopted that better technique for the faulty pattern.
Also remove a temporary hack from webstore_provider.cc added to bypass
the failing check.
Bug: 733662, 827961
Change-Id: Ia70cc4333f8afc4d45b1f676ea1bc870f6a3a079
Reviewed-on: https://chromium-review.googlesource.com/998194
Commit-Queue: Vaclav Brozek <[email protected]>
Reviewed-by: Dirk Pranke <[email protected]>
Reviewed-by: Xiyuan Xia <[email protected]>
Cr-Commit-Position: refs/heads/master@{#548896}
diff --git a/PRESUBMIT_test.py b/PRESUBMIT_test.py
index 3b75cbe..997625b7 100755
--- a/PRESUBMIT_test.py
+++ b/PRESUBMIT_test.py
@@ -1691,6 +1691,11 @@
MockFile('dir/baz.cc', [
'std::unique_ptr<T> result = std::make_unique<T>();'
]),
+ MockFile('dir/baz2.cc', [
+ 'std::unique_ptr<T> result = std::make_unique<T>('
+ ]),
+ MockFile('dir/nested.cc', ['set<std::unique_ptr<T>>();']),
+ MockFile('dir/nested2.cc', ['map<U, std::unique_ptr<T>>();']),
]
results = PRESUBMIT._CheckUniquePtr(mock_input_api, MockOutputApi())