[cfe-commits] r156489 - in /cfe/trunk: lib/Driver/ToolChains.cpp test/Driver/target-triple-deployment.c

Jordy Rose jediknil at belkadan.com
Wed May 9 11:33:08 PDT 2012


I was going to suggest using SmallString instead of std::string, but I'm not sure either is correct. When the if-scope ends, the string dies and the iOSTarget StringRef is left dangling.

Jordy


On May 9, 2012, at 14:09, Chad Rosier wrote:

> Author: mcrosier
> Date: Wed May  9 13:09:58 2012
> New Revision: 156489
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=156489&view=rev
> Log:
> [driver] Use the iOS target triple to infer the deployment target.
> rdar://11409204
> 
> Added:
>    cfe/trunk/test/Driver/target-triple-deployment.c
> Modified:
>    cfe/trunk/lib/Driver/ToolChains.cpp
> 
> Modified: cfe/trunk/lib/Driver/ToolChains.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=156489&r1=156488&r2=156489&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Driver/ToolChains.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains.cpp Wed May  9 13:09:58 2012
> @@ -524,8 +524,14 @@
>     // If no OSX or iOS target has been specified and we're compiling for armv7,
>     // go ahead as assume we're targeting iOS.
>     if (OSXTarget.empty() && iOSTarget.empty())
> -      if (getDarwinArchName(Args) == "armv7")
> -        iOSTarget = "0.0";
> +      if (getDarwinArchName(Args) == "armv7") {
> +        std::string iOSVersionMin;
> +        unsigned Major, Minor, Micro;
> +        getTriple().getiOSVersion(Major, Minor, Micro);
> +        llvm::raw_string_ostream(iOSVersionMin)
> +          << Major << '.' << Minor << '.' << Micro;
> +        iOSTarget = iOSVersionMin;
> +      }
> 
>     // Handle conflicting deployment targets
>     //
> 
> Added: cfe/trunk/test/Driver/target-triple-deployment.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/target-triple-deployment.c?rev=156489&view=auto
> ==============================================================================
> --- cfe/trunk/test/Driver/target-triple-deployment.c (added)
> +++ cfe/trunk/test/Driver/target-triple-deployment.c Wed May  9 13:09:58 2012
> @@ -0,0 +1,33 @@
> +// RUN: touch %t.o
> +// RUN: %clang -target x86_64-apple-macosx -### %t.o 2> %t.log
> +// RUN: %clang -target x86_64-apple-darwin9 -### %t.o 2>> %t.log
> +// RUN: %clang -target x86_64-apple-macosx10.7 -### %t.o 2>> %t.log
> +//
> +// RUN: %clang -target armv7-apple-ios -### %t.o 2>> %t.log
> +// RUN: %clang -target armv7-apple-ios0.0 -### %t.o 2>> %t.log
> +// RUN: %clang -target armv7-apple-ios1.2.3 -### %t.o 2>> %t.log
> +// RUN: %clang -target armv7-apple-ios5.0 -### %t.o 2>> %t.log
> +//
> +// RUN: FileCheck %s < %t.log
> +
> +// CHECK: {{ld(.exe)?"}}
> +// CHECK: -macosx_version_min
> +// CHECK: 10.4.0
> +// CHECK: {{ld(.exe)?"}}
> +// CHECK: -macosx_version_min
> +// CHECK: 10.5.0
> +// CHECK: {{ld(.exe)?"}}
> +// CHECK: -macosx_version_min
> +// CHECK: 10.7.0
> +// CHECK: {{ld(.exe)?"}}
> +// CHECK: -iphoneos_version_min
> +// CHECK: 0.0.0
> +// CHECK: {{ld(.exe)?"}}
> +// CHECK: -iphoneos_version_min
> +// CHECK: 0.0.0
> +// CHECK: {{ld(.exe)?"}}
> +// CHECK: -iphoneos_version_min
> +// CHECK: 1.2.3
> +// CHECK: {{ld(.exe)?"}}
> +// CHECK: -iphoneos_version_min
> +// CHECK: 5.0.0
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits





More information about the cfe-commits mailing list