[PATCH] D157026: TEST: Remove <iomanip> from gtest

Elliot Goodrich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 3 13:04:30 PDT 2023


IncludeGuardian created this revision.
Herald added a project: All.
IncludeGuardian requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This is an experimental commit to see whether any unit tests are transitively
depending on the `#include <iomanip>` directive from GoogleTest.

This include is responsible for ~0.45% of the preprocessing directives within
the LLVM project.  From the C++ Compile Health Watchdog <https://artificial-mind.net/projects/compile-health/>
we can see that this include adds 100-200ms of total compile time (20-30ms
preprocessing time).

This is now one of the single most expensive includes in LLVM <https://gist.github.com/IncludeGuardian/7e560c26783d5f11d7645c96db6b81d4#file-after-yaml-L4066-L4069>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157026

Files:
  third-party/unittest/googletest/include/gtest/gtest.h
  third-party/unittest/googletest/include/gtest/internal/gtest-internal.h


Index: third-party/unittest/googletest/include/gtest/internal/gtest-internal.h
===================================================================
--- third-party/unittest/googletest/include/gtest/internal/gtest-internal.h
+++ third-party/unittest/googletest/include/gtest/internal/gtest-internal.h
@@ -57,19 +57,18 @@
 #include <ctype.h>
 #include <float.h>
 #include <string.h>
-#include <iomanip>
 #include <limits>
 #include <map>
 #include <set>
 #include <string>
 #include <type_traits>
 #include <vector>

 #include "gtest/gtest-message.h"
 #include "gtest/internal/gtest-filepath.h"
 #include "gtest/internal/gtest-string.h"
 #include "gtest/internal/gtest-type-util.h"

 // Due to C++ preprocessor weirdness, we need double indirection to
 // concatenate two tokens when one of them is __LINE__.  Writing
 //
Index: third-party/unittest/googletest/include/gtest/gtest.h
===================================================================
--- third-party/unittest/googletest/include/gtest/gtest.h
+++ third-party/unittest/googletest/include/gtest/gtest.h
@@ -1737,20 +1737,18 @@
   }

   ::std::stringstream lhs_ss;
-  lhs_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
-         << lhs_value;
+  lhs_ss << lhs_value;

   ::std::stringstream rhs_ss;
-  rhs_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
-         << rhs_value;
+  rhs_ss << rhs_value;

   return EqFailure(lhs_expression,
                    rhs_expression,
                    StringStreamToString(&lhs_ss),
                    StringStreamToString(&rhs_ss),
                    false);
 }

 // Helper function for implementing ASSERT_NEAR.
 //
 // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157026.546968.patch
Type: text/x-patch
Size: 1724 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230803/10b2b54e/attachment.bin>


More information about the llvm-commits mailing list