diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2014-04-21 22:55:11 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2014-04-21 22:55:11 +0000 |
commit | e96dd8975ff6c01c6ab3b24002e61ff2d3f0f683 (patch) | |
tree | 8cef21e33bf6fe23f321d2501c9c1aed48f98e38 /llvm/utils | |
parent | 4bcfcc14bdffa4a4e5dd948a746e07077ecc4a1b (diff) | |
download | bcm5719-llvm-e96dd8975ff6c01c6ab3b24002e61ff2d3f0f683.tar.gz bcm5719-llvm-e96dd8975ff6c01c6ab3b24002e61ff2d3f0f683.zip |
[Modules] Make Support/Debug.h modular. This requires it to not change
behavior based on other files defining DEBUG_TYPE, which means it cannot
define DEBUG_TYPE at all. This is actually better IMO as it forces folks
to define relevant DEBUG_TYPEs for their files. However, it requires all
files that currently use DEBUG(...) to define a DEBUG_TYPE if they don't
already. I've updated all such files in LLVM and will do the same for
other upstream projects.
This still leaves one important change in how LLVM uses the DEBUG_TYPE
macro going forward: we need to only define the macro *after* header
files have been #include-ed. Previously, this wasn't possible because
Debug.h required the macro to be pre-defined. This commit removes that.
By defining DEBUG_TYPE after the includes two things are fixed:
- Header files that need to provide a DEBUG_TYPE for some inline code
can do so by defining the macro before their inline code and undef-ing
it afterward so the macro does not escape.
- We no longer have rampant ODR violations due to including headers with
different DEBUG_TYPE definitions. This may be mostly an academic
violation today, but with modules these types of violations are easy
to check for and potentially very relevant.
Where necessary to suppor headers with DEBUG_TYPE, I have moved the
definitions below the includes in this commit. I plan to move the rest
of the DEBUG_TYPE macros in LLVM in subsequent commits; this one is big
enough.
The comments in Debug.h, which were hilariously out of date already,
have been updated to reflect the recommended practice going forward.
llvm-svn: 206822
Diffstat (limited to 'llvm/utils')
-rw-r--r-- | llvm/utils/TableGen/AsmMatcherEmitter.cpp | 2 | ||||
-rw-r--r-- | llvm/utils/TableGen/AsmWriterEmitter.cpp | 2 | ||||
-rw-r--r-- | llvm/utils/TableGen/CodeGenDAGPatterns.cpp | 2 | ||||
-rw-r--r-- | llvm/utils/TableGen/DAGISelEmitter.cpp | 2 |
4 files changed, 8 insertions, 0 deletions
diff --git a/llvm/utils/TableGen/AsmMatcherEmitter.cpp b/llvm/utils/TableGen/AsmMatcherEmitter.cpp index 54393706052..77f92ff6140 100644 --- a/llvm/utils/TableGen/AsmMatcherEmitter.cpp +++ b/llvm/utils/TableGen/AsmMatcherEmitter.cpp @@ -117,6 +117,8 @@ #include <sstream> using namespace llvm; +#define DEBUG_TYPE "asm-matcher-emitter" + static cl::opt<std::string> MatchPrefix("match-prefix", cl::init(""), cl::desc("Only match instructions with the given prefix")); diff --git a/llvm/utils/TableGen/AsmWriterEmitter.cpp b/llvm/utils/TableGen/AsmWriterEmitter.cpp index 718bb805fe4..666d0a1b896 100644 --- a/llvm/utils/TableGen/AsmWriterEmitter.cpp +++ b/llvm/utils/TableGen/AsmWriterEmitter.cpp @@ -29,6 +29,8 @@ #include <vector> using namespace llvm; +#define DEBUG_TYPE "asm-writer-emitter" + namespace { class AsmWriterEmitter { RecordKeeper &Records; diff --git a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp index 10b036f36e0..e003dc8322a 100644 --- a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp +++ b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp @@ -25,6 +25,8 @@ #include <set> using namespace llvm; +#define DEBUG_TYPE "dag-patterns" + //===----------------------------------------------------------------------===// // EEVT::TypeSet Implementation //===----------------------------------------------------------------------===// diff --git a/llvm/utils/TableGen/DAGISelEmitter.cpp b/llvm/utils/TableGen/DAGISelEmitter.cpp index 9294cd55767..82682cd5a5a 100644 --- a/llvm/utils/TableGen/DAGISelEmitter.cpp +++ b/llvm/utils/TableGen/DAGISelEmitter.cpp @@ -18,6 +18,8 @@ #include "llvm/TableGen/TableGenBackend.h" using namespace llvm; +#define DEBUG_TYPE "dag-isel-emitter" + namespace { /// DAGISelEmitter - The top-level class which coordinates construction /// and emission of the instruction selector. |