From: Philip Herron <[email protected]>
This reduces compile time when debug is turned off due to evaultion
of any passed arguments.
gcc/rust/ChangeLog:
* rust-diagnostics.cc (rust_debug_loc): rename
(rust_debug_loc_internal): no longer check if debug is enabled
* rust-diagnostics.h (rust_debug): new wrapper
(rust_debug_loc): likewise
(rust_debug_loc_internal): likewise
Signed-off-by: Philip Herron <[email protected]>
---
This change was merged into the gccrs repository and is posted here for
upstream visibility and potential drive-by review, as requested by GCC
release managers.
Each commit email contains a link to its details on github from where you can
find the Pull-Request and associated discussions.
Commit on github:
https://github.com/Rust-GCC/gccrs/commit/66560d47f49d7dfb16fd489a6714c4689b0c3afb
The commit has NOT been mentioned in any issue.
The commit has been mentioned in the following pull-request(s):
- https://github.com/Rust-GCC/gccrs/pull/4793
gcc/rust/rust-diagnostics.cc | 5 +----
gcc/rust/rust-diagnostics.h | 20 +++++++++++++++++---
2 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/gcc/rust/rust-diagnostics.cc b/gcc/rust/rust-diagnostics.cc
index 498805acc..bdd78f7f2 100644
--- a/gcc/rust/rust-diagnostics.cc
+++ b/gcc/rust/rust-diagnostics.cc
@@ -398,11 +398,8 @@ rust_be_debug_p (void)
}
void
-rust_debug_loc (const location_t location, const char *fmt, ...)
+rust_debug_loc_internal (const location_t location, const char *fmt, ...)
{
- if (!rust_be_debug_p ())
- return;
-
va_list ap;
va_start (ap, fmt);
diff --git a/gcc/rust/rust-diagnostics.h b/gcc/rust/rust-diagnostics.h
index 7fe2596e8..e15c3a450 100644
--- a/gcc/rust/rust-diagnostics.h
+++ b/gcc/rust/rust-diagnostics.h
@@ -300,12 +300,26 @@ struct Error
} // namespace Rust
// rust_debug uses normal printf formatting, not GCC diagnostic formatting.
-#define rust_debug(...) rust_debug_loc (UNDEF_LOCATION, __VA_ARGS__)
+#define rust_debug(...)
\
+ do
\
+ {
\
+ if (rust_be_debug_p ())
\
+ rust_debug_loc_internal (UNDEF_LOCATION, __VA_ARGS__); \
+ }
\
+ while (0)
+
+#define rust_debug_loc(location, ...)
\
+ do
\
+ {
\
+ if (rust_be_debug_p ())
\
+ rust_debug_loc_internal (location, __VA_ARGS__); \
+ }
\
+ while (0)
#define rust_sorry_at(location, ...) sorry_at (location, __VA_ARGS__)
-void rust_debug_loc (const location_t location, const char *fmt,
- ...) ATTRIBUTE_PRINTF_2;
+void rust_debug_loc_internal (const location_t location, const char *fmt,
+ ...) ATTRIBUTE_PRINTF_2;
// like rust_debug, but has gcc diagnostic formatting
#define rust_debug_fmt(...) rust_debug_fmt_at (UNDEF_LOCATION, __VA_ARGS__)
base-commit: 7a008ab0e6c3e33bd7ce1f6e3240e829de3010c8
--
2.55.0