]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.boringcrypto] all: merge master (5b76343) into dev.boringcrypto
authorFilippo Valsorda <filippo@golang.org>
Wed, 24 Feb 2021 14:49:21 +0000 (15:49 +0100)
committerFilippo Valsorda <filippo@golang.org>
Wed, 24 Feb 2021 14:49:21 +0000 (15:49 +0100)
Change-Id: I52c5b317a97c7723a7c077ae3cdfdc756fd3a1cf

1  2 
src/cmd/compile/internal/reflectdata/reflect.go
src/go/build/build.go
src/go/build/deps_test.go

index 35e07ea04ced0a5a0ef3a5fa3a669a29a54c86ee,0732f6aa1991d98d374a3d687ebd4b37cad80654..5b5a742d7249459ef786c0e45a05db305b2bcd58
@@@ -1831,39 -1830,40 +1830,41 @@@ func splitQuoted(s string) (r []string
        return args, err
  }
  
- // match reports whether the name is one of:
+ // matchAuto interprets text as either a +build or //go:build expression (whichever works),
+ // reporting whether the expression matches the build context.
  //
+ // matchAuto is only used for testing of tag evaluation
+ // and in #cgo lines, which accept either syntax.
+ func (ctxt *Context) matchAuto(text string, allTags map[string]bool) bool {
+       if strings.ContainsAny(text, "&|()") {
+               text = "//go:build " + text
+       } else {
+               text = "// +build " + text
+       }
+       x, err := constraint.Parse(text)
+       if err != nil {
+               return false
+       }
+       return ctxt.eval(x, allTags)
+ }
+ func (ctxt *Context) eval(x constraint.Expr, allTags map[string]bool) bool {
+       return x.Eval(func(tag string) bool { return ctxt.matchTag(tag, allTags) })
+ }
+ // matchTag reports whether the name is one of:
+ //
+ //    cgo (if cgo is enabled)
  //    $GOOS
  //    $GOARCH
- //    cgo (if cgo is enabled)
- //    !cgo (if cgo is disabled)
 +//    boringcrypto
  //    ctxt.Compiler
- //    !ctxt.Compiler
+ //    linux (if GOOS = android)
+ //    solaris (if GOOS = illumos)
  //    tag (if tag is listed in ctxt.BuildTags or ctxt.ReleaseTags)
- //    !tag (if tag is not listed in ctxt.BuildTags or ctxt.ReleaseTags)
- //    a comma-separated list of any of these
  //
- func (ctxt *Context) match(name string, allTags map[string]bool) bool {
-       if name == "" {
-               if allTags != nil {
-                       allTags[name] = true
-               }
-               return false
-       }
-       if i := strings.Index(name, ","); i >= 0 {
-               // comma-separated list
-               ok1 := ctxt.match(name[:i], allTags)
-               ok2 := ctxt.match(name[i+1:], allTags)
-               return ok1 && ok2
-       }
-       if strings.HasPrefix(name, "!!") { // bad syntax, reject always
-               return false
-       }
-       if strings.HasPrefix(name, "!") { // negation
-               return len(name) > 1 && !ctxt.match(name[1:], allTags)
-       }
+ // It records all consulted tags in allTags.
+ func (ctxt *Context) matchTag(name string, allTags map[string]bool) bool {
        if allTags != nil {
                allTags[name] = true
        }
Simple merge