ValueType: Improved debug output for nested types

This commit is contained in:
Daniel Marjamäki 2016-05-08 13:15:20 +02:00
parent f0953c6916
commit 636e97c272
3 changed files with 14 additions and 5 deletions

View File

@ -4416,8 +4416,16 @@ std::string ValueType::str() const
ret += " double";
else if (type == LONGDOUBLE)
ret += " long double";
else if (type == NONSTD && typeScope)
ret += ' ' + typeScope->className;
else if (type == NONSTD && typeScope) {
std::string className(typeScope->className);
const Scope *s = typeScope;
while (s->nestedIn && s->nestedIn->type != Scope::eGlobal) {
s = s->nestedIn;
if (s->type == Scope::eClass || s->type == Scope::eStruct || s->type == Scope::eNamespace)
className = s->className + "::" + className;
}
ret += ' ' + className;
}
for (unsigned int p = 0; p < pointer; p++) {
ret += " *";
if (constness & (2 << p))

View File

@ -2384,7 +2384,7 @@ const ValueFlow::Value *ValueFlow::valueFlowConstantFoldAST(const Token *expr)
valueFlowConstantFoldAST(expr->astOperand2());
valueFlowSetConstantValue(expr);
}
return expr && expr->values.size() == 1U && expr->values.front().isKnown() ? &expr->values.front() : nullptr;
return expr && expr->values.size() == 1U && expr->values.front().isKnown() ? &expr->values.front() : nullptr;
}

View File

@ -3222,8 +3222,9 @@ private:
ASSERT_EQUALS("signed int", typeOf("int x; a = x++;", "++"));
ASSERT_EQUALS("AB *", typeOf("enum AB {A,B}; AB *ab; x=ab+2;", "+"));
ASSERT_EQUALS("AB *", typeOf("enum AB {A,B}; enum AB *ab; x=ab+2;", "+"));
ASSERT_EQUALS("AB *", typeOf("struct AB {int A; int B;}; AB ab; x=&ab;", "&"));
ASSERT_EQUALS("AB *", typeOf("struct AB {int A; int B;}; struct AB ab; x=&ab;", "&"));
ASSERT_EQUALS("AB *", typeOf("struct AB {int a; int b;}; AB ab; x=&ab;", "&"));
ASSERT_EQUALS("AB *", typeOf("struct AB {int a; int b;}; struct AB ab; x=&ab;", "&"));
ASSERT_EQUALS("A::BC *", typeOf("namespace A { struct BC { int b; int c; }; }; struct A::BC abc; x=&abc;", "&"));
// Unary arithmetic/bit operators
ASSERT_EQUALS("signed int", typeOf("int x; a = -x;", "-"));