aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorFaris Rehman <faris.rehman@arm.com>2021-01-19 10:01:38 +0000
committerAndrzej Warzynski <andrzej.warzynski@arm.com>2021-01-19 11:20:56 +0000
commit87dfd5e012e147f4bfa3a9a4564e9cbc167278ff (patch)
tree36335f9bf8280096a9038653357ac5eda3c87a60 /flang/lib/Frontend/CompilerInvocation.cpp
parent11f4c58c153cedf6fe04cab49d4a4f02d00e3383 (diff)
downloadllvm-87dfd5e012e147f4bfa3a9a4564e9cbc167278ff.zip
llvm-87dfd5e012e147f4bfa3a9a4564e9cbc167278ff.tar.gz
llvm-87dfd5e012e147f4bfa3a9a4564e9cbc167278ff.tar.bz2
[flang][driver] Add support for `-I` in the new driver
Add support for option -I in the new Flang driver. This will allow for included headers and module files in other directories, as the default search path is currently the working folder. The behaviour of this is consistent with the current f18 driver, where the current folder (i.e. ".") has the highest priority followed by the order of '-I's taking priority from first to last. Summary of changes: - Add SearchDirectoriesFromDashI to PreprocessorOptions, to be forwarded into the parser's searchDirectories - Add header files and non-functional module files to be used in regression tests. The module files are just text files and are used to demonstrated that paths specified with `-I` are taken into account when searching for .mod files. Differential Revision: https://reviews.llvm.org/D93453
Diffstat (limited to 'flang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--flang/lib/Frontend/CompilerInvocation.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index 57f097f..aeb4ac3 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -176,6 +176,10 @@ static void parsePreprocessorArgs(
opts.addMacroUndef(currentArg->getValue());
}
}
+
+ // Add the ordered list of -I's.
+ for (const auto *currentArg : args.filtered(clang::driver::options::OPT_I))
+ opts.searchDirectoriesFromDashI.emplace_back(currentArg->getValue());
}
bool CompilerInvocation::CreateFromArgs(CompilerInvocation &res,
@@ -261,4 +265,9 @@ void CompilerInvocation::setFortranOpts() {
const auto &preprocessorOptions = preprocessorOpts();
collectMacroDefinitions(preprocessorOptions, fortranOptions);
+
+ fortranOptions.searchDirectories.insert(
+ fortranOptions.searchDirectories.end(),
+ preprocessorOptions.searchDirectoriesFromDashI.begin(),
+ preprocessorOptions.searchDirectoriesFromDashI.end());
}