Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1417)

Side by Side Diff: cmd/vet/bool.go

Issue 106510044: go.tools/cmd/vet: enable file level checker short-circuiting (Closed)
Patch Set: diff -r 0f0740bbe48a https://code.google.com/p/go.tools Created 9 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cmd/vet/atomic.go ('k') | cmd/vet/composite.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Go Authors. All rights reserved. 1 // Copyright 2014 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // This file contains boolean condition tests. 5 // This file contains boolean condition tests.
6 6
7 package main 7 package main
8 8
9 import ( 9 import (
10 "go/ast" 10 "go/ast"
11 "go/token" 11 "go/token"
12 ) 12 )
13 13
14 func init() { 14 func init() {
15 register("bool", 15 register("bool",
16 "check for mistakes involving boolean operators", 16 "check for mistakes involving boolean operators",
17 filterBool,
17 checkBool, 18 checkBool,
18 binaryExpr) 19 binaryExpr)
19 } 20 }
20 21
22 func filterBool(f *File) bool { return true }
23
21 func checkBool(f *File, n ast.Node) { 24 func checkBool(f *File, n ast.Node) {
22 e := n.(*ast.BinaryExpr) 25 e := n.(*ast.BinaryExpr)
23 26
24 var op boolOp 27 var op boolOp
25 switch e.Op { 28 switch e.Op {
26 case token.LOR: 29 case token.LOR:
27 op = or 30 op = or
28 case token.LAND: 31 case token.LAND:
29 op = and 32 op = and
30 default: 33 default:
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 179
177 func unparen(e ast.Expr) ast.Expr { 180 func unparen(e ast.Expr) ast.Expr {
178 for { 181 for {
179 p, ok := e.(*ast.ParenExpr) 182 p, ok := e.(*ast.ParenExpr)
180 if !ok { 183 if !ok {
181 return e 184 return e
182 } 185 }
183 e = p.X 186 e = p.X
184 } 187 }
185 } 188 }
OLDNEW
« no previous file with comments | « cmd/vet/atomic.go ('k') | cmd/vet/composite.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b