Skip to content

Commit cdfe9ae

Browse files
committed
Improve c/v handling
1 parent 63628bb commit cdfe9ae

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

lib/valueflow.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1948,10 +1948,12 @@ static bool isLifetimeBorrowed(const ValueType *vt, const ValueType *vtParent)
19481948
return true;
19491949
if (vtParent->pointer < vt->pointer && vtParent->isIntegral())
19501950
return true;
1951-
std::string vtParentStr = vtParent->str();
1952-
if (startsWith(vtParentStr, "const ")) // HACK: assignment to const
1953-
vtParentStr.erase(0, 6);
1954-
if (vtParentStr == vt->str())
1951+
ValueType temp = *vtParent;
1952+
if ((temp.constness & 1) && !(vt->constness & 1)) // allow assignment to const/volatile
1953+
temp.constness &= ~1;
1954+
if ((temp.volatileness & 1) && !(vt->volatileness & 1))
1955+
temp.volatileness &= ~1;
1956+
if (temp.str() == vt->str())
19551957
return true;
19561958
}
19571959

0 commit comments

Comments
 (0)