[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 08:43:45 PDT 2026
https://github.com/StepfenShawn updated https://github.com/llvm/llvm-project/pull/192259
>From 3bea439aa834f88fff608ccdb7a3ef78265fe22f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=F0=9F=8D=8CShawn?= <m18824909883 at 163.com>
Date: Wed, 15 Apr 2026 21:36:49 +0800
Subject: [PATCH 1/3] Convert `std::vector` to `llvm::SmallVector` in
`OffloadBundlerConfig`
---
clang/include/clang/Driver/OffloadBundler.h | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
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 {
>From 059f84232b38fefd5213579973f98ede70e257b5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=F0=9F=8D=8CShawn?= <m18824909883 at 163.com>
Date: Wed, 15 Apr 2026 21:54:13 +0800
Subject: [PATCH 2/3] Refactor BundlerConfig assignments to use assign method
---
.../clang-offload-bundler/ClangOffloadBundler.cpp | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp b/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
index 75de97068e6e9..fc49bd64e6970 100644
--- a/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ b/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -184,9 +184,9 @@ int main(int argc, const char **argv) {
if (CompressionLevel.getNumOccurrences() > 0)
BundlerConfig.CompressionLevel = CompressionLevel;
- BundlerConfig.TargetNames = TargetNames;
- BundlerConfig.InputFileNames = InputFileNames;
- BundlerConfig.OutputFileNames = OutputFileNames;
+ BundlerConfig.TargetNames.assign(TargetNames.begin(), TargetNames.end());
+ BundlerConfig.InputFileNames.assign(InputFileNames.begin(), InputFileNames.end());
+ BundlerConfig.OutputFileNames.assign(OutputFileNames.begin(), OutputFileNames.end());
/// The index of the host input in the list of inputs.
BundlerConfig.HostInputIndex = ~0u;
@@ -243,7 +243,7 @@ int main(int argc, const char **argv) {
s.insert(s.end(), InputFileNamesDeprecatedOpt.begin(),
InputFileNamesDeprecatedOpt.end());
}
- BundlerConfig.InputFileNames = InputFileNames;
+ BundlerConfig.InputFileNames.assign(InputFileNames.begin(), InputFileNames.end());
if (OutputFileNames.getNumOccurrences() != 0 &&
OutputFileNamesDeprecatedOpt.getNumOccurrences() != 0) {
@@ -259,7 +259,7 @@ int main(int argc, const char **argv) {
s.insert(s.end(), OutputFileNamesDeprecatedOpt.begin(),
OutputFileNamesDeprecatedOpt.end());
}
- BundlerConfig.OutputFileNames = OutputFileNames;
+ BundlerConfig.OutputFileNames.assign(OutputFileNames.begin(), OutputFileNames.end());
if (ListBundleIDs) {
if (Unbundle) {
@@ -395,7 +395,7 @@ int main(int argc, const char **argv) {
++Index;
}
- BundlerConfig.TargetNames = StandardizedTargetNames;
+ BundlerConfig.TargetNames.assign(StandardizedTargetNames.begin(), StandardizedTargetNames.end());
for (const auto &TargetID : TargetIDs) {
if (auto ConflictingTID =
>From c38c52694fd43ea9169545fb157a4a4ce30e59d4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=F0=9F=8D=8CShawn?= <m18824909883 at 163.com>
Date: Wed, 15 Apr 2026 23:43:34 +0800
Subject: [PATCH 3/3] Fix formatting issues
---
.../clang-offload-bundler/ClangOffloadBundler.cpp | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp b/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
index fc49bd64e6970..40d77abe2ef7c 100644
--- a/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ b/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -185,8 +185,10 @@ int main(int argc, const char **argv) {
BundlerConfig.CompressionLevel = CompressionLevel;
BundlerConfig.TargetNames.assign(TargetNames.begin(), TargetNames.end());
- BundlerConfig.InputFileNames.assign(InputFileNames.begin(), InputFileNames.end());
- BundlerConfig.OutputFileNames.assign(OutputFileNames.begin(), OutputFileNames.end());
+ BundlerConfig.InputFileNames.assign(InputFileNames.begin(),
+ InputFileNames.end());
+ BundlerConfig.OutputFileNames.assign(OutputFileNames.begin(),
+ OutputFileNames.end());
/// The index of the host input in the list of inputs.
BundlerConfig.HostInputIndex = ~0u;
@@ -243,7 +245,8 @@ int main(int argc, const char **argv) {
s.insert(s.end(), InputFileNamesDeprecatedOpt.begin(),
InputFileNamesDeprecatedOpt.end());
}
- BundlerConfig.InputFileNames.assign(InputFileNames.begin(), InputFileNames.end());
+ BundlerConfig.InputFileNames.assign(InputFileNames.begin(),
+ InputFileNames.end());
if (OutputFileNames.getNumOccurrences() != 0 &&
OutputFileNamesDeprecatedOpt.getNumOccurrences() != 0) {
@@ -259,7 +262,8 @@ int main(int argc, const char **argv) {
s.insert(s.end(), OutputFileNamesDeprecatedOpt.begin(),
OutputFileNamesDeprecatedOpt.end());
}
- BundlerConfig.OutputFileNames.assign(OutputFileNames.begin(), OutputFileNames.end());
+ BundlerConfig.OutputFileNames.assign(OutputFileNames.begin(),
+ OutputFileNames.end());
if (ListBundleIDs) {
if (Unbundle) {
@@ -395,7 +399,8 @@ int main(int argc, const char **argv) {
++Index;
}
- BundlerConfig.TargetNames.assign(StandardizedTargetNames.begin(), StandardizedTargetNames.end());
+ BundlerConfig.TargetNames.assign(StandardizedTargetNames.begin(),
+ StandardizedTargetNames.end());
for (const auto &TargetID : TargetIDs) {
if (auto ConflictingTID =
More information about the cfe-commits
mailing list