! * \brief Concatenate two char sequences * * \param lhs Pointers to the lhs char array * \param lhs_size The size of the lhs char array * \param rhs Pointers to the rhs char array * \param rhs_size The size of the rhs char array * * \return The concatenated char sequence */
| 795 | * \return The concatenated char sequence |
| 796 | */ |
| 797 | static String Concat(const char* lhs, size_t lhs_size, const char* rhs, size_t rhs_size) { |
| 798 | String ret; |
| 799 | // disable stringop-overflow and restrict warnings |
| 800 | // gcc may produce false positive when we enable dest_data returned from small string path |
| 801 | // Because compiler is not able to detect the condition that the path is only triggered via |
| 802 | // size < kMaxSmallStrLen and can report it as a overflow case. |
| 803 | #if (__GNUC__) && !(__clang__) |
| 804 | #pragma GCC diagnostic push |
| 805 | #pragma GCC diagnostic ignored "-Wstringop-overflow" |
| 806 | #pragma GCC diagnostic ignored "-Warray-bounds" |
| 807 | #pragma GCC diagnostic ignored "-Wrestrict" |
| 808 | #endif |
| 809 | char* dest_data = ret.InitSpaceForSize(lhs_size + rhs_size); |
| 810 | std::memcpy(dest_data, lhs, lhs_size); |
| 811 | std::memcpy(dest_data + lhs_size, rhs, rhs_size); |
| 812 | // NOLINTNEXTLINE(clang-analyzer-security.ArrayBound) |
| 813 | dest_data[lhs_size + rhs_size] = '\0'; |
| 814 | #if (__GNUC__) && !(__clang__) |
| 815 | #pragma GCC diagnostic pop |
| 816 | #endif |
| 817 | return ret; |
| 818 | } |
| 819 | // Overload + operator |
| 820 | friend String operator+(const String& lhs, const String& rhs); |
| 821 | friend String operator+(const String& lhs, const std::string& rhs); |
nothing calls this directly
no test coverage detected