summaryrefslogtreecommitdiff
path: root/test/clang-tidy
diff options
context:
space:
mode:
authorHaojian Wu <hokein@google.com>2016-03-02 09:01:25 +0000
committerHaojian Wu <hokein@google.com>2016-03-02 09:01:25 +0000
commit62358480616d142e25ce89a390563a5c372472d1 (patch)
tree45a7625c24129b6e30abfd1ca4b99264ea2317fd /test/clang-tidy
parentc7cb34bf92d879ef0adba21d86db2ee0668e2682 (diff)
downloadclang-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.h7
-rw-r--r--test/clang-tidy/modernize-pass-by-value-header.cpp8
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)) {}