|
21 | 21 | #include "llvm/Support/VirtualFileSystem.h" |
22 | 22 | #include "gmock/gmock.h" |
23 | 23 | #include "gtest/gtest.h" |
24 | | -#include <algorithm> |
25 | 24 | #include <memory> |
26 | 25 | #include <optional> |
27 | 26 | #include <vector> |
@@ -296,35 +295,23 @@ TEST_F(SuppressionMappingTest, EmitCategoryIsExcluded) { |
296 | 295 | } |
297 | 296 |
|
298 | 297 | TEST_F(SuppressionMappingTest, LongestMatchWins) { |
299 | | - StringRef Lines[] = { |
300 | | - "[unused]", |
301 | | - "src:*clang/*", |
302 | | - "src:*clang/lib/Sema/*", |
303 | | - "src:*clang/lib/Sema/*=emit", |
304 | | - "src:*clang/lib/Sema/foo*", |
305 | | - }; |
306 | | - llvm::MutableArrayRef<StringRef> Rules = Lines; |
307 | | - Rules = Rules.drop_front(); |
308 | | - llvm::sort(Rules); |
309 | | - |
310 | | - do { |
311 | | - Diags.getDiagnosticOptions().DiagnosticSuppressionMappingsFile = "foo.txt"; |
312 | | - std::string Contents = join(std::begin(Lines), std::end(Lines), "\n"); |
313 | | - FS->addFile("foo.txt", /*ModificationTime=*/{}, |
314 | | - llvm::MemoryBuffer::getMemBuffer(Contents)); |
315 | | - clang::ProcessWarningOptions(Diags, Diags.getDiagnosticOptions(), *FS); |
316 | | - EXPECT_THAT(diags(), IsEmpty()); |
317 | | - |
318 | | - EXPECT_TRUE(Diags.isSuppressedViaMapping( |
319 | | - diag::warn_unused_function, locForFile("clang/lib/Basic/foo.h"))) |
320 | | - << Contents; |
321 | | - EXPECT_FALSE(Diags.isSuppressedViaMapping( |
322 | | - diag::warn_unused_function, locForFile("clang/lib/Sema/bar.h"))) |
323 | | - << Contents; |
324 | | - EXPECT_TRUE(Diags.isSuppressedViaMapping( |
325 | | - diag::warn_unused_function, locForFile("clang/lib/Sema/foo.h"))) |
326 | | - << Contents; |
327 | | - } while (std::next_permutation(Rules.begin(), Rules.end())); |
| 298 | + llvm::StringLiteral SuppressionMappingFile = R"( |
| 299 | + [unused] |
| 300 | + src:*clang/* |
| 301 | + src:*clang/lib/Sema/*=emit |
| 302 | + src:*clang/lib/Sema/foo*)"; |
| 303 | + Diags.getDiagnosticOptions().DiagnosticSuppressionMappingsFile = "foo.txt"; |
| 304 | + FS->addFile("foo.txt", /*ModificationTime=*/{}, |
| 305 | + llvm::MemoryBuffer::getMemBuffer(SuppressionMappingFile)); |
| 306 | + clang::ProcessWarningOptions(Diags, Diags.getDiagnosticOptions(), *FS); |
| 307 | + EXPECT_THAT(diags(), IsEmpty()); |
| 308 | + |
| 309 | + EXPECT_TRUE(Diags.isSuppressedViaMapping( |
| 310 | + diag::warn_unused_function, locForFile("clang/lib/Basic/foo.h"))); |
| 311 | + EXPECT_FALSE(Diags.isSuppressedViaMapping( |
| 312 | + diag::warn_unused_function, locForFile("clang/lib/Sema/bar.h"))); |
| 313 | + EXPECT_TRUE(Diags.isSuppressedViaMapping(diag::warn_unused_function, |
| 314 | + locForFile("clang/lib/Sema/foo.h"))); |
328 | 315 | } |
329 | 316 |
|
330 | 317 | TEST_F(SuppressionMappingTest, LongShortMatch) { |
|
0 commit comments