mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Teach the frontend how to pass through -Xllvm commands.
This patch allows you to pass through commands to llvm from the driver so now one can when compiling swift files get debug messages! Swift SVN r13761
This commit is contained in:
@@ -237,6 +237,10 @@ def Xcc : Separate<["-"], "Xcc">, Flags<[DriverOption, FrontendOption]>,
|
||||
MetaVarName<"<arg>">,
|
||||
HelpText<"Pass <arg> to the C/C++/Objective-C compiler">;
|
||||
|
||||
def Xllvm : Separate<["-"], "Xllvm">, Flags<[DriverOption, FrontendOption]>,
|
||||
MetaVarName<"<arg>">,
|
||||
HelpText<"Pass <arg> to llvm.">;
|
||||
|
||||
def target : Joined<["--"], "target=">, Flags<[DriverOption, FrontendOption]>,
|
||||
HelpText<"Generate code for the given target">;
|
||||
def target_legacy_spelling : Separate<["-"], "target">,
|
||||
|
||||
@@ -89,6 +89,10 @@ public:
|
||||
/// Arguments which should be passed in immediate mode.
|
||||
std::vector<std::string> ImmediateArgv;
|
||||
|
||||
/// \brief A list of arguments to forward to LLVM's option processing; this
|
||||
/// should only be used for debugging and experimental features.
|
||||
std::vector<std::string> LLVMArgs;
|
||||
|
||||
enum ActionType {
|
||||
Parse, ///< Parse and type-check only
|
||||
DumpParse, ///< Parse only and dump AST
|
||||
|
||||
@@ -110,6 +110,9 @@ static void addCommonFrontendArgs(const ToolChain &TC,
|
||||
inputArgs.AddAllArgs(arguments, options::OPT_I);
|
||||
|
||||
inputArgs.AddLastArg(arguments, options::OPT_g);
|
||||
|
||||
// Pass through any -Xllvm flags.
|
||||
inputArgs.AddAllArgs(arguments, options::OPT_Xllvm);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -455,6 +455,7 @@ static bool ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
|
||||
|
||||
Opts.EnableSourceImport = Args.hasArg(OPT_enable_source_import);
|
||||
Opts.SILSerializeAll = Args.hasArg(OPT_sil_serialize_all);
|
||||
Opts.LLVMArgs = Args.getAllArgValues(OPT_Xllvm);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#include "swift/Parse/Lexer.h"
|
||||
#include "swift/SIL/SILModule.h"
|
||||
#include "swift/Serialization/SerializedModuleLoader.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/MemoryBuffer.h"
|
||||
#include "llvm/Support/Path.h"
|
||||
|
||||
@@ -38,6 +40,17 @@ void swift::CompilerInstance::createSILModule() {
|
||||
bool swift::CompilerInstance::setup(const CompilerInvocation &Invok) {
|
||||
Invocation = Invok;
|
||||
|
||||
// Honor -Xllvm.
|
||||
if (!Invok.getFrontendOptions().LLVMArgs.empty()) {
|
||||
llvm::SmallVector<const char *, 4> Args;
|
||||
Args.push_back("swift (LLVM option parsing)");
|
||||
for (unsigned i = 0, e = Invok.getFrontendOptions().LLVMArgs.size(); i != e;
|
||||
++i)
|
||||
Args.push_back(Invok.getFrontendOptions().LLVMArgs[i].c_str());
|
||||
Args.push_back(nullptr);
|
||||
llvm::cl::ParseCommandLineOptions(Args.size(), Args.data());
|
||||
}
|
||||
|
||||
Context.reset(new ASTContext(Invocation.getLangOptions(),
|
||||
Invocation.getSearchPathOptions(),
|
||||
SourceMgr, Diagnostics));
|
||||
|
||||
Reference in New Issue
Block a user