Skip to content

Commit b6d12c7

Browse files
committed
do not use static const settings in tests
1 parent 6421481 commit b6d12c7

13 files changed

+23
-25
lines changed

test/helpers.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,3 @@ std::string PreprocessorHelper::getcode(Preprocessor &preprocessor, const std::s
103103

104104
return ret;
105105
}
106-
107-
const Settings givenACodeSampleToTokenize::settings;

test/helpers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Suppressions;
3333
class givenACodeSampleToTokenize {
3434
private:
3535
Tokenizer tokenizer;
36-
static const Settings settings;
36+
const Settings settings;
3737

3838
public:
3939
explicit givenACodeSampleToTokenize(const char sample[], bool createOnly = false, bool cpp = true)

test/testastutils.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class TestAstUtils : public TestFixture {
5050

5151
#define findLambdaEndToken(code) findLambdaEndToken_(code, __FILE__, __LINE__)
5252
bool findLambdaEndToken_(const char code[], const char* file, int line) {
53-
static const Settings settings;
53+
const Settings settings;
5454
Tokenizer tokenizer(&settings, this);
5555
std::istringstream istr(code);
5656
ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line);
@@ -84,7 +84,7 @@ class TestAstUtils : public TestFixture {
8484

8585
#define findLambdaStartToken(code) findLambdaStartToken_(code, __FILE__, __LINE__)
8686
bool findLambdaStartToken_(const char code[], const char* file, int line) {
87-
static const Settings settings;
87+
const Settings settings;
8888
Tokenizer tokenizer(&settings, this);
8989
std::istringstream istr(code);
9090
ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line);
@@ -117,7 +117,7 @@ class TestAstUtils : public TestFixture {
117117

118118
#define isNullOperand(code) isNullOperand_(code, __FILE__, __LINE__)
119119
bool isNullOperand_(const char code[], const char* file, int line) {
120-
static const Settings settings;
120+
const Settings settings;
121121
Tokenizer tokenizer(&settings, this);
122122
std::istringstream istr(code);
123123
ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line);
@@ -139,7 +139,7 @@ class TestAstUtils : public TestFixture {
139139

140140
#define isReturnScope(code, offset) isReturnScope_(code, offset, __FILE__, __LINE__)
141141
bool isReturnScope_(const char code[], int offset, const char* file, int line) {
142-
static const Settings settings;
142+
const Settings settings;
143143
Tokenizer tokenizer(&settings, this);
144144
std::istringstream istr(code);
145145
ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line);
@@ -170,7 +170,7 @@ class TestAstUtils : public TestFixture {
170170

171171
#define isSameExpression(code, tokStr1, tokStr2) isSameExpression_(code, tokStr1, tokStr2, __FILE__, __LINE__)
172172
bool isSameExpression_(const char code[], const char tokStr1[], const char tokStr2[], const char* file, int line) {
173-
static const Settings settings;
173+
const Settings settings;
174174
Library library;
175175
Tokenizer tokenizer(&settings, this);
176176
std::istringstream istr(code);
@@ -210,7 +210,7 @@ class TestAstUtils : public TestFixture {
210210

211211
#define isVariableChanged(code, startPattern, endPattern) isVariableChanged_(code, startPattern, endPattern, __FILE__, __LINE__)
212212
bool isVariableChanged_(const char code[], const char startPattern[], const char endPattern[], const char* file, int line) {
213-
static const Settings settings;
213+
const Settings settings;
214214
Tokenizer tokenizer(&settings, this);
215215
std::istringstream istr(code);
216216
ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line);
@@ -240,7 +240,7 @@ class TestAstUtils : public TestFixture {
240240

241241
#define isVariableChangedByFunctionCall(code, pattern, inconclusive) isVariableChangedByFunctionCall_(code, pattern, inconclusive, __FILE__, __LINE__)
242242
bool isVariableChangedByFunctionCall_(const char code[], const char pattern[], bool *inconclusive, const char* file, int line) {
243-
static const Settings settings;
243+
const Settings settings;
244244
Tokenizer tokenizer(&settings, this);
245245
std::istringstream istr(code);
246246
ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line);
@@ -416,7 +416,7 @@ class TestAstUtils : public TestFixture {
416416

417417
#define nextAfterAstRightmostLeaf(code, parentPattern, rightPattern) nextAfterAstRightmostLeaf_(code, parentPattern, rightPattern, __FILE__, __LINE__)
418418
bool nextAfterAstRightmostLeaf_(const char code[], const char parentPattern[], const char rightPattern[], const char* file, int line) {
419-
static const Settings settings;
419+
const Settings settings;
420420
Tokenizer tokenizer(&settings, this);
421421
std::istringstream istr(code);
422422
ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line);
@@ -441,7 +441,7 @@ class TestAstUtils : public TestFixture {
441441
enum class Result {False, True, Fail};
442442

443443
Result isUsedAsBool(const char code[], const char pattern[]) {
444-
static const Settings settings;
444+
const Settings settings;
445445
Tokenizer tokenizer(&settings, this);
446446
std::istringstream istr(code);
447447
if (!tokenizer.tokenize(istr, "test.cpp"))

test/testbufferoverrun.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5525,7 +5525,7 @@ class TestBufferOverrun : public TestFixture {
55255525

55265526
void checkPipeParameterSize() { // #3521
55275527

5528-
static const Settings settings = settingsBuilder().library("posix.cfg").build();
5528+
const Settings settings = settingsBuilder().library("posix.cfg").build();
55295529

55305530
check("void f(){\n"
55315531
"int pipefd[1];\n" // <-- array of two integers is needed

test/testclangimport.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class TestClangImport : public TestFixture {
137137
}
138138

139139
std::string parse(const char clang[]) {
140-
static const Settings settings = settingsBuilder().clang().build();
140+
const Settings settings = settingsBuilder().clang().build();
141141
Tokenizer tokenizer(&settings, this);
142142
std::istringstream istr(clang);
143143
clangimport::parseClangAstDump(&tokenizer, istr);

test/testclass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8317,7 +8317,7 @@ class TestClass : public TestFixture {
83178317

83188318

83198319
void ctu(const std::vector<std::string> &code) {
8320-
static const Settings settings;
8320+
const Settings settings;
83218321
auto &check = getCheck<CheckClass>();
83228322

83238323
// getFileInfo

test/testconstructors.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1948,7 +1948,7 @@ class TestConstructors : public TestFixture {
19481948

19491949
void initvar_smartptr() { // #10237
19501950
// TODO: test should probably not pass without library
1951-
static const Settings s = settingsBuilder() /*.library("std.cfg")*/.build();
1951+
const Settings s = settingsBuilder() /*.library("std.cfg")*/.build();
19521952
check("struct S {\n"
19531953
" explicit S(const std::shared_ptr<S>& sp) {\n"
19541954
" set(*sp);\n"
@@ -1990,7 +1990,7 @@ class TestConstructors : public TestFixture {
19901990
"{ }", true);
19911991
ASSERT_EQUALS("[test.cpp:13]: (warning, inconclusive) Member variable 'Fred::ints' is not assigned a value in 'Fred::operator='.\n", errout.str());
19921992

1993-
static const Settings s = settingsBuilder().certainty(Certainty::inconclusive).severity(Severity::style).severity(Severity::warning).library("std.cfg").build();
1993+
const Settings s = settingsBuilder().certainty(Certainty::inconclusive).severity(Severity::style).severity(Severity::warning).library("std.cfg").build();
19941994
check("struct S {\n"
19951995
" S& operator=(const S& s) { return *this; }\n"
19961996
" std::mutex m;\n"
@@ -3603,7 +3603,7 @@ class TestConstructors : public TestFixture {
36033603

36043604
void uninitVarInheritClassInit() {
36053605
// TODO: test should probably not pass without library
3606-
static const Settings s = settingsBuilder() /*.library("vcl.cfg")*/.build();
3606+
const Settings s = settingsBuilder() /*.library("vcl.cfg")*/.build();
36073607

36083608
check("class Fred: public TObject\n"
36093609
"{\n"

test/testnullpointer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ class TestNullPointer : public TestFixture {
195195
// Clear the error buffer..
196196
errout.str("");
197197

198-
static const Settings settings1 = settingsBuilder(settings).certainty(Certainty::inconclusive, false).build();
198+
const Settings settings1 = settingsBuilder(settings).certainty(Certainty::inconclusive, false).build();
199199

200200
// Raw tokens..
201201
std::vector<std::string> files(1, "test.cpp");

test/testsimplifytypedef.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ class TestSimplifyTypedef : public TestFixture {
280280
errout.str("");
281281
// Tokenize..
282282
// show warnings about unhandled typedef
283-
static const Settings settings = settingsBuilder(settings2).certainty(Certainty::inconclusive).debugwarnings().build();
283+
const Settings settings = settingsBuilder(settings2).certainty(Certainty::inconclusive).debugwarnings().build();
284284
Tokenizer tokenizer(&settings, this);
285285
std::istringstream istr(code);
286286
ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line);

test/testsummaries.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class TestSummaries : public TestFixture {
4444
errout.str("");
4545

4646
// tokenize..
47-
static const Settings settings;
47+
const Settings settings;
4848
Tokenizer tokenizer(&settings, this);
4949
std::istringstream istr(code);
5050
ASSERT_LOC(tokenizer.tokenize(istr, filename), file, line);

0 commit comments

Comments
 (0)