Skip to content

Commit 17bb316

Browse files
committed
symboldatabase: use qualifierBit() in ValueType::str() as well
str() tested constness/volatileness with 2 << p, which is the same out-of-range shift for pointer depths of 32 and above. Reachable via --debug-symdb and debugSymbolDatabase().
1 parent ffa42a8 commit 17bb316

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

‎lib/symboldatabase.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8938,9 +8938,9 @@ std::string ValueType::str() const
89388938
}
89398939
for (nonneg int p = 0; p < pointer; p++) {
89408940
ret += " *";
8941-
if (constness & (2 << p))
8941+
if (constness & qualifierBit(p + 1))
89428942
ret += " const";
8943-
if (volatileness & (2 << p))
8943+
if (volatileness & qualifierBit(p + 1))
89448944
ret += " volatile";
89458945
}
89468946
if (reference == Reference::LValue)

‎test/testsymboldatabase.cpp‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1889,6 +1889,10 @@ class TestSymbolDatabase : public TestFixture {
18891889
ASSERT(!p->valueType()->isVolatile(0));
18901890
ASSERT(p->valueType()->isConst(32));
18911891
ASSERT(p->valueType()->isVolatile(32));
1892+
std::string expected("signed int * const volatile");
1893+
for (int i = 1; i < 33; ++i)
1894+
expected += " *";
1895+
ASSERT_EQUALS(expected, p->valueType()->str());
18921896
}
18931897

18941898
void variableConstexpr() {

0 commit comments

Comments
 (0)