@@ -2214,12 +2214,13 @@ void Variable::evaluate(const Settings* settings)
22142214
22152215 const Library * const lib = &settings->library ;
22162216
2217+ // TODO: ValueType::parseDecl() is also performing a container lookup
22172218 bool isContainer = false ;
22182219 if (mNameToken )
22192220 setFlag (fIsArray , arrayDimensions (settings, isContainer));
22202221
22212222 if (mTypeStartToken )
2222- setValueType (ValueType::parseDecl (mTypeStartToken ,*settings, true )); // TODO: set isCpp
2223+ setValueType (ValueType::parseDecl (mTypeStartToken ,*settings));
22232224
22242225 const Token* tok = mTypeStartToken ;
22252226 while (tok && tok->previous () && tok->previous ()->isName ())
@@ -2275,7 +2276,7 @@ void Variable::evaluate(const Settings* settings)
22752276 setFlag (fIsClass , !lib->podtype (strtype) && !mTypeStartToken ->isStandardType () && !isEnumType () && !isPointer () && !isReference () && strtype != " ..." );
22762277 setFlag (fIsStlType , Token::simpleMatch (mTypeStartToken , " std ::" ));
22772278 setFlag (fIsStlString , ::isStlStringType (mTypeStartToken ));
2278- setFlag (fIsSmartPointer , lib->isSmartPointer (mTypeStartToken ));
2279+ setFlag (fIsSmartPointer , mTypeStartToken -> isCpp () && lib->isSmartPointer (mTypeStartToken ));
22792280 }
22802281 if (mAccess == AccessControl::Argument) {
22812282 tok = mNameToken ;
@@ -3558,7 +3559,7 @@ bool Type::isDerivedFrom(const std::string & ancestor) const
35583559bool Variable::arrayDimensions (const Settings* settings, bool & isContainer)
35593560{
35603561 isContainer = false ;
3561- const Library::Container* container = settings->library .detectContainer (mTypeStartToken );
3562+ const Library::Container* container = ( mTypeStartToken && mTypeStartToken -> isCpp ()) ? settings->library .detectContainer (mTypeStartToken ) : nullptr ;
35623563 if (container && container->arrayLike_indexOp && container->size_templateArgNo > 0 ) {
35633564 const Token* tok = Token::findsimplematch (mTypeStartToken , " <" );
35643565 if (tok) {
@@ -5653,7 +5654,7 @@ const Function* SymbolDatabase::findFunction(const Token* const tok) const
56535654 return tok1->valueType ()->typeScope ->findFunction (tok, tok1->valueType ()->constness == 1 );
56545655 if (tok1 && Token::Match (tok1->previous (), " %name% (" ) && tok1->previous ()->function () &&
56555656 tok1->previous ()->function ()->retDef ) {
5656- ValueType vt = ValueType::parseDecl (tok1->previous ()->function ()->retDef , mSettings , mIsCpp );
5657+ ValueType vt = ValueType::parseDecl (tok1->previous ()->function ()->retDef , mSettings );
56575658 if (vt.typeScope )
56585659 return vt.typeScope ->findFunction (tok, vt.constness == 1 );
56595660 } else if (Token::Match (tok1, " %var% ." )) {
@@ -5667,7 +5668,7 @@ const Function* SymbolDatabase::findFunction(const Token* const tok) const
56675668 } else if (Token::simpleMatch (tok->previous ()->astOperand1 (), " (" )) {
56685669 const Token *castTok = tok->previous ()->astOperand1 ();
56695670 if (castTok->isCast ()) {
5670- ValueType vt = ValueType::parseDecl (castTok->next (),mSettings , mIsCpp );
5671+ ValueType vt = ValueType::parseDecl (castTok->next (),mSettings );
56715672 if (vt.typeScope )
56725673 return vt.typeScope ->findFunction (tok, vt.constness == 1 );
56735674 }
@@ -5697,7 +5698,7 @@ const Function* SymbolDatabase::findFunction(const Token* const tok) const
56975698 }
56985699 // Check for constructor
56995700 if (Token::Match (tok, " %name% (|{" )) {
5700- ValueType vt = ValueType::parseDecl (tok, mSettings , mIsCpp );
5701+ ValueType vt = ValueType::parseDecl (tok, mSettings );
57015702 if (vt.typeScope )
57025703 return vt.typeScope ->findFunction (tok, false );
57035704 }
@@ -6991,7 +6992,7 @@ void SymbolDatabase::setValueTypeInTokenList(bool reportDebugWarnings, Token *to
69916992 }
69926993
69936994 // Construct smart pointer
6994- else if (mSettings .library .isSmartPointer (start)) {
6995+ else if (mIsCpp && mSettings .library .isSmartPointer (start)) {
69956996 ValueType valuetype;
69966997 if (parsedecl (start, &valuetype, mDefaultSignedness , mSettings , mIsCpp )) {
69976998 setValueType (tok, valuetype);
@@ -7066,7 +7067,7 @@ void SymbolDatabase::setValueTypeInTokenList(bool reportDebugWarnings, Token *to
70667067 }
70677068 }
70687069 }
7069- if (tok->astParent () && Token::Match (tok->astOperand1 (), " %name%|::" )) {
7070+ if (mIsCpp && tok->astParent () && Token::Match (tok->astOperand1 (), " %name%|::" )) {
70707071 const Token *typeStartToken = tok->astOperand1 ();
70717072 while (typeStartToken && typeStartToken->str () == " ::" )
70727073 typeStartToken = typeStartToken->astOperand1 ();
@@ -7216,7 +7217,7 @@ void SymbolDatabase::setValueTypeInTokenList(bool reportDebugWarnings, Token *to
72167217 functionScope = functionScope->nestedIn ;
72177218 if (functionScope && functionScope->type == Scope::eFunction && functionScope->function &&
72187219 functionScope->function ->retDef ) {
7219- ValueType vt = ValueType::parseDecl (functionScope->function ->retDef , mSettings , mIsCpp );
7220+ ValueType vt = ValueType::parseDecl (functionScope->function ->retDef , mSettings );
72207221 setValueType (tok, vt);
72217222 if (Token::simpleMatch (tok, " return {" ))
72227223 setValueType (tok->next (), vt);
@@ -7314,10 +7315,10 @@ void SymbolDatabase::setValueTypeInTokenList(bool reportDebugWarnings, Token *to
73147315 createSymbolDatabaseSetVariablePointers ();
73157316}
73167317
7317- ValueType ValueType::parseDecl (const Token *type, const Settings &settings, bool isCpp )
7318+ ValueType ValueType::parseDecl (const Token *type, const Settings &settings)
73187319{
73197320 ValueType vt;
7320- parsedecl (type, &vt, settings.platform .defaultSign == ' u' ? Sign::UNSIGNED : Sign::SIGNED, settings, isCpp);
7321+ parsedecl (type, &vt, settings.platform .defaultSign == ' u' ? Sign::UNSIGNED : Sign::SIGNED, settings, type-> isCpp () );
73217322 return vt;
73227323}
73237324
0 commit comments