...

Package logopt

import "cmd/compile/internal/logopt"
Overview
Index

Overview ▾

Constants

const (
    None  logFormat = iota
    Json0           // version 0 for LSP 3.14, 3.15; future versions of LSP may change the format and the compiler may need to support both as clients are updated.
)

Variables

var Format = None

func Enabled

func Enabled() bool

Enabled returns whether optimization logging is enabled.

func FlushLoggedOpts

func FlushLoggedOpts(ctxt *obj.Link, slashPkgPath string)

FlushLoggedOpts flushes all the accumulated optimization log entries.

func LogJsonOption

func LogJsonOption(flagValue string)

LogJsonOption parses and validates the version,directory value attached to the -json compiler flag.

func LogOpt

func LogOpt(pos src.XPos, what, pass, funcName string, args ...interface{})

LogOpt logs information about a (usually missed) optimization performed by the compiler. Pos is the source position (including inlining), what is the message, pass is which pass created the message, funcName is the name of the function.

func LogOptRange

func LogOptRange(pos, lastPos src.XPos, what, pass, funcName string, args ...interface{})

LogOptRange is the same as LogOpt, but includes the ability to express a range of positions, not just a point.

type Diagnostic

Diagnostic defined:

type Diagnostic struct {

    /*Range defined:
     * The range at which the message applies
     */
    Range Range `json:"range"`

    /*Severity defined:
     * The diagnostic's severity. Can be omitted. If omitted it is up to the
     * client to interpret diagnostics as error, warning, info or hint.
     */
    Severity DiagnosticSeverity `json:"severity,omitempty"` // always SeverityInformation for optimizer logging.

    /*Code defined:
     * The diagnostic's code, which usually appear in the user interface.
     */
    Code string `json:"code,omitempty"` // LSP uses 'number | string' = gopls interface{}, but only string here, e.g. "boundsCheck", "nilcheck", etc.

    /*Source defined:
     * A human-readable string describing the source of this
     * diagnostic, e.g. 'typescript' or 'super lint'. It usually
     * appears in the user interface.
     */
    Source string `json:"source,omitempty"` // "go compiler"

    /*Message defined:
     * The diagnostic's message. It usually appears in the user interface
     */
    Message string `json:"message"` // sometimes used, provides additional information.

    /*Tags defined:
     * Additional metadata about the diagnostic.
     */
    Tags []DiagnosticTag `json:"tags,omitempty"` // always empty for logging optimizations.

    /*RelatedInformation defined:
     * An array of related diagnostic information, e.g. when symbol-names within
     * a scope collide all definitions can be marked via this property.
     */
    RelatedInformation []DiagnosticRelatedInformation `json:"relatedInformation,omitempty"`
}

type DiagnosticRelatedInformation

DiagnosticRelatedInformation defined: * Represents a related message and source code location for a diagnostic. This should be * used to point to code locations that cause or related to a diagnostics, e.g when duplicating * a symbol in a scope.

type DiagnosticRelatedInformation struct {

    /*Location defined:
     * The location of this related diagnostic information.
     */
    Location Location `json:"location"`

    /*Message defined:
     * The message of this related diagnostic information.
     */
    Message string `json:"message"`
}

type DiagnosticSeverity

DiagnosticSeverity defines constants

type DiagnosticSeverity uint
const (
    /*SeverityInformation defined:
     * Reports an information.
     */
    SeverityInformation DiagnosticSeverity = 3
)

type DiagnosticTag

DiagnosticTag defines constants

type DiagnosticTag uint

type DocumentURI

type DocumentURI string

type Location

A Location represents a location inside a resource, such as a line inside a text file.

type Location struct {
    // URI is
    URI DocumentURI `json:"uri"`

    // Range is
    Range Range `json:"range"`
}

type LoggedOpt

A LoggedOpt is what the compiler produces and accumulates, to be converted to JSON for human or IDE consumption.

type LoggedOpt struct {
    // contains filtered or unexported fields
}

func NewLoggedOpt

func NewLoggedOpt(pos, lastPos src.XPos, what, pass, funcName string, args ...interface{}) *LoggedOpt

NewLoggedOpt allocates a new LoggedOpt, to later be passed to either NewLoggedOpt or LogOpt as "args". Pos is the source position (including inlining), what is the message, pass is which pass created the message, funcName is the name of the function A typical use for this to accumulate an explanation for a missed optimization, for example, why did something escape?

type Position

type Position struct {
    Line      uint `json:"line"`      // gopls uses float64, but json output is the same for integers
    Character uint `json:"character"` // gopls uses float64, but json output is the same for integers
}

type Range

A Range in a text document expressed as (zero-based) start and end positions. A range is comparable to a selection in an editor. Therefore the end position is exclusive. If you want to specify a range that contains a line including the line ending character(s) then use an end position denoting the start of the next line.

type Range struct {
    /*Start defined:
     * The range's start position
     */
    Start Position `json:"start"`

    /*End defined:
     * The range's end position
     */
    End Position `json:"end"` // exclusive
}

type VersionHeader

type VersionHeader struct {
    Version   int    `json:"version"`
    Package   string `json:"package"`
    Goos      string `json:"goos"`
    Goarch    string `json:"goarch"`
    GcVersion string `json:"gc_version"`
    File      string `json:"file,omitempty"` // LSP requires an enclosing resource, i.e., a file
}