diff options
author | dcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-03 05:39:56 +0000 |
---|---|---|
committer | dcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-03 05:39:56 +0000 |
commit | 3133e5597cbaa0c024bf56ed97edfccc5ef0c4e2 (patch) | |
tree | cbbe29511b2bef2072022dca6a982b0a2525db4d /tools/clang | |
parent | a937b22da2c1853299568aadfa72e5f248ee63ed (diff) | |
download | chromium_src-3133e5597cbaa0c024bf56ed97edfccc5ef0c4e2.zip chromium_src-3133e5597cbaa0c024bf56ed97edfccc5ef0c4e2.tar.gz chromium_src-3133e5597cbaa0c024bf56ed97edfccc5ef0c4e2.tar.bz2 |
Add std::wstring support to the empty string tool and update the tests.
BUG=none
TEST=test_tool.py empty_string
Review URL: https://codereview.chromium.org/13505002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@191998 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/clang')
-rw-r--r-- | tools/clang/empty_string/EmptyStringConverter.cpp | 7 | ||||
-rw-r--r-- | tools/clang/empty_string/tests/test-expected.cc | 8 | ||||
-rw-r--r-- | tools/clang/empty_string/tests/test-original.cc | 8 |
3 files changed, 21 insertions, 2 deletions
diff --git a/tools/clang/empty_string/EmptyStringConverter.cpp b/tools/clang/empty_string/EmptyStringConverter.cpp index a9cc4b0..bfdf7ef 100644 --- a/tools/clang/empty_string/EmptyStringConverter.cpp +++ b/tools/clang/empty_string/EmptyStringConverter.cpp @@ -152,13 +152,16 @@ void TemporaryCallback::run(const MatchFinder::MatchResult& result) { result.Nodes.getNodeAs<clang::CXXConstructExpr>("call"); // Differentiate between explicit and implicit calls to std::string's // constructor. An implicitly generated constructor won't have a valid - // source range for the parenthesis. + // source range for the parenthesis. We do this because the matched expression + // for |call| in the explicit case doesn't include the closing parenthesis. clang::SourceRange range = call->getParenRange(); if (range.isValid()) { replacements_->insert(Replacement(*result.SourceManager, literal, "")); } else { replacements_->insert( - Replacement(*result.SourceManager, call, "std::string()")); + Replacement(*result.SourceManager, + call, + literal->isWide() ? "std::wstring()" : "std::string()")); } } diff --git a/tools/clang/empty_string/tests/test-expected.cc b/tools/clang/empty_string/tests/test-expected.cc index 88877b1..e915625 100644 --- a/tools/clang/empty_string/tests/test-expected.cc +++ b/tools/clang/empty_string/tests/test-expected.cc @@ -36,3 +36,11 @@ void TestTemporaries(const std::string& reference_argument, TestTemporaries(std::string(), std::string()); TestTemporaries(std::string(), std::string()); } + +// Tests for temporary std::wstrings. +void TestWideTemporaries(const std::wstring& reference_argument, + const std::wstring value_argument) { + TestWideTemporaries(std::wstring(), std::wstring()); + TestWideTemporaries(std::wstring(), std::wstring()); +} + diff --git a/tools/clang/empty_string/tests/test-original.cc b/tools/clang/empty_string/tests/test-original.cc index f86fd08..2edb896 100644 --- a/tools/clang/empty_string/tests/test-original.cc +++ b/tools/clang/empty_string/tests/test-original.cc @@ -36,3 +36,11 @@ void TestTemporaries(const std::string& reference_argument, TestTemporaries("", ""); TestTemporaries(std::string(""), std::string("")); } + +// Tests for temporary std::wstrings. +void TestWideTemporaries(const std::wstring& reference_argument, + const std::wstring value_argument) { + TestWideTemporaries(L"", L""); + TestWideTemporaries(std::wstring(L""), std::wstring(L"")); +} + |