[Internalize] Replace fstream with line_iterator for -internalize-public-api-file
This makes my libLLVMipo.so.9svn smaller by 360 bytes. llvm-svn: 357457
This commit is contained in:
parent
821263faa5
commit
32029135e0
|
@ -27,10 +27,11 @@
|
||||||
#include "llvm/Pass.h"
|
#include "llvm/Pass.h"
|
||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
|
#include "llvm/Support/LineIterator.h"
|
||||||
|
#include "llvm/Support/MemoryBuffer.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "llvm/Transforms/IPO.h"
|
#include "llvm/Transforms/IPO.h"
|
||||||
#include "llvm/Transforms/Utils/GlobalStatus.h"
|
#include "llvm/Transforms/Utils/GlobalStatus.h"
|
||||||
#include <fstream>
|
|
||||||
#include <set>
|
#include <set>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
|
@ -72,18 +73,15 @@ private:
|
||||||
|
|
||||||
void LoadFile(StringRef Filename) {
|
void LoadFile(StringRef Filename) {
|
||||||
// Load the APIFile...
|
// Load the APIFile...
|
||||||
std::ifstream In(Filename.data());
|
ErrorOr<std::unique_ptr<MemoryBuffer>> Buf =
|
||||||
if (!In.good()) {
|
MemoryBuffer::getFile(Filename);
|
||||||
|
if (!Buf) {
|
||||||
errs() << "WARNING: Internalize couldn't load file '" << Filename
|
errs() << "WARNING: Internalize couldn't load file '" << Filename
|
||||||
<< "'! Continuing as if it's empty.\n";
|
<< "'! Continuing as if it's empty.\n";
|
||||||
return; // Just continue as if the file were empty
|
return; // Just continue as if the file were empty
|
||||||
}
|
}
|
||||||
while (In) {
|
for (line_iterator I(*Buf->get(), true), E; I != E; ++I)
|
||||||
std::string Symbol;
|
ExternalNames.insert(*I);
|
||||||
In >> Symbol;
|
|
||||||
if (!Symbol.empty())
|
|
||||||
ExternalNames.insert(Symbol);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // end anonymous namespace
|
} // end anonymous namespace
|
||||||
|
|
Loading…
Reference in New Issue