summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-08-07 12:58:11 (GMT)
committerBrad King <brad.king@kitware.com>2015-08-07 12:58:11 (GMT)
commit8a08a44ffee70f71bdb7d8bee90e325dafbfeae4 (patch)
tree7190cb9dbe1bb3101437bd7f05dc4d6f136cdec6
parent7fbf764f3a2945710d78fb0f6a1a937501df8166 (diff)
downloadCastXML-8a08a44ffee70f71bdb7d8bee90e325dafbfeae4.zip
CastXML-8a08a44ffee70f71bdb7d8bee90e325dafbfeae4.tar.gz
CastXML-8a08a44ffee70f71bdb7d8bee90e325dafbfeae4.tar.bz2
RunClang: Exit with error if compilation jobs fail to build
If an error occurs during Driver::BuildCompilation then exit with an error code immediately. This is important when an input file is missing, for example. GitHub-Issue: 23
-rw-r--r--src/RunClang.cxx3
-rw-r--r--test/CMakeLists.txt1
-rw-r--r--test/expect/cmd.input-missing.result.txt1
-rw-r--r--test/expect/cmd.input-missing.stderr.txt2
-rw-r--r--test/expect/cmd.rsp-missing.result.txt1
5 files changed, 8 insertions, 0 deletions
diff --git a/src/RunClang.cxx b/src/RunClang.cxx
index fd0f313..d902123 100644
--- a/src/RunClang.cxx
+++ b/src/RunClang.cxx
@@ -318,6 +318,9 @@ static int runClangImpl(const char* const* argBeg,
// Ask the driver to build the compiler commands for us.
std::unique_ptr<clang::driver::Compilation> c(d.BuildCompilation(cArgs));
+ if (diags->hasErrorOccurred()) {
+ return 1;
+ }
// For '-###' just print the jobs and exit early.
if(c->getArgs().hasArg(clang::driver::options::OPT__HASH_HASH_HASH)) {
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index a104cb9..f44680f 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -126,6 +126,7 @@ castxml_test_cmd(gccxml-and-objc2 --castxml-gccxml ${empty_mm})
castxml_test_cmd(gccxml-empty-c++98 --castxml-gccxml -std=c++98 ${empty_cxx})
castxml_test_cmd(gccxml-empty-c++98-E --castxml-gccxml -std=c++98 ${empty_cxx} -E)
castxml_test_cmd(gccxml-empty-c++98-c --castxml-gccxml -std=c++98 ${empty_cxx} -c)
+castxml_test_cmd(input-missing ${input}/does-not-exist.c)
castxml_test_cmd(o-missing -o)
castxml_test_cmd(start-missing --castxml-start)
castxml_test_cmd(rsp-empty @${input}/empty.rsp)
diff --git a/test/expect/cmd.input-missing.result.txt b/test/expect/cmd.input-missing.result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/test/expect/cmd.input-missing.result.txt
@@ -0,0 +1 @@
+1
diff --git a/test/expect/cmd.input-missing.stderr.txt b/test/expect/cmd.input-missing.stderr.txt
new file mode 100644
index 0000000..f46a447
--- /dev/null
+++ b/test/expect/cmd.input-missing.stderr.txt
@@ -0,0 +1,2 @@
+^error: no such file or directory: '.*/test/input/does-not-exist.c'
+error: no input files$
diff --git a/test/expect/cmd.rsp-missing.result.txt b/test/expect/cmd.rsp-missing.result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/test/expect/cmd.rsp-missing.result.txt
@@ -0,0 +1 @@
+1