aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorJan Svoboda <jan_svoboda@apple.com>2021-01-26 09:08:08 +0100
committerJan Svoboda <jan_svoboda@apple.com>2021-01-26 09:20:42 +0100
commit956d8e02e8a55fb5fd289c7af37dbfc73535e7a7 (patch)
tree39b3ff0ed6c0ebf03cc5d12c2db7b7bc87ab1e93 /clang/lib/Frontend/CompilerInvocation.cpp
parent2154cffdc2a6fc9bc7fc75064dc875fa9bf18190 (diff)
downloadllvm-956d8e02e8a55fb5fd289c7af37dbfc73535e7a7.zip
llvm-956d8e02e8a55fb5fd289c7af37dbfc73535e7a7.tar.gz
llvm-956d8e02e8a55fb5fd289c7af37dbfc73535e7a7.tar.bz2
[clang][cli] Port GNU language options to marshalling system
Port some GNU-related language options to the marshalling system for automatic command line parsing and generation. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D95343
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp30
1 files changed, 9 insertions, 21 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 84269b3..1e87bb9 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -400,9 +400,11 @@ static T extractMaskValue(T KeyPath) {
MERGER(KEYPATH, static_cast<decltype(KEYPATH)>(*MaybeValue)); \
}
+static const StringRef GetInputKindName(InputKind IK);
+
static void FixupInvocation(CompilerInvocation &Invocation,
- DiagnosticsEngine &Diags,
- const InputArgList &Args) {
+ DiagnosticsEngine &Diags, const InputArgList &Args,
+ InputKind IK) {
LangOptions &LangOpts = *Invocation.getLangOpts();
CodeGenOptions &CodeGenOpts = Invocation.getCodeGenOpts();
TargetOptions &TargetOpts = Invocation.getTargetOpts();
@@ -438,6 +440,10 @@ static void FixupInvocation(CompilerInvocation &Invocation,
LangOpts.NewAlignOverride = 0;
}
+ if (Args.hasArg(OPT_fgnu89_inline) && LangOpts.CPlusPlus)
+ Diags.Report(diag::err_drv_argument_not_allowed_with)
+ << "-fgnu89-inline" << GetInputKindName(IK);
+
if (Arg *A = Args.getLastArg(OPT_fdefault_calling_conv_EQ)) {
auto DefaultCC = LangOpts.getDefaultCallingConv();
@@ -1984,7 +1990,6 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,
Opts.CPlusPlus20 = Std.isCPlusPlus20();
Opts.CPlusPlus2b = Std.isCPlusPlus2b();
Opts.GNUMode = Std.isGNUMode();
- Opts.GNUInline = !Opts.C99 && !Opts.CPlusPlus;
Opts.GNUCVersion = 0;
Opts.HexFloats = Std.hasHexFloats();
Opts.ImplicitInt = Std.hasImplicitInt();
@@ -2056,7 +2061,6 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,
// C++ has wchar_t keyword.
Opts.WChar = Opts.CPlusPlus;
- Opts.GNUKeywords = Opts.GNUMode;
Opts.CXXOperatorNames = Opts.CPlusPlus;
Opts.AlignedAllocation = Opts.CPlusPlus17;
@@ -2254,14 +2258,6 @@ void CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
<< Args.getLastArg(OPT_cl_strict_aliasing)->getAsString(Args);
}
- // We abuse '-f[no-]gnu-keywords' to force overriding all GNU-extension
- // keywords. This behavior is provided by GCC's poorly named '-fasm' flag,
- // while a subset (the non-C++ GNU keywords) is provided by GCC's
- // '-fgnu-keywords'. Clang conflates the two for simplicity under the single
- // name, as it doesn't seem a useful distinction.
- Opts.GNUKeywords = Args.hasFlag(OPT_fgnu_keywords, OPT_fno_gnu_keywords,
- Opts.GNUKeywords);
-
if (Args.hasArg(OPT_fno_operator_names))
Opts.CXXOperatorNames = 0;
@@ -2344,14 +2340,6 @@ void CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
Opts.GNUCVersion = Major * 100 * 100 + Minor * 100 + Patch;
}
- if (Args.hasArg(OPT_fgnu89_inline)) {
- if (Opts.CPlusPlus)
- Diags.Report(diag::err_drv_argument_not_allowed_with)
- << "-fgnu89-inline" << GetInputKindName(IK);
- else
- Opts.GNUInline = 1;
- }
-
if (Args.hasArg(OPT_ftrapv)) {
Opts.setSignedOverflowBehavior(LangOptions::SOB_Trapping);
// Set the handler, if one is specified.
@@ -2994,7 +2982,7 @@ bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
Res.getCodeGenOpts().Argv0 = Argv0;
Res.getCodeGenOpts().CommandLineArgs = CommandLineArgs;
- FixupInvocation(Res, Diags, Args);
+ FixupInvocation(Res, Diags, Args, DashX);
return Success;
}