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

Side by Side Diff: tools/clang/rewrite_scoped_refptr/RewriteScopedRefptr.cpp

Issue 718873004: Various hacks for running a clang tool on Windows. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Checkpt Created 6 years, 1 month 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 | « include_rsp.py ('k') | tools/clang/scripts/update.py » ('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 (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 5 // This implements a Clang tool to rewrite all instances of
6 // scoped_refptr<T>'s implicit cast to T (operator T*) to an explicit call to 6 // scoped_refptr<T>'s implicit cast to T (operator T*) to an explicit call to
7 // the .get() method. 7 // the .get() method.
8 8
9 #include <assert.h> 9 #include <assert.h>
10 #include <algorithm> 10 #include <algorithm>
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 256
257 int main(int argc, const char* argv[]) { 257 int main(int argc, const char* argv[]) {
258 llvm::cl::OptionCategory category("Remove scoped_refptr conversions"); 258 llvm::cl::OptionCategory category("Remove scoped_refptr conversions");
259 CommonOptionsParser options(argc, argv, category); 259 CommonOptionsParser options(argc, argv, category);
260 clang::tooling::ClangTool tool(options.getCompilations(), 260 clang::tooling::ClangTool tool(options.getCompilations(),
261 options.getSourcePathList()); 261 options.getSourcePathList());
262 262
263 MatchFinder match_finder; 263 MatchFinder match_finder;
264 Replacements replacements; 264 Replacements replacements;
265 265
266 auto is_scoped_refptr = recordDecl(isSameOrDerivedFrom("::scoped_refptr"), 266 auto is_scoped_refptr = recordDecl(isSameOrDerivedFrom("::scoped_refptr"));
267 isTemplateInstantiation());
268 267
269 // Finds all calls to conversion operator member function. This catches calls 268 // Finds all calls to conversion operator member function. This catches calls
270 // to "operator T*", "operator Testable", and "operator bool" equally. 269 // to "operator T*", "operator Testable", and "operator bool" equally.
271 auto base_matcher = memberCallExpr(thisPointerType(is_scoped_refptr), 270 auto base_matcher = memberCallExpr(thisPointerType(is_scoped_refptr),
272 callee(conversionDecl()), 271 callee(conversionDecl()),
273 on(id("arg", expr()))); 272 on(id("arg", expr())));
274 273
275 // The heuristic for whether or not converting a temporary is 'unsafe'. An 274 // The heuristic for whether or not converting a temporary is 'unsafe'. An
276 // unsafe conversion is one where a temporary scoped_refptr<T> is converted to 275 // unsafe conversion is one where a temporary scoped_refptr<T> is converted to
277 // another type. The matcher provides an exception for a temporary 276 // another type. The matcher provides an exception for a temporary
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 for (const auto& r : replacements) { 418 for (const auto& r : replacements) {
420 std::string replacement_text = r.getReplacementText().str(); 419 std::string replacement_text = r.getReplacementText().str();
421 std::replace(replacement_text.begin(), replacement_text.end(), '\n', '\0'); 420 std::replace(replacement_text.begin(), replacement_text.end(), '\n', '\0');
422 llvm::outs() << "r:::" << r.getFilePath() << ":::" << r.getOffset() << ":::" 421 llvm::outs() << "r:::" << r.getFilePath() << ":::" << r.getOffset() << ":::"
423 << r.getLength() << ":::" << replacement_text << "\n"; 422 << r.getLength() << ":::" << replacement_text << "\n";
424 } 423 }
425 llvm::outs() << "==== END EDITS ====\n"; 424 llvm::outs() << "==== END EDITS ====\n";
426 425
427 return 0; 426 return 0;
428 } 427 }
OLDNEW
« no previous file with comments | « include_rsp.py ('k') | tools/clang/scripts/update.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698