diff options
author | Haojian Wu <hokein@google.com> | 2016-03-02 09:01:25 +0000 |
---|---|---|
committer | Haojian Wu <hokein@google.com> | 2016-03-02 09:01:25 +0000 |
commit | 62358480616d142e25ce89a390563a5c372472d1 (patch) | |
tree | 45a7625c24129b6e30abfd1ca4b99264ea2317fd /test/clang-tidy | |
parent | c7cb34bf92d879ef0adba21d86db2ee0668e2682 (diff) | |
download | clang-tools-extra-62358480616d142e25ce89a390563a5c372472d1.tar.gz |
[clang-tidy] Make 'modernize-pass-by-value' fix work on header files.
Reviewers: alexfh
Subscribers: jbcoe, cfe-commits
Differential Revision: http://reviews.llvm.org/D17756
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@262470 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/clang-tidy')
-rw-r--r-- | test/clang-tidy/Inputs/modernize-pass-by-value/header.h | 7 | ||||
-rw-r--r-- | test/clang-tidy/modernize-pass-by-value-header.cpp | 8 |
2 files changed, 15 insertions, 0 deletions
diff --git a/test/clang-tidy/Inputs/modernize-pass-by-value/header.h b/test/clang-tidy/Inputs/modernize-pass-by-value/header.h new file mode 100644 index 00000000..81c73d34 --- /dev/null +++ b/test/clang-tidy/Inputs/modernize-pass-by-value/header.h @@ -0,0 +1,7 @@ +class ThreadId { +}; + +struct A { + A(const ThreadId &tid) : threadid(tid) {} + ThreadId threadid; +}; diff --git a/test/clang-tidy/modernize-pass-by-value-header.cpp b/test/clang-tidy/modernize-pass-by-value-header.cpp new file mode 100644 index 00000000..91d8fcec --- /dev/null +++ b/test/clang-tidy/modernize-pass-by-value-header.cpp @@ -0,0 +1,8 @@ +// RUN: cp %S/Inputs/modernize-pass-by-value/header.h %T/pass-by-value-header.h +// RUN: clang-tidy %s -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/pass-by-value-header.h %s -check-prefix=CHECK-FIXES + +#include "pass-by-value-header.h" +// CHECK-MESSAGES: :5:5: warning: pass by value and use std::move [modernize-pass-by-value] +// CHECK-FIXES: #include <utility> +// CHECK-FIXES: A(ThreadId tid) : threadid(std::move(tid)) {} |