[clang] [clang-offload-bundler] Convert `std::vector` to `llvm::SmallVector` in `OffloadBundlerConfig` (PR #192259)

via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 15 06:38:40 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: 🍌Shawn (StepfenShawn)

<details>
<summary>Changes</summary>

Replace `std::vector<std::string>` with `llvm::SmallVector<std::string, 4>`
for TargetNames, InputFileNames, and OutputFileNames to avoid heap
allocation for small number of elements.

---
Full diff: https://github.com/llvm/llvm-project/pull/192259.diff


1 Files Affected:

- (modified) clang/include/clang/Driver/OffloadBundler.h (+4-5) 


``````````diff
diff --git a/clang/include/clang/Driver/OffloadBundler.h b/clang/include/clang/Driver/OffloadBundler.h
index e7306ce3cc9ab..637c9d146533f 100644
--- a/clang/include/clang/Driver/OffloadBundler.h
+++ b/clang/include/clang/Driver/OffloadBundler.h
@@ -17,12 +17,12 @@
 #ifndef LLVM_CLANG_DRIVER_OFFLOADBUNDLER_H
 #define LLVM_CLANG_DRIVER_OFFLOADBUNDLER_H
 
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Compression.h"
 #include "llvm/Support/Error.h"
 #include "llvm/TargetParser/Triple.h"
 #include <llvm/Support/MemoryBuffer.h>
 #include <string>
-#include <vector>
 
 namespace clang {
 
@@ -47,10 +47,9 @@ class OffloadBundlerConfig {
   std::string FilesType;
   std::string ObjcopyPath;
 
-  // TODO: Convert these to llvm::SmallVector
-  std::vector<std::string> TargetNames;
-  std::vector<std::string> InputFileNames;
-  std::vector<std::string> OutputFileNames;
+  llvm::SmallVector<std::string, 4> TargetNames;
+  llvm::SmallVector<std::string, 4> InputFileNames;
+  llvm::SmallVector<std::string, 4> OutputFileNames;
 };
 
 class OffloadBundler {

``````````

</details>


https://github.com/llvm/llvm-project/pull/192259


More information about the cfe-commits mailing list