From: Sergey Dmitriev Date: Tue, 24 Nov 2020 15:52:46 +0000 (-0800) Subject: [clang-offload-bundler] use std::forward_list for storing temp file names [NFC] X-Git-Tag: llvmorg-13-init~5249 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1b0ca81a6c358d2d52d4f84b7f42e620ead1ed26;p=platform%2Fupstream%2Fllvm.git [clang-offload-bundler] use std::forward_list for storing temp file names [NFC] Use a different container that preserves existing elements on modification for storing temporary file names. Current container can make StringRefs returned earlier invalid on reallocation. Reviewed By: ABataev Differential Revision: https://reviews.llvm.org/D92010 --- diff --git a/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp b/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp index 44c46a8..a1b2fec 100644 --- a/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp +++ b/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -394,7 +395,7 @@ public: if (std::error_code EC = sys::fs::createTemporaryFile("clang-offload-bundler", "tmp", File)) return createFileError(File, EC); - Files.push_back(File); + Files.push_front(File); if (Contents) { std::error_code EC; @@ -403,11 +404,11 @@ public: return createFileError(File, EC); OS.write(Contents->data(), Contents->size()); } - return Files.back(); + return Files.front(); } private: - SmallVector, 4u> Files; + std::forward_list> Files; }; } // end anonymous namespace