[clang] Revert "[clang][Lex] add -Wnonportable-include-path-separator (#186770)" (PR #190975)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 8 06:53:37 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Rose Hudson (rosefromthedead)
<details>
<summary>Changes</summary>
This reverts commit 9a1860c45a915328b392fa1af0bbc75dbe96af7f.
Due to a compile-time regression: https://llvm-compile-time-tracker.com/compare.php?from=c146e9fce8b46f2495a57c8ce7696da4da9d2a13&to=9a1860c45a915328b392fa1af0bbc75dbe96af7f&stat=instructions:u
---
Full diff: https://github.com/llvm/llvm-project/pull/190975.diff
6 Files Affected:
- (modified) clang/docs/ReleaseNotes.rst (-6)
- (modified) clang/include/clang/Basic/DiagnosticGroups.td (-3)
- (modified) clang/include/clang/Basic/DiagnosticLexKinds.td (+1-4)
- (modified) clang/include/clang/Basic/SourceManager.h (-9)
- (modified) clang/lib/Lex/PPDirectives.cpp (-11)
- (removed) clang/test/Lexer/backslash-include-win.c (-22)
``````````diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 2da7175b51ea3..f6c0eb1e18d14 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -360,12 +360,6 @@ Improvements to Clang's diagnostics
- Clang now emits an error when implicitly casting a complex type to a built-in vector type. (#GH186805)
-- Added ``-Wnonportable-include-path-separator`` (off by default) to catch
- #include directives that use backslashes as a path separator. The warning
- includes a FixIt to change all the backslashes to forward slashes, so that the
- code can automatically be made portable to other host platforms that don't
- support backslashes.
-
Improvements to Clang's time-trace
----------------------------------
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td
index 98902b3d9caa8..52b786c46bd7c 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -176,9 +176,6 @@ def NullConversion : DiagGroup<"null-conversion">;
def ImplicitConversionFloatingPointToBool :
DiagGroup<"implicit-conversion-floating-point-to-bool">;
def ObjCLiteralConversion : DiagGroup<"objc-literal-conversion">;
-def NonportableIncludePathSeparator : DiagGroup<"nonportable-include-path-separator">;
-def NonportableIncludePath : DiagGroup<"nonportable-include-path",
- [NonportableIncludePathSeparator]>;
def MacroRedefined : DiagGroup<"macro-redefined">;
def BuiltinMacroRedefined : DiagGroup<"builtin-macro-redefined">;
def BuiltinRequiresHeader : DiagGroup<"builtin-requires-header">;
diff --git a/clang/include/clang/Basic/DiagnosticLexKinds.td b/clang/include/clang/Basic/DiagnosticLexKinds.td
index 07afc69793499..bea0aafac98cf 100644
--- a/clang/include/clang/Basic/DiagnosticLexKinds.td
+++ b/clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -377,12 +377,9 @@ class NonportablePath : Warning<
"non-portable path to file '%0'; specified path differs in case from file"
" name on disk">;
def pp_nonportable_path : NonportablePath,
- InGroup<NonportableIncludePath>;
+ InGroup<DiagGroup<"nonportable-include-path">>;
def pp_nonportable_system_path : NonportablePath, DefaultIgnore,
InGroup<DiagGroup<"nonportable-system-include-path">>;
-def pp_nonportable_path_separator : Warning<
- "non-portable path to file '%0'; specified path contains backslashes">,
- DefaultIgnore, InGroup<NonportableIncludePathSeparator>;
def pp_pragma_once_in_main_file : Warning<"#pragma once in main file">,
InGroup<DiagGroup<"pragma-once-outside-header">>;
diff --git a/clang/include/clang/Basic/SourceManager.h b/clang/include/clang/Basic/SourceManager.h
index 4217b8683da1e..bc9e97863556d 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -1526,15 +1526,6 @@ class SourceManager : public RefCountedBase<SourceManager> {
return Filename == "<scratch space>";
}
- /// Returns whether \p Loc is located in a <module-includes> file.
- bool isWrittenInModuleIncludes(SourceLocation Loc) const {
- PresumedLoc Presumed = getPresumedLoc(Loc);
- if (Presumed.isInvalid())
- return false;
- StringRef Filename(Presumed.getFilename());
- return Filename == "<module-includes>";
- }
-
/// Returns whether \p Loc is located in a built-in or command line source.
bool isInPredefinedFile(SourceLocation Loc) const {
PresumedLoc Presumed = getPresumedLoc(Loc);
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 172c2fa57db00..b90c04776ff9e 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -2731,17 +2731,6 @@ Preprocessor::ImportAction Preprocessor::HandleHeaderIncludeOrImport(
Diag(FilenameTok, DiagId) << Path <<
FixItHint::CreateReplacement(FilenameRange, Path);
}
-
- bool SuppressBackslashDiag =
- FilenameLoc.isMacroID() ||
- SourceMgr.isWrittenInBuiltinFile(FilenameLoc) ||
- SourceMgr.isWrittenInModuleIncludes(FilenameLoc);
- if (!SuppressBackslashDiag && OriginalFilename.contains('\\')) {
- std::string SuggestedPath = OriginalFilename.str();
- llvm::replace(SuggestedPath, '\\', '/');
- Diag(FilenameTok, diag::pp_nonportable_path_separator)
- << Name << FixItHint::CreateReplacement(FilenameRange, SuggestedPath);
- }
}
switch (Action) {
diff --git a/clang/test/Lexer/backslash-include-win.c b/clang/test/Lexer/backslash-include-win.c
deleted file mode 100644
index a07325550093f..0000000000000
--- a/clang/test/Lexer/backslash-include-win.c
+++ /dev/null
@@ -1,22 +0,0 @@
-// REQUIRES: system-windows
-// RUN: mkdir -p %t/backslash
-// RUN: cp %S/Inputs/case-insensitive-include.h %t/backslash/case-insensitive-include.h
-// RUN: %clang_cc1 -fsyntax-only -Wnonportable-include-path-separator -I%t %s 2>&1 | FileCheck --check-prefixes=CHECK-ENABLED,CHECK-ALL %s
-// RUN: %clang_cc1 -fsyntax-only -Wnonportable-include-path -Wno-nonportable-include-path-separator -I%t %s 2>&1 | FileCheck --check-prefix=CHECK-DISABLED,CHECK-ALL %s
-
-#include "backslash\case-insensitive-include.h"
-// CHECK-ENABLED: non-portable path to file
-// CHECK-ENABLED: specified path contains backslashes
-// CHECK-ENABLED: "backslash/case-insensitive-include.h"
-// CHECK-DISABLED-NOT: non-portable path to file
-
-// Despite fixing the same span, nonportable-include-path is still a separate diagnostic
-// that can fire at the same time.
-#include "backslash\CASE-insensitive-include.h"
-// CHECK-ALL: non-portable path to file
-// CHECK-ALL: specified path differs in case from file name on disk
-// CHECK-ALL: "backslash\case-insensitive-include.h"
-// CHECK-ENABLED: non-portable path to file
-// CHECK-ENABLED: specified path contains backslashes
-// CHECK-ENABLED: "backslash/CASE-insensitive-include.h"
-// CHECK-DISABLED-NOT: non-portable path to file
``````````
</details>
https://github.com/llvm/llvm-project/pull/190975
More information about the cfe-commits
mailing list