[PATCH] Introduce a GlobalList ctor which takes a MemoryBuffer to make it more unit testable.
Peter Collingbourne
peter at pcc.me.uk
Wed Jul 3 19:03:34 PDT 2013
Hi kcc,
http://llvm-reviews.chandlerc.com/D1090
Files:
include/llvm/Transforms/Utils/GlobalList.h
lib/Transforms/Utils/GlobalList.cpp
Index: include/llvm/Transforms/Utils/GlobalList.h
===================================================================
--- include/llvm/Transforms/Utils/GlobalList.h
+++ include/llvm/Transforms/Utils/GlobalList.h
@@ -35,13 +35,16 @@
namespace llvm {
class Function;
class GlobalVariable;
+class MemoryBuffer;
class Module;
class Regex;
class StringRef;
class GlobalList {
public:
GlobalList(const StringRef Path);
+ GlobalList(MemoryBuffer *MB);
+
// Returns whether either this function or it's source file are blacklisted.
bool isIn(const Function &F) const;
// Returns whether either this global or it's source file are blacklisted.
@@ -53,6 +56,7 @@
private:
StringMap<Regex*> Entries;
+ void init(MemoryBuffer *MB);
bool inSection(const StringRef Section, const StringRef Query) const;
};
Index: lib/Transforms/Utils/GlobalList.cpp
===================================================================
--- lib/Transforms/Utils/GlobalList.cpp
+++ lib/Transforms/Utils/GlobalList.cpp
@@ -39,9 +39,17 @@
EC.message());
}
+ init(File.take());
+}
+
+GlobalList::GlobalList(MemoryBuffer *MB) {
+ init(MB);
+}
+
+void GlobalList::init(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 (SmallVector<StringRef, 16>::iterator I = Lines.begin(), E = Lines.end();
I != E; ++I) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1090.1.patch
Type: text/x-patch
Size: 1555 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130703/15a40559/attachment.bin>
More information about the llvm-commits
mailing list