pretty_stack_trace_function.h 898 B

1234567891011121314151617181920212223242526272829
  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. #ifndef CARBON_TOOLCHAIN_BASE_PRETTY_STACK_TRACE_FUNCTION_H_
  5. #define CARBON_TOOLCHAIN_BASE_PRETTY_STACK_TRACE_FUNCTION_H_
  6. #include <functional>
  7. #include "llvm/Support/PrettyStackTrace.h"
  8. namespace Carbon {
  9. class PrettyStackTraceFunction : public llvm::PrettyStackTraceEntry {
  10. public:
  11. explicit PrettyStackTraceFunction(
  12. std::function<auto(llvm::raw_ostream&)->void> fn)
  13. : fn_(std::move(fn)) {}
  14. ~PrettyStackTraceFunction() override = default;
  15. auto print(llvm::raw_ostream& output) const -> void override { fn_(output); }
  16. private:
  17. const std::function<auto(llvm::raw_ostream&)->void> fn_;
  18. };
  19. } // namespace Carbon
  20. #endif // CARBON_TOOLCHAIN_BASE_PRETTY_STACK_TRACE_FUNCTION_H_