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 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 | 571 |
572 // Field, variable, and enum declarations ======== | 572 // Field, variable, and enum declarations ======== |
573 // Given | 573 // Given |
574 // int x; | 574 // int x; |
575 // struct S { | 575 // struct S { |
576 // int y; | 576 // int y; |
577 // enum { VALUE }; | 577 // enum { VALUE }; |
578 // }; | 578 // }; |
579 // matches |x|, |y|, and |VALUE|. | 579 // matches |x|, |y|, and |VALUE|. |
580 auto field_decl_matcher = id("decl", fieldDecl(in_blink_namespace)); | 580 auto field_decl_matcher = id("decl", fieldDecl(in_blink_namespace)); |
581 auto is_wtf_type_trait_value = | 581 auto is_type_trait_value = |
582 varDecl(hasName("value"), hasStaticStorageDuration(), | 582 varDecl(hasName("value"), hasStaticStorageDuration(), isPublic(), |
583 hasType(isConstQualified()), hasType(booleanType()), | 583 hasType(isConstQualified()), hasType(booleanType()), |
584 hasAncestor(recordDecl(hasAncestor(namespaceDecl( | 584 unless(hasAncestor(recordDecl(has(functionDecl()))))); |
585 hasName("WTF"), hasParent(translationUnitDecl())))))); | |
586 auto var_decl_matcher = | 585 auto var_decl_matcher = |
587 id("decl", varDecl(in_blink_namespace, unless(is_wtf_type_trait_value))); | 586 id("decl", varDecl(in_blink_namespace, unless(is_type_trait_value))); |
588 auto enum_member_decl_matcher = | 587 auto enum_member_decl_matcher = |
589 id("decl", enumConstantDecl(in_blink_namespace)); | 588 id("decl", enumConstantDecl(in_blink_namespace)); |
590 | 589 |
591 FieldDeclRewriter field_decl_rewriter(&replacements); | 590 FieldDeclRewriter field_decl_rewriter(&replacements); |
592 match_finder.addMatcher(field_decl_matcher, &field_decl_rewriter); | 591 match_finder.addMatcher(field_decl_matcher, &field_decl_rewriter); |
593 | 592 |
594 VarDeclRewriter var_decl_rewriter(&replacements); | 593 VarDeclRewriter var_decl_rewriter(&replacements); |
595 match_finder.addMatcher(var_decl_matcher, &var_decl_rewriter); | 594 match_finder.addMatcher(var_decl_matcher, &var_decl_rewriter); |
596 | 595 |
597 EnumConstantDeclRewriter enum_member_decl_rewriter(&replacements); | 596 EnumConstantDeclRewriter enum_member_decl_rewriter(&replacements); |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
865 for (const auto& r : replacements) { | 864 for (const auto& r : replacements) { |
866 std::string replacement_text = r.getReplacementText().str(); | 865 std::string replacement_text = r.getReplacementText().str(); |
867 std::replace(replacement_text.begin(), replacement_text.end(), '\n', '\0'); | 866 std::replace(replacement_text.begin(), replacement_text.end(), '\n', '\0'); |
868 llvm::outs() << "r:::" << r.getFilePath() << ":::" << r.getOffset() | 867 llvm::outs() << "r:::" << r.getFilePath() << ":::" << r.getOffset() |
869 << ":::" << r.getLength() << ":::" << replacement_text << "\n"; | 868 << ":::" << r.getLength() << ":::" << replacement_text << "\n"; |
870 } | 869 } |
871 llvm::outs() << "==== END EDITS ====\n"; | 870 llvm::outs() << "==== END EDITS ====\n"; |
872 | 871 |
873 return 0; | 872 return 0; |
874 } | 873 } |
OLD | NEW |