Skip to content

Commit 088beb6

Browse files
committed
fixed readability-redundant-string-cstr clang-tidy warnings
1 parent a294535 commit 088beb6

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

test/testtoken.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class TestToken : public TestFixture {
141141
SimpleTokenizer tokenizer(settingsDefault, *this);
142142
const std::string code2 = ";" + code + ";";
143143
try {
144-
ASSERT_LOC(tokenizer.tokenize(code2.c_str()), file, line);
144+
ASSERT_LOC(tokenizer.tokenize(code2), file, line);
145145
} catch (...) {}
146146
return Token::Match(tokenizer.tokens()->next(), pattern.c_str(), varid);
147147
}

test/testtokenize.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ class TestTokenizer : public TestFixture {
931931

932932
void longtok() {
933933
const std::string filedata(10000, 'a');
934-
ASSERT_EQUALS(filedata, tokenizeAndStringify(filedata.c_str()));
934+
ASSERT_EQUALS(filedata, tokenizeAndStringify(filedata));
935935
}
936936

937937

@@ -6934,7 +6934,7 @@ class TestTokenizer : public TestFixture {
69346934
const std::string filedata = tokens1.stringify();
69356935
const std::string code = PreprocessorHelper::getcode(settings0, *this, filedata, emptyString, emptyString);
69366936

6937-
ASSERT_THROW_INTERNAL(tokenizeAndStringify(code.c_str()), AST);
6937+
ASSERT_THROW_INTERNAL(tokenizeAndStringify(code), AST);
69386938
}
69396939

69406940
#define isStartOfExecutableScope(offset, code) isStartOfExecutableScope_(offset, code, __FILE__, __LINE__)

test/testtype.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,13 @@ class TestType : public TestFixture {
9797
{
9898
const std::string types[] = {"unsigned char", /*[unsigned]*/ "char", "bool", "unsigned short", "unsigned int", "unsigned long"};
9999
for (const std::string& type : types) {
100-
check((type + " f(" + type +" x) { return x << 31; }").c_str(), settings);
100+
check(type + " f(" + type +" x) { return x << 31; }", settings);
101101
ASSERT_EQUALS("", errout_str());
102-
check((type + " f(" + type +" x) { return x << 33; }").c_str(), settings);
102+
check(type + " f(" + type +" x) { return x << 33; }", settings);
103103
ASSERT_EQUALS("[test.cpp:1]: (error) Shifting 32-bit value by 33 bits is undefined behaviour\n", errout_str());
104-
check((type + " f(int x) { return (x = (" + type + ")x << 32); }").c_str(), settings);
104+
check(type + " f(int x) { return (x = (" + type + ")x << 32); }", settings);
105105
ASSERT_EQUALS("[test.cpp:1]: (error) Shifting 32-bit value by 32 bits is undefined behaviour\n", errout_str());
106-
check((type + " foo(" + type + " x) { return x << 31; }").c_str(), settings);
106+
check(type + " foo(" + type + " x) { return x << 31; }", settings);
107107
ASSERT_EQUALS("", errout_str());
108108
}
109109
}
@@ -113,19 +113,19 @@ class TestType : public TestFixture {
113113
const std::string types[] = {"signed char", "signed short", /*[signed]*/ "short", "wchar_t", /*[signed]*/ "int", "signed int", /*[signed]*/ "long", "signed long"};
114114
for (const std::string& type : types) {
115115
// c++11
116-
check((type + " f(" + type +" x) { return x << 33; }").c_str(), settings);
116+
check(type + " f(" + type +" x) { return x << 33; }", settings);
117117
ASSERT_EQUALS("[test.cpp:1]: (error) Shifting 32-bit value by 33 bits is undefined behaviour\n", errout_str());
118-
check((type + " f(int x) { return (x = (" + type + ")x << 32); }").c_str(), settings);
118+
check(type + " f(int x) { return (x = (" + type + ")x << 32); }", settings);
119119
ASSERT_EQUALS("[test.cpp:1]: (error) Shifting 32-bit value by 32 bits is undefined behaviour\n", errout_str());
120-
check((type + " foo(" + type + " x) { return x << 31; }").c_str(), settings);
120+
check(type + " foo(" + type + " x) { return x << 31; }", settings);
121121
ASSERT_EQUALS("[test.cpp:1]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour\n", errout_str());
122-
check((type + " foo(" + type + " x) { return x << 30; }").c_str(), settings);
122+
check(type + " foo(" + type + " x) { return x << 30; }", settings);
123123
ASSERT_EQUALS("", errout_str());
124124

125125
// c++14
126-
check((type + " foo(" + type + " x) { return x << 31; }").c_str(), settings, true, Standards::cppstd_t::CPP14);
126+
check(type + " foo(" + type + " x) { return x << 31; }", settings, true, Standards::cppstd_t::CPP14);
127127
ASSERT_EQUALS("[test.cpp:1]: (portability) Shifting signed 32-bit value by 31 bits is implementation-defined behaviour\n", errout_str());
128-
check((type + " f(int x) { return (x = (" + type + ")x << 32); }").c_str(), settings, true, Standards::cppstd_t::CPP14);
128+
check(type + " f(int x) { return (x = (" + type + ")x << 32); }", settings, true, Standards::cppstd_t::CPP14);
129129
ASSERT_EQUALS("[test.cpp:1]: (error) Shifting 32-bit value by 32 bits is undefined behaviour\n", errout_str());
130130
}
131131
}

test/testunusedfunctions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ class TestUnusedFunctions : public TestFixture {
697697
const char code[] = R"(#include "test.h")";
698698
ScopedFile header("test.h", inc);
699699
const std::string processed = PreprocessorHelper::getcode(settings, *this, code, "", "test.cpp");
700-
check(processed.c_str());
700+
check(processed);
701701
TODO_ASSERT_EQUALS("[test.h:3]: (style) The function 'f' is never used.\n", "[test.cpp:3]: (style) The function 'f' is never used.\n", errout_str());
702702
}
703703
};

0 commit comments

Comments
 (0)