Skip to content

Commit 6285582

Browse files
authored
Merge pull request #13074 from gottesmm/pr-bae9d9e30d40c9211864b978ff3400b9b01034c9
2 parents 6c70718 + 7be1815 commit 6285582

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

include/swift/AST/Decl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,9 @@ class alignas(1 << DeclAlignInBits) Decl {
784784
LLVM_ATTRIBUTE_DEPRECATED(
785785
void dump() const LLVM_ATTRIBUTE_USED,
786786
"only for use within the debugger");
787+
LLVM_ATTRIBUTE_DEPRECATED(
788+
void dump(const char *filename) const LLVM_ATTRIBUTE_USED,
789+
"only for use within the debugger");
787790
void dump(raw_ostream &OS, unsigned Indent = 0) const;
788791

789792
/// \brief Pretty-print the given declaration.

lib/AST/ASTDumper.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
//
1515
//===----------------------------------------------------------------------===//
1616

17-
#include "swift/Basic/QuotedString.h"
1817
#include "swift/AST/ASTContext.h"
1918
#include "swift/AST/ASTPrinter.h"
2019
#include "swift/AST/ASTVisitor.h"
@@ -24,12 +23,14 @@
2423
#include "swift/AST/ParameterList.h"
2524
#include "swift/AST/ProtocolConformance.h"
2625
#include "swift/AST/TypeVisitor.h"
26+
#include "swift/Basic/QuotedString.h"
2727
#include "swift/Basic/STLExtras.h"
2828
#include "llvm/ADT/APFloat.h"
2929
#include "llvm/ADT/Optional.h"
3030
#include "llvm/ADT/SmallString.h"
3131
#include "llvm/ADT/StringExtras.h"
3232
#include "llvm/Support/ErrorHandling.h"
33+
#include "llvm/Support/FileSystem.h"
3334
#include "llvm/Support/Process.h"
3435
#include "llvm/Support/SaveAndRestore.h"
3536
#include "llvm/Support/raw_ostream.h"
@@ -1177,6 +1178,16 @@ void Decl::dump() const {
11771178
dump(llvm::errs(), 0);
11781179
}
11791180

1181+
void Decl::dump(const char *filename) const {
1182+
std::error_code ec;
1183+
llvm::raw_fd_ostream stream(filename, ec, llvm::sys::fs::F_RW);
1184+
// In assert builds, we blow up. Otherwise, we just return.
1185+
assert(!ec && "Failed to open file for dumping?!");
1186+
if (ec)
1187+
return;
1188+
dump(stream, 0);
1189+
}
1190+
11801191
void Decl::dump(raw_ostream &OS, unsigned Indent) const {
11811192
// Make sure to print type variables.
11821193
llvm::SaveAndRestore<bool> X(getASTContext().LangOpts.DebugConstraintSolver,

0 commit comments

Comments
 (0)