• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- tools/f18/dump.cpp ------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // This file defines Dump routines available for calling from the debugger.
10 // Each is based on operator<< for that type. There are overloadings for
11 // reference and pointer, and for dumping to a provided raw_ostream or errs().
12 
13 #ifdef DEBUGF18
14 
15 #include "llvm/Support/raw_ostream.h"
16 
17 #define DEFINE_DUMP(ns, name) \
18   namespace ns { \
19   class name; \
20   llvm::raw_ostream &operator<<(llvm::raw_ostream &, const name &); \
21   } \
22   void Dump(llvm::raw_ostream &os, const ns::name &x) { os << x << '\n'; } \
23   void Dump(llvm::raw_ostream &os, const ns::name *x) { \
24     if (x == nullptr) \
25       os << "null\n"; \
26     else \
27       Dump(os, *x); \
28   } \
29   void Dump(const ns::name &x) { Dump(llvm::errs(), x); } \
30   void Dump(const ns::name *x) { Dump(llvm::errs(), *x); }
31 
32 namespace Fortran {
33 DEFINE_DUMP(parser, Name)
34 DEFINE_DUMP(parser, CharBlock)
35 DEFINE_DUMP(semantics, Symbol)
36 DEFINE_DUMP(semantics, Scope)
37 DEFINE_DUMP(semantics, IntrinsicTypeSpec)
38 DEFINE_DUMP(semantics, DerivedTypeSpec)
39 DEFINE_DUMP(semantics, DeclTypeSpec)
40 } // namespace Fortran
41 
42 #endif
43