summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/clang-tidy/readability-redundant-string-cstr-msvc.cpp
diff options
context:
space:
mode:
authorMalcolm Parsons <malcolm.parsons@gmail.com>2016-11-03 12:56:48 +0000
committerMalcolm Parsons <malcolm.parsons@gmail.com>2016-11-03 12:56:48 +0000
commit8b70e2631c6ab4259a4aa9e797c99132fb66e79b (patch)
tree2f6c75fc3c1c324c2d6f2def8d14a9c97e25279c /clang-tools-extra/test/clang-tidy/readability-redundant-string-cstr-msvc.cpp
parenta705ab175d2b6b6ae0edb234b49a76fe6db38144 (diff)
downloadbcm5719-llvm-8b70e2631c6ab4259a4aa9e797c99132fb66e79b.tar.gz
bcm5719-llvm-8b70e2631c6ab4259a4aa9e797c99132fb66e79b.zip
[clang-tidy] Handle data() in readability-redundant-string-cstr
Summary: std::string::data() and std::string::c_str() are equivalent. Enhance the readability-redundant-string-cstr check to also handle calls to data(). Reviewers: etienneb, alexfh, aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D26279 llvm-svn: 285901
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/readability-redundant-string-cstr-msvc.cpp')
-rw-r--r--clang-tools-extra/test/clang-tidy/readability-redundant-string-cstr-msvc.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/clang-tools-extra/test/clang-tidy/readability-redundant-string-cstr-msvc.cpp b/clang-tools-extra/test/clang-tidy/readability-redundant-string-cstr-msvc.cpp
index 1c31118dbc6..a6b6b20728c 100644
--- a/clang-tools-extra/test/clang-tidy/readability-redundant-string-cstr-msvc.cpp
+++ b/clang-tools-extra/test/clang-tidy/readability-redundant-string-cstr-msvc.cpp
@@ -12,6 +12,7 @@ struct basic_string {
basic_string(const C *p);
basic_string(const C *p, const A &a);
const C *c_str() const;
+ const C *data() const;
};
typedef basic_string<char, std::char_traits<char>, std::allocator<char>> string;
}
@@ -24,7 +25,10 @@ struct StringRef {
void f1(const std::string &s) {
f1(s.c_str());
- // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to `c_str()` [readability-redundant-string-cstr]
+ // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to 'c_str' [readability-redundant-string-cstr]
+ // CHECK-FIXES: {{^ }}f1(s);{{$}}
+ f1(s.data());
+ // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to 'data' [readability-redundant-string-cstr]
// CHECK-FIXES: {{^ }}f1(s);{{$}}
}
void f2(const llvm::StringRef r) {
OpenPOWER on IntegriCloud