Skip to content

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

Open
StepfenShawn wants to merge 3 commits into
llvm:mainfrom
StepfenShawn:clang-offload-bundler
Open

[clang-offload-bundler] Convert std::vector to llvm::SmallVector in OffloadBundlerConfig#192259
StepfenShawn wants to merge 3 commits into
llvm:mainfrom
StepfenShawn:clang-offload-bundler

Conversation

@StepfenShawn
Copy link
Copy Markdown
Member

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.

@llvmbot llvmbot added the clang Clang issues not falling into any other category label Apr 15, 2026
@llvmbot
Copy link
Copy Markdown
Member

llvmbot commented Apr 15, 2026

@llvm/pr-subscribers-clang

Author: 🍌Shawn (StepfenShawn)

Changes

Replace std::vector&lt;std::string&gt; with llvm::SmallVector&lt;std::string, 4&gt;
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 --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 {

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 15, 2026

✅ With the latest revision this PR passed the C/C++ code formatter.

@StepfenShawn StepfenShawn requested a review from yxsamliu April 16, 2026 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants