diff options
| author | Fangrui Song <maskray@google.com> | 2019-04-02 09:11:18 +0000 | 
|---|---|---|
| committer | Fangrui Song <maskray@google.com> | 2019-04-02 09:11:18 +0000 | 
| commit | 32029135e0976b8d3346bc93820dde50bd5a942f (patch) | |
| tree | f486c744c0bb0af90cbbe6d3b478b15bc3221065 /llvm | |
| parent | 821263faa56af1ac2e0466d1c41df48018963bcb (diff) | |
| download | bcm5719-llvm-32029135e0976b8d3346bc93820dde50bd5a942f.tar.gz bcm5719-llvm-32029135e0976b8d3346bc93820dde50bd5a942f.zip  | |
[Internalize] Replace fstream with line_iterator for -internalize-public-api-file
This makes my libLLVMipo.so.9svn smaller by 360 bytes.
llvm-svn: 357457
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Transforms/IPO/Internalize.cpp | 16 | 
1 files changed, 7 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/IPO/Internalize.cpp b/llvm/lib/Transforms/IPO/Internalize.cpp index 008817c3c59..8423a8a4d71 100644 --- a/llvm/lib/Transforms/IPO/Internalize.cpp +++ b/llvm/lib/Transforms/IPO/Internalize.cpp @@ -27,10 +27,11 @@  #include "llvm/Pass.h"  #include "llvm/Support/CommandLine.h"  #include "llvm/Support/Debug.h" +#include "llvm/Support/LineIterator.h" +#include "llvm/Support/MemoryBuffer.h"  #include "llvm/Support/raw_ostream.h"  #include "llvm/Transforms/IPO.h"  #include "llvm/Transforms/Utils/GlobalStatus.h" -#include <fstream>  #include <set>  using namespace llvm; @@ -72,18 +73,15 @@ private:    void LoadFile(StringRef Filename) {      // Load the APIFile... -    std::ifstream In(Filename.data()); -    if (!In.good()) { +    ErrorOr<std::unique_ptr<MemoryBuffer>> Buf = +        MemoryBuffer::getFile(Filename); +    if (!Buf) {        errs() << "WARNING: Internalize couldn't load file '" << Filename               << "'! Continuing as if it's empty.\n";        return; // Just continue as if the file were empty      } -    while (In) { -      std::string Symbol; -      In >> Symbol; -      if (!Symbol.empty()) -        ExternalNames.insert(Symbol); -    } +    for (line_iterator I(*Buf->get(), true), E; I != E; ++I) +      ExternalNames.insert(*I);    }  };  } // end anonymous namespace  | 

