Index: include/llvm/Transforms/Utils/SpecialCaseList.h =================================================================== --- include/llvm/Transforms/Utils/SpecialCaseList.h +++ include/llvm/Transforms/Utils/SpecialCaseList.h @@ -73,6 +73,11 @@ ~SpecialCaseList(); + /// Returns whether this type string is listed in the given category, + /// which may be ommitted to search the empty category. + bool isIn(const StringRef TypeStr, + const StringRef Category = StringRef()) const; + /// Returns whether either this function or its source file are listed in the /// given category, which may be omitted to search the empty category. bool isIn(const Function &F, const StringRef Category = StringRef()) const; Index: lib/Transforms/Utils/SpecialCaseList.cpp =================================================================== --- lib/Transforms/Utils/SpecialCaseList.cpp +++ lib/Transforms/Utils/SpecialCaseList.cpp @@ -168,6 +168,11 @@ } } +bool SpecialCaseList::isIn(const StringRef TypeStr, + const StringRef Category) const { + return inSectionCategory("type", TypeStr, Category); +} + bool SpecialCaseList::isIn(const Function& F, const StringRef Category) const { return isIn(*F.getParent(), Category) || inSectionCategory("fun", F.getName(), Category); Index: unittests/Transforms/Utils/SpecialCaseList.cpp =================================================================== --- unittests/Transforms/Utils/SpecialCaseList.cpp +++ unittests/Transforms/Utils/SpecialCaseList.cpp @@ -102,6 +102,23 @@ EXPECT_FALSE(SCL->isIn(*Bar, "functional")); } +TEST_F(SpecialCaseListTest, TypeIsIn) { + Module M("hello", Ctx); + GlobalVariable *Bar = makeGlobal("bar", "bar_t", M); + + std::unique_ptr SCL(makeSpecialCaseList("type:bar_t\n")); + EXPECT_TRUE(SCL->isIn(*Bar)); + + SCL.reset(makeSpecialCaseList("type:b*\n")); + EXPECT_TRUE(SCL->isIn(*Bar)); + + SCL.reset(makeSpecialCaseList("type:*_t\n")); + EXPECT_TRUE(SCL->isIn(*Bar)); + + SCL.reset(makeSpecialCaseList("type:bar\n")); + EXPECT_FALSE(SCL->isIn(*Bar)); +} + TEST_F(SpecialCaseListTest, GlobalIsIn) { Module M("hello", Ctx); GlobalVariable *Foo = makeGlobal("foo", "t1", M);