@@ -48,16 +48,9 @@ namespace CTU {
4848
4949// Register CheckClass..
5050namespace {
51- CheckClass instance ;
51+ CheckClass instanceClass ;
5252}
5353
54- static const CWE CWE398 (398U ); // Indicator of Poor Code Quality
55- static const CWE CWE404 (404U ); // Improper Resource Shutdown or Release
56- static const CWE CWE665 (665U ); // Improper Initialization
57- static const CWE CWE758 (758U ); // Reliance on Undefined, Unspecified, or Implementation-Defined Behavior
58- static const CWE CWE762 (762U ); // Mismatched Memory Management Routines
59-
60- static const CWE CWE_ONE_DEFINITION_RULE (758U );
6154
6255static const char * getFunctionTypeName (Function::Type type)
6356{
@@ -2632,7 +2625,7 @@ void CheckClass::checkConstError2(const Token *tok1, const Token *tok2, const st
26322625// ClassCheck: Check that initializer list is in declared order.
26332626// ---------------------------------------------------------------------------
26342627
2635- namespace { // avoid one-definition-rule violation
2628+ namespace internal { // avoid one-definition-rule violation
26362629 struct VarInfo {
26372630 VarInfo (const Variable *_var, const Token *_tok)
26382631 : var(_var), tok(_tok) {}
@@ -2666,7 +2659,7 @@ void CheckClass::initializerListOrder()
26662659 const Token *tok = func->arg ->link ()->next ();
26672660
26682661 if (tok->str () == " :" ) {
2669- std::vector<VarInfo> vars;
2662+ std::vector<internal:: VarInfo> vars;
26702663 tok = tok->next ();
26712664
26722665 // find all variable initializations in list
@@ -3436,7 +3429,7 @@ void CheckClass::unsafeClassRefMemberError(const Token *tok, const std::string &
34363429 CWE (0 ), Certainty::normal);
34373430}
34383431
3439- // a Clang-built executable will crash when using the anonymous MyFileInfo later on - so put it in a unique namespace for now
3432+ // a Clang-built executable will crash when using the anonymous MyFileInfoClass later on - so put it in a unique namespace for now
34403433// see https://trac.cppcheck.net/ticket/12108 for more details
34413434#ifdef __clang__
34423435inline namespace CheckClass_internal
@@ -3445,7 +3438,7 @@ namespace
34453438#endif
34463439{
34473440 /* multifile checking; one definition rule violations */
3448- class MyFileInfo : public Check ::FileInfo {
3441+ class MyFileInfoClass : public Check ::FileInfo {
34493442 public:
34503443 struct NameLoc {
34513444 std::string className;
@@ -3485,7 +3478,7 @@ Check::FileInfo *CheckClass::getFileInfo(const Tokenizer *tokenizer, const Setti
34853478 return nullptr ;
34863479 (void )settings;
34873480 // One definition rule
3488- std::vector<MyFileInfo ::NameLoc> classDefinitions;
3481+ std::vector<MyFileInfoClass ::NameLoc> classDefinitions;
34893482 for (const Scope * classScope : tokenizer->getSymbolDatabase ()->classAndStructScopes ) {
34903483 if (classScope->isAnonymous ())
34913484 continue ;
@@ -3519,7 +3512,7 @@ Check::FileInfo *CheckClass::getFileInfo(const Tokenizer *tokenizer, const Setti
35193512 if (scope->type != Scope::ScopeType::eGlobal)
35203513 continue ;
35213514
3522- MyFileInfo ::NameLoc nameLoc;
3515+ MyFileInfoClass ::NameLoc nameLoc;
35233516 nameLoc.className = std::move (name);
35243517 nameLoc.fileName = tokenizer->list .file (classScope->classDef );
35253518 nameLoc.lineNumber = classScope->classDef ->linenr ();
@@ -3543,14 +3536,14 @@ Check::FileInfo *CheckClass::getFileInfo(const Tokenizer *tokenizer, const Setti
35433536 if (classDefinitions.empty ())
35443537 return nullptr ;
35453538
3546- auto *fileInfo = new MyFileInfo ;
3539+ auto *fileInfo = new MyFileInfoClass ;
35473540 fileInfo->classDefinitions .swap (classDefinitions);
35483541 return fileInfo;
35493542}
35503543
35513544Check::FileInfo * CheckClass::loadFileInfoFromXml (const tinyxml2::XMLElement *xmlElement) const
35523545{
3553- auto *fileInfo = new MyFileInfo ;
3546+ auto *fileInfo = new MyFileInfoClass ;
35543547 for (const tinyxml2::XMLElement *e = xmlElement->FirstChildElement (); e; e = e->NextSiblingElement ()) {
35553548 if (std::strcmp (e->Name (), " class" ) != 0 )
35563549 continue ;
@@ -3560,7 +3553,7 @@ Check::FileInfo * CheckClass::loadFileInfoFromXml(const tinyxml2::XMLElement *xm
35603553 const char *col = e->Attribute (" col" );
35613554 const char *hash = e->Attribute (" hash" );
35623555 if (name && file && line && col && hash) {
3563- MyFileInfo ::NameLoc nameLoc;
3556+ MyFileInfoClass ::NameLoc nameLoc;
35643557 nameLoc.className = name;
35653558 nameLoc.fileName = file;
35663559 nameLoc.lineNumber = strToInt<int >(line);
@@ -3582,17 +3575,17 @@ bool CheckClass::analyseWholeProgram(const CTU::FileInfo *ctu, const std::list<C
35823575 (void )ctu; // This argument is unused
35833576 (void )settings; // This argument is unused
35843577
3585- std::unordered_map<std::string, MyFileInfo ::NameLoc> all;
3578+ std::unordered_map<std::string, MyFileInfoClass ::NameLoc> all;
35863579
35873580 CheckClass dummy (nullptr , &settings, &errorLogger);
35883581 dummy.
35893582 logChecker (" CheckClass::analyseWholeProgram" );
35903583
35913584 for (const Check::FileInfo* fi1 : fileInfo) {
3592- const MyFileInfo *fi = dynamic_cast <const MyFileInfo *>(fi1);
3585+ const MyFileInfoClass *fi = dynamic_cast <const MyFileInfoClass *>(fi1);
35933586 if (!fi)
35943587 continue ;
3595- for (const MyFileInfo ::NameLoc &nameLoc : fi->classDefinitions ) {
3588+ for (const MyFileInfoClass ::NameLoc &nameLoc : fi->classDefinitions ) {
35963589 auto it = all.find (nameLoc.className );
35973590 if (it == all.end ()) {
35983591 all[nameLoc.className ] = nameLoc;
0 commit comments