Index: tools/clang/rewrite_scoped_refptr/tests/temp-passed-as-raw-arg-expected.cc |
diff --git a/tools/clang/rewrite_scoped_refptr/tests/temp-passed-as-raw-arg-expected.cc b/tools/clang/rewrite_scoped_refptr/tests/temp-passed-as-raw-arg-expected.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..803db29f9fd54b44b6d4304c8fa59f34e82d2db4 |
--- /dev/null |
+++ b/tools/clang/rewrite_scoped_refptr/tests/temp-passed-as-raw-arg-expected.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()); |
+} |