[llvm] [llvm][support] Add LLVM_DLOG macro. (PR #143704)
Mehdi Amini via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 8 08:20:08 PDT 2025
================
@@ -0,0 +1,69 @@
+//===- llvm/Support/DebugLog.h - Logging like debug output ------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+// This file contains macros for logging like debug output. It builds upon the
+// support in Debug.h but provides a utility function for common debug output
+// style.
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_SUPPORT_DEBUGLOG_H
+#define LLVM_SUPPORT_DEBUGLOG_H
+
+#include "llvm/Support/Debug.h"
+#include "llvm/Support/raw_ostream.h"
+
+namespace llvm {
+#ifndef NDEBUG
+
+// Output with given inputs and trailing newline. E.g.,
+// LLVM_DLOG() << "Bitset contains: " << Bitset;
+// is equivalent to
+// LLVM_DEBUG(dbgs() << DEBUG_TYPE << " " << __FILE__ << ":" << __LINE__
+// << "] " << "Bitset contains: " << Bitset << "\n");
----------------
joker-eph wrote:
While llvm::nulls() won't help with the optimization, your insertion of ` for (bool _c = false; _c; _c = false)` should be enough I think?
We may still have the edge case of a header guarding a function with `#ifndef NDEBUG` leading to compilation failure, but that may be enough of an edge case!
https://github.com/llvm/llvm-project/pull/143704
More information about the llvm-commits
mailing list