dump.h 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. // This library contains functions to assist dumping objects to stderr during
  5. // interactive debugging. Functions named `Dump` are intended for direct use by
  6. // developers, and should use overload resolution to determine which will be
  7. // invoked. The debugger should do namespace resolution automatically. For
  8. // example:
  9. //
  10. // - lldb: `expr Dump(tree, id)`
  11. // - gdb: `call Dump(tree, id)`
  12. //
  13. // The `DumpNoNewline` functions are helpers that exclude a trailing newline.
  14. // They're intended to be composed by `Dump` function implementations.
  15. #ifndef CARBON_TOOLCHAIN_PARSE_DUMP_H_
  16. #define CARBON_TOOLCHAIN_PARSE_DUMP_H_
  17. #ifndef NDEBUG
  18. #include "toolchain/parse/tree.h"
  19. namespace Carbon::Parse {
  20. auto Dump(const Tree& tree, Lex::TokenIndex token) -> std::string;
  21. auto Dump(const Tree& tree, NodeId node_id) -> std::string;
  22. } // namespace Carbon::Parse
  23. #endif // NDEBUG
  24. #endif // CARBON_TOOLCHAIN_PARSE_DUMP_H_