Skip to content

Commit 17169fc

Browse files
authored
Merge pull request #27950 from brentdax/dumpster-fire
[NFC] Standardize dump() methods in frontend
2 parents c326016 + ffbe53e commit 17169fc

File tree

103 files changed

+426
-362
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+426
-362
lines changed

docs/DebuggingTheCompiler.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@ debugging press <CTRL>-C on the LLDB prompt.
214214
Note that this only works in Xcode if the PATH variable in the scheme's
215215
environment setting contains the path to the dot tool.
216216

217+
swift/Basic/Debug.h includes macros to help contributors declare these methods
218+
with the proper attributes to ensure they'll be available in the debugger. In
219+
particular, if you see ``SWIFT_DEBUG_DUMP`` in a class declaration, that class
220+
has a ``dump()`` method you can call.
221+
217222
Debugging and Profiling on SIL level
218223
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
219224

include/swift/AST/ASTNode.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#define SWIFT_AST_AST_NODE_H
1919

2020
#include "llvm/ADT/PointerUnion.h"
21+
#include "swift/Basic/Debug.h"
2122
#include "swift/AST/TypeAlignments.h"
2223

2324
namespace llvm {
@@ -62,9 +63,7 @@ namespace swift {
6263
FUNC(Decl)
6364
#undef FUNC
6465

65-
LLVM_ATTRIBUTE_DEPRECATED(
66-
void dump() const LLVM_ATTRIBUTE_USED,
67-
"only for use within the debugger");
66+
SWIFT_DEBUG_DUMP;
6867
void dump(llvm::raw_ostream &OS, unsigned Indent = 0) const;
6968

7069
/// Whether the AST node is implicit.

include/swift/AST/ASTScope.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "swift/AST/NameLookup.h" // for DeclVisibilityKind
3333
#include "swift/AST/SimpleRequest.h"
3434
#include "swift/Basic/Compiler.h"
35+
#include "swift/Basic/Debug.h"
3536
#include "swift/Basic/LLVM.h"
3637
#include "swift/Basic/NullablePtr.h"
3738
#include "swift/Basic/SourceManager.h"
@@ -330,8 +331,7 @@ class ASTScopeImpl {
330331
virtual NullablePtr<const void> addressForPrinting() const;
331332

332333
public:
333-
LLVM_ATTRIBUTE_DEPRECATED(void dump() const LLVM_ATTRIBUTE_USED,
334-
"only for use within the debugger");
334+
SWIFT_DEBUG_DUMP;
335335

336336
void dumpOneScopeMapLocation(std::pair<unsigned, unsigned> lineColumn);
337337

include/swift/AST/AccessScope.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include "swift/AST/AttrKind.h"
1717
#include "swift/AST/DeclContext.h"
18+
#include "swift/Basic/Debug.h"
1819
#include "llvm/ADT/PointerIntPair.h"
1920

2021
namespace swift {
@@ -87,7 +88,7 @@ class AccessScope {
8788
return None;
8889
}
8990

90-
void dump() const;
91+
SWIFT_DEBUG_DUMP;
9192
};
9293

9394
} // end namespace swift

include/swift/AST/AnyFunctionRef.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#define SWIFT_AST_ANY_FUNCTION_REF_H
1515

1616
#include "swift/Basic/Compiler.h"
17+
#include "swift/Basic/Debug.h"
1718
#include "swift/Basic/LLVM.h"
1819
#include "swift/AST/Decl.h"
1920
#include "swift/AST/Expr.h"
@@ -177,8 +178,7 @@ class AnyFunctionRef {
177178
#pragma warning(push)
178179
#pragma warning(disable: 4996)
179180
#endif
180-
LLVM_ATTRIBUTE_DEPRECATED(void dump() const LLVM_ATTRIBUTE_USED,
181-
"only for use within the debugger") {
181+
SWIFT_DEBUG_DUMP {
182182
if (auto afd = TheFunction.dyn_cast<AbstractFunctionDecl *>()) {
183183
return afd->dump();
184184
}

include/swift/AST/Attr.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#ifndef SWIFT_ATTR_H
1818
#define SWIFT_ATTR_H
1919

20+
#include "swift/Basic/Debug.h"
2021
#include "swift/Basic/InlineBitfield.h"
2122
#include "swift/Basic/SourceLoc.h"
2223
#include "swift/Basic/UUID.h"
@@ -1583,7 +1584,7 @@ class DeclAttributes {
15831584
/// a declaration is deprecated on all deployment targets, or null otherwise.
15841585
const AvailableAttr *getDeprecated(const ASTContext &ctx) const;
15851586

1586-
void dump(const Decl *D = nullptr) const;
1587+
SWIFT_DEBUG_DUMPER(dump(const Decl *D = nullptr));
15871588
void print(ASTPrinter &Printer, const PrintOptions &Options,
15881589
const Decl *D = nullptr) const;
15891590
static void print(ASTPrinter &Printer, const PrintOptions &Options,

include/swift/AST/CaptureInfo.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#ifndef SWIFT_AST_CAPTURE_INFO_H
1414
#define SWIFT_AST_CAPTURE_INFO_H
1515

16+
#include "swift/Basic/Debug.h"
1617
#include "swift/Basic/LLVM.h"
1718
#include "swift/Basic/OptionSet.h"
1819
#include "swift/Basic/SourceLoc.h"
@@ -219,7 +220,7 @@ class CaptureInfo {
219220
return StorageAndFlags.getPointer()->getOpaqueValue();
220221
}
221222

222-
void dump() const;
223+
SWIFT_DEBUG_DUMP;
223224
void print(raw_ostream &OS) const;
224225
};
225226

include/swift/AST/ConcreteDeclRef.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#ifndef SWIFT_AST_CONCRETEDECLREF_H
1818
#define SWIFT_AST_CONCRETEDECLREF_H
1919

20+
#include "swift/Basic/Debug.h"
2021
#include "swift/Basic/LLVM.h"
2122
#include "swift/AST/SubstitutionMap.h"
2223
#include "swift/AST/TypeAlignments.h"
@@ -81,8 +82,8 @@ class ConcreteDeclRef {
8182
}
8283

8384
/// Dump a debug representation of this reference.
84-
void dump(raw_ostream &os);
85-
void dump() LLVM_ATTRIBUTE_USED;
85+
void dump(raw_ostream &os) const;
86+
SWIFT_DEBUG_DUMP;
8687
};
8788

8889
} // end namespace swift

include/swift/AST/Decl.h

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "swift/AST/Witness.h"
3636
#include "swift/Basic/ArrayRefView.h"
3737
#include "swift/Basic/Compiler.h"
38+
#include "swift/Basic/Debug.h"
3839
#include "swift/Basic/InlineBitfield.h"
3940
#include "swift/Basic/NullablePtr.h"
4041
#include "swift/Basic/OptionalEnum.h"
@@ -777,12 +778,8 @@ class alignas(1 << DeclAlignInBits) Decl {
777778

778779
SourceLoc TrailingSemiLoc;
779780

780-
LLVM_ATTRIBUTE_DEPRECATED(
781-
void dump() const LLVM_ATTRIBUTE_USED,
782-
"only for use within the debugger");
783-
LLVM_ATTRIBUTE_DEPRECATED(
784-
void dump(const char *filename) const LLVM_ATTRIBUTE_USED,
785-
"only for use within the debugger");
781+
SWIFT_DEBUG_DUMP;
782+
SWIFT_DEBUG_DUMPER(dump(const char *filename));
786783
void dump(raw_ostream &OS, unsigned Indent = 0) const;
787784

788785
/// Pretty-print the given declaration.
@@ -1203,9 +1200,7 @@ class RequirementRepr {
12031200
return repr->SecondType.getTypeRepr();
12041201
}
12051202

1206-
LLVM_ATTRIBUTE_DEPRECATED(
1207-
void dump() const LLVM_ATTRIBUTE_USED,
1208-
"only for use within the debugger");
1203+
SWIFT_DEBUG_DUMP;
12091204
void print(raw_ostream &OS) const;
12101205
void print(ASTPrinter &Printer) const;
12111206
};
@@ -1375,7 +1370,7 @@ class GenericParamList final :
13751370
GenericParamList *clone(DeclContext *dc) const;
13761371

13771372
void print(raw_ostream &OS) const;
1378-
void dump();
1373+
SWIFT_DEBUG_DUMP;
13791374
};
13801375

13811376
/// A trailing where clause.
@@ -2715,7 +2710,7 @@ class ValueDecl : public Decl {
27152710
void dumpRef(raw_ostream &os) const;
27162711

27172712
/// Dump a reference to the given declaration.
2718-
void dumpRef() const;
2713+
SWIFT_DEBUG_DUMPER(dumpRef());
27192714

27202715
/// Returns true if the declaration is a static member of a type.
27212716
///

include/swift/AST/DeclContext.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "swift/AST/LookupKinds.h"
2424
#include "swift/AST/ResilienceExpansion.h"
2525
#include "swift/AST/TypeAlignments.h"
26+
#include "swift/Basic/Debug.h"
2627
#include "swift/Basic/LLVM.h"
2728
#include "swift/Basic/STLExtras.h"
2829
#include "swift/Basic/SourceLoc.h"
@@ -597,7 +598,7 @@ class alignas(1 << DeclContextAlignInBits) DeclContext {
597598
/// \returns true if traversal was aborted, false otherwise.
598599
bool walkContext(ASTWalker &Walker);
599600

600-
void dumpContext() const;
601+
SWIFT_DEBUG_DUMPER(dumpContext());
601602
unsigned printContext(llvm::raw_ostream &OS, unsigned indent = 0,
602603
bool onlyAPartialLine = false) const;
603604

0 commit comments

Comments
 (0)