Skip to content

Commit

Permalink
Implement -mllvm for option passing to LLVM
Browse files Browse the repository at this point in the history
  • Loading branch information
hahnjo authored and jenkins committed Dec 2, 2021
1 parent f4641c0 commit 29d368e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/Interpreter/InvocationOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "llvm/Option/ArgList.h"
#include "llvm/Option/Option.h"
#include "llvm/Option/OptTable.h"
#include "llvm/Support/CommandLine.h"

#include <memory>

Expand Down Expand Up @@ -121,6 +122,9 @@ void CompilerOptions::Parse(int argc, const char* const argv[],
MissingArgCount, 0,
options::NoDriverOption | options::CLOption));

std::vector<const char*> LLVMArgs;
LLVMArgs.push_back("cling (LLVM option parsing)");

for (const Arg* arg : Args) {
switch (arg->getOption().getID()) {
// case options::OPT_d_Flag:
Expand Down Expand Up @@ -152,12 +156,22 @@ void CompilerOptions::Parse(int argc, const char* const argv[],
CUDAHost = false;
break;

case options::OPT_mllvm:
LLVMArgs.push_back(arg->getValue());
break;

default:
if (Inputs && arg->getOption().getKind() == Option::InputClass)
Inputs->push_back(arg->getValue());
break;
}
}

// Check that there were LLVM arguments, other than the first dummy entry.
if (LLVMArgs.size() > 1) {
LLVMArgs.push_back(nullptr);
llvm::cl::ParseCommandLineOptions(LLVMArgs.size() - 1, LLVMArgs.data());
}
}

bool CompilerOptions::DefaultLanguage(const LangOptions* LangOpts) const {
Expand Down

0 comments on commit 29d368e

Please sign in to comment.