-bool SpecialCaseList::isInInit(const GlobalVariable &G) const {
- return (isIn(*G.getParent()) ||
- inSection("global-init", G.getName()) ||
- inSection("global-init-type", GetGVTypeString(G)) ||
- inSection("global-init-src", G.getParent()->getModuleIdentifier()));
+bool SpecialCaseList::findCategory(const GlobalVariable &G,
+ StringRef &Category) const {
+ return findCategory(*G.getParent(), Category) ||
+ findCategory("global", G.getName(), Category) ||
+ findCategory("type", GetGVTypeString(G), Category);
+}
+
+bool SpecialCaseList::isIn(const GlobalVariable &G,
+ const StringRef Category) const {
+ return isIn(*G.getParent(), Category) ||
+ inSectionCategory("global", G.getName(), Category) ||
+ inSectionCategory("type", GetGVTypeString(G), Category);
+}
+
+bool SpecialCaseList::findCategory(const Module &M, StringRef &Category) const {
+ return findCategory("src", M.getModuleIdentifier(), Category);
+}
+
+bool SpecialCaseList::isIn(const Module &M, const StringRef Category) const {
+ return inSectionCategory("src", M.getModuleIdentifier(), Category);
+}
+
+bool SpecialCaseList::findCategory(const StringRef Section,
+ const StringRef Query,
+ StringRef &Category) const {
+ StringMap<StringMap<Regex *> >::const_iterator I = Entries.find(Section);
+ if (I == Entries.end()) return false;
+
+ for (StringMap<Regex *>::const_iterator II = I->second.begin(),
+ IE = I->second.end();
+ II != IE; ++II) {
+ Regex *FunctionRegex = II->getValue();
+ if (FunctionRegex->match(Query)) {
+ Category = II->first();
+ return true;
+ }
+ }
+
+ return false;