mirror of https://github.com/microsoft/clang.git
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@336219 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
82cfb485f0
commit
a0c03f2df3
|
@ -318,10 +318,12 @@ int Command::Execute(ArrayRef<llvm::Optional<StringRef>> Redirects,
|
|||
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) {
|
||||
|
|
Loading…
Reference in New Issue