[clang] [clang] Make makeInputArg available in Driver.h [NFC] (PR #182163)
Naveen Seth Hanig via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 18 14:01:46 PST 2026
https://github.com/naveen-seth created https://github.com/llvm/llvm-project/pull/182163
This moves makeInputArg from Driver.cpp to Driver.h so it can be used by other components.
This change is part of an effort to split #152770 into smaller, more manageable pieces.
>From 18b4fa81e178c18131f4a87469912a4c65bf7bde Mon Sep 17 00:00:00 2001
From: Naveen Seth Hanig <naveen.hanig at outlook.com>
Date: Wed, 18 Feb 2026 22:58:25 +0100
Subject: [PATCH] [clang] Make makeInputArg available in Driver.h
This moves makeInputArg from Driver.cpp to Driver.h so it can be used
by other components.
This change is part of an effort to split #152770 into smaller, more
manageable pieces.
---
clang/include/clang/Driver/Driver.h | 18 ++++++++++++------
clang/lib/Driver/Driver.cpp | 12 ++++++------
2 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/clang/include/clang/Driver/Driver.h b/clang/include/clang/Driver/Driver.h
index f7c138027bdae..b355ee6e15007 100644
--- a/clang/include/clang/Driver/Driver.h
+++ b/clang/include/clang/Driver/Driver.h
@@ -228,12 +228,6 @@ class Driver {
/// The file to log CC_LOG_DIAGNOSTICS output to, if enabled.
std::string CCLogDiagnosticsFilename;
- /// An input type and its arguments.
- using InputTy = std::pair<types::ID, const llvm::opt::Arg *>;
-
- /// A list of inputs and their types for the given arguments.
- using InputList = SmallVector<InputTy, 16>;
-
/// Whether the driver should follow g++ like behavior.
bool CCCIsCXX() const { return Mode == GXXMode; }
@@ -882,6 +876,18 @@ void applyOverrideOptions(SmallVectorImpl<const char *> &Args,
llvm::StringSet<> &SavedStrings, StringRef EnvVar,
raw_ostream *OS = nullptr);
+/// Creates and adds a synthesized input argument.
+///
+/// \param Args The argument list to append the input argument to.
+/// \param Opts The option table used to look up OPT_INPUT.
+/// \param Value The input to add, typically a filename.
+/// \param Claim Whether the newly created argument should be claimed.
+///
+/// \return The newly created input argument.
+llvm::opt::Arg *makeInputArg(llvm::opt::DerivedArgList &Args,
+ const llvm::opt::OptTable &Opts, StringRef Value,
+ bool Claim = true);
+
} // end namespace driver
} // end namespace clang
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index d7d744d1770b6..fe4fad520ba3a 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -421,8 +421,8 @@ Driver::executeProgram(llvm::ArrayRef<llvm::StringRef> Args) const {
return std::move(*OutputBuf);
}
-static Arg *MakeInputArg(DerivedArgList &Args, const OptTable &Opts,
- StringRef Value, bool Claim = true) {
+Arg *clang::driver::makeInputArg(DerivedArgList &Args, const OptTable &Opts,
+ StringRef Value, bool Claim) {
Arg *A = new Arg(Opts.getOption(options::OPT_INPUT), Value,
Args.getBaseArgs().MakeIndex(Value), Value.data());
Args.AddSynthesizedArg(A);
@@ -511,7 +511,7 @@ DerivedArgList *Driver::TranslateInputArgs(const InputArgList &Args) const {
if (A->getOption().matches(options::OPT__DASH_DASH)) {
A->claim();
for (StringRef Val : A->getValues())
- DAL->append(MakeInputArg(*DAL, Opts, Val, false));
+ DAL->append(makeInputArg(*DAL, Opts, Val, false));
continue;
}
@@ -3131,7 +3131,7 @@ void Driver::BuildInputs(const ToolChain &TC, DerivedArgList &Args,
StringRef Value = A->getValue();
if (DiagnoseInputExistence(Value, types::TY_C,
/*TypoCorrect=*/false)) {
- Arg *InputArg = MakeInputArg(Args, Opts, A->getValue());
+ Arg *InputArg = makeInputArg(Args, Opts, A->getValue());
Inputs.push_back(std::make_pair(types::TY_C, InputArg));
}
A->claim();
@@ -3139,7 +3139,7 @@ void Driver::BuildInputs(const ToolChain &TC, DerivedArgList &Args,
StringRef Value = A->getValue();
if (DiagnoseInputExistence(Value, types::TY_CXX,
/*TypoCorrect=*/false)) {
- Arg *InputArg = MakeInputArg(Args, Opts, A->getValue());
+ Arg *InputArg = makeInputArg(Args, Opts, A->getValue());
Inputs.push_back(std::make_pair(types::TY_CXX, InputArg));
}
A->claim();
@@ -3178,7 +3178,7 @@ void Driver::BuildInputs(const ToolChain &TC, DerivedArgList &Args,
if (CCCIsCPP() && Inputs.empty()) {
// If called as standalone preprocessor, stdin is processed
// if no other input is present.
- Arg *A = MakeInputArg(Args, Opts, "-");
+ Arg *A = makeInputArg(Args, Opts, "-");
Inputs.push_back(std::make_pair(types::TY_C, A));
}
}
More information about the cfe-commits
mailing list