[Modules] Make Support/Debug.h modular. This requires it to not change
authorChandler Carruth <chandlerc@gmail.com>
Mon, 21 Apr 2014 22:55:11 +0000 (22:55 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Mon, 21 Apr 2014 22:55:11 +0000 (22:55 +0000)
commit283b39937750b1c8c5e3244fd36ca6f46892b7c9
tree34cc5211348dc8b01bdcf9dd8b7e2ee190a6e623
parent9f38d0d113493e7ad3c43edbe065c005887eaeac
[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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206822 91177308-0d34-0410-b5e6-96231b3b80d8
59 files changed:
include/llvm/Support/Debug.h
include/llvm/Support/UnicodeCharRanges.h
include/llvm/Transforms/Utils/SSAUpdaterImpl.h
lib/Analysis/LoopPass.cpp
lib/CodeGen/MachineBasicBlock.cpp
lib/CodeGen/MachineFunction.cpp
lib/CodeGen/MachineSSAUpdater.cpp
lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp
lib/DebugInfo/DWARFContext.cpp
lib/IR/ConstantsContext.h
lib/IR/Core.cpp
lib/IR/Pass.cpp
lib/MC/MCObjectDisassembler.cpp
lib/MC/MachObjectWriter.cpp
lib/Support/CommandLine.cpp
lib/Support/DAGDeltaAlgorithm.cpp
lib/Target/AArch64/AArch64Subtarget.cpp
lib/Target/ARM/ARMBaseInstrInfo.cpp
lib/Target/ARM/ARMSubtarget.cpp
lib/Target/ARM64/ARM64Subtarget.cpp
lib/Target/Hexagon/HexagonISelLowering.cpp
lib/Target/Hexagon/HexagonInstrInfo.cpp
lib/Target/Hexagon/HexagonSubtarget.cpp
lib/Target/MSP430/MSP430ISelDAGToDAG.cpp
lib/Target/MSP430/MSP430Subtarget.cpp
lib/Target/Mips/AsmParser/MipsAsmParser.cpp
lib/Target/Mips/Disassembler/MipsDisassembler.cpp
lib/Target/Mips/Mips16InstrInfo.cpp
lib/Target/Mips/Mips16RegisterInfo.cpp
lib/Target/Mips/MipsModuleISelDAGToDAG.cpp
lib/Target/Mips/MipsSERegisterInfo.cpp
lib/Target/Mips/MipsTargetMachine.cpp
lib/Target/NVPTX/NVPTXPrologEpilogPass.cpp
lib/Target/NVPTX/NVPTXSubtarget.cpp
lib/Target/NVPTX/NVVMReflect.cpp
lib/Target/PowerPC/Disassembler/PPCDisassembler.cpp
lib/Target/PowerPC/PPCInstrInfo.cpp
lib/Target/PowerPC/PPCSubtarget.cpp
lib/Target/R600/AMDGPUSubtarget.cpp
lib/Target/Sparc/SparcSubtarget.cpp
lib/Target/SystemZ/Disassembler/SystemZDisassembler.cpp
lib/Target/SystemZ/SystemZISelDAGToDAG.cpp
lib/Target/SystemZ/SystemZSubtarget.cpp
lib/Target/X86/Disassembler/X86Disassembler.cpp
lib/Target/X86/X86InstrInfo.cpp
lib/Target/XCore/Disassembler/XCoreDisassembler.cpp
lib/Target/XCore/XCoreRegisterInfo.cpp
lib/Target/XCore/XCoreSubtarget.cpp
lib/Transforms/Utils/CodeExtractor.cpp
lib/Transforms/Utils/Local.cpp
lib/Transforms/Utils/LowerSwitch.cpp
lib/Transforms/Utils/SSAUpdater.cpp
tools/bugpoint/ExtractFunction.cpp
tools/bugpoint/OptimizerDriver.cpp
tools/lli/RemoteTargetExternal.cpp
utils/TableGen/AsmMatcherEmitter.cpp
utils/TableGen/AsmWriterEmitter.cpp
utils/TableGen/CodeGenDAGPatterns.cpp
utils/TableGen/DAGISelEmitter.cpp