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.CallExprLLVMStyle 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 LLVMStyleThe NoClones option disables inclusion of clone suffixes. NoParams implies NoClones.
const NoClonesThe NoEnclosingParams option disables demangling of the function parameter types of the enclosing function when demangling a local name defined within a function.
const NoEnclosingParamsThe 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 = iotaThe 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 NoRustThe NoTemplateParams option disables demangling of template parameters. This applies to both C++ and Rust.
const NoTemplateParamsThe Verbose option turns on more verbose demangling.
const VerboseBuiltin 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 = iotamaxLengthMask is a mask for the maxLength value.
const maxLengthMask = *ast.BinaryExprmaxLengthShift is how we shift the MaxLength value.
const maxLengthShift = 16const notForLocalNameThe 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 precAddThe precedence values, in order from high to low.
const precAndThe precedence values, in order from high to low.
const precAssignThe precedence values, in order from high to low.
const precCastThe precedence values, in order from high to low.
const precCommaThe precedence values, in order from high to low.
const precCondThe precedence values, in order from high to low.
const precDefaultThe precedence values, in order from high to low.
const precEqualThe precedence values, in order from high to low.
const precLogicalAndThe precedence values, in order from high to low.
const precLogicalOrThe precedence values, in order from high to low.
const precMulThe precedence values, in order from high to low.
const precOrThe precedence values, in order from high to low.
const precPostfixThe precedence values, in order from high to low.
const precPrimary precedence = iotaThe precedence values, in order from high to low.
const precPtrMemThe precedence values, in order from high to low.
const precRelThe precedence values, in order from high to low.
const precShiftThe precedence values, in order from high to low.
const precSpaceshipThe precedence values, in order from high to low.
const precUnaryThe precedence values, in order from high to low.
const precXorqualifiers 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 inttype forLocalNameType intprecedence is used for operator precedence. This is used to avoid unnecessary parentheses when printing expressions in the LLVM style.
type precedence intsubstitutions is the list of substitution candidates that may appear later in the string.
type substitutions []ASTAST 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) stringfunc (sb *StructuredBindings) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (op *Operator) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (eop *ExplicitObjectParameter) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (c *Constructor) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (dt *Decltype) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (d *Destructor) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (et *ElaboratedType) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (vt *VectorType) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (gcd *GlobalCDtor) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (bt *BitIntType) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (t *TaggedName) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (bfp *BinaryFP) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (pe *PackExpansion) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (ft *FixedType) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (pm *PtrMem) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (ap *ArgumentPack) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (nr *NestedRequirement) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (sp *SizeofPack) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (fp *FunctionParam) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (tr *TypeRequirement) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (ft *FunctionType) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (sa *SizeofArgs) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (er *ExprRequirement) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (tpn *TemplateParamName) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (at *ArrayType) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (re *RequiresExpr) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (ttp *TypeTemplateParam) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (vq *VendorQualifier) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (c *Constraint) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (nttp *NonTypeTemplateParam) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (tt *TransformedType) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (ttp *TemplateTemplateParam) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (st *SuffixType) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (cttp *ConstrainedTypeTemplateParam) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (it *ImaginaryType) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (f *Friend) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (tpp *TemplateParamPack) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (ct *ComplexType) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (c *Cast) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (rt *RvalueReferenceType) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (n *Nullary) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (rt *ReferenceType) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (me *ModuleEntity) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (u *Unary) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (pt *PointerType) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (b *Binary) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (mn *ModuleName) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (bt *BuiltinType) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (t *Trinary) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (mwq *MethodWithQualifiers) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (f *Fold) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (twq *TypeWithQualifiers) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (ei *EnableIf) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (so *Subobject) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (q *Qualifier) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (qs *Qualifiers) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (pmc *PtrMemCast) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (tpqa *TemplateParamQualifiedArg) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (n *New) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (la *LambdaAuto) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (tp *TemplateParam) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (s *Special2) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (l *Literal) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (t *Template) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (s *Special) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (sl *StringLiteral) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (q *Qualified) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (le *LambdaExpr) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (c *Clone) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (t *Typed) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (el *ExprList) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (n *Name) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (il *InitializerList) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (da *DefaultArg) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (ut *UnnamedType) Copy(fn func(AST) AST, skip func(AST) bool) ASTfunc (cl *Closure) Copy(fn func(AST) AST, skip func(AST) bool) ASTError implements the builtin error interface for demangleErr.
func (de demangleErr) Error() stringFilter 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) stringfunc (tt *TransformedType) GoString() stringfunc (f *Fold) GoString() stringfunc (op *Operator) GoString() stringfunc (eop *ExplicitObjectParameter) GoString() stringfunc (c *Constructor) GoString() stringfunc (dt *Decltype) GoString() stringfunc (et *ElaboratedType) GoString() stringfunc (d *Destructor) GoString() stringfunc (vt *VectorType) GoString() stringfunc (gcd *GlobalCDtor) GoString() stringfunc (cl *Closure) GoString() stringfunc (sb *StructuredBindings) GoString() stringfunc (bt *BitIntType) GoString() stringfunc (t *TaggedName) GoString() stringfunc (bfp *BinaryFP) GoString() stringfunc (ft *FixedType) GoString() stringfunc (pe *PackExpansion) GoString() stringfunc (pm *PtrMem) GoString() stringfunc (da *DefaultArg) GoString() stringfunc (ut *UnnamedType) GoString() stringfunc (nr *NestedRequirement) GoString() stringfunc (il *InitializerList) GoString() stringfunc (ap *ArgumentPack) GoString() stringfunc (fp *FunctionParam) GoString() stringfunc (tr *TypeRequirement) GoString() stringfunc (sp *SizeofPack) GoString() stringfunc (ft *FunctionType) GoString() stringfunc (n *Name) GoString() stringfunc (el *ExprList) GoString() stringfunc (er *ExprRequirement) GoString() stringfunc (sa *SizeofArgs) GoString() stringfunc (le *LambdaExpr) GoString() stringfunc (at *ArrayType) GoString() stringfunc (re *RequiresExpr) GoString() stringfunc (t *Typed) GoString() stringfunc (tpn *TemplateParamName) GoString() stringfunc (ttp *TypeTemplateParam) GoString() stringfunc (vq *VendorQualifier) GoString() stringfunc (c *Clone) GoString() stringfunc (q *Qualified) GoString() stringfunc (sl *StringLiteral) GoString() stringfunc (c *Constraint) GoString() stringfunc (nttp *NonTypeTemplateParam) GoString() stringfunc (st *SuffixType) GoString() stringfunc (s *Special) GoString() stringfunc (t *Template) GoString() stringfunc (l *Literal) GoString() stringfunc (ttp *TemplateTemplateParam) GoString() stringfunc (it *ImaginaryType) GoString() stringfunc (f *Friend) GoString() stringfunc (tp *TemplateParam) GoString() stringfunc (cttp *ConstrainedTypeTemplateParam) GoString() stringfunc (n *New) GoString() stringfunc (ct *ComplexType) GoString() stringfunc (tpp *TemplateParamPack) GoString() stringfunc (la *LambdaAuto) GoString() stringfunc (rt *RvalueReferenceType) GoString() stringfunc (c *Cast) GoString() stringfunc (me *ModuleEntity) GoString() stringfunc (s *Special2) GoString() stringfunc (tpqa *TemplateParamQualifiedArg) GoString() stringfunc (pmc *PtrMemCast) GoString() stringfunc (rt *ReferenceType) GoString() stringfunc (n *Nullary) GoString() stringfunc (pt *PointerType) GoString() stringfunc (qs *Qualifiers) GoString() stringfunc (u *Unary) GoString() stringfunc (so *Subobject) GoString() stringfunc (mn *ModuleName) GoString() stringfunc (b *Binary) GoString() stringfunc (q *Qualifier) GoString() stringfunc (bt *BuiltinType) GoString() stringfunc (t *Trinary) GoString() stringfunc (mwq *MethodWithQualifiers) GoString() stringfunc (ei *EnableIf) GoString() stringfunc (twq *TypeWithQualifiers) GoString() stringMaxLength 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) OptionToAST 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) erroradvance 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) ASTbackref parses:
func (rst *rustState) backref(demangle func())bareFunctionType parses:
func (st *state) bareFunctionType(hasReturnType bool, explicitObjectParameter bool) ASTbase62Number parses:
func (rst *rustState) base62Number() int64baseUnresolvedName parses:
func (st *state) baseUnresolvedName() ASTbasicType 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) ASTclosureTypeName parses:
func (st *state) closureTypeName() ASTcompactNumber parses:
func (st *state) compactNumber() intconstraintExpr parses a constraint expression. This is just a regular expression, but template parameters are handled specially.
func (st *state) constraintExpr() ASTcopy returns a copy of the current state.
func (st *state) copy() *statecvQualifiers parses:
func (st *state) cvQualifiers() ASTfunc (rst *rustState) decimalNumber() intdemangleCastTemplateArgs 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) ASTdemangleConst parses:
func (rst *rustState) demangleConst()demangleType parses:
func (rst *rustState) demangleType()demangleType parses:
func (st *state) demangleType(isCast bool) ASTdisambiguator parses an optional:
func (rst *rustState) disambiguator() int64discriminator parses:
func (st *state) discriminator(a AST) ASTThe 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) ASTendScope 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) stringexprList parses a sequence of expressions up to a terminating character.
func (st *state) exprList(stop byte) ASTexprPrimary parses:
func (st *state) exprPrimary() ASTexpression parses:
func (st *state) expression() ASTfail 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) *ArgumentPackfnSig parses:
func (rst *rustState) fnSig()functionType parses:
func (st *state) functionType() ASTgenericArg 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) stringfunc (il *InitializerList) goString(indent int, field string) stringfunc (op *Operator) goString(indent int, field string) stringfunc (eop *ExplicitObjectParameter) goString(indent int, field string) stringfunc (dt *Decltype) goString(indent int, field string) stringfunc (c *Constructor) goString(indent int, field string) stringfunc (nr *NestedRequirement) goString(indent int, field string) stringfunc (et *ElaboratedType) goString(indent int, field string) stringfunc (d *Destructor) goString(indent int, field string) stringfunc (tr *TypeRequirement) goString(indent int, field string) stringfunc (vt *VectorType) goString(indent int, field string) stringfunc (er *ExprRequirement) goString(indent int, field string) stringfunc (re *RequiresExpr) goString(indent int, field string) stringfunc (gcd *GlobalCDtor) goString(indent int, field string) stringfunc (c *Constraint) goString(indent int, field string) stringfunc (bt *BitIntType) goString(indent int, field string) stringfunc (f *Friend) goString(indent int, field string) stringfunc (bfp *BinaryFP) goString(indent int, field string) stringfunc (t *TaggedName) goString(indent int, field string) stringfunc (me *ModuleEntity) goString(indent int, field string) stringfunc (mn *ModuleName) goString(indent int, field string) stringfunc (ft *FixedType) goString(indent int, field string) stringfunc (ei *EnableIf) goString(indent int, field string) stringfunc (pe *PackExpansion) goString(indent int, field string) stringfunc (s *Special2) goString(indent int, field string) stringfunc (pm *PtrMem) goString(indent int, field string) stringfunc (s *Special) goString(indent int, field string) stringfunc (n *Nullary) goString(indent int, field string) stringfunc (pt *PointerType) goString(indent int, field string) stringfunc (ap *ArgumentPack) goString(indent int, field string) stringfunc (c *Clone) goString(indent int, field string) stringfunc (ut *UnnamedType) goString(indent int, field string) stringfunc (fp *FunctionParam) goString(indent int, field string) stringfunc (sb *StructuredBindings) goString(indent int, field string) stringfunc (sp *SizeofPack) goString(indent int, field string) stringfunc (u *Unary) goString(indent int, field string) stringfunc (ft *FunctionType) goString(indent int, field string) stringfunc (c *Cast) goString(indent int, field string) stringfunc (cl *Closure) goString(indent int, field string) stringfunc (sa *SizeofArgs) goString(indent int, field string) stringfunc (da *DefaultArg) goString(indent int, field string) stringfunc (rt *ReferenceType) goString(indent int, field string) stringfunc (at *ArrayType) goString(indent int, field string) stringfunc (el *ExprList) goString(indent int, field string) stringfunc (tpn *TemplateParamName) goString(indent int, field string) stringfunc (n *Name) goString(indent int, field string) stringfunc (le *LambdaExpr) goString(indent int, field string) stringfunc (t *Typed) goString(indent int, field string) stringfunc (vq *VendorQualifier) goString(indent int, field string) stringfunc (ttp *TypeTemplateParam) goString(indent int, field string) stringfunc (sl *StringLiteral) goString(indent int, field string) stringfunc (q *Qualified) goString(indent int, field string) stringfunc (l *Literal) goString(indent int, field string) stringfunc (t *Template) goString(indent int, field string) stringfunc (tt *TransformedType) goString(indent int, field string) stringfunc (nttp *NonTypeTemplateParam) goString(indent int, field string) stringfunc (tp *TemplateParam) goString(indent int, field string) stringfunc (n *New) goString(indent int, field string) stringfunc (st *SuffixType) goString(indent int, field string) stringfunc (la *LambdaAuto) goString(indent int, field string) stringfunc (ttp *TemplateTemplateParam) goString(indent int, field string) stringfunc (pmc *PtrMemCast) goString(indent int, field string) stringfunc (tpqa *TemplateParamQualifiedArg) goString(indent int, field string) stringfunc (qs *Qualifiers) goString(indent int, field string) stringfunc (it *ImaginaryType) goString(indent int, field string) stringfunc (so *Subobject) goString(indent int, field string) stringfunc (cttp *ConstrainedTypeTemplateParam) goString(indent int, field string) stringfunc (q *Qualifier) goString(indent int, field string) stringfunc (twq *TypeWithQualifiers) goString(indent int, field string) stringfunc (t *Trinary) goString(indent int, field string) stringfunc (ct *ComplexType) goString(indent int, field string) stringfunc (mwq *MethodWithQualifiers) goString(indent int, field string) stringfunc (tpp *TemplateParamPack) goString(indent int, field string) stringfunc (bt *BuiltinType) goString(indent int, field string) stringfunc (b *Binary) goString(indent int, field string) stringfunc (rt *RvalueReferenceType) goString(indent int, field string) stringhasReturnType returns whether the mangled form of a will have a return type.
func hasReturnType(a AST) boolidentifier 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) boolisDesignatedInitializer reports whether x is a designated initializer.
func isDesignatedInitializer(x AST) boolisDigit returns whetner c is a digit for demangling purposes.
func isDigit(c byte) boolisEmpty returns whether printing a will not print anything.
func (ps *printState) isEmpty(a AST) boolisLower returns whether c is a lower case letter for demangling purposes.
func isLower(c byte) boolisMaxLength reports whether an Option holds a maximum length.
func isMaxLength(opt Option) boolisUpper returns whether c is an upper case letter for demangling purposes.
func isUpper(c byte) boolParse a Java resource special-name.
func (st *state) javaResource() ASTlocalName parses:
func (st *state) localName() (AST, bool)maxLength returns the maximum length stored in an Option.
func maxLength(opt Option) intmergeQualifiers merges two qualifier lists into one.
func mergeQualifiers(q1AST AST, q2AST AST) ASTmoduleName parses:
func (st *state) moduleName(parent AST) ASTname 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() intoldRustToString 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) []ASTpath 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() boolpointerToMemberType parses:
func (st *state) pointerToMemberType(isCast bool) ASTfunc (c *Cast) prec() precedencefunc (b *Binary) prec() precedencefunc (bt *BuiltinType) prec() precedencefunc (op *Operator) prec() precedencefunc (fp *FunctionParam) prec() precedencefunc (u *Unary) prec() precedencefunc (l *Literal) prec() precedencefunc (el *ExprList) prec() precedencefunc (n *Name) prec() precedencefunc (q *Qualified) prec() precedenceprefix parses:
func (st *state) prefix() ASTfunc (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) []ASTfunc (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() stringrequiresExpr parses:
func (st *state) requiresExpr() ASTrustToString demangles a Rust symbol.
func rustToString(name string, options []Option) (ret string, err error)seqID parses:
func (st *state) seqID(eofOK bool) intsetTemplate 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) ASTsimplifyOne simplifies a single AST. It returns nil if there is nothing to do.
func simplifyOne(a AST) ASTsourceName parses:
func (st *state) sourceName() ASTspecialName parses:
func (st *state) specialName() ASTstartScope 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() ASTsubstitution parses:
func (st *state) substitution(forPrefix bool) ASTsymbolName parses:
func (rst *rustState) symbolName()taggedName parses:
func (st *state) taggedName(a AST) ASTtemplateArg parses:
func (st *state) templateArg(prev []AST) ASTtemplateArgs parses:
func (st *state) templateArgs() []ASTtemplateParam parses:
func (st *state) templateParam() ASTtemplateParamDecl parses:
func (st *state) templateParamDecl() (AST, AST)undisambiguatedIdentifier parses:
func (rst *rustState) undisambiguatedIdentifier() (id string, isPunycode bool)unnamedTypeName parses:
func (st *state) unnamedTypeName() ASTunqualifiedName parses:
func (st *state) unqualifiedName(module AST) (r AST, isCast bool)unresolvedName parses:
func (st *state) unresolvedName() ASTvectorType parses:
func (st *state) vectorType(isCast bool) ASTwriteByte 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