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