Chromium Code Reviews| Index: tools/clang/rewrite_scoped_refptr/tests/temp-passed-as-raw-arg-original.cc | 
| diff --git a/tools/clang/rewrite_scoped_refptr/tests/temp-passed-as-raw-arg-original.cc b/tools/clang/rewrite_scoped_refptr/tests/temp-passed-as-raw-arg-original.cc | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..803db29f9fd54b44b6d4304c8fa59f34e82d2db4 | 
| --- /dev/null | 
| +++ b/tools/clang/rewrite_scoped_refptr/tests/temp-passed-as-raw-arg-original.cc | 
| @@ -0,0 +1,24 @@ | 
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. | 
| +// Use of this source code is governed by a BSD-style license that can be | 
| +// found in the LICENSE file. | 
| + | 
| +#include "scoped_refptr.h" | 
| + | 
| +struct Foo { | 
| + int dummy; | 
| +}; | 
| + | 
| +// A temporary scoped_refptr is unsafely passed as a function argument. Since | 
| +// temporaries are destroyed at the end of the full expression, this is 'safe' | 
| +// and can be rewritten to use get(). Currently, the tool just skips this case | 
| +// though--hopefully this is rare enough that manual intervention is not really | 
| +// required. | 
| +scoped_refptr<Foo> GetBuggyFoo() { | 
| + return new Foo; | 
| +} | 
| + | 
| +void Bar(Foo* f); | 
| + | 
| +void UseBuggyFoo() { | 
| + Bar(GetBuggyFoo()); | 
| 
 
mdempsky
2014/08/11 20:21:54
Might be worth adding a concise "// BUG: Should be
 
dcheng
2014/08/11 21:01:00
I've updated the comments for this and several oth
 
 | 
| +} |