[llvm] 75de95d - [Option] Use llvm::interlaved (NFC) (#145642)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 25 07:58:44 PDT 2025
Author: Kazu Hirata
Date: 2025-06-25T07:58:40-07:00
New Revision: 75de95ddd28f1273779721ffff1b0cde28352931
URL: https://github.com/llvm/llvm-project/commit/75de95ddd28f1273779721ffff1b0cde28352931
DIFF: https://github.com/llvm/llvm-project/commit/75de95ddd28f1273779721ffff1b0cde28352931.diff
LOG: [Option] Use llvm::interlaved (NFC) (#145642)
Note that llvm::interleaved constructs a string with the elements from
a given range with a given separator.
Added:
Modified:
llvm/lib/Option/Arg.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Option/Arg.cpp b/llvm/lib/Option/Arg.cpp
index 2d52b947aaede..3aab7c0768e14 100644
--- a/llvm/lib/Option/Arg.cpp
+++ b/llvm/lib/Option/Arg.cpp
@@ -6,13 +6,14 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/Option/Arg.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Config/llvm-config.h"
-#include "llvm/Option/Arg.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Option/Option.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/InterleavedRange.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
@@ -72,13 +73,7 @@ std::string Arg::getAsString(const ArgList &Args) const {
ArgStringList ASL;
render(Args, ASL);
- for (ArgStringList::iterator
- it = ASL.begin(), ie = ASL.end(); it != ie; ++it) {
- if (it != ASL.begin())
- OS << ' ';
- OS << *it;
- }
-
+ OS << llvm::interleaved(ASL, " ");
return std::string(OS.str());
}
@@ -100,11 +95,7 @@ void Arg::render(const ArgList &Args, ArgStringList &Output) const {
case Option::RenderCommaJoinedStyle: {
SmallString<256> Res;
raw_svector_ostream OS(Res);
- OS << getSpelling();
- for (unsigned i = 0, e = getNumValues(); i != e; ++i) {
- if (i) OS << ',';
- OS << getValue(i);
- }
+ OS << getSpelling() << llvm::interleaved(getValues(), ",");
Output.push_back(Args.MakeArgString(OS.str()));
break;
}
More information about the llvm-commits
mailing list