PrettyDeclStackTrace.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- PrettyDeclStackTrace.h - Stack trace for decl processing -*- 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. // This file defines an llvm::PrettyStackTraceEntry object for showing
  15. // that a particular declaration was being processed when a crash
  16. // occurred.
  17. //
  18. //===----------------------------------------------------------------------===//
  19. #ifndef LLVM_CLANG_AST_PRETTYDECLSTACKTRACE_H
  20. #define LLVM_CLANG_AST_PRETTYDECLSTACKTRACE_H
  21. #include "clang/Basic/SourceLocation.h"
  22. #include "llvm/Support/PrettyStackTrace.h"
  23. namespace clang {
  24. class ASTContext;
  25. class Decl;
  26. /// PrettyDeclStackTraceEntry - If a crash occurs in the parser while
  27. /// parsing something related to a declaration, include that
  28. /// declaration in the stack trace.
  29. class PrettyDeclStackTraceEntry : public llvm::PrettyStackTraceEntry {
  30. ASTContext &Context;
  31. Decl *TheDecl;
  32. SourceLocation Loc;
  33. const char *Message;
  34. public:
  35. PrettyDeclStackTraceEntry(ASTContext &Ctx, Decl *D, SourceLocation Loc,
  36. const char *Msg)
  37. : Context(Ctx), TheDecl(D), Loc(Loc), Message(Msg) {}
  38. void print(raw_ostream &OS) const override;
  39. };
  40. }
  41. #endif
  42. #ifdef __GNUC__
  43. #pragma GCC diagnostic pop
  44. #endif