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 cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits