Implement a new command line option, -debug, which is meant to unify all of
authorChris Lattner <sabre@nondot.org>
Wed, 22 May 2002 17:06:20 +0000 (17:06 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 22 May 2002 17:06:20 +0000 (17:06 +0000)
the random debugging macros scattered throughout llvm.

The new DEBUG(x) macro should be used instead of special purpose debug macros.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2709 91177308-0d34-0410-b5e6-96231b3b80d8

include/Support/Statistic.h
include/Support/StatisticReporter.h
include/llvm/ADT/Statistic.h
lib/Support/Statistic.cpp
support/lib/Support/Statistic.cpp
support/lib/Support/StatisticReporter.cpp

index 5c464865ed1933bfc61edc25414c97909db5d14e..453af34fe019d91020a1ac5f0bc9347ff5dd116a 100644 (file)
 
 #include <iosfwd>
 
+// DebugFlag - This boolean is set to true if the '-debug' command line option
+// is specified.  This should probably not be referenced directly, instead, use
+// the DEBUG macro below.
+//
+extern bool DebugFlag;
+
+// DEBUG macro - This macro should be used by passes to emit debug information.
+// In the '-debug' option is specified on the commandline, and if this is a
+// debug build, then the code specified as the option to the macro will be
+// executed.  Otherwise it will not be.  Example:
+//
+// DEBUG(cerr << "Bitset contains: " << Bitset << "\n");
+//
+#ifdef NDEBUG
+#define DEBUG(X)
+#else
+#define DEBUG(X) \
+  do { if (DebugFlag) { X; } } while (0)
+#endif
+
+
 // StatisticBase - Nontemplated base class for Statistic<> class...
 class StatisticBase {
   const char *Name;
index 5c464865ed1933bfc61edc25414c97909db5d14e..453af34fe019d91020a1ac5f0bc9347ff5dd116a 100644 (file)
 
 #include <iosfwd>
 
+// DebugFlag - This boolean is set to true if the '-debug' command line option
+// is specified.  This should probably not be referenced directly, instead, use
+// the DEBUG macro below.
+//
+extern bool DebugFlag;
+
+// DEBUG macro - This macro should be used by passes to emit debug information.
+// In the '-debug' option is specified on the commandline, and if this is a
+// debug build, then the code specified as the option to the macro will be
+// executed.  Otherwise it will not be.  Example:
+//
+// DEBUG(cerr << "Bitset contains: " << Bitset << "\n");
+//
+#ifdef NDEBUG
+#define DEBUG(X)
+#else
+#define DEBUG(X) \
+  do { if (DebugFlag) { X; } } while (0)
+#endif
+
+
 // StatisticBase - Nontemplated base class for Statistic<> class...
 class StatisticBase {
   const char *Name;
index 5c464865ed1933bfc61edc25414c97909db5d14e..453af34fe019d91020a1ac5f0bc9347ff5dd116a 100644 (file)
 
 #include <iosfwd>
 
+// DebugFlag - This boolean is set to true if the '-debug' command line option
+// is specified.  This should probably not be referenced directly, instead, use
+// the DEBUG macro below.
+//
+extern bool DebugFlag;
+
+// DEBUG macro - This macro should be used by passes to emit debug information.
+// In the '-debug' option is specified on the commandline, and if this is a
+// debug build, then the code specified as the option to the macro will be
+// executed.  Otherwise it will not be.  Example:
+//
+// DEBUG(cerr << "Bitset contains: " << Bitset << "\n");
+//
+#ifdef NDEBUG
+#define DEBUG(X)
+#else
+#define DEBUG(X) \
+  do { if (DebugFlag) { X; } } while (0)
+#endif
+
+
 // StatisticBase - Nontemplated base class for Statistic<> class...
 class StatisticBase {
   const char *Name;
index 79b19503b72c5ec65abe3e02e8da3475b0343673..249955beeb8d8dc0df018ae405cb78577abf0154 100644 (file)
 #include "Support/CommandLine.h"
 #include <iostream>
 
+bool DebugFlag;  // DebugFlag - Exported boolean set by the -debug option
+
 static cl::Flag Enabled("stats", "Enable statistics output from program");
+static cl::Flag Debug(DebugFlag, "debug", "Enable debug output", cl::Hidden);
 
 // Print information when destroyed, iff command line option is specified
 void StatisticBase::destroy() const {
index 79b19503b72c5ec65abe3e02e8da3475b0343673..249955beeb8d8dc0df018ae405cb78577abf0154 100644 (file)
 #include "Support/CommandLine.h"
 #include <iostream>
 
+bool DebugFlag;  // DebugFlag - Exported boolean set by the -debug option
+
 static cl::Flag Enabled("stats", "Enable statistics output from program");
+static cl::Flag Debug(DebugFlag, "debug", "Enable debug output", cl::Hidden);
 
 // Print information when destroyed, iff command line option is specified
 void StatisticBase::destroy() const {
index 79b19503b72c5ec65abe3e02e8da3475b0343673..249955beeb8d8dc0df018ae405cb78577abf0154 100644 (file)
 #include "Support/CommandLine.h"
 #include <iostream>
 
+bool DebugFlag;  // DebugFlag - Exported boolean set by the -debug option
+
 static cl::Flag Enabled("stats", "Enable statistics output from program");
+static cl::Flag Debug(DebugFlag, "debug", "Enable debug output", cl::Hidden);
 
 // Print information when destroyed, iff command line option is specified
 void StatisticBase::destroy() const {