[PATCH] D34231: Add ability to retrieve all entries within a section in SpecialCaseList

Enes Goktas via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 14 22:26:20 PDT 2017


egoktas created this revision.
egoktas created this object with visibility "All Users".

Extend SpecialCaseList with the capability to return all entries within a given section and optionally within a specific category.

This ability is required by the patch that extends the Control-Flow Integrity feature in clang. This patch to clang allows the explicit linking of classes through a sanitizer blacklist file.


https://reviews.llvm.org/D34231

Files:
  include/llvm/Support/SpecialCaseList.h
  lib/Support/SpecialCaseList.cpp


Index: lib/Support/SpecialCaseList.cpp
===================================================================
--- lib/Support/SpecialCaseList.cpp
+++ lib/Support/SpecialCaseList.cpp
@@ -169,4 +169,16 @@
   return II->getValue().match(Query);
 }
 
+void SpecialCaseList::getEntriesInSection(StringRef Section,
+                                          StringSet<>& EntriesOut,
+                                          StringRef Category) const {
+  assert(IsCompiled && "SpecialCaseList::compile() was not called!");
+  StringMap<StringMap<Entry> >::const_iterator I = Entries.find(Section);
+  if (I == Entries.end()) return;
+  StringMap<Entry>::const_iterator II = I->second.find(Category);
+  if (II == I->second.end()) return;
+
+  EntriesOut = II->getValue().Strings;
+}
+
 }  // namespace llvm
Index: include/llvm/Support/SpecialCaseList.h
===================================================================
--- include/llvm/Support/SpecialCaseList.h
+++ include/llvm/Support/SpecialCaseList.h
@@ -49,6 +49,7 @@
 #define LLVM_SUPPORT_SPECIALCASELIST_H
 
 #include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringSet.h"
 #include <string>
 #include <vector>
 
@@ -82,6 +83,9 @@
   bool inSection(StringRef Section, StringRef Query,
                  StringRef Category = StringRef()) const;
 
+  void getEntriesInSection(StringRef Section, StringSet<>& EntriesOut,
+                           StringRef Category = StringRef()) const;
+
 private:
   SpecialCaseList(SpecialCaseList const &) = delete;
   SpecialCaseList &operator=(SpecialCaseList const &) = delete;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34231.102636.patch
Type: text/x-patch
Size: 1571 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170615/8ebc40d2/attachment.bin>


More information about the llvm-commits mailing list