summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/clang-tidy/boost-use-to-string.cpp
diff options
context:
space:
mode:
authorPiotr Padlewski <piotr.padlewski@gmail.com>2016-06-28 08:16:20 +0000
committerPiotr Padlewski <piotr.padlewski@gmail.com>2016-06-28 08:16:20 +0000
commitb0869a7522702654d9255d6b37590e48837263ac (patch)
treeac250fa66506deadf1816679f94a1d821ffa27b0 /clang-tools-extra/test/clang-tidy/boost-use-to-string.cpp
parenteee4711fbe5ecf919e0c440ebaec8c1c213dc007 (diff)
downloadbcm5719-llvm-b0869a7522702654d9255d6b37590e48837263ac.tar.gz
bcm5719-llvm-b0869a7522702654d9255d6b37590e48837263ac.zip
[clang-tidy] boost-use-to-string arg expr location bugfix
Summary: getExprLoc returns location after dot for member call. Reviewers: alexfh, sbenza, hokein Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D21642 llvm-svn: 274001
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/boost-use-to-string.cpp')
-rw-r--r--clang-tools-extra/test/clang-tidy/boost-use-to-string.cpp50
1 files changed, 35 insertions, 15 deletions
diff --git a/clang-tools-extra/test/clang-tidy/boost-use-to-string.cpp b/clang-tools-extra/test/clang-tidy/boost-use-to-string.cpp
index fe7a3a01285..80736332e60 100644
--- a/clang-tools-extra/test/clang-tidy/boost-use-to-string.cpp
+++ b/clang-tools-extra/test/clang-tidy/boost-use-to-string.cpp
@@ -27,7 +27,7 @@ void test_to_string1() {
// CHECK-FIXES: auto xa = std::to_string(5);
auto z = boost::lexical_cast<std::string>(42LL);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use std::to_string {{..}}
+ // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use std::to_string
// CHECK-FIXES: auto z = std::to_string(42LL);
// this should not trigger
@@ -49,22 +49,22 @@ void test_to_string2() {
bool j;
fun(boost::lexical_cast<std::string>(a));
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string {{..}}
+ // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string
// CHECK-FIXES: fun(std::to_string(a));
fun(boost::lexical_cast<std::string>(b));
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string {{..}}
+ // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string
// CHECK-FIXES: fun(std::to_string(b));
fun(boost::lexical_cast<std::string>(c));
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string {{..}}
+ // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string
// CHECK-FIXES: fun(std::to_string(c));
fun(boost::lexical_cast<std::string>(d));
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string {{..}}
+ // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string
// CHECK-FIXES: fun(std::to_string(d));
fun(boost::lexical_cast<std::string>(e));
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string {{..}}
+ // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string
// CHECK-FIXES: fun(std::to_string(e));
fun(boost::lexical_cast<std::string>(f));
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string {{..}}
+ // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string
// CHECK-FIXES: fun(std::to_string(f));
// No change for floating numbers.
@@ -93,19 +93,19 @@ void test_to_wstring() {
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_wstring instead of boost::lexical_cast<std::wstring> [boost-use-to-string]
// CHECK-FIXES: fun(std::to_wstring(a));
fun(boost::lexical_cast<std::wstring>(b));
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_wstring {{..}}
+ // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_wstring
// CHECK-FIXES: fun(std::to_wstring(b));
fun(boost::lexical_cast<std::wstring>(c));
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_wstring {{..}}
+ // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_wstring
// CHECK-FIXES: fun(std::to_wstring(c));
fun(boost::lexical_cast<std::wstring>(d));
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_wstring {{..}}
+ // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_wstring
// CHECK-FIXES: fun(std::to_wstring(d));
fun(boost::lexical_cast<std::wstring>(e));
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_wstring {{..}}
+ // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_wstring
// CHECK-FIXES: fun(std::to_wstring(e));
fun(boost::lexical_cast<std::wstring>(f));
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_wstring {{..}}
+ // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_wstring
// CHECK-FIXES: fun(std::to_wstring(f));
// No change for floating numbers
@@ -117,13 +117,13 @@ void test_to_wstring() {
}
const auto glob = boost::lexical_cast<std::string>(42);
-// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use std::to_string{{..}}
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use std::to_string
// CHECK-FIXES: const auto glob = std::to_string(42);
template <typename T>
void string_as_T(T t = T()) {
boost::lexical_cast<std::string>(42);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use std::to_string{{..}}
+ // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use std::to_string
// CHECK-FIXES: std::to_string(42);
boost::lexical_cast<T>(42);
@@ -137,7 +137,7 @@ void string_as_T(T t = T()) {
void no_fixup_inside_macro() {
my_to_string(12);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use std::to_string{{..}}
+ // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use std::to_string
}
void no_warnings() {
@@ -147,3 +147,23 @@ void no_warnings() {
string_as_T<int>();
string_as_T<std::string>();
}
+
+struct Fields {
+ int integer;
+ float floating;
+ Fields* wierd;
+ const int &getConstInteger() const {return integer;}
+};
+
+void testFields() {
+ Fields fields;
+ auto s1 = boost::lexical_cast<std::string>(fields.integer);
+ // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::to_string
+ // CHECK-FIXES: auto s1 = std::to_string(fields.integer);
+
+ auto s2 = boost::lexical_cast<std::string>(fields.floating);
+ auto s3 = boost::lexical_cast<std::string>(fields.wierd);
+ auto s4 = boost::lexical_cast<std::string>(fields.getConstInteger());
+ // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::to_string
+ // CHECK-FIXES: auto s4 = std::to_string(fields.getConstInteger());
+}
OpenPOWER on IntegriCloud