Skip to content

Commit ee6c92f

Browse files
authored
1 parent 400faf9 commit ee6c92f

File tree

1 file changed

+17
-30
lines changed

1 file changed

+17
-30
lines changed

clang/unittests/Basic/DiagnosticTest.cpp

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "llvm/Support/VirtualFileSystem.h"
2222
#include "gmock/gmock.h"
2323
#include "gtest/gtest.h"
24-
#include <algorithm>
2524
#include <memory>
2625
#include <optional>
2726
#include <vector>
@@ -296,35 +295,23 @@ TEST_F(SuppressionMappingTest, EmitCategoryIsExcluded) {
296295
}
297296

298297
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")));
328315
}
329316

330317
TEST_F(SuppressionMappingTest, LongShortMatch) {

0 commit comments

Comments
 (0)