Skip to content

Commit

Permalink
[clang-tidy] Container-size-empty fixed c++ version in tests to suppo…
Browse files Browse the repository at this point in the history
…rt string_literals operator

The goal of this PR is to properly implement the std::string_literals::operator""s that was added in commit (4001ae1) but was later changed in commit (ba52a10).

The operator""s was added in c++14 but we were running tests under c++11 which would raise an error when compiling the file.

Reviewed By: PiotrZSL

Differential Revision: https://reviews.llvm.org/D158691
  • Loading branch information
felix642 authored and PiotrZSL committed Aug 26, 2023
1 parent 0c9c9dd commit ffad4f8
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %check_clang_tidy %s readability-container-size-empty %t -- \
// RUN: %check_clang_tidy -std=c++14-or-later %s readability-container-size-empty %t -- \
// RUN: -config="{CheckOptions: {readability-container-size-empty.ExcludedComparisonTypes: '::std::array;::IgnoredDummyType'}}" \
// RUN: -- -fno-delayed-template-parsing -isystem %clang_tidy_headers
#include <string>
Expand All @@ -23,7 +23,7 @@ template <typename T> struct set {
}

namespace string_literals{
string operator""_s(const char *, size_t);
string operator""s(const char *, size_t);
}

}
Expand Down Expand Up @@ -778,13 +778,13 @@ bool testIgnoredDummyType(const IgnoredDummyType& value) {
bool testStringLiterals(const std::string& s)
{
using namespace std::string_literals;
return s == ""_s;
return s == ""s;
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: the 'empty' method should be used
// CHECK-FIXES: {{^ }}return s.empty()
}

bool testNotEmptyStringLiterals(const std::string& s)
{
using namespace std::string_literals;
return s == "foo"_s;
return s == "foo"s;
}

0 comments on commit ffad4f8

Please sign in to comment.