diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-12-02 08:08:39 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-12-02 08:08:39 +0000 |
commit | 716f0b3e2e36f362b64a2ce0a40a9ad915103255 (patch) | |
tree | 2991e194250a39dd3a6016af8a91dce1afa92f96 /tools/clang-cc/Options.cpp | |
parent | 0bd6feb9e9d40fc889fd47e899985125a43dfed8 (diff) |
Introduce a new clang-cc option
-remap-file=from;to
which takes the file "from" and transparently replaces its contents
with the contents of the file "to" from the source manager's
perspective. This is the moral equivalent of
cp from saved
cp to from
<call clang>
cp saved from
rm saved
without all of the pesky file copying.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90307 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/clang-cc/Options.cpp')
-rw-r--r-- | tools/clang-cc/Options.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/clang-cc/Options.cpp b/tools/clang-cc/Options.cpp index a18598ef7c..c97d4ca8c9 100644 --- a/tools/clang-cc/Options.cpp +++ b/tools/clang-cc/Options.cpp @@ -673,6 +673,10 @@ static llvm::cl::opt<bool> UndefMacros("undef", llvm::cl::value_desc("macro"), llvm::cl::desc("undef all system defines")); +static llvm::cl::list<std::string> +RemappedFiles("remap-file", llvm::cl::value_desc("<from>;<to>"), + llvm::cl::desc("replace the contents of the <from> file with the contents of the <to> file")); + } //===----------------------------------------------------------------------===// @@ -1071,6 +1075,20 @@ void clang::InitializePreprocessorOptions(PreprocessorOptions &Opts) { for (unsigned i = 0, e = OrderedPaths.size(); i != e; ++i) Opts.Includes.push_back(*OrderedPaths[i].second); + + // Handle file remapping. + for (unsigned i = 0, e = RemappedFiles.size(); i != e; ++i) { + std::string::size_type Semi = RemappedFiles[i].find(';'); + if (Semi == std::string::npos) { + // FIXME: Don't fail like this. + fprintf(stderr, + "error: -remap-file not of the form <from-file>;<to-file>\n"); + continue; + } + + Opts.addRemappedFile(llvm::StringRef(RemappedFiles[i].c_str(), Semi), + llvm::StringRef(RemappedFiles[i].c_str() + Semi + 1)); + } } void clang::InitializeLangOptions(LangOptions &Options, |