[PATCH] [clang] PR21195: Emit .gcno files to the proper location.

Justin Bogner mail at justinbogner.com
Wed Oct 8 22:24:39 PDT 2014


Dan Albert <danalbert at google.com> writes:
> When building with coverage, -no-integrated-as, and -c, the driver was
> emitting -cc1 -coverage-file pointing at a file in /tmp. Ensure the
> coverage file is emitted in the same directory as the output file.

LGTM, but some tests that involve relative paths would be nice.

> http://reviews.llvm.org/D5697
>
> Files:
>   lib/Driver/Tools.cpp
>   test/Driver/clang_f_opts.c
>
> Index: lib/Driver/Tools.cpp
> ===================================================================
> --- lib/Driver/Tools.cpp
> +++ lib/Driver/Tools.cpp
> @@ -3241,7 +3241,13 @@
>        C.getArgs().hasArg(options::OPT_S)) {
>      if (Output.isFilename()) {
>        CmdArgs.push_back("-coverage-file");
> -      SmallString<128> CoverageFilename(Output.getFilename());
> +      SmallString<128> CoverageFilename;
> +      Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o);
> +      if (FinalOutput) {
> +        CoverageFilename = FinalOutput->getValue();
> +      } else {
> +        CoverageFilename = llvm::sys::path::filename(Output.getBaseInput());
> +      }
>        if (llvm::sys::path::is_relative(CoverageFilename.str())) {
>          SmallString<128> Pwd;
>          if (!llvm::sys::fs::current_path(Pwd)) {
> Index: test/Driver/clang_f_opts.c
> ===================================================================
> --- test/Driver/clang_f_opts.c
> +++ test/Driver/clang_f_opts.c
> @@ -66,6 +66,18 @@
>  // CHECK-PROFILE-ARCS: "-femit-coverage-data"
>  // CHECK-NO-PROFILE-ARCS-NOT: "-femit-coverage-data"
>  
> +// RUN: %clang -### -S -fprofile-arcs %s 2>&1 | FileCheck -check-prefix=CHECK-GCNO-DEFAULT-LOCATION %s
> +// RUN: %clang -### -S -fprofile-arcs -no-integrated-as %s 2>&1 | FileCheck -check-prefix=CHECK-GCNO-DEFAULT-LOCATION %s
> +// RUN: %clang -### -c -fprofile-arcs %s 2>&1 | FileCheck -check-prefix=CHECK-GCNO-DEFAULT-LOCATION %s
> +// RUN: %clang -### -c -fprofile-arcs -no-integrated-as %s 2>&1 | FileCheck -check-prefix=CHECK-GCNO-DEFAULT-LOCATION %s
> +// RUN: %clang -### -S -fprofile-arcs %s -o /foo/bar.o 2>&1 | FileCheck -check-prefix=CHECK-GCNO-LOCATION %s
> +// RUN: %clang -### -S -fprofile-arcs -no-integrated-as %s -o /foo/bar.o 2>&1 | FileCheck -check-prefix=CHECK-GCNO-LOCATION %s
> +// RUN: %clang -### -c -fprofile-arcs %s -o /foo/bar.o 2>&1 | FileCheck -check-prefix=CHECK-GCNO-LOCATION %s
> +// RUN: %clang -### -c -fprofile-arcs -no-integrated-as %s -o /foo/bar.o 2>&1 | FileCheck -check-prefix=CHECK-GCNO-LOCATION %s
> +// CHECK-GCNO-DEFAULT-LOCATION: "-coverage-file" "{{.*}}/clang_f_opts.c"
> +// CHECK-GCNO-DEFAULT-LOCATION-NOT: "-coverage-file" "/tmp/{{.*}}/clang_f_opts.c"
> +// CHECK-GCNO-LOCATION: "-coverage-file" "/foo/bar.o"
> +
>  // RUN: %clang -### -S -fvectorize %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
>  // RUN: %clang -### -S -fno-vectorize -fvectorize %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
>  // RUN: %clang -### -S -fno-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s
> _______________________________________________
> 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