Skip to content

Commit 5cf7cb9

Browse files
committed
Conforming style: always use 'std::' namespace where needed. This removes the mixing style inside the code.
1 parent a83c47d commit 5cf7cb9

1 file changed

Lines changed: 15 additions & 17 deletions

File tree

lib/checkinternal.cpp

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
#include <string>
2424
#include <set>
2525

26-
using namespace std;
27-
2826
// Register this check class (by creating a static instance of it).
2927
// Disabled in release builds
3028
namespace {
@@ -44,16 +42,16 @@ void CheckInternal::checkTokenMatchPatterns()
4442
if (!pattern_tok || !Token::Match(pattern_tok, "%str%"))
4543
continue;
4644

47-
const string pattern = pattern_tok->strValue();
45+
const std::string pattern = pattern_tok->strValue();
4846
if (pattern.empty()) {
4947
simplePatternError(tok, pattern, funcname);
5048
continue;
5149
}
5250

5351
// Check for signs of complex patterns
54-
if (pattern.find_first_of("[|%") != string::npos)
52+
if (pattern.find_first_of("[|%") != std::string::npos)
5553
continue;
56-
else if (pattern.find("!!") != string::npos)
54+
else if (pattern.find("!!") != std::string::npos)
5755
continue;
5856

5957
simplePatternError(tok, pattern, funcname);
@@ -73,15 +71,15 @@ void CheckInternal::checkTokenSimpleMatchPatterns()
7371
if (!pattern_tok || !Token::Match(pattern_tok, "%str%"))
7472
continue;
7573

76-
const string pattern = pattern_tok->strValue();
74+
const std::string pattern = pattern_tok->strValue();
7775
if (pattern.empty()) {
7876
complexPatternError(tok, pattern, funcname);
7977
continue;
8078
}
8179

8280
// Check for [xyz] usage - but exclude standalone square brackets
8381
unsigned int char_count = 0;
84-
for (string::size_type pos = 0; pos < pattern.size(); ++pos) {
82+
for (std::string::size_type pos = 0; pos < pattern.size(); ++pos) {
8583
char c = pattern[pos];
8684

8785
if (c == ' ') {
@@ -98,7 +96,7 @@ void CheckInternal::checkTokenSimpleMatchPatterns()
9896

9997
// Check | usage: Count characters before the symbol
10098
char_count = 0;
101-
for (string::size_type pos = 0; pos < pattern.size(); ++pos) {
99+
for (std::string::size_type pos = 0; pos < pattern.size(); ++pos) {
102100
char c = pattern[pos];
103101

104102
if (c == ' ') {
@@ -114,14 +112,14 @@ void CheckInternal::checkTokenSimpleMatchPatterns()
114112
}
115113

116114
// Check for real errors
117-
if (pattern.find_first_of("%") != string::npos || pattern.find("!!") != string::npos)
115+
if (pattern.find_first_of("%") != std::string::npos || pattern.find("!!") != std::string::npos)
118116
complexPatternError(tok, pattern, funcname);
119117
}
120118
}
121119

122120
void CheckInternal::checkMissingPercentCharacter()
123121
{
124-
set<string> magics;
122+
std::set<std::string> magics;
125123
magics.insert("%any%");
126124
magics.insert("%var%");
127125
magics.insert("%type%");
@@ -143,14 +141,14 @@ void CheckInternal::checkMissingPercentCharacter()
143141
if (!pattern_tok || !Token::Match(pattern_tok, "%str%"))
144142
continue;
145143

146-
const string pattern = pattern_tok->strValue();
144+
const std::string pattern = pattern_tok->strValue();
147145

148-
set<string>::const_iterator magic, magics_end = magics.end();
146+
std::set<std::string>::const_iterator magic, magics_end = magics.end();
149147
for (magic = magics.begin(); magic != magics_end; ++magic) {
150-
const string broken_magic = (*magic).substr(0, (*magic).size()-1);
148+
const std::string broken_magic = (*magic).substr(0, (*magic).size()-1);
151149

152-
string::size_type pos = 0;
153-
while ((pos = pattern.find(broken_magic, pos)) != string::npos) {
150+
std::string::size_type pos = 0;
151+
while ((pos = pattern.find(broken_magic, pos)) != std::string::npos) {
154152
// Check if it's the full pattern
155153
if (pattern.find(*magic, pos) != pos) {
156154
// Known whitelist of substrings
@@ -169,14 +167,14 @@ void CheckInternal::checkMissingPercentCharacter()
169167
}
170168
}
171169

172-
void CheckInternal::simplePatternError(const Token* tok, const string& pattern, const std::string &funcname)
170+
void CheckInternal::simplePatternError(const Token* tok, const std::string& pattern, const std::string &funcname)
173171
{
174172
reportError(tok, Severity::warning, "simplePatternError",
175173
"Found simple pattern inside Token::" + funcname + "() call: \"" + pattern + "\""
176174
);
177175
}
178176

179-
void CheckInternal::complexPatternError(const Token* tok, const string& pattern, const std::string &funcname)
177+
void CheckInternal::complexPatternError(const Token* tok, const std::string& pattern, const std::string &funcname)
180178
{
181179
reportError(tok, Severity::error, "complexPatternError",
182180
"Found complex pattern inside Token::" + funcname + "() call: \"" + pattern + "\""

0 commit comments

Comments
 (0)