all: use "reports whether" consistently in the few places that didn't

Go documentation style for boolean funcs is to say:

    // Foo reports whether ...
    func Foo() bool

(rather than "returns true if")

This CL also replaces 4 uses of "iff" with the same "reports whether"
wording, which doesn't lose any meaning, and will prevent people from
sending typo fixes when they don't realize it's "if and only if". In
the past I think we've had the typo CLs updated to just say "reports
whether". So do them all at once.

(Inspired by the addition of another "returns true if" in CL 146938
in fd_plan9.go)

Created with:

$ perl -i -npe 's/returns true if/reports whether/' $(git grep -l "returns true iff" | grep -v vendor)
$ perl -i -npe 's/returns true if/reports whether/' $(git grep -l "returns true if" | grep -v vendor)

Change-Id: Ided502237f5ab0d25cb625dbab12529c361a8b9f
Reviewed-on: https://go-review.googlesource.com/c/147037
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Brad Fitzpatrick 2018-11-02 15:18:43 +00:00
parent e25823edce
commit 3813edf26e
47 changed files with 61 additions and 61 deletions

View file

@ -139,7 +139,7 @@ func (in *Input) Text() string {
return in.text
}
// hash processes a # preprocessor directive. It returns true iff it completes.
// hash processes a # preprocessor directive. It reports whether it completes.
func (in *Input) hash() bool {
// We have a '#'; it must be followed by a known word (define, include, etc.).
tok := in.Stack.Next()

View file

@ -314,7 +314,7 @@ func transformclosure(xfunc *Node) {
lineno = lno
}
// hasemptycvars returns true iff closure clo has an
// hasemptycvars reports whether closure clo has an
// empty list of captured vars.
func hasemptycvars(clo *Node) bool {
xfunc := clo.Func.Closure

View file

@ -929,7 +929,7 @@ type nodeQueue struct {
head, tail int
}
// empty returns true if q contains no Nodes.
// empty reports whether q contains no Nodes.
func (q *nodeQueue) empty() bool {
return q.head == q.tail
}

View file

@ -112,7 +112,7 @@ type Logger interface {
// Logf logs a message from the compiler.
Logf(string, ...interface{})
// Log returns true if logging is not a no-op
// Log reports whether logging is not a no-op
// some logging calls account for more than a few heap allocations.
Log() bool

View file

@ -790,7 +790,7 @@ func (e *pendingEntry) clear() {
}
}
// canMerge returns true if the location description for new is the same as
// canMerge reports whether the location description for new is the same as
// pending.
func canMerge(pending, new VarLoc) bool {
if pending.absent() && new.absent() {

View file

@ -621,7 +621,7 @@ func (f *Func) invalidateCFG() {
f.cachedLoopnest = nil
}
// DebugHashMatch returns true if environment variable evname
// DebugHashMatch reports whether environment variable evname
// 1) is empty (this is a special more-quickly implemented case of 3)
// 2) is "y" or "Y"
// 3) is a suffix of the sha1 hash of name

View file

@ -529,7 +529,7 @@ var genericOps = []opData{
{name: "AtomicAdd64", argLength: 3, typ: "(UInt64,Mem)", hasSideEffects: true}, // Do *arg0 += arg1. arg2=memory. Returns sum and new memory.
{name: "AtomicCompareAndSwap32", argLength: 4, typ: "(Bool,Mem)", hasSideEffects: true}, // if *arg0==arg1, then set *arg0=arg2. Returns true if store happens and new memory.
{name: "AtomicCompareAndSwap64", argLength: 4, typ: "(Bool,Mem)", hasSideEffects: true}, // if *arg0==arg1, then set *arg0=arg2. Returns true if store happens and new memory.
{name: "AtomicCompareAndSwapRel32", argLength: 4, typ: "(Bool,Mem)", hasSideEffects: true}, // if *arg0==arg1, then set *arg0=arg2. Lock release, returns true if store happens and new memory.
{name: "AtomicCompareAndSwapRel32", argLength: 4, typ: "(Bool,Mem)", hasSideEffects: true}, // if *arg0==arg1, then set *arg0=arg2. Lock release, reports whether store happens and new memory.
{name: "AtomicAnd8", argLength: 3, typ: "Mem", hasSideEffects: true}, // *arg0 &= arg1. arg2=memory. Returns memory.
{name: "AtomicOr8", argLength: 3, typ: "Mem", hasSideEffects: true}, // *arg0 |= arg1. arg2=memory. Returns memory.

View file

@ -6,7 +6,7 @@
// This program generates Go code that applies rewrite rules to a Value.
// The generated code implements a function of type func (v *Value) bool
// which returns true iff if did something.
// which reports whether if did something.
// Ideas stolen from Swift: http://www.hpl.hp.com/techreports/Compaq-DEC/WRL-2000-2.html
package main
@ -386,7 +386,7 @@ func genRules(arch arch) {
}
}
// genMatch returns true if the match can fail.
// genMatch reports whether the match can fail.
func genMatch(w io.Writer, arch arch, match string, loc string) bool {
return genMatch0(w, arch, match, "v", map[string]struct{}{}, true, loc)
}
@ -623,7 +623,7 @@ outer:
return r
}
// isBlock returns true if this op is a block opcode.
// isBlock reports whether this op is a block opcode.
func isBlock(name string, arch arch) bool {
for _, b := range genericBlocks {
if b.name == name {
@ -768,7 +768,7 @@ func typeName(typ string) string {
}
}
// unbalanced returns true if there aren't the same number of ( and ) in the string.
// unbalanced reports whether there aren't the same number of ( and ) in the string.
func unbalanced(s string) bool {
var left, right int
for _, c := range s {

View file

@ -781,7 +781,7 @@ func (po *poset) DotDump(fn string, title string) error {
return nil
}
// Ordered returns true if n1<n2. It returns false either when it is
// Ordered reports whether n1<n2. It returns false either when it is
// certain that n1<n2 is false, or if there is not enough information
// to tell.
// Complexity is O(n).
@ -799,7 +799,7 @@ func (po *poset) Ordered(n1, n2 *Value) bool {
return i1 != i2 && po.dominates(i1, i2, true)
}
// Ordered returns true if n1<=n2. It returns false either when it is
// Ordered reports whether n1<=n2. It returns false either when it is
// certain that n1<=n2 is false, or if there is not enough information
// to tell.
// Complexity is O(n).
@ -818,7 +818,7 @@ func (po *poset) OrderedOrEqual(n1, n2 *Value) bool {
(po.dominates(i2, i1, false) && !po.dominates(i2, i1, true))
}
// Equal returns true if n1==n2. It returns false either when it is
// Equal reports whether n1==n2. It returns false either when it is
// certain that n1==n2 is false, or if there is not enough information
// to tell.
// Complexity is O(1).
@ -832,7 +832,7 @@ func (po *poset) Equal(n1, n2 *Value) bool {
return f1 && f2 && i1 == i2
}
// NonEqual returns true if n1!=n2. It returns false either when it is
// NonEqual reports whether n1!=n2. It returns false either when it is
// certain that n1!=n2 is false, or if there is not enough information
// to tell.
// Complexity is O(n) (because it internally calls Ordered to see if we

View file

@ -485,7 +485,7 @@ func auxTo64F(i int64) float64 {
return math.Float64frombits(uint64(i))
}
// uaddOvf returns true if unsigned a+b would overflow.
// uaddOvf reports whether unsigned a+b would overflow.
func uaddOvf(a, b int64) bool {
return uint64(a)+uint64(b) < uint64(a)
}

View file

@ -94,7 +94,7 @@ func trim(f *Func) {
}
}
// emptyBlock returns true if the block does not contain actual
// emptyBlock reports whether the block does not contain actual
// instructions
func emptyBlock(b *Block) bool {
for _, v := range b.Values {
@ -105,7 +105,7 @@ func emptyBlock(b *Block) bool {
return true
}
// trimmableBlock returns true if the block can be trimmed from the CFG,
// trimmableBlock reports whether the block can be trimmed from the CFG,
// subject to the following criteria:
// - it should not be the first block
// - it should be BlockPlain

View file

@ -478,7 +478,7 @@ func newPkgDot(pos token.Pos, pkg, name string) ast.Expr {
}
// renameTop renames all references to the top-level name old.
// It returns true if it makes any changes.
// It reports whether it makes any changes.
func renameTop(f *ast.File, old, new string) bool {
var fixed bool

View file

@ -967,7 +967,7 @@ Outer:
}
}
// HasChildren returns true if 'die' uses an abbrev that supports children.
// HasChildren reports whether 'die' uses an abbrev that supports children.
func HasChildren(die *DWDie) bool {
return abbrevs[die.Abbrev].children != 0
}

View file

@ -508,7 +508,7 @@ func (task *taskDesc) overlappingGCDuration(evs []*trace.Event) (overlapping tim
return overlapping
}
// overlappingInstant returns true if the instantaneous event, ev, occurred during
// overlappingInstant reports whether the instantaneous event, ev, occurred during
// any of the task's region if ev is a goroutine-local event, or overlaps with the
// task's lifetime if ev is a global event.
func (task *taskDesc) overlappingInstant(ev *trace.Event) bool {

View file

@ -531,7 +531,7 @@ func printfNameAndKind(pkg *Package, called ast.Expr) (pkgpath, name string, kin
return pkgpath, name, kind
}
// isStringer returns true if the provided declaration is a "String() string"
// isStringer reports whether the provided declaration is a "String() string"
// method, an implementation of fmt.Stringer.
func isStringer(f *File, d *ast.FuncDecl) bool {
return d.Recv != nil && d.Name.Name == "String" && d.Type.Results != nil &&

View file

@ -1147,7 +1147,7 @@ func parseSANExtension(value []byte) (dnsNames, emailAddresses []string, ipAddre
return
}
// isValidIPMask returns true iff mask consists of zero or more 1 bits, followed by zero bits.
// isValidIPMask reports whether mask consists of zero or more 1 bits, followed by zero bits.
func isValidIPMask(mask []byte) bool {
seenZero := false

View file

@ -2691,7 +2691,7 @@ func (rs *Rows) nextLocked() (doClose, ok bool) {
return false, true
}
// NextResultSet prepares the next result set for reading. It returns true if
// NextResultSet prepares the next result set for reading. It reports whether
// there is further result sets, or false if there is no further result set
// or if there is an error advancing to it. The Err method should be consulted
// to distinguish between the two cases.

View file

@ -633,7 +633,7 @@ var (
bigIntType = reflect.TypeOf(new(big.Int))
)
// invalidLength returns true iff offset + length > sliceLength, or if the
// invalidLength reports whether offset + length > sliceLength, or if the
// addition would overflow.
func invalidLength(offset, length, sliceLength int) bool {
return offset+length < offset || offset+length > sliceLength

View file

@ -1134,7 +1134,7 @@ func (p *printer) controlClause(isForStmt bool, init ast.Stmt, expr ast.Expr, po
// than starting at the first line break).
//
func (p *printer) indentList(list []ast.Expr) bool {
// Heuristic: indentList returns true if there are more than one multi-
// Heuristic: indentList reports whether there are more than one multi-
// line element in the list, or if there is any element that is not
// starting on the same line as the previous one ends.
if len(list) >= 2 {

View file

@ -13,7 +13,7 @@ import (
)
// builtin type-checks a call to the built-in specified by id and
// returns true if the call is valid, with *x holding the result;
// reports whether the call is valid, with *x holding the result;
// but x.expr is not set. If the call is invalid, the result is
// false, and *x is undefined.
//

View file

@ -115,7 +115,7 @@ func (s *Scope) Insert(obj Object) Object {
func (s *Scope) Pos() token.Pos { return s.pos }
func (s *Scope) End() token.Pos { return s.end }
// Contains returns true if pos is within the scope's extent.
// Contains reports whether pos is within the scope's extent.
// The result is guaranteed to be valid only if the type-checked
// AST has complete position information.
func (s *Scope) Contains(pos token.Pos) bool {

View file

@ -340,7 +340,7 @@ func (t *Interface) NumMethods() int { return len(t.allMethods) }
// The methods are ordered by their unique Id.
func (t *Interface) Method(i int) *Func { return t.allMethods[i] }
// Empty returns true if t is the empty interface.
// Empty reports whether t is the empty interface.
func (t *Interface) Empty() bool { return len(t.allMethods) == 0 }
// Complete computes the interface's method set. It must be called by users of

View file

@ -371,7 +371,7 @@ func isJSIdentPart(r rune) bool {
return false
}
// isJSType returns true if the given MIME type should be considered JavaScript.
// isJSType reports whether the given MIME type should be considered JavaScript.
//
// It is used to determine whether a script tag with a type attribute is a javascript container.
func isJSType(mimeType string) bool {

View file

@ -86,7 +86,7 @@ func urlProcessor(norm bool, args ...interface{}) string {
}
// processURLOnto appends a normalized URL corresponding to its input to b
// and returns true if the appended content differs from s.
// and reports whether the appended content differs from s.
func processURLOnto(s string, norm bool, b *bytes.Buffer) bool {
b.Grow(len(s) + 16)
written := 0

View file

@ -193,7 +193,7 @@ func isInterrupted(err error) bool {
return err != nil && stringsHasSuffix(err.Error(), "interrupted")
}
// IsPollDescriptor returns true if fd is the descriptor being used by the poller.
// IsPollDescriptor reports whether fd is the descriptor being used by the poller.
// This is only used for testing.
func IsPollDescriptor(fd uintptr) bool {
return false

View file

@ -92,7 +92,7 @@ func setDeadlineImpl(fd *FD, t time.Time, mode int) error {
return nil
}
// IsPollDescriptor returns true if fd is the descriptor being used by the poller.
// IsPollDescriptor reports whether fd is the descriptor being used by the poller.
// This is only used for testing.
func IsPollDescriptor(fd uintptr) bool {
return false

View file

@ -154,7 +154,7 @@ func setDeadlineImpl(fd *FD, t time.Time, mode int) error {
return nil
}
// IsPollDescriptor returns true if fd is the descriptor being used by the poller.
// IsPollDescriptor reports whether fd is the descriptor being used by the poller.
// This is only used for testing.
func IsPollDescriptor(fd uintptr) bool {
return runtime_isPollServerDescriptor(fd)

View file

@ -327,7 +327,7 @@ func (z *Float) SetMantExp(mant *Float, exp int) *Float {
return z
}
// Signbit returns true if x is negative or negative zero.
// Signbit reports whether x is negative or negative zero.
func (x *Float) Signbit() bool {
return x.neg
}

View file

@ -6,7 +6,7 @@ package cmplx
import "math"
// IsInf returns true if either real(x) or imag(x) is an infinity.
// IsInf reports whether either real(x) or imag(x) is an infinity.
func IsInf(x complex128) bool {
if math.IsInf(real(x), 0) || math.IsInf(imag(x), 0) {
return true

View file

@ -6,7 +6,7 @@ package cmplx
import "math"
// IsNaN returns true if either real(x) or imag(x) is NaN
// IsNaN reports whether either real(x) or imag(x) is NaN
// and neither is an infinity.
func IsNaN(x complex128) bool {
switch {

View file

@ -4,7 +4,7 @@
package math
// Signbit returns true if x is negative or negative zero.
// Signbit reports whether x is negative or negative zero.
func Signbit(x float64) bool {
return Float64bits(x)&(1<<63) != 0
}

View file

@ -10,7 +10,7 @@ import (
"unsafe"
)
// isNulName returns true if name is NUL file name.
// isNulName reports whether name is NUL file name.
// For example, it returns true for both "NUL" and "nul".
func isNulName(name string) bool {
if len(name) != 3 {

View file

@ -106,7 +106,7 @@ func TestMatch(t *testing.T) {
}
}
// contains returns true if vector contains the string s.
// contains reports whether vector contains the string s.
func contains(vector []string, s string) bool {
for _, elem := range vector {
if elem == s {

View file

@ -2314,7 +2314,7 @@ type structTypeFixed32 struct {
m [32]method
}
// isLetter returns true if a given 'rune' is classified as a Letter.
// isLetter reports whether a given 'rune' is classified as a Letter.
func isLetter(ch rune) bool {
return 'a' <= ch && ch <= 'z' || 'A' <= ch && ch <= 'Z' || ch == '_' || ch >= utf8.RuneSelf && unicode.IsLetter(ch)
}

View file

@ -59,7 +59,7 @@ const (
const opPseudo Op = 128 // where pseudo-ops start
// Equal returns true if x and y have identical structure.
// Equal reports whether x and y have identical structure.
func (x *Regexp) Equal(y *Regexp) bool {
if x == nil || y == nil {
return x == y

View file

@ -517,7 +517,7 @@ func (h heapBits) bits() uint32 {
return uint32(*h.bitp) >> (h.shift & 31)
}
// morePointers returns true if this word and all remaining words in this object
// morePointers reports whether this word and all remaining words in this object
// are scalars.
// h must not describe the second word of the object.
func (h heapBits) morePointers() bool {

View file

@ -203,7 +203,7 @@ func (c *mcentral) uncacheSpan(s *mspan) {
// and, based on the number of free objects in s,
// moves s to the appropriate list of c or returns it
// to the heap.
// freeSpan returns true if s was returned to the heap.
// freeSpan reports whether s was returned to the heap.
// If preserve=true, it does not move s (the caller
// must take care of it).
func (c *mcentral) freeSpan(s *mspan, preserve bool, wasempty bool) bool {

View file

@ -735,7 +735,7 @@ func (c *gcControllerState) findRunnableGCWorker(_p_ *p) *g {
return gp
}
// pollFractionalWorkerExit returns true if a fractional mark worker
// pollFractionalWorkerExit reports whether a fractional mark worker
// should self-preempt. It assumes it is called from the fractional
// worker.
func pollFractionalWorkerExit() bool {
@ -1157,7 +1157,7 @@ const (
gcTriggerCycle
)
// test returns true if the trigger condition is satisfied, meaning
// test reports whether the trigger condition is satisfied, meaning
// that the exit condition for the _GCoff phase has been met. The exit
// condition should be tested when allocating.
func (t gcTrigger) test() bool {
@ -1867,7 +1867,7 @@ func gcBgMarkWorker(_p_ *p) {
}
}
// gcMarkWorkAvailable returns true if executing a mark worker
// gcMarkWorkAvailable reports whether executing a mark worker
// on p is potentially useful. p may be nil, in which case it only
// checks the global sources of work.
func gcMarkWorkAvailable(p *p) bool {

View file

@ -138,7 +138,7 @@ func (w *gcWork) put(obj uintptr) {
}
}
// putFast does a put and returns true if it can be done quickly
// putFast does a put and reports whether it can be done quickly
// otherwise it returns false and the caller needs to call put.
//go:nowritebarrierrec
func (w *gcWork) putFast(obj uintptr) bool {
@ -299,7 +299,7 @@ func (w *gcWork) balance() {
}
}
// empty returns true if w has no mark work available.
// empty reports whether w has no mark work available.
//go:nowritebarrierrec
func (w *gcWork) empty() bool {
return w.wbuf1 == nil || (w.wbuf1.nobj == 0 && w.wbuf2.nobj == 0)

View file

@ -107,7 +107,7 @@ func (b *wbBuf) discard() {
b.next = uintptr(unsafe.Pointer(&b.buf[0]))
}
// empty returns true if b contains no pointers.
// empty reports whether b contains no pointers.
func (b *wbBuf) empty() bool {
return b.next == uintptr(unsafe.Pointer(&b.buf[0]))
}

View file

@ -95,7 +95,7 @@ func netpollinited() bool {
//go:linkname poll_runtime_isPollServerDescriptor internal/poll.runtime_isPollServerDescriptor
// poll_runtime_isPollServerDescriptor returns true if fd is a
// poll_runtime_isPollServerDescriptor reports whether fd is a
// descriptor being used by netpoll.
func poll_runtime_isPollServerDescriptor(fd uintptr) bool {
fds := netpolldescriptor()

View file

@ -849,7 +849,7 @@ func canpanic(gp *g) bool {
return true
}
// shouldPushSigpanic returns true if pc should be used as sigpanic's
// shouldPushSigpanic reports whether pc should be used as sigpanic's
// return PC (pushing a frame for the call). Otherwise, it should be
// left alone so that LR is used as sigpanic's return PC, effectively
// replacing the top-most frame with sigpanic. This is used by
@ -887,7 +887,7 @@ func shouldPushSigpanic(gp *g, pc, lr uintptr) bool {
return true
}
// isAbortPC returns true if pc is the program counter at which
// isAbortPC reports whether pc is the program counter at which
// runtime.abort raises a signal.
//
// It is nosplit because it's part of the isgoexception

View file

@ -573,7 +573,7 @@ func (p *Profile) Demangle(d Demangler) error {
return nil
}
// Empty returns true if the profile contains no samples.
// Empty reports whether the profile contains no samples.
func (p *Profile) Empty() bool {
return len(p.Sample) == 0
}

View file

@ -2400,7 +2400,7 @@ stop:
goto top
}
// pollWork returns true if there is non-background work this P could
// pollWork reports whether there is non-background work this P could
// be doing. This is a fairly lightweight check to be used for
// background work loops, like idle GC. It checks a subset of the
// conditions checked by the actual scheduler.
@ -4713,7 +4713,7 @@ func pidleget() *p {
return _p_
}
// runqempty returns true if _p_ has no Gs on its local run queue.
// runqempty reports whether _p_ has no Gs on its local run queue.
// It never returns true spuriously.
func runqempty(_p_ *p) bool {
// Defend against a race where 1) _p_ has G1 in runqnext but runqhead == runqtail,
@ -4934,7 +4934,7 @@ type gQueue struct {
tail guintptr
}
// empty returns true if q is empty.
// empty reports whether q is empty.
func (q *gQueue) empty() bool {
return q.head == 0
}
@ -5000,7 +5000,7 @@ type gList struct {
head guintptr
}
// empty returns true if l is empty.
// empty reports whether l is empty.
func (l *gList) empty() bool {
return l.head == 0
}

View file

@ -38,7 +38,7 @@ func initExceptionHandler() {
}
}
// isgoexception returns true if this exception should be translated
// isgoexception reports whether this exception should be translated
// into a Go panic.
//
// It is nosplit to avoid growing the stack in case we're aborting

View file

@ -54,7 +54,7 @@ func init() {
}
// Active spinning runtime support.
// runtime_canSpin returns true if spinning makes sense at the moment.
// runtime_canSpin reports whether spinning makes sense at the moment.
func runtime_canSpin(i int) bool
// runtime_doSpin does active spinning.

View file

@ -694,7 +694,7 @@ func (src *Source) ParseFile(path string) error {
return nil
}
// IsStdRepo returns true if src is part of standard library.
// IsStdRepo reports whether src is part of standard library.
func (src *Source) IsStdRepo() (bool, error) {
if len(src.Files) == 0 {
return false, errors.New("no input files provided")