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

Side by Side Diff: tools/clang/rewrite_to_chrome_style/tests/template-original.cc

Issue 2624253002: rewrite_to_chrome_style: Make const decisions aware of const variables (Closed)
Patch Set: consistent-consts-3: Created 3 years, 11 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/rewrite_to_chrome_style/tests/template-expected.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include <type_traits> 5 #include <type_traits>
6 6
7 namespace not_blink { 7 namespace not_blink {
8 8
9 void function(int x) {} 9 void function(int x) {}
10 10
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 const int maybeAConstToo = sizeof(T); 56 const int maybeAConstToo = sizeof(T);
57 const int isAConstToo = number; 57 const int isAConstToo = number;
58 // These are built from calls to functions which produces inconsistent 58 // These are built from calls to functions which produces inconsistent
59 // results so they should not be considered const to be safe. 59 // results so they should not be considered const to be safe.
60 const bool fromAMethod = functionNotMarkedConstexpr(number); 60 const bool fromAMethod = functionNotMarkedConstexpr(number);
61 const bool fromATemplatedMethod = templatedFunctionNotMarkedConstexpr(number); 61 const bool fromATemplatedMethod = templatedFunctionNotMarkedConstexpr(number);
62 // A complex statement of const things is const. 62 // A complex statement of const things is const.
63 const bool complexConst = number || (number + 1); 63 const bool complexConst = number || (number + 1);
64 // A complex statement with a non-const thing is not const. 64 // A complex statement with a non-const thing is not const.
65 const bool complexNotConst = number || (g_globalNumber + 1); 65 const bool complexNotConst = number || (g_globalNumber + 1);
66 // A const built from other consts is a const.
67 const bool constFromAConst = complexConst || number;
66 } 68 }
67 69
68 template <int number, typename... T> 70 template <int number, typename... T>
69 void F() { 71 void F() {
70 // These are const but hacker_case so we leave them alone. 72 // These are const but hacker_case so we leave them alone.
71 const int maybe_a_const = sizeof...(T); 73 const int maybe_a_const = sizeof...(T);
72 const int is_a_const = number; 74 const int is_a_const = number;
73 // These are const expressions so they get a k prefix. 75 // These are const expressions so they get a k prefix.
74 const int maybeAConstToo = sizeof...(T); 76 const int maybeAConstToo = sizeof...(T);
75 const int isAConstToo = number; 77 const int isAConstToo = number;
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 // Need to rewrite |f| to |F| below (because this method name 370 // Need to rewrite |f| to |F| below (because this method name
369 // does get rewritten when processing blink::test_unnamed_arg::Class). 371 // does get rewritten when processing blink::test_unnamed_arg::Class).
370 // See also https://crbug.com/670434. 372 // See also https://crbug.com/670434.
371 output->f(123); 373 output->f(123);
372 } 374 }
373 }; 375 };
374 376
375 } // namespace blink_methods_called_from_mojo_traits_are_not_rewritten 377 } // namespace blink_methods_called_from_mojo_traits_are_not_rewritten
376 378
377 } // namespace not_blink 379 } // namespace not_blink
OLDNEW
« no previous file with comments | « tools/clang/rewrite_to_chrome_style/tests/template-expected.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698