Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Issue 453873002: Implement rewrite logic for assigning a temporary scoped_refptr to T*. (Closed)

Created:
6 years, 4 months ago by dcheng
Modified:
6 years, 4 months ago
Reviewers:
Ryan Sleevi, mdempsky
CC:
chromium-reviews, Ryan Sleevi
Project:
chromium
Visibility:
Public.

Description

Implement rewrite logic for assigning a temporary scoped_refptr to T*. This is always potentially dangerous. For example: scoped_refptr<Foo> CreateFoo(); void BuggyFunction() { Foo* x = CreateFoo(); // x now points to a deleted object. } In these cases, the tool prefers to rewrite the declaration type to scoped_refptr<T> instead of adding an explicit conversion to T* with get(). BUG=110610 R=mdempsky@chromium.org, rsleevi@chromium.org Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=288795

Patch Set 1 #

Patch Set 2 : Minor comment update in test case #

Patch Set 3 : Skip unsafe boolean testing #

Patch Set 4 : Tighten matchers #

Total comments: 6

Patch Set 5 : rename tests, etc #

Total comments: 2

Patch Set 6 : more changes #

Unified diffs Side-by-side diffs Delta from patch set Stats (+212 lines, -119 lines) Patch
M tools/clang/rewrite_scoped_refptr/RewriteScopedRefptr.cpp View 1 2 3 4 chunks +77 lines, -26 lines 0 comments Download
A tools/clang/rewrite_scoped_refptr/tests/const-scoped_refptr&-to-raw-adds-get-expected.cc View 1 2 3 4 1 chunk +22 lines, -0 lines 0 comments Download
A tools/clang/rewrite_scoped_refptr/tests/const-scoped_refptr&-to-raw-adds-get-original.cc View 1 2 3 4 1 chunk +22 lines, -0 lines 0 comments Download
A + tools/clang/rewrite_scoped_refptr/tests/local-returned-as-raw-expected.cc View 1 2 3 4 5 1 chunk +1 line, -0 lines 0 comments Download
A + tools/clang/rewrite_scoped_refptr/tests/local-returned-as-raw-original.cc View 1 2 3 4 5 1 chunk +1 line, -0 lines 0 comments Download
A + tools/clang/rewrite_scoped_refptr/tests/temp-assigned-to-field-init-expected.cc View 1 2 3 4 1 chunk +8 lines, -5 lines 0 comments Download
A + tools/clang/rewrite_scoped_refptr/tests/temp-assigned-to-field-init-original.cc View 1 2 3 4 1 chunk +8 lines, -5 lines 0 comments Download
A + tools/clang/rewrite_scoped_refptr/tests/temp-assigned-to-raw-var-expected.cc View 1 2 3 4 5 1 chunk +1 line, -1 line 0 comments Download
A + tools/clang/rewrite_scoped_refptr/tests/temp-assigned-to-raw-var-original.cc View 1 2 3 4 0 chunks +-1 lines, --1 lines 0 comments Download
A + tools/clang/rewrite_scoped_refptr/tests/temp-bool-test-expected.cc View 1 2 3 4 5 1 chunk +5 lines, -4 lines 0 comments Download
A + tools/clang/rewrite_scoped_refptr/tests/temp-bool-test-original.cc View 1 2 3 4 5 1 chunk +5 lines, -4 lines 0 comments Download
A tools/clang/rewrite_scoped_refptr/tests/temp-passed-as-raw-arg-expected.cc View 1 2 3 4 5 1 chunk +24 lines, -0 lines 0 comments Download
A tools/clang/rewrite_scoped_refptr/tests/temp-passed-as-raw-arg-original.cc View 1 2 3 4 5 1 chunk +24 lines, -0 lines 0 comments Download
D tools/clang/rewrite_scoped_refptr/tests/test1-expected.cc View 1 2 3 4 1 chunk +0 lines, -16 lines 0 comments Download
D tools/clang/rewrite_scoped_refptr/tests/test1-original.cc View 1 2 3 4 1 chunk +0 lines, -16 lines 0 comments Download
M tools/clang/rewrite_scoped_refptr/tests/test11-expected.cc View 1 chunk +2 lines, -0 lines 0 comments Download
M tools/clang/rewrite_scoped_refptr/tests/test11-original.cc View 1 chunk +2 lines, -0 lines 0 comments Download
M tools/clang/rewrite_scoped_refptr/tests/test12-expected.cc View 1 chunk +2 lines, -1 line 0 comments Download
M tools/clang/rewrite_scoped_refptr/tests/test12-original.cc View 1 chunk +2 lines, -1 line 0 comments Download
M tools/clang/rewrite_scoped_refptr/tests/test2-expected.cc View 1 2 3 4 1 chunk +0 lines, -19 lines 0 comments Download
D tools/clang/rewrite_scoped_refptr/tests/test2-original.cc View 1 2 3 4 1 chunk +0 lines, -19 lines 0 comments Download
M tools/clang/scripts/run_tool.py View 1 2 3 4 5 2 chunks +5 lines, -1 line 0 comments Download
M tools/clang/scripts/test_tool.py View 1 2 3 4 1 chunk +2 lines, -2 lines 0 comments Download

Messages

Total messages: 8 (0 generated)
dcheng
Sorry =P
6 years, 4 months ago (2014-08-08 18:32:48 UTC) #1
mdempsky
https://codereview.chromium.org/453873002/diff/60001/tools/clang/rewrite_scoped_refptr/RewriteScopedRefptr.cpp File tools/clang/rewrite_scoped_refptr/RewriteScopedRefptr.cpp (right): https://codereview.chromium.org/453873002/diff/60001/tools/clang/rewrite_scoped_refptr/RewriteScopedRefptr.cpp#newcode214 tools/clang/rewrite_scoped_refptr/RewriteScopedRefptr.cpp:214: auto base_matcher = memberCallExpr( [Is C++11 allowed already, or ...
6 years, 4 months ago (2014-08-08 21:59:28 UTC) #2
Ryan Sleevi
Add some tests to handle "const scoped_refptr<T>&" to make sure they're handled appropriately (presumably, as ...
6 years, 4 months ago (2014-08-08 22:10:13 UTC) #3
dcheng
While I was looking through test cases, I realized that we mishandle the case of ...
6 years, 4 months ago (2014-08-09 21:00:22 UTC) #4
mdempsky
LGTM Test cases seem convincing enough to me. https://codereview.chromium.org/453873002/diff/80001/tools/clang/rewrite_scoped_refptr/tests/temp-passed-as-raw-arg-original.cc File tools/clang/rewrite_scoped_refptr/tests/temp-passed-as-raw-arg-original.cc (right): https://codereview.chromium.org/453873002/diff/80001/tools/clang/rewrite_scoped_refptr/tests/temp-passed-as-raw-arg-original.cc#newcode23 tools/clang/rewrite_scoped_refptr/tests/temp-passed-as-raw-arg-original.cc:23: Bar(GetBuggyFoo()); ...
6 years, 4 months ago (2014-08-11 20:21:54 UTC) #5
dcheng
https://codereview.chromium.org/453873002/diff/80001/tools/clang/rewrite_scoped_refptr/tests/temp-passed-as-raw-arg-original.cc File tools/clang/rewrite_scoped_refptr/tests/temp-passed-as-raw-arg-original.cc (right): https://codereview.chromium.org/453873002/diff/80001/tools/clang/rewrite_scoped_refptr/tests/temp-passed-as-raw-arg-original.cc#newcode23 tools/clang/rewrite_scoped_refptr/tests/temp-passed-as-raw-arg-original.cc:23: Bar(GetBuggyFoo()); On 2014/08/11 20:21:54, mdempsky wrote: > Might be ...
6 years, 4 months ago (2014-08-11 21:01:00 UTC) #6
Ryan Sleevi
lgtm
6 years, 4 months ago (2014-08-11 21:22:30 UTC) #7
dcheng
6 years, 4 months ago (2014-08-11 21:31:54 UTC) #8
Message was sent while issue was closed.
Committed patchset #6 manually as 288795 (presubmit successful).

Powered by Google App Engine
This is Rietveld 408576698