[llvm] r185976 - Introduce a SpecialCaseList ctor which takes a MemoryBuffer to make

Peter Collingbourne peter at pcc.me.uk
Tue Jul 9 15:03:09 PDT 2013


Author: pcc
Date: Tue Jul  9 17:03:09 2013
New Revision: 185976

URL: http://llvm.org/viewvc/llvm-project?rev=185976&view=rev
Log:
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

Modified:
    llvm/trunk/include/llvm/Transforms/Utils/SpecialCaseList.h
    llvm/trunk/lib/Transforms/Utils/SpecialCaseList.cpp

Modified: llvm/trunk/include/llvm/Transforms/Utils/SpecialCaseList.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/SpecialCaseList.h?rev=185976&r1=185975&r2=185976&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/Utils/SpecialCaseList.h (original)
+++ llvm/trunk/include/llvm/Transforms/Utils/SpecialCaseList.h Tue Jul  9 17:03:09 2013
@@ -35,6 +35,7 @@
 namespace llvm {
 class Function;
 class GlobalVariable;
+class MemoryBuffer;
 class Module;
 class Regex;
 class StringRef;
@@ -42,6 +43,8 @@ class StringRef;
 class SpecialCaseList {
  public:
   SpecialCaseList(const StringRef Path);
+  SpecialCaseList(const 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 @@ class SpecialCaseList {
  private:
   StringMap<Regex*> Entries;
 
+  void init(const MemoryBuffer *MB);
   bool inSection(const StringRef Section, const StringRef Query) const;
 };
 

Modified: llvm/trunk/lib/Transforms/Utils/SpecialCaseList.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SpecialCaseList.cpp?rev=185976&r1=185975&r2=185976&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SpecialCaseList.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SpecialCaseList.cpp Tue Jul  9 17:03:09 2013
@@ -39,9 +39,17 @@ SpecialCaseList::SpecialCaseList(const S
                        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) {





More information about the llvm-commits mailing list