Switch to BumpPtrAllocator for C-string storage (#6550)

This keeps the allocations cheap and simplifies the code. It was
inspired by the need to expand param files, but
no functionality changed yet.
This commit is contained in:
Chandler Carruth
2026-01-07 02:53:31 +00:00
committed by GitHub
parent 505b1c86b9
commit eecbb7e508
7 changed files with 34 additions and 44 deletions
+3 -2
View File
@@ -12,6 +12,7 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Allocator.h"
namespace Carbon {
@@ -44,7 +45,7 @@ auto StringRefContainsPointer(llvm::StringRef ref, const char* ptr) -> bool;
// lines to avoid extra allocations and growth passes.
auto BuildCStrArgs(llvm::StringRef tool_path,
llvm::ArrayRef<llvm::StringRef> args,
llvm::OwningArrayRef<char>& cstr_arg_storage)
llvm::BumpPtrAllocator& alloc)
-> llvm::SmallVector<const char*, 64>;
// An overload of `BuildCStrArgs` with the same core behavior as the above, but
@@ -61,7 +62,7 @@ auto BuildCStrArgs(llvm::StringRef tool_path,
auto BuildCStrArgs(llvm::StringRef tool_path,
llvm::ArrayRef<std::string> prefix_args,
llvm::ArrayRef<llvm::StringRef> args,
llvm::OwningArrayRef<char>& cstr_arg_storage)
llvm::BumpPtrAllocator& alloc)
-> llvm::SmallVector<const char*, 64>;
} // namespace Carbon