PrettyStackTraceLocationContext.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //==- PrettyStackTraceLocationContext.h - show analysis backtrace --*- C++ -*-//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #ifndef LLVM_CLANG_LIB_STATICANALYZER_CORE_PRETTYSTACKTRACELOCATIONCONTEXT_H
  10. #define LLVM_CLANG_LIB_STATICANALYZER_CORE_PRETTYSTACKTRACELOCATIONCONTEXT_H
  11. #include "clang/Analysis/AnalysisContext.h"
  12. namespace clang {
  13. namespace ento {
  14. /// While alive, includes the current analysis stack in a crash trace.
  15. ///
  16. /// Example:
  17. /// \code
  18. /// 0. Program arguments: ...
  19. /// 1. <eof> parser at end of file
  20. /// 2. While analyzing stack:
  21. /// #0 void inlined()
  22. /// #1 void test()
  23. /// 3. crash-trace.c:6:3: Error evaluating statement
  24. /// \endcode
  25. class PrettyStackTraceLocationContext : public llvm::PrettyStackTraceEntry {
  26. const LocationContext *LCtx;
  27. public:
  28. PrettyStackTraceLocationContext(const LocationContext *LC) : LCtx(LC) {
  29. assert(LCtx);
  30. }
  31. void print(raw_ostream &OS) const override {
  32. OS << "While analyzing stack: \n";
  33. LCtx->dumpStack(OS, "\t");
  34. }
  35. };
  36. } // end ento namespace
  37. } // end clang namespace
  38. #endif