In -enable-top-level-definite-init mode, emit a "mark_function_escape" instruction for func decls that capture globals defined in the current file.  For example, for:
In -enable-top-level-definite-init mode, emit a "mark_function_escape" instruction
for func decls that capture globals defined in the current file.  For example, for:

var x : Int

func foo() {
  print(x)
}

x = 15

We now silgen to:

sil internal @top_level_code : $() -> () {
bb0:
  %0 = global_addr #x : $*Int64                   // user: %1
  %1 = mark_uninitialized %0 : $*Int64            // users: %7, %2
  mark_function_escape %1 : $*Int64
  // function_ref swift.Int64._convertFromBuiltinIntegerLiteral (swift.Int64.metatype)(val : Builtin.Int128) -> swift.Int64
  %3 = function_ref @_TSi33_convertFromBuiltinIntegerLiteralfMSiFT3valBi128__Si : $[thin] ((val : Builtin.Int128), Int64.metatype) -> Int64 // user: %6
  %4 = metatype $Int64.metatype                   // user: %6
  %5 = integer_literal $Builtin.Int128, 15        // user: %6
  %6 = apply [transparent] %3(%5, %4) : $[thin] ((val : Builtin.Int128), Int64.metatype) -> Int64 // user: %7
  assign %6 to %1 : $*Int64
  %8 = tuple ()                                   // user: %9
  return %8 : $()
}

which will allow definite initialization to diagnose the error.

Note that we don't currently handle uses in constructors, like:

class frank {
  constructor() {
    print(x)
  }
}

... because the capture list is only stored for FuncDecls, not for AbstractFunction's.  It should be hoisted up at some point.




Swift SVN r8188

