Skip to content

Commit

Permalink
Various cleanups in xls/{common,simulation,tools}
Browse files Browse the repository at this point in the history
  • Loading branch information
hzeller committed May 21, 2024
1 parent 3825ab3 commit ce440e7
Show file tree
Hide file tree
Showing 55 changed files with 179 additions and 54 deletions.
2 changes: 2 additions & 0 deletions xls/common/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ cc_test(
deps = [
":math_util",
":xls_gunit_main",
"@com_google_absl//absl/base:core_headers",
"@com_google_fuzztest//fuzztest",
"@com_google_googletest//:gtest",
],
Expand Down Expand Up @@ -331,6 +332,7 @@ cc_library(
"//xls/common/status:status_macros",
"@com_google_absl//absl/log",
"@com_google_absl//absl/numeric:int128",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
Expand Down
1 change: 1 addition & 0 deletions xls/common/case_converters.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.
#include "xls/common/case_converters.h"

#include <cctype>
#include <string>
#include <string_view>
#include <vector>
Expand Down
5 changes: 2 additions & 3 deletions xls/common/file/file_descriptor_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "xls/common/file/file_descriptor.h"

#include <cstdint>
#include <cstdio>
#include <filesystem> // NOLINT
#include <string>
#include <utility>
Expand Down Expand Up @@ -99,9 +100,7 @@ TEST_F(FileDescriptorTest, FileDescriptorIsClosedAndResetOnClose) {
}

TEST_F(FileDescriptorTest, FileDescriptorIsClosedOnDestruction) {
{
MockFileDescriptor fd(6);
}
{ MockFileDescriptor fd(6); }

EXPECT_EQ(recently_closed_fd, 6);
}
Expand Down
2 changes: 2 additions & 0 deletions xls/common/file/named_pipe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "xls/common/file/named_pipe.h"

#include <sys/stat.h>
#include <unistd.h>

#include <cerrno>
#include <cstdio>
Expand All @@ -28,6 +29,7 @@
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_format.h"
#include "xls/common/file/file_descriptor.h"
#include "xls/common/status/error_code_to_status.h"
#include "xls/common/status/status_macros.h"

Expand Down
3 changes: 2 additions & 1 deletion xls/common/file/temp_directory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@

#include "xls/common/file/temp_directory.h"

#include <cstdlib>
#include <filesystem> // NOLINT
#include <string>
#include <system_error>
#include <system_error> // NOLINT
#include <utility>

#include "absl/log/log.h"
Expand Down
5 changes: 3 additions & 2 deletions xls/common/file/temp_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
#include <fcntl.h>
#include <unistd.h>

#include <cerrno>
#include <cstdlib>
#include <filesystem> // NOLINT
#include <string>
#include <string_view>
#include <system_error>
#include <system_error> // NOLINT
#include <utility>

#include "absl/log/log.h"
Expand All @@ -45,7 +47,6 @@ absl::Status WriteContent(int fd, std::string_view content) {
}
return absl::UnavailableError(absl::StrCat(
"Failed to write content to temporary file: ", Strerror(errno)));

}
bytes_written += bytes_written_this_time;
}
Expand Down
7 changes: 5 additions & 2 deletions xls/common/file/temp_file_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@

#include "xls/common/file/temp_file.h"

#include <stdlib.h>
#include <unistd.h>

#include <filesystem> // NOLINT
#include <string>
#include <system_error>
#include <utility>

#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "absl/status/status.h"
#include "absl/strings/match.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "xls/common/file/filesystem.h"
#include "xls/common/status/matchers.h"

Expand Down
3 changes: 2 additions & 1 deletion xls/common/logging/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ cc_test(
":log_lines",
":scoped_mock_log",
"//xls/common:xls_gunit_main",
"@com_google_absl//absl/base:log_severity",
"@com_google_googletest//:gtest",
],
)
Expand Down Expand Up @@ -97,7 +98,7 @@ cc_binary(
testonly = True,
srcs = ["log_initialization_tester.cc"],
deps = [
"@com_google_absl//absl/log",
"//xls/common:init_xls",
"@com_google_absl//absl/log",
],
)
4 changes: 4 additions & 0 deletions xls/common/logging/log_flags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

#include "xls/common/logging/log_flags.h"

#include <algorithm>

#include "absl/base/log_severity.h"
#include "absl/flags/flag.h"
#include "absl/log/globals.h"

