aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-ml/llvm-ml.cpp
diff options
context:
space:
mode:
authorEric Astor <epastor@google.com>2021-06-09 14:41:24 -0400
committerEric Astor <epastor@google.com>2021-06-09 15:25:26 -0400
commitc43f413b01b021a8f7b6fce013296114fa92a245 (patch)
tree771fc7ef802b1a3380bf3a5197fb27682fc306ed /llvm/tools/llvm-ml/llvm-ml.cpp
parent222cce3828a515a9336f6d52b15ccc0c482d5ace (diff)
downloadllvm-c43f413b01b021a8f7b6fce013296114fa92a245.zip
llvm-c43f413b01b021a8f7b6fce013296114fa92a245.tar.gz
llvm-c43f413b01b021a8f7b6fce013296114fa92a245.tar.bz2
[ms] [llvm-ml] Add support for INCLUDE environment variable
Also adds support for the ML.exe command-line flag /X, which ignores the INCLUDE environment variable.
Diffstat (limited to 'llvm/tools/llvm-ml/llvm-ml.cpp')
-rw-r--r--llvm/tools/llvm-ml/llvm-ml.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/llvm/tools/llvm-ml/llvm-ml.cpp b/llvm/tools/llvm-ml/llvm-ml.cpp
index 14f75d0..7fefb9d 100644
--- a/llvm/tools/llvm-ml/llvm-ml.cpp
+++ b/llvm/tools/llvm-ml/llvm-ml.cpp
@@ -36,6 +36,7 @@
#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
+#include "llvm/Support/Process.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/TargetSelect.h"
@@ -263,8 +264,21 @@ int main(int Argc, char **Argv) {
SrcMgr.AddNewSourceBuffer(std::move(*BufferPtr), SMLoc());
// Record the location of the include directories so that the lexer can find
- // it later.
- SrcMgr.setIncludeDirs(InputArgs.getAllArgValues(OPT_include_path));
+ // included files later.
+ std::vector<std::string> IncludeDirs =
+ InputArgs.getAllArgValues(OPT_include_path);
+ if (!InputArgs.hasArg(OPT_ignore_include_envvar)) {
+ if (llvm::Optional<std::string> cl_include_dir =
+ llvm::sys::Process::GetEnv("INCLUDE")) {
+ SmallVector<StringRef, 8> Dirs;
+ StringRef(*cl_include_dir)
+ .split(Dirs, ";", /*MaxSplit=*/-1, /*KeepEmpty=*/false);
+ IncludeDirs.reserve(IncludeDirs.size() + Dirs.size());
+ for (StringRef Dir : Dirs)
+ IncludeDirs.push_back(Dir.str());
+ }
+ }
+ SrcMgr.setIncludeDirs(IncludeDirs);
std::unique_ptr<MCRegisterInfo> MRI(TheTarget->createMCRegInfo(TripleName));
assert(MRI && "Unable to create target register info!");