MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / smartPointerType

Method smartPointerType

lib/symboldatabase.cpp:2669–2692  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2667}
2668
2669const Type* Variable::smartPointerType() const
2670{
2671 if (!isSmartPointer())
2672 return nullptr;
2673
2674 if (mValueType->smartPointerType)
2675 return mValueType->smartPointerType;
2676
2677 // TODO: Cache result, handle more complex type expression
2678 const Token* typeTok = typeStartToken();
2679 while (Token::Match(typeTok, "%name%|::"))
2680 typeTok = typeTok->next();
2681 if (Token::Match(typeTok, "< %name% >")) {
2682 // cppcheck-suppress shadowFunction - TODO: fix this
2683 const Scope* scope = typeTok->scope();
2684 const Type* ptrType{};
2685 while (scope && !ptrType) {
2686 ptrType = scope->findType(typeTok->strAt(1));
2687 scope = scope->nestedIn;
2688 }
2689 return ptrType;
2690 }
2691 return nullptr;
2692}
2693
2694const Type* Variable::iteratorType() const
2695{

Callers 4

findFunctionMethod · 0.80
setValueTypeMethod · 0.80
checkConstFuncMethod · 0.80

Calls 5

isSmartPointerFunction · 0.85
typeStartTokenFunction · 0.85
nextMethod · 0.80
scopeMethod · 0.80
findTypeMethod · 0.80

Tested by

no test coverage detected