aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-12-03 05:11:16 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-12-03 05:11:16 +0000
commit6048e7fdc0f6d69699081a9ab7a0a9be104b1d02 (patch)
tree5bf622af4919e2a85a1bd18679e624355c958f83 /clang/lib/Frontend/CompilerInvocation.cpp
parentda7a52289fbdd02923e24b21c5b73ab7eef42ae6 (diff)
downloadllvm-6048e7fdc0f6d69699081a9ab7a0a9be104b1d02.zip
llvm-6048e7fdc0f6d69699081a9ab7a0a9be104b1d02.tar.gz
llvm-6048e7fdc0f6d69699081a9ab7a0a9be104b1d02.tar.bz2
Add clang -cc1 support for -remap-file.
llvm-svn: 90414
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 3e6f9cb..4f8ab50 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -554,6 +554,11 @@ static void PreprocessorOptsToArgs(const PreprocessorOptions &Opts,
assert(Opts.ImplicitPTHInclude == Opts.TokenCache &&
"Unsupported option combination!");
}
+ for (unsigned i = 0, e = Opts.RemappedFiles.size(); i != e; ++i) {
+ Res.push_back("-remap-file");
+ Res.push_back(Opts.RemappedFiles[i].first + ";" +
+ Opts.RemappedFiles[i].second);
+ }
}
static void PreprocessorOutputOptsToArgs(const PreprocessorOutputOptions &Opts,
@@ -1165,7 +1170,8 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args,
}
}
-static void ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args) {
+static void ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args,
+ Diagnostic &Diags) {
using namespace cc1options;
Opts.ImplicitPCHInclude = getLastArgValue(Args, OPT_include_pch);
Opts.ImplicitPTHInclude = getLastArgValue(Args, OPT_include_pth);
@@ -1203,6 +1209,19 @@ static void ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args) {
} else
Opts.Includes.push_back(it->getValue(Args));
}
+
+ for (arg_iterator it = Args.filtered_begin(OPT_remap_file),
+ ie = Args.filtered_end(); it != ie; ++it) {
+ std::pair<llvm::StringRef,llvm::StringRef> Split =
+ llvm::StringRef(it->getValue(Args)).split(';');
+
+ if (Split.second.empty()) {
+ Diags.Report(diag::err_drv_invalid_remap_file) << it->getAsString(Args);
+ continue;
+ }
+
+ Opts.addRemappedFile(Split.first, Split.second);
+ }
}
static void ParsePreprocessorOutputArgs(PreprocessorOutputOptions &Opts,
@@ -1261,7 +1280,7 @@ void CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
Argv0, MainAddr);
if (DashX != FrontendOptions::IK_AST)
ParseLangArgs(Res.getLangOpts(), *Args, DashX, Diags);
- ParsePreprocessorArgs(Res.getPreprocessorOpts(), *Args);
+ ParsePreprocessorArgs(Res.getPreprocessorOpts(), *Args, Diags);
ParsePreprocessorOutputArgs(Res.getPreprocessorOutputOpts(), *Args);
ParseTargetArgs(Res.getTargetOpts(), *Args);
}