mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-04 02:24:29 +00:00
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
This commit is contained in:
@ -35,6 +35,7 @@
|
|||||||
namespace llvm {
|
namespace llvm {
|
||||||
class Function;
|
class Function;
|
||||||
class GlobalVariable;
|
class GlobalVariable;
|
||||||
|
class MemoryBuffer;
|
||||||
class Module;
|
class Module;
|
||||||
class Regex;
|
class Regex;
|
||||||
class StringRef;
|
class StringRef;
|
||||||
@ -42,6 +43,8 @@ class StringRef;
|
|||||||
class SpecialCaseList {
|
class SpecialCaseList {
|
||||||
public:
|
public:
|
||||||
SpecialCaseList(const StringRef Path);
|
SpecialCaseList(const StringRef Path);
|
||||||
|
SpecialCaseList(const MemoryBuffer *MB);
|
||||||
|
|
||||||
// Returns whether either this function or it's source file are blacklisted.
|
// Returns whether either this function or it's source file are blacklisted.
|
||||||
bool isIn(const Function &F) const;
|
bool isIn(const Function &F) const;
|
||||||
// Returns whether either this global or it's source file are blacklisted.
|
// Returns whether either this global or it's source file are blacklisted.
|
||||||
@ -53,6 +56,7 @@ class SpecialCaseList {
|
|||||||
private:
|
private:
|
||||||
StringMap<Regex*> Entries;
|
StringMap<Regex*> Entries;
|
||||||
|
|
||||||
|
void init(const MemoryBuffer *MB);
|
||||||
bool inSection(const StringRef Section, const StringRef Query) const;
|
bool inSection(const StringRef Section, const StringRef Query) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -39,9 +39,17 @@ SpecialCaseList::SpecialCaseList(const StringRef Path) {
|
|||||||
EC.message());
|
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.
|
// Iterate through each line in the blacklist file.
|
||||||
SmallVector<StringRef, 16> Lines;
|
SmallVector<StringRef, 16> Lines;
|
||||||
SplitString(File.take()->getBuffer(), Lines, "\n\r");
|
SplitString(MB->getBuffer(), Lines, "\n\r");
|
||||||
StringMap<std::string> Regexps;
|
StringMap<std::string> Regexps;
|
||||||
for (SmallVectorImpl<StringRef>::iterator I = Lines.begin(), E = Lines.end();
|
for (SmallVectorImpl<StringRef>::iterator I = Lines.begin(), E = Lines.end();
|
||||||
I != E; ++I) {
|
I != E; ++I) {
|
||||||
|
Reference in New Issue
Block a user