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

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

Issue 1806903003: Don't rename references to functions that originate from template args. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a period and GetType Created 4 years, 9 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/clang/rewrite_to_chrome_style/tests/template-original.cc
diff --git a/tools/clang/rewrite_to_chrome_style/tests/template-original.cc b/tools/clang/rewrite_to_chrome_style/tests/template-original.cc
index 39ae4e5efbf726abe3dfc5e29cea2c4a5a138ff8..cb2251765dfe2ade768a635bed6f08dee4d51f74 100644
--- a/tools/clang/rewrite_to_chrome_style/tests/template-original.cc
+++ b/tools/clang/rewrite_to_chrome_style/tests/template-original.cc
@@ -2,6 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+namespace not_blink {
+
+void notBlinkFunction(int x) {}
+
+class NotBlinkClass {
+ public:
+ void notBlinkMethod() {}
+};
+
+template <typename T>
+void notBlinkFunctionTemplate(T x) {}
+
+} // not_blink
+
namespace blink {
template <typename T, int number>
@@ -20,4 +34,68 @@ void F() {
const int is_a_const = number;
}
+namespace test_template_arg_is_function {
+
+void f(int x) {}
+
+template <typename T, void g(T)>
+void h(T x) {
+ g(x);
+}
+
+void test() {
+ // f should be rewritten.
+ h<int, f>(0);
+ // notBlinkFunction should stay the same.
+ h<int, not_blink::notBlinkFunction>(1);
+}
+
+} // namespace test_template_arg_is_function
+
+namespace test_template_arg_is_method {
+
+class BlinkClass {
+ public:
+ void method() {}
+};
+
+template <typename T, void (T::*g)()>
+void h(T&& x) {
+ (x.*g)();
+}
+
+void test() {
+ // method should be rewritten.
+ h<BlinkClass, &BlinkClass::method>(BlinkClass());
+ h<not_blink::NotBlinkClass, &not_blink::NotBlinkClass::notBlinkMethod>(
+ not_blink::NotBlinkClass());
+}
+
+} // namespace test_template_arg_is_method
+
+// Test template arguments that are function templates.
+template <typename T, char converter(T)>
+unsigned reallyBadHash(const T* data, unsigned length) {
+ unsigned hash = 1;
+ for (unsigned i = 0; i < length; ++i) {
+ hash *= converter(data[i]);
+ }
+ return hash;
+}
+
+struct StringHasher {
+ static unsigned Hash(const char* data, unsigned length) {
+ // TODO(dcheng): For some reason, brokenFoldCase gets parsed as an
+ // UnresolvedLookupExpr, so this doesn't get rewritten. Meh. See
+ // https://crbug.com/584408.
+ return reallyBadHash<char, brokenFoldCase<char>>(data, length);
+ }
+
+ private:
+ template <typename T>
+ static char brokenFoldCase(T input) {
+ return input - ('a' - 'A');
+ }
+};
+
} // namespace blink
« 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