[change-namespace] fix asan failure in r296110.

llvm-svn: 296113
This commit is contained in:
Eric Liu 2017-02-24 12:56:51 +00:00
parent ebc35129e5
commit 4c8767fa55
1 changed files with 9 additions and 8 deletions

View File

@ -80,15 +80,16 @@ cl::opt<std::string> WhiteListFile(
cl::init(""), cl::cat(ChangeNamespaceCategory));
llvm::ErrorOr<std::vector<std::string>> GetWhiteListedSymbolPatterns() {
if (WhiteListFile.empty())
return std::vector<std::string>();
llvm::SmallVector<StringRef, 8> Lines;
if (!WhiteListFile.empty()) {
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> File =
llvm::MemoryBuffer::getFile(WhiteListFile);
if (!File)
return File.getError();
llvm::StringRef Content = File.get()->getBuffer();
Content.split(Lines, '\n', /*MaxSplit=*/-1, /*KeepEmpty=*/false);
}
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> File =
llvm::MemoryBuffer::getFile(WhiteListFile);
if (!File)
return File.getError();
llvm::StringRef Content = File.get()->getBuffer();
Content.split(Lines, '\n', /*MaxSplit=*/-1, /*KeepEmpty=*/false);
return std::vector<std::string>(Lines.begin(), Lines.end());
}