Revert r240137 (Fixed/added namespace ending comments using clang-tidy. NFC)
[oota-llvm.git] / lib / Bitcode / Writer / BitcodeWriterPass.cpp
index 8de7ffb2db25ea151c99d3fcb96bad4f0678caa3..3165743576ec58a50412061ac271a7c555052258 100644 (file)
@@ -1,9 +1,9 @@
-//===--- Bitcode/Writer/BitcodeWriterPass.cpp - Bitcode Writer ------------===//
+//===- BitcodeWriterPass.cpp - Bitcode writing pass -----------------------===//
 //
 //                     The LLVM Compiler Infrastructure
 //
-// This file was developed by Chris Lattner and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
 //
 //
 //===----------------------------------------------------------------------===//
 
+#include "llvm/Bitcode/BitcodeWriterPass.h"
 #include "llvm/Bitcode/ReaderWriter.h"
+#include "llvm/IR/Module.h"
+#include "llvm/IR/PassManager.h"
 #include "llvm/Pass.h"
 using namespace llvm;
 
+PreservedAnalyses BitcodeWriterPass::run(Module &M) {
+  WriteBitcodeToFile(&M, OS, ShouldPreserveUseListOrder);
+  return PreservedAnalyses::all();
+}
+
 namespace {
   class WriteBitcodePass : public ModulePass {
-    std::ostream &Out;                 // ostream to print on
+    raw_ostream &OS; // raw_ostream to print on
+    bool ShouldPreserveUseListOrder;
+
   public:
-    static char ID; // Pass identifcation, replacement for typeid
-    WriteBitcodePass(std::ostream &o) : ModulePass((intptr_t) &ID), Out(o) {}
-    
-    const char *getPassName() const { return "Bitcode Writer"; }
-    
-    bool runOnModule(Module &M) {
-      WriteBitcodeToFile(&M, Out);
+    static char ID; // Pass identification, replacement for typeid
+    explicit WriteBitcodePass(raw_ostream &o, bool ShouldPreserveUseListOrder)
+        : ModulePass(ID), OS(o),
+          ShouldPreserveUseListOrder(ShouldPreserveUseListOrder) {}
+
+    const char *getPassName() const override { return "Bitcode Writer"; }
+
+    bool runOnModule(Module &M) override {
+      WriteBitcodeToFile(&M, OS, ShouldPreserveUseListOrder);
       return false;
     }
   };
@@ -33,10 +45,7 @@ namespace {
 
 char WriteBitcodePass::ID = 0;
 
-/// CreateBitcodeWriterPass - Create and return a pass that writes the module
-/// to the specified ostream.
-ModulePass *llvm::CreateBitcodeWriterPass(std::ostream &Str) {
-  return new WriteBitcodePass(Str);
+ModulePass *llvm::createBitcodeWriterPass(raw_ostream &Str,
+                                          bool ShouldPreserveUseListOrder) {
+  return new WriteBitcodePass(Str, ShouldPreserveUseListOrder);
 }
-
-