r243085 - Fix the cc1as crash when it outputs assembly

Steven Wu stevenwu at apple.com
Thu Jul 23 19:12:43 PDT 2015


Author: steven_wu
Date: Thu Jul 23 21:12:43 2015
New Revision: 243085

URL: http://llvm.org/viewvc/llvm-project?rev=243085&view=rev
Log:
Fix the cc1as crash when it outputs assembly

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.

Added:
    cfe/trunk/test/Misc/cc1as-asm.s
Modified:
    cfe/trunk/tools/driver/cc1as_main.cpp

Added: cfe/trunk/test/Misc/cc1as-asm.s
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/cc1as-asm.s?rev=243085&view=auto
==============================================================================
--- cfe/trunk/test/Misc/cc1as-asm.s (added)
+++ cfe/trunk/test/Misc/cc1as-asm.s Thu Jul 23 21:12:43 2015
@@ -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

Modified: cfe/trunk/tools/driver/cc1as_main.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=243085&r1=243084&r2=243085&view=diff
==============================================================================
--- cfe/trunk/tools/driver/cc1as_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1as_main.cpp Thu Jul 23 21:12:43 2015
@@ -406,6 +406,9 @@ static bool ExecuteAssembler(AssemblerIn
     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();






More information about the cfe-commits mailing list