[PATCH] D21642: [clang-tidy] boost-use-to-string arg expr location bugfix
Piotr Padlewski via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 23 04:52:38 PDT 2016
Prazek created this revision.
Prazek added reviewers: alexfh, sbenza, hokein.
Prazek added a subscriber: cfe-commits.
getExprLoc returns location after dot for member call.
http://reviews.llvm.org/D21642
Files:
clang-tidy/boost/UseToStringCheck.cpp
test/clang-tidy/boost-use-to-string.cpp
Index: test/clang-tidy/boost-use-to-string.cpp
===================================================================
--- test/clang-tidy/boost-use-to-string.cpp
+++ test/clang-tidy/boost-use-to-string.cpp
@@ -147,3 +147,23 @@
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: 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: std::to_string(fields.getConstInteger());
+}
Index: clang-tidy/boost/UseToStringCheck.cpp
===================================================================
--- clang-tidy/boost/UseToStringCheck.cpp
+++ clang-tidy/boost/UseToStringCheck.cpp
@@ -64,7 +64,7 @@
Diag << FixItHint::CreateReplacement(
CharSourceRange::getCharRange(Call->getLocStart(),
- Call->getArg(0)->getExprLoc()),
+ Call->getArg(0)->getLocStart()),
(llvm::Twine("std::to_") + StringType + "(").str());
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21642.61663.patch
Type: text/x-patch
Size: 1498 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160623/30fe0df4/attachment.bin>
More information about the cfe-commits
mailing list