summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Kashkarov <m.kashkarov@partner.samsung.com>2018-04-28 19:02:38 +0300
committerMikhail Kashkarov <m.kashkarov@partner.samsung.com>2018-04-28 19:02:38 +0300
commitade91a43e02a944e8aafb329e1e7d2fc30f95322 (patch)
treed8d5c71daaded58776b256c9db778f27e2fa9bee
parentfc92bf7af24c063906ec4c11b8ed6ffd813f7fa5 (diff)
downloadlinaro-gcc-ade91a43e02a944e8aafb329e1e7d2fc30f95322.tar.gz
linaro-gcc-ade91a43e02a944e8aafb329e1e7d2fc30f95322.tar.bz2
linaro-gcc-ade91a43e02a944e8aafb329e1e7d2fc30f95322.zip
Update setting correct string length.
Change-Id: I2bd419bca8ae332b11e0ea29126a6935a34df70a
-rw-r--r--libstdc++-v3/include/bits/basic_string.h19
-rw-r--r--libstdc++-v3/include/bits/basic_string.tcc39
2 files changed, 13 insertions, 45 deletions
diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h
index 4fddb173e72..2582ff08586 100644
--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -1008,10 +1008,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
assign(__str);
}
__str.clear();
- #ifdef _GLIBCXX_HAS_ASAN // str still can modify (in __str.clear func) this->_M_data ??
+#ifdef _GLIBCXX_HAS_ASAN
_M_capacity(__str_capacity);
+#ifdef _GLIBCXX_DISABLE_STRING_SSO
+ _M_allocated_capacity ? _M_set_length(__str_length) : _M_length(__str_length);
+#else
_M_set_length(__str_length);
- #endif
+#endif
+#endif
return *this;
}
@@ -1232,13 +1236,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
void
clear() _GLIBCXX_NOEXCEPT
{
- #ifdef _GLIBCXX_DISABLE_STRING_SSO
- _M_length(0);
- if (_M_allocated_capacity == 0)
- return;
- #endif
__annotate_grow(_M_string_length, 0);
- _M_set_length(0);
+#ifdef _GLIBCXX_DISABLE_STRING_SSO
+ _M_allocated_capacity ? _M_length(0) : _M_set_length(0);
+#else
+ _M_set_length(0);
+#endif
}
/**
diff --git a/libstdc++-v3/include/bits/basic_string.tcc b/libstdc++-v3/include/bits/basic_string.tcc
index 5a6902fde4f..d8fe861399e 100644
--- a/libstdc++-v3/include/bits/basic_string.tcc
+++ b/libstdc++-v3/include/bits/basic_string.tcc
@@ -222,10 +222,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
#ifdef _GLIBCXX_DISABLE_STRING_SSO
- if (capacity() > 0)
- _M_set_length(__len);
- else
- _M_length(__len);
+ _M_allocated_capacity ? _M_set_length(__len) : _M_length(__len);
__annotate_new(__len);
#else
_M_set_length(__len);
@@ -285,14 +282,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
if (__n)
this->_S_assign(_M_data(), __n, __c);
-#ifdef _GLIBCXX_DISABLE_STRING_SSO
- if (capacity() > 0)
- _M_set_length(__n);
- else
- _M_length(__n);
-#else
_M_set_length(__n);
-#endif
}
template<typename _CharT, typename _Traits, typename _Alloc>
@@ -323,10 +313,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#endif
{
#ifdef _GLIBCXX_DISABLE_STRING_SSO
- if (capacity() > 0)
- _M_set_length(__rsize);
- else
- _M_length(__rsize);
+ _M_allocated_capacity ? _M_set_length(__rsize) : _M_length(__rsize);
#else
_M_set_length(__rsize);
#endif
@@ -422,15 +409,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
this->_S_move(_M_data() + __pos, _M_data() + __pos + __n, __how_much);
const size_type __old_length = length();
-#ifdef _GLIBCXX_DISABLE_STRING_SSO
- const size_type __new_length = __old_length - __n;
- if (__new_length)
- _M_set_length(__new_length);
- else
- _M_length(__new_length);
-#else
_M_set_length(__old_length - __n);
-#endif
__annotate_grow(__old_length, __old_length - __n);
}
@@ -465,14 +444,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
else
this->_M_mutate(__old_len, size_type(0), __s, __n);
-#ifdef _GLIBCXX_DISABLE_STRING_SSO
- if (capacity() > 0)
- this->_M_set_length(__len);
- else
- this->_M_length(__len);
-#else
this->_M_set_length(__len);
-#endif
return *this;
}
@@ -577,14 +549,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
else
this->_M_mutate(__pos, __len1, __s, __len2);
-#ifdef _GLIBCXX_DISABLE_STRING_SSO
- if (capacity() > 0)
- this->_M_set_length(__new_size);
- else
- this->_M_length(__new_size);
-#else
this->_M_set_length(__new_size);
-#endif
return *this;
}