[clang] [clang-tools-extra] [flang] [lldb] [llvm] [clang] Remove clangDriver dependency from clangFrontend (NFC) (PR #165277)
Naveen Seth Hanig via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 27 09:38:32 PDT 2025
https://github.com/naveen-seth created https://github.com/llvm/llvm-project/pull/165277
This PR removes the `clangDriver` dependency from `clangFrontend`.
The goal of this change is to remove dependencies on the Driver.
This is part of a larger effort to support driver-managed builds for compilations using C++ named modules and/or Clang modules.
This is required to eventually allow linking `clangDependencyScanning` against the Driver without creating cyclic dependencies, which would cause build failures with dynamic linking enabled.
This change is motivated by the following review comment:
https://github.com/llvm/llvm-project/pull/152770#discussion_r2430756918
>From 42d082c69bb3b332ccb409f211778e7eceda356b Mon Sep 17 00:00:00 2001
From: Naveen Seth Hanig <naveen.hanig at outlook.com>
Date: Thu, 16 Oct 2025 00:51:52 +0200
Subject: [PATCH 1/7] [clang] Move options from clangDriver into new
clangOptions library (NFC)
The goal of this change is to remove dependencies on the Driver.
This is part of a larger effort to support driver-managed builds for
compilations using C++ named modules and/or Clang modules. It is
required to eventually allow linking the dependency scanning tooling
against the Driver without creating cyclic dependencies, which would
cause build failures when dynamic linking is enabled.
This PR is motivated by the following review comment:
https://github.com/llvm/llvm-project/pull/152770#discussion_r2430756918
---
clang-tools-extra/clangd/CMakeLists.txt | 1 +
clang-tools-extra/clangd/CompileCommands.cpp | 26 +-
clang-tools-extra/modularize/CMakeLists.txt | 1 +
.../modularize/CoverageChecker.cpp | 6 +-
clang-tools-extra/modularize/Modularize.cpp | 4 +-
.../modularize/ModularizeUtilities.cpp | 6 +-
clang-tools-extra/pp-trace/CMakeLists.txt | 1 +
clang-tools-extra/pp-trace/PPTrace.cpp | 2 +-
clang/docs/InternalsManual.rst | 8 +-
clang/include/clang/CMakeLists.txt | 2 +-
clang/include/clang/Driver/Driver.h | 2 +-
clang/include/clang/Frontend/Utils.h | 2 +-
.../clang/{Driver => Options}/CMakeLists.txt | 0
.../{Driver => Options}/ClangOptionDocs.td | 2 +-
.../clang/{Driver => Options}/OptionUtils.h | 6 +-
.../clang/{Driver => Options}/Options.h | 18 +-
.../clang/{Driver => Options}/Options.td | 0
clang/lib/CMakeLists.txt | 1 +
clang/lib/Driver/CMakeLists.txt | 3 +-
clang/lib/Driver/Compilation.cpp | 2 +-
clang/lib/Driver/Driver.cpp | 2 +-
clang/lib/Driver/SanitizerArgs.cpp | 2 +-
clang/lib/Driver/ToolChain.cpp | 6 +-
clang/lib/Driver/ToolChains/AIX.cpp | 5 +-
clang/lib/Driver/ToolChains/AMDGPU.cpp | 18 +-
clang/lib/Driver/ToolChains/AMDGPU.h | 2 +-
clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp | 2 +-
clang/lib/Driver/ToolChains/AVR.cpp | 2 +-
clang/lib/Driver/ToolChains/Arch/AArch64.cpp | 4 +-
clang/lib/Driver/ToolChains/Arch/ARM.cpp | 4 +-
clang/lib/Driver/ToolChains/Arch/CSKY.cpp | 6 +-
.../lib/Driver/ToolChains/Arch/LoongArch.cpp | 4 +-
clang/lib/Driver/ToolChains/Arch/M68k.cpp | 16 +-
clang/lib/Driver/ToolChains/Arch/Mips.cpp | 4 +-
clang/lib/Driver/ToolChains/Arch/PPC.cpp | 2 +-
clang/lib/Driver/ToolChains/Arch/RISCV.cpp | 2 +-
clang/lib/Driver/ToolChains/Arch/Sparc.cpp | 4 +-
clang/lib/Driver/ToolChains/Arch/SystemZ.cpp | 8 +-
clang/lib/Driver/ToolChains/Arch/VE.cpp | 2 +-
clang/lib/Driver/ToolChains/Arch/X86.cpp | 18 +-
clang/lib/Driver/ToolChains/BareMetal.cpp | 4 +-
clang/lib/Driver/ToolChains/CSKYToolChain.cpp | 2 +-
clang/lib/Driver/ToolChains/Clang.cpp | 12 +-
clang/lib/Driver/ToolChains/CommonArgs.cpp | 20 +-
clang/lib/Driver/ToolChains/CrossWindows.cpp | 2 +-
clang/lib/Driver/ToolChains/Cuda.cpp | 8 +-
clang/lib/Driver/ToolChains/Cygwin.cpp | 4 +-
clang/lib/Driver/ToolChains/Darwin.cpp | 6 +-
clang/lib/Driver/ToolChains/DragonFly.cpp | 4 +-
clang/lib/Driver/ToolChains/Flang.cpp | 4 +-
clang/lib/Driver/ToolChains/FreeBSD.cpp | 4 +-
clang/lib/Driver/ToolChains/Fuchsia.cpp | 4 +-
clang/lib/Driver/ToolChains/Gnu.cpp | 8 +-
clang/lib/Driver/ToolChains/HIPAMD.cpp | 2 +-
clang/lib/Driver/ToolChains/HIPSPV.cpp | 4 +-
clang/lib/Driver/ToolChains/HIPUtility.cpp | 2 +-
clang/lib/Driver/ToolChains/Hexagon.cpp | 2 +-
clang/lib/Driver/ToolChains/Hurd.cpp | 4 +-
clang/lib/Driver/ToolChains/Linux.cpp | 4 +-
clang/lib/Driver/ToolChains/MSP430.cpp | 2 +-
clang/lib/Driver/ToolChains/MSVC.cpp | 2 +-
clang/lib/Driver/ToolChains/Managarm.cpp | 4 +-
clang/lib/Driver/ToolChains/MinGW.cpp | 2 +-
clang/lib/Driver/ToolChains/MipsLinux.cpp | 4 +-
clang/lib/Driver/ToolChains/NetBSD.cpp | 4 +-
clang/lib/Driver/ToolChains/OHOS.cpp | 4 +-
clang/lib/Driver/ToolChains/OpenBSD.cpp | 4 +-
clang/lib/Driver/ToolChains/PPCFreeBSD.cpp | 4 +-
clang/lib/Driver/ToolChains/PPCLinux.cpp | 4 +-
clang/lib/Driver/ToolChains/PS4CPU.cpp | 2 +-
clang/lib/Driver/ToolChains/SPIRV.cpp | 2 +-
clang/lib/Driver/ToolChains/SYCL.cpp | 2 +-
clang/lib/Driver/ToolChains/Solaris.cpp | 4 +-
clang/lib/Driver/ToolChains/UEFI.cpp | 2 +-
clang/lib/Driver/ToolChains/VEToolchain.cpp | 6 +-
clang/lib/Driver/ToolChains/WebAssembly.cpp | 6 +-
clang/lib/Driver/ToolChains/XCore.cpp | 6 +-
clang/lib/Driver/ToolChains/ZOS.cpp | 2 +-
clang/lib/Driver/XRayArgs.cpp | 2 +-
clang/lib/Frontend/CMakeLists.txt | 1 +
clang/lib/Frontend/CompilerInvocation.cpp | 54 +--
.../CreateInvocationFromCommandLine.cpp | 6 +-
clang/lib/FrontendTool/CMakeLists.txt | 1 +
.../ExecuteCompilerInvocation.cpp | 6 +-
clang/lib/Interpreter/Interpreter.cpp | 4 +-
clang/lib/Interpreter/InterpreterUtils.h | 2 +-
clang/lib/Options/CMakeLists.txt | 18 +
.../lib/{Driver => Options}/DriverOptions.cpp | 19 +-
clang/lib/{Driver => Options}/OptionUtils.cpp | 2 +-
clang/lib/Tooling/CMakeLists.txt | 1 +
.../InterpolatingCompilationDatabase.cpp | 12 +-
clang/lib/Tooling/Tooling.cpp | 10 +-
clang/tools/clang-check/CMakeLists.txt | 1 +
clang/tools/clang-check/ClangCheck.cpp | 4 +-
clang/tools/clang-installapi/CMakeLists.txt | 1 +
.../clang-installapi/ClangInstallAPI.cpp | 4 +-
clang/tools/clang-installapi/Options.cpp | 50 +-
clang/tools/driver/CMakeLists.txt | 1 +
clang/tools/driver/cc1_main.cpp | 2 +-
clang/tools/driver/cc1as_main.cpp | 7 +-
clang/tools/driver/driver.cpp | 2 +-
clang/unittests/Driver/DXCModeTest.cpp | 2 +-
clang/www/OpenProjects.html | 2 +-
flang/docs/FlangDriver.md | 8 +-
flang/lib/Frontend/CMakeLists.txt | 1 +
flang/lib/Frontend/CompilerInvocation.cpp | 456 +++++++++---------
flang/lib/FrontendTool/CMakeLists.txt | 1 +
.../ExecuteCompilerInvocation.cpp | 6 +-
flang/tools/flang-driver/CMakeLists.txt | 1 +
flang/tools/flang-driver/driver.cpp | 4 +-
.../Platform/MacOSX/PlatformDarwin.cpp | 4 +-
llvm/include/llvm/MC/MCAsmInfo.h | 2 +-
llvm/include/llvm/Option/Arg.h | 2 +-
.../llvm-project-overlay/clang/BUILD.bazel | 4 +-
114 files changed, 550 insertions(+), 525 deletions(-)
rename clang/include/clang/{Driver => Options}/CMakeLists.txt (100%)
rename clang/include/clang/{Driver => Options}/ClangOptionDocs.td (98%)
rename clang/include/clang/{Driver => Options}/OptionUtils.h (94%)
rename clang/include/clang/{Driver => Options}/Options.h (86%)
rename clang/include/clang/{Driver => Options}/Options.td (100%)
create mode 100644 clang/lib/Options/CMakeLists.txt
rename clang/lib/{Driver => Options}/DriverOptions.cpp (76%)
rename clang/lib/{Driver => Options}/OptionUtils.cpp (97%)
diff --git a/clang-tools-extra/clangd/CMakeLists.txt b/clang-tools-extra/clangd/CMakeLists.txt
index fb3f05329be21..d7ec853af862f 100644
--- a/clang-tools-extra/clangd/CMakeLists.txt
+++ b/clang-tools-extra/clangd/CMakeLists.txt
@@ -165,6 +165,7 @@ clang_target_link_libraries(clangDaemon
clangBasic
clangDependencyScanning
clangDriver
+ clangOptions
clangFormat
clangFrontend
clangIndex
diff --git a/clang-tools-extra/clangd/CompileCommands.cpp b/clang-tools-extra/clangd/CompileCommands.cpp
index c1be93730129a..f5592b60a817a 100644
--- a/clang-tools-extra/clangd/CompileCommands.cpp
+++ b/clang-tools-extra/clangd/CompileCommands.cpp
@@ -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,13 @@ 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)) {
+ 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 +424,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 +442,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 +468,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)
diff --git a/clang-tools-extra/modularize/CMakeLists.txt b/clang-tools-extra/modularize/CMakeLists.txt
index eb5383c3ad44e..a775b790a3147 100644
--- a/clang-tools-extra/modularize/CMakeLists.txt
+++ b/clang-tools-extra/modularize/CMakeLists.txt
@@ -20,6 +20,7 @@ clang_target_link_libraries(modularize
clangAST
clangBasic
clangDriver
+ clangOptions
clangFrontend
clangLex
clangSerialization
diff --git a/clang-tools-extra/modularize/CoverageChecker.cpp b/clang-tools-extra/modularize/CoverageChecker.cpp
index 1345a6ef8f489..d80d78c64c6e2 100644
--- a/clang-tools-extra/modularize/CoverageChecker.cpp
+++ b/clang-tools-extra/modularize/CoverageChecker.cpp
@@ -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;
diff --git a/clang-tools-extra/modularize/Modularize.cpp b/clang-tools-extra/modularize/Modularize.cpp
index 376ad0c7875bf..33966b44f719a 100644
--- a/clang-tools-extra/modularize/Modularize.cpp
+++ b/clang-tools-extra/modularize/Modularize.cpp
@@ -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;
diff --git a/clang-tools-extra/modularize/ModularizeUtilities.cpp b/clang-tools-extra/modularize/ModularizeUtilities.cpp
index 4dd84feac5df4..6978a6b2fe1b7 100644
--- a/clang-tools-extra/modularize/ModularizeUtilities.cpp
+++ b/clang-tools-extra/modularize/ModularizeUtilities.cpp
@@ -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;
diff --git a/clang-tools-extra/pp-trace/CMakeLists.txt b/clang-tools-extra/pp-trace/CMakeLists.txt
index 1323adbc35269..da36582ee0234 100644
--- a/clang-tools-extra/pp-trace/CMakeLists.txt
+++ b/clang-tools-extra/pp-trace/CMakeLists.txt
@@ -14,6 +14,7 @@ clang_target_link_libraries(pp-trace
PRIVATE
clangAST
clangBasic
+ clangOptions
clangFrontend
clangLex
clangSerialization
diff --git a/clang-tools-extra/pp-trace/PPTrace.cpp b/clang-tools-extra/pp-trace/PPTrace.cpp
index 0b078c49a55b7..ba5a06a26830d 100644
--- a/clang-tools-extra/pp-trace/PPTrace.cpp
+++ b/clang-tools-extra/pp-trace/PPTrace.cpp
@@ -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"
diff --git a/clang/docs/InternalsManual.rst b/clang/docs/InternalsManual.rst
index c677ddfa5ecc1..c77259f6122cd 100644
--- a/clang/docs/InternalsManual.rst
+++ b/clang/docs/InternalsManual.rst
@@ -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
// ...
diff --git a/clang/include/clang/CMakeLists.txt b/clang/include/clang/CMakeLists.txt
index 47ac70cd21690..77a44e4c48de5 100644
--- a/clang/include/clang/CMakeLists.txt
+++ b/clang/include/clang/CMakeLists.txt
@@ -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)
diff --git a/clang/include/clang/Driver/Driver.h b/clang/include/clang/Driver/Driver.h
index b9b187ada8add..aa86bffb802a4 100644
--- a/clang/include/clang/Driver/Driver.h
+++ b/clang/include/clang/Driver/Driver.h
@@ -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"
diff --git a/clang/include/clang/Frontend/Utils.h b/clang/include/clang/Frontend/Utils.h
index 49fd920d1ec43..6961b8a234d18 100644
--- a/clang/include/clang/Frontend/Utils.h
+++ b/clang/include/clang/Frontend/Utils.h
@@ -15,7 +15,7 @@
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/LLVM.h"
-#include "clang/Driver/OptionUtils.h"
+#include "clang/Options/OptionUtils.h"
#include "clang/Frontend/DependencyOutputOptions.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
diff --git a/clang/include/clang/Driver/CMakeLists.txt b/clang/include/clang/Options/CMakeLists.txt
similarity index 100%
rename from clang/include/clang/Driver/CMakeLists.txt
rename to clang/include/clang/Options/CMakeLists.txt
diff --git a/clang/include/clang/Driver/ClangOptionDocs.td b/clang/include/clang/Options/ClangOptionDocs.td
similarity index 98%
rename from clang/include/clang/Driver/ClangOptionDocs.td
rename to clang/include/clang/Options/ClangOptionDocs.td
index dea6a7ccb12c9..c4da07306eb8e 100644
--- a/clang/include/clang/Driver/ClangOptionDocs.td
+++ b/clang/include/clang/Options/ClangOptionDocs.td
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
def GlobalDocumentation {
- code Intro =[{..
+ code Intro = [{..
-------------------------------------------------------------------
NOTE: This file is automatically generated by running clang-tblgen
-gen-opt-docs. Do not edit this file by hand!!
diff --git a/clang/include/clang/Driver/OptionUtils.h b/clang/include/clang/Options/OptionUtils.h
similarity index 94%
rename from clang/include/clang/Driver/OptionUtils.h
rename to clang/include/clang/Options/OptionUtils.h
index 922f536bf33ea..9b5312eb63fcb 100644
--- a/clang/include/clang/Driver/OptionUtils.h
+++ b/clang/include/clang/Options/OptionUtils.h
@@ -10,8 +10,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_DRIVER_OPTIONUTILS_H
-#define LLVM_CLANG_DRIVER_OPTIONUTILS_H
+#ifndef LLVM_CLANG_OPTIONUTILS_H
+#define LLVM_CLANG_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_OPTIONUTILS_H
diff --git a/clang/include/clang/Driver/Options.h b/clang/include/clang/Options/Options.h
similarity index 86%
rename from clang/include/clang/Driver/Options.h
rename to clang/include/clang/Options/Options.h
index 0797410e9940e..1097845b6e108 100644
--- a/clang/include/clang/Driver/Options.h
+++ b/clang/include/clang/Options/Options.h
@@ -6,14 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_DRIVER_OPTIONS_H
-#define LLVM_CLANG_DRIVER_OPTIONS_H
+#ifndef LLVM_CLANG_OPTIONS_H
+#define LLVM_CLANG_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
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Options/Options.td
similarity index 100%
rename from clang/include/clang/Driver/Options.td
rename to clang/include/clang/Options/Options.td
diff --git a/clang/lib/CMakeLists.txt b/clang/lib/CMakeLists.txt
index 4f2218b583e41..e90b009da606a 100644
--- a/clang/lib/CMakeLists.txt
+++ b/clang/lib/CMakeLists.txt
@@ -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)
diff --git a/clang/lib/Driver/CMakeLists.txt b/clang/lib/Driver/CMakeLists.txt
index 7c4f70b966c48..8052659e9836b 100644
--- a/clang/lib/Driver/CMakeLists.txt
+++ b/clang/lib/Driver/CMakeLists.txt
@@ -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}
)
diff --git a/clang/lib/Driver/Compilation.cpp b/clang/lib/Driver/Compilation.cpp
index 4e300316ae9ba..f8ca2a3d09407 100644
--- a/clang/lib/Driver/Compilation.cpp
+++ b/clang/lib/Driver/Compilation.cpp
@@ -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"
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 40ea513e85427..d6c2aa8027ba3 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -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"
diff --git a/clang/lib/Driver/SanitizerArgs.cpp b/clang/lib/Driver/SanitizerArgs.cpp
index 5dd48f53b9069..420c4cddbc8dd 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -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"
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 3d5cac62afe01..7c77870223449 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -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));
@@ -1803,7 +1803,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
diff --git a/clang/lib/Driver/ToolChains/AIX.cpp b/clang/lib/Driver/ToolChains/AIX.cpp
index 066b59305fe3f..dfb0256e0adea 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -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;
@@ -168,7 +169,7 @@ void aix::Linker::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-bdbg:namedsects:ss");
if (Arg *A =
- Args.getLastArg(clang::driver::options::OPT_mxcoff_build_id_EQ)) {
+ 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)
diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index 654a382e87e40..6cb333b285a27 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -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"
@@ -322,27 +322,27 @@ 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);
+ RocmPathArg = Args.getLastArgValue(options::OPT_rocm_path_EQ);
PrintROCmSearchDirs =
- Args.hasArg(clang::driver::options::OPT_print_rocm_search_dirs);
+ 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);
+ Args.getAllArgValues(options::OPT_rocm_device_lib_path_EQ);
+ HIPPathArg = Args.getLastArgValue(options::OPT_hip_path_EQ);
HIPStdParPathArg =
- Args.getLastArgValue(clang::driver::options::OPT_hipstdpar_path_EQ);
+ 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);
+ 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;
diff --git a/clang/lib/Driver/ToolChains/AMDGPU.h b/clang/lib/Driver/ToolChains/AMDGPU.h
index e90a5736911e4..7b999c311154f 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.h
+++ b/clang/lib/Driver/ToolChains/AMDGPU.h
@@ -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"
diff --git a/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp b/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
index 2b41d54a9eb73..e14bc574d139a 100644
--- a/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
@@ -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;
diff --git a/clang/lib/Driver/ToolChains/AVR.cpp b/clang/lib/Driver/ToolChains/AVR.cpp
index 731076d9754a9..588255dc5a0cd 100644
--- a/clang/lib/Driver/ToolChains/AVR.cpp
+++ b/clang/lib/Driver/ToolChains/AVR.cpp
@@ -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"
diff --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index eb5d542f55605..683112cbb65b3 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -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)))
diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index 954ecabe86836..5a686e9548758 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -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();
diff --git a/clang/lib/Driver/ToolChains/Arch/CSKY.cpp b/clang/lib/Driver/ToolChains/Arch/CSKY.cpp
index 2fd2c72147f5b..65f6534e4d038 100644
--- a/clang/lib/Driver/ToolChains/Arch/CSKY.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/CSKY.cpp
@@ -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);
diff --git a/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp b/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
index 156ea03045569..8f7aaa397a261 100644
--- a/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
@@ -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"
@@ -131,7 +131,7 @@ void loongarch::getLoongArchTargetFeatures(const Driver &D,
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)))
+ (!Args.hasArgNoClaim(options::OPT_march_EQ)))
Features.push_back("+lsx");
// -mrelax is default, unless -mno-relax is specified.
diff --git a/clang/lib/Driver/ToolChains/Arch/M68k.cpp b/clang/lib/Driver/ToolChains/Arch/M68k.cpp
index 1037c0ea80bf6..609129d265007 100644
--- a/clang/lib/Driver/ToolChains/Arch/M68k.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/M68k.cpp
@@ -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 "";
diff --git a/clang/lib/Driver/ToolChains/Arch/Mips.cpp b/clang/lib/Driver/ToolChains/Arch/Mips.cpp
index bac8681921877..bcf8f3ab0edeb 100644
--- a/clang/lib/Driver/ToolChains/Arch/Mips.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/Mips.cpp
@@ -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,7 +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,
+ if (Arg *A = Args.getLastArg(options::OPT_march_EQ,
options::OPT_mcpu_EQ))
CPUName = A->getValue();
diff --git a/clang/lib/Driver/ToolChains/Arch/PPC.cpp b/clang/lib/Driver/ToolChains/Arch/PPC.cpp
index 361a68a892a8f..44afdd249fea5 100644
--- a/clang/lib/Driver/ToolChains/Arch/PPC.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/PPC.cpp
@@ -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"
diff --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
index f2e79e71f93d4..1dcce6d053a39 100644
--- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -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"
diff --git a/clang/lib/Driver/ToolChains/Arch/Sparc.cpp b/clang/lib/Driver/ToolChains/Arch/Sparc.cpp
index 94a94f1e9c487..49256d80cbdf6 100644
--- a/clang/lib/Driver/ToolChains/Arch/Sparc.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/Sparc.cpp
@@ -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());
diff --git a/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp b/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp
index 75b6afd925245..97dc9bd853ede 100644
--- a/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp
@@ -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,
+ if (Arg *A = Args.getLastArg(options::OPT_msoft_float,
options::OPT_mhard_float))
- if (A->getOption().matches(clang::driver::options::OPT_msoft_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") {
diff --git a/clang/lib/Driver/ToolChains/Arch/VE.cpp b/clang/lib/Driver/ToolChains/Arch/VE.cpp
index adc0873586588..c8353d7dc5f3a 100644
--- a/clang/lib/Driver/ToolChains/Arch/VE.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/VE.cpp
@@ -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;
diff --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp b/clang/lib/Driver/ToolChains/Arch/X86.cpp
index 1373905a5120e..092069b6ade56 100644
--- a/clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -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);
diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 9b7f58c392885..8d598be9ffb0a 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -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();
}
diff --git a/clang/lib/Driver/ToolChains/CSKYToolChain.cpp b/clang/lib/Driver/ToolChains/CSKYToolChain.cpp
index e4db3307ee3aa..c561d7d38da5b 100644
--- a/clang/lib/Driver/ToolChains/CSKYToolChain.cpp
+++ b/clang/lib/Driver/ToolChains/CSKYToolChain.cpp
@@ -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"
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index a7310ba2da061..08dd2a2160296 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -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,
@@ -1711,7 +1711,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()));
@@ -2111,7 +2111,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")
@@ -2217,12 +2217,12 @@ 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) &&
+ 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") {
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 99400ac701fbe..2452967bc0b2f 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -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,8 @@ 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())
@@ -251,15 +251,15 @@ getFramePointerKind(const llvm::opt::ArgList &Args,
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);
+ 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);
+ options::OPT_mno_omit_leaf_frame_pointer,
+ options::OPT_momit_leaf_frame_pointer, DefaultLeafFP);
bool FPRegReserved = EnableFP || mustMaintainValidFrameChain(Args, Triple);
@@ -753,7 +753,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));
@@ -1724,7 +1724,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)
@@ -3376,7 +3376,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 "";
diff --git a/clang/lib/Driver/ToolChains/CrossWindows.cpp b/clang/lib/Driver/ToolChains/CrossWindows.cpp
index 51c892fc91718..6df5315e8fff8 100644
--- a/clang/lib/Driver/ToolChains/CrossWindows.cpp
+++ b/clang/lib/Driver/ToolChains/CrossWindows.cpp
@@ -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"
diff --git a/clang/lib/Driver/ToolChains/Cuda.cpp b/clang/lib/Driver/ToolChains/Cuda.cpp
index 07201cc4676ac..6cc73ff5fc1f6 100644
--- a/clang/lib/Driver/ToolChains/Cuda.cpp
+++ b/clang/lib/Driver/ToolChains/Cuda.cpp
@@ -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.
diff --git a/clang/lib/Driver/ToolChains/Cygwin.cpp b/clang/lib/Driver/ToolChains/Cygwin.cpp
index d9c16347daa34..55438125ce0f1 100644
--- a/clang/lib/Driver/ToolChains/Cygwin.cpp
+++ b/clang/lib/Driver/ToolChains/Cygwin.cpp
@@ -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))
diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp
index d2356ebdfa86c..4ffb47c34c1d8 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -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.
diff --git a/clang/lib/Driver/ToolChains/DragonFly.cpp b/clang/lib/Driver/ToolChains/DragonFly.cpp
index 524f5f2ff391e..d4a6d6ae3e349 100644
--- a/clang/lib/Driver/ToolChains/DragonFly.cpp
+++ b/clang/lib/Driver/ToolChains/DragonFly.cpp
@@ -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)) {
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp
index a56fa41c49d34..272b5d448f8ab 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -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");
}
diff --git a/clang/lib/Driver/ToolChains/FreeBSD.cpp b/clang/lib/Driver/ToolChains/FreeBSD.cpp
index b17b76233ad30..70e66a2f5c3e7 100644
--- a/clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ b/clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -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)) {
diff --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index 146dc8bbd5313..aff2df8efacf0 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -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)
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
index 7616076847a2c..2d8d5818fe7eb 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -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();
@@ -2112,7 +2112,7 @@ void Generic_GCC::GCCInstallationDetector::init(
// If --gcc-install-dir= is specified, skip filesystem detection.
if (const Arg *A =
- Args.getLastArg(clang::driver::options::OPT_gcc_install_dir_EQ);
+ Args.getLastArg(options::OPT_gcc_install_dir_EQ);
A && A->getValue()[0]) {
StringRef InstallDir = A->getValue();
if (!ScanGCCForMultilibs(TargetTriple, Args, InstallDir, false)) {
@@ -2136,7 +2136,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)) {
+ Args.getLastArg(options::OPT_gcc_triple_EQ)) {
StringRef GCCTriple = A->getValue();
CandidateTripleAliases.clear();
CandidateTripleAliases.push_back(GCCTriple);
diff --git a/clang/lib/Driver/ToolChains/HIPAMD.cpp b/clang/lib/Driver/ToolChains/HIPAMD.cpp
index c0c8afec07264..0fbfa090ed9d3 100644
--- a/clang/lib/Driver/ToolChains/HIPAMD.cpp
+++ b/clang/lib/Driver/ToolChains/HIPAMD.cpp
@@ -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"
diff --git a/clang/lib/Driver/ToolChains/HIPSPV.cpp b/clang/lib/Driver/ToolChains/HIPSPV.cpp
index bce7f46dea468..be0f49d8e1497 100644
--- a/clang/lib/Driver/ToolChains/HIPSPV.cpp
+++ b/clang/lib/Driver/ToolChains/HIPSPV.cpp
@@ -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));
diff --git a/clang/lib/Driver/ToolChains/HIPUtility.cpp b/clang/lib/Driver/ToolChains/HIPUtility.cpp
index 732403e69a075..1af2ae6470f1e 100644
--- a/clang/lib/Driver/ToolChains/HIPUtility.cpp
+++ b/clang/lib/Driver/ToolChains/HIPUtility.cpp
@@ -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"
diff --git a/clang/lib/Driver/ToolChains/Hexagon.cpp b/clang/lib/Driver/ToolChains/Hexagon.cpp
index 9f8b676fc7dc2..084f51721315c 100644
--- a/clang/lib/Driver/ToolChains/Hexagon.cpp
+++ b/clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -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"
diff --git a/clang/lib/Driver/ToolChains/Hurd.cpp b/clang/lib/Driver/ToolChains/Hurd.cpp
index 43121233ea7d0..53ee4d4c0cbde 100644
--- a/clang/lib/Driver/ToolChains/Hurd.cpp
+++ b/clang/lib/Driver/ToolChains/Hurd.cpp
@@ -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))
diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
index 8eb4d34e0827a..cb9d81e33acee 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -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"
@@ -635,7 +635,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
diff --git a/clang/lib/Driver/ToolChains/MSP430.cpp b/clang/lib/Driver/ToolChains/MSP430.cpp
index 9eca1ad5f2865..3cc56bb7e832e 100644
--- a/clang/lib/Driver/ToolChains/MSP430.cpp
+++ b/clang/lib/Driver/ToolChains/MSP430.cpp
@@ -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"
diff --git a/clang/lib/Driver/ToolChains/MSVC.cpp b/clang/lib/Driver/ToolChains/MSVC.cpp
index bb469ff095cd4..fcae5b7a18f34 100644
--- a/clang/lib/Driver/ToolChains/MSVC.cpp
+++ b/clang/lib/Driver/ToolChains/MSVC.cpp
@@ -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"
diff --git a/clang/lib/Driver/ToolChains/Managarm.cpp b/clang/lib/Driver/ToolChains/Managarm.cpp
index da4a9072317f4..1bbabdfc631b8 100644
--- a/clang/lib/Driver/ToolChains/Managarm.cpp
+++ b/clang/lib/Driver/ToolChains/Managarm.cpp
@@ -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))
diff --git a/clang/lib/Driver/ToolChains/MinGW.cpp b/clang/lib/Driver/ToolChains/MinGW.cpp
index 1bb9bcfe6aab2..2c9a174069f70 100644
--- a/clang/lib/Driver/ToolChains/MinGW.cpp
+++ b/clang/lib/Driver/ToolChains/MinGW.cpp
@@ -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"
diff --git a/clang/lib/Driver/ToolChains/MipsLinux.cpp b/clang/lib/Driver/ToolChains/MipsLinux.cpp
index 7dd3936613296..58d6b5031f536 100644
--- a/clang/lib/Driver/ToolChains/MipsLinux.cpp
+++ b/clang/lib/Driver/ToolChains/MipsLinux.cpp
@@ -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();
diff --git a/clang/lib/Driver/ToolChains/NetBSD.cpp b/clang/lib/Driver/ToolChains/NetBSD.cpp
index 8db00deeb80df..ea722b59853d6 100644
--- a/clang/lib/Driver/ToolChains/NetBSD.cpp
+++ b/clang/lib/Driver/ToolChains/NetBSD.cpp
@@ -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)) {
diff --git a/clang/lib/Driver/ToolChains/OHOS.cpp b/clang/lib/Driver/ToolChains/OHOS.cpp
index 00991504e97a8..607eb714f85dc 100644
--- a/clang/lib/Driver/ToolChains/OHOS.cpp
+++ b/clang/lib/Driver/ToolChains/OHOS.cpp
@@ -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)
diff --git a/clang/lib/Driver/ToolChains/OpenBSD.cpp b/clang/lib/Driver/ToolChains/OpenBSD.cpp
index 8f589186af343..5e7b4f1a664e6 100644
--- a/clang/lib/Driver/ToolChains/OpenBSD.cpp
+++ b/clang/lib/Driver/ToolChains/OpenBSD.cpp
@@ -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)) {
diff --git a/clang/lib/Driver/ToolChains/PPCFreeBSD.cpp b/clang/lib/Driver/ToolChains/PPCFreeBSD.cpp
index 8d381c4f14371..76180431ee682 100644
--- a/clang/lib/Driver/ToolChains/PPCFreeBSD.cpp
+++ b/clang/lib/Driver/ToolChains/PPCFreeBSD.cpp
@@ -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);
diff --git a/clang/lib/Driver/ToolChains/PPCLinux.cpp b/clang/lib/Driver/ToolChains/PPCLinux.cpp
index 768214e416bd7..672ebd5b7b98d 100644
--- a/clang/lib/Driver/ToolChains/PPCLinux.cpp
+++ b/clang/lib/Driver/ToolChains/PPCLinux.cpp
@@ -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);
diff --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp b/clang/lib/Driver/ToolChains/PS4CPU.cpp
index 61afc61a53dfd..d9f1a141eaaee 100644
--- a/clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -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"
diff --git a/clang/lib/Driver/ToolChains/SPIRV.cpp b/clang/lib/Driver/ToolChains/SPIRV.cpp
index ea824dbad54cb..27de55cfebfc1 100644
--- a/clang/lib/Driver/ToolChains/SPIRV.cpp
+++ b/clang/lib/Driver/ToolChains/SPIRV.cpp
@@ -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;
diff --git a/clang/lib/Driver/ToolChains/SYCL.cpp b/clang/lib/Driver/ToolChains/SYCL.cpp
index 0232b047a6c4b..85859f344b491 100644
--- a/clang/lib/Driver/ToolChains/SYCL.cpp
+++ b/clang/lib/Driver/ToolChains/SYCL.cpp
@@ -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.
diff --git a/clang/lib/Driver/ToolChains/Solaris.cpp b/clang/lib/Driver/ToolChains/Solaris.cpp
index 02aa59817449d..eb3130389964b 100644
--- a/clang/lib/Driver/ToolChains/Solaris.cpp
+++ b/clang/lib/Driver/ToolChains/Solaris.cpp
@@ -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))
diff --git a/clang/lib/Driver/ToolChains/UEFI.cpp b/clang/lib/Driver/ToolChains/UEFI.cpp
index d2be147c7b9f6..7732e37f8061d 100644
--- a/clang/lib/Driver/ToolChains/UEFI.cpp
+++ b/clang/lib/Driver/ToolChains/UEFI.cpp
@@ -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"
diff --git a/clang/lib/Driver/ToolChains/VEToolchain.cpp b/clang/lib/Driver/ToolChains/VEToolchain.cpp
index ad9129046c3e1..78509bcdae0fe 100644
--- a/clang/lib/Driver/ToolChains/VEToolchain.cpp
+++ b/clang/lib/Driver/ToolChains/VEToolchain.cpp
@@ -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;
diff --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index 5054868b5ff4d..15c6f19e87fee 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -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();
diff --git a/clang/lib/Driver/ToolChains/XCore.cpp b/clang/lib/Driver/ToolChains/XCore.cpp
index 6a2a75cb99739..dd26c11affffb 100644
--- a/clang/lib/Driver/ToolChains/XCore.cpp
+++ b/clang/lib/Driver/ToolChains/XCore.cpp
@@ -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;
diff --git a/clang/lib/Driver/ToolChains/ZOS.cpp b/clang/lib/Driver/ToolChains/ZOS.cpp
index 57bcb3c306cef..7f41aeb5d2374 100644
--- a/clang/lib/Driver/ToolChains/ZOS.cpp
+++ b/clang/lib/Driver/ToolChains/ZOS.cpp
@@ -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"
diff --git a/clang/lib/Driver/XRayArgs.cpp b/clang/lib/Driver/XRayArgs.cpp
index 0325296f84b19..4c2d11751a363 100644
--- a/clang/lib/Driver/XRayArgs.cpp
+++ b/clang/lib/Driver/XRayArgs.cpp
@@ -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"
diff --git a/clang/lib/Frontend/CMakeLists.txt b/clang/lib/Frontend/CMakeLists.txt
index a916667208845..dac9e0d26f393 100644
--- a/clang/lib/Frontend/CMakeLists.txt
+++ b/clang/lib/Frontend/CMakeLists.txt
@@ -52,6 +52,7 @@ add_clang_library(clangFrontend
clangAST
clangBasic
clangDriver
+ clangOptions
clangEdit
clangLex
clangParse
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 5bd15f5d4ca31..42e3aefd0640c 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -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) {
@@ -1884,7 +1884,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
@@ -2384,7 +2384,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)
@@ -2419,7 +2419,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)) {
@@ -2547,7 +2547,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
}
@@ -2559,7 +2559,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;
@@ -2570,7 +2570,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
}
@@ -2582,7 +2582,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;
@@ -2594,7 +2594,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())
@@ -2699,7 +2699,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);
@@ -2849,7 +2849,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 =
@@ -3019,7 +3019,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;
@@ -3301,7 +3301,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)
@@ -3416,7 +3416,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))
@@ -3749,7 +3749,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.
@@ -4072,7 +4072,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)) {
@@ -4713,7 +4713,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)
@@ -4787,7 +4787,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) ||
@@ -4880,7 +4880,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;
@@ -4901,7 +4901,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);
@@ -4916,7 +4916,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())
@@ -4935,7 +4935,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)) {
diff --git a/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp b/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
index 99212b81fe064..73b81ed906808 100644
--- a/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
+++ b/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
@@ -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;
}
diff --git a/clang/lib/FrontendTool/CMakeLists.txt b/clang/lib/FrontendTool/CMakeLists.txt
index 061e54c3e62d0..66213f76eb968 100644
--- a/clang/lib/FrontendTool/CMakeLists.txt
+++ b/clang/lib/FrontendTool/CMakeLists.txt
@@ -7,6 +7,7 @@ set(link_libs
clangBasic
clangCodeGen
clangDriver
+ clangOptions
clangExtractAPI
clangFrontend
clangRewriteFrontend
diff --git a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
index c8aad4daa1c10..e571193c6a9c8 100644
--- a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -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;
}
diff --git a/clang/lib/Interpreter/Interpreter.cpp b/clang/lib/Interpreter/Interpreter.cpp
index b05cb5a0f1dbe..966333b52ccbc 100644
--- a/clang/lib/Interpreter/Interpreter.cpp
+++ b/clang/lib/Interpreter/Interpreter.cpp
@@ -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());
diff --git a/clang/lib/Interpreter/InterpreterUtils.h b/clang/lib/Interpreter/InterpreterUtils.h
index fbf9814b0d4a7..4efe8b9fbc6cc 100644
--- a/clang/lib/Interpreter/InterpreterUtils.h
+++ b/clang/lib/Interpreter/InterpreterUtils.h
@@ -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"
diff --git a/clang/lib/Options/CMakeLists.txt b/clang/lib/Options/CMakeLists.txt
new file mode 100644
index 0000000000000..a762e9918b41c
--- /dev/null
+++ b/clang/lib/Options/CMakeLists.txt
@@ -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}
+)
diff --git a/clang/lib/Driver/DriverOptions.cpp b/clang/lib/Options/DriverOptions.cpp
similarity index 76%
rename from clang/lib/Driver/DriverOptions.cpp
rename to clang/lib/Options/DriverOptions.cpp
index cde1f8989935b..d91e9291fb2f6 100644
--- a/clang/lib/Driver/DriverOptions.cpp
+++ b/clang/lib/Options/DriverOptions.cpp
@@ -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 @@ class DriverOptTable : public PrecomputedOptTable {
: 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;
}
diff --git a/clang/lib/Driver/OptionUtils.cpp b/clang/lib/Options/OptionUtils.cpp
similarity index 97%
rename from clang/lib/Driver/OptionUtils.cpp
rename to clang/lib/Options/OptionUtils.cpp
index 1f36ffc03cab3..e22692d02ec65 100644
--- a/clang/lib/Driver/OptionUtils.cpp
+++ b/clang/lib/Options/OptionUtils.cpp
@@ -8,7 +8,7 @@
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticDriver.h"
-#include "clang/Driver/OptionUtils.h"
+#include "clang/Options/OptionUtils.h"
#include "llvm/Option/ArgList.h"
using namespace clang;
diff --git a/clang/lib/Tooling/CMakeLists.txt b/clang/lib/Tooling/CMakeLists.txt
index fc1f1f9f9d367..faaa53276d0e6 100644
--- a/clang/lib/Tooling/CMakeLists.txt
+++ b/clang/lib/Tooling/CMakeLists.txt
@@ -40,6 +40,7 @@ add_clang_library(clangTooling
clangASTMatchers
clangBasic
clangDriver
+ clangOptions
clangFormat
clangFrontend
clangLex
diff --git a/clang/lib/Tooling/InterpolatingCompilationDatabase.cpp b/clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
index 28568426a6c48..e9b72388ae4df 100644
--- a/clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
+++ b/clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
@@ -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 @@ struct TransferableCommand {
// 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 @@ struct TransferableCommand {
// 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.
diff --git a/clang/lib/Tooling/Tooling.cpp b/clang/lib/Tooling/Tooling.cpp
index ea5a37216e959..f3793179694b0 100644
--- a/clang/lib/Tooling/Tooling.cpp
+++ b/clang/lib/Tooling/Tooling.cpp
@@ -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,17 @@ 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();
+ Table.getOption(options::OPT_target).getPrefixedName();
// -target X
StringRef TargetOPTLegacy =
- Table.getOption(driver::options::OPT_target_legacy_spelling)
+ 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.
diff --git a/clang/tools/clang-check/CMakeLists.txt b/clang/tools/clang-check/CMakeLists.txt
index 5493aa4237aee..1efcc91fcaec9 100644
--- a/clang/tools/clang-check/CMakeLists.txt
+++ b/clang/tools/clang-check/CMakeLists.txt
@@ -14,6 +14,7 @@ clang_target_link_libraries(clang-check
clangBasic
clangDriver
clangFrontend
+ clangOptions
clangRewriteFrontend
clangSerialization
clangStaticAnalyzerFrontend
diff --git a/clang/tools/clang-check/ClangCheck.cpp b/clang/tools/clang-check/ClangCheck.cpp
index fa6dd06a1ee58..80255c647b98f 100644
--- a/clang/tools/clang-check/ClangCheck.cpp
+++ b/clang/tools/clang-check/ClangCheck.cpp
@@ -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);
diff --git a/clang/tools/clang-installapi/CMakeLists.txt b/clang/tools/clang-installapi/CMakeLists.txt
index 9c0d9dff7dc7f..54bc80486472f 100644
--- a/clang/tools/clang-installapi/CMakeLists.txt
+++ b/clang/tools/clang-installapi/CMakeLists.txt
@@ -25,6 +25,7 @@ clang_target_link_libraries(clang-installapi
clangAST
clangInstallAPI
clangBasic
+ clangOptions
clangDriver
clangFrontend
clangTooling
diff --git a/clang/tools/clang-installapi/ClangInstallAPI.cpp b/clang/tools/clang-installapi/ClangInstallAPI.cpp
index 16abeb10284c0..75005984a1dc1 100644
--- a/clang/tools/clang-installapi/ClangInstallAPI.cpp
+++ b/clang/tools/clang-installapi/ClangInstallAPI.cpp
@@ -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);
diff --git a/clang/tools/clang-installapi/Options.cpp b/clang/tools/clang-installapi/Options.cpp
index 64324a3f8b010..8dea9e63d2d17 100644
--- a/clang/tools/clang-installapi/Options.cpp
+++ b/clang/tools/clang-installapi/Options.cpp
@@ -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,27 +413,27 @@ 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,
+ options::OPT_fapplication_extension, options::OPT_fno_application_extension,
/*Default=*/LinkerOpts.AppExtensionSafe);
if (::getenv("LD_NO_ENCRYPT") != nullptr)
@@ -446,7 +444,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 +459,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 +473,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 +500,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())
diff --git a/clang/tools/driver/CMakeLists.txt b/clang/tools/driver/CMakeLists.txt
index d9d36f7a41359..002aaef005253 100644
--- a/clang/tools/driver/CMakeLists.txt
+++ b/clang/tools/driver/CMakeLists.txt
@@ -63,6 +63,7 @@ clang_target_link_libraries(clang
clangDriver
clangFrontend
clangFrontendTool
+ clangOptions
clangSerialization
)
diff --git a/clang/tools/driver/cc1_main.cpp b/clang/tools/driver/cc1_main.cpp
index 49f8843515a35..b19b10353591a 100644
--- a/clang/tools/driver/cc1_main.cpp
+++ b/clang/tools/driver/cc1_main.cpp
@@ -17,7 +17,6 @@
#include "clang/CodeGen/ObjectFilePCHContainerWriter.h"
#include "clang/Config/config.h"
#include "clang/Driver/DriverDiagnostic.h"
-#include "clang/Driver/Options.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/CompilerInvocation.h"
#include "clang/Frontend/FrontendDiagnostic.h"
@@ -25,6 +24,7 @@
#include "clang/Frontend/TextDiagnosticPrinter.h"
#include "clang/Frontend/Utils.h"
#include "clang/FrontendTool/Utils.h"
+#include "clang/Options/Options.h"
#include "clang/Serialization/ObjectFilePCHContainerReader.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h"
diff --git a/clang/tools/driver/cc1as_main.cpp b/clang/tools/driver/cc1as_main.cpp
index 50da2f8449a22..876a302a42bc4 100644
--- a/clang/tools/driver/cc1as_main.cpp
+++ b/clang/tools/driver/cc1as_main.cpp
@@ -14,10 +14,10 @@
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticOptions.h"
#include "clang/Driver/DriverDiagnostic.h"
-#include "clang/Driver/Options.h"
#include "clang/Frontend/FrontendDiagnostic.h"
#include "clang/Frontend/TextDiagnosticPrinter.h"
#include "clang/Frontend/Utils.h"
+#include "clang/Options/Options.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSwitch.h"
@@ -59,8 +59,7 @@
#include <optional>
#include <system_error>
using namespace clang;
-using namespace clang::driver;
-using namespace clang::driver::options;
+using namespace clang::options;
using namespace llvm;
using namespace llvm::opt;
@@ -689,7 +688,7 @@ int cc1as_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {
llvm::outs(), "clang -cc1as [options] file...",
"Clang Integrated Assembler", /*ShowHidden=*/false,
/*ShowAllAliases=*/false,
- llvm::opt::Visibility(driver::options::CC1AsOption));
+ llvm::opt::Visibility(options::CC1AsOption));
return 0;
}
diff --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp
index 7390d7d610ec0..1e2c9884ba63d 100644
--- a/clang/tools/driver/driver.cpp
+++ b/clang/tools/driver/driver.cpp
@@ -18,13 +18,13 @@
#include "clang/Config/config.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/DriverDiagnostic.h"
-#include "clang/Driver/Options.h"
#include "clang/Driver/ToolChain.h"
#include "clang/Frontend/ChainedDiagnosticConsumer.h"
#include "clang/Frontend/CompilerInvocation.h"
#include "clang/Frontend/SerializedDiagnosticPrinter.h"
#include "clang/Frontend/TextDiagnosticPrinter.h"
#include "clang/Frontend/Utils.h"
+#include "clang/Options/Options.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
diff --git a/clang/unittests/Driver/DXCModeTest.cpp b/clang/unittests/Driver/DXCModeTest.cpp
index 62274235c53f5..061d47b1887db 100644
--- a/clang/unittests/Driver/DXCModeTest.cpp
+++ b/clang/unittests/Driver/DXCModeTest.cpp
@@ -132,7 +132,7 @@ TEST(DxcModeTest, ValidatorVersionValidation) {
EXPECT_NE(TranslatedArgs, nullptr);
if (TranslatedArgs) {
auto *A = TranslatedArgs->getLastArg(
- clang::driver::options::OPT_dxil_validator_version);
+ clang::options::OPT_dxil_validator_version);
EXPECT_NE(A, nullptr);
if (A) {
EXPECT_STREQ(A->getValue(), "1.1");
diff --git a/clang/www/OpenProjects.html b/clang/www/OpenProjects.html
index ae0ec1d4d12cb..3e5e84b5b2ed4 100755
--- a/clang/www/OpenProjects.html
+++ b/clang/www/OpenProjects.html
@@ -38,7 +38,7 @@ <h1>Open Clang Projects</h1>
<li>documenting <a href="https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/DiagnosticDocs.td">
diagnostic group flags</a> (adding code examples of what is diagnosed, or
other relevant information), or</li>
- <li>documenting <a href="https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Driver/Options.td">
+ <li>documenting <a href="https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Options/Options.td">
command line options</a>, or</li>
<li>help with completing other missing documentation.</li>
</ul>
diff --git a/flang/docs/FlangDriver.md b/flang/docs/FlangDriver.md
index 3286171bb1499..9953f2252218b 100644
--- a/flang/docs/FlangDriver.md
+++ b/flang/docs/FlangDriver.md
@@ -76,7 +76,7 @@ will ignore it when used without `Xflang`.
As hinted above, `flang` and `flang -fc1` are two separate tools. The
fact that these tools are accessed through one binary, `flang`, is just an
implementation detail. Each tool has a separate list of options, albeit defined
-in the same file: `clang/include/clang/Driver/Options.td`.
+in the same file: `clang/include/clang/Options/Options.td`.
The separation helps us split various tasks and allows us to implement more
specialised tools. In particular, `flang` is not aware of various
@@ -112,7 +112,7 @@ in terms of Clang's driver library, `clangDriver`. This approach allows us to:
as linkers and assemblers.
One implication of this dependency on Clang is that all of Flang's compiler
options are defined alongside Clang's options in
-`clang/include/clang/Driver/Options.td`. For options that are common for both
+`clang/include/clang/Options/Options.td`. For options that are common for both
Flang and Clang, the corresponding definitions are shared.
Internally, a `clangDriver` based compiler driver works by creating actions
@@ -242,7 +242,7 @@ Adding a new compiler option in Flang consists of two steps:
### Option Definition
All of Flang's compiler and frontend driver options are defined in
-`clang/include/clang/Driver/Options.td` in Clang. When adding a new option to
+`clang/include/clang/Options/Options.td` in Clang. When adding a new option to
Flang, you will either:
* extend the existing definition for an option that is already available
in one of Clang's drivers (e.g. `clang`), but not yet available in Flang, or
@@ -314,7 +314,7 @@ add, you will have to add a dedicated entry in that enum (e.g.
`ParseSyntaxOnly` for `-fsyntax-only`) and a corresponding `case` in
`ParseFrontendArgs` function in the `CompilerInvocation.cpp` file, e.g.:
```cpp
- case clang::driver::options::OPT_fsyntax_only:
+ case clang::options::OPT_fsyntax_only:
opts.programAction = ParseSyntaxOnly;
break;
```
diff --git a/flang/lib/Frontend/CMakeLists.txt b/flang/lib/Frontend/CMakeLists.txt
index fa0d5ecfdb9bd..629fc540a00c2 100644
--- a/flang/lib/Frontend/CMakeLists.txt
+++ b/flang/lib/Frontend/CMakeLists.txt
@@ -74,6 +74,7 @@ add_flang_library(flangFrontend
CLANG_LIBS
clangBasic
clangDriver
+ clangOptions
)
target_precompile_headers(flangFrontend PRIVATE
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index 548ca675db5ea..63eb1958d8f1b 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -26,8 +26,8 @@
#include "clang/Basic/DiagnosticOptions.h"
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Driver.h"
-#include "clang/Driver/OptionUtils.h"
-#include "clang/Driver/Options.h"
+#include "clang/Options/OptionUtils.h"
+#include "clang/Options/Options.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"
@@ -82,11 +82,11 @@ static bool parseShowColorsArgs(const llvm::opt::ArgList &args,
for (auto *a : args) {
const llvm::opt::Option &opt = a->getOption();
- if (opt.matches(clang::driver::options::OPT_fcolor_diagnostics)) {
+ if (opt.matches(clang::options::OPT_fcolor_diagnostics)) {
showColors = Colors_On;
- } else if (opt.matches(clang::driver::options::OPT_fno_color_diagnostics)) {
+ } else if (opt.matches(clang::options::OPT_fno_color_diagnostics)) {
showColors = Colors_Off;
- } else if (opt.matches(clang::driver::options::OPT_fdiagnostics_color_EQ)) {
+ } else if (opt.matches(clang::options::OPT_fdiagnostics_color_EQ)) {
llvm::StringRef value(a->getValue());
if (value == "always")
showColors = Colors_On;
@@ -108,13 +108,13 @@ static unsigned getOptimizationLevel(llvm::opt::ArgList &args,
unsigned defaultOpt = 0;
if (llvm::opt::Arg *a =
- args.getLastArg(clang::driver::options::OPT_O_Group)) {
- if (a->getOption().matches(clang::driver::options::OPT_O0))
+ args.getLastArg(clang::options::OPT_O_Group)) {
+ if (a->getOption().matches(clang::options::OPT_O0))
return 0;
- assert(a->getOption().matches(clang::driver::options::OPT_O));
+ assert(a->getOption().matches(clang::options::OPT_O));
- return getLastArgIntValue(args, clang::driver::options::OPT_O, defaultOpt,
+ return getLastArgIntValue(args, clang::options::OPT_O, defaultOpt,
diags);
}
@@ -133,7 +133,7 @@ static bool parseDebugArgs(Fortran::frontend::CodeGenOptions &opts,
clang::DiagnosticsEngine &diags) {
using DebugInfoKind = llvm::codegenoptions::DebugInfoKind;
if (llvm::opt::Arg *arg =
- args.getLastArg(clang::driver::options::OPT_debug_info_kind_EQ)) {
+ args.getLastArg(clang::options::OPT_debug_info_kind_EQ)) {
std::optional<DebugInfoKind> val =
llvm::StringSwitch<std::optional<DebugInfoKind>>(arg->getValue())
.Case("line-tables-only", llvm::codegenoptions::DebugLineTablesOnly)
@@ -158,13 +158,13 @@ static bool parseDebugArgs(Fortran::frontend::CodeGenOptions &opts,
diags.Report(debugWarning) << arg->getValue();
}
opts.DwarfVersion =
- getLastArgIntValue(args, clang::driver::options::OPT_dwarf_version_EQ,
+ getLastArgIntValue(args, clang::options::OPT_dwarf_version_EQ,
/*Default=*/0, diags);
if (const llvm::opt::Arg *a =
- args.getLastArg(clang::driver::options::OPT_split_dwarf_file))
+ args.getLastArg(clang::options::OPT_split_dwarf_file))
opts.SplitDwarfFile = a->getValue();
if (const llvm::opt::Arg *a =
- args.getLastArg(clang::driver::options::OPT_split_dwarf_output))
+ args.getLastArg(clang::options::OPT_split_dwarf_output))
opts.SplitDwarfOutput = a->getValue();
}
return true;
@@ -174,7 +174,7 @@ static void parseDoConcurrentMapping(Fortran::frontend::CodeGenOptions &opts,
llvm::opt::ArgList &args,
clang::DiagnosticsEngine &diags) {
llvm::opt::Arg *arg =
- args.getLastArg(clang::driver::options::OPT_fdo_concurrent_to_openmp_EQ);
+ args.getLastArg(clang::options::OPT_fdo_concurrent_to_openmp_EQ);
if (!arg)
return;
@@ -199,7 +199,7 @@ static void parseDoConcurrentMapping(Fortran::frontend::CodeGenOptions &opts,
static bool parseVectorLibArg(Fortran::frontend::CodeGenOptions &opts,
llvm::opt::ArgList &args,
clang::DiagnosticsEngine &diags) {
- llvm::opt::Arg *arg = args.getLastArg(clang::driver::options::OPT_fveclib);
+ llvm::opt::Arg *arg = args.getLastArg(clang::options::OPT_fveclib);
if (!arg)
return true;
@@ -237,7 +237,7 @@ parseOptimizationRemark(clang::DiagnosticsEngine &diags,
CodeGenOptions::OptRemark result;
for (llvm::opt::Arg *a : args) {
- if (a->getOption().matches(clang::driver::options::OPT_R_Joined)) {
+ if (a->getOption().matches(clang::options::OPT_R_Joined)) {
llvm::StringRef value = a->getValue();
if (value == remarkOptName) {
@@ -274,39 +274,39 @@ static void parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts,
clang::DiagnosticsEngine &diags) {
opts.OptimizationLevel = getOptimizationLevel(args, diags);
- if (args.hasFlag(clang::driver::options::OPT_fdebug_pass_manager,
- clang::driver::options::OPT_fno_debug_pass_manager, false))
+ if (args.hasFlag(clang::options::OPT_fdebug_pass_manager,
+ clang::options::OPT_fno_debug_pass_manager, false))
opts.DebugPassManager = 1;
- if (args.hasFlag(clang::driver::options::OPT_fstack_arrays,
- clang::driver::options::OPT_fno_stack_arrays, false))
+ if (args.hasFlag(clang::options::OPT_fstack_arrays,
+ clang::options::OPT_fno_stack_arrays, false))
opts.StackArrays = 1;
- if (args.getLastArg(clang::driver::options::OPT_floop_interchange))
+ if (args.getLastArg(clang::options::OPT_floop_interchange))
opts.InterchangeLoops = 1;
- if (args.getLastArg(clang::driver::options::OPT_fexperimental_loop_fusion))
+ if (args.getLastArg(clang::options::OPT_fexperimental_loop_fusion))
opts.FuseLoops = 1;
- if (args.getLastArg(clang::driver::options::OPT_vectorize_loops))
+ if (args.getLastArg(clang::options::OPT_vectorize_loops))
opts.VectorizeLoop = 1;
- if (args.getLastArg(clang::driver::options::OPT_vectorize_slp))
+ if (args.getLastArg(clang::options::OPT_vectorize_slp))
opts.VectorizeSLP = 1;
- if (args.hasFlag(clang::driver::options::OPT_floop_versioning,
- clang::driver::options::OPT_fno_loop_versioning, false))
+ if (args.hasFlag(clang::options::OPT_floop_versioning,
+ clang::options::OPT_fno_loop_versioning, false))
opts.LoopVersioning = 1;
- opts.UnrollLoops = args.hasFlag(clang::driver::options::OPT_funroll_loops,
- clang::driver::options::OPT_fno_unroll_loops,
+ opts.UnrollLoops = args.hasFlag(clang::options::OPT_funroll_loops,
+ clang::options::OPT_fno_unroll_loops,
(opts.OptimizationLevel > 1));
opts.AliasAnalysis = opts.OptimizationLevel > 0;
// -mframe-pointer=none/non-leaf/reserved/all option.
if (const llvm::opt::Arg *a =
- args.getLastArg(clang::driver::options::OPT_mframe_pointer_EQ)) {
+ args.getLastArg(clang::options::OPT_mframe_pointer_EQ)) {
std::optional<llvm::FramePointerKind> val =
llvm::StringSwitch<std::optional<llvm::FramePointerKind>>(a->getValue())
.Case("none", llvm::FramePointerKind::None)
@@ -322,7 +322,7 @@ static void parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts,
opts.setFramePointer(val.value());
}
- for (auto *a : args.filtered(clang::driver::options::OPT_fpass_plugin_EQ))
+ for (auto *a : args.filtered(clang::options::OPT_fpass_plugin_EQ))
opts.LLVMPassPlugins.push_back(a->getValue());
opts.Reciprocals = clang::driver::tools::parseMRecipOption(diags, args);
@@ -332,14 +332,14 @@ static void parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts,
// -fembed-offload-object option
for (auto *a :
- args.filtered(clang::driver::options::OPT_fembed_offload_object_EQ))
+ args.filtered(clang::options::OPT_fembed_offload_object_EQ))
opts.OffloadObjects.push_back(a->getValue());
- if (args.hasArg(clang::driver::options::OPT_finstrument_functions))
+ if (args.hasArg(clang::options::OPT_finstrument_functions))
opts.InstrumentFunctions = 1;
if (const llvm::opt::Arg *a = args.getLastArg(
- clang::driver::options::OPT_mcode_object_version_EQ)) {
+ clang::options::OPT_mcode_object_version_EQ)) {
llvm::StringRef s = a->getValue();
if (s == "6")
opts.CodeObjectVersion = llvm::CodeObjectVersionKind::COV_6;
@@ -353,36 +353,36 @@ static void parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts,
// -f[no-]save-optimization-record[=<format>]
if (const llvm::opt::Arg *a =
- args.getLastArg(clang::driver::options::OPT_opt_record_file))
+ args.getLastArg(clang::options::OPT_opt_record_file))
opts.OptRecordFile = a->getValue();
// Optimization file format. Defaults to yaml
if (const llvm::opt::Arg *a =
- args.getLastArg(clang::driver::options::OPT_opt_record_format))
+ args.getLastArg(clang::options::OPT_opt_record_format))
opts.OptRecordFormat = a->getValue();
// Specifies, using a regex, which successful optimization passes(middle and
// backend), to include in the final optimization record file generated. If
// not provided -fsave-optimization-record will include all passes.
if (const llvm::opt::Arg *a =
- args.getLastArg(clang::driver::options::OPT_opt_record_passes))
+ args.getLastArg(clang::options::OPT_opt_record_passes))
opts.OptRecordPasses = a->getValue();
// Create OptRemark that allows printing of all successful optimization
// passes applied.
opts.OptimizationRemark =
- parseOptimizationRemark(diags, args, clang::driver::options::OPT_Rpass_EQ,
+ parseOptimizationRemark(diags, args, clang::options::OPT_Rpass_EQ,
/*remarkOptName=*/"pass");
// Create OptRemark that allows all missed optimization passes to be printed.
opts.OptimizationRemarkMissed = parseOptimizationRemark(
- diags, args, clang::driver::options::OPT_Rpass_missed_EQ,
+ diags, args, clang::options::OPT_Rpass_missed_EQ,
/*remarkOptName=*/"pass-missed");
// Create OptRemark that allows all optimization decisions made by LLVM
// to be printed.
opts.OptimizationRemarkAnalysis = parseOptimizationRemark(
- diags, args, clang::driver::options::OPT_Rpass_analysis_EQ,
+ diags, args, clang::options::OPT_Rpass_analysis_EQ,
/*remarkOptName=*/"pass-analysis");
if (opts.getDebugInfo() == llvm::codegenoptions::NoDebugInfo) {
@@ -400,23 +400,23 @@ static void parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts,
opts.setDebugInfo(llvm::codegenoptions::LocTrackingOnly);
}
- if (auto *a = args.getLastArg(clang::driver::options::OPT_save_temps_EQ))
+ if (auto *a = args.getLastArg(clang::options::OPT_save_temps_EQ))
opts.SaveTempsDir = a->getValue();
// -record-command-line option.
if (const llvm::opt::Arg *a =
- args.getLastArg(clang::driver::options::OPT_record_command_line)) {
+ args.getLastArg(clang::options::OPT_record_command_line)) {
opts.RecordCommandLine = a->getValue();
}
// -mlink-builtin-bitcode
for (auto *a :
- args.filtered(clang::driver::options::OPT_mlink_builtin_bitcode))
+ args.filtered(clang::options::OPT_mlink_builtin_bitcode))
opts.BuiltinBCLibs.push_back(a->getValue());
// -mrelocation-model option.
if (const llvm::opt::Arg *a =
- args.getLastArg(clang::driver::options::OPT_mrelocation_model)) {
+ args.getLastArg(clang::options::OPT_mrelocation_model)) {
llvm::StringRef modelName = a->getValue();
auto relocModel =
llvm::StringSwitch<std::optional<llvm::Reloc::Model>>(modelName)
@@ -436,30 +436,30 @@ static void parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts,
// -pic-level and -pic-is-pie option.
if (int picLevel = getLastArgIntValue(
- args, clang::driver::options::OPT_pic_level, 0, diags)) {
+ args, clang::options::OPT_pic_level, 0, diags)) {
if (picLevel > 2)
diags.Report(clang::diag::err_drv_invalid_value)
- << args.getLastArg(clang::driver::options::OPT_pic_level)
+ << args.getLastArg(clang::options::OPT_pic_level)
->getAsString(args)
<< picLevel;
opts.PICLevel = picLevel;
- if (args.hasArg(clang::driver::options::OPT_pic_is_pie))
+ if (args.hasArg(clang::options::OPT_pic_is_pie))
opts.IsPIE = 1;
}
- if (args.hasArg(clang::driver::options::OPT_fprofile_generate)) {
+ if (args.hasArg(clang::options::OPT_fprofile_generate)) {
opts.setProfileInstr(llvm::driver::ProfileInstrKind::ProfileIRInstr);
}
- if (auto A = args.getLastArg(clang::driver::options::OPT_fprofile_use_EQ)) {
+ if (auto A = args.getLastArg(clang::options::OPT_fprofile_use_EQ)) {
opts.setProfileUse(llvm::driver::ProfileInstrKind::ProfileIRInstr);
opts.ProfileInstrumentUsePath = A->getValue();
}
// -mcmodel option.
if (const llvm::opt::Arg *a =
- args.getLastArg(clang::driver::options::OPT_mcmodel_EQ)) {
+ args.getLastArg(clang::options::OPT_mcmodel_EQ)) {
llvm::StringRef modelName = a->getValue();
std::optional<llvm::CodeModel::Model> codeModel = getCodeModel(modelName);
@@ -471,7 +471,7 @@ static void parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts,
}
if (const llvm::opt::Arg *arg = args.getLastArg(
- clang::driver::options::OPT_mlarge_data_threshold_EQ)) {
+ clang::options::OPT_mlarge_data_threshold_EQ)) {
uint64_t LDT;
if (llvm::StringRef(arg->getValue()).getAsInteger(/*Radix=*/10, LDT)) {
diags.Report(clang::diag::err_drv_invalid_value)
@@ -481,15 +481,15 @@ static void parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts,
}
// This option is compatible with -f[no-]underscoring in gfortran.
- if (args.hasFlag(clang::driver::options::OPT_fno_underscoring,
- clang::driver::options::OPT_funderscoring, false)) {
+ if (args.hasFlag(clang::options::OPT_fno_underscoring,
+ clang::options::OPT_funderscoring, false)) {
opts.Underscoring = 0;
}
parseDoConcurrentMapping(opts, args, diags);
if (const llvm::opt::Arg *arg =
- args.getLastArg(clang::driver::options::OPT_complex_range_EQ)) {
+ args.getLastArg(clang::options::OPT_complex_range_EQ)) {
llvm::StringRef argValue = llvm::StringRef(arg->getValue());
if (argValue == "full") {
opts.setComplexRange(CodeGenOptions::ComplexRangeKind::CX_Full);
@@ -511,45 +511,45 @@ static void parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts,
/// \param [in] args The list of input arguments (from the compiler invocation)
static void parseTargetArgs(TargetOptions &opts, llvm::opt::ArgList &args) {
if (const llvm::opt::Arg *a =
- args.getLastArg(clang::driver::options::OPT_triple))
+ args.getLastArg(clang::options::OPT_triple))
opts.triple = a->getValue();
opts.atomicIgnoreDenormalMode = args.hasFlag(
- clang::driver::options::OPT_fatomic_ignore_denormal_mode,
- clang::driver::options::OPT_fno_atomic_ignore_denormal_mode, false);
+ clang::options::OPT_fatomic_ignore_denormal_mode,
+ clang::options::OPT_fno_atomic_ignore_denormal_mode, false);
opts.atomicFineGrainedMemory = args.hasFlag(
- clang::driver::options::OPT_fatomic_fine_grained_memory,
- clang::driver::options::OPT_fno_atomic_fine_grained_memory, false);
+ clang::options::OPT_fatomic_fine_grained_memory,
+ clang::options::OPT_fno_atomic_fine_grained_memory, false);
opts.atomicRemoteMemory =
- args.hasFlag(clang::driver::options::OPT_fatomic_remote_memory,
- clang::driver::options::OPT_fno_atomic_remote_memory, false);
+ args.hasFlag(clang::options::OPT_fatomic_remote_memory,
+ clang::options::OPT_fno_atomic_remote_memory, false);
if (const llvm::opt::Arg *a =
- args.getLastArg(clang::driver::options::OPT_target_cpu))
+ args.getLastArg(clang::options::OPT_target_cpu))
opts.cpu = a->getValue();
if (const llvm::opt::Arg *a =
- args.getLastArg(clang::driver::options::OPT_tune_cpu))
+ args.getLastArg(clang::options::OPT_tune_cpu))
opts.cpuToTuneFor = a->getValue();
for (const llvm::opt::Arg *currentArg :
- args.filtered(clang::driver::options::OPT_target_feature))
+ args.filtered(clang::options::OPT_target_feature))
opts.featuresAsWritten.emplace_back(currentArg->getValue());
- if (args.hasArg(clang::driver::options::OPT_fdisable_real_10))
+ if (args.hasArg(clang::options::OPT_fdisable_real_10))
opts.disabledRealKinds.push_back(10);
- if (args.hasArg(clang::driver::options::OPT_fdisable_real_3))
+ if (args.hasArg(clang::options::OPT_fdisable_real_3))
opts.disabledRealKinds.push_back(3);
- if (args.hasArg(clang::driver::options::OPT_fdisable_integer_2))
+ if (args.hasArg(clang::options::OPT_fdisable_integer_2))
opts.disabledIntegerKinds.push_back(2);
- if (args.hasArg(clang::driver::options::OPT_fdisable_integer_16))
+ if (args.hasArg(clang::options::OPT_fdisable_integer_16))
opts.disabledIntegerKinds.push_back(16);
if (const llvm::opt::Arg *a =
- args.getLastArg(clang::driver::options::OPT_mabi_EQ)) {
+ args.getLastArg(clang::options::OPT_mabi_EQ)) {
opts.abi = a->getValue();
llvm::StringRef V = a->getValue();
if (V == "vec-extabi") {
@@ -560,8 +560,8 @@ static void parseTargetArgs(TargetOptions &opts, llvm::opt::ArgList &args) {
}
opts.asmVerbose =
- args.hasFlag(clang::driver::options::OPT_fverbose_asm,
- clang::driver::options::OPT_fno_verbose_asm, false);
+ args.hasFlag(clang::options::OPT_fverbose_asm,
+ clang::options::OPT_fno_verbose_asm, false);
}
// Tweak the frontend configuration based on the frontend action
static void setUpFrontendBasedOnAction(FrontendOptions &opts) {
@@ -594,7 +594,7 @@ static bool parseFrontendArgs(FrontendOptions &opts, llvm::opt::ArgList &args,
// Treat multiple action options as an invocation error. Note that `clang
// -cc1` does accept multiple action options, but will only consider the
// rightmost one.
- if (args.hasMultipleArgs(clang::driver::options::OPT_Action_Group)) {
+ if (args.hasMultipleArgs(clang::options::OPT_Action_Group)) {
const unsigned diagID = diags.getCustomDiagID(
clang::DiagnosticsEngine::Error, "Only one action option is allowed");
diags.Report(diagID);
@@ -603,99 +603,99 @@ static bool parseFrontendArgs(FrontendOptions &opts, llvm::opt::ArgList &args,
// Identify the action (i.e. opts.ProgramAction)
if (const llvm::opt::Arg *a =
- args.getLastArg(clang::driver::options::OPT_Action_Group)) {
+ args.getLastArg(clang::options::OPT_Action_Group)) {
switch (a->getOption().getID()) {
default: {
llvm_unreachable("Invalid option in group!");
}
- case clang::driver::options::OPT_test_io:
+ case clang::options::OPT_test_io:
opts.programAction = InputOutputTest;
break;
- case clang::driver::options::OPT_E:
+ case clang::options::OPT_E:
opts.programAction = PrintPreprocessedInput;
break;
- case clang::driver::options::OPT_fsyntax_only:
+ case clang::options::OPT_fsyntax_only:
opts.programAction = ParseSyntaxOnly;
break;
- case clang::driver::options::OPT_emit_fir:
+ case clang::options::OPT_emit_fir:
opts.programAction = EmitFIR;
break;
- case clang::driver::options::OPT_emit_hlfir:
+ case clang::options::OPT_emit_hlfir:
opts.programAction = EmitHLFIR;
break;
- case clang::driver::options::OPT_emit_llvm:
+ case clang::options::OPT_emit_llvm:
opts.programAction = EmitLLVM;
break;
- case clang::driver::options::OPT_emit_llvm_bc:
+ case clang::options::OPT_emit_llvm_bc:
opts.programAction = EmitLLVMBitcode;
break;
- case clang::driver::options::OPT_emit_obj:
+ case clang::options::OPT_emit_obj:
opts.programAction = EmitObj;
break;
- case clang::driver::options::OPT_S:
+ case clang::options::OPT_S:
opts.programAction = EmitAssembly;
break;
- case clang::driver::options::OPT_fdebug_unparse:
+ case clang::options::OPT_fdebug_unparse:
opts.programAction = DebugUnparse;
break;
- case clang::driver::options::OPT_fdebug_unparse_no_sema:
+ case clang::options::OPT_fdebug_unparse_no_sema:
opts.programAction = DebugUnparseNoSema;
break;
- case clang::driver::options::OPT_fdebug_unparse_with_symbols:
+ case clang::options::OPT_fdebug_unparse_with_symbols:
opts.programAction = DebugUnparseWithSymbols;
break;
- case clang::driver::options::OPT_fdebug_unparse_with_modules:
+ case clang::options::OPT_fdebug_unparse_with_modules:
opts.programAction = DebugUnparseWithModules;
break;
- case clang::driver::options::OPT_fdebug_dump_symbols:
+ case clang::options::OPT_fdebug_dump_symbols:
opts.programAction = DebugDumpSymbols;
break;
- case clang::driver::options::OPT_fdebug_dump_parse_tree:
+ case clang::options::OPT_fdebug_dump_parse_tree:
opts.programAction = DebugDumpParseTree;
break;
- case clang::driver::options::OPT_fdebug_dump_pft:
+ case clang::options::OPT_fdebug_dump_pft:
opts.programAction = DebugDumpPFT;
break;
- case clang::driver::options::OPT_fdebug_dump_all:
+ case clang::options::OPT_fdebug_dump_all:
opts.programAction = DebugDumpAll;
break;
- case clang::driver::options::OPT_fdebug_dump_parse_tree_no_sema:
+ case clang::options::OPT_fdebug_dump_parse_tree_no_sema:
opts.programAction = DebugDumpParseTreeNoSema;
break;
- case clang::driver::options::OPT_fdebug_dump_provenance:
+ case clang::options::OPT_fdebug_dump_provenance:
opts.programAction = DebugDumpProvenance;
break;
- case clang::driver::options::OPT_fdebug_dump_parsing_log:
+ case clang::options::OPT_fdebug_dump_parsing_log:
opts.programAction = DebugDumpParsingLog;
break;
- case clang::driver::options::OPT_fdebug_measure_parse_tree:
+ case clang::options::OPT_fdebug_measure_parse_tree:
opts.programAction = DebugMeasureParseTree;
break;
- case clang::driver::options::OPT_fdebug_pre_fir_tree:
+ case clang::options::OPT_fdebug_pre_fir_tree:
opts.programAction = DebugPreFIRTree;
break;
- case clang::driver::options::OPT_fget_symbols_sources:
+ case clang::options::OPT_fget_symbols_sources:
opts.programAction = GetSymbolsSources;
break;
- case clang::driver::options::OPT_fget_definition:
+ case clang::options::OPT_fget_definition:
opts.programAction = GetDefinition;
break;
- case clang::driver::options::OPT_init_only:
+ case clang::options::OPT_init_only:
opts.programAction = InitOnly;
break;
// TODO:
- // case clang::driver::options::OPT_emit_llvm:
- // case clang::driver::options::OPT_emit_llvm_only:
- // case clang::driver::options::OPT_emit_codegen_only:
- // case clang::driver::options::OPT_emit_module:
+ // case clang::options::OPT_emit_llvm:
+ // case clang::options::OPT_emit_llvm_only:
+ // case clang::options::OPT_emit_codegen_only:
+ // case clang::options::OPT_emit_module:
// (...)
}
// Parse the values provided with `-fget-definition` (there should be 3
// integers)
if (llvm::opt::OptSpecifier(a->getOption().getID()) ==
- clang::driver::options::OPT_fget_definition) {
+ clang::options::OPT_fget_definition) {
unsigned optVals[3] = {0, 0, 0};
for (unsigned i = 0; i < 3; i++) {
@@ -715,27 +715,27 @@ static bool parseFrontendArgs(FrontendOptions &opts, llvm::opt::ArgList &args,
}
// Parsing -load <dsopath> option and storing shared object path
- if (llvm::opt::Arg *a = args.getLastArg(clang::driver::options::OPT_load)) {
+ if (llvm::opt::Arg *a = args.getLastArg(clang::options::OPT_load)) {
opts.plugins.push_back(a->getValue());
}
// Parsing -plugin <name> option and storing plugin name and setting action
if (const llvm::opt::Arg *a =
- args.getLastArg(clang::driver::options::OPT_plugin)) {
+ args.getLastArg(clang::options::OPT_plugin)) {
opts.programAction = PluginAction;
opts.actionName = a->getValue();
}
- opts.outputFile = args.getLastArgValue(clang::driver::options::OPT_o);
- opts.showHelp = args.hasArg(clang::driver::options::OPT_help);
- opts.showVersion = args.hasArg(clang::driver::options::OPT_version);
+ opts.outputFile = args.getLastArgValue(clang::options::OPT_o);
+ opts.showHelp = args.hasArg(clang::options::OPT_help);
+ opts.showVersion = args.hasArg(clang::options::OPT_version);
opts.printSupportedCPUs =
- args.hasArg(clang::driver::options::OPT_print_supported_cpus);
+ args.hasArg(clang::options::OPT_print_supported_cpus);
// Get the input kind (from the value passed via `-x`)
InputKind dashX(Language::Unknown);
if (const llvm::opt::Arg *a =
- args.getLastArg(clang::driver::options::OPT_x)) {
+ args.getLastArg(clang::options::OPT_x)) {
llvm::StringRef xValue = a->getValue();
// Principal languages.
dashX = llvm::StringSwitch<InputKind>(xValue)
@@ -762,7 +762,7 @@ static bool parseFrontendArgs(FrontendOptions &opts, llvm::opt::ArgList &args,
// Collect the input files and save them in our instance of FrontendOptions.
std::vector<std::string> inputs =
- args.getAllArgValues(clang::driver::options::OPT_INPUT);
+ args.getAllArgValues(clang::options::OPT_INPUT);
opts.inputs.clear();
if (inputs.empty())
// '-' is the default input if none is given.
@@ -783,17 +783,17 @@ static bool parseFrontendArgs(FrontendOptions &opts, llvm::opt::ArgList &args,
// Set fortranForm based on options -ffree-form and -ffixed-form.
if (const auto *arg =
- args.getLastArg(clang::driver::options::OPT_ffixed_form,
- clang::driver::options::OPT_ffree_form)) {
+ args.getLastArg(clang::options::OPT_ffixed_form,
+ clang::options::OPT_ffree_form)) {
opts.fortranForm =
- arg->getOption().matches(clang::driver::options::OPT_ffixed_form)
+ arg->getOption().matches(clang::options::OPT_ffixed_form)
? FortranForm::FixedForm
: FortranForm::FreeForm;
}
// Set fixedFormColumns based on -ffixed-line-length=<value>
if (const auto *arg =
- args.getLastArg(clang::driver::options::OPT_ffixed_line_length_EQ)) {
+ args.getLastArg(clang::options::OPT_ffixed_line_length_EQ)) {
llvm::StringRef argValue = llvm::StringRef(arg->getValue());
std::int64_t columns = -1;
if (argValue == "none") {
@@ -816,7 +816,7 @@ static bool parseFrontendArgs(FrontendOptions &opts, llvm::opt::ArgList &args,
// Set conversion based on -fconvert=<value>
if (const auto *arg =
- args.getLastArg(clang::driver::options::OPT_fconvert_EQ)) {
+ args.getLastArg(clang::options::OPT_fconvert_EQ)) {
const char *argValue = arg->getValue();
if (auto convert = parseConvertArg(argValue))
opts.envDefaults.push_back({"FORT_CONVERT", *convert});
@@ -828,57 +828,57 @@ static bool parseFrontendArgs(FrontendOptions &opts, llvm::opt::ArgList &args,
// -f{no-}implicit-none
opts.features.Enable(
Fortran::common::LanguageFeature::ImplicitNoneTypeAlways,
- args.hasFlag(clang::driver::options::OPT_fimplicit_none,
- clang::driver::options::OPT_fno_implicit_none, false));
+ args.hasFlag(clang::options::OPT_fimplicit_none,
+ clang::options::OPT_fno_implicit_none, false));
// -f{no-}implicit-none-ext
opts.features.Enable(
Fortran::common::LanguageFeature::ImplicitNoneExternal,
- args.hasFlag(clang::driver::options::OPT_fimplicit_none_ext,
- clang::driver::options::OPT_fno_implicit_none_ext, false));
+ args.hasFlag(clang::options::OPT_fimplicit_none_ext,
+ clang::options::OPT_fno_implicit_none_ext, false));
// -f{no-}backslash
opts.features.Enable(Fortran::common::LanguageFeature::BackslashEscapes,
- args.hasFlag(clang::driver::options::OPT_fbackslash,
- clang::driver::options::OPT_fno_backslash,
+ args.hasFlag(clang::options::OPT_fbackslash,
+ clang::options::OPT_fno_backslash,
false));
// -f{no-}logical-abbreviations
opts.features.Enable(
Fortran::common::LanguageFeature::LogicalAbbreviations,
- args.hasFlag(clang::driver::options::OPT_flogical_abbreviations,
- clang::driver::options::OPT_fno_logical_abbreviations,
+ args.hasFlag(clang::options::OPT_flogical_abbreviations,
+ clang::options::OPT_fno_logical_abbreviations,
false));
// -f{no-}unsigned
opts.features.Enable(Fortran::common::LanguageFeature::Unsigned,
- args.hasFlag(clang::driver::options::OPT_funsigned,
- clang::driver::options::OPT_fno_unsigned,
+ args.hasFlag(clang::options::OPT_funsigned,
+ clang::options::OPT_fno_unsigned,
false));
// -f{no-}xor-operator
opts.features.Enable(
Fortran::common::LanguageFeature::XOROperator,
- args.hasFlag(clang::driver::options::OPT_fxor_operator,
- clang::driver::options::OPT_fno_xor_operator, false));
+ args.hasFlag(clang::options::OPT_fxor_operator,
+ clang::options::OPT_fno_xor_operator, false));
// -fno-automatic
- if (args.hasArg(clang::driver::options::OPT_fno_automatic)) {
+ if (args.hasArg(clang::options::OPT_fno_automatic)) {
opts.features.Enable(Fortran::common::LanguageFeature::DefaultSave);
}
// -f{no}-save-main-program
opts.features.Enable(
Fortran::common::LanguageFeature::SaveMainProgram,
- args.hasFlag(clang::driver::options::OPT_fsave_main_program,
- clang::driver::options::OPT_fno_save_main_program, false));
+ args.hasFlag(clang::options::OPT_fsave_main_program,
+ clang::options::OPT_fno_save_main_program, false));
if (args.hasArg(
- clang::driver::options::OPT_falternative_parameter_statement)) {
+ clang::options::OPT_falternative_parameter_statement)) {
opts.features.Enable(Fortran::common::LanguageFeature::OldStyleParameter);
}
if (const llvm::opt::Arg *arg =
- args.getLastArg(clang::driver::options::OPT_finput_charset_EQ)) {
+ args.getLastArg(clang::options::OPT_finput_charset_EQ)) {
llvm::StringRef argValue = arg->getValue();
if (argValue == "utf-8") {
opts.encoding = Fortran::parser::Encoding::UTF_8;
@@ -923,9 +923,9 @@ static std::string getOpenMPHeadersDir(const char *argv) {
static void parsePreprocessorArgs(Fortran::frontend::PreprocessorOptions &opts,
llvm::opt::ArgList &args) {
// Add macros from the command line.
- for (const auto *currentArg : args.filtered(clang::driver::options::OPT_D,
- clang::driver::options::OPT_U)) {
- if (currentArg->getOption().matches(clang::driver::options::OPT_D)) {
+ for (const auto *currentArg : args.filtered(clang::options::OPT_D,
+ clang::options::OPT_U)) {
+ if (currentArg->getOption().matches(clang::options::OPT_D)) {
opts.addMacroDef(currentArg->getValue());
} else {
opts.addMacroUndef(currentArg->getValue());
@@ -933,34 +933,34 @@ static void parsePreprocessorArgs(Fortran::frontend::PreprocessorOptions &opts,
}
// Add the ordered list of -I's.
- for (const auto *currentArg : args.filtered(clang::driver::options::OPT_I))
+ for (const auto *currentArg : args.filtered(clang::options::OPT_I))
opts.searchDirectoriesFromDashI.emplace_back(currentArg->getValue());
// Prepend the ordered list of -intrinsic-modules-path
// to the default location to search.
for (const auto *currentArg :
- args.filtered(clang::driver::options::OPT_fintrinsic_modules_path))
+ args.filtered(clang::options::OPT_fintrinsic_modules_path))
opts.searchDirectoriesFromIntrModPath.emplace_back(currentArg->getValue());
// -cpp/-nocpp
if (const auto *currentArg = args.getLastArg(
- clang::driver::options::OPT_cpp, clang::driver::options::OPT_nocpp))
+ clang::options::OPT_cpp, clang::options::OPT_nocpp))
opts.macrosFlag =
- (currentArg->getOption().matches(clang::driver::options::OPT_cpp))
+ (currentArg->getOption().matches(clang::options::OPT_cpp))
? PPMacrosFlag::Include
: PPMacrosFlag::Exclude;
// Enable -cpp based on -x unless explicitly disabled with -nocpp
if (opts.macrosFlag != PPMacrosFlag::Exclude)
- if (const auto *dashX = args.getLastArg(clang::driver::options::OPT_x))
+ if (const auto *dashX = args.getLastArg(clang::options::OPT_x))
opts.macrosFlag = llvm::StringSwitch<PPMacrosFlag>(dashX->getValue())
.Case("f95-cpp-input", PPMacrosFlag::Include)
.Default(opts.macrosFlag);
- opts.noReformat = args.hasArg(clang::driver::options::OPT_fno_reformat);
+ opts.noReformat = args.hasArg(clang::options::OPT_fno_reformat);
opts.preprocessIncludeLines =
- args.hasArg(clang::driver::options::OPT_fpreprocess_include_lines);
- opts.noLineDirectives = args.hasArg(clang::driver::options::OPT_P);
- opts.showMacros = args.hasArg(clang::driver::options::OPT_dM);
+ args.hasArg(clang::options::OPT_fpreprocess_include_lines);
+ opts.noLineDirectives = args.hasArg(clang::options::OPT_P);
+ opts.showMacros = args.hasArg(clang::options::OPT_dM);
}
/// Parses all semantic related arguments and populates the variables
@@ -971,7 +971,7 @@ static bool parseSemaArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
// -J/module-dir option
std::vector<std::string> moduleDirList =
- args.getAllArgValues(clang::driver::options::OPT_module_dir);
+ args.getAllArgValues(clang::options::OPT_module_dir);
// User can only specify one -J/-module-dir directory, but may repeat
// -J/-module-dir as long as the directory is the same each time.
// https://gcc.gnu.org/onlinedocs/gfortran/Directory-Options.html
@@ -990,25 +990,25 @@ static bool parseSemaArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
res.setModuleDir(moduleDirList[0]);
// -fdebug-module-writer option
- if (args.hasArg(clang::driver::options::OPT_fdebug_module_writer)) {
+ if (args.hasArg(clang::options::OPT_fdebug_module_writer)) {
res.setDebugModuleDir(true);
}
// -fhermetic-module-files option
- if (args.hasArg(clang::driver::options::OPT_fhermetic_module_files)) {
+ if (args.hasArg(clang::options::OPT_fhermetic_module_files)) {
res.setHermeticModuleFileOutput(true);
}
// -module-suffix
if (const auto *moduleSuffix =
- args.getLastArg(clang::driver::options::OPT_module_suffix)) {
+ args.getLastArg(clang::options::OPT_module_suffix)) {
res.setModuleFileSuffix(moduleSuffix->getValue());
}
// -f{no-}analyzed-objects-for-unparse
res.setUseAnalyzedObjectsForUnparse(args.hasFlag(
- clang::driver::options::OPT_fanalyzed_objects_for_unparse,
- clang::driver::options::OPT_fno_analyzed_objects_for_unparse, true));
+ clang::options::OPT_fanalyzed_objects_for_unparse,
+ clang::options::OPT_fno_analyzed_objects_for_unparse, true));
return diags.getNumErrors() == numErrorsBefore;
}
@@ -1025,7 +1025,7 @@ static bool parseDiagArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
// chosen to match clang's behavior.
// -pedantic
- if (args.hasArg(clang::driver::options::OPT_pedantic)) {
+ if (args.hasArg(clang::options::OPT_pedantic)) {
features.WarnOnAllNonstandard();
features.WarnOnAllUsage();
res.setEnableConformanceChecks();
@@ -1035,9 +1035,9 @@ static bool parseDiagArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
// -Werror option
// TODO: Currently throws a Diagnostic for anything other than -W<error>,
// this has to change when other -W<opt>'s are supported.
- if (args.hasArg(clang::driver::options::OPT_W_Joined)) {
+ if (args.hasArg(clang::options::OPT_W_Joined)) {
const auto &wArgs =
- args.getAllArgValues(clang::driver::options::OPT_W_Joined);
+ args.getAllArgValues(clang::options::OPT_W_Joined);
for (const auto &wArg : wArgs) {
if (wArg == "error") {
res.setWarnAsErr(true);
@@ -1054,7 +1054,7 @@ static bool parseDiagArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
}
// -w
- if (args.hasArg(clang::driver::options::OPT_w)) {
+ if (args.hasArg(clang::options::OPT_w)) {
features.DisableAllWarnings();
res.setDisableWarnings();
}
@@ -1074,7 +1074,7 @@ static bool parseDialectArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
unsigned numErrorsBefore = diags.getNumErrors();
// -fd-lines-as-code
- if (args.hasArg(clang::driver::options::OPT_fd_lines_as_code)) {
+ if (args.hasArg(clang::options::OPT_fd_lines_as_code)) {
if (res.getFrontendOpts().fortranForm == FortranForm::FreeForm) {
const unsigned fdLinesAsWarning = diags.getCustomDiagID(
clang::DiagnosticsEngine::Warning,
@@ -1087,7 +1087,7 @@ static bool parseDialectArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
}
// -fd-lines-as-comments
- if (args.hasArg(clang::driver::options::OPT_fd_lines_as_comments)) {
+ if (args.hasArg(clang::options::OPT_fd_lines_as_comments)) {
if (res.getFrontendOpts().fortranForm == FortranForm::FreeForm) {
const unsigned fdLinesAsWarning = diags.getCustomDiagID(
clang::DiagnosticsEngine::Warning,
@@ -1100,18 +1100,18 @@ static bool parseDialectArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
}
// -fdefault* family
- if (args.hasArg(clang::driver::options::OPT_fdefault_real_8)) {
+ if (args.hasArg(clang::options::OPT_fdefault_real_8)) {
res.getDefaultKinds().set_defaultRealKind(8);
res.getDefaultKinds().set_doublePrecisionKind(16);
}
- if (args.hasArg(clang::driver::options::OPT_fdefault_integer_8)) {
+ if (args.hasArg(clang::options::OPT_fdefault_integer_8)) {
res.getDefaultKinds().set_defaultIntegerKind(8);
res.getDefaultKinds().set_subscriptIntegerKind(8);
res.getDefaultKinds().set_sizeIntegerKind(8);
res.getDefaultKinds().set_defaultLogicalKind(8);
}
- if (args.hasArg(clang::driver::options::OPT_fdefault_double_8)) {
- if (!args.hasArg(clang::driver::options::OPT_fdefault_real_8)) {
+ if (args.hasArg(clang::options::OPT_fdefault_double_8)) {
+ if (!args.hasArg(clang::options::OPT_fdefault_real_8)) {
// -fdefault-double-8 has to be used with -fdefault-real-8
// to be compatible with gfortran
const unsigned diagID = diags.getCustomDiagID(
@@ -1122,18 +1122,18 @@ static bool parseDialectArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
// https://gcc.gnu.org/onlinedocs/gfortran/Fortran-Dialect-Options.html
res.getDefaultKinds().set_doublePrecisionKind(8);
}
- if (args.hasArg(clang::driver::options::OPT_flarge_sizes))
+ if (args.hasArg(clang::options::OPT_flarge_sizes))
res.getDefaultKinds().set_sizeIntegerKind(8);
// -x cuda
- auto language = args.getLastArgValue(clang::driver::options::OPT_x);
+ auto language = args.getLastArgValue(clang::options::OPT_x);
if (language == "cuda") {
res.getFrontendOpts().features.Enable(
Fortran::common::LanguageFeature::CUDA);
}
// -fopenacc
- if (args.hasArg(clang::driver::options::OPT_fopenacc)) {
+ if (args.hasArg(clang::options::OPT_fopenacc)) {
res.getFrontendOpts().features.Enable(
Fortran::common::LanguageFeature::OpenACC);
}
@@ -1141,8 +1141,8 @@ static bool parseDialectArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
// -std=f2018
// TODO: Set proper options when more fortran standards
// are supported.
- if (args.hasArg(clang::driver::options::OPT_std_EQ)) {
- auto standard = args.getLastArgValue(clang::driver::options::OPT_std_EQ);
+ if (args.hasArg(clang::options::OPT_std_EQ)) {
+ auto standard = args.getLastArgValue(clang::options::OPT_std_EQ);
// We only allow f2018 as the given standard
if (standard == "f2018") {
res.setEnableConformanceChecks();
@@ -1155,7 +1155,7 @@ static bool parseDialectArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
}
}
// -fcoarray
- if (args.hasArg(clang::driver::options::OPT_fcoarray)) {
+ if (args.hasArg(clang::options::OPT_fcoarray)) {
res.getFrontendOpts().features.Enable(
Fortran::common::LanguageFeature::Coarray);
const unsigned diagID =
@@ -1173,13 +1173,13 @@ static bool parseDialectArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
/// generated.
static bool parseOpenMPArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
clang::DiagnosticsEngine &diags) {
- llvm::opt::Arg *arg = args.getLastArg(clang::driver::options::OPT_fopenmp,
- clang::driver::options::OPT_fno_openmp);
+ llvm::opt::Arg *arg = args.getLastArg(clang::options::OPT_fopenmp,
+ clang::options::OPT_fno_openmp);
if (!arg ||
- arg->getOption().matches(clang::driver::options::OPT_fno_openmp)) {
+ arg->getOption().matches(clang::options::OPT_fno_openmp)) {
bool isSimdSpecified = args.hasFlag(
- clang::driver::options::OPT_fopenmp_simd,
- clang::driver::options::OPT_fno_openmp_simd, /*Default=*/false);
+ clang::options::OPT_fopenmp_simd,
+ clang::options::OPT_fno_openmp_simd, /*Default=*/false);
if (!isSimdSpecified)
return true;
res.getLangOpts().OpenMPSimd = 1;
@@ -1195,7 +1195,7 @@ static bool parseOpenMPArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
res.getFrontendOpts().features.Enable(
Fortran::common::LanguageFeature::OpenMP);
if (auto *arg =
- args.getLastArg(clang::driver::options::OPT_fopenmp_version_EQ)) {
+ args.getLastArg(clang::options::OPT_fopenmp_version_EQ)) {
llvm::ArrayRef<unsigned> ompVersions = llvm::omp::getOpenMPVersions();
unsigned oldVersions[] = {11, 20, 25, 30};
unsigned version = 0;
@@ -1248,16 +1248,16 @@ static bool parseOpenMPArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
}
}
- if (args.hasArg(clang::driver::options::OPT_fopenmp_force_usm)) {
+ if (args.hasArg(clang::options::OPT_fopenmp_force_usm)) {
res.getLangOpts().OpenMPForceUSM = 1;
}
- if (args.hasArg(clang::driver::options::OPT_fopenmp_is_target_device)) {
+ if (args.hasArg(clang::options::OPT_fopenmp_is_target_device)) {
res.getLangOpts().OpenMPIsTargetDevice = 1;
// Get OpenMP host file path if any and report if a non existent file is
// found
if (auto *arg = args.getLastArg(
- clang::driver::options::OPT_fopenmp_host_ir_file_path)) {
+ clang::options::OPT_fopenmp_host_ir_file_path)) {
res.getLangOpts().OMPHostIRFile = arg->getValue();
if (!llvm::sys::fs::exists(res.getLangOpts().OMPHostIRFile))
diags.Report(clang::diag::err_omp_host_ir_file_not_found)
@@ -1265,37 +1265,37 @@ static bool parseOpenMPArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
}
if (args.hasFlag(
- clang::driver::options::OPT_fopenmp_assume_teams_oversubscription,
- clang::driver::options::
+ clang::options::OPT_fopenmp_assume_teams_oversubscription,
+ clang::options::
OPT_fno_openmp_assume_teams_oversubscription,
/*Default=*/false))
res.getLangOpts().OpenMPTeamSubscription = true;
- if (args.hasArg(clang::driver::options::OPT_fopenmp_assume_no_thread_state))
+ if (args.hasArg(clang::options::OPT_fopenmp_assume_no_thread_state))
res.getLangOpts().OpenMPNoThreadState = 1;
if (args.hasArg(
- clang::driver::options::OPT_fopenmp_assume_no_nested_parallelism))
+ clang::options::OPT_fopenmp_assume_no_nested_parallelism))
res.getLangOpts().OpenMPNoNestedParallelism = 1;
if (args.hasFlag(
- clang::driver::options::OPT_fopenmp_assume_threads_oversubscription,
- clang::driver::options::
+ clang::options::OPT_fopenmp_assume_threads_oversubscription,
+ clang::options::
OPT_fno_openmp_assume_threads_oversubscription,
/*Default=*/false))
res.getLangOpts().OpenMPThreadSubscription = true;
- if ((args.hasArg(clang::driver::options::OPT_fopenmp_target_debug) ||
- args.hasArg(clang::driver::options::OPT_fopenmp_target_debug_EQ))) {
+ if ((args.hasArg(clang::options::OPT_fopenmp_target_debug) ||
+ args.hasArg(clang::options::OPT_fopenmp_target_debug_EQ))) {
res.getLangOpts().OpenMPTargetDebug = getLastArgIntValue(
- args, clang::driver::options::OPT_fopenmp_target_debug_EQ,
+ args, clang::options::OPT_fopenmp_target_debug_EQ,
res.getLangOpts().OpenMPTargetDebug, diags);
if (!res.getLangOpts().OpenMPTargetDebug &&
- args.hasArg(clang::driver::options::OPT_fopenmp_target_debug))
+ args.hasArg(clang::options::OPT_fopenmp_target_debug))
res.getLangOpts().OpenMPTargetDebug = 1;
}
- if (args.hasArg(clang::driver::options::OPT_no_offloadlib))
+ if (args.hasArg(clang::options::OPT_no_offloadlib))
res.getLangOpts().NoGPULib = 1;
}
if (llvm::Triple(res.getTargetOpts().triple).isGPU()) {
@@ -1312,7 +1312,7 @@ static bool parseOpenMPArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
// Get the OpenMP target triples if any.
if (auto *arg =
- args.getLastArg(clang::driver::options::OPT_offload_targets_EQ)) {
+ args.getLastArg(clang::options::OPT_offload_targets_EQ)) {
enum ArchPtrSize { Arch16Bit, Arch32Bit, Arch64Bit };
auto getArchPtrSize = [](const llvm::Triple &triple) {
if (triple.isArch16Bit())
@@ -1355,7 +1355,7 @@ static bool parseIntegerOverflowArgs(CompilerInvocation &invoc,
clang::DiagnosticsEngine &diags) {
Fortran::common::LangOptions &opts = invoc.getLangOpts();
- if (args.getLastArg(clang::driver::options::OPT_fwrapv))
+ if (args.getLastArg(clang::options::OPT_fwrapv))
opts.setSignedOverflowBehavior(Fortran::common::LangOptions::SOB_Defined);
return true;
@@ -1374,7 +1374,7 @@ static bool parseFloatingPointArgs(CompilerInvocation &invoc,
Fortran::common::LangOptions &opts = invoc.getLangOpts();
if (const llvm::opt::Arg *a =
- args.getLastArg(clang::driver::options::OPT_ffp_contract)) {
+ args.getLastArg(clang::options::OPT_ffp_contract)) {
const llvm::StringRef val = a->getValue();
enum Fortran::common::LangOptions::FPModeKind fpContractMode;
@@ -1391,31 +1391,31 @@ static bool parseFloatingPointArgs(CompilerInvocation &invoc,
opts.setFPContractMode(fpContractMode);
}
- if (args.getLastArg(clang::driver::options::OPT_menable_no_infs)) {
+ if (args.getLastArg(clang::options::OPT_menable_no_infs)) {
opts.NoHonorInfs = true;
}
- if (args.getLastArg(clang::driver::options::OPT_menable_no_nans)) {
+ if (args.getLastArg(clang::options::OPT_menable_no_nans)) {
opts.NoHonorNaNs = true;
}
- if (args.getLastArg(clang::driver::options::OPT_fapprox_func)) {
+ if (args.getLastArg(clang::options::OPT_fapprox_func)) {
opts.ApproxFunc = true;
}
- if (args.getLastArg(clang::driver::options::OPT_fno_signed_zeros)) {
+ if (args.getLastArg(clang::options::OPT_fno_signed_zeros)) {
opts.NoSignedZeros = true;
}
- if (args.getLastArg(clang::driver::options::OPT_mreassociate)) {
+ if (args.getLastArg(clang::options::OPT_mreassociate)) {
opts.AssociativeMath = true;
}
- if (args.getLastArg(clang::driver::options::OPT_freciprocal_math)) {
+ if (args.getLastArg(clang::options::OPT_freciprocal_math)) {
opts.ReciprocalMath = true;
}
- if (args.getLastArg(clang::driver::options::OPT_ffast_math)) {
+ if (args.getLastArg(clang::options::OPT_ffast_math)) {
opts.NoHonorInfs = true;
opts.NoHonorNaNs = true;
opts.AssociativeMath = true;
@@ -1425,7 +1425,7 @@ static bool parseFloatingPointArgs(CompilerInvocation &invoc,
opts.setFPContractMode(Fortran::common::LangOptions::FPM_Fast);
}
- if (args.hasArg(clang::driver::options::OPT_fno_fast_real_mod))
+ if (args.hasArg(clang::options::OPT_fno_fast_real_mod))
opts.NoFastRealMod = true;
return true;
@@ -1441,9 +1441,9 @@ static bool parseFloatingPointArgs(CompilerInvocation &invoc,
static bool parseVScaleArgs(CompilerInvocation &invoc, llvm::opt::ArgList &args,
clang::DiagnosticsEngine &diags) {
const auto *vscaleMin =
- args.getLastArg(clang::driver::options::OPT_mvscale_min_EQ);
+ args.getLastArg(clang::options::OPT_mvscale_min_EQ);
const auto *vscaleMax =
- args.getLastArg(clang::driver::options::OPT_mvscale_max_EQ);
+ args.getLastArg(clang::options::OPT_mvscale_max_EQ);
if (!vscaleMin && !vscaleMax)
return true;
@@ -1491,7 +1491,7 @@ static bool parseLinkerOptionsArgs(CompilerInvocation &invoc,
// TODO: support --dependent-lib on other platforms when MLIR supports
// !llvm.dependent.lib
- if (args.hasArg(clang::driver::options::OPT_dependent_lib) &&
+ if (args.hasArg(clang::options::OPT_dependent_lib) &&
!triple.isOSWindows()) {
const unsigned diagID =
diags.getCustomDiagID(clang::DiagnosticsEngine::Error,
@@ -1501,11 +1501,11 @@ static bool parseLinkerOptionsArgs(CompilerInvocation &invoc,
}
opts.DependentLibs =
- args.getAllArgValues(clang::driver::options::OPT_dependent_lib);
+ args.getAllArgValues(clang::options::OPT_dependent_lib);
// -flto=full/thin option.
if (const llvm::opt::Arg *a =
- args.getLastArg(clang::driver::options::OPT_flto_EQ)) {
+ args.getLastArg(clang::options::OPT_flto_EQ)) {
llvm::StringRef s = a->getValue();
assert((s == "full" || s == "thin") && "Unknown LTO mode.");
if (s == "full")
@@ -1516,10 +1516,10 @@ static bool parseLinkerOptionsArgs(CompilerInvocation &invoc,
// -ffat-lto-objects
if (const llvm::opt::Arg *arg =
- args.getLastArg(clang::driver::options::OPT_ffat_lto_objects,
- clang::driver::options::OPT_fno_fat_lto_objects)) {
+ args.getLastArg(clang::options::OPT_ffat_lto_objects,
+ clang::options::OPT_fno_fat_lto_objects)) {
opts.PrepareForFatLTO =
- arg->getOption().matches(clang::driver::options::OPT_ffat_lto_objects);
+ arg->getOption().matches(clang::options::OPT_ffat_lto_objects);
if (opts.PrepareForFatLTO) {
assert((opts.PrepareForFullLTO || opts.PrepareForThinLTO) &&
"Unknown LTO mode");
@@ -1560,8 +1560,8 @@ bool CompilerInvocation::createFromArgs(
llvm::Triple::normalize(llvm::sys::getDefaultTargetTriple());
// Parse the arguments
- const llvm::opt::OptTable &opts = clang::driver::getDriverOptTable();
- llvm::opt::Visibility visibilityMask(clang::driver::options::FC1Option);
+ const llvm::opt::OptTable &opts = clang::getDriverOptTable();
+ llvm::opt::Visibility visibilityMask(clang::options::FC1Option);
unsigned missingArgIndex, missingArgCount;
llvm::opt::InputArgList args = opts.ParseArgs(
commandLineArgs, missingArgIndex, missingArgCount, visibilityMask);
@@ -1574,7 +1574,7 @@ bool CompilerInvocation::createFromArgs(
}
// Issue errors on unknown arguments
- for (const auto *a : args.filtered(clang::driver::options::OPT_UNKNOWN)) {
+ for (const auto *a : args.filtered(clang::options::OPT_UNKNOWN)) {
auto argString = a->getAsString(args);
std::string nearest;
if (opts.findNearest(argString, nearest, visibilityMask) > 1)
@@ -1586,15 +1586,15 @@ bool CompilerInvocation::createFromArgs(
}
// -flang-experimental-hlfir
- if (args.hasArg(clang::driver::options::OPT_flang_experimental_hlfir) ||
- args.hasArg(clang::driver::options::OPT_emit_hlfir)) {
+ if (args.hasArg(clang::options::OPT_flang_experimental_hlfir) ||
+ args.hasArg(clang::options::OPT_emit_hlfir)) {
invoc.loweringOpts.setLowerToHighLevelFIR(true);
}
// -flang-deprecated-no-hlfir
- if (args.hasArg(clang::driver::options::OPT_flang_deprecated_no_hlfir) &&
- !args.hasArg(clang::driver::options::OPT_emit_hlfir)) {
- if (args.hasArg(clang::driver::options::OPT_flang_experimental_hlfir)) {
+ if (args.hasArg(clang::options::OPT_flang_deprecated_no_hlfir) &&
+ !args.hasArg(clang::options::OPT_emit_hlfir)) {
+ if (args.hasArg(clang::options::OPT_flang_experimental_hlfir)) {
const unsigned diagID = diags.getCustomDiagID(
clang::DiagnosticsEngine::Error,
"Options '-flang-experimental-hlfir' and "
@@ -1605,13 +1605,13 @@ bool CompilerInvocation::createFromArgs(
}
// -fno-ppc-native-vector-element-order
- if (args.hasArg(clang::driver::options::OPT_fno_ppc_native_vec_elem_order)) {
+ if (args.hasArg(clang::options::OPT_fno_ppc_native_vec_elem_order)) {
invoc.loweringOpts.setNoPPCNativeVecElemOrder(true);
}
// -f[no-]init-global-zero
- if (args.hasFlag(clang::driver::options::OPT_finit_global_zero,
- clang::driver::options::OPT_fno_init_global_zero,
+ if (args.hasFlag(clang::options::OPT_finit_global_zero,
+ clang::options::OPT_fno_init_global_zero,
/*default=*/true))
invoc.loweringOpts.setInitGlobalZero(true);
else
@@ -1620,8 +1620,8 @@ bool CompilerInvocation::createFromArgs(
// Preserve all the remark options requested, i.e. -Rpass, -Rpass-missed or
// -Rpass-analysis. This will be used later when processing and outputting the
// remarks generated by LLVM in ExecuteCompilerInvocation.cpp.
- for (auto *a : args.filtered(clang::driver::options::OPT_R_Group)) {
- if (a->getOption().matches(clang::driver::options::OPT_R_value_Group))
+ for (auto *a : args.filtered(clang::options::OPT_R_Group)) {
+ if (a->getOption().matches(clang::options::OPT_R_value_Group))
// This is -Rfoo=, where foo is the name of the diagnostic
// group. Add only the remark option name to the diagnostics. e.g. for
// -Rpass= we will add the string "pass".
@@ -1634,20 +1634,20 @@ bool CompilerInvocation::createFromArgs(
}
// -frealloc-lhs is the default.
- if (!args.hasFlag(clang::driver::options::OPT_frealloc_lhs,
- clang::driver::options::OPT_fno_realloc_lhs, true))
+ if (!args.hasFlag(clang::options::OPT_frealloc_lhs,
+ clang::options::OPT_fno_realloc_lhs, true))
invoc.loweringOpts.setReallocateLHS(false);
invoc.loweringOpts.setRepackArrays(
- args.hasFlag(clang::driver::options::OPT_frepack_arrays,
- clang::driver::options::OPT_fno_repack_arrays,
+ args.hasFlag(clang::options::OPT_frepack_arrays,
+ clang::options::OPT_fno_repack_arrays,
/*default=*/false));
invoc.loweringOpts.setStackRepackArrays(
- args.hasFlag(clang::driver::options::OPT_fstack_repack_arrays,
- clang::driver::options::OPT_fno_stack_repack_arrays,
+ args.hasFlag(clang::options::OPT_fstack_repack_arrays,
+ clang::options::OPT_fno_stack_repack_arrays,
/*default=*/false));
if (auto *arg = args.getLastArg(
- clang::driver::options::OPT_frepack_arrays_contiguity_EQ))
+ clang::options::OPT_frepack_arrays_contiguity_EQ))
invoc.loweringOpts.setRepackArraysWhole(arg->getValue() ==
llvm::StringRef{"whole"});
@@ -1668,9 +1668,9 @@ bool CompilerInvocation::createFromArgs(
// * `-mllvm <your-llvm-option>`, or
// * `-mmlir <your-mlir-option>`.
invoc.frontendOpts.llvmArgs =
- args.getAllArgValues(clang::driver::options::OPT_mllvm);
+ args.getAllArgValues(clang::options::OPT_mllvm);
invoc.frontendOpts.mlirArgs =
- args.getAllArgValues(clang::driver::options::OPT_mmlir);
+ args.getAllArgValues(clang::options::OPT_mmlir);
success &= parseLangOptionsArgs(invoc, args, diags);
@@ -1694,7 +1694,7 @@ bool CompilerInvocation::createFromArgs(
}
// Process the timing-related options.
- if (args.hasArg(clang::driver::options::OPT_ftime_report))
+ if (args.hasArg(clang::options::OPT_ftime_report))
invoc.enableTimers = true;
invoc.setArgv0(argv0);
diff --git a/flang/lib/FrontendTool/CMakeLists.txt b/flang/lib/FrontendTool/CMakeLists.txt
index faf56e9d955a1..b69436c36d438 100644
--- a/flang/lib/FrontendTool/CMakeLists.txt
+++ b/flang/lib/FrontendTool/CMakeLists.txt
@@ -18,5 +18,6 @@ add_flang_library(flangFrontendTool
CLANG_LIBS
clangBasic
+ clangOptions
clangDriver
)
diff --git a/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
index 09ac129d3e689..a725b14f2146f 100644
--- a/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ b/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -23,7 +23,7 @@
#include "mlir/IR/MLIRContext.h"
#include "mlir/Pass/PassManager.h"
#include "clang/Basic/DiagnosticFrontend.h"
-#include "clang/Driver/Options.h"
+#include "clang/Options/Options.h"
#include "llvm/Option/OptTable.h"
#include "llvm/Option/Option.h"
#include "llvm/Support/BuryPointer.h"
@@ -153,10 +153,10 @@ updateDiagEngineForOptRemarks(clang::DiagnosticsEngine &diagsEng,
bool executeCompilerInvocation(CompilerInstance *flang) {
// Honor -help.
if (flang->getFrontendOpts().showHelp) {
- clang::driver::getDriverOptTable().printHelp(
+ clang::getDriverOptTable().printHelp(
llvm::outs(), "flang -fc1 [options] file...", "LLVM 'Flang' Compiler",
/*ShowHidden=*/false, /*ShowAllAliases=*/false,
- llvm::opt::Visibility(clang::driver::options::FC1Option));
+ llvm::opt::Visibility(options::FC1Option));
return true;
}
diff --git a/flang/tools/flang-driver/CMakeLists.txt b/flang/tools/flang-driver/CMakeLists.txt
index b5d6727025121..4dfc0d40cd55d 100644
--- a/flang/tools/flang-driver/CMakeLists.txt
+++ b/flang/tools/flang-driver/CMakeLists.txt
@@ -26,6 +26,7 @@ target_link_libraries(flang
clang_target_link_libraries(flang
PRIVATE
clangDriver
+ clangOptions
clangBasic
)
diff --git a/flang/tools/flang-driver/driver.cpp b/flang/tools/flang-driver/driver.cpp
index bd878b7a642f1..0840255a739f3 100644
--- a/flang/tools/flang-driver/driver.cpp
+++ b/flang/tools/flang-driver/driver.cpp
@@ -52,9 +52,9 @@ createAndPopulateDiagOpts(llvm::ArrayRef<const char *> argv) {
// Any errors that would be diagnosed here will also be diagnosed later,
// when the DiagnosticsEngine actually exists.
unsigned missingArgIndex, missingArgCount;
- llvm::opt::InputArgList args = clang::driver::getDriverOptTable().ParseArgs(
+ llvm::opt::InputArgList args = clang::getDriverOptTable().ParseArgs(
argv.slice(1), missingArgIndex, missingArgCount,
- llvm::opt::Visibility(clang::driver::options::FlangOption));
+ llvm::opt::Visibility(clang::options::FlangOption));
(void)Fortran::frontend::parseDiagnosticArgs(*diagOpts, args);
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
index 5aad4470091bc..659665b79e7dd 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -56,7 +56,7 @@ using namespace lldb;
using namespace lldb_private;
#define OPTTABLE_STR_TABLE_CODE
-#include "clang/Driver/Options.inc"
+#include "clang/Options/Options.inc"
#undef OPTTABLE_STR_TABLE_CODE
static Status ExceptionMaskValidator(const char *string, void *unused) {
@@ -1122,7 +1122,7 @@ void PlatformDarwin::AddClangModuleCompilationOptionsForSDKType(
#define OPTION(PREFIX_OFFSET, NAME_OFFSET, VAR, ...) \
llvm::StringRef opt_##VAR = OptionStrTable[NAME_OFFSET]; \
(void)opt_##VAR;
-#include "clang/Driver/Options.inc"
+#include "clang/Options/Options.inc"
#undef OPTION
minimum_version_option << '-';
switch (sdk_type) {
diff --git a/llvm/include/llvm/MC/MCAsmInfo.h b/llvm/include/llvm/MC/MCAsmInfo.h
index 7a2e9ad154f01..ea8ac6dbe6e34 100644
--- a/llvm/include/llvm/MC/MCAsmInfo.h
+++ b/llvm/include/llvm/MC/MCAsmInfo.h
@@ -401,7 +401,7 @@ class LLVM_ABI MCAsmInfo {
// Generated object files can use all ELF features supported by GNU ld of
// this binutils version and later. INT_MAX means all features can be used,
// regardless of GNU ld support. The default value is referenced by
- // clang/Driver/Options.td.
+ // clang/Options/Options.td.
std::pair<int, int> BinutilsVersion = {2, 26};
/// Should we use the integrated assembler?
diff --git a/llvm/include/llvm/Option/Arg.h b/llvm/include/llvm/Option/Arg.h
index b1e56b58da684..496373d28600f 100644
--- a/llvm/include/llvm/Option/Arg.h
+++ b/llvm/include/llvm/Option/Arg.h
@@ -51,7 +51,7 @@ class Arg {
/// Was this argument used to affect compilation?
///
/// This is used to generate an "argument unused" warning (without
- /// clang::driver::options::TargetSpecific) or "unsupported option" error
+ /// clang::options::TargetSpecific) or "unsupported option" error
/// (with TargetSpecific).
mutable unsigned Claimed : 1;
diff --git a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel
index 4d279bffd3723..36b71dd49ef13 100644
--- a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel
@@ -1501,9 +1501,9 @@ cc_library(
gentbl_cc_library(
name = "driver_options_inc_gen",
- tbl_outs = {"include/clang/Driver/Options.inc": ["-gen-opt-parser-defs"]},
+ tbl_outs = {"include/clang/Options/Options.inc": ["-gen-opt-parser-defs"]},
tblgen = "//llvm:llvm-tblgen",
- td_file = "include/clang/Driver/Options.td",
+ td_file = "include/clang/Options/Options.td",
deps = ["//llvm:OptParserTdFiles"],
)
>From d9aac486fe05b613ec3f33c8ce798ce1e870b32d Mon Sep 17 00:00:00 2001
From: Naveen Seth Hanig <naveen.hanig at outlook.com>
Date: Thu, 16 Oct 2025 01:57:26 +0200
Subject: [PATCH 2/7] Fix missing namespace qualifier for flang
---
flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
index a725b14f2146f..7586be59ba01b 100644
--- a/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ b/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -156,7 +156,7 @@ bool executeCompilerInvocation(CompilerInstance *flang) {
clang::getDriverOptTable().printHelp(
llvm::outs(), "flang -fc1 [options] file...", "LLVM 'Flang' Compiler",
/*ShowHidden=*/false, /*ShowAllAliases=*/false,
- llvm::opt::Visibility(options::FC1Option));
+ llvm::opt::Visibility(clang::options::FC1Option));
return true;
}
>From 2e4675e61fda66cee3018bdf865f5b919fe57bce Mon Sep 17 00:00:00 2001
From: Naveen Seth Hanig <naveen.hanig at outlook.com>
Date: Thu, 16 Oct 2025 02:23:27 +0200
Subject: [PATCH 3/7] Fix documentation build
---
clang/docs/CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/docs/CMakeLists.txt b/clang/docs/CMakeLists.txt
index 1f06c040c96cb..9469a832adb62 100644
--- a/clang/docs/CMakeLists.txt
+++ b/clang/docs/CMakeLists.txt
@@ -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)
>From 19b4d8c41d9a36d2e811f4815f82c414c6ec048b Mon Sep 17 00:00:00 2001
From: Naveen Seth Hanig <naveen.hanig at outlook.com>
Date: Thu, 16 Oct 2025 02:37:55 +0200
Subject: [PATCH 4/7] Fix formatting
---
clang-tools-extra/clangd/CompileCommands.cpp | 3 +-
clang/include/clang/Frontend/Utils.h | 2 +-
clang/lib/Driver/ToolChains/AIX.cpp | 3 +-
clang/lib/Driver/ToolChains/AMDGPU.cpp | 11 +-
.../lib/Driver/ToolChains/Arch/LoongArch.cpp | 3 +-
clang/lib/Driver/ToolChains/Arch/Mips.cpp | 3 +-
clang/lib/Driver/ToolChains/Arch/SystemZ.cpp | 4 +-
clang/lib/Driver/ToolChains/Clang.cpp | 3 +-
clang/lib/Driver/ToolChains/CommonArgs.cpp | 16 +-
clang/lib/Driver/ToolChains/Gnu.cpp | 6 +-
clang/lib/Options/OptionUtils.cpp | 2 +-
clang/lib/Tooling/Tooling.cpp | 6 +-
clang/tools/clang-installapi/Options.cpp | 7 +-
clang/tools/driver/cc1as_main.cpp | 3 +-
clang/unittests/Driver/DXCModeTest.cpp | 4 +-
flang/lib/Frontend/CompilerInvocation.cpp | 217 ++++++++----------
16 files changed, 122 insertions(+), 171 deletions(-)
diff --git a/clang-tools-extra/clangd/CompileCommands.cpp b/clang-tools-extra/clangd/CompileCommands.cpp
index f5592b60a817a..7990f2719e9a0 100644
--- a/clang-tools-extra/clangd/CompileCommands.cpp
+++ b/clang-tools-extra/clangd/CompileCommands.cpp
@@ -267,8 +267,7 @@ void CommandMangler::operator()(tooling::CompileCommand &Command,
IndicesToDrop.push_back(Input->getIndex());
}
// Anything after `--` is also treated as input, drop them as well.
- if (auto *DashDash =
- ArgList.getLastArgNoClaim(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)
diff --git a/clang/include/clang/Frontend/Utils.h b/clang/include/clang/Frontend/Utils.h
index 6961b8a234d18..ed2703c76f18d 100644
--- a/clang/include/clang/Frontend/Utils.h
+++ b/clang/include/clang/Frontend/Utils.h
@@ -15,8 +15,8 @@
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/LLVM.h"
-#include "clang/Options/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"
diff --git a/clang/lib/Driver/ToolChains/AIX.cpp b/clang/lib/Driver/ToolChains/AIX.cpp
index dfb0256e0adea..a8acf9cfc44c9 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -168,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(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)
diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index 6cb333b285a27..6685783f3bdbf 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -323,22 +323,19 @@ RocmInstallationDetector::RocmInstallationDetector(
: D(D) {
Verbose = Args.hasArg(options::OPT_v);
RocmPathArg = Args.getLastArgValue(options::OPT_rocm_path_EQ);
- PrintROCmSearchDirs =
- Args.hasArg(options::OPT_print_rocm_search_dirs);
+ PrintROCmSearchDirs = Args.hasArg(options::OPT_print_rocm_search_dirs);
RocmDeviceLibPathArg =
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);
+ HIPStdParPathArg = Args.getLastArgValue(options::OPT_hipstdpar_path_EQ);
HasHIPStdParLibrary =
!HIPStdParPathArg.empty() && D.getVFS().exists(HIPStdParPathArg +
"/hipstdpar_lib.hpp");
HIPRocThrustPathArg =
- Args.getLastArgValue(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(options::OPT_hipstdpar_prim_path_EQ);
+ HIPRocPrimPathArg = Args.getLastArgValue(options::OPT_hipstdpar_prim_path_EQ);
HasRocPrimLibrary = !HIPRocPrimPathArg.empty() &&
D.getVFS().exists(HIPRocPrimPathArg + "/rocprim");
diff --git a/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp b/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
index 8f7aaa397a261..da084bdabaee3 100644
--- a/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
@@ -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(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.
diff --git a/clang/lib/Driver/ToolChains/Arch/Mips.cpp b/clang/lib/Driver/ToolChains/Arch/Mips.cpp
index bcf8f3ab0edeb..4bcbb7146ef02 100644
--- a/clang/lib/Driver/ToolChains/Arch/Mips.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/Mips.cpp
@@ -49,8 +49,7 @@ void mips::getMipsCPUAndABI(const ArgList &Args, const llvm::Triple &Triple,
DefMips64CPU = "mips3";
}
- if (Arg *A = Args.getLastArg(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)) {
diff --git a/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp b/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp
index 97dc9bd853ede..1ef6a725483e8 100644
--- a/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp
@@ -25,8 +25,8 @@ 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(options::OPT_msoft_float,
- options::OPT_mhard_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;
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 08dd2a2160296..8964af8e022b0 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2217,8 +2217,7 @@ void Clang::AddX86TargetArgs(const ArgList &Args,
// Default to "generic" unless -march is present or targetting the PS4/PS5.
std::string TuneCPU;
- if (!Args.hasArg(options::OPT_march_EQ) &&
- !getToolChain().getTriple().isPS())
+ if (!Args.hasArg(options::OPT_march_EQ) && !getToolChain().getTriple().isPS())
TuneCPU = "generic";
// Override based on -mtune.
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 2452967bc0b2f..06982e1f679ea 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -69,8 +69,7 @@ using namespace llvm::opt;
static bool useFramePointerForTargetByDefault(const llvm::opt::ArgList &Args,
const llvm::Triple &Triple) {
- if (Args.hasArg(options::OPT_pg) &&
- !Args.hasArg(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(options::OPT_fno_omit_frame_pointer,
- 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(
- options::OPT_mno_omit_leaf_frame_pointer,
- 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);
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
index 2d8d5818fe7eb..6e8874d8113c1 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -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(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(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);
diff --git a/clang/lib/Options/OptionUtils.cpp b/clang/lib/Options/OptionUtils.cpp
index e22692d02ec65..fcafd3c83c6b3 100644
--- a/clang/lib/Options/OptionUtils.cpp
+++ b/clang/lib/Options/OptionUtils.cpp
@@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//
+#include "clang/Options/OptionUtils.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticDriver.h"
-#include "clang/Options/OptionUtils.h"
#include "llvm/Option/ArgList.h"
using namespace clang;
diff --git a/clang/lib/Tooling/Tooling.cpp b/clang/lib/Tooling/Tooling.cpp
index f3793179694b0..6af7c7a8d482e 100644
--- a/clang/lib/Tooling/Tooling.cpp
+++ b/clang/lib/Tooling/Tooling.cpp
@@ -272,12 +272,10 @@ void addTargetAndModeForProgramName(std::vector<std::string> &CommandLine,
return;
const auto &Table = getDriverOptTable();
// --target=X
- StringRef TargetOPT =
- Table.getOption(options::OPT_target).getPrefixedName();
+ StringRef TargetOPT = Table.getOption(options::OPT_target).getPrefixedName();
// -target X
StringRef TargetOPTLegacy =
- Table.getOption(options::OPT_target_legacy_spelling)
- .getPrefixedName();
+ Table.getOption(options::OPT_target_legacy_spelling).getPrefixedName();
// --driver-mode=X
StringRef DriverModeOPT =
Table.getOption(options::OPT_driver_mode).getPrefixedName();
diff --git a/clang/tools/clang-installapi/Options.cpp b/clang/tools/clang-installapi/Options.cpp
index 8dea9e63d2d17..f484d6f33ad8f 100644
--- a/clang/tools/clang-installapi/Options.cpp
+++ b/clang/tools/clang-installapi/Options.cpp
@@ -432,9 +432,10 @@ bool Options::processLinkerOptions(InputArgList &Args) {
Arg->claim();
}
- LinkerOpts.AppExtensionSafe = Args.hasFlag(
- options::OPT_fapplication_extension, options::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;
diff --git a/clang/tools/driver/cc1as_main.cpp b/clang/tools/driver/cc1as_main.cpp
index 876a302a42bc4..f13812f2a8383 100644
--- a/clang/tools/driver/cc1as_main.cpp
+++ b/clang/tools/driver/cc1as_main.cpp
@@ -687,8 +687,7 @@ int cc1as_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {
getDriverOptTable().printHelp(
llvm::outs(), "clang -cc1as [options] file...",
"Clang Integrated Assembler", /*ShowHidden=*/false,
- /*ShowAllAliases=*/false,
- llvm::opt::Visibility(options::CC1AsOption));
+ /*ShowAllAliases=*/false, llvm::opt::Visibility(options::CC1AsOption));
return 0;
}
diff --git a/clang/unittests/Driver/DXCModeTest.cpp b/clang/unittests/Driver/DXCModeTest.cpp
index 061d47b1887db..e0454f190b35a 100644
--- a/clang/unittests/Driver/DXCModeTest.cpp
+++ b/clang/unittests/Driver/DXCModeTest.cpp
@@ -131,8 +131,8 @@ TEST(DxcModeTest, ValidatorVersionValidation) {
TC.TranslateArgs(*DAL, "0", Action::OffloadKind::OFK_None)};
EXPECT_NE(TranslatedArgs, nullptr);
if (TranslatedArgs) {
- auto *A = TranslatedArgs->getLastArg(
- clang::options::OPT_dxil_validator_version);
+ auto *A =
+ TranslatedArgs->getLastArg(clang::options::OPT_dxil_validator_version);
EXPECT_NE(A, nullptr);
if (A) {
EXPECT_STREQ(A->getValue(), "1.1");
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index 63eb1958d8f1b..de0e331c29a6b 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -107,15 +107,13 @@ static unsigned getOptimizationLevel(llvm::opt::ArgList &args,
clang::DiagnosticsEngine &diags) {
unsigned defaultOpt = 0;
- if (llvm::opt::Arg *a =
- args.getLastArg(clang::options::OPT_O_Group)) {
+ if (llvm::opt::Arg *a = args.getLastArg(clang::options::OPT_O_Group)) {
if (a->getOption().matches(clang::options::OPT_O0))
return 0;
assert(a->getOption().matches(clang::options::OPT_O));
- return getLastArgIntValue(args, clang::options::OPT_O, defaultOpt,
- diags);
+ return getLastArgIntValue(args, clang::options::OPT_O, defaultOpt, diags);
}
return defaultOpt;
@@ -331,15 +329,14 @@ static void parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts,
clang::driver::tools::parseMPreferVectorWidthOption(diags, args);
// -fembed-offload-object option
- for (auto *a :
- args.filtered(clang::options::OPT_fembed_offload_object_EQ))
+ for (auto *a : args.filtered(clang::options::OPT_fembed_offload_object_EQ))
opts.OffloadObjects.push_back(a->getValue());
if (args.hasArg(clang::options::OPT_finstrument_functions))
opts.InstrumentFunctions = 1;
- if (const llvm::opt::Arg *a = args.getLastArg(
- clang::options::OPT_mcode_object_version_EQ)) {
+ if (const llvm::opt::Arg *a =
+ args.getLastArg(clang::options::OPT_mcode_object_version_EQ)) {
llvm::StringRef s = a->getValue();
if (s == "6")
opts.CodeObjectVersion = llvm::CodeObjectVersionKind::COV_6;
@@ -375,9 +372,9 @@ static void parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts,
/*remarkOptName=*/"pass");
// Create OptRemark that allows all missed optimization passes to be printed.
- opts.OptimizationRemarkMissed = parseOptimizationRemark(
- diags, args, clang::options::OPT_Rpass_missed_EQ,
- /*remarkOptName=*/"pass-missed");
+ opts.OptimizationRemarkMissed =
+ parseOptimizationRemark(diags, args, clang::options::OPT_Rpass_missed_EQ,
+ /*remarkOptName=*/"pass-missed");
// Create OptRemark that allows all optimization decisions made by LLVM
// to be printed.
@@ -410,8 +407,7 @@ static void parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts,
}
// -mlink-builtin-bitcode
- for (auto *a :
- args.filtered(clang::options::OPT_mlink_builtin_bitcode))
+ for (auto *a : args.filtered(clang::options::OPT_mlink_builtin_bitcode))
opts.BuiltinBCLibs.push_back(a->getValue());
// -mrelocation-model option.
@@ -435,12 +431,11 @@ static void parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts,
}
// -pic-level and -pic-is-pie option.
- if (int picLevel = getLastArgIntValue(
- args, clang::options::OPT_pic_level, 0, diags)) {
+ if (int picLevel =
+ getLastArgIntValue(args, clang::options::OPT_pic_level, 0, diags)) {
if (picLevel > 2)
diags.Report(clang::diag::err_drv_invalid_value)
- << args.getLastArg(clang::options::OPT_pic_level)
- ->getAsString(args)
+ << args.getLastArg(clang::options::OPT_pic_level)->getAsString(args)
<< picLevel;
opts.PICLevel = picLevel;
@@ -470,8 +465,8 @@ static void parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts,
<< a->getAsString(args) << modelName;
}
- if (const llvm::opt::Arg *arg = args.getLastArg(
- clang::options::OPT_mlarge_data_threshold_EQ)) {
+ if (const llvm::opt::Arg *arg =
+ args.getLastArg(clang::options::OPT_mlarge_data_threshold_EQ)) {
uint64_t LDT;
if (llvm::StringRef(arg->getValue()).getAsInteger(/*Radix=*/10, LDT)) {
diags.Report(clang::diag::err_drv_invalid_value)
@@ -510,26 +505,23 @@ static void parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts,
/// \param [in] opts The target options instance to update
/// \param [in] args The list of input arguments (from the compiler invocation)
static void parseTargetArgs(TargetOptions &opts, llvm::opt::ArgList &args) {
- if (const llvm::opt::Arg *a =
- args.getLastArg(clang::options::OPT_triple))
+ if (const llvm::opt::Arg *a = args.getLastArg(clang::options::OPT_triple))
opts.triple = a->getValue();
- opts.atomicIgnoreDenormalMode = args.hasFlag(
- clang::options::OPT_fatomic_ignore_denormal_mode,
- clang::options::OPT_fno_atomic_ignore_denormal_mode, false);
- opts.atomicFineGrainedMemory = args.hasFlag(
- clang::options::OPT_fatomic_fine_grained_memory,
- clang::options::OPT_fno_atomic_fine_grained_memory, false);
+ opts.atomicIgnoreDenormalMode =
+ args.hasFlag(clang::options::OPT_fatomic_ignore_denormal_mode,
+ clang::options::OPT_fno_atomic_ignore_denormal_mode, false);
+ opts.atomicFineGrainedMemory =
+ args.hasFlag(clang::options::OPT_fatomic_fine_grained_memory,
+ clang::options::OPT_fno_atomic_fine_grained_memory, false);
opts.atomicRemoteMemory =
args.hasFlag(clang::options::OPT_fatomic_remote_memory,
clang::options::OPT_fno_atomic_remote_memory, false);
- if (const llvm::opt::Arg *a =
- args.getLastArg(clang::options::OPT_target_cpu))
+ if (const llvm::opt::Arg *a = args.getLastArg(clang::options::OPT_target_cpu))
opts.cpu = a->getValue();
- if (const llvm::opt::Arg *a =
- args.getLastArg(clang::options::OPT_tune_cpu))
+ if (const llvm::opt::Arg *a = args.getLastArg(clang::options::OPT_tune_cpu))
opts.cpuToTuneFor = a->getValue();
for (const llvm::opt::Arg *currentArg :
@@ -548,8 +540,7 @@ static void parseTargetArgs(TargetOptions &opts, llvm::opt::ArgList &args) {
if (args.hasArg(clang::options::OPT_fdisable_integer_16))
opts.disabledIntegerKinds.push_back(16);
- if (const llvm::opt::Arg *a =
- args.getLastArg(clang::options::OPT_mabi_EQ)) {
+ if (const llvm::opt::Arg *a = args.getLastArg(clang::options::OPT_mabi_EQ)) {
opts.abi = a->getValue();
llvm::StringRef V = a->getValue();
if (V == "vec-extabi") {
@@ -559,9 +550,8 @@ static void parseTargetArgs(TargetOptions &opts, llvm::opt::ArgList &args) {
}
}
- opts.asmVerbose =
- args.hasFlag(clang::options::OPT_fverbose_asm,
- clang::options::OPT_fno_verbose_asm, false);
+ opts.asmVerbose = args.hasFlag(clang::options::OPT_fverbose_asm,
+ clang::options::OPT_fno_verbose_asm, false);
}
// Tweak the frontend configuration based on the frontend action
static void setUpFrontendBasedOnAction(FrontendOptions &opts) {
@@ -720,8 +710,7 @@ static bool parseFrontendArgs(FrontendOptions &opts, llvm::opt::ArgList &args,
}
// Parsing -plugin <name> option and storing plugin name and setting action
- if (const llvm::opt::Arg *a =
- args.getLastArg(clang::options::OPT_plugin)) {
+ if (const llvm::opt::Arg *a = args.getLastArg(clang::options::OPT_plugin)) {
opts.programAction = PluginAction;
opts.actionName = a->getValue();
}
@@ -734,8 +723,7 @@ static bool parseFrontendArgs(FrontendOptions &opts, llvm::opt::ArgList &args,
// Get the input kind (from the value passed via `-x`)
InputKind dashX(Language::Unknown);
- if (const llvm::opt::Arg *a =
- args.getLastArg(clang::options::OPT_x)) {
+ if (const llvm::opt::Arg *a = args.getLastArg(clang::options::OPT_x)) {
llvm::StringRef xValue = a->getValue();
// Principal languages.
dashX = llvm::StringSwitch<InputKind>(xValue)
@@ -782,13 +770,11 @@ static bool parseFrontendArgs(FrontendOptions &opts, llvm::opt::ArgList &args,
}
// Set fortranForm based on options -ffree-form and -ffixed-form.
- if (const auto *arg =
- args.getLastArg(clang::options::OPT_ffixed_form,
- clang::options::OPT_ffree_form)) {
- opts.fortranForm =
- arg->getOption().matches(clang::options::OPT_ffixed_form)
- ? FortranForm::FixedForm
- : FortranForm::FreeForm;
+ if (const auto *arg = args.getLastArg(clang::options::OPT_ffixed_form,
+ clang::options::OPT_ffree_form)) {
+ opts.fortranForm = arg->getOption().matches(clang::options::OPT_ffixed_form)
+ ? FortranForm::FixedForm
+ : FortranForm::FreeForm;
}
// Set fixedFormColumns based on -ffixed-line-length=<value>
@@ -815,8 +801,7 @@ static bool parseFrontendArgs(FrontendOptions &opts, llvm::opt::ArgList &args,
}
// Set conversion based on -fconvert=<value>
- if (const auto *arg =
- args.getLastArg(clang::options::OPT_fconvert_EQ)) {
+ if (const auto *arg = args.getLastArg(clang::options::OPT_fconvert_EQ)) {
const char *argValue = arg->getValue();
if (auto convert = parseConvertArg(argValue))
opts.envDefaults.push_back({"FORT_CONVERT", *convert});
@@ -826,41 +811,38 @@ static bool parseFrontendArgs(FrontendOptions &opts, llvm::opt::ArgList &args,
}
// -f{no-}implicit-none
- opts.features.Enable(
- Fortran::common::LanguageFeature::ImplicitNoneTypeAlways,
- args.hasFlag(clang::options::OPT_fimplicit_none,
- clang::options::OPT_fno_implicit_none, false));
+ opts.features.Enable(Fortran::common::LanguageFeature::ImplicitNoneTypeAlways,
+ args.hasFlag(clang::options::OPT_fimplicit_none,
+ clang::options::OPT_fno_implicit_none,
+ false));
// -f{no-}implicit-none-ext
- opts.features.Enable(
- Fortran::common::LanguageFeature::ImplicitNoneExternal,
- args.hasFlag(clang::options::OPT_fimplicit_none_ext,
- clang::options::OPT_fno_implicit_none_ext, false));
+ opts.features.Enable(Fortran::common::LanguageFeature::ImplicitNoneExternal,
+ args.hasFlag(clang::options::OPT_fimplicit_none_ext,
+ clang::options::OPT_fno_implicit_none_ext,
+ false));
// -f{no-}backslash
opts.features.Enable(Fortran::common::LanguageFeature::BackslashEscapes,
args.hasFlag(clang::options::OPT_fbackslash,
- clang::options::OPT_fno_backslash,
- false));
+ clang::options::OPT_fno_backslash, false));
// -f{no-}logical-abbreviations
opts.features.Enable(
Fortran::common::LanguageFeature::LogicalAbbreviations,
args.hasFlag(clang::options::OPT_flogical_abbreviations,
- clang::options::OPT_fno_logical_abbreviations,
- false));
+ clang::options::OPT_fno_logical_abbreviations, false));
// -f{no-}unsigned
opts.features.Enable(Fortran::common::LanguageFeature::Unsigned,
args.hasFlag(clang::options::OPT_funsigned,
- clang::options::OPT_fno_unsigned,
- false));
+ clang::options::OPT_fno_unsigned, false));
// -f{no-}xor-operator
- opts.features.Enable(
- Fortran::common::LanguageFeature::XOROperator,
- args.hasFlag(clang::options::OPT_fxor_operator,
- clang::options::OPT_fno_xor_operator, false));
+ opts.features.Enable(Fortran::common::LanguageFeature::XOROperator,
+ args.hasFlag(clang::options::OPT_fxor_operator,
+ clang::options::OPT_fno_xor_operator,
+ false));
// -fno-automatic
if (args.hasArg(clang::options::OPT_fno_automatic)) {
@@ -868,13 +850,12 @@ static bool parseFrontendArgs(FrontendOptions &opts, llvm::opt::ArgList &args,
}
// -f{no}-save-main-program
- opts.features.Enable(
- Fortran::common::LanguageFeature::SaveMainProgram,
- args.hasFlag(clang::options::OPT_fsave_main_program,
- clang::options::OPT_fno_save_main_program, false));
+ opts.features.Enable(Fortran::common::LanguageFeature::SaveMainProgram,
+ args.hasFlag(clang::options::OPT_fsave_main_program,
+ clang::options::OPT_fno_save_main_program,
+ false));
- if (args.hasArg(
- clang::options::OPT_falternative_parameter_statement)) {
+ if (args.hasArg(clang::options::OPT_falternative_parameter_statement)) {
opts.features.Enable(Fortran::common::LanguageFeature::OldStyleParameter);
}
if (const llvm::opt::Arg *arg =
@@ -923,8 +904,8 @@ static std::string getOpenMPHeadersDir(const char *argv) {
static void parsePreprocessorArgs(Fortran::frontend::PreprocessorOptions &opts,
llvm::opt::ArgList &args) {
// Add macros from the command line.
- for (const auto *currentArg : args.filtered(clang::options::OPT_D,
- clang::options::OPT_U)) {
+ for (const auto *currentArg :
+ args.filtered(clang::options::OPT_D, clang::options::OPT_U)) {
if (currentArg->getOption().matches(clang::options::OPT_D)) {
opts.addMacroDef(currentArg->getValue());
} else {
@@ -943,12 +924,11 @@ static void parsePreprocessorArgs(Fortran::frontend::PreprocessorOptions &opts,
opts.searchDirectoriesFromIntrModPath.emplace_back(currentArg->getValue());
// -cpp/-nocpp
- if (const auto *currentArg = args.getLastArg(
- clang::options::OPT_cpp, clang::options::OPT_nocpp))
- opts.macrosFlag =
- (currentArg->getOption().matches(clang::options::OPT_cpp))
- ? PPMacrosFlag::Include
- : PPMacrosFlag::Exclude;
+ if (const auto *currentArg =
+ args.getLastArg(clang::options::OPT_cpp, clang::options::OPT_nocpp))
+ opts.macrosFlag = (currentArg->getOption().matches(clang::options::OPT_cpp))
+ ? PPMacrosFlag::Include
+ : PPMacrosFlag::Exclude;
// Enable -cpp based on -x unless explicitly disabled with -nocpp
if (opts.macrosFlag != PPMacrosFlag::Exclude)
if (const auto *dashX = args.getLastArg(clang::options::OPT_x))
@@ -1006,9 +986,9 @@ static bool parseSemaArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
}
// -f{no-}analyzed-objects-for-unparse
- res.setUseAnalyzedObjectsForUnparse(args.hasFlag(
- clang::options::OPT_fanalyzed_objects_for_unparse,
- clang::options::OPT_fno_analyzed_objects_for_unparse, true));
+ res.setUseAnalyzedObjectsForUnparse(
+ args.hasFlag(clang::options::OPT_fanalyzed_objects_for_unparse,
+ clang::options::OPT_fno_analyzed_objects_for_unparse, true));
return diags.getNumErrors() == numErrorsBefore;
}
@@ -1036,8 +1016,7 @@ static bool parseDiagArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
// TODO: Currently throws a Diagnostic for anything other than -W<error>,
// this has to change when other -W<opt>'s are supported.
if (args.hasArg(clang::options::OPT_W_Joined)) {
- const auto &wArgs =
- args.getAllArgValues(clang::options::OPT_W_Joined);
+ const auto &wArgs = args.getAllArgValues(clang::options::OPT_W_Joined);
for (const auto &wArg : wArgs) {
if (wArg == "error") {
res.setWarnAsErr(true);
@@ -1175,11 +1154,10 @@ static bool parseOpenMPArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
clang::DiagnosticsEngine &diags) {
llvm::opt::Arg *arg = args.getLastArg(clang::options::OPT_fopenmp,
clang::options::OPT_fno_openmp);
- if (!arg ||
- arg->getOption().matches(clang::options::OPT_fno_openmp)) {
- bool isSimdSpecified = args.hasFlag(
- clang::options::OPT_fopenmp_simd,
- clang::options::OPT_fno_openmp_simd, /*Default=*/false);
+ if (!arg || arg->getOption().matches(clang::options::OPT_fno_openmp)) {
+ bool isSimdSpecified =
+ args.hasFlag(clang::options::OPT_fopenmp_simd,
+ clang::options::OPT_fno_openmp_simd, /*Default=*/false);
if (!isSimdSpecified)
return true;
res.getLangOpts().OpenMPSimd = 1;
@@ -1194,8 +1172,7 @@ static bool parseOpenMPArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
res.getLangOpts().OpenMPVersion = newestFullySupported;
res.getFrontendOpts().features.Enable(
Fortran::common::LanguageFeature::OpenMP);
- if (auto *arg =
- args.getLastArg(clang::options::OPT_fopenmp_version_EQ)) {
+ if (auto *arg = args.getLastArg(clang::options::OPT_fopenmp_version_EQ)) {
llvm::ArrayRef<unsigned> ompVersions = llvm::omp::getOpenMPVersions();
unsigned oldVersions[] = {11, 20, 25, 30};
unsigned version = 0;
@@ -1256,8 +1233,8 @@ static bool parseOpenMPArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
// Get OpenMP host file path if any and report if a non existent file is
// found
- if (auto *arg = args.getLastArg(
- clang::options::OPT_fopenmp_host_ir_file_path)) {
+ if (auto *arg =
+ args.getLastArg(clang::options::OPT_fopenmp_host_ir_file_path)) {
res.getLangOpts().OMPHostIRFile = arg->getValue();
if (!llvm::sys::fs::exists(res.getLangOpts().OMPHostIRFile))
diags.Report(clang::diag::err_omp_host_ir_file_not_found)
@@ -1266,30 +1243,27 @@ static bool parseOpenMPArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
if (args.hasFlag(
clang::options::OPT_fopenmp_assume_teams_oversubscription,
- clang::options::
- OPT_fno_openmp_assume_teams_oversubscription,
+ clang::options::OPT_fno_openmp_assume_teams_oversubscription,
/*Default=*/false))
res.getLangOpts().OpenMPTeamSubscription = true;
if (args.hasArg(clang::options::OPT_fopenmp_assume_no_thread_state))
res.getLangOpts().OpenMPNoThreadState = 1;
- if (args.hasArg(
- clang::options::OPT_fopenmp_assume_no_nested_parallelism))
+ if (args.hasArg(clang::options::OPT_fopenmp_assume_no_nested_parallelism))
res.getLangOpts().OpenMPNoNestedParallelism = 1;
if (args.hasFlag(
clang::options::OPT_fopenmp_assume_threads_oversubscription,
- clang::options::
- OPT_fno_openmp_assume_threads_oversubscription,
+ clang::options::OPT_fno_openmp_assume_threads_oversubscription,
/*Default=*/false))
res.getLangOpts().OpenMPThreadSubscription = true;
if ((args.hasArg(clang::options::OPT_fopenmp_target_debug) ||
args.hasArg(clang::options::OPT_fopenmp_target_debug_EQ))) {
- res.getLangOpts().OpenMPTargetDebug = getLastArgIntValue(
- args, clang::options::OPT_fopenmp_target_debug_EQ,
- res.getLangOpts().OpenMPTargetDebug, diags);
+ res.getLangOpts().OpenMPTargetDebug =
+ getLastArgIntValue(args, clang::options::OPT_fopenmp_target_debug_EQ,
+ res.getLangOpts().OpenMPTargetDebug, diags);
if (!res.getLangOpts().OpenMPTargetDebug &&
args.hasArg(clang::options::OPT_fopenmp_target_debug))
@@ -1311,8 +1285,7 @@ static bool parseOpenMPArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
}
// Get the OpenMP target triples if any.
- if (auto *arg =
- args.getLastArg(clang::options::OPT_offload_targets_EQ)) {
+ if (auto *arg = args.getLastArg(clang::options::OPT_offload_targets_EQ)) {
enum ArchPtrSize { Arch16Bit, Arch32Bit, Arch64Bit };
auto getArchPtrSize = [](const llvm::Triple &triple) {
if (triple.isArch16Bit())
@@ -1440,10 +1413,8 @@ static bool parseFloatingPointArgs(CompilerInvocation &invoc,
/// \param [out] diags DiagnosticsEngine to report erros with
static bool parseVScaleArgs(CompilerInvocation &invoc, llvm::opt::ArgList &args,
clang::DiagnosticsEngine &diags) {
- const auto *vscaleMin =
- args.getLastArg(clang::options::OPT_mvscale_min_EQ);
- const auto *vscaleMax =
- args.getLastArg(clang::options::OPT_mvscale_max_EQ);
+ const auto *vscaleMin = args.getLastArg(clang::options::OPT_mvscale_min_EQ);
+ const auto *vscaleMax = args.getLastArg(clang::options::OPT_mvscale_max_EQ);
if (!vscaleMin && !vscaleMax)
return true;
@@ -1491,8 +1462,7 @@ static bool parseLinkerOptionsArgs(CompilerInvocation &invoc,
// TODO: support --dependent-lib on other platforms when MLIR supports
// !llvm.dependent.lib
- if (args.hasArg(clang::options::OPT_dependent_lib) &&
- !triple.isOSWindows()) {
+ if (args.hasArg(clang::options::OPT_dependent_lib) && !triple.isOSWindows()) {
const unsigned diagID =
diags.getCustomDiagID(clang::DiagnosticsEngine::Error,
"--dependent-lib is only supported on Windows");
@@ -1500,12 +1470,10 @@ static bool parseLinkerOptionsArgs(CompilerInvocation &invoc,
return false;
}
- opts.DependentLibs =
- args.getAllArgValues(clang::options::OPT_dependent_lib);
+ opts.DependentLibs = args.getAllArgValues(clang::options::OPT_dependent_lib);
// -flto=full/thin option.
- if (const llvm::opt::Arg *a =
- args.getLastArg(clang::options::OPT_flto_EQ)) {
+ if (const llvm::opt::Arg *a = args.getLastArg(clang::options::OPT_flto_EQ)) {
llvm::StringRef s = a->getValue();
assert((s == "full" || s == "thin") && "Unknown LTO mode.");
if (s == "full")
@@ -1638,16 +1606,15 @@ bool CompilerInvocation::createFromArgs(
clang::options::OPT_fno_realloc_lhs, true))
invoc.loweringOpts.setReallocateLHS(false);
- invoc.loweringOpts.setRepackArrays(
- args.hasFlag(clang::options::OPT_frepack_arrays,
- clang::options::OPT_fno_repack_arrays,
- /*default=*/false));
+ invoc.loweringOpts.setRepackArrays(args.hasFlag(
+ clang::options::OPT_frepack_arrays, clang::options::OPT_fno_repack_arrays,
+ /*default=*/false));
invoc.loweringOpts.setStackRepackArrays(
args.hasFlag(clang::options::OPT_fstack_repack_arrays,
clang::options::OPT_fno_stack_repack_arrays,
/*default=*/false));
- if (auto *arg = args.getLastArg(
- clang::options::OPT_frepack_arrays_contiguity_EQ))
+ if (auto *arg =
+ args.getLastArg(clang::options::OPT_frepack_arrays_contiguity_EQ))
invoc.loweringOpts.setRepackArraysWhole(arg->getValue() ==
llvm::StringRef{"whole"});
@@ -1667,10 +1634,8 @@ bool CompilerInvocation::createFromArgs(
// `mlirArgs`. Instead, you can use
// * `-mllvm <your-llvm-option>`, or
// * `-mmlir <your-mlir-option>`.
- invoc.frontendOpts.llvmArgs =
- args.getAllArgValues(clang::options::OPT_mllvm);
- invoc.frontendOpts.mlirArgs =
- args.getAllArgValues(clang::options::OPT_mmlir);
+ invoc.frontendOpts.llvmArgs = args.getAllArgValues(clang::options::OPT_mllvm);
+ invoc.frontendOpts.mlirArgs = args.getAllArgValues(clang::options::OPT_mmlir);
success &= parseLangOptionsArgs(invoc, args, diags);
>From fd385af8e5a2789cc38e24fcc35d068571c09359 Mon Sep 17 00:00:00 2001
From: Naveen Seth Hanig <naveen.hanig at outlook.com>
Date: Thu, 16 Oct 2025 02:52:15 +0200
Subject: [PATCH 5/7] Fix documentation build - episode 2
---
flang/docs/CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/flang/docs/CMakeLists.txt b/flang/docs/CMakeLists.txt
index 568f942cb4aa6..b183d6add1059 100644
--- a/flang/docs/CMakeLists.txt
+++ b/flang/docs/CMakeLists.txt
@@ -88,7 +88,7 @@ function (gen_rst_file_from_td output_file td_option source target)
endif()
get_filename_component(TABLEGEN_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${source}" DIRECTORY)
list(APPEND LLVM_TABLEGEN_FLAGS "-I${TABLEGEN_INCLUDE_DIR}")
- list(APPEND LLVM_TABLEGEN_FLAGS "-I${CMAKE_CURRENT_SOURCE_DIR}/../../clang/include/clang/Driver/")
+ list(APPEND LLVM_TABLEGEN_FLAGS "-I${CMAKE_CURRENT_SOURCE_DIR}/../../clang/include/clang/Options/")
clang_tablegen(Source/${output_file} ${td_option} SOURCE ${source} TARGET ${target})
endfunction()
>From a05bd1268ec09bc5fa3433d26a15cd9942de5e73 Mon Sep 17 00:00:00 2001
From: Naveen Seth Hanig <naveen.hanig at outlook.com>
Date: Thu, 16 Oct 2025 03:41:21 +0200
Subject: [PATCH 6/7] Address Bigcheese's review feedback
---
clang/include/clang/Options/ClangOptionDocs.td | 2 +-
clang/include/clang/Options/OptionUtils.h | 6 +++---
clang/include/clang/Options/Options.h | 6 +++---
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/clang/include/clang/Options/ClangOptionDocs.td b/clang/include/clang/Options/ClangOptionDocs.td
index c4da07306eb8e..dea6a7ccb12c9 100644
--- a/clang/include/clang/Options/ClangOptionDocs.td
+++ b/clang/include/clang/Options/ClangOptionDocs.td
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
def GlobalDocumentation {
- code Intro = [{..
+ code Intro =[{..
-------------------------------------------------------------------
NOTE: This file is automatically generated by running clang-tblgen
-gen-opt-docs. Do not edit this file by hand!!
diff --git a/clang/include/clang/Options/OptionUtils.h b/clang/include/clang/Options/OptionUtils.h
index 9b5312eb63fcb..83c48bd7d6843 100644
--- a/clang/include/clang/Options/OptionUtils.h
+++ b/clang/include/clang/Options/OptionUtils.h
@@ -10,8 +10,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_OPTIONUTILS_H
-#define LLVM_CLANG_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_OPTIONUTILS_H
+#endif // LLVM_CLANG_OPTIONS_OPTIONUTILS_H
diff --git a/clang/include/clang/Options/Options.h b/clang/include/clang/Options/Options.h
index 1097845b6e108..ac98699001965 100644
--- a/clang/include/clang/Options/Options.h
+++ b/clang/include/clang/Options/Options.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_OPTIONS_H
-#define LLVM_CLANG_OPTIONS_H
+#ifndef LLVM_CLANG_OPTIONS_OPTIONS_H
+#define LLVM_CLANG_OPTIONS_OPTIONS_H
#include "llvm/Option/OptTable.h"
#include "llvm/Option/Option.h"
@@ -52,4 +52,4 @@ enum ID {
const llvm::opt::OptTable &getDriverOptTable();
} // namespace clang
-#endif
+#endif // LLVM_CLANG_OPTIONS_OPTIONS_H
>From 65b3857f3da5f980915440850dac83c72cee89db Mon Sep 17 00:00:00 2001
From: naveen-seth <naveen.hanig at outlook.com>
Date: Mon, 27 Oct 2025 17:59:59 +0100
Subject: [PATCH 7/7] [clang] Remove clangDriver dependency from clangFrontend
(NFC)
This PR removes the clangDriver dependency from clangFrontend.
The goal of this change is to remove dependencies on the Driver.
This is part of a larger effort to support driver-managed builds for
compilations using C++ named modules and/or Clang modules.
This is required to eventually allow linking the dependency scanning
toolingagainst the Driver without creating cyclic dependencies, which
would cause build failures with dynamic linking enabled.
This change is motivated by the following review comment:
https://github.com/llvm/llvm-project/pull/152770#discussion_r2430756918
---
clang-tools-extra/clangd/CompileCommands.cpp | 4 +-
clang-tools-extra/clangd/Compiler.cpp | 1 +
.../clang/Driver/CreateASTUnitFromArgs.h | 80 ++++
.../clang/Driver/CreateInvocationFromArgs.h | 76 ++++
clang/include/clang/Driver/Driver.h | 10 +
clang/include/clang/Frontend/ASTUnit.h | 146 ++++----
.../Frontend/ChainedDiagnosticConsumer.h | 2 +-
.../clang/Frontend/CompilerInvocation.h | 10 -
.../clang/Frontend/StandaloneDiagnostic.h | 86 +++++
clang/include/clang/Frontend/Utils.h | 45 ---
clang/lib/CrossTU/CMakeLists.txt | 1 +
clang/lib/CrossTU/CrossTranslationUnit.cpp | 3 +-
clang/lib/Driver/CMakeLists.txt | 4 +
clang/lib/Driver/CreateASTUnitFromArgs.cpp | 168 +++++++++
.../CreateInvocationFromArgs.cpp} | 18 +-
clang/lib/Driver/Driver.cpp | 8 +-
clang/lib/Frontend/ASTUnit.cpp | 344 +++---------------
clang/lib/Frontend/CMakeLists.txt | 3 +-
clang/lib/Frontend/CompilerInvocation.cpp | 7 -
clang/lib/Frontend/StandaloneDiagnostic.cpp | 102 ++++++
clang/lib/Interpreter/Interpreter.cpp | 2 +-
clang/lib/Tooling/Tooling.cpp | 3 +-
clang/tools/c-index-test/CMakeLists.txt | 1 +
clang/tools/c-index-test/core_main.cpp | 1 +
clang/tools/diagtool/CMakeLists.txt | 1 +
clang/tools/diagtool/ShowEnabledWarnings.cpp | 1 +
clang/tools/driver/cc1_main.cpp | 3 +-
clang/tools/libclang/CIndex.cpp | 3 +-
clang/tools/libclang/Indexing.cpp | 1 +
clang/unittests/Driver/DXCModeTest.cpp | 1 +
clang/unittests/Driver/ToolChainTest.cpp | 1 +
clang/unittests/Frontend/ASTUnitTest.cpp | 6 +-
.../Frontend/CompilerInstanceTest.cpp | 1 +
clang/unittests/Frontend/UtilsTest.cpp | 1 +
clang/unittests/Sema/CMakeLists.txt | 1 +
clang/unittests/Sema/SemaNoloadLookupTest.cpp | 1 +
.../Serialization/ForceCheckFileInputTest.cpp | 1 +
.../Serialization/LoadSpecLazilyTest.cpp | 1 +
.../Serialization/ModuleCacheTest.cpp | 1 +
.../Serialization/NoCommentsTest.cpp | 1 +
.../PreambleInNamedModulesTest.cpp | 1 +
.../Serialization/VarDeclConstantInitTest.cpp | 1 +
clang/unittests/Tooling/Syntax/TokensTest.cpp | 1 +
.../unittests/Tooling/Syntax/TreeTestBase.cpp | 1 +
44 files changed, 695 insertions(+), 459 deletions(-)
create mode 100644 clang/include/clang/Driver/CreateASTUnitFromArgs.h
create mode 100644 clang/include/clang/Driver/CreateInvocationFromArgs.h
create mode 100644 clang/include/clang/Frontend/StandaloneDiagnostic.h
create mode 100644 clang/lib/Driver/CreateASTUnitFromArgs.cpp
rename clang/lib/{Frontend/CreateInvocationFromCommandLine.cpp => Driver/CreateInvocationFromArgs.cpp} (91%)
create mode 100644 clang/lib/Frontend/StandaloneDiagnostic.cpp
diff --git a/clang-tools-extra/clangd/CompileCommands.cpp b/clang-tools-extra/clangd/CompileCommands.cpp
index 7990f2719e9a0..611a403bed33d 100644
--- a/clang-tools-extra/clangd/CompileCommands.cpp
+++ b/clang-tools-extra/clangd/CompileCommands.cpp
@@ -132,8 +132,8 @@ std::optional<std::string> detectSysroot() {
std::string detectStandardResourceDir() {
static int StaticForMainAddr; // Just an address in this process.
- return CompilerInvocation::GetResourcesPath("clangd",
- (void *)&StaticForMainAddr);
+ return driver::Driver::GetResourcesPathForInvocation(
+ "clangd", (void *)&StaticForMainAddr);
}
// The path passed to argv[0] is important:
diff --git a/clang-tools-extra/clangd/Compiler.cpp b/clang-tools-extra/clangd/Compiler.cpp
index 6ebc2eac25745..9ea7df139382a 100644
--- a/clang-tools-extra/clangd/Compiler.cpp
+++ b/clang-tools-extra/clangd/Compiler.cpp
@@ -9,6 +9,7 @@
#include "Compiler.h"
#include "support/Logger.h"
#include "clang/Basic/TargetInfo.h"
+#include "clang/Driver/CreateInvocationFromArgs.h"
#include "clang/Frontend/CompilerInvocation.h"
#include "clang/Lex/PreprocessorOptions.h"
#include "clang/Serialization/PCHContainerOperations.h"
diff --git a/clang/include/clang/Driver/CreateASTUnitFromArgs.h b/clang/include/clang/Driver/CreateASTUnitFromArgs.h
new file mode 100644
index 0000000000000..30575cc04ca7c
--- /dev/null
+++ b/clang/include/clang/Driver/CreateASTUnitFromArgs.h
@@ -0,0 +1,80 @@
+//===-- CreateInvocationFromArgs.h - Create an ASTUnit from Args-*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// Utility for creating an ASTUnit from a vector of command line arguments.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_DRIVER_CREATEASTUNITFROMARGS_H
+#define LLVM_CLANG_DRIVER_CREATEASTUNITFROMARGS_H
+
+#include "clang/Frontend/ASTUnit.h"
+
+namespace clang {
+
+/// Create an ASTUnit from a vector of command line arguments, which must
+/// specify exactly one source file.
+///
+/// \param ArgBegin - The beginning of the argument vector.
+///
+/// \param ArgEnd - The end of the argument vector.
+///
+/// \param PCHContainerOps - The PCHContainerOperations to use for loading and
+/// creating modules.
+///
+/// \param Diags - The diagnostics engine to use for reporting errors; its
+/// lifetime is expected to extend past that of the returned ASTUnit.
+///
+/// \param ResourceFilesPath - The path to the compiler resource files.
+///
+/// \param StorePreamblesInMemory - Whether to store PCH in memory. If false,
+/// PCH are stored in temporary files.
+///
+/// \param PreambleStoragePath - The path to a directory, in which to create
+/// temporary PCH files. If empty, the default system temporary directory is
+/// used. This parameter is ignored if \p StorePreamblesInMemory is true.
+///
+/// \param ModuleFormat - If provided, uses the specific module format.
+///
+/// \param ErrAST - If non-null and parsing failed without any AST to return
+/// (e.g. because the PCH could not be loaded), this accepts the ASTUnit
+/// mainly to allow the caller to see the diagnostics.
+///
+/// \param VFS - A llvm::vfs::FileSystem to be used for all file accesses.
+/// Note that preamble is saved to a temporary directory on a RealFileSystem,
+/// so in order for it to be loaded correctly, VFS should have access to
+/// it(i.e., be an overlay over RealFileSystem). RealFileSystem will be used
+/// if \p VFS is nullptr.
+///
+// FIXME: Move OnlyLocalDecls, UseBumpAllocator to setters on the ASTUnit, we
+// shouldn't need to specify them at construction time.
+std::unique_ptr<ASTUnit> CreateASTUnitFromCommandLine(
+ const char **ArgBegin, const char **ArgEnd,
+ std::shared_ptr<PCHContainerOperations> PCHContainerOps,
+ std::shared_ptr<DiagnosticOptions> DiagOpts,
+ IntrusiveRefCntPtr<DiagnosticsEngine> Diags, StringRef ResourceFilesPath,
+ bool StorePreamblesInMemory = false,
+ StringRef PreambleStoragePath = StringRef(), bool OnlyLocalDecls = false,
+ CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None,
+ ArrayRef<ASTUnit::RemappedFile> RemappedFiles = {},
+ bool RemappedFilesKeepOriginalName = true,
+ unsigned PrecompilePreambleAfterNParses = 0,
+ TranslationUnitKind TUKind = TU_Complete,
+ bool CacheCodeCompletionResults = false,
+ bool IncludeBriefCommentsInCodeCompletion = false,
+ bool AllowPCHWithCompilerErrors = false,
+ SkipFunctionBodiesScope SkipFunctionBodies = SkipFunctionBodiesScope::None,
+ bool SingleFileParse = false, bool UserFilesAreVolatile = false,
+ bool ForSerialization = false, bool RetainExcludedConditionalBlocks = false,
+ std::optional<StringRef> ModuleFormat = std::nullopt,
+ std::unique_ptr<ASTUnit> *ErrAST = nullptr,
+ IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS = nullptr);
+
+} // namespace clang
+
+#endif // LLVM_CLANG_DRIVER_CREATEASTUNITFROMARGS_H
diff --git a/clang/include/clang/Driver/CreateInvocationFromArgs.h b/clang/include/clang/Driver/CreateInvocationFromArgs.h
new file mode 100644
index 0000000000000..0e0f67373ce87
--- /dev/null
+++ b/clang/include/clang/Driver/CreateInvocationFromArgs.h
@@ -0,0 +1,76 @@
+//===--- CreateInvocationFromArgs.h - CompilerInvocation from Args --------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// Utility for creating a CompilerInvocation from command-line arguments, for
+// tools to use in preparation to parse a file.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_DRIVER_CREATEINVOCATIONFROMARGS_H
+#define LLVM_CLANG_DRIVER_CREATEINVOCATIONFROMARGS_H
+
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/LLVM.h"
+#include "llvm/Support/VirtualFileSystem.h"
+#include <memory>
+#include <string>
+#include <vector>
+
+namespace clang {
+
+class CompilerInvocation;
+class DiagnosticsEngine;
+
+/// Optional inputs to createInvocation.
+struct CreateInvocationOptions {
+ /// Receives diagnostics encountered while parsing command-line flags.
+ /// If not provided, these are printed to stderr.
+ IntrusiveRefCntPtr<DiagnosticsEngine> Diags = nullptr;
+ /// Used e.g. to probe for system headers locations.
+ /// If not provided, the real filesystem is used.
+ /// FIXME: the driver does perform some non-virtualized IO.
+ IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS = nullptr;
+ /// Whether to attempt to produce a non-null (possibly incorrect) invocation
+ /// if any errors were encountered.
+ /// By default, always return null on errors.
+ bool RecoverOnError = false;
+ /// Allow the driver to probe the filesystem for PCH files.
+ /// This is used to replace -include with -include-pch in the cc1 args.
+ /// FIXME: ProbePrecompiled=true is a poor, historical default.
+ /// It misbehaves if the PCH file is from GCC, has the wrong version, etc.
+ bool ProbePrecompiled = false;
+ /// If set, the target is populated with the cc1 args produced by the driver.
+ /// This may be populated even if createInvocation returns nullptr.
+ std::vector<std::string> *CC1Args = nullptr;
+};
+
+/// Interpret clang arguments in preparation to parse a file.
+///
+/// This simulates a number of steps Clang takes when its driver is invoked:
+/// - choosing actions (e.g compile + link) to run
+/// - probing the system for settings like standard library locations
+/// - spawning a cc1 subprocess to compile code, with more explicit arguments
+/// - in the cc1 process, assembling those arguments into a CompilerInvocation
+/// which is used to configure the parser
+///
+/// This simulation is lossy, e.g. in some situations one driver run would
+/// result in multiple parses. (Multi-arch, CUDA, ...).
+/// This function tries to select a reasonable invocation that tools should use.
+///
+/// Args[0] should be the driver name, such as "clang" or "/usr/bin/g++".
+/// Absolute path is preferred - this affects searching for system headers.
+///
+/// May return nullptr if an invocation could not be determined.
+/// See CreateInvocationOptions::RecoverOnError to try harder!
+std::unique_ptr<CompilerInvocation>
+createInvocation(ArrayRef<const char *> Args,
+ CreateInvocationOptions Opts = {});
+
+} // namespace clang
+
+#endif // LLVM_CLANG_DRIVER_CREATEINVOCATIONFROMARGS_H
diff --git a/clang/include/clang/Driver/Driver.h b/clang/include/clang/Driver/Driver.h
index aa86bffb802a4..be446fe46a128 100644
--- a/clang/include/clang/Driver/Driver.h
+++ b/clang/include/clang/Driver/Driver.h
@@ -411,6 +411,16 @@ class Driver {
/// the path to clang's resource directory.
static std::string GetResourcesPath(StringRef BinaryPath);
+ /// Get the directory where the compiler headers reside, relative to the
+ /// compiler binary (found by the passed in arguments).
+ ///
+ /// \param Argv0 - The program path (from argv[0]), for finding the builtin
+ /// compiler path.
+ /// \param MainAddr - The address of main (or some other function in the main
+ /// executable), for finding the builtin compiler path.
+ static std::string GetResourcesPathForInvocation(const char *Argv0,
+ void *MainAddr);
+
Driver(StringRef ClangExecutable, StringRef TargetTriple,
DiagnosticsEngine &Diags, std::string Title = "clang LLVM compiler",
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS = nullptr);
diff --git a/clang/include/clang/Frontend/ASTUnit.h b/clang/include/clang/Frontend/ASTUnit.h
index 3cea159afa33c..341460e1962cb 100644
--- a/clang/include/clang/Frontend/ASTUnit.h
+++ b/clang/include/clang/Frontend/ASTUnit.h
@@ -22,12 +22,14 @@
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetOptions.h"
+#include "clang/Frontend/PrecompiledPreamble.h"
+#include "clang/Frontend/StandaloneDiagnostic.h"
#include "clang/Lex/HeaderSearchOptions.h"
#include "clang/Lex/ModuleLoader.h"
#include "clang/Lex/PreprocessingRecord.h"
#include "clang/Sema/CodeCompleteConsumer.h"
#include "clang/Serialization/ASTBitCodes.h"
-#include "clang/Frontend/PrecompiledPreamble.h"
+#include "clang/Serialization/ASTWriter.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
@@ -36,6 +38,7 @@
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/iterator_range.h"
+#include "llvm/Bitstream/BitstreamWriter.h"
#include <cassert>
#include <cstddef>
#include <cstdint>
@@ -88,25 +91,6 @@ enum class CaptureDiagsKind { None, All, AllWithoutNonErrorsFromIncludes };
/// Utility class for loading a ASTContext from an AST file.
class ASTUnit {
-public:
- struct StandaloneFixIt {
- std::pair<unsigned, unsigned> RemoveRange;
- std::pair<unsigned, unsigned> InsertFromRange;
- std::string CodeToInsert;
- bool BeforePreviousInsertions;
- };
-
- struct StandaloneDiagnostic {
- unsigned ID;
- DiagnosticsEngine::Level Level;
- std::string Message;
- std::string Filename;
- unsigned LocOffset;
- std::vector<std::pair<unsigned, unsigned>> Ranges;
- std::vector<StandaloneFixIt> FixIts;
- };
-
-private:
std::unique_ptr<LangOptions> LangOpts;
std::unique_ptr<CodeGenOptions> CodeGenOpts;
// FIXME: The documentation on \c LoadFrom* member functions states that the
@@ -129,7 +113,15 @@ class ASTUnit {
bool HadModuleLoaderFatalFailure = false;
bool StorePreamblesInMemory = false;
- struct ASTWriterData;
+ /// Utility struct for managing ASTWriter and its associated data streams.
+ struct ASTWriterData {
+ SmallString<128> Buffer;
+ llvm::BitstreamWriter Stream;
+ ASTWriter Writer;
+
+ ASTWriterData(ModuleCache &ModCache, const CodeGenOptions &CGOpts)
+ : Stream(Buffer), Writer(Stream, Buffer, ModCache, CGOpts, {}) {}
+ };
std::unique_ptr<ASTWriterData> WriterData;
FileSystemOptions FileSystemOpts;
@@ -271,11 +263,6 @@ class ASTUnit {
static void ConfigureDiags(IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
ASTUnit &AST, CaptureDiagsKind CaptureDiagnostics);
- void TranslateStoredDiagnostics(FileManager &FileMgr,
- SourceManager &SrcMan,
- const SmallVectorImpl<StandaloneDiagnostic> &Diags,
- SmallVectorImpl<StoredDiagnostic> &Out);
-
void clearFileLevelDecls();
public:
@@ -834,65 +821,24 @@ class ASTUnit {
bool IncludeBriefCommentsInCodeCompletion = false,
bool UserFilesAreVolatile = false);
- /// LoadFromCommandLine - Create an ASTUnit from a vector of command line
- /// arguments, which must specify exactly one source file.
- ///
- /// \param ArgBegin - The beginning of the argument vector.
- ///
- /// \param ArgEnd - The end of the argument vector.
- ///
- /// \param PCHContainerOps - The PCHContainerOperations to use for loading and
- /// creating modules.
- ///
- /// \param Diags - The diagnostics engine to use for reporting errors; its
- /// lifetime is expected to extend past that of the returned ASTUnit.
- ///
- /// \param ResourceFilesPath - The path to the compiler resource files.
- ///
- /// \param StorePreamblesInMemory - Whether to store PCH in memory. If false,
- /// PCH are stored in temporary files.
- ///
- /// \param PreambleStoragePath - The path to a directory, in which to create
- /// temporary PCH files. If empty, the default system temporary directory is
- /// used. This parameter is ignored if \p StorePreamblesInMemory is true.
- ///
- /// \param ModuleFormat - If provided, uses the specific module format.
- ///
- /// \param ErrAST - If non-null and parsing failed without any AST to return
- /// (e.g. because the PCH could not be loaded), this accepts the ASTUnit
- /// mainly to allow the caller to see the diagnostics.
- ///
- /// \param VFS - A llvm::vfs::FileSystem to be used for all file accesses.
- /// Note that preamble is saved to a temporary directory on a RealFileSystem,
- /// so in order for it to be loaded correctly, VFS should have access to
- /// it(i.e., be an overlay over RealFileSystem). RealFileSystem will be used
- /// if \p VFS is nullptr.
- ///
- // FIXME: Move OnlyLocalDecls, UseBumpAllocator to setters on the ASTUnit, we
- // shouldn't need to specify them at construction time.
- static std::unique_ptr<ASTUnit> LoadFromCommandLine(
+ friend std::unique_ptr<ASTUnit> CreateASTUnitFromCommandLine(
const char **ArgBegin, const char **ArgEnd,
std::shared_ptr<PCHContainerOperations> PCHContainerOps,
std::shared_ptr<DiagnosticOptions> DiagOpts,
IntrusiveRefCntPtr<DiagnosticsEngine> Diags, StringRef ResourceFilesPath,
- bool StorePreamblesInMemory = false,
- StringRef PreambleStoragePath = StringRef(), bool OnlyLocalDecls = false,
- CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None,
- ArrayRef<RemappedFile> RemappedFiles = {},
- bool RemappedFilesKeepOriginalName = true,
- unsigned PrecompilePreambleAfterNParses = 0,
- TranslationUnitKind TUKind = TU_Complete,
- bool CacheCodeCompletionResults = false,
- bool IncludeBriefCommentsInCodeCompletion = false,
- bool AllowPCHWithCompilerErrors = false,
- SkipFunctionBodiesScope SkipFunctionBodies =
- SkipFunctionBodiesScope::None,
- bool SingleFileParse = false, bool UserFilesAreVolatile = false,
- bool ForSerialization = false,
- bool RetainExcludedConditionalBlocks = false,
- std::optional<StringRef> ModuleFormat = std::nullopt,
- std::unique_ptr<ASTUnit> *ErrAST = nullptr,
- IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS = nullptr);
+ bool StorePreamblesInMemory, StringRef PreambleStoragePath,
+ bool OnlyLocalDecls, CaptureDiagsKind CaptureDiagnostics,
+ ArrayRef<ASTUnit::RemappedFile> RemappedFiles,
+ bool RemappedFilesKeepOriginalName,
+ unsigned PrecompilePreambleAfterNParses, TranslationUnitKind TUKind,
+ bool CacheCodeCompletionResults,
+ bool IncludeBriefCommentsInCodeCompletion,
+ bool AllowPCHWithCompilerErrors,
+ SkipFunctionBodiesScope SkipFunctionBodies, bool SingleFileParse,
+ bool UserFilesAreVolatile, bool ForSerialization,
+ bool RetainExcludedConditionalBlocks,
+ std::optional<StringRef> ModuleFormat, std::unique_ptr<ASTUnit> *ErrAST,
+ IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS);
/// Reparse the source files using the same command-line options that
/// were originally used to produce this translation unit.
@@ -963,6 +909,44 @@ class ASTUnit {
bool serialize(raw_ostream &OS);
};
+/// Diagnostic consumer that saves each diagnostic it is given.
+class FilterAndStoreDiagnosticConsumer : public DiagnosticConsumer {
+ SmallVectorImpl<StoredDiagnostic> *StoredDiags;
+ SmallVectorImpl<StandaloneDiagnostic> *StandaloneDiags;
+ bool CaptureNonErrorsFromIncludes = true;
+ const LangOptions *LangOpts = nullptr;
+ SourceManager *SourceMgr = nullptr;
+
+public:
+ FilterAndStoreDiagnosticConsumer(
+ SmallVectorImpl<StoredDiagnostic> *StoredDiags,
+ SmallVectorImpl<StandaloneDiagnostic> *StandaloneDiags,
+ bool CaptureNonErrorsFromIncludes);
+
+ void BeginSourceFile(const LangOptions &LangOpts,
+ const Preprocessor *PP = nullptr) override;
+
+ void HandleDiagnostic(DiagnosticsEngine::Level Level,
+ const Diagnostic &Info) override;
+};
+
+/// RAII object that optionally captures and filters diagnostics, if
+/// there is no diagnostic client to capture them already.
+class CaptureDroppedDiagnostics {
+ DiagnosticsEngine &Diags;
+ FilterAndStoreDiagnosticConsumer Client;
+ DiagnosticConsumer *PreviousClient = nullptr;
+ std::unique_ptr<DiagnosticConsumer> OwningPreviousClient;
+
+public:
+ CaptureDroppedDiagnostics(
+ CaptureDiagsKind CaptureDiagnostics, DiagnosticsEngine &Diags,
+ SmallVectorImpl<StoredDiagnostic> *StoredDiags,
+ SmallVectorImpl<StandaloneDiagnostic> *StandaloneDiags);
+
+ ~CaptureDroppedDiagnostics();
+};
+
} // namespace clang
#endif // LLVM_CLANG_FRONTEND_ASTUNIT_H
diff --git a/clang/include/clang/Frontend/ChainedDiagnosticConsumer.h b/clang/include/clang/Frontend/ChainedDiagnosticConsumer.h
index ca284560754fd..839b5e7fa0a3e 100644
--- a/clang/include/clang/Frontend/ChainedDiagnosticConsumer.h
+++ b/clang/include/clang/Frontend/ChainedDiagnosticConsumer.h
@@ -66,6 +66,6 @@ class ChainedDiagnosticConsumer : public DiagnosticConsumer {
}
};
-} // end namspace clang
+} // namespace clang
#endif
diff --git a/clang/include/clang/Frontend/CompilerInvocation.h b/clang/include/clang/Frontend/CompilerInvocation.h
index e147d2ba6087e..b48d930f44490 100644
--- a/clang/include/clang/Frontend/CompilerInvocation.h
+++ b/clang/include/clang/Frontend/CompilerInvocation.h
@@ -281,16 +281,6 @@ class CompilerInvocation : public CompilerInvocationBase {
DiagnosticsEngine &Diags,
const char *Argv0 = nullptr);
- /// Get the directory where the compiler headers
- /// reside, relative to the compiler binary (found by the passed in
- /// arguments).
- ///
- /// \param Argv0 - The program path (from argv[0]), for finding the builtin
- /// compiler path.
- /// \param MainAddr - The address of main (or some other function in the main
- /// executable), for finding the builtin compiler path.
- static std::string GetResourcesPath(const char *Argv0, void *MainAddr);
-
/// Populate \p Opts with the default set of pointer authentication-related
/// options given \p LangOpts and \p Triple.
///
diff --git a/clang/include/clang/Frontend/StandaloneDiagnostic.h b/clang/include/clang/Frontend/StandaloneDiagnostic.h
new file mode 100644
index 0000000000000..d010334a6006e
--- /dev/null
+++ b/clang/include/clang/Frontend/StandaloneDiagnostic.h
@@ -0,0 +1,86 @@
+//===--- StandaloneDiagnostic.h - Serializable Diagnostic -------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// A serializable diagnostic representation to retain diagnostics after their
+// SourceManager has been destroyed.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_FRONTEND_STANDALONEDIAGNOSTICS_H
+#define LLVM_CLANG_FRONTEND_STANDALONEDIAGNOSTICS_H
+
+#include "clang/Basic/DiagnosticIDs.h"
+#include "clang/Basic/DiagnosticOptions.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Basic/Specifiers.h"
+#include "llvm/ADT/StringExtras.h"
+#include <cassert>
+#include <string>
+#include <vector>
+
+namespace clang {
+
+/// Represents a StoredDiagnostic in a form that can be retained until after its
+/// SourceManager has been destroyed.
+///
+/// Source locations are stored as a combination of filename and offsets into
+/// that file.
+/// To report the diagnostic, it must first be translated back into a
+/// StoredDiagnostic with a new associated SourceManager.
+///
+struct StandaloneDiagnostic {
+ /// Represents a CharSourceRange within a StandaloneDiagnostic.
+ struct SourceOffsetRange {
+ SourceOffsetRange(CharSourceRange Range, const SourceManager &SrcMgr,
+ const LangOptions &LangOpts);
+
+ unsigned Begin = 0;
+ unsigned End = 0;
+ bool IsTokenRange = false;
+ };
+
+ /// Represents a FixItHint within a StandaloneDiagnostic.
+ struct StandaloneFixIt {
+ StandaloneFixIt(const SourceManager &SrcMgr, const LangOptions &LangOpts,
+ const FixItHint &FixIt);
+
+ SourceOffsetRange RemoveRange;
+ SourceOffsetRange InsertFromRange;
+ std::string CodeToInsert;
+ bool BeforePreviousInsertions;
+ };
+
+ StandaloneDiagnostic(const LangOptions &LangOpts,
+ const StoredDiagnostic &InDiag);
+
+ DiagnosticsEngine::Level Level;
+ SrcMgr::CharacteristicKind FileKind;
+ unsigned ID = 0;
+ unsigned FileOffset = 0;
+ std::string Message;
+ std::string Filename;
+ std::vector<SourceOffsetRange> Ranges;
+ std::vector<StandaloneFixIt> FixIts;
+};
+
+/// Translates \c StandaloneDiag into a StoredDiagnostic, associating it with
+/// the provided FileManager and SourceManager.
+///
+/// This allows the diagnostic to be emitted using the diagnostics engine, since
+/// StandaloneDiagnostics themselfs cannot be emitted directly.
+StoredDiagnostic translateStandaloneDiag(FileManager &FileMgr,
+ SourceManager &SrcMgr,
+ StandaloneDiagnostic &&StandaloneDiag);
+
+// Simple debug printing of StandaloneDiagnostic.
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const StoredDiagnostic &);
+
+} // namespace clang
+
+#endif // STANDALONEDIAGNOSTICS
diff --git a/clang/include/clang/Frontend/Utils.h b/clang/include/clang/Frontend/Utils.h
index ed2703c76f18d..1c561b47b5c47 100644
--- a/clang/include/clang/Frontend/Utils.h
+++ b/clang/include/clang/Frontend/Utils.h
@@ -192,51 +192,6 @@ IntrusiveRefCntPtr<ExternalSemaSource>
createChainedIncludesSource(CompilerInstance &CI,
IntrusiveRefCntPtr<ASTReader> &OutReader);
-/// Optional inputs to createInvocation.
-struct CreateInvocationOptions {
- /// Receives diagnostics encountered while parsing command-line flags.
- /// If not provided, these are printed to stderr.
- IntrusiveRefCntPtr<DiagnosticsEngine> Diags = nullptr;
- /// Used e.g. to probe for system headers locations.
- /// If not provided, the real filesystem is used.
- /// FIXME: the driver does perform some non-virtualized IO.
- IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS = nullptr;
- /// Whether to attempt to produce a non-null (possibly incorrect) invocation
- /// if any errors were encountered.
- /// By default, always return null on errors.
- bool RecoverOnError = false;
- /// Allow the driver to probe the filesystem for PCH files.
- /// This is used to replace -include with -include-pch in the cc1 args.
- /// FIXME: ProbePrecompiled=true is a poor, historical default.
- /// It misbehaves if the PCH file is from GCC, has the wrong version, etc.
- bool ProbePrecompiled = false;
- /// If set, the target is populated with the cc1 args produced by the driver.
- /// This may be populated even if createInvocation returns nullptr.
- std::vector<std::string> *CC1Args = nullptr;
-};
-
-/// Interpret clang arguments in preparation to parse a file.
-///
-/// This simulates a number of steps Clang takes when its driver is invoked:
-/// - choosing actions (e.g compile + link) to run
-/// - probing the system for settings like standard library locations
-/// - spawning a cc1 subprocess to compile code, with more explicit arguments
-/// - in the cc1 process, assembling those arguments into a CompilerInvocation
-/// which is used to configure the parser
-///
-/// This simulation is lossy, e.g. in some situations one driver run would
-/// result in multiple parses. (Multi-arch, CUDA, ...).
-/// This function tries to select a reasonable invocation that tools should use.
-///
-/// Args[0] should be the driver name, such as "clang" or "/usr/bin/g++".
-/// Absolute path is preferred - this affects searching for system headers.
-///
-/// May return nullptr if an invocation could not be determined.
-/// See CreateInvocationOptions::ShouldRecoverOnErrors to try harder!
-std::unique_ptr<CompilerInvocation>
-createInvocation(ArrayRef<const char *> Args,
- CreateInvocationOptions Opts = {});
-
} // namespace clang
#endif // LLVM_CLANG_FRONTEND_UTILS_H
diff --git a/clang/lib/CrossTU/CMakeLists.txt b/clang/lib/CrossTU/CMakeLists.txt
index 3349fc283925d..eef7a892701fb 100644
--- a/clang/lib/CrossTU/CMakeLists.txt
+++ b/clang/lib/CrossTU/CMakeLists.txt
@@ -9,6 +9,7 @@ add_clang_library(clangCrossTU
LINK_LIBS
clangAST
clangBasic
+ clangDriver
clangFrontend
clangIndex
)
diff --git a/clang/lib/CrossTU/CrossTranslationUnit.cpp b/clang/lib/CrossTU/CrossTranslationUnit.cpp
index 0287845a741ed..a3fc2cf6bfb3c 100644
--- a/clang/lib/CrossTU/CrossTranslationUnit.cpp
+++ b/clang/lib/CrossTU/CrossTranslationUnit.cpp
@@ -16,6 +16,7 @@
#include "clang/Basic/DiagnosticDriver.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/CrossTU/CrossTUDiagnostic.h"
+#include "clang/Driver/CreateASTUnitFromArgs.h"
#include "clang/Frontend/ASTUnit.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/TextDiagnosticPrinter.h"
@@ -619,7 +620,7 @@ CrossTranslationUnitContext::ASTLoader::loadFromSource(
auto Diags = llvm::makeIntrusiveRefCnt<DiagnosticsEngine>(DiagID, *DiagOpts,
DiagClient);
- return ASTUnit::LoadFromCommandLine(
+ return CreateASTUnitFromCommandLine(
CommandLineArgs.begin(), (CommandLineArgs.end()),
CI.getPCHContainerOperations(), DiagOpts, Diags,
CI.getHeaderSearchOpts().ResourceDir);
diff --git a/clang/lib/Driver/CMakeLists.txt b/clang/lib/Driver/CMakeLists.txt
index 8052659e9836b..d987111827597 100644
--- a/clang/lib/Driver/CMakeLists.txt
+++ b/clang/lib/Driver/CMakeLists.txt
@@ -17,6 +17,8 @@ endif()
add_clang_library(clangDriver
Action.cpp
Compilation.cpp
+ CreateASTUnitFromArgs.cpp
+ CreateInvocationFromArgs.cpp
Distro.cpp
Driver.cpp
Job.cpp
@@ -96,6 +98,8 @@ add_clang_library(clangDriver
LINK_LIBS
clangBasic
+ clangFrontend
+ clangSerialization
clangLex
clangOptions
${system_libs}
diff --git a/clang/lib/Driver/CreateASTUnitFromArgs.cpp b/clang/lib/Driver/CreateASTUnitFromArgs.cpp
new file mode 100644
index 0000000000000..5d94733d6bae9
--- /dev/null
+++ b/clang/lib/Driver/CreateASTUnitFromArgs.cpp
@@ -0,0 +1,168 @@
+//===--- CreateASTUnitFromArgs.h - Create an ASTUnit from Args ------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// Utility for creating an ASTUnit from a vector of command line arguments.
+//
+//===----------------------------------------------------------------------===//
+
+#include "clang/Driver/CreateASTUnitFromArgs.h"
+#include "clang/Driver/CreateInvocationFromArgs.h"
+#include "clang/Frontend/CompilerInvocation.h"
+#include "clang/Lex/PreprocessorOptions.h"
+#include "clang/Serialization/ModuleCache.h"
+#include "llvm/Support/CrashRecoveryContext.h"
+
+namespace clang {
+
+/// Create an ASTUnit from a vector of command line arguments, which must
+/// specify exactly one source file.
+///
+/// \param ArgBegin - The beginning of the argument vector.
+///
+/// \param ArgEnd - The end of the argument vector.
+///
+/// \param PCHContainerOps - The PCHContainerOperations to use for loading and
+/// creating modules.
+///
+/// \param Diags - The diagnostics engine to use for reporting errors; its
+/// lifetime is expected to extend past that of the returned ASTUnit.
+///
+/// \param ResourceFilesPath - The path to the compiler resource files.
+///
+/// \param StorePreamblesInMemory - Whether to store PCH in memory. If false,
+/// PCH are stored in temporary files.
+///
+/// \param PreambleStoragePath - The path to a directory, in which to create
+/// temporary PCH files. If empty, the default system temporary directory is
+/// used. This parameter is ignored if \p StorePreamblesInMemory is true.
+///
+/// \param ModuleFormat - If provided, uses the specific module format.
+///
+/// \param ErrAST - If non-null and parsing failed without any AST to return
+/// (e.g. because the PCH could not be loaded), this accepts the ASTUnit
+/// mainly to allow the caller to see the diagnostics.
+///
+/// \param VFS - A llvm::vfs::FileSystem to be used for all file accesses.
+/// Note that preamble is saved to a temporary directory on a RealFileSystem,
+/// so in order for it to be loaded correctly, VFS should have access to
+/// it(i.e., be an overlay over RealFileSystem). RealFileSystem will be used
+/// if \p VFS is nullptr.
+///
+// FIXME: Move OnlyLocalDecls, UseBumpAllocator to setters on the ASTUnit, we
+// shouldn't need to specify them at construction time.
+std::unique_ptr<ASTUnit> CreateASTUnitFromCommandLine(
+ const char **ArgBegin, const char **ArgEnd,
+ std::shared_ptr<PCHContainerOperations> PCHContainerOps,
+ std::shared_ptr<DiagnosticOptions> DiagOpts,
+ IntrusiveRefCntPtr<DiagnosticsEngine> Diags, StringRef ResourceFilesPath,
+ bool StorePreamblesInMemory, StringRef PreambleStoragePath,
+ bool OnlyLocalDecls, CaptureDiagsKind CaptureDiagnostics,
+ ArrayRef<ASTUnit::RemappedFile> RemappedFiles,
+ bool RemappedFilesKeepOriginalName, unsigned PrecompilePreambleAfterNParses,
+ TranslationUnitKind TUKind, bool CacheCodeCompletionResults,
+ bool IncludeBriefCommentsInCodeCompletion, bool AllowPCHWithCompilerErrors,
+ SkipFunctionBodiesScope SkipFunctionBodies, bool SingleFileParse,
+ bool UserFilesAreVolatile, bool ForSerialization,
+ bool RetainExcludedConditionalBlocks, std::optional<StringRef> ModuleFormat,
+ std::unique_ptr<ASTUnit> *ErrAST,
+ IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) {
+ assert(Diags.get() && "no DiagnosticsEngine was provided");
+
+ // If no VFS was provided, create one that tracks the physical file system.
+ // If '-working-directory' was passed as an argument, 'createInvocation' will
+ // set this as the current working directory of the VFS.
+ if (!VFS)
+ VFS = llvm::vfs::createPhysicalFileSystem();
+
+ SmallVector<StoredDiagnostic, 4> StoredDiagnostics;
+
+ std::shared_ptr<CompilerInvocation> CI;
+
+ {
+ CaptureDroppedDiagnostics Capture(CaptureDiagnostics, *Diags,
+ &StoredDiagnostics, nullptr);
+
+ CreateInvocationOptions CIOpts;
+ CIOpts.VFS = VFS;
+ CIOpts.Diags = Diags;
+ CIOpts.ProbePrecompiled = true; // FIXME: historical default. Needed?
+ CI = createInvocation(llvm::ArrayRef(ArgBegin, ArgEnd), std::move(CIOpts));
+ if (!CI)
+ return nullptr;
+ }
+
+ // Override any files that need remapping
+ for (const auto &RemappedFile : RemappedFiles) {
+ CI->getPreprocessorOpts().addRemappedFile(RemappedFile.first,
+ RemappedFile.second);
+ }
+ PreprocessorOptions &PPOpts = CI->getPreprocessorOpts();
+ PPOpts.RemappedFilesKeepOriginalName = RemappedFilesKeepOriginalName;
+ PPOpts.AllowPCHWithCompilerErrors = AllowPCHWithCompilerErrors;
+ PPOpts.SingleFileParseMode = SingleFileParse;
+ PPOpts.RetainExcludedConditionalBlocks = RetainExcludedConditionalBlocks;
+
+ // Override the resources path.
+ CI->getHeaderSearchOpts().ResourceDir = std::string(ResourceFilesPath);
+
+ CI->getFrontendOpts().SkipFunctionBodies =
+ SkipFunctionBodies == SkipFunctionBodiesScope::PreambleAndMainFile;
+
+ if (ModuleFormat)
+ CI->getHeaderSearchOpts().ModuleFormat = std::string(*ModuleFormat);
+
+ // Create the AST unit.
+ std::unique_ptr<ASTUnit> AST;
+ AST.reset(new ASTUnit(false));
+ AST->NumStoredDiagnosticsFromDriver = StoredDiagnostics.size();
+ AST->StoredDiagnostics.swap(StoredDiagnostics);
+ ASTUnit::ConfigureDiags(Diags, *AST, CaptureDiagnostics);
+ AST->DiagOpts = DiagOpts;
+ AST->Diagnostics = Diags;
+ AST->FileSystemOpts = CI->getFileSystemOpts();
+ AST->CodeGenOpts = std::make_unique<CodeGenOptions>(CI->getCodeGenOpts());
+ VFS = createVFSFromCompilerInvocation(*CI, *Diags, VFS);
+ AST->FileMgr =
+ llvm::makeIntrusiveRefCnt<FileManager>(AST->FileSystemOpts, VFS);
+ AST->StorePreamblesInMemory = StorePreamblesInMemory;
+ AST->PreambleStoragePath = PreambleStoragePath;
+ AST->ModCache = createCrossProcessModuleCache();
+ AST->OnlyLocalDecls = OnlyLocalDecls;
+ AST->CaptureDiagnostics = CaptureDiagnostics;
+ AST->TUKind = TUKind;
+ AST->ShouldCacheCodeCompletionResults = CacheCodeCompletionResults;
+ AST->IncludeBriefCommentsInCodeCompletion =
+ IncludeBriefCommentsInCodeCompletion;
+ AST->UserFilesAreVolatile = UserFilesAreVolatile;
+ AST->Invocation = CI;
+ AST->SkipFunctionBodies = SkipFunctionBodies;
+ if (ForSerialization)
+ AST->WriterData.reset(
+ new ASTUnit::ASTWriterData(*AST->ModCache, *AST->CodeGenOpts));
+ // Zero out now to ease cleanup during crash recovery.
+ CI = nullptr;
+ Diags = nullptr;
+
+ // Recover resources if we crash before exiting this method.
+ llvm::CrashRecoveryContextCleanupRegistrar<ASTUnit> ASTUnitCleanup(AST.get());
+
+ if (AST->LoadFromCompilerInvocation(std::move(PCHContainerOps),
+ PrecompilePreambleAfterNParses, VFS)) {
+ // Some error occurred, if caller wants to examine diagnostics, pass it the
+ // ASTUnit.
+ if (ErrAST) {
+ AST->StoredDiagnostics.swap(AST->FailedParseDiagnostics);
+ ErrAST->swap(AST);
+ }
+ return nullptr;
+ }
+
+ return AST;
+}
+
+} // namespace clang
diff --git a/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp b/clang/lib/Driver/CreateInvocationFromArgs.cpp
similarity index 91%
rename from clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
rename to clang/lib/Driver/CreateInvocationFromArgs.cpp
index 73b81ed906808..5a1eba71edef5 100644
--- a/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
+++ b/clang/lib/Driver/CreateInvocationFromArgs.cpp
@@ -1,4 +1,4 @@
-//===--- CreateInvocationFromCommandLine.cpp - CompilerInvocation from Args ==//
+//===--- CreateInvocationFromArgs.h - CompilerInvocation from Args --------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,26 +10,26 @@
//
//===----------------------------------------------------------------------===//
+#include "clang/Driver/CreateInvocationFromArgs.h"
+#include "clang/Basic/DiagnosticFrontend.h"
#include "clang/Basic/DiagnosticOptions.h"
-#include "clang/Driver/Action.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.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"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/TargetParser/Host.h"
-using namespace clang;
+
using namespace llvm::opt;
+namespace clang {
+
std::unique_ptr<CompilerInvocation>
-clang::createInvocation(ArrayRef<const char *> ArgList,
- CreateInvocationOptions Opts) {
+createInvocation(ArrayRef<const char *> ArgList, CreateInvocationOptions Opts) {
assert(!ArgList.empty());
std::optional<DiagnosticOptions> LocalDiagOpts;
IntrusiveRefCntPtr<DiagnosticsEngine> Diags;
@@ -78,7 +78,7 @@ clang::createInvocation(ArrayRef<const char *> ArgList,
const driver::JobList &Jobs = C->getJobs();
bool OffloadCompilation = false;
if (Jobs.size() > 1) {
- for (auto &A : C->getActions()){
+ for (auto &A : C->getActions()) {
// On MacOSX real actions may end up being wrapped in BindArchAction
if (isa<driver::BindArchAction>(A))
A = *A->input_begin();
@@ -114,3 +114,5 @@ clang::createInvocation(ArrayRef<const char *> ArgList,
return nullptr;
return CI;
}
+
+} // namespace clang
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index d6c2aa8027ba3..092b9197ef472 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -123,7 +123,6 @@ template <typename F> static bool usesInput(const ArgList &Args, F &&Fn) {
});
}
-// static
std::string Driver::GetResourcesPath(StringRef BinaryPath) {
// Since the resource directory is embedded in the module hash, it's important
// that all places that need it call this function, so that they get the
@@ -157,6 +156,13 @@ std::string Driver::GetResourcesPath(StringRef BinaryPath) {
return std::string(P);
}
+std::string Driver::GetResourcesPathForInvocation(const char *Argv0,
+ void *MainAddr) {
+ std::string ClangExecutable =
+ llvm::sys::fs::getMainExecutable(Argv0, MainAddr);
+ return GetResourcesPath(ClangExecutable);
+}
+
CUIDOptions::CUIDOptions(llvm::opt::DerivedArgList &Args, const Driver &D)
: UseCUID(Kind::Hash) {
if (Arg *A = Args.getLastArg(options::OPT_fuse_cuid_EQ)) {
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index 6cc7094846155..9b94c443dea33 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -44,6 +44,7 @@
#include "clang/Frontend/FrontendOptions.h"
#include "clang/Frontend/MultiplexConsumer.h"
#include "clang/Frontend/PrecompiledPreamble.h"
+#include "clang/Frontend/StandaloneDiagnostic.h"
#include "clang/Frontend/Utils.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/HeaderSearchOptions.h"
@@ -210,15 +211,6 @@ getBufferForFileHandlingRemapping(const CompilerInvocation &Invocation,
return llvm::MemoryBuffer::getMemBufferCopy(Buffer->getBuffer(), FilePath);
}
-struct ASTUnit::ASTWriterData {
- SmallString<128> Buffer;
- llvm::BitstreamWriter Stream;
- ASTWriter Writer;
-
- ASTWriterData(ModuleCache &ModCache, const CodeGenOptions &CGOpts)
- : Stream(Buffer), Writer(Stream, Buffer, ModCache, CGOpts, {}) {}
-};
-
void ASTUnit::clearFileLevelDecls() {
FileDecls.clear();
}
@@ -581,73 +573,24 @@ class ASTInfoCollector : public ASTReaderListener {
Counter = NewCounter;
}
};
+} // anonymous namespace
-/// Diagnostic consumer that saves each diagnostic it is given.
-class FilterAndStoreDiagnosticConsumer : public DiagnosticConsumer {
- SmallVectorImpl<StoredDiagnostic> *StoredDiags;
- SmallVectorImpl<ASTUnit::StandaloneDiagnostic> *StandaloneDiags;
- bool CaptureNonErrorsFromIncludes = true;
- const LangOptions *LangOpts = nullptr;
- SourceManager *SourceMgr = nullptr;
-
-public:
- FilterAndStoreDiagnosticConsumer(
- SmallVectorImpl<StoredDiagnostic> *StoredDiags,
- SmallVectorImpl<ASTUnit::StandaloneDiagnostic> *StandaloneDiags,
- bool CaptureNonErrorsFromIncludes)
- : StoredDiags(StoredDiags), StandaloneDiags(StandaloneDiags),
- CaptureNonErrorsFromIncludes(CaptureNonErrorsFromIncludes) {
- assert((StoredDiags || StandaloneDiags) &&
- "No output collections were passed to StoredDiagnosticConsumer.");
- }
-
- void BeginSourceFile(const LangOptions &LangOpts,
- const Preprocessor *PP = nullptr) override {
- this->LangOpts = &LangOpts;
- if (PP)
- SourceMgr = &PP->getSourceManager();
- }
-
- void HandleDiagnostic(DiagnosticsEngine::Level Level,
- const Diagnostic &Info) override;
-};
-
-/// RAII object that optionally captures and filters diagnostics, if
-/// there is no diagnostic client to capture them already.
-class CaptureDroppedDiagnostics {
- DiagnosticsEngine &Diags;
- FilterAndStoreDiagnosticConsumer Client;
- DiagnosticConsumer *PreviousClient = nullptr;
- std::unique_ptr<DiagnosticConsumer> OwningPreviousClient;
-
-public:
- CaptureDroppedDiagnostics(
- CaptureDiagsKind CaptureDiagnostics, DiagnosticsEngine &Diags,
- SmallVectorImpl<StoredDiagnostic> *StoredDiags,
- SmallVectorImpl<ASTUnit::StandaloneDiagnostic> *StandaloneDiags)
- : Diags(Diags),
- Client(StoredDiags, StandaloneDiags,
- CaptureDiagnostics !=
- CaptureDiagsKind::AllWithoutNonErrorsFromIncludes) {
- if (CaptureDiagnostics != CaptureDiagsKind::None ||
- Diags.getClient() == nullptr) {
- OwningPreviousClient = Diags.takeClient();
- PreviousClient = Diags.getClient();
- Diags.setClient(&Client, false);
- }
- }
-
- ~CaptureDroppedDiagnostics() {
- if (Diags.getClient() == &Client)
- Diags.setClient(PreviousClient, !!OwningPreviousClient.release());
- }
-};
-
-} // namespace
+FilterAndStoreDiagnosticConsumer::FilterAndStoreDiagnosticConsumer(
+ SmallVectorImpl<StoredDiagnostic> *StoredDiags,
+ SmallVectorImpl<StandaloneDiagnostic> *StandaloneDiags,
+ bool CaptureNonErrorsFromIncludes)
+ : StoredDiags(StoredDiags), StandaloneDiags(StandaloneDiags),
+ CaptureNonErrorsFromIncludes(CaptureNonErrorsFromIncludes) {
+ assert((StoredDiags || StandaloneDiags) &&
+ "No output collections were passed to StoredDiagnosticConsumer.");
+}
-static ASTUnit::StandaloneDiagnostic
-makeStandaloneDiagnostic(const LangOptions &LangOpts,
- const StoredDiagnostic &InDiag);
+void FilterAndStoreDiagnosticConsumer::BeginSourceFile(
+ const LangOptions &LangOpts, const Preprocessor *PP) {
+ this->LangOpts = &LangOpts;
+ if (PP)
+ SourceMgr = &PP->getSourceManager();
+}
static bool isInMainFile(const clang::Diagnostic &D) {
if (!D.hasSourceManager() || !D.getLocation().isValid())
@@ -683,12 +626,32 @@ void FilterAndStoreDiagnosticConsumer::HandleDiagnostic(
StoredDiag.emplace(Level, Info);
ResultDiag = &*StoredDiag;
}
- StandaloneDiags->push_back(
- makeStandaloneDiagnostic(*LangOpts, *ResultDiag));
+ StandaloneDiags->emplace_back(*LangOpts, *ResultDiag);
}
}
}
+CaptureDroppedDiagnostics::CaptureDroppedDiagnostics(
+ CaptureDiagsKind CaptureDiagnostics, DiagnosticsEngine &Diags,
+ SmallVectorImpl<StoredDiagnostic> *StoredDiags,
+ SmallVectorImpl<StandaloneDiagnostic> *StandaloneDiags)
+ : Diags(Diags),
+ Client(StoredDiags, StandaloneDiags,
+ CaptureDiagnostics !=
+ CaptureDiagsKind::AllWithoutNonErrorsFromIncludes) {
+ if (CaptureDiagnostics != CaptureDiagsKind::None ||
+ Diags.getClient() == nullptr) {
+ OwningPreviousClient = Diags.takeClient();
+ PreviousClient = Diags.getClient();
+ Diags.setClient(&Client, false);
+ }
+}
+
+CaptureDroppedDiagnostics::~CaptureDroppedDiagnostics() {
+ if (Diags.getClient() == &Client)
+ Diags.setClient(PreviousClient, !!OwningPreviousClient.release());
+}
+
IntrusiveRefCntPtr<ASTReader> ASTUnit::getASTReader() const {
return Reader;
}
@@ -1110,7 +1073,7 @@ class ASTUnitPreambleCallbacks : public PreambleCallbacks {
unsigned Hash = 0;
std::vector<Decl *> TopLevelDecls;
std::vector<LocalDeclID> TopLevelDeclIDs;
- llvm::SmallVector<ASTUnit::StandaloneDiagnostic, 4> PreambleDiags;
+ llvm::SmallVector<StandaloneDiagnostic, 4> PreambleDiags;
};
} // namespace
@@ -1259,10 +1222,15 @@ bool ASTUnit::Parse(std::shared_ptr<PCHContainerOperations> PCHContainerOps,
if (!Act->BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0]))
return true;
- if (SavedMainFileBuffer)
- TranslateStoredDiagnostics(getFileManager(), getSourceManager(),
- PreambleDiagnostics, StoredDiagnostics);
- else
+ if (SavedMainFileBuffer) {
+ StoredDiagnostics.reserve(PreambleDiagnostics.size());
+ llvm::transform(
+ std::move(PreambleDiagnostics), std::back_inserter(StoredDiagnostics),
+ [&](auto &&StandaloneDiag) {
+ return translateStandaloneDiag(getFileManager(), getSourceManager(),
+ std::move(StandaloneDiag));
+ });
+ } else
PreambleSrcLocCache.clear();
if (llvm::Error Err = Act->Execute()) {
@@ -1281,51 +1249,6 @@ bool ASTUnit::Parse(std::shared_ptr<PCHContainerOperations> PCHContainerOps,
return false;
}
-static std::pair<unsigned, unsigned>
-makeStandaloneRange(CharSourceRange Range, const SourceManager &SM,
- const LangOptions &LangOpts) {
- CharSourceRange FileRange = Lexer::makeFileCharRange(Range, SM, LangOpts);
- unsigned Offset = SM.getFileOffset(FileRange.getBegin());
- unsigned EndOffset = SM.getFileOffset(FileRange.getEnd());
- return std::make_pair(Offset, EndOffset);
-}
-
-static ASTUnit::StandaloneFixIt makeStandaloneFixIt(const SourceManager &SM,
- const LangOptions &LangOpts,
- const FixItHint &InFix) {
- ASTUnit::StandaloneFixIt OutFix;
- OutFix.RemoveRange = makeStandaloneRange(InFix.RemoveRange, SM, LangOpts);
- OutFix.InsertFromRange = makeStandaloneRange(InFix.InsertFromRange, SM,
- LangOpts);
- OutFix.CodeToInsert = InFix.CodeToInsert;
- OutFix.BeforePreviousInsertions = InFix.BeforePreviousInsertions;
- return OutFix;
-}
-
-static ASTUnit::StandaloneDiagnostic
-makeStandaloneDiagnostic(const LangOptions &LangOpts,
- const StoredDiagnostic &InDiag) {
- ASTUnit::StandaloneDiagnostic OutDiag;
- OutDiag.ID = InDiag.getID();
- OutDiag.Level = InDiag.getLevel();
- OutDiag.Message = std::string(InDiag.getMessage());
- OutDiag.LocOffset = 0;
- if (InDiag.getLocation().isInvalid())
- return OutDiag;
- const SourceManager &SM = InDiag.getLocation().getManager();
- SourceLocation FileLoc = SM.getFileLoc(InDiag.getLocation());
- OutDiag.Filename = std::string(SM.getFilename(FileLoc));
- if (OutDiag.Filename.empty())
- return OutDiag;
- OutDiag.LocOffset = SM.getFileOffset(FileLoc);
- for (const auto &Range : InDiag.getRanges())
- OutDiag.Ranges.push_back(makeStandaloneRange(Range, SM, LangOpts));
- for (const auto &FixIt : InDiag.getFixIts())
- OutDiag.FixIts.push_back(makeStandaloneFixIt(SM, LangOpts, FixIt));
-
- return OutDiag;
-}
-
/// Attempt to build or re-use a precompiled preamble when (re-)parsing
/// the source file.
///
@@ -1780,116 +1703,6 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromCompilerInvocation(
return AST;
}
-std::unique_ptr<ASTUnit> ASTUnit::LoadFromCommandLine(
- const char **ArgBegin, const char **ArgEnd,
- std::shared_ptr<PCHContainerOperations> PCHContainerOps,
- std::shared_ptr<DiagnosticOptions> DiagOpts,
- IntrusiveRefCntPtr<DiagnosticsEngine> Diags, StringRef ResourceFilesPath,
- bool StorePreamblesInMemory, StringRef PreambleStoragePath,
- bool OnlyLocalDecls, CaptureDiagsKind CaptureDiagnostics,
- ArrayRef<RemappedFile> RemappedFiles, bool RemappedFilesKeepOriginalName,
- unsigned PrecompilePreambleAfterNParses, TranslationUnitKind TUKind,
- bool CacheCodeCompletionResults, bool IncludeBriefCommentsInCodeCompletion,
- bool AllowPCHWithCompilerErrors, SkipFunctionBodiesScope SkipFunctionBodies,
- bool SingleFileParse, bool UserFilesAreVolatile, bool ForSerialization,
- bool RetainExcludedConditionalBlocks, std::optional<StringRef> ModuleFormat,
- std::unique_ptr<ASTUnit> *ErrAST,
- IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) {
- assert(Diags.get() && "no DiagnosticsEngine was provided");
-
- // If no VFS was provided, create one that tracks the physical file system.
- // If '-working-directory' was passed as an argument, 'createInvocation' will
- // set this as the current working directory of the VFS.
- if (!VFS)
- VFS = llvm::vfs::createPhysicalFileSystem();
-
- SmallVector<StoredDiagnostic, 4> StoredDiagnostics;
-
- std::shared_ptr<CompilerInvocation> CI;
-
- {
- CaptureDroppedDiagnostics Capture(CaptureDiagnostics, *Diags,
- &StoredDiagnostics, nullptr);
-
- CreateInvocationOptions CIOpts;
- CIOpts.VFS = VFS;
- CIOpts.Diags = Diags;
- CIOpts.ProbePrecompiled = true; // FIXME: historical default. Needed?
- CI = createInvocation(llvm::ArrayRef(ArgBegin, ArgEnd), std::move(CIOpts));
- if (!CI)
- return nullptr;
- }
-
- // Override any files that need remapping
- for (const auto &RemappedFile : RemappedFiles) {
- CI->getPreprocessorOpts().addRemappedFile(RemappedFile.first,
- RemappedFile.second);
- }
- PreprocessorOptions &PPOpts = CI->getPreprocessorOpts();
- PPOpts.RemappedFilesKeepOriginalName = RemappedFilesKeepOriginalName;
- PPOpts.AllowPCHWithCompilerErrors = AllowPCHWithCompilerErrors;
- PPOpts.SingleFileParseMode = SingleFileParse;
- PPOpts.RetainExcludedConditionalBlocks = RetainExcludedConditionalBlocks;
-
- // Override the resources path.
- CI->getHeaderSearchOpts().ResourceDir = std::string(ResourceFilesPath);
-
- CI->getFrontendOpts().SkipFunctionBodies =
- SkipFunctionBodies == SkipFunctionBodiesScope::PreambleAndMainFile;
-
- if (ModuleFormat)
- CI->getHeaderSearchOpts().ModuleFormat = std::string(*ModuleFormat);
-
- // Create the AST unit.
- std::unique_ptr<ASTUnit> AST;
- AST.reset(new ASTUnit(false));
- AST->NumStoredDiagnosticsFromDriver = StoredDiagnostics.size();
- AST->StoredDiagnostics.swap(StoredDiagnostics);
- ConfigureDiags(Diags, *AST, CaptureDiagnostics);
- AST->DiagOpts = DiagOpts;
- AST->Diagnostics = Diags;
- AST->FileSystemOpts = CI->getFileSystemOpts();
- AST->CodeGenOpts = std::make_unique<CodeGenOptions>(CI->getCodeGenOpts());
- VFS = createVFSFromCompilerInvocation(*CI, *Diags, VFS);
- AST->FileMgr =
- llvm::makeIntrusiveRefCnt<FileManager>(AST->FileSystemOpts, VFS);
- AST->StorePreamblesInMemory = StorePreamblesInMemory;
- AST->PreambleStoragePath = PreambleStoragePath;
- AST->ModCache = createCrossProcessModuleCache();
- AST->OnlyLocalDecls = OnlyLocalDecls;
- AST->CaptureDiagnostics = CaptureDiagnostics;
- AST->TUKind = TUKind;
- AST->ShouldCacheCodeCompletionResults = CacheCodeCompletionResults;
- AST->IncludeBriefCommentsInCodeCompletion
- = IncludeBriefCommentsInCodeCompletion;
- AST->UserFilesAreVolatile = UserFilesAreVolatile;
- AST->Invocation = CI;
- AST->SkipFunctionBodies = SkipFunctionBodies;
- if (ForSerialization)
- AST->WriterData.reset(new ASTWriterData(*AST->ModCache, *AST->CodeGenOpts));
- // Zero out now to ease cleanup during crash recovery.
- CI = nullptr;
- Diags = nullptr;
-
- // Recover resources if we crash before exiting this method.
- llvm::CrashRecoveryContextCleanupRegistrar<ASTUnit>
- ASTUnitCleanup(AST.get());
-
- if (AST->LoadFromCompilerInvocation(std::move(PCHContainerOps),
- PrecompilePreambleAfterNParses,
- VFS)) {
- // Some error occurred, if caller wants to examine diagnostics, pass it the
- // ASTUnit.
- if (ErrAST) {
- AST->StoredDiagnostics.swap(AST->FailedParseDiagnostics);
- ErrAST->swap(AST);
- }
- return nullptr;
- }
-
- return AST;
-}
-
bool ASTUnit::Reparse(std::shared_ptr<PCHContainerOperations> PCHContainerOps,
ArrayRef<RemappedFile> RemappedFiles,
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) {
@@ -2408,65 +2221,6 @@ bool ASTUnit::serialize(raw_ostream &OS) {
return serializeUnit(Writer, Buffer, getSema(), OS);
}
-void ASTUnit::TranslateStoredDiagnostics(
- FileManager &FileMgr,
- SourceManager &SrcMgr,
- const SmallVectorImpl<StandaloneDiagnostic> &Diags,
- SmallVectorImpl<StoredDiagnostic> &Out) {
- // Map the standalone diagnostic into the new source manager. We also need to
- // remap all the locations to the new view. This includes the diag location,
- // any associated source ranges, and the source ranges of associated fix-its.
- // FIXME: There should be a cleaner way to do this.
- SmallVector<StoredDiagnostic, 4> Result;
- Result.reserve(Diags.size());
-
- for (const auto &SD : Diags) {
- // Rebuild the StoredDiagnostic.
- if (SD.Filename.empty())
- continue;
- auto FE = FileMgr.getOptionalFileRef(SD.Filename);
- if (!FE)
- continue;
- SourceLocation FileLoc;
- auto ItFileID = PreambleSrcLocCache.find(SD.Filename);
- if (ItFileID == PreambleSrcLocCache.end()) {
- FileID FID = SrcMgr.translateFile(*FE);
- FileLoc = SrcMgr.getLocForStartOfFile(FID);
- PreambleSrcLocCache[SD.Filename] = FileLoc;
- } else {
- FileLoc = ItFileID->getValue();
- }
-
- if (FileLoc.isInvalid())
- continue;
- SourceLocation L = FileLoc.getLocWithOffset(SD.LocOffset);
- FullSourceLoc Loc(L, SrcMgr);
-
- SmallVector<CharSourceRange, 4> Ranges;
- Ranges.reserve(SD.Ranges.size());
- for (const auto &Range : SD.Ranges) {
- SourceLocation BL = FileLoc.getLocWithOffset(Range.first);
- SourceLocation EL = FileLoc.getLocWithOffset(Range.second);
- Ranges.push_back(CharSourceRange::getCharRange(BL, EL));
- }
-
- SmallVector<FixItHint, 2> FixIts;
- FixIts.reserve(SD.FixIts.size());
- for (const auto &FixIt : SD.FixIts) {
- FixIts.push_back(FixItHint());
- FixItHint &FH = FixIts.back();
- FH.CodeToInsert = FixIt.CodeToInsert;
- SourceLocation BL = FileLoc.getLocWithOffset(FixIt.RemoveRange.first);
- SourceLocation EL = FileLoc.getLocWithOffset(FixIt.RemoveRange.second);
- FH.RemoveRange = CharSourceRange::getCharRange(BL, EL);
- }
-
- Result.push_back(StoredDiagnostic(SD.Level, SD.ID,
- SD.Message, Loc, Ranges, FixIts));
- }
- Result.swap(Out);
-}
-
void ASTUnit::addFileLevelDecl(Decl *D) {
assert(D);
diff --git a/clang/lib/Frontend/CMakeLists.txt b/clang/lib/Frontend/CMakeLists.txt
index dac9e0d26f393..634f239933605 100644
--- a/clang/lib/Frontend/CMakeLists.txt
+++ b/clang/lib/Frontend/CMakeLists.txt
@@ -17,7 +17,6 @@ add_clang_library(clangFrontend
ChainedIncludesSource.cpp
CompilerInstance.cpp
CompilerInvocation.cpp
- CreateInvocationFromCommandLine.cpp
DependencyFile.cpp
DependencyGraph.cpp
DiagnosticRenderer.cpp
@@ -36,6 +35,7 @@ add_clang_library(clangFrontend
SARIFDiagnosticPrinter.cpp
SerializedDiagnosticPrinter.cpp
SerializedDiagnosticReader.cpp
+ StandaloneDiagnostic.cpp
TestModuleFileExtension.cpp
TextDiagnostic.cpp
TextDiagnosticBuffer.cpp
@@ -51,7 +51,6 @@ add_clang_library(clangFrontend
clangAPINotes
clangAST
clangBasic
- clangDriver
clangOptions
clangEdit
clangLex
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index abaa1d587b16a..40ead453e6f99 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3276,13 +3276,6 @@ static bool ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
return Diags.getNumErrors() == NumErrorsBefore;
}
-std::string CompilerInvocation::GetResourcesPath(const char *Argv0,
- void *MainAddr) {
- std::string ClangExecutable =
- llvm::sys::fs::getMainExecutable(Argv0, MainAddr);
- return Driver::GetResourcesPath(ClangExecutable);
-}
-
static void GenerateHeaderSearchArgs(const HeaderSearchOptions &Opts,
ArgumentConsumer Consumer) {
const HeaderSearchOptions *HeaderSearchOpts = &Opts;
diff --git a/clang/lib/Frontend/StandaloneDiagnostic.cpp b/clang/lib/Frontend/StandaloneDiagnostic.cpp
new file mode 100644
index 0000000000000..6305c4a634cf2
--- /dev/null
+++ b/clang/lib/Frontend/StandaloneDiagnostic.cpp
@@ -0,0 +1,102 @@
+//===--- StandaloneDiagnostic.h - Serializable Diagnostic ------------- ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "clang/Frontend/StandaloneDiagnostic.h"
+#include "clang/Lex/Lexer.h"
+
+namespace clang {
+
+StandaloneDiagnostic::SourceOffsetRange::SourceOffsetRange(
+ CharSourceRange Range, const SourceManager &SrcMgr,
+ const LangOptions &LangOpts)
+ : IsTokenRange(Range.isTokenRange()) {
+ const auto FileRange = Lexer::makeFileCharRange(Range, SrcMgr, LangOpts);
+ Begin = SrcMgr.getFileOffset(FileRange.getBegin());
+ End = SrcMgr.getFileOffset(FileRange.getEnd());
+}
+
+StandaloneDiagnostic::StandaloneFixIt::StandaloneFixIt(
+ const SourceManager &SrcMgr, const LangOptions &LangOpts,
+ const FixItHint &FixIt)
+ : RemoveRange(FixIt.RemoveRange, SrcMgr, LangOpts),
+ InsertFromRange(FixIt.InsertFromRange, SrcMgr, LangOpts),
+ CodeToInsert(FixIt.CodeToInsert),
+ BeforePreviousInsertions(FixIt.BeforePreviousInsertions) {}
+
+StandaloneDiagnostic::StandaloneDiagnostic(const LangOptions &LangOpts,
+ const StoredDiagnostic &InDiag)
+ : Level(InDiag.getLevel()), ID(InDiag.getID()),
+ Message(InDiag.getMessage()) {
+ const FullSourceLoc &FullLoc = InDiag.getLocation();
+ // This is not an invalid diagnostic; invalid SourceLocations are used to
+ // represent diagnostics without a specific SourceLocation.
+ if (FullLoc.isInvalid())
+ return;
+
+ const auto &SrcMgr = FullLoc.getManager();
+ FileKind = SrcMgr.getFileCharacteristic(static_cast<SourceLocation>(FullLoc));
+ const auto FileLoc = SrcMgr.getFileLoc(static_cast<SourceLocation>(FullLoc));
+ FileOffset = SrcMgr.getFileOffset(FileLoc);
+ Filename = SrcMgr.getFilename(FileLoc);
+ assert(!Filename.empty() && "diagnostic with location has no source file?");
+
+ Ranges.reserve(InDiag.getRanges().size());
+ for (const auto &Range : InDiag.getRanges())
+ Ranges.emplace_back(Range, SrcMgr, LangOpts);
+
+ FixIts.reserve(InDiag.getFixIts().size());
+ for (const auto &FixIt : InDiag.getFixIts())
+ FixIts.emplace_back(SrcMgr, LangOpts, FixIt);
+}
+
+StoredDiagnostic
+translateStandaloneDiag(FileManager &FileMgr, SourceManager &SrcMgr,
+ StandaloneDiagnostic &&StandaloneDiag) {
+ const auto FileRef = FileMgr.getOptionalFileRef(StandaloneDiag.Filename);
+ if (!FileRef)
+ return StoredDiagnostic(StandaloneDiag.Level, StandaloneDiag.ID,
+ std::move(StandaloneDiag.Message));
+
+ const auto FileID =
+ SrcMgr.getOrCreateFileID(*FileRef, StandaloneDiag.FileKind);
+ const auto FileLoc = SrcMgr.getLocForStartOfFile(FileID);
+ assert(FileLoc.isValid() && "StandaloneDiagnostic should only use FilePath "
+ "for encoding a valid source location.");
+ const auto DiagLoc = FileLoc.getLocWithOffset(StandaloneDiag.FileOffset);
+ const FullSourceLoc Loc(DiagLoc, SrcMgr);
+
+ auto ConvertOffsetRange =
+ [&](const StandaloneDiagnostic::SourceOffsetRange &Range) {
+ return CharSourceRange(
+ SourceRange(FileLoc.getLocWithOffset(Range.Begin),
+ FileLoc.getLocWithOffset(Range.End)),
+ Range.IsTokenRange);
+ };
+
+ SmallVector<CharSourceRange, 0> TranslatedRanges;
+ TranslatedRanges.reserve(StandaloneDiag.Ranges.size());
+ transform(StandaloneDiag.Ranges, std::back_inserter(TranslatedRanges),
+ ConvertOffsetRange);
+
+ SmallVector<FixItHint, 0> TranslatedFixIts;
+ TranslatedFixIts.reserve(StandaloneDiag.FixIts.size());
+ for (const auto &FixIt : StandaloneDiag.FixIts) {
+ FixItHint TranslatedFixIt;
+ TranslatedFixIt.CodeToInsert = std::string(FixIt.CodeToInsert);
+ TranslatedFixIt.RemoveRange = ConvertOffsetRange(FixIt.RemoveRange);
+ TranslatedFixIt.InsertFromRange = ConvertOffsetRange(FixIt.InsertFromRange);
+ TranslatedFixIt.BeforePreviousInsertions = FixIt.BeforePreviousInsertions;
+ TranslatedFixIts.push_back(std::move(TranslatedFixIt));
+ }
+
+ return StoredDiagnostic(StandaloneDiag.Level, StandaloneDiag.ID,
+ StandaloneDiag.Message, Loc, TranslatedRanges,
+ TranslatedFixIts);
+}
+
+} // namespace clang
diff --git a/clang/lib/Interpreter/Interpreter.cpp b/clang/lib/Interpreter/Interpreter.cpp
index 966333b52ccbc..6744eeff79246 100644
--- a/clang/lib/Interpreter/Interpreter.cpp
+++ b/clang/lib/Interpreter/Interpreter.cpp
@@ -105,7 +105,7 @@ CreateCI(const llvm::opt::ArgStringList &Argv) {
if (Clang->getHeaderSearchOpts().UseBuiltinIncludes &&
Clang->getHeaderSearchOpts().ResourceDir.empty())
Clang->getHeaderSearchOpts().ResourceDir =
- CompilerInvocation::GetResourcesPath(Argv[0], nullptr);
+ driver::Driver::GetResourcesPathForInvocation(Argv[0], nullptr);
Clang->createVirtualFileSystem();
diff --git a/clang/lib/Tooling/Tooling.cpp b/clang/lib/Tooling/Tooling.cpp
index 1f6a5c94601fc..fef10a31f5956 100644
--- a/clang/lib/Tooling/Tooling.cpp
+++ b/clang/lib/Tooling/Tooling.cpp
@@ -510,7 +510,8 @@ static void injectResourceDir(CommandLineArguments &Args, const char *Argv0,
// If there's no override in place add our resource dir.
Args = getInsertArgumentAdjuster(
- ("-resource-dir=" + CompilerInvocation::GetResourcesPath(Argv0, MainAddr))
+ ("-resource-dir=" +
+ driver::Driver::GetResourcesPathForInvocation(Argv0, MainAddr))
.c_str())(Args, "");
}
diff --git a/clang/tools/c-index-test/CMakeLists.txt b/clang/tools/c-index-test/CMakeLists.txt
index 24e7c9692ca56..41e80e66ffa7a 100644
--- a/clang/tools/c-index-test/CMakeLists.txt
+++ b/clang/tools/c-index-test/CMakeLists.txt
@@ -27,6 +27,7 @@ else()
libclang
clangAST
clangBasic
+ clangDriver
clangFrontend
clangIndex
clangSerialization
diff --git a/clang/tools/c-index-test/core_main.cpp b/clang/tools/c-index-test/core_main.cpp
index 5a3086a7fc08f..c67479fd130ca 100644
--- a/clang/tools/c-index-test/core_main.cpp
+++ b/clang/tools/c-index-test/core_main.cpp
@@ -8,6 +8,7 @@
#include "clang/AST/Mangle.h"
#include "clang/Basic/LangOptions.h"
+#include "clang/Driver/CreateInvocationFromArgs.h"
#include "clang/Frontend/ASTUnit.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/CompilerInvocation.h"
diff --git a/clang/tools/diagtool/CMakeLists.txt b/clang/tools/diagtool/CMakeLists.txt
index b49619c075c73..09b2a81790f87 100644
--- a/clang/tools/diagtool/CMakeLists.txt
+++ b/clang/tools/diagtool/CMakeLists.txt
@@ -15,5 +15,6 @@ add_clang_tool(diagtool
clang_target_link_libraries(diagtool
PRIVATE
clangBasic
+ clangDriver
clangFrontend
)
diff --git a/clang/tools/diagtool/ShowEnabledWarnings.cpp b/clang/tools/diagtool/ShowEnabledWarnings.cpp
index bea0288c09358..5b25e656dafa4 100644
--- a/clang/tools/diagtool/ShowEnabledWarnings.cpp
+++ b/clang/tools/diagtool/ShowEnabledWarnings.cpp
@@ -9,6 +9,7 @@
#include "DiagTool.h"
#include "DiagnosticNames.h"
#include "clang/Basic/LLVM.h"
+#include "clang/Driver/CreateInvocationFromArgs.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/TextDiagnosticBuffer.h"
#include "clang/Frontend/TextDiagnosticPrinter.h"
diff --git a/clang/tools/driver/cc1_main.cpp b/clang/tools/driver/cc1_main.cpp
index b19b10353591a..a7102b129e7d0 100644
--- a/clang/tools/driver/cc1_main.cpp
+++ b/clang/tools/driver/cc1_main.cpp
@@ -16,6 +16,7 @@
#include "clang/Basic/TargetOptions.h"
#include "clang/CodeGen/ObjectFilePCHContainerWriter.h"
#include "clang/Config/config.h"
+#include "clang/Driver/Driver.h"
#include "clang/Driver/DriverDiagnostic.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/CompilerInvocation.h"
@@ -269,7 +270,7 @@ int cc1_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {
if (Clang->getHeaderSearchOpts().UseBuiltinIncludes &&
Clang->getHeaderSearchOpts().ResourceDir.empty())
Clang->getHeaderSearchOpts().ResourceDir =
- CompilerInvocation::GetResourcesPath(Argv0, MainAddr);
+ driver::Driver::GetResourcesPathForInvocation(Argv0, MainAddr);
/// Create the actual file system.
Clang->createVirtualFileSystem(llvm::vfs::getRealFileSystem(), DiagsBuffer);
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index fc27fd29da933..47e35934030e8 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -38,6 +38,7 @@
#include "clang/Basic/Stack.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/Version.h"
+#include "clang/Driver/CreateASTUnitFromArgs.h"
#include "clang/Frontend/ASTUnit.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Index/CommentToXML.h"
@@ -4354,7 +4355,7 @@ clang_parseTranslationUnit_Impl(CXIndex CIdx, const char *source_filename,
LibclangInvocationReporter InvocationReporter(
*CXXIdx, LibclangInvocationReporter::OperationKind::ParseOperation,
options, llvm::ArrayRef(*Args), /*InvocationArgs=*/{}, unsaved_files);
- std::unique_ptr<ASTUnit> Unit = ASTUnit::LoadFromCommandLine(
+ std::unique_ptr<ASTUnit> Unit = CreateASTUnitFromCommandLine(
Args->data(), Args->data() + Args->size(),
CXXIdx->getPCHContainerOperations(), DiagOpts, Diags,
CXXIdx->getClangResourcesPath(), CXXIdx->getStorePreamblesInMemory(),
diff --git a/clang/tools/libclang/Indexing.cpp b/clang/tools/libclang/Indexing.cpp
index c142f142d5071..75323d70afcfe 100644
--- a/clang/tools/libclang/Indexing.cpp
+++ b/clang/tools/libclang/Indexing.cpp
@@ -15,6 +15,7 @@
#include "CXString.h"
#include "CXTranslationUnit.h"
#include "clang/AST/ASTConsumer.h"
+#include "clang/Driver/CreateInvocationFromArgs.h"
#include "clang/Frontend/ASTUnit.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/CompilerInvocation.h"
diff --git a/clang/unittests/Driver/DXCModeTest.cpp b/clang/unittests/Driver/DXCModeTest.cpp
index e0454f190b35a..130da620b40b5 100644
--- a/clang/unittests/Driver/DXCModeTest.cpp
+++ b/clang/unittests/Driver/DXCModeTest.cpp
@@ -15,6 +15,7 @@
#include "clang/Basic/LLVM.h"
#include "clang/Basic/TargetOptions.h"
#include "clang/Driver/Compilation.h"
+#include "clang/Driver/CreateInvocationFromArgs.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/ToolChain.h"
#include "clang/Frontend/CompilerInstance.h"
diff --git a/clang/unittests/Driver/ToolChainTest.cpp b/clang/unittests/Driver/ToolChainTest.cpp
index afa17ff219be2..8f533790ec501 100644
--- a/clang/unittests/Driver/ToolChainTest.cpp
+++ b/clang/unittests/Driver/ToolChainTest.cpp
@@ -17,6 +17,7 @@
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/TargetOptions.h"
#include "clang/Driver/Compilation.h"
+#include "clang/Driver/CreateInvocationFromArgs.h"
#include "clang/Driver/Driver.h"
#include "clang/Frontend/CompilerInstance.h"
#include "llvm/ADT/ArrayRef.h"
diff --git a/clang/unittests/Frontend/ASTUnitTest.cpp b/clang/unittests/Frontend/ASTUnitTest.cpp
index dfdbe90e72f1f..bf9e4e184b5db 100644
--- a/clang/unittests/Frontend/ASTUnitTest.cpp
+++ b/clang/unittests/Frontend/ASTUnitTest.cpp
@@ -9,6 +9,8 @@
#include <fstream>
#include "clang/Basic/FileManager.h"
+#include "clang/Driver/CreateASTUnitFromArgs.h"
+#include "clang/Driver/CreateInvocationFromArgs.h"
#include "clang/Frontend/ASTUnit.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/CompilerInvocation.h"
@@ -173,7 +175,7 @@ TEST_F(ASTUnitTest, LoadFromCommandLineEarlyError) {
auto PCHContainerOps = std::make_shared<PCHContainerOperations>();
std::unique_ptr<clang::ASTUnit> ErrUnit;
- std::unique_ptr<ASTUnit> AST = ASTUnit::LoadFromCommandLine(
+ std::unique_ptr<ASTUnit> AST = CreateASTUnitFromCommandLine(
&Args[0], &Args[4], PCHContainerOps, DiagOpts, Diags, "", false, "",
false, CaptureDiagsKind::All, {}, true, 0, TU_Complete, false, false,
false, SkipFunctionBodiesScope::None, false, true, false, false,
@@ -201,7 +203,7 @@ TEST_F(ASTUnitTest, LoadFromCommandLineWorkingDirectory) {
auto PCHContainerOps = std::make_shared<PCHContainerOperations>();
std::unique_ptr<clang::ASTUnit> ErrUnit;
- std::unique_ptr<ASTUnit> AST = ASTUnit::LoadFromCommandLine(
+ std::unique_ptr<ASTUnit> AST = CreateASTUnitFromCommandLine(
&Args[0], &Args[4], PCHContainerOps, DiagOpts, Diags, "", false, "",
false, CaptureDiagsKind::All, {}, true, 0, TU_Complete, false, false,
false, SkipFunctionBodiesScope::None, false, true, false, false,
diff --git a/clang/unittests/Frontend/CompilerInstanceTest.cpp b/clang/unittests/Frontend/CompilerInstanceTest.cpp
index cd3fefa1ea994..39d35b48f394a 100644
--- a/clang/unittests/Frontend/CompilerInstanceTest.cpp
+++ b/clang/unittests/Frontend/CompilerInstanceTest.cpp
@@ -8,6 +8,7 @@
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Basic/FileManager.h"
+#include "clang/Driver/CreateInvocationFromArgs.h"
#include "clang/Frontend/CompilerInvocation.h"
#include "clang/Frontend/FrontendActions.h"
#include "clang/Frontend/TextDiagnosticPrinter.h"
diff --git a/clang/unittests/Frontend/UtilsTest.cpp b/clang/unittests/Frontend/UtilsTest.cpp
index fc411e4af705f..a82733d57714a 100644
--- a/clang/unittests/Frontend/UtilsTest.cpp
+++ b/clang/unittests/Frontend/UtilsTest.cpp
@@ -9,6 +9,7 @@
#include "clang/Frontend/Utils.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/TargetOptions.h"
+#include "clang/Driver/CreateInvocationFromArgs.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/CompilerInvocation.h"
#include "clang/Lex/PreprocessorOptions.h"
diff --git a/clang/unittests/Sema/CMakeLists.txt b/clang/unittests/Sema/CMakeLists.txt
index b61ed8c457635..188f6135a60ac 100644
--- a/clang/unittests/Sema/CMakeLists.txt
+++ b/clang/unittests/Sema/CMakeLists.txt
@@ -13,6 +13,7 @@ add_distinct_clang_unittest(SemaTests
clangAST
clangASTMatchers
clangBasic
+ clangDriver
clangFrontend
clangParse
clangSema
diff --git a/clang/unittests/Sema/SemaNoloadLookupTest.cpp b/clang/unittests/Sema/SemaNoloadLookupTest.cpp
index e565372698e5e..3944269eff502 100644
--- a/clang/unittests/Sema/SemaNoloadLookupTest.cpp
+++ b/clang/unittests/Sema/SemaNoloadLookupTest.cpp
@@ -10,6 +10,7 @@
#include "clang/AST/DeclarationName.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Driver/CreateInvocationFromArgs.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/FrontendAction.h"
#include "clang/Frontend/FrontendActions.h"
diff --git a/clang/unittests/Serialization/ForceCheckFileInputTest.cpp b/clang/unittests/Serialization/ForceCheckFileInputTest.cpp
index edf33ae04230b..b76dcfec96063 100644
--- a/clang/unittests/Serialization/ForceCheckFileInputTest.cpp
+++ b/clang/unittests/Serialization/ForceCheckFileInputTest.cpp
@@ -9,6 +9,7 @@
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/ASTMatchers/ASTMatchers.h"
#include "clang/Basic/FileManager.h"
+#include "clang/Driver/CreateInvocationFromArgs.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/CompilerInvocation.h"
#include "clang/Frontend/FrontendActions.h"
diff --git a/clang/unittests/Serialization/LoadSpecLazilyTest.cpp b/clang/unittests/Serialization/LoadSpecLazilyTest.cpp
index d7b55491fddac..f55925aeae1f2 100644
--- a/clang/unittests/Serialization/LoadSpecLazilyTest.cpp
+++ b/clang/unittests/Serialization/LoadSpecLazilyTest.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+#include "clang/Driver/CreateInvocationFromArgs.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/FrontendAction.h"
#include "clang/Frontend/FrontendActions.h"
diff --git a/clang/unittests/Serialization/ModuleCacheTest.cpp b/clang/unittests/Serialization/ModuleCacheTest.cpp
index e9b8da3dba6af..df26e54588b9e 100644
--- a/clang/unittests/Serialization/ModuleCacheTest.cpp
+++ b/clang/unittests/Serialization/ModuleCacheTest.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "clang/Basic/FileManager.h"
+#include "clang/Driver/CreateInvocationFromArgs.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/CompilerInvocation.h"
#include "clang/Frontend/FrontendActions.h"
diff --git a/clang/unittests/Serialization/NoCommentsTest.cpp b/clang/unittests/Serialization/NoCommentsTest.cpp
index 01bb6999a7c90..444a082bba907 100644
--- a/clang/unittests/Serialization/NoCommentsTest.cpp
+++ b/clang/unittests/Serialization/NoCommentsTest.cpp
@@ -9,6 +9,7 @@
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/ASTMatchers/ASTMatchers.h"
#include "clang/Basic/FileManager.h"
+#include "clang/Driver/CreateInvocationFromArgs.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/CompilerInvocation.h"
#include "clang/Frontend/FrontendActions.h"
diff --git a/clang/unittests/Serialization/PreambleInNamedModulesTest.cpp b/clang/unittests/Serialization/PreambleInNamedModulesTest.cpp
index 55ee72875ead2..b826f20ce4d70 100644
--- a/clang/unittests/Serialization/PreambleInNamedModulesTest.cpp
+++ b/clang/unittests/Serialization/PreambleInNamedModulesTest.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+#include "clang/Driver/CreateInvocationFromArgs.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/CompilerInvocation.h"
#include "clang/Frontend/FrontendActions.h"
diff --git a/clang/unittests/Serialization/VarDeclConstantInitTest.cpp b/clang/unittests/Serialization/VarDeclConstantInitTest.cpp
index 743f851fc5fe1..2be01def49809 100644
--- a/clang/unittests/Serialization/VarDeclConstantInitTest.cpp
+++ b/clang/unittests/Serialization/VarDeclConstantInitTest.cpp
@@ -9,6 +9,7 @@
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/ASTMatchers/ASTMatchers.h"
#include "clang/Basic/FileManager.h"
+#include "clang/Driver/CreateInvocationFromArgs.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/CompilerInvocation.h"
#include "clang/Frontend/FrontendActions.h"
diff --git a/clang/unittests/Tooling/Syntax/TokensTest.cpp b/clang/unittests/Tooling/Syntax/TokensTest.cpp
index 47184cbf5d768..468ca5ddd2c75 100644
--- a/clang/unittests/Tooling/Syntax/TokensTest.cpp
+++ b/clang/unittests/Tooling/Syntax/TokensTest.cpp
@@ -20,6 +20,7 @@
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TokenKinds.def"
#include "clang/Basic/TokenKinds.h"
+#include "clang/Driver/CreateInvocationFromArgs.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/FrontendAction.h"
#include "clang/Frontend/Utils.h"
diff --git a/clang/unittests/Tooling/Syntax/TreeTestBase.cpp b/clang/unittests/Tooling/Syntax/TreeTestBase.cpp
index b2be64fc08f3d..dad75854240ef 100644
--- a/clang/unittests/Tooling/Syntax/TreeTestBase.cpp
+++ b/clang/unittests/Tooling/Syntax/TreeTestBase.cpp
@@ -13,6 +13,7 @@
#include "TreeTestBase.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/Basic/LLVM.h"
+#include "clang/Driver/CreateInvocationFromArgs.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/CompilerInvocation.h"
#include "clang/Frontend/FrontendAction.h"
More information about the cfe-commits
mailing list