PrettyStackTrace.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- clang/Basic/PrettyStackTrace.h - Pretty Crash Handling --*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. ///
  14. /// \file
  15. /// Defines the PrettyStackTraceEntry class, which is used to make
  16. /// crashes give more contextual information about what the program was doing
  17. /// when it crashed.
  18. ///
  19. //===----------------------------------------------------------------------===//
  20. #ifndef LLVM_CLANG_BASIC_PRETTYSTACKTRACE_H
  21. #define LLVM_CLANG_BASIC_PRETTYSTACKTRACE_H
  22. #include "clang/Basic/SourceLocation.h"
  23. #include "llvm/Support/PrettyStackTrace.h"
  24. namespace clang {
  25. /// If a crash happens while one of these objects are live, the message
  26. /// is printed out along with the specified source location.
  27. class PrettyStackTraceLoc : public llvm::PrettyStackTraceEntry {
  28. SourceManager &SM;
  29. SourceLocation Loc;
  30. const char *Message;
  31. public:
  32. PrettyStackTraceLoc(SourceManager &sm, SourceLocation L, const char *Msg)
  33. : SM(sm), Loc(L), Message(Msg) {}
  34. void print(raw_ostream &OS) const override;
  35. };
  36. }
  37. #endif
  38. #ifdef __GNUC__
  39. #pragma GCC diagnostic pop
  40. #endif