Files
swift-mirror/include/swift/AST/PrettyStackTrace.h
John McCall 77b62557a6 Add a pretty stack trace entry for a type (and a newline to
the generic source-location printer).

Swift SVN r4922
2013-04-26 18:48:36 +00:00

95 lines
3.0 KiB
C++

//===- PrettyStackTrace.h - Crash trace information -----------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This file defines RAII classes that give better dagnostic output
// about when, exactly, a crash is occurring.
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_PRETTYSTACKTRACE_H
#define SWIFT_PRETTYSTACKTRACE_H
#include "llvm/Support/PrettyStackTrace.h"
#include "swift/AST/Type.h"
namespace swift {
class ASTContext;
class Decl;
class Expr;
class Stmt;
/// printSourceLoc - Print a debugging view of the given source location
/// to an output stream.
void printSourceLoc(llvm::raw_ostream &OS, SourceLoc loc, ASTContext &C);
/// PrettyStackTraceLocation - Observe that we are doing some
/// processing starting at a fixed location.
class PrettyStackTraceLocation : public llvm::PrettyStackTraceEntry {
ASTContext &Context;
SourceLoc Loc;
const char *Action;
public:
PrettyStackTraceLocation(ASTContext &C, const char *action, SourceLoc loc)
: Context(C), Loc(loc), Action(action) {}
virtual void print(llvm::raw_ostream &OS) const;
};
/// PrettyStackTraceDecl - Observe that we are processing a specific
/// declaration.
class PrettyStackTraceDecl : public llvm::PrettyStackTraceEntry {
Decl *TheDecl;
const char *Action;
public:
PrettyStackTraceDecl(const char *action, Decl *D)
: TheDecl(D), Action(action) {}
virtual void print(llvm::raw_ostream &OS) const;
};
/// PrettyStackTraceExpr - Observe that we are processing a specific
/// expression.
class PrettyStackTraceExpr : public llvm::PrettyStackTraceEntry {
ASTContext &Context;
Expr *TheExpr;
const char *Action;
public:
PrettyStackTraceExpr(ASTContext &C, const char *action, Expr *E)
: Context(C), TheExpr(E), Action(action) {}
virtual void print(llvm::raw_ostream &OS) const;
};
/// PrettyStackTraceStmt - Observe that we are processing a specific
/// statement.
class PrettyStackTraceStmt : public llvm::PrettyStackTraceEntry {
ASTContext &Context;
Stmt *TheStmt;
const char *Action;
public:
PrettyStackTraceStmt(ASTContext &C, const char *action, Stmt *S)
: Context(C), TheStmt(S), Action(action) {}
virtual void print(llvm::raw_ostream &OS) const;
};
/// PrettyStackTraceType - Observe that we are processing a specific type.
class PrettyStackTraceType : public llvm::PrettyStackTraceEntry {
ASTContext &Context;
Type TheType;
const char *Action;
public:
PrettyStackTraceType(ASTContext &C, const char *action, Type type)
: Context(C), TheType(type), Action(action) {}
virtual void print(llvm::raw_ostream &OS) const;
};
} // end namespace swift
#endif