1352d347aSAlexis Perry //===-- tools/f18/dump.cpp ------------------------------------------------===// 2352d347aSAlexis Perry // 3352d347aSAlexis Perry // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4352d347aSAlexis Perry // See https://llvm.org/LICENSE.txt for license information. 5352d347aSAlexis Perry // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6352d347aSAlexis Perry // 7352d347aSAlexis Perry //===----------------------------------------------------------------------===// 8352d347aSAlexis Perry 9352d347aSAlexis Perry // This file defines Dump routines available for calling from the debugger. 10352d347aSAlexis Perry // Each is based on operator<< for that type. There are overloadings for 118670e499SCaroline Concatto // reference and pointer, and for dumping to a provided raw_ostream or errs(). 12352d347aSAlexis Perry 13352d347aSAlexis Perry #ifdef DEBUGF18 14352d347aSAlexis Perry 158670e499SCaroline Concatto #include "llvm/Support/raw_ostream.h" 16352d347aSAlexis Perry 17352d347aSAlexis Perry #define DEFINE_DUMP(ns, name) \ 18352d347aSAlexis Perry namespace ns { \ 19352d347aSAlexis Perry class name; \ 208670e499SCaroline Concatto llvm::raw_ostream &operator<<(llvm::raw_ostream &, const name &); \ 21352d347aSAlexis Perry } \ 228670e499SCaroline Concatto void Dump(llvm::raw_ostream &os, const ns::name &x) { os << x << '\n'; } \ 238670e499SCaroline Concatto void Dump(llvm::raw_ostream &os, const ns::name *x) { \ 24352d347aSAlexis Perry if (x == nullptr) \ 25352d347aSAlexis Perry os << "null\n"; \ 26352d347aSAlexis Perry else \ 27352d347aSAlexis Perry Dump(os, *x); \ 28352d347aSAlexis Perry } \ 298670e499SCaroline Concatto void Dump(const ns::name &x) { Dump(llvm::errs(), x); } \ 308670e499SCaroline Concatto void Dump(const ns::name *x) { Dump(llvm::errs(), *x); } 31352d347aSAlexis Perry 32352d347aSAlexis Perry namespace Fortran { 33352d347aSAlexis Perry DEFINE_DUMP(parser, Name) 34352d347aSAlexis Perry DEFINE_DUMP(parser, CharBlock) 35352d347aSAlexis Perry DEFINE_DUMP(semantics, Symbol) 36352d347aSAlexis Perry DEFINE_DUMP(semantics, Scope) 37352d347aSAlexis Perry DEFINE_DUMP(semantics, IntrinsicTypeSpec) 38352d347aSAlexis Perry DEFINE_DUMP(semantics, DerivedTypeSpec) 39352d347aSAlexis Perry DEFINE_DUMP(semantics, DeclTypeSpec) 40*1f879005STim Keith } // namespace Fortran 41352d347aSAlexis Perry 42352d347aSAlexis Perry #endif 43