diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2013-07-09 22:03:09 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2013-07-09 22:03:09 +0000 |
commit | c5afb9ed5eb9aeb3eff5158e15844705e8a9ee2d (patch) | |
tree | 2ad39d3ae33f0ad65d0d88b152fe9f1dedc04572 /lib | |
parent | 405515d55f470d04ef75f653b7f1994329c9066b (diff) | |
download | external_llvm-c5afb9ed5eb9aeb3eff5158e15844705e8a9ee2d.zip external_llvm-c5afb9ed5eb9aeb3eff5158e15844705e8a9ee2d.tar.gz external_llvm-c5afb9ed5eb9aeb3eff5158e15844705e8a9ee2d.tar.bz2 |
Introduce a SpecialCaseList ctor which takes a MemoryBuffer to make
it more unit testable, and fix memory leak in the other ctor.
Differential Revision: http://llvm-reviews.chandlerc.com/D1090
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185976 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/Utils/SpecialCaseList.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/Transforms/Utils/SpecialCaseList.cpp b/lib/Transforms/Utils/SpecialCaseList.cpp index a1083e3..8f6802b 100644 --- a/lib/Transforms/Utils/SpecialCaseList.cpp +++ b/lib/Transforms/Utils/SpecialCaseList.cpp @@ -39,9 +39,17 @@ SpecialCaseList::SpecialCaseList(const StringRef Path) { EC.message()); } + init(File.get()); +} + +SpecialCaseList::SpecialCaseList(const MemoryBuffer *MB) { + init(MB); +} + +void SpecialCaseList::init(const MemoryBuffer *MB) { // Iterate through each line in the blacklist file. SmallVector<StringRef, 16> Lines; - SplitString(File.take()->getBuffer(), Lines, "\n\r"); + SplitString(MB->getBuffer(), Lines, "\n\r"); StringMap<std::string> Regexps; for (SmallVectorImpl<StringRef>::iterator I = Lines.begin(), E = Lines.end(); I != E; ++I) { |