]> granicus.if.org Git - clang/commitdiff
[driver] Do emit the diagnostics when CompilerInvocation::CreateFromArgs() fails.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 25 Jan 2012 20:00:43 +0000 (20:00 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 25 Jan 2012 20:00:43 +0000 (20:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148970 91177308-0d34-0410-b5e6-96231b3b80d8

test/Driver/unknown-arg.c [new file with mode: 0644]
tools/driver/cc1_main.cpp

diff --git a/test/Driver/unknown-arg.c b/test/Driver/unknown-arg.c
new file mode 100644 (file)
index 0000000..5d0f7af
--- /dev/null
@@ -0,0 +1,4 @@
+// RUN: not %clang_cc1 %s -cake-is-lie 2> %t.log
+// RUN: FileCheck %s -input-file=%t.log
+
+// CHECK: unknown argument
index 0a14fdd315df2839c4effbe5d0a9ee6a47facb5b..ad3f3502ec00eedb2abccc1ff648739d09f48cc2 100644 (file)
@@ -140,8 +140,6 @@ int cc1_main(const char **ArgBegin, const char **ArgEnd,
   bool Success;
   Success = CompilerInvocation::CreateFromArgs(Clang->getInvocation(),
                                                ArgBegin, ArgEnd, Diags);
-  if (!Success)
-    return 1;
 
   // Infer the builtin include path if unspecified.
   if (Clang->getHeaderSearchOpts().UseBuiltinIncludes &&
@@ -160,6 +158,8 @@ int cc1_main(const char **ArgBegin, const char **ArgEnd,
                                   static_cast<void*>(&Clang->getDiagnostics()));
 
   DiagsBuffer->FlushDiagnostics(Clang->getDiagnostics());
+  if (!Success)
+    return 1;
 
   // Execute the frontend actions.
   Success = ExecuteCompilerInvocation(Clang.get());