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

Side by Side Diff: tools/clang/rewrite_to_chrome_style/tests/function-templates-expected.cc

Issue 2256913002: Handling of DependentScopeDeclRefExpr and CXXDependentScopeMemberExpr nodes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blink-style-new-clang
Patch Set: Created 4 years, 4 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 namespace WTF { 5 namespace WTF {
6 6
7 template <typename To, typename From> 7 template <typename To, typename From>
8 bool IsInBounds(From value) { 8 bool IsInBounds(From value) {
9 return true; 9 return true;
10 } 10 }
11 11
12 template <typename To, typename From> 12 template <typename To, typename From>
13 To SafeCast(From value) { 13 To SafeCast(From value) {
14 if (!IsInBounds<To>(value)) 14 if (!IsInBounds<To>(value))
15 return 0; 15 return 0;
16 return static_cast<To>(value); 16 return static_cast<To>(value);
17 } 17 }
18 18
19 template <typename T, typename OverflowHandler> 19 template <typename T, typename OverflowHandler>
20 class Checked { 20 class Checked {
21 public: 21 public:
22 template <typename U, typename V> 22 template <typename U, typename V>
23 Checked(const Checked<U, V>& rhs) { 23 Checked(const Checked<U, V>& rhs) {
24 // This (incorrectly) doesn't get rewritten, since it's not instantiated. In 24 if (rhs.HasOverflowed())
25 // this case, the AST representation contains a bunch of 25 this->Overflowed();
26 // CXXDependentScopeMemberExpr nodes. 26 if (!IsInBounds<T>(rhs.value_))
27 if (rhs.hasOverflowed()) 27 this->Overflowed();
28 this->overflowed(); 28 value_ = static_cast<T>(rhs.value_);
Łukasz Anforowicz 2016/08/17 22:45:09 Ha! This is the "m_" heuristic in effect - seems
29 if (!IsInBounds<T>(rhs.m_value))
30 this->overflowed();
31 value_ = static_cast<T>(rhs.m_value);
32 } 29 }
33 30
34 bool HasOverflowed() const { return false; } 31 bool HasOverflowed() const { return false; }
35 void Overflowed() {} 32 void Overflowed() {}
36 33
37 private: 34 private:
38 T value_; 35 T value_;
39 }; 36 };
40 37
41 template <typename To, typename From> 38 template <typename To, typename From>
42 To Bitwise_cast(From from) { 39 To Bitwise_cast(From from) {
43 static_assert(sizeof(To) == sizeof(From)); 40 static_assert(sizeof(To) == sizeof(From));
44 return reinterpret_cast<To>(from); 41 return reinterpret_cast<To>(from);
45 } 42 }
46 43
47 } // namespace WTF 44 } // namespace WTF
48 45
49 using WTF::Bitwise_cast; 46 using WTF::Bitwise_cast;
50 using WTF::SafeCast; 47 using WTF::SafeCast;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698