]> granicus.if.org Git - clang/commitdiff
Fix the cc1as crash when it outputs assembly
authorSteven Wu <stevenwu@apple.com>
Fri, 24 Jul 2015 02:12:43 +0000 (02:12 +0000)
committerSteven Wu <stevenwu@apple.com>
Fri, 24 Jul 2015 02:12:43 +0000 (02:12 +0000)
In clang cc1as_main, when the output file type is “asm”, AsmStreamer
owns a formatted_raw_ostream which has a reference to FDOS
(raw_ostream), so AsmStreamer must be closed before FDOS is closed.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@243085 91177308-0d34-0410-b5e6-96231b3b80d8

test/Misc/cc1as-asm.s [new file with mode: 0644]
tools/driver/cc1as_main.cpp

diff --git a/test/Misc/cc1as-asm.s b/test/Misc/cc1as-asm.s
new file mode 100644 (file)
index 0000000..af92644
--- /dev/null
@@ -0,0 +1,3 @@
+// Run cc1as asm output path just to make sure it works
+// REQUIRES: x86-registered-target
+// RUN: %clang -cc1as -triple x86_64-apple-macosx10.10.0 -filetype asm %s -o /dev/null
index aa92541953fa07e86d383c5a6b64964565711498..fd0fbb4c5a26b0023ff249d55b1cf14d2196f1b4 100644 (file)
@@ -406,6 +406,9 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts,
     Failed = Parser->Run(Opts.NoInitialTextSection);
   }
 
+  // Close Streamer first.
+  // It might have a reference to the output stream.
+  Str.reset();
   // Close the output stream early.
   BOS.reset();
   FDOS.reset();