SymbolDatabase: Hardcoded handling for std::make_shared and std::make_unique , todo: library configuration would be better than hard coding
This commit is contained in:
parent
c9b95d7d49
commit
9f40341ba8
|
@ -5591,6 +5591,19 @@ void SymbolDatabase::setValueTypeInTokenList(bool reportDebugWarnings)
|
|||
setValueType(tok, vt);
|
||||
continue;
|
||||
}
|
||||
|
||||
const std::string e = tok->astOperand1()->expressionString();
|
||||
|
||||
if ((e == "std::make_shared" || e == "std::make_unique") && Token::Match(tok->astOperand1(), ":: %name% < %name%")) {
|
||||
ValueType vt;
|
||||
parsedecl(tok->astOperand1()->tokAt(3), &vt, mDefaultSignedness, mSettings);
|
||||
if (vt.typeScope) {
|
||||
vt.smartPointerType = vt.typeScope->definedType;
|
||||
vt.typeScope = nullptr;
|
||||
setValueType(tok, vt);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const std::string& typestr(mSettings->library.returnValueType(tok->previous()));
|
||||
|
|
|
@ -2349,8 +2349,7 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void danglingTemporaryLifetime()
|
||||
{
|
||||
void danglingTemporaryLifetime() {
|
||||
check("const int& g(const int& x) {\n"
|
||||
" return x;\n"
|
||||
"}\n"
|
||||
|
|
|
@ -6382,6 +6382,9 @@ private:
|
|||
// Variable declaration
|
||||
ASSERT_EQUALS("char *", typeOf("; char abc[] = \"abc\";", "["));
|
||||
ASSERT_EQUALS("", typeOf("; int x[10] = { [3]=1 };", "[ 3 ]"));
|
||||
|
||||
// std::make_shared
|
||||
ASSERT_EQUALS("smart-pointer<C>", typeOf("class C {}; x = std::make_shared<C>();", "("));
|
||||
}
|
||||
|
||||
void variadic1() { // #7453
|
||||
|
|
Loading…
Reference in New Issue