summaryrefslogtreecommitdiff
path: root/lib/TableGen
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2017-01-28 02:02:38 +0000
committerMatthias Braun <matze@braunis.de>2017-01-28 02:02:38 +0000
commit88d207542b618ca6054b24491ddd67f8ca397540 (patch)
treef62acd2207c3b8c726f2b30d9501355613c092c3 /lib/TableGen
parent92cf58ee368511a9ef8a97cd7ff2702effcc745c (diff)
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293359 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/TableGen')
-rw-r--r--lib/TableGen/Record.cpp10
-rw-r--r--lib/TableGen/TGParser.cpp2
2 files changed, 11 insertions, 1 deletions
diff --git a/lib/TableGen/Record.cpp b/lib/TableGen/Record.cpp
index ea9c9a19904..33d3de5daf3 100644
--- a/lib/TableGen/Record.cpp
+++ b/lib/TableGen/Record.cpp
@@ -40,7 +40,9 @@ IntRecTy IntRecTy::Shared;
StringRecTy StringRecTy::Shared;
DagRecTy DagRecTy::Shared;
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void RecTy::dump() const { print(errs()); }
+#endif
ListRecTy *RecTy::getListTy() {
if (!ListTy)
@@ -161,7 +163,9 @@ RecTy *llvm::resolveTypes(RecTy *T1, RecTy *T2) {
//===----------------------------------------------------------------------===//
void Init::anchor() { }
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void Init::dump() const { return print(errs()); }
+#endif
UnsetInit *UnsetInit::get() {
static UnsetInit TheInit;
@@ -1591,7 +1595,9 @@ StringRef RecordVal::getName() const {
return cast<StringInit>(getNameInit())->getValue();
}
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void RecordVal::dump() const { errs() << *this; }
+#endif
void RecordVal::print(raw_ostream &OS, bool PrintSem) const {
if (getPrefix()) OS << "field ";
@@ -1673,7 +1679,9 @@ void Record::resolveReferencesTo(const RecordVal *RV) {
}
}
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void Record::dump() const { errs() << *this; }
+#endif
raw_ostream &llvm::operator<<(raw_ostream &OS, const Record &R) {
OS << R.getNameInitAsString();
@@ -1865,6 +1873,7 @@ DagInit *Record::getValueAsDag(StringRef FieldName) const {
FieldName + "' does not have a dag initializer!");
}
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void MultiClass::dump() const {
errs() << "Record:\n";
Rec.dump();
@@ -1875,6 +1884,7 @@ LLVM_DUMP_METHOD void MultiClass::dump() const {
}
LLVM_DUMP_METHOD void RecordKeeper::dump() const { errs() << *this; }
+#endif
raw_ostream &llvm::operator<<(raw_ostream &OS, const RecordKeeper &RK) {
OS << "------------- Classes -----------------\n";
diff --git a/lib/TableGen/TGParser.cpp b/lib/TableGen/TGParser.cpp
index 1a91b37b742..59b837f4187 100644
--- a/lib/TableGen/TGParser.cpp
+++ b/lib/TableGen/TGParser.cpp
@@ -945,7 +945,7 @@ Init *TGParser::ParseOperation(Record *CurRec, RecTy *ItemType) {
else if (ListInit *Arg0 = dyn_cast<ListInit>(InitList[0]))
Type = Arg0->getType();
else {
- InitList[0]->dump();
+ InitList[0]->print(errs());
Error(OpLoc, "expected a list");
return nullptr;
}