summaryrefslogtreecommitdiff
path: root/src/base
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2018-01-29 14:42:26 -0800
committerGabe Black <gabeblack@google.com>2018-01-29 23:48:24 +0000
commitcca6459b4fe68593137cb0f3ede7d1415cdbd522 (patch)
tree0afa5d9b94e28a8bb805f26b21ccf2d7c80567de /src/base
parentba7a202ffac695dd2c6c9c7254d34d89dea68eaf (diff)
downloadgem5-cca6459b4fe68593137cb0f3ede7d1415cdbd522.tar.xz
base: Remove the ability to cprintf stringstreams directly.
The cprintf functions don't know ahead of time what format characters are going to be used with what underlying data types, and so any type must be minimally usable with the default specialization of format_integer, format_char, format_float and format_string. All of those functions ultimately print their parameter with out << data except the one which prints stringstreams. That function accesses the buffer of the string stream with .str(), and then prints that instead. That should technically work out ok as long as stringstreams are only printed using %s, but there's no way to guarantee that ahead of time. To avoid that problem, and because gem5 doesn't ever actually use the ability to print stringstreams directly, this change removes that feature and modifies the corresponding part of the unit test. If we ever do want to print the contents of a string stream, it won't be difficult to add a .str() to it. Change-Id: Id902eaff042b96b374efe0183e5e3be9626e8c88 Reviewed-on: https://gem5-review.googlesource.com/7642 Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/base')
-rw-r--r--src/base/cprintf_formats.hh4
-rw-r--r--src/base/cprintftest.cc2
2 files changed, 1 insertions, 5 deletions
diff --git a/src/base/cprintf_formats.hh b/src/base/cprintf_formats.hh
index 4c78fdf50..f55fb955e 100644
--- a/src/base/cprintf_formats.hh
+++ b/src/base/cprintf_formats.hh
@@ -337,10 +337,6 @@ inline void
format_string(std::ostream &out, const T &data, Format &fmt)
{ _format_string(out, data, fmt); }
-inline void
-format_string(std::ostream &out, const std::stringstream &data, Format &fmt)
-{ _format_string(out, data.str(), fmt); }
-
} // namespace cp
#endif // __CPRINTF_FORMATS_HH__
diff --git a/src/base/cprintftest.cc b/src/base/cprintftest.cc
index 86694ed83..3a1b97e40 100644
--- a/src/base/cprintftest.cc
+++ b/src/base/cprintftest.cc
@@ -166,7 +166,7 @@ TEST(CPrintf, Types)
std::stringstream foo2;
foo2 << "stringstream test";
- ccprintf(ss, "%s\n", foo2);
+ ccprintf(ss, "%s\n", foo2.str());
EXPECT_EQ(ss.str(), "stringstream test\n");
ss.str("");