@@ -7530,6 +7530,40 @@ static const Function* getFunction(const Token* tok) {
75307530 return nullptr ;
75317531}
75327532
7533+ static int getIntegerConstantMacroWidth (const Token* tok) {
7534+ if (!Token::Match (tok, " %name% (" ) || Token::simpleMatch (tok->next ()->astOperand2 (), " ," ))
7535+ return 0 ;
7536+ const std::string &name = tok->str ();
7537+ if (name.back () != ' C' )
7538+ return 0 ;
7539+ size_t pos = (name[0 ] == ' U' ) ? 1 : 0 ;
7540+ if (name[pos] != ' I' || name[pos + 1 ] != ' N' || name[pos + 2 ] != ' T' )
7541+ return 0 ;
7542+ pos += 3 ;
7543+ int intnum = 0 ;
7544+ if (name[pos] == ' 8' ) {
7545+ ++pos;
7546+ intnum = 8 ;
7547+ }
7548+ else if (name[pos] == ' 1' && name[pos + 1 ] == ' 6' ) {
7549+ pos += 2 ;
7550+ intnum = 16 ;
7551+ }
7552+ else if (name[pos] == ' 3' && name[pos + 1 ] == ' 2' ) {
7553+ pos += 2 ;
7554+ intnum = 32 ;
7555+ }
7556+ else if (name[pos] == ' 6' && name[pos + 1 ] == ' 4' ) {
7557+ pos += 2 ;
7558+ intnum = 64 ;
7559+ }
7560+ else
7561+ return 0 ;
7562+ if (pos + 2 != name.size () || name[pos] != ' _' )
7563+ return 0 ;
7564+ return intnum;
7565+ }
7566+
75337567void SymbolDatabase::setValueTypeInTokenList (bool reportDebugWarnings, Token *tokens)
75347568{
75357569 if (!tokens)
@@ -7671,6 +7705,29 @@ void SymbolDatabase::setValueTypeInTokenList(bool reportDebugWarnings, Token *to
76717705 }
76727706 }
76737707
7708+ // functions from stdint.h
7709+ else if (const int macroWidth = getIntegerConstantMacroWidth (tok->previous ())) {
7710+ ValueType valuetype;
7711+ if (macroWidth == mSettings .platform .char_bit )
7712+ valuetype.type = ValueType::Type::CHAR;
7713+ else if (macroWidth == mSettings .platform .short_bit )
7714+ valuetype.type = ValueType::Type::SHORT;
7715+ else if (macroWidth == mSettings .platform .int_bit )
7716+ valuetype.type = ValueType::Type::INT;
7717+ else if (macroWidth == mSettings .platform .long_bit )
7718+ valuetype.type = ValueType::Type::LONG;
7719+ else if (macroWidth == mSettings .platform .long_long_bit )
7720+ valuetype.type = ValueType::Type::LONGLONG;
7721+ else
7722+ valuetype.type = ValueType::Type::INT;
7723+
7724+ if (tok->strAt (-1 )[0 ] == ' U' )
7725+ valuetype.sign = ValueType::Sign::UNSIGNED;
7726+ else
7727+ valuetype.sign = ValueType::Sign::SIGNED;
7728+ setValueType (tok, valuetype);
7729+ }
7730+
76747731 // function style cast
76757732 else if (tok->previous () && tok->previous ()->isStandardType ()) {
76767733 ValueType valuetype;
0 commit comments