diff options
author | Matthias Braun <matze@braunis.de> | 2017-01-28 02:02:38 +0000 |
---|---|---|
committer | Matthias Braun <matze@braunis.de> | 2017-01-28 02:02:38 +0000 |
commit | 8c209aa8779de57771b64896f805e14cc0016dcd (patch) | |
tree | b3f7bc33dbb7be8ffe9a4f974253d6547b94ebdb /llvm/lib/Support | |
parent | cfa5dc4a1dc2b7495aba96caba6fd2600c1ceb8a (diff) | |
download | bcm5719-llvm-8c209aa8779de57771b64896f805e14cc0016dcd.tar.gz bcm5719-llvm-8c209aa8779de57771b64896f805e14cc0016dcd.zip |
Cleanup dump() functions.
We had various variants of defining dump() functions in LLVM. Normalize
them (this should just consistently implement the things discussed in
http://lists.llvm.org/pipermail/cfe-dev/2014-January/034323.html
For reference:
- Public headers should just declare the dump() method but not use
LLVM_DUMP_METHOD or #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
- The definition of a dump method should look like this:
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void MyClass::dump() {
// print stuff to dbgs()...
}
#endif
llvm-svn: 293359
Diffstat (limited to 'llvm/lib/Support')
-rw-r--r-- | llvm/lib/Support/APFloat.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/Support/APInt.cpp | 3 | ||||
-rw-r--r-- | llvm/lib/Support/BranchProbability.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Support/Twine.cpp | 4 |
4 files changed, 10 insertions, 3 deletions
diff --git a/llvm/lib/Support/APFloat.cpp b/llvm/lib/Support/APFloat.cpp index 2fe3b070023..4dc9307f762 100644 --- a/llvm/lib/Support/APFloat.cpp +++ b/llvm/lib/Support/APFloat.cpp @@ -4494,7 +4494,9 @@ void APFloat::print(raw_ostream &OS) const { OS << Buffer << "\n"; } -void APFloat::dump() const { print(dbgs()); } +#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) +LLVM_DUMP_METHOD void APFloat::dump() const { print(dbgs()); } +#endif void APFloat::Profile(FoldingSetNodeID &NID) const { NID.Add(bitcastToAPInt()); diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp index bc3e4b2666b..3c742303936 100644 --- a/llvm/lib/Support/APInt.cpp +++ b/llvm/lib/Support/APInt.cpp @@ -2241,7 +2241,7 @@ std::string APInt::toString(unsigned Radix = 10, bool Signed = true) const { return S.str(); } - +#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) LLVM_DUMP_METHOD void APInt::dump() const { SmallString<40> S, U; this->toStringUnsigned(U); @@ -2249,6 +2249,7 @@ LLVM_DUMP_METHOD void APInt::dump() const { dbgs() << "APInt(" << BitWidth << "b, " << U << "u " << S << "s)"; } +#endif void APInt::print(raw_ostream &OS, bool isSigned) const { SmallString<40> S; diff --git a/llvm/lib/Support/BranchProbability.cpp b/llvm/lib/Support/BranchProbability.cpp index 1c41659cf8d..44ad110d456 100644 --- a/llvm/lib/Support/BranchProbability.cpp +++ b/llvm/lib/Support/BranchProbability.cpp @@ -32,7 +32,9 @@ raw_ostream &BranchProbability::print(raw_ostream &OS) const { Percent); } +#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) LLVM_DUMP_METHOD void BranchProbability::dump() const { print(dbgs()) << '\n'; } +#endif BranchProbability::BranchProbability(uint32_t Numerator, uint32_t Denominator) { assert(Denominator > 0 && "Denominator cannot be 0!"); diff --git a/llvm/lib/Support/Twine.cpp b/llvm/lib/Support/Twine.cpp index 465c6e6b8c4..d17cd4e6643 100644 --- a/llvm/lib/Support/Twine.cpp +++ b/llvm/lib/Support/Twine.cpp @@ -173,10 +173,12 @@ void Twine::printRepr(raw_ostream &OS) const { OS << ")"; } +#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) LLVM_DUMP_METHOD void Twine::dump() const { print(dbgs()); } -void Twine::dumpRepr() const { +LLVM_DUMP_METHOD void Twine::dumpRepr() const { printRepr(dbgs()); } +#endif |