Summary:
`vector::assign` will cause UB at here.
fixes: https://github.com/clangd/clangd/issues/223
Reviewers: kadircet, sammccall, hokein
Reviewed By: sammccall
Subscribers: merge_guards_bot, ilya-biryukov, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D71172
llvm::StringSaver Saver(Alloc);
llvm::cl::ExpandResponseFiles(Saver, Tokenizer, Argv, false, false, *FS,
llvm::StringRef(Cmd.Directory));
- Cmd.CommandLine.assign(Argv.begin(), Argv.end());
+ // Don't assign directly, Argv aliases CommandLine.
+ std::vector<std::string> ExpandedArgv(Argv.begin(), Argv.end());
+ Cmd.CommandLine = std::move(ExpandedArgv);
}
return Cmds;
}