OLD | NEW |
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 "ListValueRewriter.h" | 5 #include "ListValueRewriter.h" |
6 | 6 |
7 #include <assert.h> | 7 #include <assert.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 | 9 |
10 #include "clang/AST/ASTContext.h" | 10 #include "clang/AST/ASTContext.h" |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 append_double_callback_(replacements), | 344 append_double_callback_(replacements), |
345 append_string_callback_(replacements), | 345 append_string_callback_(replacements), |
346 append_released_unique_ptr_callback_(replacements), | 346 append_released_unique_ptr_callback_(replacements), |
347 append_raw_ptr_callback_(replacements) {} | 347 append_raw_ptr_callback_(replacements) {} |
348 | 348 |
349 void ListValueRewriter::RegisterMatchers(MatchFinder* match_finder) { | 349 void ListValueRewriter::RegisterMatchers(MatchFinder* match_finder) { |
350 auto is_list_append = cxxMemberCallExpr( | 350 auto is_list_append = cxxMemberCallExpr( |
351 callee(cxxMethodDecl(hasName("::base::ListValue::Append"))), | 351 callee(cxxMethodDecl(hasName("::base::ListValue::Append"))), |
352 argumentCountIs(1)); | 352 argumentCountIs(1)); |
353 | 353 |
354 // base::ListValue::Append(new base::FundamentalValue(bool)) | 354 // base::ListValue::Append(new base::Value(bool)) |
355 // => base::ListValue::AppendBoolean() | 355 // => base::ListValue::AppendBoolean() |
356 match_finder->addMatcher( | 356 match_finder->addMatcher( |
357 id("callExpr", | 357 id("callExpr", |
358 cxxMemberCallExpr( | 358 cxxMemberCallExpr( |
359 is_list_append, | 359 is_list_append, |
360 hasArgument( | 360 hasArgument( |
361 0, ignoringParenImpCasts(id( | 361 0, ignoringParenImpCasts( |
362 "newExpr", | 362 id("newExpr", |
363 cxxNewExpr(has(cxxConstructExpr( | 363 cxxNewExpr(has(cxxConstructExpr( |
364 hasDeclaration(cxxMethodDecl(hasName( | 364 hasDeclaration(cxxMethodDecl( |
365 "::base::FundamentalValue::FundamentalValue"))), | 365 hasName("::base::Value::FundamentalValue"))), |
366 argumentCountIs(1), | 366 argumentCountIs(1), |
367 hasArgument( | 367 hasArgument( |
368 0, id("argExpr", | 368 0, id("argExpr", |
369 expr(hasType(booleanType())))))))))))), | 369 expr(hasType(booleanType())))))))))))), |
370 &append_boolean_callback_); | 370 &append_boolean_callback_); |
371 | 371 |
372 // base::ListValue::Append(new base::FundamentalValue(int)) | 372 // base::ListValue::Append(new base::Value(int)) |
373 // => base::ListValue::AppendInteger() | 373 // => base::ListValue::AppendInteger() |
374 match_finder->addMatcher( | 374 match_finder->addMatcher( |
375 id("callExpr", | 375 id("callExpr", |
376 cxxMemberCallExpr( | 376 cxxMemberCallExpr( |
377 is_list_append, | 377 is_list_append, |
378 hasArgument( | 378 hasArgument( |
379 0, | 379 0, |
380 ignoringParenImpCasts(id( | 380 ignoringParenImpCasts(id( |
381 "newExpr", | 381 "newExpr", |
382 cxxNewExpr(has(cxxConstructExpr( | 382 cxxNewExpr(has(cxxConstructExpr( |
383 hasDeclaration(cxxMethodDecl(hasName( | 383 hasDeclaration(cxxMethodDecl( |
384 "::base::FundamentalValue::FundamentalValue"))), | 384 hasName("::base::Value::FundamentalValue"))), |
385 argumentCountIs(1), | 385 argumentCountIs(1), |
386 hasArgument(0, id("argExpr", | 386 hasArgument(0, id("argExpr", |
387 expr(hasType(isInteger()), | 387 expr(hasType(isInteger()), |
388 unless(hasType( | 388 unless(hasType( |
389 booleanType()))))))))))))), | 389 booleanType()))))))))))))), |
390 &append_integer_callback_); | 390 &append_integer_callback_); |
391 | 391 |
392 // base::ListValue::Append(new base::FundamentalValue(double)) | 392 // base::ListValue::Append(new base::Value(double)) |
393 // => base::ListValue::AppendDouble() | 393 // => base::ListValue::AppendDouble() |
394 match_finder->addMatcher( | 394 match_finder->addMatcher( |
395 id("callExpr", | 395 id("callExpr", |
396 cxxMemberCallExpr( | 396 cxxMemberCallExpr( |
397 is_list_append, | 397 is_list_append, |
398 hasArgument( | 398 hasArgument( |
399 0, ignoringParenImpCasts(id( | 399 0, ignoringParenImpCasts(id( |
400 "newExpr", | 400 "newExpr", |
401 cxxNewExpr(has(cxxConstructExpr( | 401 cxxNewExpr(has(cxxConstructExpr( |
402 hasDeclaration(cxxMethodDecl(hasName( | 402 hasDeclaration(cxxMethodDecl( |
403 "::base::FundamentalValue::FundamentalValue"))), | 403 hasName("::base::Value::FundamentalValue"))), |
404 argumentCountIs(1), | 404 argumentCountIs(1), |
405 hasArgument( | 405 hasArgument( |
406 0, id("argExpr", | 406 0, id("argExpr", |
407 expr(hasType( | 407 expr(hasType( |
408 realFloatingPointType())))))))))))), | 408 realFloatingPointType())))))))))))), |
409 &append_double_callback_); | 409 &append_double_callback_); |
410 | 410 |
411 // base::ListValue::Append(new base::StringValue(...)) | 411 // base::ListValue::Append(new base::StringValue(...)) |
412 // => base::ListValue::AppendString() | 412 // => base::ListValue::AppendString() |
413 match_finder->addMatcher( | 413 match_finder->addMatcher( |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 anyOf(hasInitializer( | 473 anyOf(hasInitializer( |
474 // Note this won't match C++11 uniform | 474 // Note this won't match C++11 uniform |
475 // initialization syntax, since the | 475 // initialization syntax, since the |
476 // CXXNewExpr is wrapped in an | 476 // CXXNewExpr is wrapped in an |
477 // InitListExpr in that case. | 477 // InitListExpr in that case. |
478 ignoringParenImpCasts(cxxNewExpr())), | 478 ignoringParenImpCasts(cxxNewExpr())), |
479 unless(hasInitializer(expr()))), | 479 unless(hasInitializer(expr()))), |
480 unless(parmVarDecl()))))))))), | 480 unless(parmVarDecl()))))))))), |
481 &append_raw_ptr_callback_); | 481 &append_raw_ptr_callback_); |
482 } | 482 } |
OLD | NEW |