Imports #
"errors"
"fmt"
"strings"
"fmt"
"math"
"math/bits"
"strings"
"unicode/utf8"
"fmt"
"strings"
"errors"
"fmt"
"strings"
"fmt"
"math"
"math/bits"
"strings"
"unicode/utf8"
"fmt"
"strings"
ErrNotMangledName is returned by CheckedDemangle if the string does not appear to be a C++ symbol name.
var ErrNotMangledName = *ast.CallExpr
LLVMStyle tries to translate an AST to a string in the style of the LLVM demangler. This does not affect the parsing of the AST, only the conversion of the AST to a string.
const LLVMStyle
The NoClones option disables inclusion of clone suffixes. NoParams implies NoClones.
const NoClones
The NoEnclosingParams option disables demangling of the function parameter types of the enclosing function when demangling a local name defined within a function.
const NoEnclosingParams
The NoParams option disables demangling of function parameters. It only omits the parameters of the function name being demangled, not the parameter types of other functions that may be mentioned. Using the option will speed up the demangler and cause it to use less memory.
const NoParams Option = iota
The NoRust option disables demangling of old-style Rust mangled names, which can be confused with C++ style mangled names. New style Rust mangled names are still recognized.
const NoRust
The NoTemplateParams option disables demangling of template parameters. This applies to both C++ and Rust.
const NoTemplateParams
The Verbose option turns on more verbose demangling.
const Verbose
Builtin float types.
var builtinTypeFloat = map[string]bool{...}
Suffixes to use for constants of the given integer type.
var builtinTypeSuffix = map[string]string{...}
builtinTypes maps the type letter to the type name.
var builtinTypes = map[byte]string{...}
const forLocalName forLocalNameType = iota
maxLengthMask is a mask for the maxLength value.
const maxLengthMask = *ast.BinaryExpr
maxLengthShift is how we shift the MaxLength value.
const maxLengthShift = 16
const notForLocalName
The operators map maps the mangled operator names to information about them.
var operators = map[string]operator{...}
The precedence values, in order from high to low.
const precAdd
The precedence values, in order from high to low.
const precAnd
The precedence values, in order from high to low.
const precAssign
The precedence values, in order from high to low.
const precCast
The precedence values, in order from high to low.
const precComma
The precedence values, in order from high to low.
const precCond
The precedence values, in order from high to low.
const precDefault
The precedence values, in order from high to low.
const precEqual
The precedence values, in order from high to low.
const precLogicalAnd
The precedence values, in order from high to low.
const precLogicalOr
The precedence values, in order from high to low.
const precMul
The precedence values, in order from high to low.
const precOr
The precedence values, in order from high to low.
const precPostfix
The precedence values, in order from high to low.
const precPrimary precedence = iota
The precedence values, in order from high to low.
const precPtrMem
The precedence values, in order from high to low.
const precRel
The precedence values, in order from high to low.
const precShift
The precedence values, in order from high to low.
const precSpaceship
The precedence values, in order from high to low.
const precUnary
The precedence values, in order from high to low.
const precXor
qualifiers maps from the character used in the mangled name to the string to print.
var qualifiers = map[byte]string{...}
var rustBasicTypes = map[byte]string{...}
subAST maps standard substitution codes to the corresponding AST.
var subAST = map[byte]AST{...}
verboseAST maps standard substitution codes to the long form of the corresponding AST. We use this when the Verbose option is used, to match the standard demangler.
var verboseAST = map[byte]AST{...}
Option is the type of demangler options.
type Option int
type forLocalNameType int
precedence is used for operator precedence. This is used to avoid unnecessary parentheses when printing expressions in the LLVM style.
type precedence int
substitutions is the list of substitution candidates that may appear later in the string.
type substitutions []AST
AST is an abstract syntax tree representing a C++ declaration. This is sufficient for the demangler but is by no means a general C++ AST. This abstract syntax tree is only used for C++ symbols, not Rust symbols.
type AST interface {
print(*printState)
Traverse(func(AST) bool)
Copy(copy func(AST) AST, skip func(AST) bool) AST
GoString() string
goString(indent int, field string) string
}
hasPrec matches the AST nodes that have a prec method that returns the node's precedence.
type hasPrec interface {
prec() precedence
}
innerPrinter is an interface for types that can print themselves as inner types.
type innerPrinter interface {
printInner(*printState)
}
ArgumentPack is an argument pack.
type ArgumentPack struct {
Args []AST
}
ArrayType is an array type.
type ArrayType struct {
Dimension AST
Element AST
}
Binary is a binary operation in an expression.
type Binary struct {
Op AST
Left AST
Right AST
}
BinaryFP is a binary floating-point type.
type BinaryFP struct {
Bits int
}
BitIntType is the C++23 _BitInt(N) type.
type BitIntType struct {
Size AST
Signed bool
}
BuiltinType is a builtin type, like "int".
type BuiltinType struct {
Name string
}
Cast is a type cast.
type Cast struct {
To AST
}
Clone is a clone of a function, with a distinguishing suffix.
type Clone struct {
Base AST
Suffix string
}
Closure is a closure, or lambda expression.
type Closure struct {
TemplateArgs []AST
TemplateArgsConstraint AST
Types []AST
Num int
CallConstraint AST
}
ComplexType is a complex type.
type ComplexType struct {
Base AST
}
ConstrainedTypeTemplateParam is a constrained template type parameter declaration.
type ConstrainedTypeTemplateParam struct {
Name AST
Constraint AST
}
Constraint represents an AST with a constraint.
type Constraint struct {
Name AST
Requires AST
}
Constructor is a constructor.
type Constructor struct {
Name AST
Base AST
}
Decltype is the decltype operator.
type Decltype struct {
Expr AST
}
DefaultArg holds a default argument for a local name.
type DefaultArg struct {
Num int
Arg AST
}
Destructor is a destructor.
type Destructor struct {
Name AST
}
ElaboratedType is an elaborated struct/union/enum type.
type ElaboratedType struct {
Kind string
Type AST
}
EnableIf is used by clang for an enable_if attribute.
type EnableIf struct {
Type AST
Args []AST
}
ExplicitObjectParameter represents a C++23 explicit object parameter.
type ExplicitObjectParameter struct {
Base AST
}
ExprList is a list of expressions, typically arguments to a function call in an expression.
type ExprList struct {
Exprs []AST
}
ExprRequirement is a simple requirement in a requires expression. This is an arbitrary expression.
type ExprRequirement struct {
Expr AST
Noexcept bool
TypeReq AST
}
FixedType is a fixed numeric type of unknown size.
type FixedType struct {
Base AST
Accum bool
Sat bool
}
Fold is a C++17 fold-expression. Arg2 is nil for a unary operator.
type Fold struct {
Left bool
Op AST
Arg1 AST
Arg2 AST
}
Friend is a member like friend name.
type Friend struct {
Name AST
}
FunctionParam is a parameter of a function, used for last-specified return type in a closure.
type FunctionParam struct {
Index int
}
FunctionType is a function type.
type FunctionType struct {
Return AST
Args []AST
ForLocalName bool
}
GlobalCDtor is a global constructor or destructor.
type GlobalCDtor struct {
Ctor bool
Key AST
}
ImaginaryType is an imaginary type.
type ImaginaryType struct {
Base AST
}
InitializerList is an initializer list: an optional type with a list of expressions.
type InitializerList struct {
Type AST
Exprs AST
}
LambdaAuto is a lambda auto parameter.
type LambdaAuto struct {
Index int
}
LambdaExpr is a literal that is a lambda expression.
type LambdaExpr struct {
Type AST
}
Literal is a literal in an expression.
type Literal struct {
Type AST
Val string
Neg bool
}
MethodWithQualifiers is a method with qualifiers.
type MethodWithQualifiers struct {
Method AST
Qualifiers AST
RefQualifier string
}
ModuleEntity is a name inside a module.
type ModuleEntity struct {
Module AST
Name AST
}
ModuleName is a C++20 module.
type ModuleName struct {
Parent AST
Name AST
IsPartition bool
}
Name is an unqualified name.
type Name struct {
Name string
}
NestedRequirement is a nested requirement in a requires expression.
type NestedRequirement struct {
Constraint AST
}
New is a use of operator new in an expression.
type New struct {
Op AST
Place AST
Type AST
Init AST
}
NonTypeTemplateParam is a non-type template parameter that appears in a lambda with explicit template parameters.
type NonTypeTemplateParam struct {
Name AST
Type AST
}
Nullary is an operator in an expression with no arguments, such as throw.
type Nullary struct {
Op AST
}
Operator is an operator.
type Operator struct {
Name string
precedence precedence
}
PackExpansion is a pack expansion. The Pack field may be nil.
type PackExpansion struct {
Base AST
Pack *ArgumentPack
}
PointerType is a pointer type.
type PointerType struct {
Base AST
}
PtrMem is a pointer-to-member expression.
type PtrMem struct {
Class AST
Member AST
}
PtrMemCast is a conversion of an expression to a pointer-to-member type. This is used for C++20 manglings of class types used as the type of non-type template arguments. See https://github.com/itanium-cxx-abi/cxx-abi/issues/47.
type PtrMemCast struct {
Type AST
Expr AST
Offset int
}
Qualified is a name in a scope.
type Qualified struct {
Scope AST
Name AST
LocalName bool
}
Qualifier is a single type qualifier.
type Qualifier struct {
Name string
Exprs []AST
}
Qualifiers is an ordered list of type qualifiers.
type Qualifiers struct {
Qualifiers []AST
}
ReferenceType is a reference type.
type ReferenceType struct {
Base AST
}
RequiresExpr is a C++20 requires expression.
type RequiresExpr struct {
Params []AST
Requirements []AST
}
RvalueReferenceType is an rvalue reference type.
type RvalueReferenceType struct {
Base AST
}
SizeofArgs is the size of a captured template parameter pack from an alias template.
type SizeofArgs struct {
Args []AST
}
SizeofPack is the sizeof operator applied to an argument pack.
type SizeofPack struct {
Pack *ArgumentPack
}
Special is a special symbol, printed as a prefix plus another value.
type Special struct {
Prefix string
Val AST
}
Special2 is like special, but uses two values.
type Special2 struct {
Prefix string
Val1 AST
Middle string
Val2 AST
}
StringLiteral is a string literal.
type StringLiteral struct {
Type AST
}
StructuredBindings is a structured binding declaration.
type StructuredBindings struct {
Bindings []AST
}
Subobject is a a reference to an offset in an expression. This is used for C++20 manglings of class types used as the type of non-type template arguments. See https://github.com/itanium-cxx-abi/cxx-abi/issues/47.
type Subobject struct {
Type AST
SubExpr AST
Offset int
Selectors []int
PastEnd bool
}
SuffixType is an type with an arbitrary suffix.
type SuffixType struct {
Base AST
Suffix string
}
TaggedName is a name with an ABI tag.
type TaggedName struct {
Name AST
Tag AST
}
Template is a template with arguments.
type Template struct {
Name AST
Args []AST
}
TemplateParam is a template parameter. The Template field is filled in while parsing the demangled string. We don't normally see these while printing--they are replaced by the simplify function.
type TemplateParam struct {
Index int
Template *Template
}
TemplateParamName is the name of a template parameter that the demangler introduced for a lambda that has explicit template parameters. This is a prefix with an index.
type TemplateParamName struct {
Prefix string
Index int
}
TemplateParamPack is a template parameter pack that appears in a lambda with explicit template parameters.
type TemplateParamPack struct {
Param AST
}
TemplateParamQualifiedArg is used when the mangled name includes both the template parameter declaration and the template argument. See https://github.com/itanium-cxx-abi/cxx-abi/issues/47.
type TemplateParamQualifiedArg struct {
Param AST
Arg AST
}
TemplateTemplateParam is a template template parameter that appears in a lambda with explicit template parameters.
type TemplateTemplateParam struct {
Name AST
Params []AST
Constraint AST
}
TransformedType is a builtin type with a template argument.
type TransformedType struct {
Name string
Base AST
}
Trinary is the ?: trinary operation in an expression.
type Trinary struct {
Op AST
First AST
Second AST
Third AST
}
TypeRequirement is a type requirement in a requires expression.
type TypeRequirement struct {
Type AST
}
TypeTemplateParam is a type template parameter that appears in a lambda with explicit template parameters.
type TypeTemplateParam struct {
Name AST
}
TypeWithQualifiers is a type with standard qualifiers.
type TypeWithQualifiers struct {
Base AST
Qualifiers AST
}
Typed is a typed name.
type Typed struct {
Name AST
Type AST
}
Unary is a unary operation in an expression.
type Unary struct {
Op AST
Expr AST
Suffix bool
SizeofType bool
}
UnnamedType is an unnamed type, that just has an index.
type UnnamedType struct {
Num int
}
VectorType is a vector type.
type VectorType struct {
Dimension AST
Base AST
}
VendorQualifier is a type qualified by a vendor-specific qualifier.
type VendorQualifier struct {
Qualifier AST
Type AST
}
A demangleErr is an error at a specific offset in the mangled string.
type demangleErr struct {
err string
off int
}
An operator is the demangled name, and the number of arguments it takes in an expression.
type operator struct {
name string
args int
prec precedence
}
The printState type holds information needed to print an AST.
type printState struct {
tparams bool
enclosingParams bool
llvmStyle bool
max int
scopes int
buf strings.Builder
last byte
inner []AST
printing []AST
}
A rustState holds the current state of demangling a Rust string.
type rustState struct {
orig string
str string
off int
buf strings.Builder
skip bool
lifetimes int64
last byte
noGenericArgs bool
max int
}
A state holds the current state of demangling a string.
type state struct {
str string
verbose bool
off int
subs substitutions
templates []*Template
lambdaTemplateLevel int
parsingConstraint bool
typeTemplateParamCount int
nonTypeTemplateParamCount int
templateTemplateParamCount int
}
ASTToString returns the demangled name of the AST.
func ASTToString(a AST, options ...Option) string
func (sb *StructuredBindings) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (op *Operator) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (eop *ExplicitObjectParameter) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (c *Constructor) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (dt *Decltype) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (d *Destructor) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (et *ElaboratedType) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (vt *VectorType) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (gcd *GlobalCDtor) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (bt *BitIntType) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (t *TaggedName) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (bfp *BinaryFP) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (pe *PackExpansion) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (ft *FixedType) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (pm *PtrMem) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (ap *ArgumentPack) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (nr *NestedRequirement) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (sp *SizeofPack) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (fp *FunctionParam) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (tr *TypeRequirement) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (ft *FunctionType) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (sa *SizeofArgs) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (er *ExprRequirement) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (tpn *TemplateParamName) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (at *ArrayType) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (re *RequiresExpr) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (ttp *TypeTemplateParam) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (vq *VendorQualifier) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (c *Constraint) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (nttp *NonTypeTemplateParam) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (tt *TransformedType) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (ttp *TemplateTemplateParam) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (st *SuffixType) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (cttp *ConstrainedTypeTemplateParam) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (it *ImaginaryType) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (f *Friend) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (tpp *TemplateParamPack) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (ct *ComplexType) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (c *Cast) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (rt *RvalueReferenceType) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (n *Nullary) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (rt *ReferenceType) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (me *ModuleEntity) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (u *Unary) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (pt *PointerType) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (b *Binary) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (mn *ModuleName) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (bt *BuiltinType) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (t *Trinary) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (mwq *MethodWithQualifiers) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (f *Fold) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (twq *TypeWithQualifiers) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (ei *EnableIf) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (so *Subobject) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (q *Qualifier) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (qs *Qualifiers) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (pmc *PtrMemCast) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (tpqa *TemplateParamQualifiedArg) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (n *New) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (la *LambdaAuto) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (tp *TemplateParam) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (s *Special2) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (l *Literal) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (t *Template) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (s *Special) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (sl *StringLiteral) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (q *Qualified) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (le *LambdaExpr) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (c *Clone) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (t *Typed) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (el *ExprList) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (n *Name) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (il *InitializerList) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (da *DefaultArg) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (ut *UnnamedType) Copy(fn func(AST) AST, skip func(AST) bool) AST
func (cl *Closure) Copy(fn func(AST) AST, skip func(AST) bool) AST
Error implements the builtin error interface for demangleErr.
func (de demangleErr) Error() string
Filter demangles a C++ or Rust symbol name, returning the human-readable C++ or Rust name. If any error occurs during demangling, the input string is returned.
func Filter(name string, options ...Option) string
func (tt *TransformedType) GoString() string
func (f *Fold) GoString() string
func (op *Operator) GoString() string
func (eop *ExplicitObjectParameter) GoString() string
func (c *Constructor) GoString() string
func (dt *Decltype) GoString() string
func (et *ElaboratedType) GoString() string
func (d *Destructor) GoString() string
func (vt *VectorType) GoString() string
func (gcd *GlobalCDtor) GoString() string
func (cl *Closure) GoString() string
func (sb *StructuredBindings) GoString() string
func (bt *BitIntType) GoString() string
func (t *TaggedName) GoString() string
func (bfp *BinaryFP) GoString() string
func (ft *FixedType) GoString() string
func (pe *PackExpansion) GoString() string
func (pm *PtrMem) GoString() string
func (da *DefaultArg) GoString() string
func (ut *UnnamedType) GoString() string
func (nr *NestedRequirement) GoString() string
func (il *InitializerList) GoString() string
func (ap *ArgumentPack) GoString() string
func (fp *FunctionParam) GoString() string
func (tr *TypeRequirement) GoString() string
func (sp *SizeofPack) GoString() string
func (ft *FunctionType) GoString() string
func (n *Name) GoString() string
func (el *ExprList) GoString() string
func (er *ExprRequirement) GoString() string
func (sa *SizeofArgs) GoString() string
func (le *LambdaExpr) GoString() string
func (at *ArrayType) GoString() string
func (re *RequiresExpr) GoString() string
func (t *Typed) GoString() string
func (tpn *TemplateParamName) GoString() string
func (ttp *TypeTemplateParam) GoString() string
func (vq *VendorQualifier) GoString() string
func (c *Clone) GoString() string
func (q *Qualified) GoString() string
func (sl *StringLiteral) GoString() string
func (c *Constraint) GoString() string
func (nttp *NonTypeTemplateParam) GoString() string
func (st *SuffixType) GoString() string
func (s *Special) GoString() string
func (t *Template) GoString() string
func (l *Literal) GoString() string
func (ttp *TemplateTemplateParam) GoString() string
func (it *ImaginaryType) GoString() string
func (f *Friend) GoString() string
func (tp *TemplateParam) GoString() string
func (cttp *ConstrainedTypeTemplateParam) GoString() string
func (n *New) GoString() string
func (ct *ComplexType) GoString() string
func (tpp *TemplateParamPack) GoString() string
func (la *LambdaAuto) GoString() string
func (rt *RvalueReferenceType) GoString() string
func (c *Cast) GoString() string
func (me *ModuleEntity) GoString() string
func (s *Special2) GoString() string
func (tpqa *TemplateParamQualifiedArg) GoString() string
func (pmc *PtrMemCast) GoString() string
func (rt *ReferenceType) GoString() string
func (n *Nullary) GoString() string
func (pt *PointerType) GoString() string
func (qs *Qualifiers) GoString() string
func (u *Unary) GoString() string
func (so *Subobject) GoString() string
func (mn *ModuleName) GoString() string
func (b *Binary) GoString() string
func (q *Qualifier) GoString() string
func (bt *BuiltinType) GoString() string
func (t *Trinary) GoString() string
func (mwq *MethodWithQualifiers) GoString() string
func (ei *EnableIf) GoString() string
func (twq *TypeWithQualifiers) GoString() string
MaxLength returns an Option that limits the maximum length of a demangled string. The maximum length is expressed as a power of 2, so a value of 1 limits the returned string to 2 characters, and a value of 16 limits the returned string to 65,536 characters. The value must be between 1 and 30.
func MaxLength(pow int) Option
ToAST demangles a C++ symbol name into an abstract syntax tree representing the symbol. If the NoParams option is passed, and the name has a function type, the parameter types are not demangled. If the name does not appear to be a C++ symbol name at all, the error will be ErrNotMangledName. This function does not currently support Rust symbol names.
func ToAST(name string, options ...Option) (AST, error)
ToString demangles a C++ or Rust symbol name, returning a human-readable C++ or Rust name or an error. If the name does not appear to be a C++ or Rust symbol name at all, the error will be ErrNotMangledName.
func ToString(name string, options ...Option) (string, error)
func (rt *ReferenceType) Traverse(fn func(AST) bool)
func (l *Literal) Traverse(fn func(AST) bool)
func (f *Fold) Traverse(fn func(AST) bool)
func (mwq *MethodWithQualifiers) Traverse(fn func(AST) bool)
func (mn *ModuleName) Traverse(fn func(AST) bool)
func (twq *TypeWithQualifiers) Traverse(fn func(AST) bool)
func (so *Subobject) Traverse(fn func(AST) bool)
func (sb *StructuredBindings) Traverse(fn func(AST) bool)
func (bt *BuiltinType) Traverse(fn func(AST) bool)
func (op *Operator) Traverse(fn func(AST) bool)
func (dt *Decltype) Traverse(fn func(AST) bool)
func (t *Trinary) Traverse(fn func(AST) bool)
func (d *Destructor) Traverse(fn func(AST) bool)
func (q *Qualifier) Traverse(fn func(AST) bool)
func (b *Binary) Traverse(fn func(AST) bool)
func (pmc *PtrMemCast) Traverse(fn func(AST) bool)
func (pt *PointerType) Traverse(fn func(AST) bool)
func (et *ElaboratedType) Traverse(fn func(AST) bool)
func (gcd *GlobalCDtor) Traverse(fn func(AST) bool)
func (me *ModuleEntity) Traverse(fn func(AST) bool)
func (u *Unary) Traverse(fn func(AST) bool)
func (qs *Qualifiers) Traverse(fn func(AST) bool)
func (vt *VectorType) Traverse(fn func(AST) bool)
func (t *TaggedName) Traverse(fn func(AST) bool)
func (ei *EnableIf) Traverse(fn func(AST) bool)
func (tpqa *TemplateParamQualifiedArg) Traverse(fn func(AST) bool)
func (n *Nullary) Traverse(fn func(AST) bool)
func (n *New) Traverse(fn func(AST) bool)
func (rt *RvalueReferenceType) Traverse(fn func(AST) bool)
func (f *Friend) Traverse(fn func(AST) bool)
func (bt *BitIntType) Traverse(fn func(AST) bool)
func (bfp *BinaryFP) Traverse(fn func(AST) bool)
func (c *Cast) Traverse(fn func(AST) bool)
func (pe *PackExpansion) Traverse(fn func(AST) bool)
func (ct *ComplexType) Traverse(fn func(AST) bool)
func (ft *FixedType) Traverse(fn func(AST) bool)
func (la *LambdaAuto) Traverse(fn func(AST) bool)
func (cl *Closure) Traverse(fn func(AST) bool)
func (tpp *TemplateParamPack) Traverse(fn func(AST) bool)
func (il *InitializerList) Traverse(fn func(AST) bool)
func (it *ImaginaryType) Traverse(fn func(AST) bool)
func (fp *FunctionParam) Traverse(fn func(AST) bool)
func (tp *TemplateParam) Traverse(fn func(AST) bool)
func (ap *ArgumentPack) Traverse(fn func(AST) bool)
func (cttp *ConstrainedTypeTemplateParam) Traverse(fn func(AST) bool)
func (s *Special2) Traverse(fn func(AST) bool)
func (st *SuffixType) Traverse(fn func(AST) bool)
func (c *Constraint) Traverse(fn func(AST) bool)
func (t *Template) Traverse(fn func(AST) bool)
func (ut *UnnamedType) Traverse(fn func(AST) bool)
func (ttp *TemplateTemplateParam) Traverse(fn func(AST) bool)
func (tt *TransformedType) Traverse(fn func(AST) bool)
func (eop *ExplicitObjectParameter) Traverse(fn func(AST) bool)
func (c *Constructor) Traverse(fn func(AST) bool)
func (sl *StringLiteral) Traverse(fn func(AST) bool)
func (pm *PtrMem) Traverse(fn func(AST) bool)
func (nttp *NonTypeTemplateParam) Traverse(fn func(AST) bool)
func (vq *VendorQualifier) Traverse(fn func(AST) bool)
func (s *Special) Traverse(fn func(AST) bool)
func (q *Qualified) Traverse(fn func(AST) bool)
func (le *LambdaExpr) Traverse(fn func(AST) bool)
func (re *RequiresExpr) Traverse(fn func(AST) bool)
func (ttp *TypeTemplateParam) Traverse(fn func(AST) bool)
func (da *DefaultArg) Traverse(fn func(AST) bool)
func (at *ArrayType) Traverse(fn func(AST) bool)
func (c *Clone) Traverse(fn func(AST) bool)
func (t *Typed) Traverse(fn func(AST) bool)
func (er *ExprRequirement) Traverse(fn func(AST) bool)
func (tpn *TemplateParamName) Traverse(fn func(AST) bool)
func (el *ExprList) Traverse(fn func(AST) bool)
func (sp *SizeofPack) Traverse(fn func(AST) bool)
func (ft *FunctionType) Traverse(fn func(AST) bool)
func (tr *TypeRequirement) Traverse(fn func(AST) bool)
func (nr *NestedRequirement) Traverse(fn func(AST) bool)
func (sa *SizeofArgs) Traverse(fn func(AST) bool)
func (n *Name) Traverse(fn func(AST) bool)
add adds a new substitution candidate.
func (subs *substitutions) add(a AST)
adjustErr adjusts the position of err, if it is a demangleErr, and returns err.
func adjustErr(err error, adj int) error
advance advances the current string offset.
func (st *state) advance(add int)
advance advances the current string offset.
func (rst *rustState) advance(add int)
arrayType parses:
func (st *state) arrayType(isCast bool) AST
backref parses:
func (rst *rustState) backref(demangle func())
bareFunctionType parses:
func (st *state) bareFunctionType(hasReturnType bool, explicitObjectParameter bool) AST
base62Number parses:
func (rst *rustState) base62Number() int64
baseUnresolvedName parses:
func (st *state) baseUnresolvedName() AST
basicType parses:
func (rst *rustState) basicType()
binder parses an optional:
func (rst *rustState) binder()
callOffset parses:
func (st *state) callOffset(c byte)
checkChar requires that the next character in the string be c, and advances past it.
func (st *state) checkChar(c byte)
checkChar requires that the next character in the string be c, and advances past it.
func (rst *rustState) checkChar(c byte)
clearTemplateArgs gives an error for any unset Template field in args. This handles erroneous cases where a cast operator with a forward referenced template is in the scope of another cast operator.
func (st *state) clearTemplateArgs(args []AST)
Recognize a clone suffix. These are not part of the mangling API, but are added by GCC when cloning functions.
func (st *state) cloneSuffix(a AST) AST
closureTypeName parses:
func (st *state) closureTypeName() AST
compactNumber parses:
func (st *state) compactNumber() int
constraintExpr parses a constraint expression. This is just a regular expression, but template parameters are handled specially.
func (st *state) constraintExpr() AST
copy returns a copy of the current state.
func (st *state) copy() *state
cvQualifiers parses:
func (st *state) cvQualifiers() AST
func (rst *rustState) decimalNumber() int
demangleCastTemplateArgs is for a rather hideous parse. When we
see a template-param followed by a template-args, we need to decide
whether we have a template-param or a template-template-param.
Normally it is template-template-param, meaning that we pick up the
template arguments here. But, if we are parsing the type for a
cast operator, then the only way this can be template-template-param
is if there is another set of template-args immediately after this
set. That would look like this:
func (st *state) demangleCastTemplateArgs(tp AST, addSubst bool) AST
demangleConst parses:
func (rst *rustState) demangleConst()
demangleType parses:
func (rst *rustState) demangleType()
demangleType parses:
func (st *state) demangleType(isCast bool) AST
disambiguator parses an optional:
func (rst *rustState) disambiguator() int64
discriminator parses:
func (st *state) discriminator(a AST) AST
The doDemangle function is the entry point into the demangler proper.
func doDemangle(name string, options ...Option) (ret AST, err error)
dynBounds parses:
func (rst *rustState) dynBounds()
dynTrait parses:
func (rst *rustState) dynTrait()
encoding parses:
encoding ::= <(function) name>
func (st *state) encoding(params bool, local forLocalNameType) AST
endScope closes a scope.
func (ps *printState) endScope(b byte)
expandPunycode decodes the Rust version of punycode. This algorithm is taken from RFC 3492 section 6.2.
func (rst *rustState) expandPunycode(s string) string
exprList parses a sequence of expressions up to a terminating character.
func (st *state) exprList(stop byte) AST
exprPrimary parses:
func (st *state) exprPrimary() AST
expression parses:
func (st *state) expression() AST
fail panics with demangleErr, to be caught in doDemangle.
func (st *state) fail(err string)
fail panics with demangleErr, to be caught in rustToString.
func (rst *rustState) fail(err string)
failEarlier is like fail, but decrements the offset to indicate that the point of failure occurred earlier in the string.
func (st *state) failEarlier(err string, dec int)
findArgumentPack walks the AST looking for the argument pack for a pack expansion. We find it via a template parameter.
func (st *state) findArgumentPack(a AST) *ArgumentPack
fnSig parses:
func (rst *rustState) fnSig()
functionType parses:
func (st *state) functionType() AST
genericArg parses:
func (rst *rustState) genericArg()
genericArgs prints a list of generic arguments, without angle brackets.
func (rst *rustState) genericArgs()
globalCDtorName demangles a global constructor/destructor symbol name. The parameter is the string following the "_GLOBAL_" prefix.
func globalCDtorName(name string, options ...Option) (AST, error)
func (f *Fold) goString(indent int, field string) string
func (il *InitializerList) goString(indent int, field string) string
func (op *Operator) goString(indent int, field string) string
func (eop *ExplicitObjectParameter) goString(indent int, field string) string
func (dt *Decltype) goString(indent int, field string) string
func (c *Constructor) goString(indent int, field string) string
func (nr *NestedRequirement) goString(indent int, field string) string
func (et *ElaboratedType) goString(indent int, field string) string
func (d *Destructor) goString(indent int, field string) string
func (tr *TypeRequirement) goString(indent int, field string) string
func (vt *VectorType) goString(indent int, field string) string
func (er *ExprRequirement) goString(indent int, field string) string
func (re *RequiresExpr) goString(indent int, field string) string
func (gcd *GlobalCDtor) goString(indent int, field string) string
func (c *Constraint) goString(indent int, field string) string
func (bt *BitIntType) goString(indent int, field string) string
func (f *Friend) goString(indent int, field string) string
func (bfp *BinaryFP) goString(indent int, field string) string
func (t *TaggedName) goString(indent int, field string) string
func (me *ModuleEntity) goString(indent int, field string) string
func (mn *ModuleName) goString(indent int, field string) string
func (ft *FixedType) goString(indent int, field string) string
func (ei *EnableIf) goString(indent int, field string) string
func (pe *PackExpansion) goString(indent int, field string) string
func (s *Special2) goString(indent int, field string) string
func (pm *PtrMem) goString(indent int, field string) string
func (s *Special) goString(indent int, field string) string
func (n *Nullary) goString(indent int, field string) string
func (pt *PointerType) goString(indent int, field string) string
func (ap *ArgumentPack) goString(indent int, field string) string
func (c *Clone) goString(indent int, field string) string
func (ut *UnnamedType) goString(indent int, field string) string
func (fp *FunctionParam) goString(indent int, field string) string
func (sb *StructuredBindings) goString(indent int, field string) string
func (sp *SizeofPack) goString(indent int, field string) string
func (u *Unary) goString(indent int, field string) string
func (ft *FunctionType) goString(indent int, field string) string
func (c *Cast) goString(indent int, field string) string
func (cl *Closure) goString(indent int, field string) string
func (sa *SizeofArgs) goString(indent int, field string) string
func (da *DefaultArg) goString(indent int, field string) string
func (rt *ReferenceType) goString(indent int, field string) string
func (at *ArrayType) goString(indent int, field string) string
func (el *ExprList) goString(indent int, field string) string
func (tpn *TemplateParamName) goString(indent int, field string) string
func (n *Name) goString(indent int, field string) string
func (le *LambdaExpr) goString(indent int, field string) string
func (t *Typed) goString(indent int, field string) string
func (vq *VendorQualifier) goString(indent int, field string) string
func (ttp *TypeTemplateParam) goString(indent int, field string) string
func (sl *StringLiteral) goString(indent int, field string) string
func (q *Qualified) goString(indent int, field string) string
func (l *Literal) goString(indent int, field string) string
func (t *Template) goString(indent int, field string) string
func (tt *TransformedType) goString(indent int, field string) string
func (nttp *NonTypeTemplateParam) goString(indent int, field string) string
func (tp *TemplateParam) goString(indent int, field string) string
func (n *New) goString(indent int, field string) string
func (st *SuffixType) goString(indent int, field string) string
func (la *LambdaAuto) goString(indent int, field string) string
func (ttp *TemplateTemplateParam) goString(indent int, field string) string
func (pmc *PtrMemCast) goString(indent int, field string) string
func (tpqa *TemplateParamQualifiedArg) goString(indent int, field string) string
func (qs *Qualifiers) goString(indent int, field string) string
func (it *ImaginaryType) goString(indent int, field string) string
func (so *Subobject) goString(indent int, field string) string
func (cttp *ConstrainedTypeTemplateParam) goString(indent int, field string) string
func (q *Qualifier) goString(indent int, field string) string
func (twq *TypeWithQualifiers) goString(indent int, field string) string
func (t *Trinary) goString(indent int, field string) string
func (ct *ComplexType) goString(indent int, field string) string
func (mwq *MethodWithQualifiers) goString(indent int, field string) string
func (tpp *TemplateParamPack) goString(indent int, field string) string
func (bt *BuiltinType) goString(indent int, field string) string
func (b *Binary) goString(indent int, field string) string
func (rt *RvalueReferenceType) goString(indent int, field string) string
hasReturnType returns whether the mangled form of a will have a return type.
func hasReturnType(a AST) bool
identifier parses:
func (rst *rustState) identifier() (int64, string)
implPath parses:
func (rst *rustState) implPath()
isCDtorConversion returns when an AST is a constructor, a destructor, or a conversion operator.
func isCDtorConversion(a AST) bool
isDesignatedInitializer reports whether x is a designated initializer.
func isDesignatedInitializer(x AST) bool
isDigit returns whetner c is a digit for demangling purposes.
func isDigit(c byte) bool
isEmpty returns whether printing a will not print anything.
func (ps *printState) isEmpty(a AST) bool
isLower returns whether c is a lower case letter for demangling purposes.
func isLower(c byte) bool
isMaxLength reports whether an Option holds a maximum length.
func isMaxLength(opt Option) bool
isUpper returns whether c is an upper case letter for demangling purposes.
func isUpper(c byte) bool
Parse a Java resource special-name.
func (st *state) javaResource() AST
localName parses:
func (st *state) localName() (AST, bool)
maxLength returns the maximum length stored in an Option.
func maxLength(opt Option) int
mergeQualifiers merges two qualifier lists into one.
func mergeQualifiers(q1AST AST, q2AST AST) AST
moduleName parses:
func (st *state) moduleName(parent AST) AST
name parses:
func (st *state) name() (AST, bool)
nestedName parses:
func (st *state) nestedName() (AST, bool)
number parses: number ::= [n] <(non-negative decimal integer)>
func (st *state) number() int
oldRustToString demangles a Rust symbol using the old demangling. The second result reports whether this is a valid Rust mangled name.
func oldRustToString(name string, options []Option) (string, bool)
operatorName parses:
operator_name ::= many different two character encodings.
::= cv
func (st *state) operatorName(inExpression bool) (AST, int)
The parenthesize function prints the string for val, wrapped in parentheses if necessary.
func parenthesize(ps *printState, val AST)
parmlist parses:
func (st *state) parmlist(explicitObjectParameter bool) []AST
path parses:
func (rst *rustState) path(needsSeparator bool)
pathStartGenerics is like path but if it sees an I to start generic arguments it won't close them. It reports whether it started generics.
func (rst *rustState) pathStartGenerics() bool
pointerToMemberType parses:
func (st *state) pointerToMemberType(isCast bool) AST
func (c *Cast) prec() precedence
func (b *Binary) prec() precedence
func (bt *BuiltinType) prec() precedence
func (op *Operator) prec() precedence
func (fp *FunctionParam) prec() precedence
func (u *Unary) prec() precedence
func (l *Literal) prec() precedence
func (el *ExprList) prec() precedence
func (n *Name) prec() precedence
func (q *Qualified) prec() precedence
prefix parses:
func (st *state) prefix() AST
func (sb *StructuredBindings) print(ps *printState)
func (t *Trinary) print(ps *printState)
func (c *Constructor) print(ps *printState)
func (pmc *PtrMemCast) print(ps *printState)
func (st *SuffixType) print(ps *printState)
func (qs *Qualifiers) print(ps *printState)
func (op *Operator) print(ps *printState)
func (cttp *ConstrainedTypeTemplateParam) print(ps *printState)
func (n *New) print(ps *printState)
func (tpqa *TemplateParamQualifiedArg) print(ps *printState)
func (n *Nullary) print(ps *printState)
func (la *LambdaAuto) print(ps *printState)
func (tt *TransformedType) print(ps *printState)
func (l *Literal) print(ps *printState)
func (ttp *TemplateTemplateParam) print(ps *printState)
func (tp *TemplateParam) print(ps *printState)
func (vq *VendorQualifier) print(ps *printState)
func (d *Destructor) print(ps *printState)
func (tpp *TemplateParamPack) print(ps *printState)
func (sl *StringLiteral) print(ps *printState)
func (t *Template) print(ps *printState)
func (twq *TypeWithQualifiers) print(ps *printState)
func (eop *ExplicitObjectParameter) print(ps *printState)
func (nttp *NonTypeTemplateParam) print(ps *printState)
func (le *LambdaExpr) print(ps *printState)
func (q *Qualified) print(ps *printState)
func (at *ArrayType) print(ps *printState)
func (dt *Decltype) print(ps *printState)
func (et *ElaboratedType) print(ps *printState)
func (el *ExprList) print(ps *printState)
func (t *Typed) print(ps *printState)
func (so *Subobject) print(ps *printState)
func (ttp *TypeTemplateParam) print(ps *printState)
func (u *Unary) print(ps *printState)
func (nr *NestedRequirement) print(ps *printState)
func (il *InitializerList) print(ps *printState)
func (n *Name) print(ps *printState)
func (gcd *GlobalCDtor) print(ps *printState)
func (rt *ReferenceType) print(ps *printState)
func (ft *FunctionType) print(ps *printState)
func (da *DefaultArg) print(ps *printState)
Print an AST.
func (ps *printState) print(a AST)
func (tr *TypeRequirement) print(ps *printState)
func (b *Binary) print(ps *printState)
func (tpn *TemplateParamName) print(ps *printState)
func (cl *Closure) print(ps *printState)
func (er *ExprRequirement) print(ps *printState)
func (vt *VectorType) print(ps *printState)
func (pt *PointerType) print(ps *printState)
func (mwq *MethodWithQualifiers) print(ps *printState)
func (re *RequiresExpr) print(ps *printState)
func (rt *RvalueReferenceType) print(ps *printState)
func (t *TaggedName) print(ps *printState)
func (ct *ComplexType) print(ps *printState)
func (sa *SizeofArgs) print(ps *printState)
func (fp *FunctionParam) print(ps *printState)
func (ut *UnnamedType) print(ps *printState)
func (q *Qualifier) print(ps *printState)
func (c *Constraint) print(ps *printState)
func (bt *BitIntType) print(ps *printState)
func (f *Fold) print(ps *printState)
func (c *Clone) print(ps *printState)
func (c *Cast) print(ps *printState)
func (f *Friend) print(ps *printState)
func (pe *PackExpansion) print(ps *printState)
func (sp *SizeofPack) print(ps *printState)
func (s *Special) print(ps *printState)
func (bt *BuiltinType) print(ps *printState)
func (it *ImaginaryType) print(ps *printState)
func (me *ModuleEntity) print(ps *printState)
func (pm *PtrMem) print(ps *printState)
func (s *Special2) print(ps *printState)
func (bfp *BinaryFP) print(ps *printState)
func (mn *ModuleName) print(ps *printState)
func (ft *FixedType) print(ps *printState)
func (ap *ArgumentPack) print(ps *printState)
func (ei *EnableIf) print(ps *printState)
printArgs prints the arguments of a function type. It looks at the inner types for spacing.
func (ft *FunctionType) printArgs(ps *printState)
printBase is common print code for types that are printed with a simple suffix.
func printBase(ps *printState, qual AST, base AST)
Print the array dimension.
func (at *ArrayType) printDimension(ps *printState)
func (t *Typed) printInner(ps *printState)
func (pt *PointerType) printInner(ps *printState)
func (cttp *ConstrainedTypeTemplateParam) printInner(ps *printState)
func (rt *ReferenceType) printInner(ps *printState)
func (st *SuffixType) printInner(ps *printState)
func (pm *PtrMem) printInner(ps *printState)
func (ct *ComplexType) printInner(ps *printState)
func (vq *VendorQualifier) printInner(ps *printState)
func (nttp *NonTypeTemplateParam) printInner(ps *printState)
func (tpp *TemplateParamPack) printInner(ps *printState)
func (at *ArrayType) printInner(ps *printState)
func (ft *FunctionType) printInner(ps *printState)
func (rt *RvalueReferenceType) printInner(ps *printState)
Print qualifiers as an inner type by just printing the qualifiers.
func (twq *TypeWithQualifiers) printInner(ps *printState)
func (it *ImaginaryType) printInner(ps *printState)
func (vt *VectorType) printInner(ps *printState)
Print the inner types.
func (ps *printState) printInner(prefixOnly bool) []AST
func (mwq *MethodWithQualifiers) printInner(ps *printState)
printList prints a list of AST values separated by commas, optionally skipping some.
func (ps *printState) printList(args []AST, skip func(AST) bool)
Print the most recent inner type. If save is not nil, only print prefixes.
func (ps *printState) printOneInner(save *[]AST)
func (cl *Closure) printTypes(ps *printState)
refQualifier parses:
func (st *state) refQualifier() string
requiresExpr parses:
func (st *state) requiresExpr() AST
rustToString demangles a Rust symbol.
func rustToString(name string, options []Option) (ret string, err error)
seqID parses:
func (st *state) seqID(eofOK bool) int
setTemplate sets the Template field of any TemplateParam's in a. This handles the forward referencing template parameters found in cast operators.
func (st *state) setTemplate(a AST, tmpl *Template)
simplify replaces template parameters with their expansions, and merges qualifiers.
func simplify(a AST) AST
simplifyOne simplifies a single AST. It returns nil if there is nothing to do.
func simplifyOne(a AST) AST
sourceName parses:
func (st *state) sourceName() AST
specialName parses:
func (st *state) specialName() AST
startScope starts a scope. This is used to decide whether we need to parenthesize an expression using > or >>.
func (ps *printState) startScope(b byte)
subobject parses:
func (st *state) subobject() AST
substitution parses:
func (st *state) substitution(forPrefix bool) AST
symbolName parses:
func (rst *rustState) symbolName()
taggedName parses:
func (st *state) taggedName(a AST) AST
templateArg parses:
func (st *state) templateArg(prev []AST) AST
templateArgs parses:
func (st *state) templateArgs() []AST
templateParam parses:
func (st *state) templateParam() AST
templateParamDecl parses:
func (st *state) templateParamDecl() (AST, AST)
undisambiguatedIdentifier parses:
func (rst *rustState) undisambiguatedIdentifier() (id string, isPunycode bool)
unnamedTypeName parses:
func (st *state) unnamedTypeName() AST
unqualifiedName parses:
func (st *state) unqualifiedName(module AST) (r AST, isCast bool)
unresolvedName parses:
func (st *state) unresolvedName() AST
vectorType parses:
func (st *state) vectorType(isCast bool) AST
writeByte writes a byte to the buffer.
func (rst *rustState) writeByte(c byte)
writeByte adds a byte to the string being printed.
func (ps *printState) writeByte(b byte)
writeLifetime writes out a lifetime binding.
func (rst *rustState) writeLifetime(lifetime int64)
writeString writes a string to the buffer.
func (rst *rustState) writeString(s string)
writeString adds a string to the string being printed.
func (ps *printState) writeString(s string)
Generated with Arrow