Replace "virtual method" with "virtual function" in messages.

The term "method" is not really a part of C++ terminology.
This commit is contained in:
Lauri Nurmi 2019-01-14 20:54:34 +02:00 committed by Daniel Marjamäki
parent f267900257
commit 3bbd9fc9a4
3 changed files with 11 additions and 11 deletions

View File

@ -1212,9 +1212,9 @@ void CheckClass::checkMemsetType(const Scope *start, const Token *tok, const Sco
for (const Function &func : type->functionList) { for (const Function &func : type->functionList) {
if (func.isVirtual()) { if (func.isVirtual()) {
if (allocation) if (allocation)
mallocOnClassError(tok, tok->str(), type->classDef, "virtual method"); mallocOnClassError(tok, tok->str(), type->classDef, "virtual function");
else else
memsetError(tok, tok->str(), "virtual method", type->classDef->str()); memsetError(tok, tok->str(), "virtual function", type->classDef->str());
} }
} }
@ -1791,7 +1791,7 @@ void CheckClass::checkConst()
// does the function have a body? // does the function have a body?
if (func.type != Function::eFunction || !func.hasBody()) if (func.type != Function::eFunction || !func.hasBody())
continue; continue;
// don't warn for friend/static/virtual methods // don't warn for friend/static/virtual functions
if (func.isFriend() || func.isStatic() || func.isVirtual()) if (func.isFriend() || func.isStatic() || func.isVirtual())
continue; continue;
// get last token of return type // get last token of return type
@ -2381,7 +2381,7 @@ void CheckClass::virtualFunctionCallInConstructorError(
errorPath.emplace_back(tok, "Calling " + tok->str()); errorPath.emplace_back(tok, "Calling " + tok->str());
if (!errorPath.empty()) { if (!errorPath.empty()) {
lineNumber = errorPath.front().first->linenr(); lineNumber = errorPath.front().first->linenr();
errorPath.back().second = funcname + " is a virtual method"; errorPath.back().second = funcname + " is a virtual function";
} }
std::string constructorName; std::string constructorName;
@ -2413,7 +2413,7 @@ void CheckClass::pureVirtualFunctionCallInConstructorError(
for (const Token *tok : tokStack) for (const Token *tok : tokStack)
errorPath.emplace_back(tok, "Calling " + tok->str()); errorPath.emplace_back(tok, "Calling " + tok->str());
if (!errorPath.empty()) if (!errorPath.empty())
errorPath.back().second = purefuncname + " is a pure virtual method without body"; errorPath.back().second = purefuncname + " is a pure virtual function without body";
reportError(errorPath, Severity::warning, "pureVirtualCall", reportError(errorPath, Severity::warning, "pureVirtualCall",
"$symbol:" + purefuncname +"\n" "$symbol:" + purefuncname +"\n"

View File

@ -157,7 +157,7 @@ public:
/** @brief Check that arbitrary usage of the public interface does not result in division by zero */ /** @brief Check that arbitrary usage of the public interface does not result in division by zero */
void checkUnsafeClassDivZero(bool test=false); void checkUnsafeClassDivZero(bool test=false);
/** @brief Check that the override keyword is used when overriding virtual methods */ /** @brief Check that the override keyword is used when overriding virtual functions */
void checkOverride(); void checkOverride();
private: private:
@ -262,7 +262,7 @@ private:
"- Duplicated inherited data members\n" "- Duplicated inherited data members\n"
// disabled for now "- If 'copy constructor' defined, 'operator=' also should be defined and vice versa\n" // disabled for now "- If 'copy constructor' defined, 'operator=' also should be defined and vice versa\n"
"- Check that arbitrary usage of public interface does not result in division by zero\n" "- Check that arbitrary usage of public interface does not result in division by zero\n"
"- Check that the 'override' keyword is used when overriding virtual methods\n"; "- Check that the 'override' keyword is used when overriding virtual functions\n";
} }
// operatorEqRetRefThis helper functions // operatorEqRetRefThis helper functions

View File

@ -2798,7 +2798,7 @@ private:
" Fred fred;\n" " Fred fred;\n"
" memset(&fred, 0, sizeof(fred));\n" " memset(&fred, 0, sizeof(fred));\n"
"}"); "}");
ASSERT_EQUALS("[test.cpp:8]: (error) Using 'memset' on class that contains a virtual method.\n", errout.str()); ASSERT_EQUALS("[test.cpp:8]: (error) Using 'memset' on class that contains a virtual function.\n", errout.str());
checkNoMemset("class Fred\n" checkNoMemset("class Fred\n"
"{\n" "{\n"
@ -2809,7 +2809,7 @@ private:
" static Fred fred;\n" " static Fred fred;\n"
" memset(&fred, 0, sizeof(fred));\n" " memset(&fred, 0, sizeof(fred));\n"
"}"); "}");
ASSERT_EQUALS("[test.cpp:8]: (error) Using 'memset' on class that contains a virtual method.\n", errout.str()); ASSERT_EQUALS("[test.cpp:8]: (error) Using 'memset' on class that contains a virtual function.\n", errout.str());
checkNoMemset("class Fred\n" checkNoMemset("class Fred\n"
"{\n" "{\n"
@ -2824,7 +2824,7 @@ private:
" Pebbles pebbles;\n" " Pebbles pebbles;\n"
" memset(&pebbles, 0, sizeof(pebbles));\n" " memset(&pebbles, 0, sizeof(pebbles));\n"
"}"); "}");
ASSERT_EQUALS("[test.cpp:12]: (error) Using 'memset' on class that contains a virtual method.\n", errout.str()); ASSERT_EQUALS("[test.cpp:12]: (error) Using 'memset' on class that contains a virtual function.\n", errout.str());
// Fred not defined in scope // Fred not defined in scope
checkNoMemset("namespace n1 {\n" checkNoMemset("namespace n1 {\n"
@ -3240,7 +3240,7 @@ private:
"void foo(C*& p) {\n" "void foo(C*& p) {\n"
" p = malloc(sizeof(C));\n" " p = malloc(sizeof(C));\n"
"}"); "}");
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:1]: (error) Memory for class instance allocated with malloc(), but class contains a virtual method.\n", errout.str()); ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:1]: (error) Memory for class instance allocated with malloc(), but class contains a virtual function.\n", errout.str());
checkNoMemset("struct C { std::string s; };\n" checkNoMemset("struct C { std::string s; };\n"
"void foo(C*& p) {\n" "void foo(C*& p) {\n"