Prazek updated this revision to Diff 61665. Prazek added a comment. - small fix
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: 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()); +} 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()); }
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: 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()); +} 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()); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits