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

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

Issue 2276813003: Improve accuracy of detecting type trait fields. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blink-style-definition-outside-of-namespace-node
Patch Set: Moving part of a matcher into a separate |is_wtf_type_trait_value| variable. Created 4 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 blink { 5 namespace blink {
6 6
7 // Note: do not add any copy or move constructors to this class: doing so will 7 // Note: do not add any copy or move constructors to this class: doing so will
8 // break test coverage that we don't clobber the class name by trying to emit 8 // break test coverage that we don't clobber the class name by trying to emit
9 // replacements for synthesized functions. 9 // replacements for synthesized functions.
10 class C { 10 class C {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 char four_chars[4]; 62 char four_chars[4];
63 short two_shorts[2]; 63 short two_shorts[2];
64 int one_hopefully_four_byte_int; 64 int one_hopefully_four_byte_int;
65 int has_prefix_; 65 int has_prefix_;
66 }; 66 };
67 67
68 } // namespace blink 68 } // namespace blink
69 69
70 namespace WTF { 70 namespace WTF {
71 71
72 struct TypeTrait { 72 // We don't want to capitalize fields in type traits
73 // WTF has structs for things like type traits, which we don't want to 73 // (i.e. no |value| -> |kValue| rename is undesirable below).
74 // capitalize. 74 struct TypeTrait1 {
75 static const bool value = true; 75 static const bool value = true;
76 }; 76 };
77 77
78 // Some type traits are implemented as classes, not structs
79 // (e.g. WTF::IsGarbageCollectedType or WTF::IsAssignable).
80 template <typename T>
81 class TypeTrait2 {
82 public:
83 static const bool value = false;
84 };
85 template <>
86 class TypeTrait2<void> {
87 public:
88 static const bool value = false;
89 };
90
78 }; // namespace WTF 91 }; // namespace WTF
79 92
80 void F() { 93 void F() {
81 // Test that references to a static field are correctly rewritten. 94 // Test that references to a static field are correctly rewritten.
82 blink::C::instance_count_++; 95 blink::C::instance_count_++;
83 // Force instantiation of a copy constructor for blink::C to make sure field 96 // Force instantiation of a copy constructor for blink::C to make sure field
84 // initializers for synthesized functions don't cause weird rewrites. 97 // initializers for synthesized functions don't cause weird rewrites.
85 blink::C c; 98 blink::C c;
86 blink::C c2 = c; 99 blink::C c2 = c;
87 100
88 bool b = WTF::TypeTrait::value; 101 bool b1 = WTF::TypeTrait1::value;
102 bool b2 = WTF::TypeTrait2<void>::value;
89 } 103 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698