kentya6/swift,amraboelela/swift,djwbrown/swift,bitjammer/swift,gottesmm/swift,shahmishal/swift,devincoughlin/swift,brentdax/swift,harlanhaskins/swift,alblue/swift,zisko/swift,LeoShimonaka/swift,cbrentharris/swift,xwu/swift,nathawes/swift,kusl/swift,johnno1962d/swift,uasys/swift,jmgc/swift,swiftix/swift.old,rudkx/swift,felix91gr/swift,return/swift,jmgc/swift,Jnosh/swift,jckarter/swift,mightydeveloper/swift,shahmishal/swift,KrishMunot/swift,allevato/swift,Ivacker/swift,OscarSwanros/swift,danielmartin/swift,LeoShimonaka/swift,hughbe/swift,allevato/swift,austinzheng/swift,gmilos/swift,allevato/swift,modocache/swift,Jnosh/swift,jmgc/swift,emilstahl/swift,IngmarStein/swift,ben-ng/swift,calebd/swift,cbrentharris/swift,stephentyrone/swift,bitjammer/swift,aschwaighofer/swift,gmilos/swift,karwa/swift,stephentyrone/swift,shahmishal/swift,kusl/swift,jtbandes/swift,OscarSwanros/swift,dduan/swift,glessard/swift,dduan/swift,gribozavr/swift,zisko/swift,sschiau/swift,kentya6/swift,dreamsxin/swift,ben-ng/swift,tkremenek/swift,djwbrown/swift,amraboelela/swift,apple/swift,kentya6/swift,tkremenek/swift,CodaFi/swift,airspeedswift/swift,russbishop/swift,therealbnut/swift,Jnosh/swift,bitjammer/swift,felix91gr/swift,cbrentharris/swift,airspeedswift/swift,brentdax/swift,uasys/swift,SwiftAndroid/swift,johnno1962d/swift,uasys/swift,natecook1000/swift,sdulal/swift,hooman/swift,shajrawi/swift,tinysun212/swift-windows,kperryua/swift,khizkhiz/swift,CodaFi/swift,LeoShimonaka/swift,natecook1000/swift,brentdax/swift,deyton/swift,allevato/swift,return/swift,Ivacker/swift,gregomni/swift,sdulal/swift,modocache/swift,harlanhaskins/swift,OscarSwanros/swift,kstaring/swift,LeoShimonaka/swift,arvedviehweger/swift,jopamer/swift,aschwaighofer/swift,sdulal/swift,slavapestov/swift,manavgabhawala/swift,adrfer/swift,natecook1000/swift,deyton/swift,hughbe/swift,benlangmuir/swift,aschwaighofer/swift,swiftix/swift.old,kusl/swift,JGiola/swift,jckarter/swift,sschiau/swift,milseman/swift,ahoppen/swift,karwa/swift,tjw/swift,emilstahl/swift,kusl/swift,johnno1962d/swift,brentdax/swift,apple/swift,slavapestov/swift,IngmarStein/swift,ahoppen/swift,frootloops/swift,lorentey/swift,jopamer/swift,atrick/swift,xwu/swift,swiftix/swift.old,ken0nek/swift,gribozavr/swift,CodaFi/swift,sdulal/swift,kusl/swift,LeoShimonaka/swift,danielmartin/swift,hughbe/swift,modocache/swift,jtbandes/swift,huonw/swift,glessard/swift,apple/swift,karwa/swift,emilstahl/swift,natecook1000/swift,adrfer/swift,JaSpa/swift,tjw/swift,stephentyrone/swift,deyton/swift,harlanhaskins/swift,danielmartin/swift,xedin/swift,modocache/swift,ken0nek/swift,huonw/swift,tardieu/swift,huonw/swift,jtbandes/swift,MukeshKumarS/Swift,kstaring/swift,ahoppen/swift,harlanhaskins/swift,ben-ng/swift,apple/swift,manavgabhawala/swift,modocache/swift,uasys/swift,apple/swift,therealbnut/swift,IngmarStein/swift,frootloops/swift,kentya6/swift,xwu/swift,arvedviehweger/swift,gottesmm/swift,CodaFi/swift,practicalswift/swift,emilstahl/swift,airspeedswift/swift,austinzheng/swift,jmgc/swift,kperryua/swift,uasys/swift,xedin/swift,Ivacker/swift,SwiftAndroid/swift,khizkhiz/swift,nathawes/swift,nathawes/swift,airspeedswift/swift,MukeshKumarS/Swift,benlangmuir/swift,swiftix/swift,hooman/swift,tinysun212/swift-windows,gmilos/swift,karwa/swift,lorentey/swift,shajrawi/swift,cbrentharris/swift,hooman/swift,KrishMunot/swift,frootloops/swift,dduan/swift,shajrawi/swift,CodaFi/swift,swiftix/swift,deyton/swift,KrishMunot/swift,bitjammer/swift,gmilos/swift,amraboelela/swift,dreamsxin/swift,SwiftAndroid/swift,adrfer/swift,Jnosh/swift,gmilos/swift,return/swift,gottesmm/swift,parkera/swift,Ivacker/swift,kstaring/swift,devincoughlin/swift,SwiftAndroid/swift,roambotics/swift,atrick/swift,xedin/swift,aschwaighofer/swift,calebd/swift,felix91gr/swift,deyton/swift,lorentey/swift,manavgabhawala/swift,xwu/swift,xedin/swift,russbishop/swift,shahmishal/swift,gottesmm/swift,kusl/swift,tkremenek/swift,LeoShimonaka/swift,arvedviehweger/swift,brentdax/swift,slavapestov/swift,xedin/swift,stephentyrone/swift,slavapestov/swift,devincoughlin/swift,johnno1962d/swift,OscarSwanros/swift,tjw/swift,alblue/swift,tinysun212/swift-windows,shahmishal/swift,mightydeveloper/swift,austinzheng/swift,benlangmuir/swift,Jnosh/swift,slavapestov/swift,tardieu/swift,shahmishal/swift,khizkhiz/swift,atrick/swift,sdulal/swift,manavgabhawala/swift,ken0nek/swift,alblue/swift,kperryua/swift,johnno1962d/swift,kperryua/swift,bitjammer/swift,gottesmm/swift,xedin/swift,austinzheng/swift,tjw/swift,emilstahl/swift,atrick/swift,calebd/swift,practicalswift/swift,rudkx/swift,gribozavr/swift,kentya6/swift,swiftix/swift.old,dduan/swift,brentdax/swift,shajrawi/swift,slavapestov/swift,xwu/swift,emilstahl/swift,benlangmuir/swift,CodaFi/swift,modocache/swift,shahmishal/swift,arvedviehweger/swift,deyton/swift,sschiau/swift,LeoShimonaka/swift,OscarSwanros/swift,return/swift,xedin/swift,sdulal/swift,parkera/swift,JGiola/swift,swiftix/swift,kusl/swift,JaSpa/swift,mightydeveloper/swift,return/swift,gregomni/swift,kperryua/swift,bitjammer/swift,MukeshKumarS/Swift,devincoughlin/swift,kusl/swift,dduan/swift,JGiola/swift,harlanhaskins/swift,djwbrown/swift,tinysun212/swift-windows,felix91gr/swift,codestergit/swift,danielmartin/swift,rudkx/swift,therealbnut/swift,johnno1962d/swift,hughbe/swift,gregomni/swift,dduan/swift,manavgabhawala/swift,hughbe/swift,Jnosh/swift,jopamer/swift,aschwaighofer/swift,gregomni/swift,jopamer/swift,stephentyrone/swift,parkera/swift,therealbnut/swift,jtbandes/swift,sdulal/swift,alblue/swift,sschiau/swift,benlangmuir/swift,swiftix/swift.old,gribozavr/swift,therealbnut/swift,milseman/swift,frootloops/swift,deyton/swift,emilstahl/swift,JaSpa/swift,allevato/swift,SwiftAndroid/swift,codestergit/swift,xedin/swift,IngmarStein/swift,Jnosh/swift,calebd/swift,jmgc/swift,karwa/swift,felix91gr/swift,brentdax/swift,sschiau/swift,tkremenek/swift,devincoughlin/swift,hughbe/swift,djwbrown/swift,cbrentharris/swift,mightydeveloper/swift,adrfer/swift,swiftix/swift,rudkx/swift,austinzheng/swift,natecook1000/swift,natecook1000/swift,jckarter/swift,MukeshKumarS/Swift,MukeshKumarS/Swift,glessard/swift,allevato/swift,parkera/swift,swiftix/swift,tardieu/swift,return/swift,jtbandes/swift,bitjammer/swift,zisko/swift,natecook1000/swift,khizkhiz/swift,ben-ng/swift,uasys/swift,huonw/swift,zisko/swift,gottesmm/swift,milseman/swift,practicalswift/swift,MukeshKumarS/Swift,huonw/swift,djwbrown/swift,gregomni/swift,codestergit/swift,lorentey/swift,tinysun212/swift-windows,OscarSwanros/swift,tardieu/swift,kstaring/swift,Ivacker/swift,devincoughlin/swift,roambotics/swift,JaSpa/swift,allevato/swift,kentya6/swift,jmgc/swift,mightydeveloper/swift,aschwaighofer/swift,kentya6/swift,nathawes/swift,jtbandes/swift,gribozavr/swift,devincoughlin/swift,tjw/swift,practicalswift/swift,shajrawi/swift,practicalswift/swift,JGiola/swift,gregomni/swift,jopamer/swift,airspeedswift/swift,russbishop/swift,Ivacker/swift,austinzheng/swift,KrishMunot/swift,harlanhaskins/swift,felix91gr/swift,shajrawi/swift,glessard/swift,parkera/swift,ben-ng/swift,SwiftAndroid/swift,cbrentharris/swift,codestergit/swift,jopamer/swift,tkremenek/swift,sdulal/swift,KrishMunot/swift,SwiftAndroid/swift,xwu/swift,jmgc/swift,LeoShimonaka/swift,glessard/swift,alblue/swift,JaSpa/swift,cbrentharris/swift,sschiau/swift,hooman/swift,danielmartin/swift,jtbandes/swift,glessard/swift,rudkx/swift,apple/swift,karwa/swift,uasys/swift,amraboelela/swift,lorentey/swift,adrfer/swift,cbrentharris/swift,amraboelela/swift,tardieu/swift,russbishop/swift,stephentyrone/swift,huonw/swift,mightydeveloper/swift,CodaFi/swift,Ivacker/swift,lorentey/swift,mightydeveloper/swift,harlanhaskins/swift,gribozavr/swift,arvedviehweger/swift,KrishMunot/swift,kstaring/swift,roambotics/swift,kstaring/swift,djwbrown/swift,mightydeveloper/swift,gribozavr/swift,aschwaighofer/swift,arvedviehweger/swift,milseman/swift,IngmarStein/swift,airspeedswift/swift,felix91gr/swift,nathawes/swift,tardieu/swift,hooman/swift,OscarSwanros/swift,swiftix/swift.old,ben-ng/swift,modocache/swift,sschiau/swift,frootloops/swift,therealbnut/swift,lorentey/swift,shajrawi/swift,karwa/swift,frootloops/swift,manavgabhawala/swift,ken0nek/swift,roambotics/swift,practicalswift/swift,austinzheng/swift,milseman/swift,tjw/swift,dduan/swift,lorentey/swift,karwa/swift,benlangmuir/swift,swiftix/swift.old,jckarter/swift,ken0nek/swift,tkremenek/swift,gottesmm/swift,ahoppen/swift,roambotics/swift,khizkhiz/swift,codestergit/swift,jckarter/swift,parkera/swift,tardieu/swift,calebd/swift,kperryua/swift,zisko/swift,swiftix/swift,danielmartin/swift,roambotics/swift,swiftix/swift,milseman/swift,tinysun212/swift-windows,atrick/swift,alblue/swift,calebd/swift,rudkx/swift,johnno1962d/swift,arvedviehweger/swift,tinysun212/swift-windows,JaSpa/swift,nathawes/swift,tjw/swift,zisko/swift,parkera/swift,ben-ng/swift,khizkhiz/swift,shajrawi/swift,milseman/swift,parkera/swift,devincoughlin/swift,manavgabhawala/swift,amraboelela/swift,MukeshKumarS/Swift,kentya6/swift,tkremenek/swift,JaSpa/swift,slavapestov/swift,shahmishal/swift,atrick/swift,frootloops/swift,practicalswift/swift,JGiola/swift,xwu/swift,jopamer/swift,adrfer/swift,kstaring/swift,ken0nek/swift,IngmarStein/swift,nathawes/swift,russbishop/swift,return/swift,jckarter/swift,zisko/swift,alblue/swift,ken0nek/swift,codestergit/swift,amraboelela/swift,stephentyrone/swift,hooman/swift,IngmarStein/swift,JGiola/swift,russbishop/swift,calebd/swift,KrishMunot/swift,codestergit/swift,sschiau/swift,danielmartin/swift,kperryua/swift,jckarter/swift,gmilos/swift,airspeedswift/swift,gmilos/swift,emilstahl/swift,adrfer/swift,djwbrown/swift,ahoppen/swift,Ivacker/swift,huonw/swift,swiftix/swift.old,russbishop/swift,gribozavr/swift,therealbnut/swift,hooman/swift,hughbe/swift,practicalswift/swift,ahoppen/swift,khizkhiz/swift