Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fix misspellings & gcc v3.4.6 warnings

1.  fix typos / misspellings
 - Fix misspelling within comments, variable/function names, stdout messages
 - changes the name of an error code: ```stlBoundries``` changed to ```stlBoundaries```.  Alias old name (```stlBoundries```) to the new one.

2.  fix gcc v3.4.6 32bit & 64bit warnings

 - fixes gcc v3.4.6 warnings, except for those in tinyxml and "-Wmissing-declarations" makefile warnings
 - in Preprocessor::handleIncludes(), replace a ```vector <bool>``` with ```stack<bool>``` (see ```vector<bool>``` warning below).
   - this is the only ```vector<bool>``` in the codebase
 - ```vector <bool>``` is actually a case of template specialization, and is not recommended, according to the following links:

http://stackoverflow.com/q/6461487
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2160.html
http://stackoverflow.com/q/670308

 - in the codebase before and after this change, testrunner SEGVs in a number of places on gcc v3.4.6, including ```Check::~Check()```, among others
   - fc42fc9 fixes this particular runtime issue for DJGPP & __sun
  • Loading branch information...
commit bd0d9b963943d19e232191892815c0bf70738192 1 parent 318ace7
Andrew Martin authored February 09, 2013
4  cli/threadexecutor.cpp
@@ -220,7 +220,7 @@ unsigned int ThreadExecutor::check()
220 220
                     if (FD_ISSET(*rp, &rfds)) {
221 221
                         int readRes = handleRead(*rp, result);
222 222
                         if (readRes == -1) {
223  
-                            long size = 0;
  223
+                            std::size_t size = 0;
224 224
                             std::map<int, std::string>::iterator p = pipeFile.find(*rp);
225 225
                             if (p != pipeFile.end()) {
226 226
                                 std::string name = p->second;
@@ -408,7 +408,7 @@ unsigned int __stdcall ThreadExecutor::threadProc(void *args)
408 408
 
409 409
         }
410 410
         const std::string &file = it->first;
411  
-        const int fileSize = it->second;
  411
+        const std::size_t fileSize = it->second;
412 412
         it++;
413 413
 
414 414
         LeaveCriticalSection(&threadExecutor->_fileSync);
8  gui/projectfile.cpp
@@ -27,7 +27,7 @@
27 27
 static const char ProjectElementName[] = "project";
28 28
 static const char ProjectVersionAttrib[] = "version";
29 29
 static const char ProjectFileVersion[] = "1";
30  
-static const char IncludDirElementName[] = "includedir";
  30
+static const char IncludeDirElementName[] = "includedir";
31 31
 static const char DirElementName[] = "dir";
32 32
 static const char DirNameAttrib[] = "name";
33 33
 static const char DefinesElementName[] = "defines";
@@ -84,7 +84,7 @@ bool ProjectFile::Read(const QString &filename)
84 84
                 ReadCheckPaths(xmlReader);
85 85
 
86 86
             // Find include directory from inside project element
87  
-            if (insideProject && xmlReader.name() == IncludDirElementName)
  87
+            if (insideProject && xmlReader.name() == IncludeDirElementName)
88 88
                 ReadIncludeDirs(xmlReader);
89 89
 
90 90
             // Find preprocessor define from inside project element
@@ -187,7 +187,7 @@ void ProjectFile::ReadIncludeDirs(QXmlStreamReader &reader)
187 187
             break;
188 188
 
189 189
         case QXmlStreamReader::EndElement:
190  
-            if (reader.name().toString() == IncludDirElementName)
  190
+            if (reader.name().toString() == IncludeDirElementName)
191 191
                 allRead = true;
192 192
             break;
193 193
 
@@ -369,7 +369,7 @@ bool ProjectFile::Write(const QString &filename)
369 369
     }
370 370
 
371 371
     if (!mIncludeDirs.isEmpty()) {
372  
-        xmlWriter.writeStartElement(IncludDirElementName);
  372
+        xmlWriter.writeStartElement(IncludeDirElementName);
373 373
         foreach(QString incdir, mIncludeDirs) {
374 374
             xmlWriter.writeStartElement(DirElementName);
375 375
             xmlWriter.writeAttribute(DirNameAttrib, incdir);
2  lib/checkmemoryleak.h
@@ -218,7 +218,7 @@ class CPPCHECKLIB CheckMemoryLeakInFunction : private Check, public CheckMemoryL
218 218
     /**
219 219
      * @brief %Check if there is a "!var" match inside a condition
220 220
      * @param tok      first token to match
221  
-     * @param varid    variabla id
  221
+     * @param varid    variable id
222 222
      * @param endpar   if this is true the "!var" must be followed by ")"
223 223
      * @return true if match
224 224
      */
6  lib/checkother.cpp
@@ -246,7 +246,7 @@ void CheckOther::clarifyConditionError(const Token *tok, bool assign, bool boolo
246 246
 }
247 247
 
248 248
 //---------------------------------------------------------------------------
249  
-// Clarify (meaningless) statements like *foo++; with parantheses.
  249
+// Clarify (meaningless) statements like *foo++; with parentheses.
250 250
 //---------------------------------------------------------------------------
251 251
 void CheckOther::clarifyStatement()
252 252
 {
@@ -1933,8 +1933,8 @@ void CheckOther::lookupVar(const Token *tok, const Variable* var)
1933 1933
         tok = tok->next();
1934 1934
 
1935 1935
     // Check if the variable is used in this indentlevel..
1936  
-    bool used1 = false;   // used in one sub-scope -> reducable
1937  
-    bool used2 = false;   // used in more sub-scopes -> not reducable
  1936
+    bool used1 = false;   // used in one sub-scope -> reducible
  1937
+    bool used2 = false;   // used in more sub-scopes -> not reducible
1938 1938
     unsigned int indentlevel = 0;
1939 1939
     int parlevel = 0;
1940 1940
     bool for_or_while = false;  // is sub-scope a "for/while/etc". anything that is not "if"
8  lib/checkother.h
@@ -119,7 +119,7 @@ class CPPCHECKLIB CheckOther : public Check {
119 119
         checkOther.checkSuspiciousEqualityComparison();
120 120
     }
121 121
 
122  
-    /** To check the dead code in a program, which is unaccessible due to the counter-conditions check in nested-if statements **/
  122
+    /** To check the dead code in a program, which is inaccessible due to the counter-conditions check in nested-if statements **/
123 123
     void oppositeInnerCondition();
124 124
 
125 125
     /** @brief Clarify calculation for ".. a * b ? .." */
@@ -183,7 +183,7 @@ class CPPCHECKLIB CheckOther : public Check {
183 183
     /** @brief %Check for suspicious calculations with sizeof results */
184 184
     void suspiciousSizeofCalculation();
185 185
 
186  
-    /** @brief copying to memory or assigning to a variablen twice */
  186
+    /** @brief copying to memory or assigning to a variable twice */
187 187
     void checkRedundantAssignment();
188 188
 
189 189
     /** @brief %Check for assigning to the same variable twice in a switch statement*/
@@ -470,7 +470,7 @@ class CPPCHECKLIB CheckOther : public Check {
470 470
                "* subsequent assignment or copying to a variable or buffer\n"
471 471
 
472 472
                // style
473  
-               "* Find dead code which is unaccessible due to the counter-conditions check in nested if statements\n"
  473
+               "* Find dead code which is inaccessible due to the counter-conditions check in nested if statements\n"
474 474
                "* C-style pointer cast in cpp file\n"
475 475
                "* casting between incompatible pointer types\n"
476 476
                "* redundant if\n"
@@ -481,7 +481,7 @@ class CPPCHECKLIB CheckOther : public Check {
481 481
                "* [[charvar|check how signed char variables are used]]\n"
482 482
                "* variable scope can be limited\n"
483 483
                "* condition that is always true/false\n"
484  
-               "* unusal pointer arithmetic. For example: \"abc\" + 'd'\n"
  484
+               "* unusual pointer arithmetic. For example: \"abc\" + 'd'\n"
485 485
                "* redundant assignment in a switch statement\n"
486 486
                "* redundant pre/post operation in a switch statement\n"
487 487
                "* redundant bitwise operation in a switch statement\n"
12  lib/checkstl.cpp
@@ -705,7 +705,7 @@ void CheckStl::invalidPointerError(const Token *tok, const std::string &func, co
705 705
 
706 706
 
707 707
 
708  
-void CheckStl::stlBoundries()
  708
+void CheckStl::stlBoundaries()
709 709
 {
710 710
     const SymbolDatabase* const symbolDatabase = _tokenizer->getSymbolDatabase();
711 711
     const std::size_t functions = symbolDatabase->functionScopes.size();
@@ -729,9 +729,9 @@ void CheckStl::stlBoundries()
729 729
                     const Token* const end = tok->scope()->classEnd;
730 730
                     for (const Token *tok2 = tok; tok2 != end; tok2 = tok2->next()) {
731 731
                         if (Token::Match(tok2, "!!* %varid% <", iteratorid)) {
732  
-                            stlBoundriesError(tok2, container_name);
  732
+                            stlBoundariesError(tok2, container_name);
733 733
                         } else if (Token::Match(tok2, "> %varid% !!.", iteratorid)) {
734  
-                            stlBoundriesError(tok2, container_name);
  734
+                            stlBoundariesError(tok2, container_name);
735 735
                         }
736 736
                     }
737 737
                 }
@@ -741,9 +741,9 @@ void CheckStl::stlBoundries()
741 741
 }
742 742
 
743 743
 // Error message for bad boundary usage..
744  
-void CheckStl::stlBoundriesError(const Token *tok, const std::string &container_name)
  744
+void CheckStl::stlBoundariesError(const Token *tok, const std::string &container_name)
745 745
 {
746  
-    reportError(tok, Severity::error, "stlBoundries",
  746
+    reportError(tok, Severity::error, "stlBoundaries",
747 747
                 "Dangerous iterator comparison using operator< on 'std::" + container_name + "'.\n"
748 748
                 "Iterator of container 'std::" + container_name + "' compared with operator<. "
749 749
                 "This is dangerous since the order of items in the container is not guaranteed. "
@@ -885,7 +885,7 @@ void CheckStl::if_findError(const Token *tok, bool str)
885 885
     if (str)
886 886
         reportError(tok, Severity::performance, "stlIfStrFind",
887 887
                     "Inefficient usage of string::find() in condition; string::compare() would be faster.\n"
888  
-                    "Either inefficent or wrong usage of string::find(). string::compare() will be faster if "
  888
+                    "Either inefficient or wrong usage of string::find(). string::compare() will be faster if "
889 889
                     "string::find's result is compared with 0, because it will not scan the whole "
890 890
                     "string. If your intention is to check that there are no findings in the string, "
891 891
                     "you should compare with std::string::npos.");
8  lib/checkstl.h
@@ -55,7 +55,7 @@ class CPPCHECKLIB CheckStl : public Check {
55 55
         checkStl.mismatchingContainers();
56 56
         checkStl.erase();
57 57
         checkStl.pushback();
58  
-        checkStl.stlBoundries();
  58
+        checkStl.stlBoundaries();
59 59
         checkStl.if_find();
60 60
         checkStl.string_c_str();
61 61
         checkStl.checkAutoPointer();
@@ -101,7 +101,7 @@ class CPPCHECKLIB CheckStl : public Check {
101 101
     /**
102 102
      * bad condition.. "it < alist.end()"
103 103
      */
104  
-    void stlBoundries();
  104
+    void stlBoundaries();
105 105
 
106 106
     /** if (a.find(x)) - possibly incorrect condition */
107 107
     void if_find();
@@ -164,7 +164,7 @@ class CPPCHECKLIB CheckStl : public Check {
164 164
     void mismatchingContainersError(const Token *tok);
165 165
     void invalidIteratorError(const Token *tok, const std::string &func, const std::string &iterator_name);
166 166
     void invalidPointerError(const Token *tok, const std::string &func, const std::string &pointer_name);
167  
-    void stlBoundriesError(const Token *tok, const std::string &container_name);
  167
+    void stlBoundariesError(const Token *tok, const std::string &container_name);
168 168
     void if_findError(const Token *tok, bool str);
169 169
     void sizeError(const Token *tok);
170 170
     void redundantIfRemoveError(const Token *tok);
@@ -188,7 +188,7 @@ class CPPCHECKLIB CheckStl : public Check {
188 188
         c.stlOutOfBoundsError(0, "i", "foo", false);
189 189
         c.invalidIteratorError(0, "push_back|push_front|insert", "iterator");
190 190
         c.invalidPointerError(0, "push_back", "pointer");
191  
-        c.stlBoundriesError(0, "container");
  191
+        c.stlBoundariesError(0, "container");
192 192
         c.if_findError(0, false);
193 193
         c.if_findError(0, true);
194 194
         c.string_c_strError(0);
17  lib/preprocessor.cpp
@@ -1923,14 +1923,14 @@ std::string Preprocessor::handleIncludes(const std::string &code, const std::str
1923 1923
     const std::string path(filePath.substr(0, 1 + filePath.find_last_of("\\/")));
1924 1924
 
1925 1925
     // current #if indent level.
1926  
-    unsigned int indent = 0;
  1926
+    std::stack<bool>::size_type indent = 0;
1927 1927
 
1928 1928
     // how deep does the #if match? this can never be bigger than "indent".
1929  
-    unsigned int indentmatch = 0;
  1929
+    std::stack<bool>::size_type indentmatch = 0;
1930 1930
 
1931 1931
     // has there been a true #if condition at the current indentmatch level?
1932 1932
     // then no more #elif or #else can be true before the #endif is seen.
1933  
-    std::vector<bool> elseIsTrueStack;
  1933
+    std::stack<bool> elseIsTrueStack;
1934 1934
 
1935 1935
     unsigned int linenr = 0;
1936 1936
 
@@ -1951,8 +1951,15 @@ std::string Preprocessor::handleIncludes(const std::string &code, const std::str
1951 1951
 
1952 1952
         // has there been a true #if condition at the current indentmatch level?
1953 1953
         // then no more #elif or #else can be true before the #endif is seen.
1954  
-        elseIsTrueStack.resize(1U + indentmatch, true);
1955  
-        std::vector<bool>::reference elseIsTrue = elseIsTrueStack[indentmatch];
  1954
+        while (elseIsTrueStack.size() != indentmatch + 1) {
  1955
+            if (elseIsTrueStack.size() < indentmatch + 1) {
  1956
+                elseIsTrueStack.push(true);
  1957
+            } else {
  1958
+                elseIsTrueStack.pop();
  1959
+            }
  1960
+        }
  1961
+
  1962
+        std::stack<bool>::reference elseIsTrue = elseIsTrueStack.top();
1956 1963
 
1957 1964
         if (line.compare(0,7,"#ifdef ") == 0) {
1958 1965
             if (indent == indentmatch) {
6  lib/preprocessor.h
@@ -62,7 +62,7 @@ class CPPCHECKLIB Preprocessor {
62 62
      * @param istr The (file/string) stream to read from.
63 63
      * @param result The map that will get the results
64 64
      * @param filename The name of the file to check e.g. "src/main.cpp"
65  
-     * @param includePaths List of paths where incude files should be searched from,
  65
+     * @param includePaths List of paths where include files should be searched from,
66 66
      * single path can be e.g. in format "include/".
67 67
      * There must be a path separator at the end. Default parameter is empty list.
68 68
      * Note that if path from given filename is also extracted and that is used as
@@ -81,7 +81,7 @@ class CPPCHECKLIB Preprocessor {
81 81
      * @param resultConfigurations List of configurations. Pass these one by one
82 82
      * to getcode() with processedFile.
83 83
      * @param filename The name of the file to check e.g. "src/main.cpp"
84  
-     * @param includePaths List of paths where incude files should be searched from,
  84
+     * @param includePaths List of paths where include files should be searched from,
85 85
      * single path can be e.g. in format "include/".
86 86
      * There must be a path separator at the end. Default parameter is empty list.
87 87
      * Note that if path from given filename is also extracted and that is used as
@@ -253,7 +253,7 @@ class CPPCHECKLIB Preprocessor {
253 253
      * file
254 254
      * @param code The source code to modify
255 255
      * @param filePath Relative path to file to check e.g. "src/main.cpp"
256  
-     * @param includePaths List of paths where incude files should be searched from,
  256
+     * @param includePaths List of paths where include files should be searched from,
257 257
      * single path can be e.g. in format "include/".
258 258
      * There must be a path separator at the end. Default parameter is empty list.
259 259
      * Note that if path from given filename is also extracted and that is used as
9  lib/suppressions.cpp
@@ -139,7 +139,7 @@ bool Suppressions::FileMatcher::match(const std::string &pattern, const std::str
139 139
             return true;
140 140
         }
141 141
 
142  
-        // If there are no other paths to tray, then fail
  142
+        // If there are no other paths to try, then fail
143 143
         if (backtrack.empty()) {
144 144
             return false;
145 145
         }
@@ -223,8 +223,13 @@ std::string Suppressions::addSuppression(const std::string &errorId, const std::
223 223
         return "Failed to add suppression. No id.";
224 224
     }
225 225
     if (errorId != "*") {
  226
+        // Support "stlBoundries", as that was the name of the errorId until v1.59.
  227
+        if (errorId == "stlBoundries") {
  228
+            return _suppressions["stlBoundaries"].addFile(file, line);
  229
+        }
  230
+
226 231
         for (std::string::size_type pos = 0; pos < errorId.length(); ++pos) {
227  
-            if (errorId[pos] < 0 || (!std::isalnum(errorId[pos]) &&  errorId[pos] != '_')) {
  232
+            if (errorId[pos] < 0 || (!std::isalnum(errorId[pos]) && errorId[pos] != '_')) {
228 233
                 return "Failed to add suppression. Invalid id \"" + errorId + "\"";
229 234
             }
230 235
             if (pos == 0 && std::isdigit(errorId[pos])) {
2  lib/suppressions.h
@@ -91,7 +91,7 @@ class CPPCHECKLIB Suppressions {
91 91
     std::string addSuppressionLine(const std::string &line);
92 92
 
93 93
     /**
94  
-     * @brief Don't show this error. If file and/or line are optional. In which case
  94
+     * @brief Don't show this error. File and/or line are optional. In which case
95 95
      * the errorId alone is used for filtering.
96 96
      * @param errorId the id for the error, e.g. "arrayIndexOutOfBounds"
97 97
      * @param file File name with the path, e.g. "src/main.cpp"
4  lib/symboldatabase.h
@@ -50,7 +50,7 @@ struct Dimension {
50 50
 
51 51
     const Token *start;  // size start token
52 52
     const Token *end;    // size end token
53  
-    MathLib::bigint num; // (assumpted) dimension length when size is a number, 0 if not known
  53
+    MathLib::bigint num; // (assumed) dimension length when size is a number, 0 if not known
54 54
     bool known;          // Known size
55 55
 };
56 56
 
@@ -162,7 +162,7 @@ class CPPCHECKLIB Variable {
162 162
 
163 163
     /**
164 164
      * Get index of variable in declared order.
165  
-     * @return varaible index
  165
+     * @return variable index
166 166
      */
167 167
     std::size_t index() const {
168 168
         return _index;
26  lib/templatesimplifier.cpp
@@ -589,7 +589,7 @@ void TemplateSimplifier::expandTemplate(
589 589
     const std::string &name,
590 590
     std::vector<const Token *> &typeParametersInDeclaration,
591 591
     const std::string &newName,
592  
-    std::vector<const Token *> &typesUsedInTemplateInstantion,
  592
+    std::vector<const Token *> &typesUsedInTemplateInstantiation,
593 593
     std::list<Token *> &templateInstantiations)
594 594
 {
595 595
     for (const Token *tok3 = tokenlist.front(); tok3; tok3 = tok3->next()) {
@@ -624,7 +624,7 @@ void TemplateSimplifier::expandTemplate(
624 624
 
625 625
                 // replace type with given type..
626 626
                 if (itype < typeParametersInDeclaration.size()) {
627  
-                    for (const Token *typetok = typesUsedInTemplateInstantion[itype];
  627
+                    for (const Token *typetok = typesUsedInTemplateInstantiation[itype];
628 628
                          typetok && !Token::Match(typetok, "[,>]");
629 629
                          typetok = typetok->next()) {
630 630
                         tokenlist.addtoken(typetok, tok3->linenr(), tok3->fileIndex());
@@ -965,7 +965,7 @@ bool TemplateSimplifier::simplifyCalculations(Token *_tokens)
965 965
 }
966 966
 
967 967
 
968  
-bool TemplateSimplifier::simplifyTemplateInstantions(
  968
+bool TemplateSimplifier::simplifyTemplateInstantiations(
969 969
     TokenList& tokenlist,
970 970
     ErrorLogger& errorlogger,
971 971
     const Settings *_settings,
@@ -1030,7 +1030,7 @@ bool TemplateSimplifier::simplifyTemplateInstantions(
1030 1030
             continue;
1031 1031
 
1032 1032
         // New type..
1033  
-        std::vector<const Token *> typesUsedInTemplateInstantion;
  1033
+        std::vector<const Token *> typesUsedInTemplateInstantiation;
1034 1034
         std::string typeForNewNameStr;
1035 1035
         std::string templateMatchPattern(name + " < ");
1036 1036
         unsigned int indentlevel = 0;
@@ -1052,7 +1052,7 @@ bool TemplateSimplifier::simplifyTemplateInstantions(
1052 1052
             templateMatchPattern += tok3->str();
1053 1053
             templateMatchPattern += " ";
1054 1054
             if (indentlevel == 0 && Token::Match(tok3->previous(), "[<,]"))
1055  
-                typesUsedInTemplateInstantion.push_back(tok3);
  1055
+                typesUsedInTemplateInstantiation.push_back(tok3);
1056 1056
             // add additional type information
1057 1057
             if (tok3->isUnsigned())
1058 1058
                 typeForNewNameStr += "unsigned";
@@ -1065,7 +1065,7 @@ bool TemplateSimplifier::simplifyTemplateInstantions(
1065 1065
         templateMatchPattern += ">";
1066 1066
         const std::string typeForNewName(typeForNewNameStr);
1067 1067
 
1068  
-        if (typeForNewName.empty() || typeParametersInDeclaration.size() != typesUsedInTemplateInstantion.size()) {
  1068
+        if (typeForNewName.empty() || typeParametersInDeclaration.size() != typesUsedInTemplateInstantiation.size()) {
1069 1069
             if (_settings->debugwarnings) {
1070 1070
                 std::list<const Token *> callstack(1, tok);
1071 1071
                 errorlogger.reportErr(ErrorLogger::ErrorMessage(callstack, &tokenlist, Severity::debug, "debg",
@@ -1081,7 +1081,7 @@ bool TemplateSimplifier::simplifyTemplateInstantions(
1081 1081
 
1082 1082
         if (expandedtemplates.find(newName) == expandedtemplates.end()) {
1083 1083
             expandedtemplates.insert(newName);
1084  
-            TemplateSimplifier::expandTemplate(tokenlist, tok,name,typeParametersInDeclaration,newName,typesUsedInTemplateInstantion,templateInstantiations);
  1084
+            TemplateSimplifier::expandTemplate(tokenlist, tok,name,typeParametersInDeclaration,newName,typesUsedInTemplateInstantiation,templateInstantiations);
1085 1085
             instantiated = true;
1086 1086
         }
1087 1087
 
@@ -1090,8 +1090,8 @@ bool TemplateSimplifier::simplifyTemplateInstantions(
1090 1090
         for (Token *tok4 = tok2; tok4; tok4 = tok4->next()) {
1091 1091
             if (Token::simpleMatch(tok4, templateMatchPattern.c_str())) {
1092 1092
                 Token * tok5 = tok4->tokAt(2);
1093  
-                unsigned int typeCountInInstantion = 1U; // There is always at least one type
1094  
-                const Token *typetok = (!typesUsedInTemplateInstantion.empty()) ? typesUsedInTemplateInstantion[0] : 0;
  1093
+                unsigned int typeCountInInstantiation = 1U; // There is always at least one type
  1094
+                const Token *typetok = (!typesUsedInTemplateInstantiation.empty()) ? typesUsedInTemplateInstantiation[0] : 0;
1095 1095
                 unsigned int indentlevel5 = 0;  // indentlevel for tok5
1096 1096
                 while (tok5 && (indentlevel5 > 0 || tok5->str() != ">")) {
1097 1097
                     if (tok5->str() == "<" && templateParameters(tok5) > 0)
@@ -1109,8 +1109,8 @@ bool TemplateSimplifier::simplifyTemplateInstantions(
1109 1109
 
1110 1110
                             typetok = typetok ? typetok->next() : 0;
1111 1111
                         } else {
1112  
-                            typetok = (typeCountInInstantion < typesUsedInTemplateInstantion.size()) ? typesUsedInTemplateInstantion[typeCountInInstantion] : 0;
1113  
-                            ++typeCountInInstantion;
  1112
+                            typetok = (typeCountInInstantiation < typesUsedInTemplateInstantiation.size()) ? typesUsedInTemplateInstantiation[typeCountInInstantiation] : 0;
  1113
+                            ++typeCountInInstantiation;
1114 1114
                         }
1115 1115
                     }
1116 1116
                     tok5 = tok5->next();
@@ -1118,7 +1118,7 @@ bool TemplateSimplifier::simplifyTemplateInstantions(
1118 1118
 
1119 1119
                 // matching template usage => replace tokens..
1120 1120
                 // Foo < int >  =>  Foo<int>
1121  
-                if (tok5 && tok5->str() == ">" && typeCountInInstantion == typesUsedInTemplateInstantion.size()) {
  1121
+                if (tok5 && tok5->str() == ">" && typeCountInInstantiation == typesUsedInTemplateInstantiation.size()) {
1122 1122
                     tok4->str(newName);
1123 1123
                     for (Token *tok6 = tok4->next(); tok6 != tok5; tok6 = tok6->next()) {
1124 1124
                         if (tok6->isName())
@@ -1191,7 +1191,7 @@ void TemplateSimplifier::simplifyTemplates(
1191 1191
         //done = true;
1192 1192
         std::list<Token *> templates2;
1193 1193
         for (std::list<Token *>::reverse_iterator iter1 = templates.rbegin(); iter1 != templates.rend(); ++iter1) {
1194  
-            bool instantiated = TemplateSimplifier::simplifyTemplateInstantions(tokenlist,
  1194
+            bool instantiated = TemplateSimplifier::simplifyTemplateInstantiations(tokenlist,
1195 1195
                                 errorlogger,
1196 1196
                                 _settings,
1197 1197
                                 *iter1,
8  lib/templatesimplifier.h
@@ -114,11 +114,11 @@ class CPPCHECKLIB TemplateSimplifier {
114 114
         const std::string &name,
115 115
         std::vector<const Token *> &typeParametersInDeclaration,
116 116
         const std::string &newName,
117  
-        std::vector<const Token *> &typesUsedInTemplateInstantion,
  117
+        std::vector<const Token *> &typesUsedInTemplateInstantiation,
118 118
         std::list<Token *> &templateInstantiations);
119 119
 
120 120
     /**
121  
-     * Simplify templates : expand all instantiatiations for a template
  121
+     * Simplify templates : expand all instantiations for a template
122 122
      * @todo It seems that inner templates should be instantiated recursively
123 123
      * @param tokenlist token list
124 124
      * @param errorlogger error logger
@@ -128,7 +128,7 @@ class CPPCHECKLIB TemplateSimplifier {
128 128
      * @param expandedtemplates all templates that has been expanded so far. The full names are stored.
129 129
      * @return true if the template was instantiated
130 130
      */
131  
-    static bool simplifyTemplateInstantions(
  131
+    static bool simplifyTemplateInstantiations(
132 132
         TokenList& tokenlist,
133 133
         ErrorLogger& errorlogger,
134 134
         const Settings *_settings,
@@ -159,7 +159,7 @@ class CPPCHECKLIB TemplateSimplifier {
159 159
 
160 160
     /**
161 161
      * Simplify constant calculations such as "1+2" => "3".
162  
-     * This also perform simple cleanup of parantheses etc.
  162
+     * This also performs simple cleanup of parentheses etc.
163 163
      * @param _tokens start token
164 164
      * @return true if modifications to token-list are done.
165 165
      *         false if no modifications are done.
2  lib/token.cpp
@@ -980,7 +980,7 @@ std::string Token::stringifyList(bool varid, bool attributes, bool linenumbers,
980 980
     std::ostringstream ret;
981 981
 
982 982
     unsigned int lineNumber = _linenr;
983  
-    int fileInd = files?-1:_fileIndex;
  983
+    int fileInd = files ? -1 : static_cast<int>(_fileIndex);
984 984
     std::map<int, unsigned int> lineNumbers;
985 985
     for (const Token *tok = this; tok != end; tok = tok->next()) {
986 986
         bool fileChange = false;
2  test/testcmdlineparser.cpp
@@ -411,7 +411,7 @@ class TestCmdlineParser : public TestFixture {
411 411
             ASSERT_EQUALS(Settings::C, settings.enforcedLang);
412 412
         }
413 413
         {
414  
-            const char *argv[] = {"cppcheck", "--language=unknwonLanguage", "file.cpp"};
  414
+            const char *argv[] = {"cppcheck", "--language=unknownLanguage", "file.cpp"};
415 415
             Settings settings;
416 416
             CmdLineParser parser(&settings);
417 417
             ASSERT(!parser.ParseFromArgs(3, argv));
2  test/testother.cpp
@@ -3072,7 +3072,7 @@ class TestOther : public TestFixture {
3072 3072
     }
3073 3073
 
3074 3074
     void testMisusedScopeObjectDoesNotPickConstructorDeclaration() {
3075  
-        check("class Something : public SomthingElse\n"
  3075
+        check("class Something : public SomethingElse\n"
3076 3076
               "{\n"
3077 3077
               "public:\n"
3078 3078
               "~Something ( ) ;\n"
2  test/testsimplifytokens.cpp
@@ -2412,7 +2412,7 @@ class TestSimplifyTokens : public TestFixture {
2412 2412
     }
2413 2413
 
2414 2414
     void templateParameters1() {
2415  
-        // #4169 - semgentation fault (invalid code)
  2415
+        // #4169 - segmentation fault (invalid code)
2416 2416
         const char code[] = "volatile true , test < test < #ifdef __ppc__ true ,";
2417 2417
         // do not crash on invalid code
2418 2418
         ASSERT_EQUALS(0, templateParameters(code));
16  test/teststl.cpp
@@ -89,10 +89,10 @@ class TestStl : public TestFixture {
89 89
 
90 90
         TEST_CASE(invalidcode);
91 91
 
92  
-        TEST_CASE(stlBoundries1);
93  
-        TEST_CASE(stlBoundries2);
94  
-        TEST_CASE(stlBoundries3);
95  
-        TEST_CASE(stlBoundries4); // #4364
  92
+        TEST_CASE(stlBoundaries1);
  93
+        TEST_CASE(stlBoundaries2);
  94
+        TEST_CASE(stlBoundaries3);
  95
+        TEST_CASE(stlBoundaries4); // #4364
96 96
 
97 97
         // if (str.find("ab"))
98 98
         TEST_CASE(if_find);
@@ -1200,7 +1200,7 @@ class TestStl : public TestFixture {
1200 1200
 
1201 1201
 
1202 1202
 
1203  
-    void stlBoundries1() {
  1203
+    void stlBoundaries1() {
1204 1204
         const int STL_CONTAINER_LIST = 9;
1205 1205
         const std::string stlCont[STL_CONTAINER_LIST] = {
1206 1206
             "deque", "list", "set", "multiset", "map",
@@ -1225,7 +1225,7 @@ class TestStl : public TestFixture {
1225 1225
         ASSERT_EQUALS("[test.cpp:3]: (error) Dangerous iterator comparison using operator< on 'std::forward_list'.\n", errout.str());
1226 1226
     }
1227 1227
 
1228  
-    void stlBoundries2() {
  1228
+    void stlBoundaries2() {
1229 1229
         check("void f()\n"
1230 1230
               "{\n"
1231 1231
               "    std::vector<std::string> files;\n"
@@ -1237,7 +1237,7 @@ class TestStl : public TestFixture {
1237 1237
         ASSERT_EQUALS("", errout.str());
1238 1238
     }
1239 1239
 
1240  
-    void stlBoundries3() {
  1240
+    void stlBoundaries3() {
1241 1241
         check("void f()\n"
1242 1242
               "{\n"
1243 1243
               "    set<int> files;\n"
@@ -1257,7 +1257,7 @@ class TestStl : public TestFixture {
1257 1257
         ASSERT_EQUALS("[test.cpp:3]: (error) Invalid iterator 'current' used.\n", errout.str());
1258 1258
     }
1259 1259
 
1260  
-    void stlBoundries4() {
  1260
+    void stlBoundaries4() {
1261 1261
 
1262 1262
         check("void f() {\n"
1263 1263
               "    std::forward_list<std::vector<std::vector<int>>>::iterator it;\n"
26  test/testtoken.cpp
@@ -34,7 +34,7 @@ class TestToken : public TestFixture {
34 34
     std::vector<std::string> arithmeticalOps;
35 35
     std::vector<std::string> logicalOps;
36 36
     std::vector<std::string> bitOps;
37  
-    std::vector<std::string> comparisionOps;
  37
+    std::vector<std::string> comparisonOps;
38 38
     std::vector<std::string> extendedOps;
39 39
     std::vector<std::string> assignmentOps;
40 40
 
@@ -484,12 +484,12 @@ class TestToken : public TestFixture {
484 484
         logicalOps.push_back("&&");
485 485
         logicalOps.push_back("||");
486 486
         logicalOps.push_back("!");
487  
-        comparisionOps.push_back("==");
488  
-        comparisionOps.push_back("!=");
489  
-        comparisionOps.push_back("<");
490  
-        comparisionOps.push_back("<=");
491  
-        comparisionOps.push_back(">");
492  
-        comparisionOps.push_back(">=");
  487
+        comparisonOps.push_back("==");
  488
+        comparisonOps.push_back("!=");
  489
+        comparisonOps.push_back("<");
  490
+        comparisonOps.push_back("<=");
  491
+        comparisonOps.push_back(">");
  492
+        comparisonOps.push_back(">=");
493 493
         bitOps.push_back("&");
494 494
         bitOps.push_back("|");
495 495
         bitOps.push_back("^");
@@ -520,7 +520,7 @@ class TestToken : public TestFixture {
520 520
         std::vector<std::string> test_ops;
521 521
         append_vector(test_ops, arithmeticalOps);
522 522
         append_vector(test_ops, bitOps);
523  
-        append_vector(test_ops, comparisionOps);
  523
+        append_vector(test_ops, comparisonOps);
524 524
         append_vector(test_ops, logicalOps);
525 525
 
526 526
         std::vector<std::string>::const_iterator test_op, test_ops_end = test_ops.end();
@@ -550,7 +550,7 @@ class TestToken : public TestFixture {
550 550
         // Negative test against other operators
551 551
         std::vector<std::string> other_ops;
552 552
         append_vector(other_ops, bitOps);
553  
-        append_vector(other_ops, comparisionOps);
  553
+        append_vector(other_ops, comparisonOps);
554 554
         append_vector(other_ops, logicalOps);
555 555
         append_vector(other_ops, extendedOps);
556 556
         append_vector(other_ops, assignmentOps);
@@ -567,7 +567,7 @@ class TestToken : public TestFixture {
567 567
         std::vector<std::string> test_ops;
568 568
         append_vector(test_ops, arithmeticalOps);
569 569
         append_vector(test_ops, bitOps);
570  
-        append_vector(test_ops, comparisionOps);
  570
+        append_vector(test_ops, comparisonOps);
571 571
         append_vector(test_ops, logicalOps);
572 572
 
573 573
         std::vector<std::string>::const_iterator test_op, test_ops_end = test_ops.end();
@@ -594,7 +594,7 @@ class TestToken : public TestFixture {
594 594
         std::vector<std::string> test_ops;
595 595
         append_vector(test_ops, arithmeticalOps);
596 596
         append_vector(test_ops, bitOps);
597  
-        append_vector(test_ops, comparisionOps);
  597
+        append_vector(test_ops, comparisonOps);
598 598
         append_vector(test_ops, logicalOps);
599 599
         append_vector(test_ops, extendedOps);
600 600
 
@@ -626,7 +626,7 @@ class TestToken : public TestFixture {
626 626
         std::vector<std::string> other_ops;
627 627
         append_vector(other_ops, arithmeticalOps);
628 628
         append_vector(other_ops, bitOps);
629  
-        append_vector(other_ops, comparisionOps);
  629
+        append_vector(other_ops, comparisonOps);
630 630
         append_vector(other_ops, logicalOps);
631 631
         append_vector(other_ops, extendedOps);
632 632
 
@@ -655,7 +655,7 @@ class TestToken : public TestFixture {
655 655
             tok.str(*test_op);
656 656
             ASSERT_EQUALS(Token::eBitOp, tok.type());
657 657
         }
658  
-        for (test_op = comparisionOps.begin(); test_op != comparisionOps.end(); ++test_op) {
  658
+        for (test_op = comparisonOps.begin(); test_op != comparisonOps.end(); ++test_op) {
659 659
             Token tok(NULL);
660 660
             tok.str(*test_op);
661 661
             ASSERT_EQUALS(Token::eComparisonOp, tok.type());
24  test/testtokenize.cpp
@@ -5983,20 +5983,20 @@ class TestTokenizer : public TestFixture {
5983 5983
             tokenizer.tokenize(istr, "test.cpp");
5984 5984
             const Token *tok = tokenizer.tokens();
5985 5985
             // template<
5986  
-            ASSERT_EQUALS((long long)tok->tokAt(6), (long long)tok->linkAt(4));
5987  
-            ASSERT_EQUALS((long long)tok->tokAt(4), (long long)tok->linkAt(6));
  5986
+            ASSERT_EQUALS(true, tok->tokAt(6) == tok->linkAt(4));
  5987
+            ASSERT_EQUALS(true, tok->tokAt(4) == tok->linkAt(6));
5988 5988
 
5989 5989
             // bar<
5990  
-            ASSERT_EQUALS((long long)tok->tokAt(17), (long long)tok->linkAt(10));
5991  
-            ASSERT_EQUALS((long long)tok->tokAt(10), (long long)tok->linkAt(17));
  5990
+            ASSERT_EQUALS(true, tok->tokAt(17) == tok->linkAt(10));
  5991
+            ASSERT_EQUALS(true, tok->tokAt(10) == tok->linkAt(17));
5992 5992
 
5993 5993
             // x<
5994  
-            ASSERT_EQUALS((long long)tok->tokAt(16), (long long)tok->linkAt(14));
5995  
-            ASSERT_EQUALS((long long)tok->tokAt(14), (long long)tok->linkAt(16));
  5994
+            ASSERT_EQUALS(true, tok->tokAt(16) == tok->linkAt(14));
  5995
+            ASSERT_EQUALS(true, tok->tokAt(14) == tok->linkAt(16));
5996 5996
 
5997 5997
             // a<b && b>f
5998  
-            ASSERT_EQUALS(0, (long long)tok->linkAt(28));
5999  
-            ASSERT_EQUALS(0, (long long)tok->linkAt(32));
  5998
+            ASSERT_EQUALS(true, 0 == tok->linkAt(28));
  5999
+            ASSERT_EQUALS(true, 0 == tok->linkAt(32));
6000 6000
 
6001 6001
             ASSERT_EQUALS("", errout.str());
6002 6002
         }
@@ -6013,8 +6013,8 @@ class TestTokenizer : public TestFixture {
6013 6013
             const Token *tok = tokenizer.tokens();
6014 6014
 
6015 6015
             // static_cast<
6016  
-            ASSERT_EQUALS((long long)tok->tokAt(9), (long long)tok->linkAt(7));
6017  
-            ASSERT_EQUALS((long long)tok->tokAt(7), (long long)tok->linkAt(9));
  6016
+            ASSERT_EQUALS(true, tok->tokAt(9) == tok->linkAt(7));
  6017
+            ASSERT_EQUALS(true, tok->tokAt(7) == tok->linkAt(9));
6018 6018
 
6019 6019
             ASSERT_EQUALS("", errout.str());
6020 6020
         }
@@ -6031,8 +6031,8 @@ class TestTokenizer : public TestFixture {
6031 6031
             const Token *tok = tokenizer.tokens();
6032 6032
 
6033 6033
             // nvwa<(x > y)>
6034  
-            ASSERT_EQUALS((long long)tok->tokAt(12), (long long)tok->linkAt(6));
6035  
-            ASSERT_EQUALS((long long)tok->tokAt(6), (long long)tok->linkAt(12));
  6034
+            ASSERT_EQUALS(true, tok->tokAt(12) == tok->linkAt(6));
  6035
+            ASSERT_EQUALS(true, tok->tokAt(6) == tok->linkAt(12));
6036 6036
 
6037 6037
             ASSERT_EQUALS("", errout.str());
6038 6038
         }

0 notes on commit bd0d9b9

Please sign in to comment.
Something went wrong with that request. Please try again.