File tree Expand file tree Collapse file tree 3 files changed +29
-2
lines changed Expand file tree Collapse file tree 3 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ static bool consumeNegativeIndicator(StringRef &GlobList) {
27
27
// Converts first glob from the comma-separated list of globs to Regex and
28
28
// removes it and the trailing comma from the GlobList.
29
29
static llvm::Regex consumeGlob (StringRef &GlobList) {
30
- StringRef UntrimmedGlob = GlobList.substr (0 , GlobList.find ( ' , ' ));
30
+ StringRef UntrimmedGlob = GlobList.substr (0 , GlobList.find_first_of ( " , \n " ));
31
31
StringRef Glob = UntrimmedGlob.trim ();
32
32
GlobList = GlobList.substr (UntrimmedGlob.size () + 1 );
33
33
SmallString<128 > RegexText (" ^" );
@@ -44,7 +44,7 @@ static llvm::Regex consumeGlob(StringRef &GlobList) {
44
44
}
45
45
46
46
GlobList::GlobList (StringRef Globs, bool KeepNegativeGlobs /* =true */ ) {
47
- Items.reserve (Globs.count (' ,' ) + 1 );
47
+ Items.reserve (Globs.count (' ,' ) + Globs. count ( ' \n ' ) + 1 );
48
48
do {
49
49
GlobListItem Item;
50
50
Item.IsPositive = !consumeNegativeIndicator (Globs);
Original file line number Diff line number Diff line change @@ -86,6 +86,20 @@ TEST(ParseConfiguration, ValidConfiguration) {
86
86
EXPECT_EQ (" some.user" , *Options->User );
87
87
}
88
88
89
+ TEST (ParseConfiguration, ChecksSeparatedByNewlines) {
90
+ auto MemoryBuffer = llvm::MemoryBufferRef (" Checks: |\n "
91
+ " -*,misc-*\n "
92
+ " llvm-*\n "
93
+ " -clang-*,\n "
94
+ " google-*" ,
95
+ " Options" );
96
+
97
+ auto Options = parseConfiguration (MemoryBuffer);
98
+
99
+ EXPECT_TRUE (!!Options);
100
+ EXPECT_EQ (" -*,misc-*\n llvm-*\n -clang-*,\n google-*\n " , *Options->Checks );
101
+ }
102
+
89
103
TEST (ParseConfiguration, MergeConfigurations) {
90
104
llvm::ErrorOr<ClangTidyOptions> Options1 =
91
105
parseConfiguration (llvm::MemoryBufferRef (R"(
Original file line number Diff line number Diff line change @@ -104,5 +104,18 @@ TYPED_TEST(GlobListTest, Complex) {
104
104
EXPECT_TRUE (Filter.contains (" asdfqwEasdf" ));
105
105
}
106
106
107
+ TYPED_TEST (GlobListTest, NewlineCharactersAsSeparators) {
108
+ TypeParam Filter (" a* \n b,\n -c*,dd" );
109
+
110
+ EXPECT_FALSE (Filter.contains (" " ));
111
+ EXPECT_TRUE (Filter.contains (" aaa" ));
112
+ EXPECT_TRUE (Filter.contains (" b" ));
113
+ EXPECT_FALSE (Filter.contains (" c" ));
114
+ EXPECT_FALSE (Filter.contains (" ccc" ));
115
+ EXPECT_FALSE (Filter.contains (" d" ));
116
+ EXPECT_TRUE (Filter.contains (" dd" ));
117
+ EXPECT_FALSE (Filter.contains (" ddd" ));
118
+ }
119
+
107
120
} // namespace tidy
108
121
} // namespace clang
You can’t perform that action at this time.
0 commit comments