[llvm] r186431 - Make SpecialCaseList match full strings, as documented, using anchors.
Peter Collingbourne
peter at pcc.me.uk
Tue Jul 16 10:56:08 PDT 2013
Author: pcc
Date: Tue Jul 16 12:56:07 2013
New Revision: 186431
URL: http://llvm.org/viewvc/llvm-project?rev=186431&view=rev
Log:
Make SpecialCaseList match full strings, as documented, using anchors.
Differential Revision: http://llvm-reviews.chandlerc.com/D1149
Modified:
llvm/trunk/lib/Transforms/Utils/SpecialCaseList.cpp
llvm/trunk/unittests/Transforms/Utils/SpecialCaseList.cpp
Modified: llvm/trunk/lib/Transforms/Utils/SpecialCaseList.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SpecialCaseList.cpp?rev=186431&r1=186430&r2=186431&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SpecialCaseList.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SpecialCaseList.cpp Tue Jul 16 12:56:07 2013
@@ -99,7 +99,7 @@ void SpecialCaseList::init(const MemoryB
// Add this regexp into the proper group by its prefix.
if (!Regexps[Prefix][Category].empty())
Regexps[Prefix][Category] += "|";
- Regexps[Prefix][Category] += Regexp;
+ Regexps[Prefix][Category] += "^" + Regexp + "$";
}
// Iterate through each of the prefixes, and create Regexs for them.
Modified: llvm/trunk/unittests/Transforms/Utils/SpecialCaseList.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Transforms/Utils/SpecialCaseList.cpp?rev=186431&r1=186430&r2=186431&view=diff
==============================================================================
--- llvm/trunk/unittests/Transforms/Utils/SpecialCaseList.cpp (original)
+++ llvm/trunk/unittests/Transforms/Utils/SpecialCaseList.cpp Tue Jul 16 12:56:07 2013
@@ -139,4 +139,20 @@ TEST_F(SpecialCaseListTest, GlobalIsIn)
EXPECT_TRUE(SCL->isIn(*Bar, "init"));
}
+TEST_F(SpecialCaseListTest, Substring) {
+ Module M("othello", Ctx);
+ Function *F = makeFunction("tomfoolery", M);
+ GlobalVariable *GV = makeGlobal("bartender", "t", M);
+
+ OwningPtr<SpecialCaseList> SCL(makeSpecialCaseList("src:hello\n"
+ "fun:foo\n"
+ "global:bar\n"));
+ EXPECT_FALSE(SCL->isIn(M));
+ EXPECT_FALSE(SCL->isIn(*F));
+ EXPECT_FALSE(SCL->isIn(*GV));
+
+ SCL.reset(makeSpecialCaseList("fun:*foo*\n"));
+ EXPECT_TRUE(SCL->isIn(*F));
+}
+
}
More information about the llvm-commits
mailing list