Skip to content

Commit 90a69e2

Browse files
committed
Enable only on windows
1 parent 6b4efe7 commit 90a69e2

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

clang/unittests/Basic/DiagnosticTest.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,8 @@ TEST_F(SuppressionMappingTest, ParsingRespectsOtherWarningOpts) {
361361
EXPECT_THAT(diags(), IsEmpty());
362362
}
363363

364+
#ifdef _WIN32
365+
// We're only slash-agnostic on windows hosts
364366
TEST_F(SuppressionMappingTest, ForwardSlashMatchesBothDirections) {
365367
llvm::StringLiteral SuppressionMappingFile = R"(
366368
[unused]
@@ -383,4 +385,5 @@ TEST_F(SuppressionMappingTest, ForwardSlashMatchesBothDirections) {
383385
EXPECT_FALSE(Diags.isSuppressedViaMapping(
384386
diag::warn_unused_function, locForFile(R"(clang/lib/Sema/foo.h)")));
385387
}
388+
#endif
386389
} // namespace

llvm/docs/ReleaseNotes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,9 @@ Changes to BOLT
165165
Changes to Sanitizers
166166
---------------------
167167

168-
* The [sanitizer special case list format](https://clang.llvm.org/docs/SanitizerSpecialCaseList.html#format)
168+
* On windows hosts, the [sanitizer special case list format](https://clang.llvm.org/docs/SanitizerSpecialCaseList.html#format)
169169
now treats forward slashes as either a forward or a backslash, to handle
170-
paths with mixed unix and window styles.
170+
paths with mixed unix and windows styles.
171171

172172
Other Changes
173173
-------------

llvm/include/llvm/Support/GlobPattern.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ namespace llvm {
3535
/// expansions are not supported. If \p MaxSubPatterns is empty then
3636
/// brace expansions are not supported and characters `{,}` are treated as
3737
/// literals.
38-
/// * `/` matches both unix and windows path separators: `/` and `\`.
38+
/// * If IsSlashAgnostic is passed, `/` matches both unix and windows path
39+
/// separators: `/` and `\`.
3940
/// * `\` escapes the next character so it is treated as a literal.
4041
///
4142
/// Some known edge cases are:

llvm/lib/Support/SpecialCaseList.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#include "llvm/Support/LineIterator.h"
1919
#include "llvm/Support/MemoryBuffer.h"
2020
#include "llvm/Support/VirtualFileSystem.h"
21+
#include "llvm/TargetParser/Host.h"
22+
#include "llvm/TargetParser/Triple.h"
2123
#include <stdio.h>
2224
#include <string>
2325
#include <system_error>
@@ -57,10 +59,12 @@ Error SpecialCaseList::Matcher::insert(StringRef Pattern, unsigned LineNumber,
5759
auto Glob = std::make_unique<Matcher::Glob>();
5860
Glob->Name = Pattern.str();
5961
Glob->LineNo = LineNumber;
62+
// Backslashes are valid in posix-style filenames.
63+
bool IsSlashAgnostic = Triple(sys::getDefaultTargetTriple()).isOSWindows();
6064
// We must be sure to use the string in `Glob` rather than the provided
6165
// reference which could be destroyed before match() is called
6266
if (auto Err = GlobPattern::create(Glob->Name, /*MaxSubPatterns=*/1024,
63-
/*IsSlashAgnostic=*/true)
67+
/*IsSlashAgnostic=*/IsSlashAgnostic)
6468
.moveInto(Glob->Pattern))
6569
return Err;
6670
Globs.push_back(std::move(Glob));

0 commit comments

Comments
 (0)