mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[NFC] Standardize dump() methods in frontend
By convention, most structs and classes in the Swift compiler include a `dump()` method which prints debugging information. This method is meant to be called only from the debugger, but this means they’re often unused and may be eliminated from optimized binaries. On the other hand, some parts of the compiler call `dump()` methods directly despite them being intended as a pure debugging aid. clang supports attributes which can be used to avoid these problems, but they’re used very inconsistently across the compiler. This commit adds `SWIFT_DEBUG_DUMP` and `SWIFT_DEBUG_DUMPER(<name>(<params>))` macros to declare `dump()` methods with the appropriate set of attributes and adopts this macro throughout the frontend. It does not pervasively adopt this macro in SILGen, SILOptimizer, or IRGen; these components use `dump()` methods in a different way where they’re frequently called from debugging code. Nor does it adopt it in runtime components like swiftRuntime and swiftReflection, because I’m a bit worried about size. Despite the large number of files and lines affected, this change is NFC.
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#ifndef SWIFT_PARSE_PARSEDRAWSYNTAXNODE_H
|
||||
#define SWIFT_PARSE_PARSEDRAWSYNTAXNODE_H
|
||||
|
||||
#include "swift/Basic/Debug.h"
|
||||
#include "swift/Basic/SourceLoc.h"
|
||||
#include "swift/Parse/ParsedTrivia.h"
|
||||
#include "swift/Parse/Token.h"
|
||||
@@ -327,9 +328,7 @@ public:
|
||||
}
|
||||
|
||||
/// Dump this piece of syntax recursively for debugging or testing.
|
||||
LLVM_ATTRIBUTE_DEPRECATED(
|
||||
void dump() const LLVM_ATTRIBUTE_USED,
|
||||
"only for use within the debugger");
|
||||
SWIFT_DEBUG_DUMP;
|
||||
|
||||
/// Dump this piece of syntax recursively.
|
||||
void dump(raw_ostream &OS, unsigned Indent = 0) const;
|
||||
|
||||
Reference in New Issue
Block a user