Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[offload] gnu::format with variadic template functions is Clang-only #124406

Merged
merged 1 commit into from
Feb 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions offload/plugins-nextgen/common/include/ErrorReporting.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,21 @@ class ErrorReporter {
/// Print \p Format, instantiated with \p Args to stderr.
/// TODO: Allow redirection into a file stream.
template <typename... ArgsTy>
[[gnu::format(__printf__, 1, 2)]] static void print(const char *Format,
ArgsTy &&...Args) {
#ifdef __clang__ // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77958
[[gnu::format(__printf__, 1, 2)]]
#endif
static void print(const char *Format, ArgsTy &&...Args) {
raw_fd_ostream OS(STDERR_FILENO, false);
OS << llvm::format(Format, Args...);
}

/// Print \p Format, instantiated with \p Args to stderr, but colored.
/// TODO: Allow redirection into a file stream.
template <typename... ArgsTy>
[[gnu::format(__printf__, 2, 3)]] static void
print(ColorTy Color, const char *Format, ArgsTy &&...Args) {
#ifdef __clang__ // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77958
[[gnu::format(__printf__, 2, 3)]]
#endif
static void print(ColorTy Color, const char *Format, ArgsTy &&...Args) {
raw_fd_ostream OS(STDERR_FILENO, false);
WithColor(OS, HighlightColor(Color)) << llvm::format(Format, Args...);
}
Expand All @@ -99,8 +103,10 @@ class ErrorReporter {
/// a banner.
/// TODO: Allow redirection into a file stream.
template <typename... ArgsTy>
[[gnu::format(__printf__, 1, 2)]] static void reportError(const char *Format,
ArgsTy &&...Args) {
#ifdef __clang__ // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77958
[[gnu::format(__printf__, 1, 2)]]
#endif
static void reportError(const char *Format, ArgsTy &&...Args) {
print(BoldRed, "%s", ErrorBanner);
print(BoldRed, Format, Args...);
print("\n");
Expand Down
Loading