File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1017,30 +1017,28 @@ static const std::uint32_t crc32Table[] = {
10171017 0xb40bbe37 , 0xc30c8ea1 , 0x5a05df1b , 0x2d02ef8d
10181018};
10191019
1020- static std:: uint32_t crc32 (const std::string &data)
1020+ static void crc32 (const std::string &data, uint32_t & crc )
10211021{
1022- std::uint32_t crc = ~0U ;
10231022 for (char c : data) {
10241023 crc = crc32Table[(crc ^ (unsigned char )c) & 0xFF ] ^ (crc >> 8 );
10251024 }
1026- return crc ^ ~0U ;
10271025}
10281026
1029- unsigned int Preprocessor::calculateChecksum (const simplecpp::TokenList &tokens1, const std::string &toolinfo) const
1027+ uint32_t Preprocessor::calculateChecksum (const simplecpp::TokenList &tokens1, const std::string &toolinfo) const
10301028{
1031- std::ostringstream ostr ;
1032- ostr << toolinfo << ' \n ' ;
1029+ std::uint32_t crc = ~ 0U ;
1030+ crc32 ( toolinfo, crc) ;
10331031 for (const simplecpp::Token *tok = tokens1.cfront (); tok; tok = tok->next ) {
10341032 if (!tok->comment )
1035- ostr << tok->str ();
1033+ crc32 ( tok->str (), crc );
10361034 }
10371035 for (std::map<std::string, simplecpp::TokenList *>::const_iterator it = mTokenLists .begin (); it != mTokenLists .end (); ++it) {
10381036 for (const simplecpp::Token *tok = it->second ->cfront (); tok; tok = tok->next ) {
10391037 if (!tok->comment )
1040- ostr << tok->str ();
1038+ crc32 ( tok->str (), crc );
10411039 }
10421040 }
1043- return crc32 (ostr. str ()) ;
1041+ return crc ^ ~ 0U ;
10441042}
10451043
10461044void Preprocessor::simplifyPragmaAsm (simplecpp::TokenList *tokenList) const
Original file line number Diff line number Diff line change @@ -170,7 +170,7 @@ class CPPCHECKLIB Preprocessor {
170170 * @param toolinfo Arbitrary extra toolinfo
171171 * @return CRC32 checksum
172172 */
173- unsigned int calculateChecksum (const simplecpp::TokenList &tokens1, const std::string &toolinfo) const ;
173+ uint32_t calculateChecksum (const simplecpp::TokenList &tokens1, const std::string &toolinfo) const ;
174174
175175 void simplifyPragmaAsm (simplecpp::TokenList *tokenList) const ;
176176
Original file line number Diff line number Diff line change @@ -460,20 +460,20 @@ void TokenList::createTokens(simplecpp::TokenList&& tokenList)
460460
461461// ---------------------------------------------------------------------------
462462
463- unsigned long long TokenList::calculateChecksum () const
463+ uint64_t TokenList::calculateChecksum () const
464464{
465- unsigned long long checksum = 0 ;
465+ uint64_t checksum = 0 ;
466466 for (const Token* tok = front (); tok; tok = tok->next ()) {
467- const unsigned int subchecksum1 = tok->flags () + tok->varId () + tok->tokType ();
468- unsigned int subchecksum2 = 0 ;
467+ const uint32_t subchecksum1 = tok->flags () + tok->varId () + tok->tokType ();
468+ uint32_t subchecksum2 = 0 ;
469469 for (char i : tok->str ())
470- subchecksum2 += (unsigned int )i;
470+ subchecksum2 += (uint32_t )i;
471471 if (!tok->originalName ().empty ()) {
472472 for (char i : tok->originalName ())
473- subchecksum2 += (unsigned int ) i;
473+ subchecksum2 += (uint32_t ) i;
474474 }
475475
476- checksum ^= ((static_cast <unsigned long long >(subchecksum1) << 32 ) | subchecksum2);
476+ checksum ^= ((static_cast <uint64_t >(subchecksum1) << 32 ) | subchecksum2);
477477
478478 const bool bit1 = (checksum & 1 ) != 0 ;
479479 checksum >>= 1 ;
Original file line number Diff line number Diff line change @@ -156,7 +156,7 @@ class CPPCHECKLIB TokenList {
156156 * Calculates a 64-bit checksum of the token list used to compare
157157 * multiple token lists with each other as quickly as possible.
158158 */
159- unsigned long long calculateChecksum () const ;
159+ uint64_t calculateChecksum () const ;
160160
161161 /* *
162162 * Create abstract syntax tree.
You can’t perform that action at this time.
0 commit comments