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