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

Side by Side Diff: tools/clang/plugins/tests/base_passed.cpp

Issue 520283002: . Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: notjustcalls Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/clang/plugins/ChromeClassTester.cpp ('k') | tools/clang/plugins/tests/base_passed.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #define MOVE_ONLY_TYPE_FOR_CPP_03(type, rvalue_type) \
2 public: \
3 struct rvalue_type { \
4 explicit rvalue_type(type* object) : object(object) {} \
5 type* object; \
6 }; \
7 type(type&); \
8 void operator=(type&); \
9 operator rvalue_type() { return rvalue_type(this); } \
10 type Pass() { return type(rvalue_type(this)); } \
11 typedef void MoveOnlyTypeForCPP03; \
12 private:
13
14 namespace base {
15 template <class T>
16 class scoped_ptr {
17 MOVE_ONLY_TYPE_FOR_CPP_03(scoped_ptr, RValue)
18 public:
19 typedef T element_type;
20 scoped_ptr() { }
21 explicit scoped_ptr(element_type* p) { }
22 scoped_ptr(RValue rvalue) { }
23 template <typename U>
24 scoped_ptr& operator=(scoped_ptr<U> rhs) { return *this; }
25 element_type* get() const { return 0; }
26 };
27
28 template <typename T>
29 static inline T Passed(T scoper) {
30 return scoper.Pass();
31 }
32 template <typename T>
33 static inline T Passed(T* scoper) {
34 return scoper->Pass();
35 }
36
37 }
38
39 void f_bad(base::scoped_ptr<int> i, int* p) {}
40
41 void f_ok(base::scoped_ptr<int> i) {}
42
43 int h_bad1(base::scoped_ptr<int> i) { return 0; }
44 int h_bad2(int* i) { return 0; }
45 int h(int a, int b) { return 0; }
46
47 void g() {
48 base::scoped_ptr<int> s;
49
50 f_bad(base::Passed(&s), s.get());
51 f_bad(base::Passed(s.Pass()), s.get());
52
53 // Shouldn't warn.
54 f_ok(base::Passed(&s));
55
56 h(h_bad1(base::Passed(&s)),
57 h_bad2(s.get()));
58 }
OLDNEW
« no previous file with comments | « tools/clang/plugins/ChromeClassTester.cpp ('k') | tools/clang/plugins/tests/base_passed.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698