mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Demangler: remove StringRef dependencies in the demangler interface and
PrettyStackTrace dependencies in the implementation Swift SVN r20248
This commit is contained in:
@@ -13,8 +13,8 @@
|
||||
#ifndef SWIFT_BASIC_DEMANGLE_H
|
||||
#define SWIFT_BASIC_DEMANGLE_H
|
||||
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace llvm {
|
||||
@@ -63,10 +63,6 @@ private:
|
||||
Node(Kind k)
|
||||
: NodeKind(k), NodePayloadKind(PayloadKind::None) {
|
||||
}
|
||||
Node(Kind k, llvm::StringRef t)
|
||||
: NodeKind(k), NodePayloadKind(PayloadKind::Text) {
|
||||
new (&TextPayload) std::string(t);
|
||||
}
|
||||
Node(Kind k, std::string &&t)
|
||||
: NodeKind(k), NodePayloadKind(PayloadKind::Text) {
|
||||
new (&TextPayload) std::string(std::move(t));
|
||||
@@ -77,24 +73,10 @@ private:
|
||||
}
|
||||
Node(const Node &) = delete;
|
||||
Node &operator=(const Node &) = delete;
|
||||
public:
|
||||
static NodePointer create(Kind k) {
|
||||
return NodePointer(new Node(k));
|
||||
}
|
||||
static NodePointer create(Kind k, IndexType index) {
|
||||
return NodePointer(new Node(k, index));
|
||||
}
|
||||
static NodePointer create(Kind k, llvm::StringRef text) {
|
||||
return NodePointer(new Node(k, text));
|
||||
}
|
||||
static NodePointer create(Kind k, std::string &&text) {
|
||||
return NodePointer(new Node(k, std::move(text)));
|
||||
}
|
||||
template <size_t N>
|
||||
static NodePointer create(Kind k, const char (&text)[N]) {
|
||||
return NodePointer(new Node(k, llvm::StringRef(text)));
|
||||
}
|
||||
|
||||
friend struct NodeFactory;
|
||||
|
||||
public:
|
||||
~Node();
|
||||
|
||||
Kind getKind() const { return NodeKind; }
|
||||
@@ -141,11 +123,8 @@ public:
|
||||
addChild(std::move(child1));
|
||||
addChild(std::move(child2));
|
||||
}
|
||||
|
||||
void dump() const;
|
||||
void print(llvm::raw_ostream &out) const;
|
||||
};
|
||||
|
||||
|
||||
/// \brief Demangle the given string as a Swift symbol.
|
||||
///
|
||||
/// Typical usage:
|
||||
@@ -154,14 +133,16 @@ public:
|
||||
/// swift::Demangler::demangleSymbol("SomeSwiftMangledName")
|
||||
/// \endcode
|
||||
///
|
||||
/// \param mangled The mangled string.
|
||||
/// \param options An object encapsulating options to use to perform this demangling.
|
||||
/// \param MangledName The mangled string.
|
||||
/// \param Options An object encapsulating options to use to perform this demangling.
|
||||
///
|
||||
///
|
||||
/// \returns A parse tree for the demangled string - or a Failure node on
|
||||
/// failure.
|
||||
///
|
||||
NodePointer demangleSymbolAsNode(llvm::StringRef mangled, const DemangleOptions& options = DemangleOptions());
|
||||
NodePointer
|
||||
demangleSymbolAsNode(const char *MangledName, size_t MangledNameLength,
|
||||
const DemangleOptions &Options = DemangleOptions());
|
||||
|
||||
/// \brief Transform the node structure in a string.
|
||||
///
|
||||
@@ -171,12 +152,13 @@ NodePointer demangleSymbolAsNode(llvm::StringRef mangled, const DemangleOptions&
|
||||
/// swift::Demangler::nodeToString(aNode)
|
||||
/// \endcode
|
||||
///
|
||||
/// \param pointer A pointer to a parse tree generated by the demangler.
|
||||
/// \param options An object encapsulating options to use to perform this demangling.
|
||||
/// \param Root A pointer to a parse tree generated by the demangler.
|
||||
/// \param Options An object encapsulating options to use to perform this demangling.
|
||||
///
|
||||
/// \returns A string representing the demangled name.
|
||||
///
|
||||
std::string nodeToString(NodePointer pointer, const DemangleOptions& options = DemangleOptions());
|
||||
std::string nodeToString(NodePointer Root,
|
||||
const DemangleOptions &Options = DemangleOptions());
|
||||
|
||||
/// \brief Demangle the given string as a Swift symbol.
|
||||
///
|
||||
@@ -186,15 +168,18 @@ std::string nodeToString(NodePointer pointer, const DemangleOptions& options = D
|
||||
/// swift::Demangler::demangleSymbol("SomeSwiftMangledName")
|
||||
/// \endcode
|
||||
///
|
||||
/// \param mangled The mangled string.
|
||||
/// \param options An object encapsulating options to use to perform this demangling.
|
||||
/// \param MangledName The mangled string.
|
||||
/// \param Options An object encapsulating options to use to perform this demangling.
|
||||
///
|
||||
///
|
||||
/// \returns A string representing the demangled name.
|
||||
///
|
||||
std::string demangleSymbolAsString(llvm::StringRef mangled, const DemangleOptions& options = DemangleOptions());
|
||||
std::string
|
||||
demangleSymbolAsString(const char *MangledName, size_t MangledNameLength,
|
||||
const DemangleOptions &Options = DemangleOptions());
|
||||
|
||||
} // end namespace Demangle
|
||||
} // end namespace swift
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user