Reland "[clang] Refactor option-related code from clangDriver into new clangOptions library" (#167374)

This relands #167348.

The original PR was reverted due to a reported build failure, which was
later diagnosed as a local issue in the developer’s checkout or build
state. See discussion here:
https://github.com/llvm/llvm-project/pull/163659#discussion_r2511546964

No additional changes have been made in this reland.
This commit is contained in:
Naveen Seth Hanig 2025-11-10 21:24:39 +01:00 committed by GitHub
parent f2f04c363c
commit f63d33da0a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
118 changed files with 590 additions and 610 deletions

View File

@ -165,6 +165,7 @@ clang_target_link_libraries(clangDaemon
clangBasic
clangDependencyScanning
clangDriver
clangOptions
clangFormat
clangFrontend
clangIndex

View File

@ -11,8 +11,8 @@
#include "support/Logger.h"
#include "support/Trace.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Frontend/CompilerInvocation.h"
#include "clang/Options/Options.h"
#include "clang/Tooling/CompilationDatabase.h"
#include "clang/Tooling/Tooling.h"
#include "llvm/ADT/ArrayRef.h"
@ -206,7 +206,7 @@ void CommandMangler::operator()(tooling::CompileCommand &Command,
if (Cmd.empty())
return;
auto &OptTable = clang::driver::getDriverOptTable();
auto &OptTable = getDriverOptTable();
// OriginalArgs needs to outlive ArgList.
llvm::SmallVector<const char *, 16> OriginalArgs;
OriginalArgs.reserve(Cmd.size());
@ -222,8 +222,8 @@ void CommandMangler::operator()(tooling::CompileCommand &Command,
llvm::opt::InputArgList ArgList;
ArgList = OptTable.ParseArgs(
llvm::ArrayRef(OriginalArgs).drop_front(), IgnoredCount, IgnoredCount,
llvm::opt::Visibility(IsCLMode ? driver::options::CLOption
: driver::options::ClangOption));
llvm::opt::Visibility(IsCLMode ? options::CLOption
: options::ClangOption));
llvm::SmallVector<unsigned, 1> IndicesToDrop;
// Having multiple architecture options (e.g. when building fat binaries)
@ -232,7 +232,7 @@ void CommandMangler::operator()(tooling::CompileCommand &Command,
// As there are no signals to figure out which one user actually wants. They
// can explicitly specify one through `CompileFlags.Add` if need be.
unsigned ArchOptCount = 0;
for (auto *Input : ArgList.filtered(driver::options::OPT_arch)) {
for (auto *Input : ArgList.filtered(options::OPT_arch)) {
++ArchOptCount;
for (auto I = 0U; I <= Input->getNumValues(); ++I)
IndicesToDrop.push_back(Input->getIndex() + I);
@ -262,13 +262,12 @@ void CommandMangler::operator()(tooling::CompileCommand &Command,
// explicitly at the end of the flags. This ensures modifications done in the
// following steps apply in more cases (like setting -x, which only affects
// inputs that come after it).
for (auto *Input : ArgList.filtered(driver::options::OPT_INPUT)) {
for (auto *Input : ArgList.filtered(options::OPT_INPUT)) {
SawInput(Input->getValue(0));
IndicesToDrop.push_back(Input->getIndex());
}
// Anything after `--` is also treated as input, drop them as well.
if (auto *DashDash =
ArgList.getLastArgNoClaim(driver::options::OPT__DASH_DASH)) {
if (auto *DashDash = ArgList.getLastArgNoClaim(options::OPT__DASH_DASH)) {
auto DashDashIndex = DashDash->getIndex() + 1; // +1 accounts for Cmd[0]
// Another +1 so we don't treat the `--` itself as an input.
for (unsigned I = DashDashIndex + 1; I < Cmd.size(); ++I)
@ -424,11 +423,11 @@ DriverMode getDriverMode(const std::vector<std::string> &Args) {
// Returns the set of DriverModes where an option may be used.
unsigned char getModes(const llvm::opt::Option &Opt) {
unsigned char Result = DM_None;
if (Opt.hasVisibilityFlag(driver::options::ClangOption))
if (Opt.hasVisibilityFlag(options::ClangOption))
Result |= DM_GCC;
if (Opt.hasVisibilityFlag(driver::options::CC1Option))
if (Opt.hasVisibilityFlag(options::CC1Option))
Result |= DM_CC1;
if (Opt.hasVisibilityFlag(driver::options::CLOption))
if (Opt.hasVisibilityFlag(options::CLOption))
Result |= DM_CL;
return Result;
}
@ -442,8 +441,8 @@ llvm::ArrayRef<ArgStripper::Rule> ArgStripper::rulesFor(llvm::StringRef Arg) {
using TableTy =
llvm::StringMap<llvm::SmallVector<Rule, 4>, llvm::BumpPtrAllocator>;
static TableTy *Table = [] {
auto &DriverTable = driver::getDriverOptTable();
using DriverID = clang::driver::options::ID;
auto &DriverTable = getDriverOptTable();
using DriverID = clang::options::ID;
// Collect sets of aliases, so we can treat -foo and -foo= as synonyms.
// Conceptually a double-linked list: PrevAlias[I] -> I -> NextAlias[I].
@ -468,7 +467,7 @@ llvm::ArrayRef<ArgStripper::Rule> ArgStripper::rulesFor(llvm::StringRef Arg) {
FLAGS, VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, \
METAVAR, VALUES, SUBCOMMANDIDS_OFFSET) \
{DriverID::OPT_##ID, DriverID::OPT_##ALIAS, ALIASARGS},
#include "clang/Driver/Options.inc"
#include "clang/Options/Options.inc"
#undef OPTION
};
for (auto &E : AliasTable)

View File

@ -20,6 +20,7 @@ clang_target_link_libraries(modularize
clangAST
clangBasic
clangDriver
clangOptions
clangFrontend
clangLex
clangSerialization

View File

@ -50,18 +50,18 @@
//
//===----------------------------------------------------------------------===//
#include "CoverageChecker.h"
#include "ModularizeUtilities.h"
#include "clang/AST/ASTConsumer.h"
#include "CoverageChecker.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Driver/Options.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/FrontendAction.h"
#include "clang/Frontend/FrontendActions.h"
#include "clang/Lex/PPCallbacks.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Options/Options.h"
#include "clang/Tooling/CompilationDatabase.h"
#include "clang/Tooling/Tooling.h"
#include "llvm/Option/Option.h"
@ -73,7 +73,7 @@
using namespace Modularize;
using namespace clang;
using namespace clang::driver;
using namespace clang::driver::options;
using namespace clang::options;
using namespace clang::tooling;
namespace cl = llvm::cl;
namespace sys = llvm::sys;

View File

@ -231,11 +231,11 @@
#include "clang/AST/ASTContext.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Driver/Options.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/FrontendAction.h"
#include "clang/Frontend/FrontendActions.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Options/Options.h"
#include "clang/Tooling/CompilationDatabase.h"
#include "clang/Tooling/Tooling.h"
#include "llvm/Option/Arg.h"
@ -254,7 +254,7 @@
using namespace clang;
using namespace clang::driver;
using namespace clang::driver::options;
using namespace clang::options;
using namespace clang::tooling;
using namespace llvm;
using namespace llvm::opt;

View File

@ -12,17 +12,17 @@
//
//===----------------------------------------------------------------------===//
#include "ModularizeUtilities.h"
#include "CoverageChecker.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Driver/Options.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/FrontendActions.h"
#include "CoverageChecker.h"
#include "clang/Options/Options.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/FileUtilities.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
#include "ModularizeUtilities.h"
using namespace clang;
using namespace llvm;

View File

@ -14,6 +14,7 @@ clang_target_link_libraries(pp-trace
PRIVATE
clangAST
clangBasic
clangOptions
clangFrontend
clangLex
clangSerialization

View File

@ -28,11 +28,11 @@
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Driver/Options.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/FrontendAction.h"
#include "clang/Frontend/FrontendActions.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Options/Options.h"
#include "clang/Tooling/Execution.h"
#include "clang/Tooling/Tooling.h"
#include "llvm/Option/Arg.h"

View File

@ -132,7 +132,7 @@ if (LLVM_ENABLE_SPHINX)
# Generated files
gen_rst_file_from_td(AttributeReference.rst -gen-attr-docs ../include/clang/Basic/Attr.td "${docs_targets}")
gen_rst_file_from_td(DiagnosticsReference.rst -gen-diag-docs ../include/clang/Basic/Diagnostic.td "${docs_targets}")
gen_rst_file_from_td(ClangCommandLineReference.rst -gen-opt-docs ../include/clang/Driver/ClangOptionDocs.td "${docs_targets}")
gen_rst_file_from_td(ClangCommandLineReference.rst -gen-opt-docs ../include/clang/Options/ClangOptionDocs.td "${docs_targets}")
# Another generated file from a different source
set(docs_tools_dir ${CMAKE_CURRENT_SOURCE_DIR}/tools)

View File

@ -667,7 +667,7 @@ Command Line Interface
----------------------
The command line interface of the Clang ``-cc1`` frontend is defined alongside
the driver options in ``clang/Driver/Options.td``. The information making up an
the driver options in ``clang/Options/Options.td``. The information making up an
option definition includes its prefix and name (for example ``-std=``), form and
position of the option value, help text, aliases and more. Each option may
belong to a certain group and can be marked with zero or more flags. Options
@ -712,7 +712,7 @@ variable for the option value:
}
Next, declare the command line interface of the option in the tablegen file
``clang/include/clang/Driver/Options.td``. This is done by instantiating the
``clang/include/clang/Options/Options.td``. This is done by instantiating the
``Option`` class (defined in ``llvm/include/llvm/Option/OptParser.td``). The
instance is typically created through one of the helper classes that encode the
acceptable ways to specify the option value on the command line:
@ -906,7 +906,7 @@ command line:
SHOULD_PARSE, KEYPATH, DEFAULT_VALUE, \
IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, \
MERGER, TABLE_INDEX)
#include "clang/Driver/Options.inc"
#include "clang/Options/Options.inc"
#undef LANG_OPTION_WITH_MARSHALLING
// ...
@ -925,7 +925,7 @@ command line:
GENERATE_OPTION_WITH_MARSHALLING( \
Args, SA, KIND, FLAGS, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE, \
IMPLIED_CHECK, IMPLIED_VALUE, DENORMALIZER, EXTRACTOR, TABLE_INDEX)
#include "clang/Driver/Options.inc"
#include "clang/Options/Options.inc"
#undef LANG_OPTION_WITH_MARSHALLING
// ...

View File

@ -79,6 +79,9 @@ Potentially Breaking Changes
void foo(void) {
return ({ 1;; });
}
- Downstream projects that previously linked only against ``clangDriver`` may
now (also) need to link against the new ``clangOptions`` library, since
options-related code has been moved out of the Driver into a separate library.
C/C++ Language Potentially Breaking Changes
-------------------------------------------

View File

@ -3,7 +3,7 @@ add_subdirectory(Basic)
if(CLANG_ENABLE_CIR)
add_subdirectory(CIR)
endif()
add_subdirectory(Driver)
add_subdirectory(Options)
add_subdirectory(Parse)
add_subdirectory(Sema)
add_subdirectory(Serialization)

View File

@ -15,11 +15,11 @@
#include "clang/Driver/Action.h"
#include "clang/Driver/DriverDiagnostic.h"
#include "clang/Driver/InputInfo.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/Phases.h"
#include "clang/Driver/ToolChain.h"
#include "clang/Driver/Types.h"
#include "clang/Driver/Util.h"
#include "clang/Options/Options.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLFunctionalExtras.h"
#include "llvm/ADT/StringMap.h"

View File

@ -15,8 +15,8 @@
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/LLVM.h"
#include "clang/Driver/OptionUtils.h"
#include "clang/Frontend/DependencyOutputOptions.h"
#include "clang/Options/OptionUtils.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/StringMap.h"

View File

@ -10,8 +10,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_DRIVER_OPTIONUTILS_H
#define LLVM_CLANG_DRIVER_OPTIONUTILS_H
#ifndef LLVM_CLANG_OPTIONS_OPTIONUTILS_H
#define LLVM_CLANG_OPTIONS_OPTIONUTILS_H
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/LLVM.h"
@ -55,4 +55,4 @@ inline uint64_t getLastArgUInt64Value(const llvm::opt::ArgList &Args,
} // namespace clang
#endif // LLVM_CLANG_DRIVER_OPTIONUTILS_H
#endif // LLVM_CLANG_OPTIONS_OPTIONUTILS_H

View File

@ -6,14 +6,13 @@
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_DRIVER_OPTIONS_H
#define LLVM_CLANG_DRIVER_OPTIONS_H
#ifndef LLVM_CLANG_OPTIONS_OPTIONS_H
#define LLVM_CLANG_OPTIONS_OPTIONS_H
#include "llvm/Option/OptTable.h"
#include "llvm/Option/Option.h"
namespace clang {
namespace driver {
namespace options {
/// Flags specifically for clang options. Must not overlap with
@ -42,16 +41,15 @@ enum ClangVisibility {
};
enum ID {
OPT_INVALID = 0, // This is not an option ID.
OPT_INVALID = 0, // This is not an option ID.
#define OPTION(...) LLVM_MAKE_OPT_ID(__VA_ARGS__),
#include "clang/Driver/Options.inc"
LastOption
#include "clang/Options/Options.inc"
LastOption
#undef OPTION
};
}
};
} // namespace options
const llvm::opt::OptTable &getDriverOptTable();
}
}
} // namespace clang
#endif
#endif // LLVM_CLANG_OPTIONS_OPTIONS_H

View File

@ -146,6 +146,7 @@ module Clang_Lex {
module * { export * }
}
module Clang_Options { requires cplusplus umbrella "clang/Options" module * { export * } }
module Clang_Parse { requires cplusplus umbrella "clang/Parse" module * { export * } }
module Clang_Rewrite { requires cplusplus umbrella "clang/Rewrite/Core" module * { export * } }
module Clang_RewriteFrontend { requires cplusplus umbrella "clang/Rewrite/Frontend" module * { export * } }

View File

@ -13,6 +13,7 @@ add_subdirectory(Edit)
add_subdirectory(ExtractAPI)
add_subdirectory(Rewrite)
add_subdirectory(Driver)
add_subdirectory(Options)
add_subdirectory(Serialization)
add_subdirectory(Frontend)
add_subdirectory(FrontendTool)

View File

@ -19,12 +19,10 @@ add_clang_library(clangDriver
Compilation.cpp
Distro.cpp
Driver.cpp
DriverOptions.cpp
Job.cpp
Multilib.cpp
MultilibBuilder.cpp
OffloadBundler.cpp
OptionUtils.cpp
Phases.cpp
SanitizerArgs.cpp
Tool.cpp
@ -99,5 +97,6 @@ add_clang_library(clangDriver
LINK_LIBS
clangBasic
clangLex
clangOptions
${system_libs}
)

View File

@ -11,9 +11,9 @@
#include "clang/Driver/Action.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Job.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/ToolChain.h"
#include "clang/Driver/Util.h"
#include "clang/Options/Options.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Option/OptSpecifier.h"
#include "llvm/Option/Option.h"

View File

@ -60,13 +60,13 @@
#include "clang/Driver/Compilation.h"
#include "clang/Driver/InputInfo.h"
#include "clang/Driver/Job.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/Phases.h"
#include "clang/Driver/SanitizerArgs.h"
#include "clang/Driver/Tool.h"
#include "clang/Driver/ToolChain.h"
#include "clang/Driver/Types.h"
#include "clang/Lex/DependencyDirectivesScanner.h"
#include "clang/Options/Options.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallSet.h"

View File

@ -8,8 +8,8 @@
#include "clang/Driver/SanitizerArgs.h"
#include "clang/Basic/Sanitizers.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/ToolChain.h"
#include "clang/Options/Options.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"

View File

@ -21,9 +21,9 @@
#include "clang/Driver/Driver.h"
#include "clang/Driver/InputInfo.h"
#include "clang/Driver/Job.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/SanitizerArgs.h"
#include "clang/Driver/XRayArgs.h"
#include "clang/Options/Options.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
@ -338,7 +338,7 @@ static void getRISCVMultilibFlags(const Driver &D, const llvm::Triple &Triple,
Multilib::flags_list
ToolChain::getMultilibFlags(const llvm::opt::ArgList &Args) const {
using namespace clang::driver::options;
using namespace clang::options;
std::vector<std::string> Result;
const llvm::Triple Triple(ComputeEffectiveClangTriple(Args));
@ -1805,7 +1805,7 @@ void ToolChain::TranslateXarchArgs(
unsigned Index = BaseArgs.MakeIndex(A->getValue(ValuePos));
unsigned Prev = Index;
std::unique_ptr<llvm::opt::Arg> XarchArg(Opts.ParseOneArg(
Args, Index, llvm::opt::Visibility(clang::driver::options::ClangOption)));
Args, Index, llvm::opt::Visibility(options::ClangOption)));
// If the argument parsing failed or more than one argument was
// consumed, the -Xarch_ argument's parameter tried to consume

View File

@ -9,8 +9,8 @@
#include "AIX.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/SanitizerArgs.h"
#include "clang/Options/Options.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Option/ArgList.h"
#include "llvm/ProfileData/InstrProf.h"
@ -19,6 +19,7 @@
#include <set>
using AIX = clang::driver::toolchains::AIX;
using namespace clang;
using namespace clang::driver;
using namespace clang::driver::tools;
using namespace clang::driver::toolchains;
@ -167,8 +168,7 @@ void aix::Linker::ConstructJob(Compilation &C, const JobAction &JA,
Args.hasArg(options::OPT_coverage))
CmdArgs.push_back("-bdbg:namedsects:ss");
if (Arg *A =
Args.getLastArg(clang::driver::options::OPT_mxcoff_build_id_EQ)) {
if (Arg *A = Args.getLastArg(options::OPT_mxcoff_build_id_EQ)) {
StringRef BuildId = A->getValue();
if (BuildId[0] != '0' || BuildId[1] != 'x' ||
BuildId.find_if_not(llvm::isHexDigit, 2) != StringRef::npos)

View File

@ -12,8 +12,8 @@
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/InputInfo.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/SanitizerArgs.h"
#include "clang/Options/Options.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/Error.h"
@ -323,27 +323,24 @@ RocmInstallationDetector::RocmInstallationDetector(
const llvm::opt::ArgList &Args, bool DetectHIPRuntime, bool DetectDeviceLib)
: D(D) {
Verbose = Args.hasArg(options::OPT_v);
RocmPathArg = Args.getLastArgValue(clang::driver::options::OPT_rocm_path_EQ);
PrintROCmSearchDirs =
Args.hasArg(clang::driver::options::OPT_print_rocm_search_dirs);
RocmPathArg = Args.getLastArgValue(options::OPT_rocm_path_EQ);
PrintROCmSearchDirs = Args.hasArg(options::OPT_print_rocm_search_dirs);
RocmDeviceLibPathArg =
Args.getAllArgValues(clang::driver::options::OPT_rocm_device_lib_path_EQ);
HIPPathArg = Args.getLastArgValue(clang::driver::options::OPT_hip_path_EQ);
HIPStdParPathArg =
Args.getLastArgValue(clang::driver::options::OPT_hipstdpar_path_EQ);
Args.getAllArgValues(options::OPT_rocm_device_lib_path_EQ);
HIPPathArg = Args.getLastArgValue(options::OPT_hip_path_EQ);
HIPStdParPathArg = Args.getLastArgValue(options::OPT_hipstdpar_path_EQ);
HasHIPStdParLibrary =
!HIPStdParPathArg.empty() && D.getVFS().exists(HIPStdParPathArg +
"/hipstdpar_lib.hpp");
HIPRocThrustPathArg =
Args.getLastArgValue(clang::driver::options::OPT_hipstdpar_thrust_path_EQ);
Args.getLastArgValue(options::OPT_hipstdpar_thrust_path_EQ);
HasRocThrustLibrary = !HIPRocThrustPathArg.empty() &&
D.getVFS().exists(HIPRocThrustPathArg + "/thrust");
HIPRocPrimPathArg =
Args.getLastArgValue(clang::driver::options::OPT_hipstdpar_prim_path_EQ);
HIPRocPrimPathArg = Args.getLastArgValue(options::OPT_hipstdpar_prim_path_EQ);
HasRocPrimLibrary = !HIPRocPrimPathArg.empty() &&
D.getVFS().exists(HIPRocPrimPathArg + "/rocprim");
if (auto *A = Args.getLastArg(clang::driver::options::OPT_hip_version_EQ)) {
if (auto *A = Args.getLastArg(options::OPT_hip_version_EQ)) {
HIPVersionArg = A->getValue();
unsigned Major = ~0U;
unsigned Minor = ~0U;

View File

@ -11,9 +11,9 @@
#include "Gnu.h"
#include "clang/Basic/TargetID.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/Tool.h"
#include "clang/Driver/ToolChain.h"
#include "clang/Options/Options.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/TargetParser/TargetParser.h"

View File

@ -10,8 +10,8 @@
#include "AMDGPU.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/Tool.h"
#include "clang/Options/Options.h"
#include "llvm/ADT/STLExtras.h"
using namespace clang::driver;

View File

@ -10,7 +10,7 @@
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/InputInfo.h"
#include "clang/Driver/Options.h"
#include "clang/Options/Options.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"

View File

@ -9,7 +9,7 @@
#include "AArch64.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Options/Options.h"
#include "llvm/Option/ArgList.h"
#include "llvm/TargetParser/AArch64TargetParser.h"
#include "llvm/TargetParser/Host.h"
@ -222,7 +222,7 @@ void aarch64::getAArch64TargetFeatures(const Driver &D,
// Default to 'A' profile if the architecture is not specified.
success = getAArch64ArchFeaturesFromMarch(D, "armv8-a", Args, Extensions);
if (success && (A = Args.getLastArg(clang::driver::options::OPT_mtune_EQ)))
if (success && (A = Args.getLastArg(options::OPT_mtune_EQ)))
success =
getAArch64MicroArchFeaturesFromMtune(D, A->getValue(), Args, Features);
else if (success && (A = Args.getLastArg(options::OPT_mcpu_EQ)))

View File

@ -8,7 +8,7 @@
#include "ARM.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Options/Options.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Option/ArgList.h"
#include "llvm/TargetParser/ARMTargetParser.h"
@ -74,7 +74,7 @@ bool arm::isARMEABIBareMetal(const llvm::Triple &Triple) {
// Get Arch/CPU from args.
void arm::getARMArchCPUFromArgs(const ArgList &Args, llvm::StringRef &Arch,
llvm::StringRef &CPU, bool FromAs) {
if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_mcpu_EQ))
if (const Arg *A = Args.getLastArg(options::OPT_mcpu_EQ))
CPU = A->getValue();
if (const Arg *A = Args.getLastArg(options::OPT_march_EQ))
Arch = A->getValue();

View File

@ -8,7 +8,7 @@
#include "CSKY.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Options/Options.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Option/ArgList.h"
#include "llvm/TargetParser/CSKYTargetParser.h"
@ -33,7 +33,7 @@ csky::getCSKYArchName(const Driver &D, const ArgList &Args,
return std::optional<llvm::StringRef>(A->getValue());
}
if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_mcpu_EQ)) {
if (const Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
llvm::CSKY::ArchKind ArchKind = llvm::CSKY::parseCPUArch(A->getValue());
if (ArchKind == llvm::CSKY::ArchKind::INVALID) {
D.Diag(clang::diag::err_drv_clang_unsupported) << A->getAsString(Args);
@ -126,7 +126,7 @@ void csky::getCSKYTargetFeatures(const Driver &D, const llvm::Triple &Triple,
archName = A->getValue();
}
if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_mcpu_EQ)) {
if (const Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
llvm::CSKY::ArchKind Kind = llvm::CSKY::parseCPUArch(A->getValue());
if (Kind == llvm::CSKY::ArchKind::INVALID) {
D.Diag(clang::diag::err_drv_clang_unsupported) << A->getAsString(Args);

View File

@ -11,7 +11,7 @@
#include "clang/Basic/DiagnosticDriver.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Options/Options.h"
#include "llvm/TargetParser/Host.h"
#include "llvm/TargetParser/LoongArchTargetParser.h"
@ -130,8 +130,7 @@ void loongarch::getLoongArchTargetFeatures(const Driver &D,
const ArgList &Args,
std::vector<StringRef> &Features) {
// Enable the `lsx` feature on 64-bit LoongArch by default.
if (Triple.isLoongArch64() &&
(!Args.hasArgNoClaim(clang::driver::options::OPT_march_EQ)))
if (Triple.isLoongArch64() && (!Args.hasArgNoClaim(options::OPT_march_EQ)))
Features.push_back("+lsx");
// -mrelax is default, unless -mno-relax is specified.

View File

@ -8,7 +8,7 @@
#include "M68k.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Options/Options.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/Regex.h"
@ -21,7 +21,7 @@ using namespace llvm::opt;
/// getM68kTargetCPU - Get the (LLVM) name of the 68000 cpu we are targeting.
std::string m68k::getM68kTargetCPU(const ArgList &Args) {
if (Arg *A = Args.getLastArg(clang::driver::options::OPT_mcpu_EQ)) {
if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
// The canonical CPU name is captalize. However, we allow
// starting with lower case or numbers only
StringRef CPUName = A->getValue();
@ -45,17 +45,17 @@ std::string m68k::getM68kTargetCPU(const ArgList &Args) {
.Default(CPUName.str());
}
// FIXME: Throw error when multiple sub-architecture flag exist
if (Args.hasArg(clang::driver::options::OPT_m68000))
if (Args.hasArg(options::OPT_m68000))
return "M68000";
if (Args.hasArg(clang::driver::options::OPT_m68010))
if (Args.hasArg(options::OPT_m68010))
return "M68010";
if (Args.hasArg(clang::driver::options::OPT_m68020))
if (Args.hasArg(options::OPT_m68020))
return "M68020";
if (Args.hasArg(clang::driver::options::OPT_m68030))
if (Args.hasArg(options::OPT_m68030))
return "M68030";
if (Args.hasArg(clang::driver::options::OPT_m68040))
if (Args.hasArg(options::OPT_m68040))
return "M68040";
if (Args.hasArg(clang::driver::options::OPT_m68060))
if (Args.hasArg(options::OPT_m68060))
return "M68060";
return "";

View File

@ -9,7 +9,7 @@
#include "Mips.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Options/Options.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Option/ArgList.h"
@ -49,8 +49,7 @@ void mips::getMipsCPUAndABI(const ArgList &Args, const llvm::Triple &Triple,
DefMips64CPU = "mips3";
}
if (Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ,
options::OPT_mcpu_EQ))
if (Arg *A = Args.getLastArg(options::OPT_march_EQ, options::OPT_mcpu_EQ))
CPUName = A->getValue();
if (Arg *A = Args.getLastArg(options::OPT_mabi_EQ)) {

View File

@ -9,7 +9,7 @@
#include "PPC.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Options/Options.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Option/ArgList.h"
#include "llvm/TargetParser/Host.h"

View File

@ -10,7 +10,7 @@
#include "../Clang.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Options/Options.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/Error.h"
#include "llvm/TargetParser/Host.h"

View File

@ -8,7 +8,7 @@
#include "Sparc.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Options/Options.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Option/ArgList.h"
#include "llvm/TargetParser/Host.h"
@ -122,7 +122,7 @@ sparc::FloatABI sparc::getSparcFloatABI(const Driver &D,
std::string sparc::getSparcTargetCPU(const Driver &D, const ArgList &Args,
const llvm::Triple &Triple) {
if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_mcpu_EQ)) {
if (const Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
StringRef CPUName = A->getValue();
if (CPUName == "native") {
std::string CPU = std::string(llvm::sys::getHostCPUName());

View File

@ -8,7 +8,7 @@
#include "SystemZ.h"
#include "clang/Config/config.h"
#include "clang/Driver/Options.h"
#include "clang/Options/Options.h"
#include "llvm/Option/ArgList.h"
#include "llvm/TargetParser/Host.h"
@ -25,9 +25,9 @@ systemz::FloatABI systemz::getSystemZFloatABI(const Driver &D,
D.Diag(diag::err_drv_unsupported_opt)
<< Args.getLastArg(options::OPT_mfloat_abi_EQ)->getAsString(Args);
if (Arg *A = Args.getLastArg(clang::driver::options::OPT_msoft_float,
options::OPT_mhard_float))
if (A->getOption().matches(clang::driver::options::OPT_msoft_float))
if (Arg *A =
Args.getLastArg(options::OPT_msoft_float, options::OPT_mhard_float))
if (A->getOption().matches(options::OPT_msoft_float))
ABI = systemz::FloatABI::Soft;
return ABI;
@ -35,7 +35,7 @@ systemz::FloatABI systemz::getSystemZFloatABI(const Driver &D,
std::string systemz::getSystemZTargetCPU(const ArgList &Args,
const llvm::Triple &T) {
if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) {
if (const Arg *A = Args.getLastArg(options::OPT_march_EQ)) {
llvm::StringRef CPUName = A->getValue();
if (CPUName == "native") {

View File

@ -8,7 +8,7 @@
#include "VE.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Options/Options.h"
#include "llvm/Option/ArgList.h"
using namespace clang::driver;

View File

@ -8,7 +8,7 @@
#include "X86.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Options/Options.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/Option/ArgList.h"
@ -21,7 +21,7 @@ using namespace llvm::opt;
std::string x86::getX86TargetCPU(const Driver &D, const ArgList &Args,
const llvm::Triple &Triple) {
if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) {
if (const Arg *A = Args.getLastArg(options::OPT_march_EQ)) {
StringRef CPU = A->getValue();
if (CPU != "native")
return std::string(CPU);
@ -119,7 +119,7 @@ void x86::getX86TargetFeatures(const Driver &D, const llvm::Triple &Triple,
std::vector<StringRef> &Features) {
// Claim and report unsupported -mabi=. Note: we don't support "sysv_abi" or
// "ms_abi" as default function attributes.
if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_mabi_EQ)) {
if (const Arg *A = Args.getLastArg(options::OPT_mabi_EQ)) {
StringRef DefaultAbi =
(Triple.isOSWindows() || Triple.isUEFI()) ? "ms" : "sysv";
if (A->getValue() != DefaultAbi)
@ -128,7 +128,7 @@ void x86::getX86TargetFeatures(const Driver &D, const llvm::Triple &Triple,
}
// If -march=native, autodetect the feature list.
if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) {
if (const Arg *A = Args.getLastArg(options::OPT_march_EQ)) {
if (StringRef(A->getValue()) == "native") {
for (auto &F : llvm::sys::getHostCPUFeatures())
Features.push_back(
@ -163,7 +163,7 @@ void x86::getX86TargetFeatures(const Driver &D, const llvm::Triple &Triple,
// flags). This is a bit hacky but keeps existing usages working. We should
// consider deprecating this and instead warn if the user requests external
// retpoline thunks and *doesn't* request some form of retpolines.
auto SpectreOpt = clang::driver::options::ID::OPT_INVALID;
auto SpectreOpt = options::ID::OPT_INVALID;
if (Args.hasArgNoClaim(options::OPT_mretpoline, options::OPT_mno_retpoline,
options::OPT_mspeculative_load_hardening,
options::OPT_mno_speculative_load_hardening)) {
@ -189,7 +189,7 @@ void x86::getX86TargetFeatures(const Driver &D, const llvm::Triple &Triple,
SpectreOpt = options::OPT_mretpoline_external_thunk;
}
auto LVIOpt = clang::driver::options::ID::OPT_INVALID;
auto LVIOpt = options::ID::OPT_INVALID;
if (Args.hasFlag(options::OPT_mlvi_hardening, options::OPT_mno_lvi_hardening,
false)) {
Features.push_back("+lvi-load-hardening");
@ -207,7 +207,7 @@ void x86::getX86TargetFeatures(const Driver &D, const llvm::Triple &Triple,
<< D.getOpts().getOptionName(options::OPT_mlvi_hardening)
<< D.getOpts().getOptionName(options::OPT_m_seses);
if (SpectreOpt != clang::driver::options::ID::OPT_INVALID)
if (SpectreOpt != options::ID::OPT_INVALID)
D.Diag(diag::err_drv_argument_not_allowed_with)
<< D.getOpts().getOptionName(SpectreOpt)
<< D.getOpts().getOptionName(options::OPT_m_seses);
@ -219,8 +219,8 @@ void x86::getX86TargetFeatures(const Driver &D, const llvm::Triple &Triple,
}
}
if (SpectreOpt != clang::driver::options::ID::OPT_INVALID &&
LVIOpt != clang::driver::options::ID::OPT_INVALID) {
if (SpectreOpt != options::ID::OPT_INVALID &&
LVIOpt != options::ID::OPT_INVALID) {
D.Diag(diag::err_drv_argument_not_allowed_with)
<< D.getOpts().getOptionName(SpectreOpt)
<< D.getOpts().getOptionName(LVIOpt);

View File

@ -18,7 +18,7 @@
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/MultilibBuilder.h"
#include "clang/Driver/Options.h"
#include "clang/Options/Options.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/Path.h"
@ -135,7 +135,7 @@ static std::string computeClangRuntimesSysRoot(const Driver &D,
bool BareMetal::initGCCInstallation(const llvm::Triple &Triple,
const llvm::opt::ArgList &Args) {
if (Args.getLastArg(options::OPT_gcc_toolchain) ||
Args.getLastArg(clang::driver::options::OPT_gcc_install_dir_EQ)) {
Args.getLastArg(clang::options::OPT_gcc_install_dir_EQ)) {
GCCInstallation.init(Triple, Args);
return GCCInstallation.isValid();
}

View File

@ -10,7 +10,7 @@
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/InputInfo.h"
#include "clang/Driver/Options.h"
#include "clang/Options/Options.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"

View File

@ -29,10 +29,10 @@
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Distro.h"
#include "clang/Driver/InputInfo.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/SanitizerArgs.h"
#include "clang/Driver/Types.h"
#include "clang/Driver/XRayArgs.h"
#include "clang/Options/Options.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/StringExtras.h"
@ -65,7 +65,7 @@ using namespace clang;
using namespace llvm::opt;
static void CheckPreprocessingOptions(const Driver &D, const ArgList &Args) {
if (Arg *A = Args.getLastArg(clang::driver::options::OPT_C, options::OPT_CC,
if (Arg *A = Args.getLastArg(options::OPT_C, options::OPT_CC,
options::OPT_fminimize_whitespace,
options::OPT_fno_minimize_whitespace,
options::OPT_fkeep_system_includes,
@ -1661,7 +1661,7 @@ void Clang::AddAArch64TargetArgs(const ArgList &Args,
AddAAPCSVolatileBitfieldArgs(Args, CmdArgs);
if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_mtune_EQ)) {
if (const Arg *A = Args.getLastArg(options::OPT_mtune_EQ)) {
CmdArgs.push_back("-tune-cpu");
if (strcmp(A->getValue(), "native") == 0)
CmdArgs.push_back(Args.MakeArgString(llvm::sys::getHostCPUName()));
@ -2067,7 +2067,7 @@ void Clang::AddSparcTargetArgs(const ArgList &Args,
CmdArgs.push_back("hard");
}
if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_mtune_EQ)) {
if (const Arg *A = Args.getLastArg(options::OPT_mtune_EQ)) {
StringRef Name = A->getValue();
std::string TuneCPU;
if (Name == "native")
@ -2173,12 +2173,11 @@ void Clang::AddX86TargetArgs(const ArgList &Args,
// Default to "generic" unless -march is present or targetting the PS4/PS5.
std::string TuneCPU;
if (!Args.hasArg(clang::driver::options::OPT_march_EQ) &&
!getToolChain().getTriple().isPS())
if (!Args.hasArg(options::OPT_march_EQ) && !getToolChain().getTriple().isPS())
TuneCPU = "generic";
// Override based on -mtune.
if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_mtune_EQ)) {
if (const Arg *A = Args.getLastArg(options::OPT_mtune_EQ)) {
StringRef Name = A->getValue();
if (Name == "native") {

View File

@ -31,11 +31,11 @@
#include "clang/Driver/Driver.h"
#include "clang/Driver/InputInfo.h"
#include "clang/Driver/Job.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/SanitizerArgs.h"
#include "clang/Driver/ToolChain.h"
#include "clang/Driver/Util.h"
#include "clang/Driver/XRayArgs.h"
#include "clang/Options/Options.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallString.h"
@ -69,8 +69,7 @@ using namespace llvm::opt;
static bool useFramePointerForTargetByDefault(const llvm::opt::ArgList &Args,
const llvm::Triple &Triple) {
if (Args.hasArg(clang::driver::options::OPT_pg) &&
!Args.hasArg(clang::driver::options::OPT_mfentry))
if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
return true;
if (Triple.isAndroid())
@ -249,17 +248,16 @@ getFramePointerKind(const llvm::opt::ArgList &Args,
// without requiring new frame records to be created.
bool DefaultFP = useFramePointerForTargetByDefault(Args, Triple);
bool EnableFP =
mustUseNonLeafFramePointerForTarget(Triple) ||
Args.hasFlag(clang::driver::options::OPT_fno_omit_frame_pointer,
clang::driver::options::OPT_fomit_frame_pointer, DefaultFP);
bool EnableFP = mustUseNonLeafFramePointerForTarget(Triple) ||
Args.hasFlag(options::OPT_fno_omit_frame_pointer,
options::OPT_fomit_frame_pointer, DefaultFP);
bool DefaultLeafFP =
useLeafFramePointerForTargetByDefault(Triple) ||
(EnableFP && framePointerImpliesLeafFramePointer(Args, Triple));
bool EnableLeafFP = Args.hasFlag(
clang::driver::options::OPT_mno_omit_leaf_frame_pointer,
clang::driver::options::OPT_momit_leaf_frame_pointer, DefaultLeafFP);
bool EnableLeafFP =
Args.hasFlag(options::OPT_mno_omit_leaf_frame_pointer,
options::OPT_momit_leaf_frame_pointer, DefaultLeafFP);
bool FPRegReserved = EnableFP || mustMaintainValidFrameChain(Args, Triple);
@ -753,7 +751,7 @@ std::string tools::getCPUName(const Driver &D, const ArgList &Args,
case llvm::Triple::ppcle:
case llvm::Triple::ppc64:
case llvm::Triple::ppc64le:
if (Arg *A = Args.getLastArg(clang::driver::options::OPT_mcpu_EQ))
if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ))
return std::string(
llvm::PPC::getNormalizedPPCTargetCPU(T, A->getValue()));
return std::string(llvm::PPC::getNormalizedPPCTargetCPU(T));
@ -1733,7 +1731,7 @@ bool tools::addSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
if (SanArgs.needsFuzzerInterceptors())
addSanitizerRuntime(TC, Args, CmdArgs, "fuzzer_interceptors", false,
true);
if (!Args.hasArg(clang::driver::options::OPT_nostdlibxx)) {
if (!Args.hasArg(options::OPT_nostdlibxx)) {
bool OnlyLibstdcxxStatic = Args.hasArg(options::OPT_static_libstdcxx) &&
!Args.hasArg(options::OPT_static);
if (OnlyLibstdcxxStatic)
@ -3385,7 +3383,7 @@ void tools::handleInterchangeLoopsArgs(const ArgList &Args,
// Otherwise, return an empty string and issue a diagnosic message if needed.
StringRef tools::parseMPreferVectorWidthOption(clang::DiagnosticsEngine &Diags,
const llvm::opt::ArgList &Args) {
Arg *A = Args.getLastArg(clang::driver::options::OPT_mprefer_vector_width_EQ);
Arg *A = Args.getLastArg(options::OPT_mprefer_vector_width_EQ);
if (!A)
return "";

View File

@ -10,8 +10,8 @@
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/SanitizerArgs.h"
#include "clang/Options/Options.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/Path.h"

View File

@ -14,7 +14,7 @@
#include "clang/Driver/Distro.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/InputInfo.h"
#include "clang/Driver/Options.h"
#include "clang/Options/Options.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Config/llvm-config.h" // for LLVM_HOST_TRIPLE
#include "llvm/Option/ArgList.h"
@ -153,16 +153,16 @@ CudaInstallationDetector::CudaInstallationDetector(
std::initializer_list<const char *> Versions = {"8.0", "7.5", "7.0"};
auto &FS = D.getVFS();
if (Args.hasArg(clang::driver::options::OPT_cuda_path_EQ)) {
if (Args.hasArg(options::OPT_cuda_path_EQ)) {
Candidates.emplace_back(
Args.getLastArgValue(clang::driver::options::OPT_cuda_path_EQ).str());
Args.getLastArgValue(options::OPT_cuda_path_EQ).str());
} else if (HostTriple.isOSWindows()) {
for (const char *Ver : Versions)
Candidates.emplace_back(
D.SysRoot + "/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v" +
Ver);
} else {
if (!Args.hasArg(clang::driver::options::OPT_cuda_path_ignore_env)) {
if (!Args.hasArg(options::OPT_cuda_path_ignore_env)) {
// Try to find ptxas binary. If the executable is located in a directory
// called 'bin/', its parent directory might be a good guess for a valid
// CUDA installation.

View File

@ -10,7 +10,7 @@
#include "clang/Config/config.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Options/Options.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/VirtualFileSystem.h"
@ -58,7 +58,7 @@ void Cygwin::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
const Driver &D = getDriver();
std::string SysRoot = computeSysRoot();
if (DriverArgs.hasArg(clang::driver::options::OPT_nostdinc))
if (DriverArgs.hasArg(options::OPT_nostdinc))
return;
if (!DriverArgs.hasArg(options::OPT_nostdlibinc))

View File

@ -14,8 +14,8 @@
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/SanitizerArgs.h"
#include "clang/Options/Options.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Option/ArgList.h"
#include "llvm/ProfileData/InstrProf.h"
@ -1079,7 +1079,7 @@ StringRef MachO::getMachOArchName(const ArgList &Args) const {
case llvm::Triple::thumb:
case llvm::Triple::arm:
if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ))
if (const Arg *A = Args.getLastArg(options::OPT_march_EQ))
if (const char *Arch = ArmMachOArchName(A->getValue()))
return Arch;
@ -2993,7 +2993,7 @@ DerivedArgList *MachO::TranslateArgs(const DerivedArgList &Args,
if (!BoundArch.empty()) {
StringRef Name = BoundArch;
const Option MCpu = Opts.getOption(options::OPT_mcpu_EQ);
const Option MArch = Opts.getOption(clang::driver::options::OPT_march_EQ);
const Option MArch = Opts.getOption(options::OPT_march_EQ);
// This code must be kept in sync with LLVM's getArchTypeForDarwinArch,
// which defines the list of which architectures we accept.

View File

@ -10,7 +10,7 @@
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Options/Options.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/Path.h"
@ -219,7 +219,7 @@ void DragonFly::AddClangSystemIncludeArgs(
llvm::opt::ArgStringList &CC1Args) const {
const Driver &D = getDriver();
if (DriverArgs.hasArg(clang::driver::options::OPT_nostdinc))
if (DriverArgs.hasArg(options::OPT_nostdinc))
return;
if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {

View File

@ -11,7 +11,7 @@
#include "clang/Basic/CodeGenOptions.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Options.h"
#include "clang/Options/Options.h"
#include "llvm/Frontend/Debug/Options.h"
#include "llvm/Support/Path.h"
#include "llvm/TargetParser/Host.h"
@ -230,7 +230,7 @@ void Flang::addCodegenOptions(const ArgList &Args,
options::OPT_fstack_repack_arrays, options::OPT_fno_stack_repack_arrays,
options::OPT_ftime_report, options::OPT_ftime_report_EQ,
options::OPT_funroll_loops, options::OPT_fno_unroll_loops});
if (Args.hasArg(clang::driver::options::OPT_fcoarray))
if (Args.hasArg(options::OPT_fcoarray))
CmdArgs.push_back("-fcoarray");
}

View File

@ -13,8 +13,8 @@
#include "clang/Config/config.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/SanitizerArgs.h"
#include "clang/Options/Options.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/VirtualFileSystem.h"
@ -404,7 +404,7 @@ void FreeBSD::AddClangSystemIncludeArgs(
llvm::opt::ArgStringList &CC1Args) const {
const Driver &D = getDriver();
if (DriverArgs.hasArg(clang::driver::options::OPT_nostdinc))
if (DriverArgs.hasArg(options::OPT_nostdinc))
return;
if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {

View File

@ -12,8 +12,8 @@
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/MultilibBuilder.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/SanitizerArgs.h"
#include "clang/Options/Options.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
@ -344,7 +344,7 @@ Tool *Fuchsia::buildStaticLibTool() const {
ToolChain::RuntimeLibType
Fuchsia::GetRuntimeLibType(const ArgList &Args) const {
if (Arg *A = Args.getLastArg(clang::driver::options::OPT_rtlib_EQ)) {
if (Arg *A = Args.getLastArg(options::OPT_rtlib_EQ)) {
StringRef Value = A->getValue();
if (Value != "compiler-rt")
getDriver().Diag(clang::diag::err_drv_invalid_rtlib_name)

View File

@ -20,9 +20,9 @@
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/MultilibBuilder.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/Tool.h"
#include "clang/Driver/ToolChain.h"
#include "clang/Options/Options.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Option/ArgList.h"
@ -2058,7 +2058,7 @@ Generic_GCC::GCCVersion Generic_GCC::GCCVersion::Parse(StringRef VersionText) {
static llvm::StringRef getGCCToolchainDir(const ArgList &Args,
llvm::StringRef SysRoot) {
const Arg *A = Args.getLastArg(clang::driver::options::OPT_gcc_toolchain);
const Arg *A = Args.getLastArg(options::OPT_gcc_toolchain);
if (A)
return A->getValue();
@ -2111,8 +2111,7 @@ void Generic_GCC::GCCInstallationDetector::init(
CandidateBiarchTripleAliases);
// If --gcc-install-dir= is specified, skip filesystem detection.
if (const Arg *A =
Args.getLastArg(clang::driver::options::OPT_gcc_install_dir_EQ);
if (const Arg *A = Args.getLastArg(options::OPT_gcc_install_dir_EQ);
A && A->getValue()[0]) {
StringRef InstallDir = A->getValue();
if (!ScanGCCForMultilibs(TargetTriple, Args, InstallDir, false)) {
@ -2135,8 +2134,7 @@ void Generic_GCC::GCCInstallationDetector::init(
// If --gcc-triple is specified use this instead of trying to
// auto-detect a triple.
if (const Arg *A =
Args.getLastArg(clang::driver::options::OPT_gcc_triple_EQ)) {
if (const Arg *A = Args.getLastArg(options::OPT_gcc_triple_EQ)) {
StringRef GCCTriple = A->getValue();
CandidateTripleAliases.clear();
CandidateTripleAliases.push_back(GCCTriple);

View File

@ -15,8 +15,8 @@
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/InputInfo.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/SanitizerArgs.h"
#include "clang/Options/Options.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "llvm/TargetParser/TargetParser.h"

View File

@ -12,7 +12,7 @@
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/InputInfo.h"
#include "clang/Driver/Options.h"
#include "clang/Options/Options.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
@ -211,7 +211,7 @@ HIPSPVToolChain::getDeviceLibs(
// Find device libraries in --hip-device-lib-path and HIP_DEVICE_LIB_PATH.
auto HipDeviceLibPathArgs = DriverArgs.getAllArgValues(
// --hip-device-lib-path is alias to this option.
clang::driver::options::OPT_rocm_device_lib_path_EQ);
options::OPT_rocm_device_lib_path_EQ);
for (auto Path : HipDeviceLibPathArgs)
LibraryPaths.push_back(DriverArgs.MakeArgString(Path));

View File

@ -9,7 +9,7 @@
#include "HIPUtility.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Options.h"
#include "clang/Options/Options.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Object/Archive.h"

View File

@ -11,7 +11,7 @@
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/InputInfo.h"
#include "clang/Driver/Options.h"
#include "clang/Options/Options.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"

View File

@ -10,7 +10,7 @@
#include "clang/Config/config.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Options/Options.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/VirtualFileSystem.h"
@ -168,7 +168,7 @@ void Hurd::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
const Driver &D = getDriver();
std::string SysRoot = computeSysRoot();
if (DriverArgs.hasArg(clang::driver::options::OPT_nostdinc))
if (DriverArgs.hasArg(options::OPT_nostdinc))
return;
if (!DriverArgs.hasArg(options::OPT_nostdlibinc))

View File

@ -16,8 +16,8 @@
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Distro.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/SanitizerArgs.h"
#include "clang/Options/Options.h"
#include "llvm/Option/ArgList.h"
#include "llvm/ProfileData/InstrProf.h"
#include "llvm/Support/Path.h"
@ -731,7 +731,7 @@ void Linux::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
const Driver &D = getDriver();
std::string SysRoot = computeSysRoot();
if (DriverArgs.hasArg(clang::driver::options::OPT_nostdinc))
if (DriverArgs.hasArg(options::OPT_nostdinc))
return;
// Add 'include' in the resource directory, which is similar to

View File

@ -12,7 +12,7 @@
#include "clang/Driver/Compilation.h"
#include "clang/Driver/InputInfo.h"
#include "clang/Driver/Multilib.h"
#include "clang/Driver/Options.h"
#include "clang/Options/Options.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/Path.h"

View File

@ -12,8 +12,8 @@
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/SanitizerArgs.h"
#include "clang/Options/Options.h"
#include "llvm/Option/Arg.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/ConvertUTF.h"

View File

@ -11,8 +11,8 @@
#include "clang/Config/config.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/SanitizerArgs.h"
#include "clang/Options/Options.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/Path.h"
@ -136,7 +136,7 @@ void Managarm::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
const Driver &D = getDriver();
std::string SysRoot = computeSysRoot();
if (DriverArgs.hasArg(clang::driver::options::OPT_nostdinc))
if (DriverArgs.hasArg(options::OPT_nostdinc))
return;
if (!DriverArgs.hasArg(options::OPT_nostdlibinc))

View File

@ -12,8 +12,8 @@
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/InputInfo.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/SanitizerArgs.h"
#include "clang/Options/Options.h"
#include "llvm/Config/llvm-config.h" // for LLVM_HOST_TRIPLE
#include "llvm/Option/ArgList.h"
#include "llvm/Support/FileSystem.h"

View File

@ -9,7 +9,7 @@
#include "MipsLinux.h"
#include "Arch/Mips.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Options/Options.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
@ -38,7 +38,7 @@ MipsLLVMToolChain::MipsLLVMToolChain(const Driver &D,
void MipsLLVMToolChain::AddClangSystemIncludeArgs(
const ArgList &DriverArgs, ArgStringList &CC1Args) const {
if (DriverArgs.hasArg(clang::driver::options::OPT_nostdinc))
if (DriverArgs.hasArg(options::OPT_nostdinc))
return;
const Driver &D = getDriver();

View File

@ -14,8 +14,8 @@
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/SanitizerArgs.h"
#include "clang/Options/Options.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/VirtualFileSystem.h"
@ -466,7 +466,7 @@ void NetBSD::AddClangSystemIncludeArgs(
llvm::opt::ArgStringList &CC1Args) const {
const Driver &D = getDriver();
if (DriverArgs.hasArg(clang::driver::options::OPT_nostdinc))
if (DriverArgs.hasArg(options::OPT_nostdinc))
return;
if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {

View File

@ -12,8 +12,8 @@
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/SanitizerArgs.h"
#include "clang/Options/Options.h"
#include "llvm/Option/ArgList.h"
#include "llvm/ProfileData/InstrProf.h"
#include "llvm/Support/FileSystem.h"
@ -174,7 +174,7 @@ OHOS::OHOS(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
ToolChain::RuntimeLibType OHOS::GetRuntimeLibType(
const ArgList &Args) const {
if (Arg *A = Args.getLastArg(clang::driver::options::OPT_rtlib_EQ)) {
if (Arg *A = Args.getLastArg(options::OPT_rtlib_EQ)) {
StringRef Value = A->getValue();
if (Value != "compiler-rt")
getDriver().Diag(clang::diag::err_drv_invalid_rtlib_name)

View File

@ -13,8 +13,8 @@
#include "clang/Config/config.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/SanitizerArgs.h"
#include "clang/Options/Options.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/VirtualFileSystem.h"
@ -315,7 +315,7 @@ void OpenBSD::AddClangSystemIncludeArgs(
llvm::opt::ArgStringList &CC1Args) const {
const Driver &D = getDriver();
if (DriverArgs.hasArg(clang::driver::options::OPT_nostdinc))
if (DriverArgs.hasArg(options::OPT_nostdinc))
return;
if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {

View File

@ -8,7 +8,7 @@
#include "PPCFreeBSD.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Options/Options.h"
#include "llvm/Support/Path.h"
using namespace clang::driver::toolchains;
@ -16,7 +16,7 @@ using namespace llvm::opt;
void PPCFreeBSDToolChain::AddClangSystemIncludeArgs(
const ArgList &DriverArgs, ArgStringList &CC1Args) const {
if (!DriverArgs.hasArg(clang::driver::options::OPT_nostdinc) &&
if (!DriverArgs.hasArg(options::OPT_nostdinc) &&
!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
const Driver &D = getDriver();
SmallString<128> P(D.ResourceDir);

View File

@ -8,7 +8,7 @@
#include "PPCLinux.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Options/Options.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
@ -58,7 +58,7 @@ PPCLinuxToolChain::PPCLinuxToolChain(const Driver &D,
void PPCLinuxToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const {
if (!DriverArgs.hasArg(clang::driver::options::OPT_nostdinc) &&
if (!DriverArgs.hasArg(options::OPT_nostdinc) &&
!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
const Driver &D = getDriver();
SmallString<128> P(D.ResourceDir);

View File

@ -11,8 +11,8 @@
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/SanitizerArgs.h"
#include "clang/Options/Options.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"

View File

@ -10,7 +10,7 @@
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/InputInfo.h"
#include "clang/Driver/Options.h"
#include "clang/Options/Options.h"
using namespace clang::driver;
using namespace clang::driver::toolchains;

View File

@ -20,7 +20,7 @@ SYCLInstallationDetector::SYCLInstallationDetector(
void SYCLInstallationDetector::addSYCLIncludeArgs(
const ArgList &DriverArgs, ArgStringList &CC1Args) const {
if (DriverArgs.hasArg(clang::driver::options::OPT_nobuiltininc))
if (DriverArgs.hasArg(options::OPT_nobuiltininc))
return;
// Add the SYCL header search locations in the specified order.

View File

@ -13,9 +13,9 @@
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/SanitizerArgs.h"
#include "clang/Driver/ToolChain.h"
#include "clang/Options/Options.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/FileSystem.h"
@ -360,7 +360,7 @@ void Solaris::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const {
const Driver &D = getDriver();
if (DriverArgs.hasArg(clang::driver::options::OPT_nostdinc))
if (DriverArgs.hasArg(options::OPT_nostdinc))
return;
if (!DriverArgs.hasArg(options::OPT_nostdlibinc))

View File

@ -11,8 +11,8 @@
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/SanitizerArgs.h"
#include "clang/Options/Options.h"
#include "llvm/Option/Arg.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/VirtualFileSystem.h"

View File

@ -10,7 +10,7 @@
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Options/Options.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/Path.h"
#include <cstdlib> // ::getenv
@ -78,7 +78,7 @@ bool VEToolChain::hasBlocksRuntime() const { return false; }
void VEToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const {
if (DriverArgs.hasArg(clang::driver::options::OPT_nostdinc))
if (DriverArgs.hasArg(options::OPT_nostdinc))
return;
if (DriverArgs.hasArg(options::OPT_nobuiltininc) &&
@ -117,7 +117,7 @@ void VEToolChain::addClangTargetOptions(const ArgList &DriverArgs,
void VEToolChain::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const {
if (DriverArgs.hasArg(clang::driver::options::OPT_nostdinc) ||
if (DriverArgs.hasArg(options::OPT_nostdinc) ||
DriverArgs.hasArg(options::OPT_nostdlibinc) ||
DriverArgs.hasArg(options::OPT_nostdincxx))
return;

View File

@ -12,7 +12,7 @@
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Options/Options.h"
#include "llvm/Config/llvm-config.h" // for LLVM_VERSION_STRING
#include "llvm/Option/ArgList.h"
#include "llvm/Support/FileSystem.h"
@ -297,7 +297,7 @@ bool WebAssembly::HasNativeLLVMSupport() const { return true; }
void WebAssembly::addClangTargetOptions(const ArgList &DriverArgs,
ArgStringList &CC1Args,
Action::OffloadKind) const {
if (!DriverArgs.hasFlag(clang::driver::options::OPT_fuse_init_array,
if (!DriverArgs.hasFlag(options::OPT_fuse_init_array,
options::OPT_fno_use_init_array, true))
CC1Args.push_back("-fno-use-init-array");
@ -472,7 +472,7 @@ WebAssembly::GetCXXStdlibType(const ArgList &Args) const {
void WebAssembly::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const {
if (DriverArgs.hasArg(clang::driver::options::OPT_nostdinc))
if (DriverArgs.hasArg(options::OPT_nostdinc))
return;
const Driver &D = getDriver();

View File

@ -10,7 +10,7 @@
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Options/Options.h"
#include "llvm/Option/ArgList.h"
#include <cstdlib> // ::getenv
@ -113,7 +113,7 @@ bool XCoreToolChain::hasBlocksRuntime() const { return false; }
void XCoreToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const {
if (DriverArgs.hasArg(clang::driver::options::OPT_nostdinc) ||
if (DriverArgs.hasArg(options::OPT_nostdinc) ||
DriverArgs.hasArg(options::OPT_nostdlibinc))
return;
if (const char *cl_include_dir = getenv("XCC_C_INCLUDE_PATH")) {
@ -137,7 +137,7 @@ void XCoreToolChain::addClangTargetOptions(const ArgList &DriverArgs,
void XCoreToolChain::AddClangCXXStdlibIncludeArgs(
const ArgList &DriverArgs, ArgStringList &CC1Args) const {
if (DriverArgs.hasArg(clang::driver::options::OPT_nostdinc) ||
if (DriverArgs.hasArg(options::OPT_nostdinc) ||
DriverArgs.hasArg(options::OPT_nostdlibinc) ||
DriverArgs.hasArg(options::OPT_nostdincxx))
return;

View File

@ -9,7 +9,7 @@
#include "ZOS.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Options.h"
#include "clang/Options/Options.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/WithColor.h"

View File

@ -8,8 +8,8 @@
#include "clang/Driver/XRayArgs.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/ToolChain.h"
#include "clang/Options/Options.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/SpecialCaseList.h"

View File

@ -52,6 +52,7 @@ add_clang_library(clangFrontend
clangAST
clangBasic
clangDriver
clangOptions
clangEdit
clangLex
clangParse

View File

@ -27,7 +27,6 @@
#include "clang/Basic/XRayInstr.h"
#include "clang/Config/config.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Frontend/CommandLineSourceLoc.h"
#include "clang/Frontend/DependencyOutputOptions.h"
#include "clang/Frontend/FrontendDiagnostic.h"
@ -38,6 +37,7 @@
#include "clang/Frontend/Utils.h"
#include "clang/Lex/HeaderSearchOptions.h"
#include "clang/Lex/PreprocessorOptions.h"
#include "clang/Options/Options.h"
#include "clang/Serialization/ASTBitCodes.h"
#include "clang/Serialization/ModuleFileExtension.h"
#include "clang/StaticAnalyzer/Core/AnalyzerOptions.h"
@ -255,7 +255,7 @@ CowCompilerInvocation::getMutPreprocessorOutputOpts() {
using ArgumentConsumer = CompilerInvocation::ArgumentConsumer;
#define OPTTABLE_STR_TABLE_CODE
#include "clang/Driver/Options.inc"
#include "clang/Options/Options.inc"
#undef OPTTABLE_STR_TABLE_CODE
static llvm::StringRef lookupStrInTable(unsigned Offset) {
@ -263,7 +263,7 @@ static llvm::StringRef lookupStrInTable(unsigned Offset) {
}
#define SIMPLE_ENUM_VALUE_TABLE
#include "clang/Driver/Options.inc"
#include "clang/Options/Options.inc"
#undef SIMPLE_ENUM_VALUE_TABLE
static std::optional<bool> normalizeSimpleFlag(OptSpecifier Opt,
@ -981,7 +981,7 @@ static void GenerateAnalyzerArgs(const AnalyzerOptions &Opts,
#define ANALYZER_OPTION_WITH_MARSHALLING(...) \
GENERATE_OPTION_WITH_MARSHALLING(Consumer, __VA_ARGS__)
#include "clang/Driver/Options.inc"
#include "clang/Options/Options.inc"
#undef ANALYZER_OPTION_WITH_MARSHALLING
if (Opts.AnalysisConstraintsOpt != RangeConstraintsModel) {
@ -1068,7 +1068,7 @@ static bool ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args,
#define ANALYZER_OPTION_WITH_MARSHALLING(...) \
PARSE_OPTION_WITH_MARSHALLING(Args, Diags, __VA_ARGS__)
#include "clang/Driver/Options.inc"
#include "clang/Options/Options.inc"
#undef ANALYZER_OPTION_WITH_MARSHALLING
if (Arg *A = Args.getLastArg(OPT_analyzer_constraints)) {
@ -1575,7 +1575,7 @@ void CompilerInvocationBase::GenerateCodeGenArgs(const CodeGenOptions &Opts,
#define CODEGEN_OPTION_WITH_MARSHALLING(...) \
GENERATE_OPTION_WITH_MARSHALLING(Consumer, __VA_ARGS__)
#include "clang/Driver/Options.inc"
#include "clang/Options/Options.inc"
#undef CODEGEN_OPTION_WITH_MARSHALLING
if (Opts.OptimizationLevel > 0) {
@ -1880,7 +1880,7 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
#define CODEGEN_OPTION_WITH_MARSHALLING(...) \
PARSE_OPTION_WITH_MARSHALLING(Args, Diags, __VA_ARGS__)
#include "clang/Driver/Options.inc"
#include "clang/Options/Options.inc"
#undef CODEGEN_OPTION_WITH_MARSHALLING
// At O0 we want to fully disable inlining outside of cases marked with
@ -2371,7 +2371,7 @@ static void GenerateDependencyOutputArgs(const DependencyOutputOptions &Opts,
const DependencyOutputOptions &DependencyOutputOpts = Opts;
#define DEPENDENCY_OUTPUT_OPTION_WITH_MARSHALLING(...) \
GENERATE_OPTION_WITH_MARSHALLING(Consumer, __VA_ARGS__)
#include "clang/Driver/Options.inc"
#include "clang/Options/Options.inc"
#undef DEPENDENCY_OUTPUT_OPTION_WITH_MARSHALLING
if (Opts.ShowIncludesDest != ShowIncludesDestination::None)
@ -2406,7 +2406,7 @@ static bool ParseDependencyOutputArgs(DependencyOutputOptions &Opts,
DependencyOutputOptions &DependencyOutputOpts = Opts;
#define DEPENDENCY_OUTPUT_OPTION_WITH_MARSHALLING(...) \
PARSE_OPTION_WITH_MARSHALLING(Args, Diags, __VA_ARGS__)
#include "clang/Driver/Options.inc"
#include "clang/Options/Options.inc"
#undef DEPENDENCY_OUTPUT_OPTION_WITH_MARSHALLING
if (Args.hasArg(OPT_show_includes)) {
@ -2534,7 +2534,7 @@ static void GenerateFileSystemArgs(const FileSystemOptions &Opts,
#define FILE_SYSTEM_OPTION_WITH_MARSHALLING(...) \
GENERATE_OPTION_WITH_MARSHALLING(Consumer, __VA_ARGS__)
#include "clang/Driver/Options.inc"
#include "clang/Options/Options.inc"
#undef FILE_SYSTEM_OPTION_WITH_MARSHALLING
}
@ -2546,7 +2546,7 @@ static bool ParseFileSystemArgs(FileSystemOptions &Opts, const ArgList &Args,
#define FILE_SYSTEM_OPTION_WITH_MARSHALLING(...) \
PARSE_OPTION_WITH_MARSHALLING(Args, Diags, __VA_ARGS__)
#include "clang/Driver/Options.inc"
#include "clang/Options/Options.inc"
#undef FILE_SYSTEM_OPTION_WITH_MARSHALLING
return Diags.getNumErrors() == NumErrorsBefore;
@ -2557,7 +2557,7 @@ static void GenerateMigratorArgs(const MigratorOptions &Opts,
const MigratorOptions &MigratorOpts = Opts;
#define MIGRATOR_OPTION_WITH_MARSHALLING(...) \
GENERATE_OPTION_WITH_MARSHALLING(Consumer, __VA_ARGS__)
#include "clang/Driver/Options.inc"
#include "clang/Options/Options.inc"
#undef MIGRATOR_OPTION_WITH_MARSHALLING
}
@ -2569,7 +2569,7 @@ static bool ParseMigratorArgs(MigratorOptions &Opts, const ArgList &Args,
#define MIGRATOR_OPTION_WITH_MARSHALLING(...) \
PARSE_OPTION_WITH_MARSHALLING(Args, Diags, __VA_ARGS__)
#include "clang/Driver/Options.inc"
#include "clang/Options/Options.inc"
#undef MIGRATOR_OPTION_WITH_MARSHALLING
return Diags.getNumErrors() == NumErrorsBefore;
@ -2581,7 +2581,7 @@ void CompilerInvocationBase::GenerateDiagnosticArgs(
const DiagnosticOptions *DiagnosticOpts = &Opts;
#define DIAG_OPTION_WITH_MARSHALLING(...) \
GENERATE_OPTION_WITH_MARSHALLING(Consumer, __VA_ARGS__)
#include "clang/Driver/Options.inc"
#include "clang/Options/Options.inc"
#undef DIAG_OPTION_WITH_MARSHALLING
if (!Opts.DiagnosticSerializationFile.empty())
@ -2686,7 +2686,7 @@ bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
#define DIAG_OPTION_WITH_MARSHALLING(...) \
PARSE_OPTION_WITH_MARSHALLING(Args, *Diags, __VA_ARGS__)
#include "clang/Driver/Options.inc"
#include "clang/Options/Options.inc"
#undef DIAG_OPTION_WITH_MARSHALLING
llvm::sys::Process::UseANSIEscapeCodes(Opts.UseANSIEscapeCodes);
@ -2836,7 +2836,7 @@ static void GenerateFrontendArgs(const FrontendOptions &Opts,
const FrontendOptions &FrontendOpts = Opts;
#define FRONTEND_OPTION_WITH_MARSHALLING(...) \
GENERATE_OPTION_WITH_MARSHALLING(Consumer, __VA_ARGS__)
#include "clang/Driver/Options.inc"
#include "clang/Options/Options.inc"
#undef FRONTEND_OPTION_WITH_MARSHALLING
std::optional<OptSpecifier> ProgramActionOpt =
@ -3006,7 +3006,7 @@ static bool ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
#define FRONTEND_OPTION_WITH_MARSHALLING(...) \
PARSE_OPTION_WITH_MARSHALLING(Args, Diags, __VA_ARGS__)
#include "clang/Driver/Options.inc"
#include "clang/Options/Options.inc"
#undef FRONTEND_OPTION_WITH_MARSHALLING
Opts.ProgramAction = frontend::ParseSyntaxOnly;
@ -3288,7 +3288,7 @@ static void GenerateHeaderSearchArgs(const HeaderSearchOptions &Opts,
const HeaderSearchOptions *HeaderSearchOpts = &Opts;
#define HEADER_SEARCH_OPTION_WITH_MARSHALLING(...) \
GENERATE_OPTION_WITH_MARSHALLING(Consumer, __VA_ARGS__)
#include "clang/Driver/Options.inc"
#include "clang/Options/Options.inc"
#undef HEADER_SEARCH_OPTION_WITH_MARSHALLING
if (Opts.UseLibcxx)
@ -3403,7 +3403,7 @@ static bool ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args,
#define HEADER_SEARCH_OPTION_WITH_MARSHALLING(...) \
PARSE_OPTION_WITH_MARSHALLING(Args, Diags, __VA_ARGS__)
#include "clang/Driver/Options.inc"
#include "clang/Options/Options.inc"
#undef HEADER_SEARCH_OPTION_WITH_MARSHALLING
if (const Arg *A = Args.getLastArg(OPT_stdlib_EQ))
@ -3736,7 +3736,7 @@ void CompilerInvocationBase::GenerateLangArgs(const LangOptions &Opts,
#define LANG_OPTION_WITH_MARSHALLING(...) \
GENERATE_OPTION_WITH_MARSHALLING(Consumer, __VA_ARGS__)
#include "clang/Driver/Options.inc"
#include "clang/Options/Options.inc"
#undef LANG_OPTION_WITH_MARSHALLING
// The '-fcf-protection=' option is generated by CodeGenOpts generator.
@ -4082,7 +4082,7 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
#define LANG_OPTION_WITH_MARSHALLING(...) \
PARSE_OPTION_WITH_MARSHALLING(Args, Diags, __VA_ARGS__)
#include "clang/Driver/Options.inc"
#include "clang/Options/Options.inc"
#undef LANG_OPTION_WITH_MARSHALLING
if (const Arg *A = Args.getLastArg(OPT_fcf_protection_EQ)) {
@ -4745,7 +4745,7 @@ static void GeneratePreprocessorArgs(const PreprocessorOptions &Opts,
#define PREPROCESSOR_OPTION_WITH_MARSHALLING(...) \
GENERATE_OPTION_WITH_MARSHALLING(Consumer, __VA_ARGS__)
#include "clang/Driver/Options.inc"
#include "clang/Options/Options.inc"
#undef PREPROCESSOR_OPTION_WITH_MARSHALLING
if (Opts.PCHWithHdrStop && !Opts.PCHWithHdrStopCreate)
@ -4819,7 +4819,7 @@ static bool ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args,
#define PREPROCESSOR_OPTION_WITH_MARSHALLING(...) \
PARSE_OPTION_WITH_MARSHALLING(Args, Diags, __VA_ARGS__)
#include "clang/Driver/Options.inc"
#include "clang/Options/Options.inc"
#undef PREPROCESSOR_OPTION_WITH_MARSHALLING
Opts.PCHWithHdrStop = Args.hasArg(OPT_pch_through_hdrstop_create) ||
@ -4912,7 +4912,7 @@ GeneratePreprocessorOutputArgs(const PreprocessorOutputOptions &Opts,
#define PREPROCESSOR_OUTPUT_OPTION_WITH_MARSHALLING(...) \
GENERATE_OPTION_WITH_MARSHALLING(Consumer, __VA_ARGS__)
#include "clang/Driver/Options.inc"
#include "clang/Options/Options.inc"
#undef PREPROCESSOR_OUTPUT_OPTION_WITH_MARSHALLING
bool Generate_dM = isStrictlyPreprocessorAction(Action) && !Opts.ShowCPP;
@ -4933,7 +4933,7 @@ static bool ParsePreprocessorOutputArgs(PreprocessorOutputOptions &Opts,
#define PREPROCESSOR_OUTPUT_OPTION_WITH_MARSHALLING(...) \
PARSE_OPTION_WITH_MARSHALLING(Args, Diags, __VA_ARGS__)
#include "clang/Driver/Options.inc"
#include "clang/Options/Options.inc"
#undef PREPROCESSOR_OUTPUT_OPTION_WITH_MARSHALLING
Opts.ShowCPP = isStrictlyPreprocessorAction(Action) && !Args.hasArg(OPT_dM);
@ -4948,7 +4948,7 @@ static void GenerateTargetArgs(const TargetOptions &Opts,
const TargetOptions *TargetOpts = &Opts;
#define TARGET_OPTION_WITH_MARSHALLING(...) \
GENERATE_OPTION_WITH_MARSHALLING(Consumer, __VA_ARGS__)
#include "clang/Driver/Options.inc"
#include "clang/Options/Options.inc"
#undef TARGET_OPTION_WITH_MARSHALLING
if (!Opts.SDKVersion.empty())
@ -4967,7 +4967,7 @@ static bool ParseTargetArgs(TargetOptions &Opts, ArgList &Args,
#define TARGET_OPTION_WITH_MARSHALLING(...) \
PARSE_OPTION_WITH_MARSHALLING(Args, Diags, __VA_ARGS__)
#include "clang/Driver/Options.inc"
#include "clang/Options/Options.inc"
#undef TARGET_OPTION_WITH_MARSHALLING
if (Arg *A = Args.getLastArg(options::OPT_target_sdk_version_EQ)) {

View File

@ -14,11 +14,11 @@
#include "clang/Driver/Action.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/Tool.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/FrontendDiagnostic.h"
#include "clang/Frontend/Utils.h"
#include "clang/Options/Options.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Option/ArgList.h"
@ -61,11 +61,11 @@ clang::createInvocation(ArrayRef<const char *> ArgList,
if (!C)
return nullptr;
if (C->getArgs().hasArg(driver::options::OPT_fdriver_only))
if (C->getArgs().hasArg(options::OPT_fdriver_only))
return nullptr;
// Just print the cc1 options if -### was present.
if (C->getArgs().hasArg(driver::options::OPT__HASH_HASH_HASH)) {
if (C->getArgs().hasArg(options::OPT__HASH_HASH_HASH)) {
C->getJobs().Print(llvm::errs(), "\n", true);
return nullptr;
}

View File

@ -7,6 +7,7 @@ set(link_libs
clangBasic
clangCodeGen
clangDriver
clangOptions
clangExtractAPI
clangFrontend
clangRewriteFrontend

View File

@ -13,7 +13,6 @@
#include "clang/CodeGen/CodeGenAction.h"
#include "clang/Config/config.h"
#include "clang/Driver/Options.h"
#include "clang/ExtractAPI/FrontendActions.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/CompilerInvocation.h"
@ -22,6 +21,7 @@
#include "clang/Frontend/FrontendPluginRegistry.h"
#include "clang/Frontend/Utils.h"
#include "clang/FrontendTool/Utils.h"
#include "clang/Options/Options.h"
#include "clang/Rewrite/Frontend/FrontendActions.h"
#include "clang/StaticAnalyzer/Frontend/AnalyzerHelpFlags.h"
#include "clang/StaticAnalyzer/Frontend/FrontendActions.h"
@ -215,11 +215,11 @@ bool ExecuteCompilerInvocation(CompilerInstance *Clang) {
// Honor -help.
if (Clang->getFrontendOpts().ShowHelp) {
driver::getDriverOptTable().printHelp(
getDriverOptTable().printHelp(
llvm::outs(), "clang -cc1 [options] file...",
"LLVM 'Clang' Compiler: http://clang.llvm.org",
/*ShowHidden=*/false, /*ShowAllAliases=*/false,
llvm::opt::Visibility(driver::options::CC1Option));
llvm::opt::Visibility(options::CC1Option));
return true;
}

View File

@ -33,7 +33,6 @@
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Job.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/Tool.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/FrontendAction.h"
@ -43,6 +42,7 @@
#include "clang/Interpreter/Interpreter.h"
#include "clang/Interpreter/Value.h"
#include "clang/Lex/PreprocessorOptions.h"
#include "clang/Options/Options.h"
#include "clang/Sema/Lookup.h"
#include "clang/Serialization/ObjectFilePCHContainerReader.h"
#include "llvm/ExecutionEngine/JITSymbol.h"
@ -185,7 +185,7 @@ IncrementalCompilerBuilder::create(std::string TT,
llvm::ArrayRef<const char *> RF = llvm::ArrayRef(ClangArgv);
std::unique_ptr<driver::Compilation> Compilation(Driver.BuildCompilation(RF));
if (Compilation->getArgs().hasArg(driver::options::OPT_v))
if (Compilation->getArgs().hasArg(options::OPT_v))
Compilation->getJobs().Print(llvm::errs(), "\n", /*Quote=*/false);
auto ErrOrCC1Args = GetCC1Arguments(&Diags, Compilation.get());

View File

@ -21,11 +21,11 @@
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Job.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/Tool.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/TextDiagnosticBuffer.h"
#include "clang/Lex/PreprocessorOptions.h"
#include "clang/Options/Options.h"
#include "clang/Sema/Lookup.h"
#include "llvm/IR/Module.h"

View File

@ -0,0 +1,18 @@
set(LLVM_LINK_COMPONENTS
Option
Support
)
add_clang_library(clangOptions
DriverOptions.cpp
OptionUtils.cpp
DEPENDS
ClangDriverOptions
# These generated headers are included transitively.
target_parser_gen
LINK_LIBS
clangBasic
${system_libs}
)

View File

@ -6,33 +6,32 @@
//
//===----------------------------------------------------------------------===//
#include "clang/Driver/Options.h"
#include "clang/Options/Options.h"
#include "llvm/Option/OptTable.h"
#include <cassert>
using namespace clang::driver;
using namespace clang::driver::options;
using namespace clang::options;
using namespace llvm::opt;
#define OPTTABLE_STR_TABLE_CODE
#include "clang/Driver/Options.inc"
#include "clang/Options/Options.inc"
#undef OPTTABLE_STR_TABLE_CODE
#define OPTTABLE_VALUES_CODE
#include "clang/Driver/Options.inc"
#include "clang/Options/Options.inc"
#undef OPTTABLE_VALUES_CODE
#define OPTTABLE_PREFIXES_TABLE_CODE
#include "clang/Driver/Options.inc"
#include "clang/Options/Options.inc"
#undef OPTTABLE_PREFIXES_TABLE_CODE
#define OPTTABLE_PREFIXES_UNION_CODE
#include "clang/Driver/Options.inc"
#include "clang/Options/Options.inc"
#undef OPTTABLE_PREFIXES_UNION_CODE
static constexpr OptTable::Info InfoTable[] = {
#define OPTION(...) LLVM_CONSTRUCT_OPT_INFO(__VA_ARGS__),
#include "clang/Driver/Options.inc"
#include "clang/Options/Options.inc"
#undef OPTION
};
@ -44,9 +43,9 @@ public:
: PrecomputedOptTable(OptionStrTable, OptionPrefixesTable, InfoTable,
OptionPrefixesUnion) {}
};
}
} // anonymous namespace
const llvm::opt::OptTable &clang::driver::getDriverOptTable() {
const llvm::opt::OptTable &clang::getDriverOptTable() {
static DriverOptTable Table;
return Table;
}

View File

@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//
#include "clang/Options/OptionUtils.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticDriver.h"
#include "clang/Driver/OptionUtils.h"
#include "llvm/Option/ArgList.h"
using namespace clang;

View File

@ -40,6 +40,7 @@ add_clang_library(clangTooling
clangASTMatchers
clangBasic
clangDriver
clangOptions
clangFormat
clangFrontend
clangLex

View File

@ -44,8 +44,8 @@
#include "clang/Basic/LangStandard.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/Types.h"
#include "clang/Options/Options.h"
#include "clang/Tooling/CompilationDatabase.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
@ -164,11 +164,11 @@ struct TransferableCommand {
// We parse each argument individually so that we can retain the exact
// spelling of each argument; re-rendering is lossy for aliased flags.
// E.g. in CL mode, /W4 maps to -Wall.
auto &OptTable = clang::driver::getDriverOptTable();
auto &OptTable = getDriverOptTable();
if (!OldArgs.empty())
Cmd.CommandLine.emplace_back(OldArgs.front());
for (unsigned Pos = 1; Pos < OldArgs.size();) {
using namespace driver::options;
using namespace options;
const unsigned OldPos = Pos;
std::unique_ptr<llvm::opt::Arg> Arg(OptTable.ParseOneArg(
@ -296,14 +296,14 @@ private:
// Try to interpret the argument as a type specifier, e.g. '-x'.
std::optional<types::ID> tryParseTypeArg(const llvm::opt::Arg &Arg) {
const llvm::opt::Option &Opt = Arg.getOption();
using namespace driver::options;
using namespace options;
if (ClangCLMode) {
if (Opt.matches(OPT__SLASH_TC) || Opt.matches(OPT__SLASH_Tc))
return types::TY_C;
if (Opt.matches(OPT__SLASH_TP) || Opt.matches(OPT__SLASH_Tp))
return types::TY_CXX;
} else {
if (Opt.matches(driver::options::OPT_x))
if (Opt.matches(options::OPT_x))
return types::lookupTypeForTypeSpecifier(Arg.getValue());
}
return std::nullopt;
@ -311,7 +311,7 @@ private:
// Try to interpret the argument as '-std='.
std::optional<LangStandard::Kind> tryParseStdArg(const llvm::opt::Arg &Arg) {
using namespace driver::options;
using namespace options;
if (Arg.getOption().matches(ClangCLMode ? OPT__SLASH_std : OPT_std_EQ)) {
// "c++latest" is not a recognized LangStandard, but it's accepted by
// the clang driver in CL mode.

View File

@ -21,7 +21,6 @@
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Job.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/Tool.h"
#include "clang/Driver/ToolChain.h"
#include "clang/Frontend/ASTUnit.h"
@ -32,6 +31,7 @@
#include "clang/Frontend/TextDiagnosticPrinter.h"
#include "clang/Lex/HeaderSearchOptions.h"
#include "clang/Lex/PreprocessorOptions.h"
#include "clang/Options/Options.h"
#include "clang/Tooling/ArgumentsAdjusters.h"
#include "clang/Tooling/CompilationDatabase.h"
#include "llvm/ADT/ArrayRef.h"
@ -270,17 +270,15 @@ void addTargetAndModeForProgramName(std::vector<std::string> &CommandLine,
StringRef InvokedAs) {
if (CommandLine.empty() || InvokedAs.empty())
return;
const auto &Table = driver::getDriverOptTable();
const auto &Table = getDriverOptTable();
// --target=X
StringRef TargetOPT =
Table.getOption(driver::options::OPT_target).getPrefixedName();
StringRef TargetOPT = Table.getOption(options::OPT_target).getPrefixedName();
// -target X
StringRef TargetOPTLegacy =
Table.getOption(driver::options::OPT_target_legacy_spelling)
.getPrefixedName();
Table.getOption(options::OPT_target_legacy_spelling).getPrefixedName();
// --driver-mode=X
StringRef DriverModeOPT =
Table.getOption(driver::options::OPT_driver_mode).getPrefixedName();
Table.getOption(options::OPT_driver_mode).getPrefixedName();
auto TargetMode =
driver::ToolChain::getTargetAndModeFromProgramName(InvokedAs);
// No need to search for target args if we don't have a target/mode to insert.

View File

@ -14,6 +14,7 @@ clang_target_link_libraries(clang-check
clangBasic
clangDriver
clangFrontend
clangOptions
clangRewriteFrontend
clangSerialization
clangStaticAnalyzerFrontend

View File

@ -16,9 +16,9 @@
//===----------------------------------------------------------------------===//
#include "clang/AST/ASTConsumer.h"
#include "clang/Driver/Options.h"
#include "clang/Frontend/ASTConsumers.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Options/Options.h"
#include "clang/Rewrite/Frontend/FixItRewriter.h"
#include "clang/Rewrite/Frontend/FrontendActions.h"
#include "clang/StaticAnalyzer/Frontend/FrontendActions.h"
@ -34,8 +34,8 @@
#include "llvm/Support/Signals.h"
#include "llvm/Support/TargetSelect.h"
using namespace clang::driver;
using namespace clang::tooling;
using namespace clang;
using namespace llvm;
static cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage);

View File

@ -25,6 +25,7 @@ clang_target_link_libraries(clang-installapi
clangAST
clangInstallAPI
clangBasic
clangOptions
clangDriver
clangFrontend
clangTooling

View File

@ -35,7 +35,7 @@
using namespace clang;
using namespace clang::installapi;
using namespace clang::driver::options;
using namespace clang::options;
using namespace llvm::opt;
using namespace llvm::MachO;
@ -71,7 +71,7 @@ static bool runFrontend(StringRef ProgName, Twine Label, bool Verbose,
static bool run(ArrayRef<const char *> Args, const char *ProgName) {
// Setup Diagnostics engine.
DiagnosticOptions DiagOpts;
const llvm::opt::OptTable &ClangOpts = clang::driver::getDriverOptTable();
const llvm::opt::OptTable &ClangOpts = getDriverOptTable();
unsigned MissingArgIndex, MissingArgCount;
llvm::opt::InputArgList ParsedArgs = ClangOpts.ParseArgs(
ArrayRef(Args).slice(1), MissingArgIndex, MissingArgCount);

View File

@ -26,8 +26,6 @@ using namespace llvm;
using namespace llvm::opt;
using namespace llvm::MachO;
namespace drv = clang::driver::options;
namespace clang {
namespace installapi {
@ -109,7 +107,7 @@ getArgListFromJSON(const StringRef Input, llvm::opt::OptTable *Table,
bool Options::processDriverOptions(InputArgList &Args) {
// Handle inputs.
for (const StringRef Path : Args.getAllArgValues(drv::OPT_INPUT)) {
for (const StringRef Path : Args.getAllArgValues(options::OPT_INPUT)) {
// Assume any input that is not a directory is a filelist.
// InstallAPI does not accept multiple directories, so retain the last one.
if (FM->getOptionalDirectoryRef(Path))
@ -120,7 +118,7 @@ bool Options::processDriverOptions(InputArgList &Args) {
// Handle output.
SmallString<PATH_MAX> OutputPath;
if (auto *Arg = Args.getLastArg(drv::OPT_o)) {
if (auto *Arg = Args.getLastArg(options::OPT_o)) {
OutputPath = Arg->getValue();
if (OutputPath != "-")
FM->makeAbsolutePath(OutputPath);
@ -132,10 +130,10 @@ bool Options::processDriverOptions(InputArgList &Args) {
}
// Do basic error checking first for mixing -target and -arch options.
auto *ArgArch = Args.getLastArgNoClaim(drv::OPT_arch);
auto *ArgTarget = Args.getLastArgNoClaim(drv::OPT_target);
auto *ArgArch = Args.getLastArgNoClaim(options::OPT_arch);
auto *ArgTarget = Args.getLastArgNoClaim(options::OPT_target);
auto *ArgTargetVariant =
Args.getLastArgNoClaim(drv::OPT_darwin_target_variant);
Args.getLastArgNoClaim(options::OPT_darwin_target_variant);
if (ArgArch && (ArgTarget || ArgTargetVariant)) {
Diags->Report(clang::diag::err_drv_argument_not_allowed_with)
<< ArgArch->getAsString(Args)
@ -143,7 +141,7 @@ bool Options::processDriverOptions(InputArgList &Args) {
return false;
}
auto *ArgMinTargetOS = Args.getLastArgNoClaim(drv::OPT_mtargetos_EQ);
auto *ArgMinTargetOS = Args.getLastArgNoClaim(options::OPT_mtargetos_EQ);
if ((ArgTarget || ArgTargetVariant) && ArgMinTargetOS) {
Diags->Report(clang::diag::err_drv_cannot_mix_options)
<< ArgTarget->getAsString(Args) << ArgMinTargetOS->getAsString(Args);
@ -152,7 +150,7 @@ bool Options::processDriverOptions(InputArgList &Args) {
// Capture target triples first.
if (ArgTarget) {
for (const Arg *A : Args.filtered(drv::OPT_target)) {
for (const Arg *A : Args.filtered(options::OPT_target)) {
A->claim();
llvm::Triple TargetTriple(A->getValue());
Target TAPITarget = Target(TargetTriple);
@ -168,7 +166,7 @@ bool Options::processDriverOptions(InputArgList &Args) {
// Capture target variants.
DriverOpts.Zippered = ArgTargetVariant != nullptr;
for (Arg *A : Args.filtered(drv::OPT_darwin_target_variant)) {
for (Arg *A : Args.filtered(options::OPT_darwin_target_variant)) {
A->claim();
Triple Variant(A->getValue());
if (Variant.getVendor() != Triple::Apple) {
@ -213,7 +211,7 @@ bool Options::processDriverOptions(InputArgList &Args) {
DriverOpts.Targets[TAPIVariant] = Variant;
}
DriverOpts.Verbose = Args.hasArgNoClaim(drv::OPT_v);
DriverOpts.Verbose = Args.hasArgNoClaim(options::OPT_v);
return true;
}
@ -407,7 +405,7 @@ bool Options::processOptionList(InputArgList &Args,
bool Options::processLinkerOptions(InputArgList &Args) {
// Handle required arguments.
if (const Arg *A = Args.getLastArg(drv::OPT_install__name))
if (const Arg *A = Args.getLastArg(options::OPT_install__name))
LinkerOpts.InstallName = A->getValue();
if (LinkerOpts.InstallName.empty()) {
Diags->Report(diag::err_no_install_name);
@ -415,28 +413,29 @@ bool Options::processLinkerOptions(InputArgList &Args) {
}
// Defaulted or optional arguments.
if (auto *Arg = Args.getLastArg(drv::OPT_current__version))
if (auto *Arg = Args.getLastArg(options::OPT_current__version))
LinkerOpts.CurrentVersion.parse64(Arg->getValue());
if (auto *Arg = Args.getLastArg(drv::OPT_compatibility__version))
if (auto *Arg = Args.getLastArg(options::OPT_compatibility__version))
LinkerOpts.CompatVersion.parse64(Arg->getValue());
if (auto *Arg = Args.getLastArg(drv::OPT_compatibility__version))
if (auto *Arg = Args.getLastArg(options::OPT_compatibility__version))
LinkerOpts.CompatVersion.parse64(Arg->getValue());
if (auto *Arg = Args.getLastArg(drv::OPT_umbrella))
if (auto *Arg = Args.getLastArg(options::OPT_umbrella))
LinkerOpts.ParentUmbrella = Arg->getValue();
LinkerOpts.IsDylib = Args.hasArg(drv::OPT_dynamiclib);
LinkerOpts.IsDylib = Args.hasArg(options::OPT_dynamiclib);
for (auto *Arg : Args.filtered(drv::OPT_alias_list)) {
for (auto *Arg : Args.filtered(options::OPT_alias_list)) {
LinkerOpts.AliasLists.emplace_back(Arg->getValue());
Arg->claim();
}
LinkerOpts.AppExtensionSafe = Args.hasFlag(
drv::OPT_fapplication_extension, drv::OPT_fno_application_extension,
/*Default=*/LinkerOpts.AppExtensionSafe);
LinkerOpts.AppExtensionSafe =
Args.hasFlag(options::OPT_fapplication_extension,
options::OPT_fno_application_extension,
/*Default=*/LinkerOpts.AppExtensionSafe);
if (::getenv("LD_NO_ENCRYPT") != nullptr)
LinkerOpts.AppExtensionSafe = true;
@ -446,7 +445,7 @@ bool Options::processLinkerOptions(InputArgList &Args) {
// Capture library paths.
PathSeq LibraryPaths;
for (const Arg *A : Args.filtered(drv::OPT_L)) {
for (const Arg *A : Args.filtered(options::OPT_L)) {
LibraryPaths.emplace_back(A->getValue());
A->claim();
}
@ -461,7 +460,7 @@ bool Options::processLinkerOptions(InputArgList &Args) {
// invocations.
bool Options::processFrontendOptions(InputArgList &Args) {
// Capture language mode.
if (auto *A = Args.getLastArgNoClaim(drv::OPT_x)) {
if (auto *A = Args.getLastArgNoClaim(options::OPT_x)) {
FEOpts.LangMode = llvm::StringSwitch<clang::Language>(A->getValue())
.Case("c", clang::Language::C)
.Case("c++", clang::Language::CXX)
@ -475,15 +474,15 @@ bool Options::processFrontendOptions(InputArgList &Args) {
return false;
}
}
for (auto *A : Args.filtered(drv::OPT_ObjC, drv::OPT_ObjCXX)) {
if (A->getOption().matches(drv::OPT_ObjC))
for (auto *A : Args.filtered(options::OPT_ObjC, options::OPT_ObjCXX)) {
if (A->getOption().matches(options::OPT_ObjC))
FEOpts.LangMode = clang::Language::ObjC;
else
FEOpts.LangMode = clang::Language::ObjCXX;
}
// Capture Sysroot.
if (const Arg *A = Args.getLastArgNoClaim(drv::OPT_isysroot)) {
if (const Arg *A = Args.getLastArgNoClaim(options::OPT_isysroot)) {
SmallString<PATH_MAX> Path(A->getValue());
FM->makeAbsolutePath(Path);
if (!FM->getOptionalDirectoryRef(Path)) {
@ -502,13 +501,13 @@ bool Options::processFrontendOptions(InputArgList &Args) {
}
// Capture system frameworks for all platforms.
for (const Arg *A : Args.filtered(drv::OPT_iframework))
for (const Arg *A : Args.filtered(options::OPT_iframework))
FEOpts.SystemFwkPaths.emplace_back(A->getValue(),
std::optional<PlatformType>{});
// Capture framework paths.
PathSeq FrameworkPaths;
for (const Arg *A : Args.filtered(drv::OPT_F))
for (const Arg *A : Args.filtered(options::OPT_F))
FrameworkPaths.emplace_back(A->getValue());
if (!FrameworkPaths.empty())

Some files were not shown because too many files have changed in this diff Show More