Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix clang-tidy crash when a single fix is applied on multiple files.
Summary: tooling::Replacements only holds replacements for a single file, so this patch makes Fix a map from file paths to tooling::Replacements so that it can be applied on multiple files. Reviewers: hokein, alexfh Subscribers: Prazek, cfe-commits Differential Revision: https://reviews.llvm.org/D23257 llvm-svn: 278101
- Loading branch information
Eric Liu
committed
Aug 9, 2016
1 parent
cf66ef2
commit 7e54452
Showing
6 changed files
with
83 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
clang-tools-extra/test/clang-tidy/Inputs/modernize-pass-by-value/header-with-fix.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
struct S { | ||
S(S&&); | ||
S(const S&); | ||
}; | ||
struct Foo { | ||
Foo(const S &s); | ||
S s; | ||
}; |
12 changes: 12 additions & 0 deletions
12
clang-tools-extra/test/clang-tidy/modernize-pass-by-value-multi-fixes.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// RUN: cat %S/Inputs/modernize-pass-by-value/header-with-fix.h > %T/pass-by-value-header-with-fix.h | ||
// RUN: sed -e 's#//.*$##' %s > %t.cpp | ||
// RUN: clang-tidy %t.cpp -checks='-*,modernize-pass-by-value' -header-filter='.*' -fix -- -std=c++11 -I %T | FileCheck %s -check-prefix=CHECK-MESSAGES -implicit-check-not="{{warning|error}}:" | ||
// RUN: FileCheck -input-file=%t.cpp %s -check-prefix=CHECK-FIXES | ||
// RUN: FileCheck -input-file=%T/pass-by-value-header-with-fix.h %s -check-prefix=CHECK-HEADER-FIXES | ||
|
||
#include "pass-by-value-header-with-fix.h" | ||
// CHECK-HEADER-FIXES: Foo(S s); | ||
Foo::Foo(const S &s) : s(s) {} | ||
// CHECK-MESSAGES: :9:10: warning: pass by value and use std::move [modernize-pass-by-value] | ||
// CHECK-FIXES: #include <utility> | ||
// CHECK-FIXES: Foo::Foo(S s) : s(std::move(s)) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters