OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 // This implements a Clang tool to rewrite all instances of scoped_array<T> to | 5 // This implements a Clang tool to rewrite all instances of scoped_array<T> to |
6 // scoped_ptr<T[]>. The former is being deprecated in favor of the latter, to | 6 // scoped_ptr<T[]>. The former is being deprecated in favor of the latter, to |
7 // allow for an eventual transition from scoped_ptr to unique_ptr. | 7 // allow for an eventual transition from scoped_ptr to unique_ptr. |
8 | 8 |
9 #include "clang/AST/ASTContext.h" | 9 #include "clang/AST/ASTContext.h" |
10 #include "clang/ASTMatchers/ASTMatchers.h" | 10 #include "clang/ASTMatchers/ASTMatchers.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 loc(qualType(hasDeclaration(recordDecl(hasName("::scoped_array")))))), | 78 loc(qualType(hasDeclaration(recordDecl(hasName("::scoped_array")))))), |
79 &callback); | 79 &callback); |
80 | 80 |
81 int result = | 81 int result = |
82 tool.run(clang::tooling::newFrontendActionFactory(&match_finder)); | 82 tool.run(clang::tooling::newFrontendActionFactory(&match_finder)); |
83 if (result != 0) | 83 if (result != 0) |
84 return result; | 84 return result; |
85 | 85 |
86 // Serialization format is documented in tools/clang/scripts/run_tool.py | 86 // Serialization format is documented in tools/clang/scripts/run_tool.py |
87 llvm::outs() << "==== BEGIN EDITS ====\n"; | 87 llvm::outs() << "==== BEGIN EDITS ====\n"; |
88 for (const Replacement& r : replacements) { | 88 for (Replacements::const_iterator it = replacements.begin(); |
89 llvm::outs() << "r:" << r.getFilePath() << ":" << r.getOffset() << ":" | 89 it != replacements.end(); ++it) { |
90 << r.getLength() << ":" << r.getReplacementText() << "\n"; | 90 llvm::outs() << "r:" << it->getFilePath() << ":" << it->getOffset() << ":" |
| 91 << it->getLength() << ":" << it->getReplacementText() << "\n"; |
91 } | 92 } |
92 llvm::outs() << "==== END EDITS ====\n"; | 93 llvm::outs() << "==== END EDITS ====\n"; |
93 | 94 |
94 return 0; | 95 return 0; |
95 } | 96 } |
OLD | NEW |