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

Side by Side Diff: tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp

Issue 2544933002: Handling ElaboratedType and InjectedClassNameType in blink_qual_type_matcher. (Closed)
Patch Set: Removed unnecessary debugging output. Ooops. Created 4 years 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 | « no previous file | tools/clang/rewrite_to_chrome_style/tests/template-expected.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 cxxDependentScopeMemberExpr; 71 cxxDependentScopeMemberExpr;
72 72
73 AST_MATCHER(clang::FunctionDecl, isOverloadedOperator) { 73 AST_MATCHER(clang::FunctionDecl, isOverloadedOperator) {
74 return Node.isOverloadedOperator(); 74 return Node.isOverloadedOperator();
75 } 75 }
76 76
77 AST_MATCHER(clang::CXXMethodDecl, isInstanceMethod) { 77 AST_MATCHER(clang::CXXMethodDecl, isInstanceMethod) {
78 return Node.isInstance(); 78 return Node.isInstance();
79 } 79 }
80 80
81 // TODO(lukasza): Remove this matcher definition, after we pull
82 // https://reviews.llvm.org/D27207 (aka rL288366) from upstream clang.
83 AST_MATCHER_P(clang::Type,
84 hasUnqualifiedDesugaredType,
85 clang::ast_matchers::internal::Matcher<clang::Type>,
86 InnerMatcher) {
87 const clang::Type* desugaredType = Node.getUnqualifiedDesugaredType();
88 return InnerMatcher.matches(*desugaredType, Finder, Builder);
89 }
90
81 AST_MATCHER_P(clang::FunctionTemplateDecl, 91 AST_MATCHER_P(clang::FunctionTemplateDecl,
82 templatedDecl, 92 templatedDecl,
83 clang::ast_matchers::internal::Matcher<clang::FunctionDecl>, 93 clang::ast_matchers::internal::Matcher<clang::FunctionDecl>,
84 InnerMatcher) { 94 InnerMatcher) {
85 return InnerMatcher.matches(*Node.getTemplatedDecl(), Finder, Builder); 95 return InnerMatcher.matches(*Node.getTemplatedDecl(), Finder, Builder);
86 } 96 }
87 97
88 // If |InnerMatcher| matches |top|, then the returned matcher will match: 98 // If |InnerMatcher| matches |top|, then the returned matcher will match:
89 // - |top::function| 99 // - |top::function|
90 // - |top::Class::method| 100 // - |top::Class::method|
(...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after
1183 var_decl_matcher, field_decl_matcher, function_decl_matcher, 1193 var_decl_matcher, field_decl_matcher, function_decl_matcher,
1184 method_decl_matcher, function_template_decl_matcher, 1194 method_decl_matcher, function_template_decl_matcher,
1185 method_template_decl_matcher, enum_member_decl_matcher))))); 1195 method_template_decl_matcher, enum_member_decl_matcher)))));
1186 UsingDeclRewriter using_decl_rewriter(&replacements); 1196 UsingDeclRewriter using_decl_rewriter(&replacements);
1187 match_finder.addMatcher(using_decl_matcher, &using_decl_rewriter); 1197 match_finder.addMatcher(using_decl_matcher, &using_decl_rewriter);
1188 1198
1189 // Matches any QualType that refers to a blink type: 1199 // Matches any QualType that refers to a blink type:
1190 // - const blink::Foo& 1200 // - const blink::Foo&
1191 // - blink::Foo* 1201 // - blink::Foo*
1192 // - blink::Foo<T> 1202 // - blink::Foo<T>
1193 // - ... 1203 auto blink_qual_type_base_matcher = hasBaseType(hasUnqualifiedDesugaredType(
1194 // TODO(lukasza): The matchers below can be simplified after
1195 // https://llvm.org/bugs/show_bug.cgi?id=30331 is fixed.
1196 // Simplified matchers:
1197 // auto blink_qual_type_base_matcher =
1198 // qualType(hasDeclaration(in_blink_namespace));
1199 // auto blink_qual_type_matcher = qualType(anyOf(
1200 // blink_qual_type_base_matcher,
1201 // pointsTo(blink_qual_type_base_matcher),
1202 // references(blink_qual_type_base_matcher)));
1203 auto blink_qual_type_bug_workaround_matcher1 = hasBaseType(
1204 anyOf(enumType(hasDeclaration(in_blink_namespace)), 1204 anyOf(enumType(hasDeclaration(in_blink_namespace)),
1205 injectedClassNameType(hasDeclaration(in_blink_namespace)),
1205 recordType(hasDeclaration(in_blink_namespace)), 1206 recordType(hasDeclaration(in_blink_namespace)),
1206 templateSpecializationType(hasDeclaration(in_blink_namespace)), 1207 templateSpecializationType(hasDeclaration(in_blink_namespace)),
1207 templateTypeParmType(hasDeclaration(in_blink_namespace)), 1208 templateTypeParmType(hasDeclaration(in_blink_namespace)))));
1208 typedefType(hasDeclaration(in_blink_namespace)))); 1209 auto blink_qual_type_matcher = qualType(anyOf(
1209 auto blink_qual_type_base_matcher = 1210 blink_qual_type_base_matcher, pointsTo(blink_qual_type_base_matcher),
1210 qualType(anyOf(blink_qual_type_bug_workaround_matcher1, 1211 references(blink_qual_type_base_matcher)));
1211 hasBaseType(elaboratedType(
1212 namesType(blink_qual_type_bug_workaround_matcher1)))));
1213 auto blink_qual_type_matcher =
1214 qualType(anyOf(blink_qual_type_base_matcher, pointsTo(in_blink_namespace),
1215 references(in_blink_namespace)));
1216 1212
1217 // Template-dependent decl lookup ======== 1213 // Template-dependent decl lookup ========
1218 // Given 1214 // Given
1219 // template <typename T> void f() { T::foo(); } 1215 // template <typename T> void f() { T::foo(); }
1220 // matches |T::foo|. 1216 // matches |T::foo|.
1221 auto dependent_scope_decl_ref_expr_matcher = 1217 auto dependent_scope_decl_ref_expr_matcher =
1222 expr(id("expr", dependentScopeDeclRefExpr(has(nestedNameSpecifier( 1218 expr(id("expr", dependentScopeDeclRefExpr(has(nestedNameSpecifier(
1223 specifiesType(blink_qual_type_matcher)))))); 1219 specifiesType(blink_qual_type_matcher))))));
1224 DependentScopeDeclRefExprRewriter dependent_scope_decl_ref_expr_rewriter( 1220 DependentScopeDeclRefExprRewriter dependent_scope_decl_ref_expr_rewriter(
1225 &replacements); 1221 &replacements);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1286 for (const auto& r : replacements) { 1282 for (const auto& r : replacements) {
1287 std::string replacement_text = r.getReplacementText().str(); 1283 std::string replacement_text = r.getReplacementText().str();
1288 std::replace(replacement_text.begin(), replacement_text.end(), '\n', '\0'); 1284 std::replace(replacement_text.begin(), replacement_text.end(), '\n', '\0');
1289 llvm::outs() << "r:::" << r.getFilePath() << ":::" << r.getOffset() 1285 llvm::outs() << "r:::" << r.getFilePath() << ":::" << r.getOffset()
1290 << ":::" << r.getLength() << ":::" << replacement_text << "\n"; 1286 << ":::" << r.getLength() << ":::" << replacement_text << "\n";
1291 } 1287 }
1292 llvm::outs() << "==== END EDITS ====\n"; 1288 llvm::outs() << "==== END EDITS ====\n";
1293 1289
1294 return 0; 1290 return 0;
1295 } 1291 }
OLDNEW
« no previous file with comments | « no previous file | tools/clang/rewrite_to_chrome_style/tests/template-expected.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698