OLD | NEW |
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 // Changes Blink-style names to Chrome-style names. Currently transforms: | 5 // Changes Blink-style names to Chrome-style names. Currently transforms: |
6 // fields: | 6 // fields: |
7 // int m_operationCount => int operation_count_ | 7 // int m_operationCount => int operation_count_ |
8 // variables (including parameters): | 8 // variables (including parameters): |
9 // int mySuperVariable => int my_super_variable | 9 // int mySuperVariable => int my_super_variable |
10 // constants: | 10 // constants: |
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1067 // Given | 1067 // Given |
1068 // int x; | 1068 // int x; |
1069 // struct S { | 1069 // struct S { |
1070 // int y; | 1070 // int y; |
1071 // enum { VALUE }; | 1071 // enum { VALUE }; |
1072 // }; | 1072 // }; |
1073 // matches |x|, |y|, and |VALUE|. | 1073 // matches |x|, |y|, and |VALUE|. |
1074 auto field_decl_matcher = id("decl", fieldDecl(in_blink_namespace)); | 1074 auto field_decl_matcher = id("decl", fieldDecl(in_blink_namespace)); |
1075 auto is_type_trait_value = | 1075 auto is_type_trait_value = |
1076 varDecl(hasName("value"), hasStaticStorageDuration(), isPublic(), | 1076 varDecl(hasName("value"), hasStaticStorageDuration(), isPublic(), |
1077 hasType(isConstQualified()), hasType(type(anyOf( | 1077 hasType(isConstQualified()), |
1078 booleanType(), enumType()))), | 1078 hasType(type(anyOf(builtinType(), enumType()))), |
1079 unless(hasAncestor(recordDecl( | 1079 unless(hasAncestor(recordDecl( |
1080 has(cxxMethodDecl(isUserProvided(), isInstanceMethod())))))); | 1080 has(cxxMethodDecl(isUserProvided(), isInstanceMethod())))))); |
1081 auto var_decl_matcher = | 1081 auto var_decl_matcher = |
1082 id("decl", varDecl(in_blink_namespace, unless(is_type_trait_value))); | 1082 id("decl", varDecl(in_blink_namespace, unless(is_type_trait_value))); |
1083 auto enum_member_decl_matcher = | 1083 auto enum_member_decl_matcher = |
1084 id("decl", enumConstantDecl(in_blink_namespace)); | 1084 id("decl", enumConstantDecl(in_blink_namespace)); |
1085 | 1085 |
1086 FieldDeclRewriter field_decl_rewriter(&replacements); | 1086 FieldDeclRewriter field_decl_rewriter(&replacements); |
1087 match_finder.addMatcher(field_decl_matcher, &field_decl_rewriter); | 1087 match_finder.addMatcher(field_decl_matcher, &field_decl_rewriter); |
1088 | 1088 |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1409 for (const auto& r : replacements) { | 1409 for (const auto& r : replacements) { |
1410 std::string replacement_text = r.getReplacementText().str(); | 1410 std::string replacement_text = r.getReplacementText().str(); |
1411 std::replace(replacement_text.begin(), replacement_text.end(), '\n', '\0'); | 1411 std::replace(replacement_text.begin(), replacement_text.end(), '\n', '\0'); |
1412 llvm::outs() << "r:::" << r.getFilePath() << ":::" << r.getOffset() | 1412 llvm::outs() << "r:::" << r.getFilePath() << ":::" << r.getOffset() |
1413 << ":::" << r.getLength() << ":::" << replacement_text << "\n"; | 1413 << ":::" << r.getLength() << ":::" << replacement_text << "\n"; |
1414 } | 1414 } |
1415 llvm::outs() << "==== END EDITS ====\n"; | 1415 llvm::outs() << "==== END EDITS ====\n"; |
1416 | 1416 |
1417 return 0; | 1417 return 0; |
1418 } | 1418 } |
OLD | NEW |