Did this fail on an existing regression test, or is there a need for more
test coverage? (guessing it failed on existing tests)

Also, is the makeArrayRef necessary? Looks like if the original code
compiled (implicitly converting from vector to ArrayRef) then the new code
wouldn't need a makeArrayRef either?

On Tue, Jul 3, 2018 at 11:17 AM Zachary Turner via cfe-commits <
[email protected]> wrote:

> Author: zturner
> Date: Tue Jul  3 11:12:39 2018
> New Revision: 336219
>
> URL: http://llvm.org/viewvc/llvm-project?rev=336219&view=rev
> Log:
> Fix crash in clang.
>
> This happened during a recent refactor.  toStringRefArray() returns
> a vector<StringRef>, which was being implicitly converted to an
> ArrayRef<StringRef>, and then the vector was immediately being
> destroyed, so the ArrayRef<> was losing its backing storage.
> Fix this by making sure the vector gets permanent storage.
>
> Modified:
>     cfe/trunk/lib/Driver/Job.cpp
>
> Modified: cfe/trunk/lib/Driver/Job.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Job.cpp?rev=336219&r1=336218&r2=336219&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Driver/Job.cpp (original)
> +++ cfe/trunk/lib/Driver/Job.cpp Tue Jul  3 11:12:39 2018
> @@ -318,10 +318,12 @@ int Command::Execute(ArrayRef<llvm::Opti
>    SmallVector<const char*, 128> Argv;
>
>    Optional<ArrayRef<StringRef>> Env;
> +  std::vector<StringRef> ArgvVectorStorage;
>    if (!Environment.empty()) {
>      assert(Environment.back() == nullptr &&
>             "Environment vector should be null-terminated by now");
> -    Env = llvm::toStringRefArray(Environment.data());
> +    ArgvVectorStorage = llvm::toStringRefArray(Environment.data());
> +    Env = makeArrayRef(ArgvVectorStorage);
>    }
>
>    if (ResponseFile == nullptr) {
>
>
> _______________________________________________
> cfe-commits mailing list
> [email protected]
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to