Skip to content

Commit 3bbd9fc

Browse files
lanurmidanmar
authored andcommitted
Replace "virtual method" with "virtual function" in messages.
The term "method" is not really a part of C++ terminology.
1 parent f267900 commit 3bbd9fc

3 files changed

Lines changed: 11 additions & 11 deletions

File tree

‎lib/checkclass.cpp‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,9 +1212,9 @@ void CheckClass::checkMemsetType(const Scope *start, const Token *tok, const Sco
12121212
for (const Function &func : type->functionList) {
12131213
if (func.isVirtual()) {
12141214
if (allocation)
1215-
mallocOnClassError(tok, tok->str(), type->classDef, "virtual method");
1215+
mallocOnClassError(tok, tok->str(), type->classDef, "virtual function");
12161216
else
1217-
memsetError(tok, tok->str(), "virtual method", type->classDef->str());
1217+
memsetError(tok, tok->str(), "virtual function", type->classDef->str());
12181218
}
12191219
}
12201220

@@ -1791,7 +1791,7 @@ void CheckClass::checkConst()
17911791
// does the function have a body?
17921792
if (func.type != Function::eFunction || !func.hasBody())
17931793
continue;
1794-
// don't warn for friend/static/virtual methods
1794+
// don't warn for friend/static/virtual functions
17951795
if (func.isFriend() || func.isStatic() || func.isVirtual())
17961796
continue;
17971797
// get last token of return type
@@ -2381,7 +2381,7 @@ void CheckClass::virtualFunctionCallInConstructorError(
23812381
errorPath.emplace_back(tok, "Calling " + tok->str());
23822382
if (!errorPath.empty()) {
23832383
lineNumber = errorPath.front().first->linenr();
2384-
errorPath.back().second = funcname + " is a virtual method";
2384+
errorPath.back().second = funcname + " is a virtual function";
23852385
}
23862386

23872387
std::string constructorName;
@@ -2413,7 +2413,7 @@ void CheckClass::pureVirtualFunctionCallInConstructorError(
24132413
for (const Token *tok : tokStack)
24142414
errorPath.emplace_back(tok, "Calling " + tok->str());
24152415
if (!errorPath.empty())
2416-
errorPath.back().second = purefuncname + " is a pure virtual method without body";
2416+
errorPath.back().second = purefuncname + " is a pure virtual function without body";
24172417

24182418
reportError(errorPath, Severity::warning, "pureVirtualCall",
24192419
"$symbol:" + purefuncname +"\n"

‎lib/checkclass.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ class CPPCHECKLIB CheckClass : public Check {
157157
/** @brief Check that arbitrary usage of the public interface does not result in division by zero */
158158
void checkUnsafeClassDivZero(bool test=false);
159159

160-
/** @brief Check that the override keyword is used when overriding virtual methods */
160+
/** @brief Check that the override keyword is used when overriding virtual functions */
161161
void checkOverride();
162162

163163
private:
@@ -262,7 +262,7 @@ class CPPCHECKLIB CheckClass : public Check {
262262
"- Duplicated inherited data members\n"
263263
// disabled for now "- If 'copy constructor' defined, 'operator=' also should be defined and vice versa\n"
264264
"- Check that arbitrary usage of public interface does not result in division by zero\n"
265-
"- Check that the 'override' keyword is used when overriding virtual methods\n";
265+
"- Check that the 'override' keyword is used when overriding virtual functions\n";
266266
}
267267

268268
// operatorEqRetRefThis helper functions

‎test/testclass.cpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2798,7 +2798,7 @@ class TestClass : public TestFixture {
27982798
" Fred fred;\n"
27992799
" memset(&fred, 0, sizeof(fred));\n"
28002800
"}");
2801-
ASSERT_EQUALS("[test.cpp:8]: (error) Using 'memset' on class that contains a virtual method.\n", errout.str());
2801+
ASSERT_EQUALS("[test.cpp:8]: (error) Using 'memset' on class that contains a virtual function.\n", errout.str());
28022802

28032803
checkNoMemset("class Fred\n"
28042804
"{\n"
@@ -2809,7 +2809,7 @@ class TestClass : public TestFixture {
28092809
" static Fred fred;\n"
28102810
" memset(&fred, 0, sizeof(fred));\n"
28112811
"}");
2812-
ASSERT_EQUALS("[test.cpp:8]: (error) Using 'memset' on class that contains a virtual method.\n", errout.str());
2812+
ASSERT_EQUALS("[test.cpp:8]: (error) Using 'memset' on class that contains a virtual function.\n", errout.str());
28132813

28142814
checkNoMemset("class Fred\n"
28152815
"{\n"
@@ -2824,7 +2824,7 @@ class TestClass : public TestFixture {
28242824
" Pebbles pebbles;\n"
28252825
" memset(&pebbles, 0, sizeof(pebbles));\n"
28262826
"}");
2827-
ASSERT_EQUALS("[test.cpp:12]: (error) Using 'memset' on class that contains a virtual method.\n", errout.str());
2827+
ASSERT_EQUALS("[test.cpp:12]: (error) Using 'memset' on class that contains a virtual function.\n", errout.str());
28282828

28292829
// Fred not defined in scope
28302830
checkNoMemset("namespace n1 {\n"
@@ -3240,7 +3240,7 @@ class TestClass : public TestFixture {
32403240
"void foo(C*& p) {\n"
32413241
" p = malloc(sizeof(C));\n"
32423242
"}");
3243-
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());
3243+
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());
32443244

32453245
checkNoMemset("struct C { std::string s; };\n"
32463246
"void foo(C*& p) {\n"

0 commit comments

Comments
 (0)