Skip to content

Commit 125de33

Browse files
mcinallyCameron McInallyshafik
authored andcommitted
[Driver] Move CommonArgs to a location visible by the Frontend Drivers (llvm#142800)
This patch moves the CommonArgs utilities into a location visible by the Frontend Drivers, so that the Frontend Drivers may share option parsing code with the Compiler Driver. This is useful when the Frontend Drivers would like to verify that their incoming options are well-formed and also not reinvent the option parsing wheel. We already see code in the Clang/Flang Drivers that is parsing and verifying its incoming options. E.g. OPT_ffp_contract. This option is parsed in the Compiler Driver, Clang Driver, and Flang Driver, all with slightly different parsing code. It would be nice if the Frontend Drivers were not required to duplicate this Compiler Driver code. That way there is no/low maintenance burden on keeping all these parsing functions in sync. Along those lines, the Frontend Drivers will now have a useful mechanism to verify their incoming options are well-formed. Currently, the Frontend Drivers trust that the Compiler Driver is not passing back junk in some cases. The Language Drivers may even accept junk with no error at all. E.g.: `clang -cc1 -mprefer-vector-width=junk test.c' With this patch, we'll now be able to tighten up incomming options to the Frontend drivers in a lightweight way. --------- Co-authored-by: Cameron McInally <[email protected]> Co-authored-by: Shafik Yaghmour <[email protected]>
1 parent f69d048 commit 125de33

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+95
-89
lines changed

clang/lib/Driver/ToolChains/CommonArgs.h renamed to clang/include/clang/Driver/CommonArgs.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,12 @@ void handleVectorizeLoopsArgs(const llvm::opt::ArgList &Args,
270270
/// Enable -fslp-vectorize based on the optimization level selected.
271271
void handleVectorizeSLPArgs(const llvm::opt::ArgList &Args,
272272
llvm::opt::ArgStringList &CmdArgs);
273+
274+
// Parse -mprefer-vector-width=. Return the Value string if well-formed.
275+
// Otherwise, return an empty string and issue a diagnosic message if needed.
276+
StringRef ParseMPreferVectorWidthOption(clang::DiagnosticsEngine &Diags,
277+
const llvm::opt::ArgList &Args);
278+
273279
} // end namespace tools
274280
} // end namespace driver
275281
} // end namespace clang

clang/lib/Driver/MultilibBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "clang/Driver/MultilibBuilder.h"
10-
#include "ToolChains/CommonArgs.h"
10+
#include "clang/Driver/CommonArgs.h"
1111
#include "llvm/ADT/StringMap.h"
1212
#include "llvm/Support/Path.h"
1313
#include "llvm/Support/Regex.h"

clang/lib/Driver/ToolChain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
#include "ToolChains/Arch/ARM.h"
1212
#include "ToolChains/Arch/RISCV.h"
1313
#include "ToolChains/Clang.h"
14-
#include "ToolChains/CommonArgs.h"
1514
#include "ToolChains/Flang.h"
1615
#include "ToolChains/InterfaceStubs.h"
1716
#include "clang/Basic/ObjCRuntime.h"
1817
#include "clang/Basic/Sanitizers.h"
1918
#include "clang/Config/config.h"
2019
#include "clang/Driver/Action.h"
20+
#include "clang/Driver/CommonArgs.h"
2121
#include "clang/Driver/Driver.h"
2222
#include "clang/Driver/InputInfo.h"
2323
#include "clang/Driver/Job.h"

clang/lib/Driver/ToolChains/AIX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "AIX.h"
10-
#include "CommonArgs.h"
10+
#include "clang/Driver/CommonArgs.h"
1111
#include "clang/Driver/Compilation.h"
1212
#include "clang/Driver/Options.h"
1313
#include "clang/Driver/SanitizerArgs.h"

clang/lib/Driver/ToolChains/AMDGPU.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "AMDGPU.h"
10-
#include "CommonArgs.h"
1110
#include "clang/Basic/TargetID.h"
1211
#include "clang/Config/config.h"
12+
#include "clang/Driver/CommonArgs.h"
1313
#include "clang/Driver/Compilation.h"
1414
#include "clang/Driver/InputInfo.h"
1515
#include "clang/Driver/Options.h"

clang/lib/Driver/ToolChains/AVR.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "AVR.h"
10-
#include "CommonArgs.h"
10+
#include "clang/Driver/CommonArgs.h"
1111
#include "clang/Driver/Compilation.h"
1212
#include "clang/Driver/InputInfo.h"
1313
#include "clang/Driver/Options.h"

clang/lib/Driver/ToolChains/Arch/AArch64.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "AArch64.h"
10-
#include "../CommonArgs.h"
10+
#include "clang/Driver/CommonArgs.h"
1111
#include "clang/Driver/Driver.h"
1212
#include "clang/Driver/Options.h"
1313
#include "llvm/Option/ArgList.h"

clang/lib/Driver/ToolChains/Arch/LoongArch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
#include "LoongArch.h"
1010
#include "../Clang.h"
11-
#include "ToolChains/CommonArgs.h"
1211
#include "clang/Basic/DiagnosticDriver.h"
12+
#include "clang/Driver/CommonArgs.h"
1313
#include "clang/Driver/Driver.h"
1414
#include "clang/Driver/Options.h"
1515
#include "llvm/TargetParser/Host.h"

clang/lib/Driver/ToolChains/Arch/Mips.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "Mips.h"
10-
#include "ToolChains/CommonArgs.h"
10+
#include "clang/Driver/CommonArgs.h"
1111
#include "clang/Driver/Driver.h"
1212
#include "clang/Driver/Options.h"
1313
#include "llvm/ADT/StringSwitch.h"

clang/lib/Driver/ToolChains/Arch/PPC.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "PPC.h"
10-
#include "ToolChains/CommonArgs.h"
10+
#include "clang/Driver/CommonArgs.h"
1111
#include "clang/Driver/Driver.h"
1212
#include "clang/Driver/Options.h"
1313
#include "llvm/ADT/StringSwitch.h"

0 commit comments

Comments
 (0)