Fixed the grammar in some reportError messages in the Tokenizer class, thanks to kimmov's suggestion.
This commit is contained in:
parent
dd5e9aa454
commit
08ae15e42d
|
@ -440,7 +440,7 @@ void Tokenizer::duplicateTypedefError(const Token *tok1, const Token *tok2, cons
|
|||
const std::string tok2_str = tok2 ? tok2->str():std::string("name");
|
||||
|
||||
reportError(locationList, Severity::style, "variableHidingTypedef",
|
||||
std::string(type + " '" + tok2_str + "' hides typedef with same name"), true);
|
||||
std::string("The " + type + " '" + tok2_str + "' hides a typedef with the same name."), true);
|
||||
}
|
||||
|
||||
void Tokenizer::duplicateDeclarationError(const Token *tok1, const Token *tok2, const std::string &type)
|
||||
|
@ -454,7 +454,7 @@ void Tokenizer::duplicateDeclarationError(const Token *tok1, const Token *tok2,
|
|||
const std::string tok2_str = tok2 ? tok2->str():std::string("name");
|
||||
|
||||
reportError(locationList, Severity::style, "unnecessaryForwardDeclaration",
|
||||
std::string(type + " '" + tok2_str + "' forward declaration unnecessary, already declared"));
|
||||
std::string("The " + type + " '" + tok2_str + "' forward declaration is unnecessary. Type " + type + " is already declared earlier."));
|
||||
}
|
||||
|
||||
// check if this statement is a duplicate definition
|
||||
|
@ -501,12 +501,12 @@ bool Tokenizer::duplicateTypedef(Token **tokPtr, const Token *name, const Token
|
|||
if (!Token::Match(tok->tokAt(-3), ",|<"))
|
||||
return false;
|
||||
|
||||
duplicateTypedefError(*tokPtr, name, "Template instantiation");
|
||||
duplicateTypedefError(*tokPtr, name, "template instantiation");
|
||||
*tokPtr = end->link();
|
||||
return true;
|
||||
} else if (Token::Match(tok->previous(), "%type%")) {
|
||||
if (end->link()->next()->str() == "{") {
|
||||
duplicateTypedefError(*tokPtr, name, "Function");
|
||||
duplicateTypedefError(*tokPtr, name, "function");
|
||||
*tokPtr = end->link()->next()->link();
|
||||
return true;
|
||||
}
|
||||
|
@ -518,7 +518,7 @@ bool Tokenizer::duplicateTypedef(Token **tokPtr, const Token *name, const Token
|
|||
// look backwards
|
||||
if (Token::Match(tok->previous(), "%type%") &&
|
||||
!Token::Match(tok->previous(), "return|new|const")) {
|
||||
duplicateTypedefError(*tokPtr, name, "Function parameter");
|
||||
duplicateTypedefError(*tokPtr, name, "function parameter");
|
||||
// duplicate definition so skip entire function
|
||||
*tokPtr = end->next()->link();
|
||||
return true;
|
||||
|
@ -531,7 +531,7 @@ bool Tokenizer::duplicateTypedef(Token **tokPtr, const Token *name, const Token
|
|||
while (end && end->str() != "{")
|
||||
end = end->next();
|
||||
if (end) {
|
||||
duplicateTypedefError(*tokPtr, name, "Template parameter");
|
||||
duplicateTypedefError(*tokPtr, name, "template parameter");
|
||||
*tokPtr = end->link();
|
||||
return true;
|
||||
}
|
||||
|
@ -549,10 +549,10 @@ bool Tokenizer::duplicateTypedef(Token **tokPtr, const Token *name, const Token
|
|||
if (tok->previous()->str() == "}") {
|
||||
tok = tok->previous()->link();
|
||||
} else if (tok->previous()->str() == "typedef") {
|
||||
duplicateTypedefError(*tokPtr, name, "Typedef");
|
||||
duplicateTypedefError(*tokPtr, name, "typedef");
|
||||
return true;
|
||||
} else if (tok->previous()->str() == "enum") {
|
||||
duplicateTypedefError(*tokPtr, name, "Enum");
|
||||
duplicateTypedefError(*tokPtr, name, "enum");
|
||||
return true;
|
||||
} else if (tok->previous()->str() == "struct") {
|
||||
if (tok->strAt(-2) == "typedef" &&
|
||||
|
@ -562,36 +562,36 @@ bool Tokenizer::duplicateTypedef(Token **tokPtr, const Token *name, const Token
|
|||
return true;
|
||||
} else if (tok->next()->str() == "{") {
|
||||
if (!undefinedStruct)
|
||||
duplicateTypedefError(*tokPtr, name, "Struct");
|
||||
duplicateTypedefError(*tokPtr, name, "struct");
|
||||
return true;
|
||||
} else if (Token::Match(tok->next(), ")|*")) {
|
||||
return true;
|
||||
} else if (tok->next()->str() == name->str()) {
|
||||
return true;
|
||||
} else if (tok->next()->str() != ";") {
|
||||
duplicateTypedefError(*tokPtr, name, "Struct");
|
||||
duplicateTypedefError(*tokPtr, name, "struct");
|
||||
return true;
|
||||
} else {
|
||||
// forward declaration after declaration
|
||||
duplicateDeclarationError(*tokPtr, name, "Struct");
|
||||
duplicateDeclarationError(*tokPtr, name, "struct");
|
||||
return false;
|
||||
}
|
||||
} else if (tok->previous()->str() == "union") {
|
||||
if (tok->next()->str() != ";") {
|
||||
duplicateTypedefError(*tokPtr, name, "Union");
|
||||
duplicateTypedefError(*tokPtr, name, "union");
|
||||
return true;
|
||||
} else {
|
||||
// forward declaration after declaration
|
||||
duplicateDeclarationError(*tokPtr, name, "Union");
|
||||
duplicateDeclarationError(*tokPtr, name, "union");
|
||||
return false;
|
||||
}
|
||||
} else if (tok->previous()->str() == "class") {
|
||||
if (tok->next()->str() != ";") {
|
||||
duplicateTypedefError(*tokPtr, name, "Class");
|
||||
duplicateTypedefError(*tokPtr, name, "class");
|
||||
return true;
|
||||
} else {
|
||||
// forward declaration after declaration
|
||||
duplicateDeclarationError(*tokPtr, name, "Class");
|
||||
duplicateDeclarationError(*tokPtr, name, "class");
|
||||
return false;
|
||||
}
|
||||
} else if (tok->previous()->str() == "{")
|
||||
|
@ -600,7 +600,7 @@ bool Tokenizer::duplicateTypedef(Token **tokPtr, const Token *name, const Token
|
|||
tok = tok->previous();
|
||||
}
|
||||
|
||||
duplicateTypedefError(*tokPtr, name, "Variable");
|
||||
duplicateTypedefError(*tokPtr, name, "variable");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -8113,9 +8113,9 @@ void Tokenizer::getErrorMessages(ErrorLogger *errorLogger, const Settings *setti
|
|||
Tokenizer t(settings, errorLogger);
|
||||
t.syntaxError(0, ' ');
|
||||
t.cppcheckError(0);
|
||||
t.duplicateTypedefError(0, 0, "Variable");
|
||||
t.duplicateDeclarationError(0, 0, "Variable");
|
||||
t.duplicateEnumError(0, 0, "Variable");
|
||||
t.duplicateTypedefError(0, 0, "variable");
|
||||
t.duplicateDeclarationError(0, 0, "variable");
|
||||
t.duplicateEnumError(0, 0, "variable");
|
||||
t.unnecessaryQualificationError(0, "type");
|
||||
}
|
||||
|
||||
|
@ -8995,7 +8995,7 @@ void Tokenizer::removeUnnecessaryQualification()
|
|||
void Tokenizer::unnecessaryQualificationError(const Token *tok, const std::string &qualification)
|
||||
{
|
||||
reportError(tok, Severity::portability, "unnecessaryQualification",
|
||||
"Extra qualification \'" + qualification + "\' unnecessary and considered an error by many compilers.");
|
||||
"The extra qualification \'" + qualification + "\' is unnecessary and is considered an error by many compilers.");
|
||||
}
|
||||
|
||||
void Tokenizer::simplifyReturnStrncat()
|
||||
|
|
|
@ -4362,10 +4362,10 @@ private:
|
|||
ASSERT_EQUALS(expected, tok(code, false));
|
||||
|
||||
checkSimplifyTypedef(code);
|
||||
ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:1]: (style) Typedef 'A' hides typedef with same name\n"
|
||||
"[test.cpp:20] -> [test.cpp:1]: (style) Function parameter 'A' hides typedef with same name\n"
|
||||
"[test.cpp:21] -> [test.cpp:1]: (style) Variable 'A' hides typedef with same name\n"
|
||||
"[test.cpp:24] -> [test.cpp:1]: (style) Typedef 'A' hides typedef with same name\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:1]: (style) The typedef 'A' hides a typedef with the same name.\n"
|
||||
"[test.cpp:20] -> [test.cpp:1]: (style) The function parameter 'A' hides a typedef with the same name.\n"
|
||||
"[test.cpp:21] -> [test.cpp:1]: (style) The variable 'A' hides a typedef with the same name.\n"
|
||||
"[test.cpp:24] -> [test.cpp:1]: (style) The typedef 'A' hides a typedef with the same name.\n", errout.str());
|
||||
}
|
||||
|
||||
void simplifyTypedef36() {
|
||||
|
@ -4392,8 +4392,8 @@ private:
|
|||
"typedef int B;";
|
||||
|
||||
checkSimplifyTypedef(code);
|
||||
ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:2]: (style) Typedef 'A' hides typedef with same name\n"
|
||||
"[test.cpp:5] -> [test.cpp:3]: (style) Typedef 'B' hides typedef with same name\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:2]: (style) The typedef 'A' hides a typedef with the same name.\n"
|
||||
"[test.cpp:5] -> [test.cpp:3]: (style) The typedef 'B' hides a typedef with the same name.\n", errout.str());
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -4438,8 +4438,8 @@ private:
|
|||
ASSERT_EQUALS(expected, tok(code, false));
|
||||
|
||||
checkSimplifyTypedef(code);
|
||||
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:1]: (style) Template parameter 'A' hides typedef with same name\n"
|
||||
"[test.cpp:3] -> [test.cpp:2]: (style) Template parameter 'B' hides typedef with same name\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:1]: (style) The template parameter 'A' hides a typedef with the same name.\n"
|
||||
"[test.cpp:3] -> [test.cpp:2]: (style) The template parameter 'B' hides a typedef with the same name.\n", errout.str());
|
||||
|
||||
checkSimplifyTypedef("typedef tuple<double&, const double&, const double, double*, const double*> t2;\n"
|
||||
"void ordering_test()\n"
|
||||
|
@ -4447,7 +4447,7 @@ private:
|
|||
" tuple<short, float> t2(5, 3.3f);\n"
|
||||
" BOOST_CHECK(t3 > t2);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:1]: (style) Template instantiation 't2' hides typedef with same name\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:1]: (style) The template instantiation 't2' hides a typedef with the same name.\n", errout.str());
|
||||
|
||||
checkSimplifyTypedef("class MyOverflowingUnsigned\n"
|
||||
"{\n"
|
||||
|
@ -4500,15 +4500,15 @@ private:
|
|||
// ticket #1506
|
||||
checkSimplifyTypedef("typedef struct A { } A;\n"
|
||||
"struct A;");
|
||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:1]: (style) Struct 'A' forward declaration unnecessary, already declared\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:1]: (style) The struct 'A' forward declaration is unnecessary. Type struct is already declared earlier.\n", errout.str());
|
||||
|
||||
checkSimplifyTypedef("typedef union A { int i; float f; } A;\n"
|
||||
"union A;");
|
||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:1]: (style) Union 'A' forward declaration unnecessary, already declared\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:1]: (style) The union 'A' forward declaration is unnecessary. Type union is already declared earlier.\n", errout.str());
|
||||
|
||||
checkSimplifyTypedef("typedef std::map<std::string, int> A;\n"
|
||||
"class A;");
|
||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:1]: (style) Class 'A' forward declaration unnecessary, already declared\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:1]: (style) The class 'A' forward declaration is unnecessary. Type class is already declared earlier.\n", errout.str());
|
||||
}
|
||||
|
||||
void simplifyTypedef43() {
|
||||
|
@ -4528,7 +4528,7 @@ private:
|
|||
ASSERT_EQUALS(expected, tok(code));
|
||||
|
||||
checkSimplifyTypedef(code);
|
||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:1]: (style) Struct 'A' hides typedef with same name\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:1]: (style) The struct 'A' hides a typedef with the same name.\n", errout.str());
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -4546,7 +4546,7 @@ private:
|
|||
ASSERT_EQUALS(expected, tok(code));
|
||||
|
||||
checkSimplifyTypedef(code);
|
||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:1]: (style) Union 'A' hides typedef with same name\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:1]: (style) The union 'A' hides a typedef with the same name.\n", errout.str());
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -4564,7 +4564,7 @@ private:
|
|||
ASSERT_EQUALS(expected, tok(code));
|
||||
|
||||
checkSimplifyTypedef(code);
|
||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:1]: (style) Class 'A' hides typedef with same name\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:1]: (style) The class 'A' hides a typedef with the same name.\n", errout.str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4793,14 +4793,14 @@ private:
|
|||
"typedef int (*PPDMarkOption)(ppd_file_t *ppd, const char *keyword, const char *option);\n";
|
||||
|
||||
checkSimplifyTypedef(code);
|
||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:1]: (style) Typedef 'PPDMarkOption' hides typedef with same name\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:1]: (style) The typedef 'PPDMarkOption' hides a typedef with the same name.\n", errout.str());
|
||||
}
|
||||
|
||||
{
|
||||
const char code[] = "typedef int * A;\n"
|
||||
"typedef int * A;\n";
|
||||
checkSimplifyTypedef(code);
|
||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:1]: (style) Typedef 'A' hides typedef with same name\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:1]: (style) The typedef 'A' hides a typedef with the same name.\n", errout.str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7437,7 +7437,7 @@ private:
|
|||
const char code[] = "class Fred { Fred::Fred() {} };";
|
||||
const char expected[] = "class Fred { Fred ( ) { } } ;";
|
||||
ASSERT_EQUALS(expected, tok(code, false));
|
||||
ASSERT_EQUALS("[test.cpp:1]: (portability) Extra qualification 'Fred::' unnecessary and considered an error by many compilers.\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:1]: (portability) The extra qualification 'Fred::' is unnecessary and is considered an error by many compilers.\n", errout.str());
|
||||
}
|
||||
|
||||
void removeUnnecessaryQualification2() {
|
||||
|
@ -7501,7 +7501,7 @@ private:
|
|||
" };\n"
|
||||
"}\n";
|
||||
tok(code, false);
|
||||
ASSERT_EQUALS("[test.cpp:11]: (portability) Extra qualification 'two::c::' unnecessary and considered an error by many compilers.\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:11]: (portability) The extra qualification 'two::c::' is unnecessary and is considered an error by many compilers.\n", errout.str());
|
||||
}
|
||||
|
||||
void removeUnnecessaryQualification6() {
|
||||
|
@ -7527,7 +7527,7 @@ private:
|
|||
" long m_lEndAddr;\n"
|
||||
"};\n";
|
||||
tok(code, false);
|
||||
ASSERT_EQUALS("[test.cpp:3]: (portability) Extra qualification 'TProcedure::' unnecessary and considered an error by many compilers.\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:3]: (portability) The extra qualification 'TProcedure::' is unnecessary and is considered an error by many compilers.\n", errout.str());
|
||||
}
|
||||
|
||||
void removeUnnecessaryQualification8() {
|
||||
|
@ -7538,9 +7538,9 @@ private:
|
|||
" void Fred::operator delete[](void* x);\n"
|
||||
"};\n";
|
||||
tok(code, false);
|
||||
ASSERT_EQUALS("[test.cpp:3]: (portability) Extra qualification 'Fred::' unnecessary and considered an error by many compilers.\n"
|
||||
"[test.cpp:4]: (portability) Extra qualification 'Fred::' unnecessary and considered an error by many compilers.\n"
|
||||
"[test.cpp:5]: (portability) Extra qualification 'Fred::' unnecessary and considered an error by many compilers.\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:3]: (portability) The extra qualification 'Fred::' is unnecessary and is considered an error by many compilers.\n"
|
||||
"[test.cpp:4]: (portability) The extra qualification 'Fred::' is unnecessary and is considered an error by many compilers.\n"
|
||||
"[test.cpp:5]: (portability) The extra qualification 'Fred::' is unnecessary and is considered an error by many compilers.\n", errout.str());
|
||||
}
|
||||
|
||||
void removeUnnecessaryQualification9() {
|
||||
|
@ -7549,7 +7549,7 @@ private:
|
|||
" Fred::~Fred();\n"
|
||||
"};\n";
|
||||
tok(code, false);
|
||||
ASSERT_EQUALS("[test.cpp:3]: (portability) Extra qualification 'Fred::' unnecessary and considered an error by many compilers.\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:3]: (portability) The extra qualification 'Fred::' is unnecessary and is considered an error by many compilers.\n", errout.str());
|
||||
}
|
||||
|
||||
void removeUnnecessaryQualification10() {
|
||||
|
|
Loading…
Reference in New Issue