Fixed the escaping of strings in swift::json::Output.
Fixed the escaping of strings in swift::json::Output.

Instead of using llvm::raw_ostream::write_escaped (which does not produce valid
JSON strings), implemented custom escaping logic based on the JSON standard,
which only requires that the following characters be escaped:

  - Quotation mark (U+0022)
  - Reverse solidus (U+005C)
  - Control characters (U+0000 to U+001F)

Since these characters all fit within a single UTF8 byte, and will not be
present in a multi-byte UTF8 representation, simply check whether the current
byte needs to be escaped according to those requirements. If the current byte
needs to be escaped, then print out the escaped version of the byte; otherwise,
pass the current byte to the stream directly.

This fixes <rdar://problem/18266570>.

Swift SVN r21892

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