mirror of
https://github.com/github/codeql.git
synced 2025-12-17 17:23:36 +01:00
This replaces usages of `llvm::fs` and string manipulation with `std::filesystem`, also replacing `std::string` with `std::filesystem::path` where it made sense. Moreover MD5 hashing used in macOS file remapping was replaced by SHA256 hashing using a small header-only SHA256 C++ library with an MIT license, https://github.com/okdshin/PicoSHA2. File contents hashing was relocated to the newly created `file` library for later planned reuse.
24 lines
817 B
C++
24 lines
817 B
C++
#include "swift/extractor/TargetTrapFile.h"
|
|
#include <iomanip>
|
|
namespace codeql {
|
|
std::optional<TargetFile> createTargetTrapFile(const SwiftExtractorConfiguration& configuration,
|
|
const std::filesystem::path& target) {
|
|
auto trap = target;
|
|
trap += ".trap";
|
|
auto ret = TargetFile::create(trap, configuration.trapDir, configuration.getTempTrapDir());
|
|
if (ret) {
|
|
*ret << "/* extractor-args:\n";
|
|
for (const auto& opt : configuration.frontendOptions) {
|
|
*ret << " " << std::quoted(opt) << " \\\n";
|
|
}
|
|
*ret << "\n*/\n"
|
|
"/* swift-frontend-args:\n";
|
|
for (const auto& opt : configuration.patchedFrontendOptions) {
|
|
*ret << " " << std::quoted(opt) << " \\\n";
|
|
}
|
|
*ret << "\n*/\n";
|
|
}
|
|
return ret;
|
|
}
|
|
} // namespace codeql
|