aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Thompson <John.Thompson.JTSoftware@gmail.com>2015-05-06 18:43:01 +0000
committerJohn Thompson <John.Thompson.JTSoftware@gmail.com>2015-05-06 18:43:01 +0000
commitcbfb437eb554f662e93a45ae88ee6f9262da9d76 (patch)
tree230154438960a2041575d372754f9ca121edc050
parent41ae1d231c43fb086dd7cd0d1e93f1053ce50a2e (diff)
Changed option processing to implicitly use -x c++ if no other -x option specified. Added implicit -w option to disable compilation warnings, in particular to avoid warning on pragma once.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@236625 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--docs/ModularizeUsage.rst7
-rw-r--r--modularize/Modularize.cpp16
2 files changed, 16 insertions, 7 deletions
diff --git a/docs/ModularizeUsage.rst b/docs/ModularizeUsage.rst
index b43389e8..8d822bc8 100644
--- a/docs/ModularizeUsage.rst
+++ b/docs/ModularizeUsage.rst
@@ -37,9 +37,10 @@ directory.
``<front-end-options>`` is a place-holder for regular Clang
front-end arguments, which must follow the <include-files-list>.
-Note that by default, the underlying Clang front end assumes .h files
-contain C source, so you might need to specify the ``-x c++`` Clang option
-to tell Clang that the header contains C++ definitions.
+Note that by default, modularize assumes .h files
+contain C++ source, so if you are using a different language,
+you might need to use a ``-x`` option to tell Clang that the
+header contains another language, i.e.: ``-x c``
Note also that because modularize does not use the clang driver,
you will likely need to pass in additional compiler front-end
diff --git a/modularize/Modularize.cpp b/modularize/Modularize.cpp
index b88476e7..56aa96dd 100644
--- a/modularize/Modularize.cpp
+++ b/modularize/Modularize.cpp
@@ -73,9 +73,9 @@
// you will likely need to pass in additional compiler front-end
// arguments to match those passed in by default by the driver.
//
-// Note that by default, the underlying Clang front end assumes .h files
-// contain C source. If your .h files in the file list contain C++ source,
-// you should append the following to your command lines: -x c++
+// Note that by default, the modularize assumes .h files contain C++ source.
+// If your .h files in the file list contain another language, you should
+// append an appropriate -x option to your command line, i.e.: -x c
//
// Modularization Issue Checks
//
@@ -331,7 +331,8 @@ static std::string findInputFile(const CommandLineArguments &CLArgs) {
}
// This arguments adjuster inserts "-include (file)" arguments for header
-// dependencies.
+// dependencies. It also insertts a "-w" option and a "-x c++",
+// if no other "-x" option is present.
static ArgumentsAdjuster
getAddDependenciesAdjuster(DependencyMap &Dependencies) {
return [&Dependencies](const CommandLineArguments &Args) {
@@ -346,6 +347,13 @@ getAddDependenciesAdjuster(DependencyMap &Dependencies) {
NewArgs.push_back(FileDependents[Index]);
}
}
+ // Ignore warnings. (Insert after "clang_tool" at beginning.)
+ NewArgs.insert(NewArgs.begin() + 1, "-w");
+ // Since we are compiling .h files, assume C++ unless given a -x option.
+ if (std::find(NewArgs.begin(), NewArgs.end(), "-x") == NewArgs.end()) {
+ NewArgs.insert(NewArgs.begin() + 2, "-x");
+ NewArgs.insert(NewArgs.begin() + 3, "c++");
+ }
return NewArgs;
};
}