### [ Helper functions ] #################################################### headerString returns the string representation of the function header.
(f *Func)
| 211 | |
| 212 | // headerString returns the string representation of the function header. |
| 213 | func headerString(f *Func) string { |
| 214 | // (Linkage | ExternLinkage)? Preemptionopt Visibilityopt DLLStorageClassopt CallingConvopt ReturnAttrs=ReturnAttribute* RetType=Type Name=GlobalIdent '(' Params ')' UnnamedAddropt AddrSpaceopt FuncAttrs=FuncAttribute* Sectionopt Partitionopt Comdatopt Alignopt GCopt Prefixopt Prologueopt Personalityopt |
| 215 | buf := &strings.Builder{} |
| 216 | if f.Preemption != enum.PreemptionNone { |
| 217 | fmt.Fprintf(buf, " %s", f.Preemption) |
| 218 | } |
| 219 | if f.Visibility != enum.VisibilityNone { |
| 220 | fmt.Fprintf(buf, " %s", f.Visibility) |
| 221 | } |
| 222 | if f.DLLStorageClass != enum.DLLStorageClassNone { |
| 223 | fmt.Fprintf(buf, " %s", f.DLLStorageClass) |
| 224 | } |
| 225 | if f.CallingConv != enum.CallingConvNone { |
| 226 | fmt.Fprintf(buf, " %s", callingConvString(f.CallingConv)) |
| 227 | } |
| 228 | for _, attr := range f.ReturnAttrs { |
| 229 | fmt.Fprintf(buf, " %s", attr) |
| 230 | } |
| 231 | fmt.Fprintf(buf, " %s", f.Sig.RetType) |
| 232 | fmt.Fprintf(buf, " %s(", f.Ident()) |
| 233 | for i, param := range f.Params { |
| 234 | if i != 0 { |
| 235 | buf.WriteString(", ") |
| 236 | } |
| 237 | buf.WriteString(param.LLString()) |
| 238 | } |
| 239 | if f.Sig.Variadic { |
| 240 | if len(f.Params) > 0 { |
| 241 | buf.WriteString(", ") |
| 242 | } |
| 243 | buf.WriteString("...") |
| 244 | } |
| 245 | buf.WriteString(")") |
| 246 | if f.UnnamedAddr != enum.UnnamedAddrNone { |
| 247 | fmt.Fprintf(buf, " %s", f.UnnamedAddr) |
| 248 | } |
| 249 | if f.AddrSpace != 0 { |
| 250 | fmt.Fprintf(buf, " %s", f.AddrSpace) |
| 251 | } |
| 252 | for _, attr := range f.FuncAttrs { |
| 253 | fmt.Fprintf(buf, " %s", attr) |
| 254 | } |
| 255 | if len(f.Section) > 0 { |
| 256 | fmt.Fprintf(buf, " section %s", quote(f.Section)) |
| 257 | } |
| 258 | if len(f.Partition) > 0 { |
| 259 | fmt.Fprintf(buf, " partition %s", quote(f.Partition)) |
| 260 | } |
| 261 | if f.Comdat != nil { |
| 262 | if f.Comdat.Name == f.Name() { |
| 263 | buf.WriteString(" comdat") |
| 264 | } else { |
| 265 | fmt.Fprintf(buf, " %s", f.Comdat) |
| 266 | } |
| 267 | } |
| 268 | if f.Align != 0 { |
| 269 | fmt.Fprintf(buf, " %s", f.Align) |
| 270 | } |
no test coverage detected
searching dependent graphs…