@@ -7531,6 +7531,41 @@ static const Function* getFunction(const Token* tok) {
75317531 return nullptr ;
75327532}
75337533
7534+ static int getIntegerConstantMacroWidth (const Token* tok) {
7535+ if (!tok)
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+
7566+ return intnum;
7567+ }
7568+
75347569void SymbolDatabase::setValueTypeInTokenList (bool reportDebugWarnings, Token *tokens)
75357570{
75367571 if (!tokens)
@@ -7672,6 +7707,29 @@ void SymbolDatabase::setValueTypeInTokenList(bool reportDebugWarnings, Token *to
76727707 }
76737708 }
76747709
7710+ // functions from stdint.h
7711+ else if (const int macroWidth = getIntegerConstantMacroWidth (tok->previous ())) {
7712+ ValueType valuetype;
7713+ if (macroWidth == mSettings .platform .char_bit )
7714+ valuetype.type = ValueType::Type::CHAR;
7715+ else if (macroWidth == mSettings .platform .short_bit )
7716+ valuetype.type = ValueType::Type::SHORT;
7717+ else if (macroWidth == mSettings .platform .int_bit )
7718+ valuetype.type = ValueType::Type::INT;
7719+ else if (macroWidth == mSettings .platform .long_bit )
7720+ valuetype.type = ValueType::Type::LONG;
7721+ else if (macroWidth == mSettings .platform .long_long_bit )
7722+ valuetype.type = ValueType::Type::LONGLONG;
7723+ else
7724+ valuetype.type = ValueType::Type::INT;
7725+
7726+ if (tok->previous ()->str ()[0 ] == ' U' )
7727+ valuetype.sign = ValueType::Sign::UNSIGNED;
7728+ else
7729+ valuetype.sign = ValueType::Sign::SIGNED;
7730+ setValueType (tok, valuetype);
7731+ }
7732+
76757733 // function style cast
76767734 else if (tok->previous () && tok->previous ()->isStandardType ()) {
76777735 ValueType valuetype;
0 commit comments