[PATCH] D60059: [Driver] implement -feverything
Nick Desaulniers via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 1 02:35:19 PDT 2019
nickdesaulniers created this revision.
nickdesaulniers added a reviewer: rsmith.
Herald added subscribers: llvm-commits, cfe-commits, jdoerfert.
Herald added projects: clang, LLVM.
Due to the wild popularity of -Weverything (used for enabling all
warnings), we're back for round 2 (electric boogaloo) with a succinct
analog to enable all -f flags; -feverything.
This includes favorite hits like:
- -funsafe-math-optimizations
- who knew floating point math could be BOTH fun and safe, WHO KNEW?!1
- your favorite language extensions
- -fborland-extensions
- -fms-extensions
- -fheinous-gnu-extensions
- -fplan9-extensions (TODO: implement like GCC)
- flags specific to languages (whether you're using them or not) like:
- CUDA
- FORTRAN
- Objective-C
- OpenMP
- flags specific to target (whether you're targeting them or not) like:
- -faltivec
- -fcray-pointer
- -fcall-saved-*/-ffixed-* (aka "build your own calling convention!")
- I don't know what these do, but they sound nice:
- -fmudflap
- -fdollar-ok
- -fropi
- -frwpi
Can't decide between the overflow behavior of -fwrapv or -ftrapv?
¿Porque No Los Dos?
Next time you're having trouble getting your code to compile, try
-feverything.
TODO:
- unit tests (honestly afraid to run this outside a VM, though this does
enable all runtime sanitizers for extra safety).
- -fno-everything
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D60059
Files:
clang/include/clang/Driver/Options.td
clang/include/clang/Frontend/CompilerInvocation.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
llvm/include/llvm/Option/OptTable.h
Index: llvm/include/llvm/Option/OptTable.h
===================================================================
--- llvm/include/llvm/Option/OptTable.h
+++ llvm/include/llvm/Option/OptTable.h
@@ -88,6 +88,8 @@
/// Return the total number of option classes.
unsigned getNumOptions() const { return OptionInfos.size(); }
+ unsigned getFirstSearchableIndex() const { return FirstSearchableIndex; }
+
/// Get the given Opt's Option instance, lazily creating it
/// if necessary.
///
Index: clang/lib/Frontend/CompilerInvocation.cpp
===================================================================
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1427,6 +1427,25 @@
return Success;
}
+void clang::ParseFEverything(llvm::opt::OptTable *Opts,
+ llvm::opt::InputArgList *Args) {
+ if (!Args->hasArg(options::OPT_feverything))
+ return;
+ const unsigned f_group = Opts->getOption(OPT_f_Group).getID();
+ unsigned i = Opts->getFirstSearchableIndex();
+ const unsigned len = Opts->getNumOptions();
+ for (; i != len; ++i) {
+ const Option &opt = Opts->getOption(i);
+ const Option group = opt.getGroup();
+ // TODO: add more groups
+ if (group.isValid() && group.getID() == f_group) {
+ const std::string Flag = opt.getPrefixedName();
+ if (Flag.back() != '=' && Flag.back() != '-')
+ Args->append(new Arg(opt, Flag, Args->MakeIndex(Flag), Flag.c_str()));
+ }
+ }
+}
+
bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
DiagnosticsEngine *Diags,
bool DefaultDiagColor, bool DefaultShowOpt) {
@@ -3247,6 +3266,7 @@
InputArgList Args =
Opts->ParseArgs(llvm::makeArrayRef(ArgBegin, ArgEnd), MissingArgIndex,
MissingArgCount, IncludedFlagsBitmask);
+ ParseFEverything(Opts.get(), &Args);
LangOptions &LangOpts = *Res.getLangOpts();
// Check for missing argument error.
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5389,6 +5389,9 @@
}
}
+ if (Args.hasArg(options::OPT_feverything))
+ CmdArgs.push_back("-feverything");
+
if (Args.hasFlag(options::OPT_faddrsig, options::OPT_fno_addrsig,
(TC.getTriple().isOSBinFormatELF() ||
TC.getTriple().isOSBinFormatCOFF()) &&
Index: clang/include/clang/Frontend/CompilerInvocation.h
===================================================================
--- clang/include/clang/Frontend/CompilerInvocation.h
+++ clang/include/clang/Frontend/CompilerInvocation.h
@@ -31,6 +31,8 @@
namespace opt {
class ArgList;
+class InputArgList;
+class OptTable;
} // namespace opt
@@ -61,6 +63,8 @@
bool DefaultDiagColor = true,
bool DefaultShowOpt = true);
+void ParseFEverything(llvm::opt::OptTable *Opts, llvm::opt::InputArgList *Args);
+
class CompilerInvocationBase {
public:
/// Options controlling the language variant.
Index: clang/include/clang/Driver/Options.td
===================================================================
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -434,6 +434,7 @@
HelpText<"Pass the comma separated arguments in <arg> to the assembler">,
MetaVarName<"<arg>">;
def Wall : Flag<["-"], "Wall">, Group<W_Group>, Flags<[CC1Option, HelpHidden]>;
+def feverything : Flag<["-"], "feverything">, Group<f_Group>, Flags<[CC1Option, HelpHidden]>;
def WCL4 : Flag<["-"], "WCL4">, Group<W_Group>, Flags<[CC1Option, HelpHidden]>;
def Wdeprecated : Flag<["-"], "Wdeprecated">, Group<W_Group>, Flags<[CC1Option]>,
HelpText<"Enable warnings for deprecated constructs and define __DEPRECATED">;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60059.193057.patch
Type: text/x-patch
Size: 3928 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190401/4070c322/attachment.bin>
More information about the llvm-commits
mailing list