Replace `crubit/common/check.h` with `absl/log/...`.
- `CRUBIT_CHECK` becomes `CHECK`, or `LOG(FATAL)`, (or `CHECK_LE`, etc.)
- `CRUBIT_DIE_IF_NULL` becomes `ABSL_DIE_IF_NULL`
PiperOrigin-RevId: 470239907
diff --git a/common/BUILD b/common/BUILD
index 1cf9dad..700be73 100644
--- a/common/BUILD
+++ b/common/BUILD
@@ -56,15 +56,6 @@
)
cc_library(
- name = "check",
- hdrs = ["check.h"],
- deps = [
- "@absl//absl/base:core_headers",
- "@llvm-project//llvm:Support",
- ],
-)
-
-cc_library(
name = "strong_int",
hdrs = ["strong_int.h"],
deps = [
@@ -123,8 +114,8 @@
srcs = ["test_utils.cc"],
hdrs = ["test_utils.h"],
deps = [
- ":check",
":file_io",
+ "@absl//absl/log:check",
"@absl//absl/strings",
"@com_google_googletest//:gtest",
"@llvm-project//llvm:Support",
diff --git a/common/check.h b/common/check.h
deleted file mode 100644
index cfe26a7..0000000
--- a/common/check.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// Part of the Crubit project, under the Apache License v2.0 with LLVM
-// Exceptions. See /LICENSE for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-#ifndef CRUBIT_COMMON_CHECK_H_
-#define CRUBIT_COMMON_CHECK_H_
-
-#include "absl/base/attributes.h"
-#include "absl/base/optimization.h"
-#include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/FormatVariadic.h"
-
-#define CRUBIT_CHECK(condition) \
- do { \
- if (ABSL_PREDICT_FALSE(!(condition))) { \
- ::llvm::report_fatal_error( \
- ::llvm::formatv("CRUBIT_CHECK failure: {0}:{1}: {2}", __FILE__, \
- __LINE__, #condition)); \
- } \
- } while (false)
-
-namespace crubit {
-template <typename T>
-ABSL_MUST_USE_RESULT T DieIfNull(const char* file, int line,
- const char* exprtext, T&& t) {
- if (ABSL_PREDICT_FALSE(t == nullptr)) {
- ::llvm::report_fatal_error(llvm::formatv(
- "CRUBIT_DIE_IF_NULL failure: {0}:{1}: {2}", file, line, exprtext));
- }
- return std::forward<T>(t);
-}
-} // namespace crubit
-#define CRUBIT_DIE_IF_NULL(value) \
- ::crubit::DieIfNull(__FILE__, __LINE__, #value, (value))
-
-#endif // CRUBIT_COMMON_CHECK_H_
diff --git a/common/test_utils.cc b/common/test_utils.cc
index a6a5eb9..74f24d6 100644
--- a/common/test_utils.cc
+++ b/common/test_utils.cc
@@ -8,7 +8,7 @@
#include <vector>
#include "gtest/gtest.h"
-#include "common/check.h"
+#include "absl/log/check.h"
#include "common/file_io.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
@@ -22,14 +22,14 @@
absl::StrCat(testing::TempDir(), "/", current_test_name, "/");
llvm::StringRef parent_dir =
llvm::sys::path::parent_path(current_test_tmpdir_path);
- CRUBIT_CHECK(!llvm::sys::fs::create_directories(parent_dir));
+ CHECK(!llvm::sys::fs::create_directories(parent_dir));
return current_test_tmpdir_path;
}
std::string WriteFileForCurrentTest(absl::string_view filename,
absl::string_view content) {
std::string path = absl::StrCat(MakeTmpdirForCurrentTest(), "/", filename);
- CRUBIT_CHECK(SetFileContents(path, content).ok());
+ CHECK(SetFileContents(path, content).ok());
return path;
}
diff --git a/migrator/rs_from_cc/BUILD b/migrator/rs_from_cc/BUILD
index 557f69d..327992a 100644
--- a/migrator/rs_from_cc/BUILD
+++ b/migrator/rs_from_cc/BUILD
@@ -10,10 +10,10 @@
":rs_from_cc_lib",
"@absl//absl/flags:flag",
"@absl//absl/flags:parse",
+ "@absl//absl/log:check",
"@absl//absl/status",
"@absl//absl/status:statusor",
"@absl//absl/strings",
- "//common:check",
"//common:file_io",
"@llvm-project//llvm:Support",
"//common:rust_allocator_shims",
@@ -39,7 +39,7 @@
hdrs = ["ast_consumer.h"],
deps = [
":converter",
- "//common:check",
+ "@absl//absl/log:check",
"@llvm-project//clang:ast",
"@llvm-project//clang:frontend",
],
diff --git a/migrator/rs_from_cc/ast_consumer.cc b/migrator/rs_from_cc/ast_consumer.cc
index c41bbad..649c97b 100644
--- a/migrator/rs_from_cc/ast_consumer.cc
+++ b/migrator/rs_from_cc/ast_consumer.cc
@@ -4,7 +4,7 @@
#include "migrator/rs_from_cc/ast_consumer.h"
-#include "common/check.h"
+#include "absl/log/check.h"
#include "migrator/rs_from_cc/converter.h"
#include "clang/AST/ASTContext.h"
#include "clang/Frontend/CompilerInstance.h"
@@ -19,7 +19,7 @@
// There is nothing more for us to do here.
return;
}
- CRUBIT_CHECK(instance_.hasSema());
+ CHECK(instance_.hasSema());
Converter converter(invocation_, ast_context);
converter.Convert(ast_context.getTranslationUnitDecl());
}
diff --git a/migrator/rs_from_cc/rs_from_cc.cc b/migrator/rs_from_cc/rs_from_cc.cc
index 40e7cfd..3bd2b45 100644
--- a/migrator/rs_from_cc/rs_from_cc.cc
+++ b/migrator/rs_from_cc/rs_from_cc.cc
@@ -9,10 +9,10 @@
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
+#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/string_view.h"
-#include "common/check.h"
#include "common/file_io.h"
#include "migrator/rs_from_cc/rs_from_cc_lib.h"
#include "llvm/Support/FileSystem.h"
@@ -38,7 +38,7 @@
}
auto status_or_cc_file_content = crubit::GetFileContents(cc_in);
- CRUBIT_CHECK(status_or_cc_file_content.ok());
+ CHECK(status_or_cc_file_content.ok());
std::string cc_file_content = std::move(*status_or_cc_file_content);
// Skip $0.
@@ -47,10 +47,8 @@
absl::StatusOr<std::string> rs_code = crubit_rs_from_cc::RsFromCc(
cc_file_content, cc_in,
std::vector<absl::string_view>(argv, argv + argc));
- if (!rs_code.ok()) {
- CRUBIT_CHECK(rs_code.ok());
- }
+ CHECK(rs_code.ok());
- CRUBIT_CHECK(crubit::SetFileContents(rs_out, *rs_code).ok());
+ CHECK(crubit::SetFileContents(rs_out, *rs_code).ok());
return 0;
}
diff --git a/nullability_verification/BUILD b/nullability_verification/BUILD
index 3ebbdbd..3dce169 100644
--- a/nullability_verification/BUILD
+++ b/nullability_verification/BUILD
@@ -17,7 +17,7 @@
deps = [
":pointer_nullability",
":pointer_nullability_matchers",
- "//common:check",
+ "@absl//absl/log:check",
"@llvm-project//clang:analysis",
"@llvm-project//clang:ast",
"@llvm-project//clang:ast_matchers",
diff --git a/nullability_verification/pointer_nullability_analysis.cc b/nullability_verification/pointer_nullability_analysis.cc
index 773d3c6..83136b4 100644
--- a/nullability_verification/pointer_nullability_analysis.cc
+++ b/nullability_verification/pointer_nullability_analysis.cc
@@ -6,7 +6,7 @@
#include <string>
-#include "common/check.h"
+#include "absl/log/check.h"
#include "nullability_verification/pointer_nullability.h"
#include "nullability_verification/pointer_nullability_matchers.h"
#include "clang/AST/ASTContext.h"
diff --git a/rs_bindings_from_cc/BUILD b/rs_bindings_from_cc/BUILD
index 82c43bc..51db342 100644
--- a/rs_bindings_from_cc/BUILD
+++ b/rs_bindings_from_cc/BUILD
@@ -114,7 +114,6 @@
hdrs = ["ast_util.h"],
visibility = ["//:__subpackages__"],
deps = [
- "//common:check",
"@llvm-project//clang:ast",
],
)
@@ -124,8 +123,8 @@
srcs = ["bazel_types.cc"],
hdrs = ["bazel_types.h"],
deps = [
- "//common:check",
"//common:string_type",
+ "@absl//absl/log:check",
"@absl//absl/strings",
],
)
@@ -175,8 +174,8 @@
":bazel_types",
"//lifetime_annotations",
"@absl//absl/container:flat_hash_map",
+ "@absl//absl/log:check",
"@absl//absl/status:statusor",
- "@llvm-project//clang:ast",
],
)
@@ -199,7 +198,7 @@
deps = [
":decl_importer",
":importer",
- "//common:check",
+ "@absl//absl/log:check",
"@llvm-project//clang:ast",
"@llvm-project//clang:frontend",
],
@@ -210,14 +209,12 @@
srcs = ["importer.cc"],
hdrs = ["importer.h"],
deps = [
- ":ast_convert",
+ ":ast_util",
":bazel_types",
":cc_ir",
":decl_importer",
- "//common:check",
"//common:status_macros",
"//lifetime_annotations:type_lifetimes",
- "//rs_bindings_from_cc:ast_util",
"//rs_bindings_from_cc/importers:class_template",
"//rs_bindings_from_cc/importers:cxx_record",
"//rs_bindings_from_cc/importers:enum",
@@ -228,6 +225,9 @@
"//rs_bindings_from_cc/importers:typedef_name",
"@absl//absl/container:flat_hash_map",
"@absl//absl/container:flat_hash_set",
+ "@absl//absl/log",
+ "@absl//absl/log:check",
+ "@absl//absl/log:die_if_null",
"@absl//absl/status",
"@absl//absl/status:statusor",
"@absl//absl/strings",
@@ -262,9 +262,9 @@
hdrs = ["ir.h"],
deps = [
":bazel_types",
- "//common:check",
"//common:strong_int",
"@absl//absl/container:flat_hash_map",
+ "@absl//absl/log:check",
"@absl//absl/status:statusor",
"@absl//absl/strings",
"@llvm-project//clang:ast",
@@ -315,14 +315,12 @@
":bazel_types",
":cc_ir",
":frontend_action",
- ":importer",
- "//common:check",
"@absl//absl/container:flat_hash_map",
+ "@absl//absl/log:check",
"@absl//absl/status",
"@absl//absl/status:statusor",
"@absl//absl/strings",
"@absl//absl/types:span",
- "@llvm-project//clang:basic",
"@llvm-project//clang:frontend",
"@llvm-project//clang:tooling",
],
@@ -416,8 +414,8 @@
visibility = ["//rs_bindings_from_cc:__subpackages__"],
deps = [
":cc_ir",
- "//common:check",
"@absl//absl/functional:function_ref",
+ "@absl//absl/log:check",
"@llvm-project//clang:ast",
"@llvm-project//clang:basic",
],
@@ -495,7 +493,6 @@
deps = [
":collect_instantiations",
"//common:cc_ffi_types",
- "//common:check",
"@absl//absl/status:statusor",
"@absl//absl/types:span",
"@llvm-project//llvm:Support",
diff --git a/rs_bindings_from_cc/ast_consumer.cc b/rs_bindings_from_cc/ast_consumer.cc
index d55eb80..80572bc 100644
--- a/rs_bindings_from_cc/ast_consumer.cc
+++ b/rs_bindings_from_cc/ast_consumer.cc
@@ -4,7 +4,7 @@
#include "rs_bindings_from_cc/ast_consumer.h"
-#include "common/check.h"
+#include "absl/log/check.h"
#include "rs_bindings_from_cc/importer.h"
#include "clang/AST/ASTContext.h"
#include "clang/Frontend/CompilerInstance.h"
@@ -19,7 +19,7 @@
// There is nothing more for us to do here.
return;
}
- CRUBIT_CHECK(instance_.hasSema());
+ CHECK(instance_.hasSema());
Importer importer(invocation_, ast_context, instance_.getSema());
importer.Import(ast_context.getTranslationUnitDecl());
}
diff --git a/rs_bindings_from_cc/ast_convert.cc b/rs_bindings_from_cc/ast_convert.cc
index ffdf43b..575a221 100644
--- a/rs_bindings_from_cc/ast_convert.cc
+++ b/rs_bindings_from_cc/ast_convert.cc
@@ -5,7 +5,7 @@
#include "rs_bindings_from_cc/ast_convert.h"
#include "absl/functional/function_ref.h"
-#include "common/check.h"
+#include "absl/log/check.h"
#include "rs_bindings_from_cc/ir.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h"
@@ -86,9 +86,8 @@
case clang::AS_private:
return SpecialMemberFunc::kUnavailable;
case clang::AS_none:
- CRUBIT_CHECK(
- false &&
- "We should never be encoding a 'none' access specifier in IR.");
+ CHECK(false &&
+ "We should never be encoding a 'none' access specifier in IR.");
// We have to return something. kDeleted seems like a safe fallback.
return SpecialMemberFunc::kUnavailable;
}
diff --git a/rs_bindings_from_cc/ast_util.cc b/rs_bindings_from_cc/ast_util.cc
index 93fce47..ff8df3b 100644
--- a/rs_bindings_from_cc/ast_util.cc
+++ b/rs_bindings_from_cc/ast_util.cc
@@ -4,7 +4,6 @@
#include "rs_bindings_from_cc/ast_util.h"
-#include "common/check.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclTemplate.h"
diff --git a/rs_bindings_from_cc/bazel_types.cc b/rs_bindings_from_cc/bazel_types.cc
index dd8f60a..62f82a9 100644
--- a/rs_bindings_from_cc/bazel_types.cc
+++ b/rs_bindings_from_cc/bazel_types.cc
@@ -6,9 +6,9 @@
#include <limits>
+#include "absl/log/check.h"
#include "absl/strings/ascii.h"
#include "absl/strings/str_cat.h"
-#include "common/check.h"
namespace crubit {
@@ -32,8 +32,8 @@
}
result.shrink_to_fit();
- CRUBIT_CHECK(!result.empty());
- CRUBIT_CHECK(absl::ascii_isalpha(result[0]) || result[0] == '_');
+ CHECK(!result.empty());
+ CHECK(absl::ascii_isalpha(result[0]) || result[0] == '_');
return result;
}
diff --git a/rs_bindings_from_cc/decl_importer.h b/rs_bindings_from_cc/decl_importer.h
index 8ceda89..13fe0ca 100644
--- a/rs_bindings_from_cc/decl_importer.h
+++ b/rs_bindings_from_cc/decl_importer.h
@@ -6,6 +6,7 @@
#define CRUBIT_RS_BINDINGS_FROM_CC_DECL_IMPORTER_H_
#include "absl/container/flat_hash_map.h"
+#include "absl/log/check.h"
#include "absl/status/statusor.h"
#include "lifetime_annotations/lifetime_annotations.h"
#include "rs_bindings_from_cc/bazel_types.h"
@@ -25,8 +26,8 @@
clang::tidy::lifetimes::LifetimeAnnotationContext>()),
header_targets_(header_targets) {
// Caller should verify that the inputs are non-empty.
- CRUBIT_CHECK(!entry_headers_.empty());
- CRUBIT_CHECK(!header_targets_.empty());
+ CHECK(!entry_headers_.empty());
+ CHECK(!header_targets_.empty());
ir_.used_headers.insert(ir_.used_headers.end(), entry_headers_.begin(),
entry_headers.end());
diff --git a/rs_bindings_from_cc/importer.cc b/rs_bindings_from_cc/importer.cc
index ba08915..1af97ea 100644
--- a/rs_bindings_from_cc/importer.cc
+++ b/rs_bindings_from_cc/importer.cc
@@ -18,6 +18,8 @@
#include "absl/container/flat_hash_map.h"
#include "absl/container/flat_hash_set.h"
+#include "absl/log/check.h"
+#include "absl/log/log.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/cord.h"
@@ -25,7 +27,6 @@
#include "absl/strings/str_join.h"
#include "absl/strings/string_view.h"
#include "absl/strings/substitute.h"
-#include "common/check.h"
#include "common/status_macros.h"
#include "lifetime_annotations/type_lifetimes.h"
#include "rs_bindings_from_cc/ast_util.h"
@@ -735,7 +736,7 @@
std::move(mapped_return_type),
std::move(mapped_param_types));
} else {
- CRUBIT_CHECK(type->isLValueReferenceType());
+ CHECK(type->isLValueReferenceType());
return MappedType::FuncRef(cc_call_conv, rs_abi, lifetime,
std::move(mapped_return_type),
std::move(mapped_param_types));
@@ -751,7 +752,7 @@
return MappedType::LValueReferenceTo(std::move(mapped_pointee_type),
lifetime);
} else {
- CRUBIT_CHECK(type->isRValueReferenceType());
+ CHECK(type->isRValueReferenceType());
if (!lifetime.has_value()) {
return absl::UnimplementedError(
"Unsupported type: && without lifetime");
@@ -801,7 +802,7 @@
} else if (const auto* deduced_type = type->getAs<clang::DeducedType>()) {
// Deduction should have taken place earlier (e.g. via DeduceReturnType
// called from FunctionDeclImporter::Import).
- CRUBIT_CHECK(deduced_type->isDeduced());
+ CHECK(deduced_type->isDeduced());
return ConvertQualType(deduced_type->getDeducedType(), lifetimes);
}
@@ -868,7 +869,7 @@
// with regular C and C++ structs.
constexpr llvm::StringRef kZtsPrefix = "_ZTS";
constexpr llvm::StringRef kCcTemplatePrefix = "__CcTemplateInst";
- CRUBIT_CHECK(buffer.str().take_front(4) == kZtsPrefix);
+ CHECK(buffer.str().take_front(4) == kZtsPrefix);
return llvm::formatv("{0}{1}", kCcTemplatePrefix,
buffer.str().drop_front(kZtsPrefix.size()));
}
@@ -972,12 +973,10 @@
case clang::DeclarationName::CXXOperatorName:
switch (named_decl->getDeclName().getCXXOverloadedOperator()) {
case clang::OO_None:
- CRUBIT_CHECK(false &&
- "No OO_None expected under CXXOperatorName branch");
+ LOG(FATAL) << "No OO_None expected under CXXOperatorName branch";
return std::nullopt;
case clang::NUM_OVERLOADED_OPERATORS:
- CRUBIT_CHECK(false &&
- "No NUM_OVERLOADED_OPERATORS expected at runtime");
+ LOG(FATAL) << "No NUM_OVERLOADED_OPERATORS expected at runtime";
return std::nullopt;
// clang-format off
#define OVERLOADED_OPERATOR(name, spelling, ...) \
@@ -988,7 +987,7 @@
#undef OVERLOADED_OPERATOR
// clang-format on
}
- CRUBIT_CHECK(false && "The `switch` above should handle all cases");
+ LOG(FATAL) << "The `switch` above should handle all cases";
return std::nullopt;
default:
// To be implemented later: CXXConversionFunctionName.
diff --git a/rs_bindings_from_cc/importer.h b/rs_bindings_from_cc/importer.h
index f6bc8a1..2ee373c 100644
--- a/rs_bindings_from_cc/importer.h
+++ b/rs_bindings_from_cc/importer.h
@@ -12,6 +12,7 @@
#include <utility>
#include <vector>
+#include "absl/log/die_if_null.h"
#include "rs_bindings_from_cc/decl_importer.h"
#include "rs_bindings_from_cc/importers/class_template.h"
#include "rs_bindings_from_cc/importers/cxx_record.h"
@@ -35,7 +36,7 @@
explicit Importer(Invocation& invocation, clang::ASTContext& ctx,
clang::Sema& sema)
: ImportContext(invocation, ctx, sema),
- mangler_(CRUBIT_DIE_IF_NULL(ctx_.createMangleContext())) {
+ mangler_(ABSL_DIE_IF_NULL(ctx_.createMangleContext())) {
decl_importers_.push_back(
std::make_unique<ClassTemplateDeclImporter>(*this));
decl_importers_.push_back(std::make_unique<CXXRecordDeclImporter>(*this));
diff --git a/rs_bindings_from_cc/importers/BUILD b/rs_bindings_from_cc/importers/BUILD
index cb20ded..0d6e914 100644
--- a/rs_bindings_from_cc/importers/BUILD
+++ b/rs_bindings_from_cc/importers/BUILD
@@ -17,9 +17,11 @@
srcs = ["cxx_record.cc"],
hdrs = ["cxx_record.h"],
deps = [
+ "@absl//absl/log",
+ "@absl//absl/log:check",
+ "@absl//absl/log:die_if_null",
"@absl//absl/strings",
"//rs_bindings_from_cc:ast_convert",
- "//rs_bindings_from_cc:ast_util",
"//rs_bindings_from_cc:decl_importer",
"@llvm-project//clang:ast",
"@llvm-project//clang:sema",
@@ -74,6 +76,7 @@
srcs = ["namespace.cc"],
hdrs = ["namespace.h"],
deps = [
+ "@absl//absl/log:check",
"@absl//absl/strings",
"//rs_bindings_from_cc:decl_importer",
"@llvm-project//clang:ast",
@@ -85,6 +88,7 @@
srcs = ["typedef_name.cc"],
hdrs = ["typedef_name.h"],
deps = [
+ "@absl//absl/log:check",
"//rs_bindings_from_cc:decl_importer",
"@llvm-project//clang:ast",
],
diff --git a/rs_bindings_from_cc/importers/cxx_record.cc b/rs_bindings_from_cc/importers/cxx_record.cc
index edb36c5..1653c60 100644
--- a/rs_bindings_from_cc/importers/cxx_record.cc
+++ b/rs_bindings_from_cc/importers/cxx_record.cc
@@ -4,6 +4,9 @@
#include "rs_bindings_from_cc/importers/cxx_record.h"
+#include "absl/log/check.h"
+#include "absl/log/die_if_null.h"
+#include "absl/log/log.h"
#include "absl/strings/match.h"
#include "rs_bindings_from_cc/ast_convert.h"
#include "clang/AST/ASTContext.h"
@@ -66,9 +69,8 @@
case clang::AS_private:
return kPrivate;
case clang::AS_none:
- CRUBIT_CHECK(
- false &&
- "We should never be encoding a 'none' access specifier in IR.");
+ LOG(FATAL)
+ << "We should never be encoding a 'none' access specifier in IR.";
// We have to return something. Conservatively return private so we don't
// inadvertently make a private member variable accessible in Rust.
return kPrivate;
@@ -158,7 +160,7 @@
if (clang::CXXRecordDecl* complete = record_decl->getDefinition()) {
record_decl = complete;
} else {
- CRUBIT_CHECK(!record_decl->isCompleteDefinition());
+ CHECK(!record_decl->isCompleteDefinition());
ictx_.MarkAsSuccessfullyImported(record_decl);
return IncompleteRecord{
.cc_name = std::move(cc_name),
@@ -272,10 +274,9 @@
std::optional<Identifier> field_name =
ictx_.GetTranslatedIdentifier(field_decl);
- CRUBIT_CHECK(
- field_name ||
- !field_decl->hasAttr<clang::NoUniqueAddressAttr>() &&
- "Unnamed fields can't be annotated with [[no_unique_address]]");
+ CHECK(field_name ||
+ !field_decl->hasAttr<clang::NoUniqueAddressAttr>() &&
+ "Unnamed fields can't be annotated with [[no_unique_address]]");
fields.push_back(
{.identifier = field_name ? *std::move(field_name)
: llvm::Optional<Identifier>(llvm::None),
@@ -344,7 +345,7 @@
}
clang::CXXRecordDecl* base_record_decl =
- CRUBIT_DIE_IF_NULL(base_specifier.getType()->getAsCXXRecordDecl());
+ ABSL_DIE_IF_NULL(base_specifier.getType()->getAsCXXRecordDecl());
if (!ictx_.HasBeenAlreadySuccessfullyImported(base_record_decl)) {
continue;
}
@@ -357,12 +358,12 @@
}
*offset +=
{ictx_.ctx_.getASTRecordLayout(base_path_element.Class)
- .getBaseClassOffset(CRUBIT_DIE_IF_NULL(
+ .getBaseClassOffset(ABSL_DIE_IF_NULL(
base_path_element.Base->getType()->getAsCXXRecordDecl()))
.getQuantity()};
}
- CRUBIT_CHECK((!offset.has_value() || *offset >= 0) &&
- "Concrete base classes should have non-negative offsets.");
+ CHECK((!offset.has_value() || *offset >= 0) &&
+ "Concrete base classes should have non-negative offsets.");
bases.push_back(
BaseClass{.base_record_id = GenerateItemId(base_record_decl),
.offset = offset});
diff --git a/rs_bindings_from_cc/importers/function.cc b/rs_bindings_from_cc/importers/function.cc
index 346c5e9..4ae2bbd 100644
--- a/rs_bindings_from_cc/importers/function.cc
+++ b/rs_bindings_from_cc/importers/function.cc
@@ -29,7 +29,7 @@
std::set<std::string> errors;
auto add_error = [&errors](std::string msg) {
auto result = errors.insert(std::move(msg));
- CRUBIT_CHECK(result.second && "Duplicated error message");
+ CHECK(result.second) << "Duplicated error message";
};
if (auto* method_decl =
clang::dyn_cast<clang::CXXMethodDecl>(function_decl)) {
@@ -57,7 +57,7 @@
}
if (lifetimes) {
- CRUBIT_CHECK(lifetimes->IsValidForDecl(function_decl));
+ CHECK(lifetimes->IsValidForDecl(function_decl));
}
for (unsigned i = 0; i < function_decl->getNumParams(); ++i) {
@@ -74,7 +74,7 @@
}
std::optional<Identifier> param_name = ictx_.GetTranslatedIdentifier(param);
- CRUBIT_CHECK(param_name.has_value()); // No known failure cases.
+ CHECK(param_name.has_value()); // No known failure cases.
params.push_back({*param_type, *std::move(param_name)});
}
@@ -107,7 +107,7 @@
for (clang::tidy::lifetimes::Lifetime lifetime : all_free_lifetimes) {
std::optional<llvm::StringRef> name =
lifetime_symbol_table.LookupLifetime(lifetime);
- CRUBIT_CHECK(name.has_value());
+ CHECK(name.has_value());
lifetime_params.push_back(
{.name = name->str(), .id = LifetimeId(lifetime.Id())});
}
@@ -196,7 +196,7 @@
// Silence ClangTidy, checked above: calling `add_error` if
// `!return_type.ok()` and returning early if `!errors.empty()`.
- CRUBIT_CHECK(return_type.ok());
+ CHECK(return_type.ok());
if (translated_name.has_value()) {
return Func{
diff --git a/rs_bindings_from_cc/importers/namespace.cc b/rs_bindings_from_cc/importers/namespace.cc
index b3b8a2c..0fcd9d2 100644
--- a/rs_bindings_from_cc/importers/namespace.cc
+++ b/rs_bindings_from_cc/importers/namespace.cc
@@ -4,6 +4,7 @@
#include "rs_bindings_from_cc/importers/namespace.h"
+#include "absl/log/check.h"
#include "absl/strings/match.h"
namespace crubit {
@@ -18,7 +19,7 @@
ictx_.ImportDeclsFromDeclContext(namespace_decl);
auto identifier = ictx_.GetTranslatedIdentifier(namespace_decl);
- CRUBIT_CHECK(identifier.has_value());
+ CHECK(identifier.has_value());
auto item_ids = ictx_.GetItemIdsInSourceOrder(namespace_decl);
return Namespace{
.name = *identifier,
diff --git a/rs_bindings_from_cc/importers/typedef_name.cc b/rs_bindings_from_cc/importers/typedef_name.cc
index 65289d1..eeccfd1 100644
--- a/rs_bindings_from_cc/importers/typedef_name.cc
+++ b/rs_bindings_from_cc/importers/typedef_name.cc
@@ -4,6 +4,7 @@
#include "rs_bindings_from_cc/importers/typedef_name.h"
+#include "absl/log/check.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Attr.h"
@@ -31,7 +32,7 @@
std::optional<Identifier> identifier =
ictx_.GetTranslatedIdentifier(typedef_name_decl);
- CRUBIT_CHECK(identifier.has_value()); // This must always hold.
+ CHECK(identifier.has_value()); // This must always hold.
std::optional<clang::tidy::lifetimes::ValueLifetimes> no_lifetimes;
absl::StatusOr<MappedType> underlying_type = ictx_.ConvertQualType(
@@ -78,7 +79,7 @@
// canonical size in IR and in the binding code.
// Make sure that `alignment` is a power of 2.
- CRUBIT_CHECK(!(record->alignment & (record->alignment - 1)));
+ CHECK(!(record->alignment & (record->alignment - 1)));
// Given that `alignment` is a power of 2, we can round it up by
// a bit arithmetic: `alignment - 1` clears the single bit of it
diff --git a/rs_bindings_from_cc/ir.cc b/rs_bindings_from_cc/ir.cc
index c76b59b..3d1a869 100644
--- a/rs_bindings_from_cc/ir.cc
+++ b/rs_bindings_from_cc/ir.cc
@@ -13,8 +13,8 @@
#include <variant>
#include <vector>
+#include "absl/log/check.h"
#include "absl/strings/string_view.h"
-#include "common/check.h"
#include "common/strong_int.h"
#include "rs_bindings_from_cc/bazel_types.h"
#include "llvm/Support/JSON.h"
@@ -96,7 +96,7 @@
: internal::kRustPtrMut;
}
} else {
- CRUBIT_CHECK(has_lifetime);
+ CHECK(has_lifetime);
rs_name = pointee_type.cc_type.is_const ? internal::kRustRvalueRefConst
: internal::kRustRvalueRefMut;
}
@@ -144,13 +144,12 @@
MappedType result = FuncRef(cc_call_conv, rs_abi, lifetime,
std::move(return_type), std::move(param_types));
- CRUBIT_CHECK(result.cc_type.name == internal::kCcLValueRef);
+ CHECK_EQ(result.cc_type.name, internal::kCcLValueRef);
result.cc_type.name = std::string(internal::kCcPtr);
RsType rs_func_ptr_type = std::move(result.rs_type);
- CRUBIT_CHECK(
- rs_func_ptr_type.name.substr(0, internal::kRustFuncPtr.length()) ==
- internal::kRustFuncPtr);
+ CHECK(rs_func_ptr_type.name.substr(0, internal::kRustFuncPtr.length()) ==
+ internal::kRustFuncPtr);
result.rs_type =
RsType{.name = "Option", .type_args = {std::move(rs_func_ptr_type)}};
diff --git a/rs_bindings_from_cc/ir.h b/rs_bindings_from_cc/ir.h
index 47c6b8f..3ed219b 100644
--- a/rs_bindings_from_cc/ir.h
+++ b/rs_bindings_from_cc/ir.h
@@ -22,9 +22,9 @@
#include <vector>
#include "absl/container/flat_hash_map.h"
+#include "absl/log/check.h"
#include "absl/status/statusor.h"
#include "absl/strings/string_view.h"
-#include "common/check.h"
#include "common/strong_int.h"
#include "rs_bindings_from_cc/bazel_types.h"
#include "clang/AST/Decl.h"
@@ -305,7 +305,7 @@
public:
explicit Identifier(std::string identifier)
: identifier_(std::move(identifier)) {
- CRUBIT_CHECK(!identifier_.empty());
+ CHECK(!identifier_.empty());
}
absl::string_view Ident() const { return identifier_; }
@@ -326,7 +326,7 @@
class IntegerConstant {
public:
explicit IntegerConstant(const llvm::APSInt& value) {
- CRUBIT_CHECK(value.getSignificantBits() <= 64);
+ CHECK_LE(value.getSignificantBits(), 64);
is_negative_ = value < 0;
wrapped_value_ = static_cast<uint64_t>(value.getExtValue());
}
@@ -346,7 +346,7 @@
class Operator {
public:
explicit Operator(std::string name) : name_(std::move(name)) {
- CRUBIT_CHECK(!name_.empty());
+ CHECK(!name_.empty());
}
absl::string_view Name() const { return name_; }
diff --git a/rs_bindings_from_cc/ir_from_cc.cc b/rs_bindings_from_cc/ir_from_cc.cc
index 4f2be3f..f8e422e 100644
--- a/rs_bindings_from_cc/ir_from_cc.cc
+++ b/rs_bindings_from_cc/ir_from_cc.cc
@@ -10,12 +10,12 @@
#include <vector>
#include "absl/container/flat_hash_map.h"
+#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/string_view.h"
#include "absl/strings/substitute.h"
#include "absl/types/span.h"
-#include "common/check.h"
#include "rs_bindings_from_cc/bazel_types.h"
#include "rs_bindings_from_cc/frontend_action.h"
#include "rs_bindings_from_cc/ir.h"
@@ -40,10 +40,10 @@
// Caller should verify that the inputs are not empty.
// TODO(b/440066049): Generate a source file for requested instantiations once
// cl/430823388 is submitted.
- CRUBIT_CHECK(!extra_source_code.empty() || !public_headers.empty() ||
- !extra_instantiations.empty());
- CRUBIT_CHECK(!extra_source_code.empty() || !headers_to_targets.empty() ||
- !extra_instantiations.empty());
+ CHECK(!extra_source_code.empty() || !public_headers.empty() ||
+ !extra_instantiations.empty());
+ CHECK(!extra_source_code.empty() || !headers_to_targets.empty() ||
+ !extra_instantiations.empty());
std::vector<HeaderName> entrypoint_headers(public_headers.begin(),
public_headers.end());