namespace {
Expand Down
2 changes: 2 additions & 0 deletions xls/common/logging/log_lines_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <string>
#include <string_view>

#include "absl/base/log_severity.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "xls/common/logging/scoped_mock_log.h"

Expand Down
5 changes: 4 additions & 1 deletion xls/common/math_util_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@

#include "xls/common/math_util.h"

#include <sys/types.h>

#include <algorithm>
#include <cstdint>
#include <limits>

#include "gtest/gtest.h"
#include "absl/base/macros.h"
#include "fuzztest/fuzztest.h"
#include "gtest/gtest.h"

namespace xls {
namespace {
Expand Down
24 changes: 13 additions & 11 deletions xls/common/status/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ cc_test(
deps = [
":error_code_to_status",
":matchers",
"@com_google_absl//absl/status",
"//xls/common:xls_gunit_main",
"@com_google_absl//absl/status",
"@com_google_googletest//:gtest",
],
)
Expand All @@ -55,11 +55,11 @@ cc_library(
deps = [
":status_builder",
":status_macros",
"//xls/common:source_location",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/base:log_severity",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"//xls/common:source_location",
],
)

Expand All @@ -69,10 +69,11 @@ cc_test(
deps = [
":matchers",
":ret_check",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"//xls/common:xls_gunit_main",
"//xls/common/logging:scoped_mock_log",
"@com_google_absl//absl/base:log_severity",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_googletest//:gtest",
],
)
Expand All @@ -85,6 +86,8 @@ cc_library(
],
hdrs = ["status_builder.h"],
deps = [
"//xls/common:source_location",
"//xls/common:symbolized_stacktrace",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/base:log_severity",
"@com_google_absl//absl/container:flat_hash_map",
Expand All @@ -93,11 +96,10 @@ cc_library(
"@com_google_absl//absl/log:log_sink",
"@com_google_absl//absl/status",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:cord",
"@com_google_absl//absl/synchronization",
"@com_google_absl//absl/time",
"@com_google_absl//absl/types:span",
"//xls/common:source_location",
"//xls/common:symbolized_stacktrace",
],
)

Expand All @@ -106,6 +108,9 @@ cc_test(
srcs = ["status_builder_test.cc"],
deps = [
":status_builder",
"//xls/common:source_location",
"//xls/common:xls_gunit_main",
"//xls/common/logging:scoped_mock_log",
"@com_google_absl//absl/base:log_severity",
"@com_google_absl//absl/log:globals",
"@com_google_absl//absl/log:log_entry",
Expand All @@ -114,9 +119,6 @@ cc_test(
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/time",
"//xls/common:source_location",
"//xls/common:xls_gunit_main",
"//xls/common/logging:scoped_mock_log",
"@com_google_googletest//:gtest",
],
)
Expand All @@ -127,9 +129,9 @@ cc_library(
visibility = ["//xls:xls_utility_users"],
deps = [
":status_builder",
"//xls/common:source_location",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/status",
"//xls/common:source_location",
],
)

Expand All @@ -139,9 +141,9 @@ cc_test(
deps = [
":status_builder",
":status_macros",
"//xls/common:xls_gunit_main",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"//xls/common:xls_gunit_main",
"@com_google_googletest//:gtest",
],
)
Expand Down
1 change: 1 addition & 0 deletions xls/common/status/error_code_to_status.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <system_error> // NOLINT(build/c++11)

#include "absl/status/status.h"
#include "xls/common/status/status_builder.h"

namespace xls {

Expand Down
3 changes: 3 additions & 0 deletions xls/common/status/matchers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

#include "absl/status/status.h"
#include "absl/strings/str_cat.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "xls/common/status/status_builder.h"

namespace xls {
namespace status_testing {
Expand Down
1 change: 1 addition & 0 deletions xls/common/status/ret_check.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "absl/base/log_severity.h"
#include "absl/status/status.h"
#include "xls/common/source_location.h"
#include "xls/common/status/status_builder.h"

namespace xls {
namespace internal_status_macros_ret_check {
Expand Down
5 changes: 3 additions & 2 deletions xls/common/status/ret_check_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@

#include <string>

#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "absl/base/log_severity.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "xls/common/logging/scoped_mock_log.h"
#include "xls/common/status/matchers.h"

Expand Down
4 changes: 4 additions & 0 deletions xls/common/status/status_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

#include "xls/common/status/status_builder.h"

#include <sys/types.h>

#include <memory>
#include <optional>
#include <ostream>
Expand All @@ -29,9 +31,11 @@
#include "absl/log/log_entry.h"
#include "absl/log/log_sink.h"
#include "absl/status/status.h"
#include "absl/strings/cord.h"
#include "absl/strings/str_cat.h"
#include "absl/synchronization/mutex.h"
#include "absl/time/clock.h"
#include "absl/time/time.h"
#include "xls/common/source_location.h"
#include "xls/common/symbolized_stacktrace.h"

Expand Down
5 changes: 3 additions & 2 deletions xls/common/status/status_macros_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@

#include "xls/common/status/status_macros.h"

#include <cstddef>
#include <memory>
#include <string>
#include <string_view>
#include <tuple>
#include <utility>

#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "xls/common/status/status_builder.h"

namespace {
Expand Down
1 change: 1 addition & 0 deletions xls/common/strerror.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include "xls/common/strerror.h"

#include <cstring>
#include <string>
#include <type_traits>

Expand Down
1 change: 1 addition & 0 deletions xls/common/strerror_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "xls/common/strerror.h"

#include <cerrno>
#include <cstring>

#include "gtest/gtest.h"

Expand Down
1 change: 1 addition & 0 deletions xls/common/string_to_int.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "absl/log/log.h"
#include "absl/numeric/int128.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_format.h"
#include "absl/strings/strip.h"
Expand Down
Loading

0 comments on commit ce440e7

Please sign in to comment.