MCPcopy Create free account
hub / github.com/llir/llvm / headerString

Function headerString

ir/func.go:213–284  ·  view source on GitHub ↗

### [ Helper functions ] #################################################### headerString returns the string representation of the function header.

(f *Func)

Source from the content-addressed store, hash-verified

211
212// headerString returns the string representation of the function header.
213func 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 }

Callers 1

LLStringMethod · 0.85

Calls 7

callingConvStringFunction · 0.85
FprintfMethod · 0.80
quoteFunction · 0.70
IdentMethod · 0.65
LLStringMethod · 0.65
NameMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…