[clang] [clang] Fix include behavior for leading double slashes (PR #213689)

QIU Chaofan via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 3 07:47:22 PDT 2026


https://github.com/ecnelises created https://github.com/llvm/llvm-project/pull/213689

Fixes #133174 

>From 20543a326459d005f00e23ca867fc5cac8f40202 Mon Sep 17 00:00:00 2001
From: Qiu Chaofan <qcf at ecnelises.com>
Date: Mon, 3 Aug 2026 22:36:06 +0800
Subject: [PATCH] [clang] Fix include behavior for leading double slashes

---
 clang/lib/Lex/HeaderSearch.cpp                         | 2 +-
 clang/test/Preprocessor/include-leading-double-slash.c | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/Preprocessor/include-leading-double-slash.c

diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index ecd80db10f2bd..eddec19405211 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -968,7 +968,7 @@ OptionalFileEntryRef HeaderSearch::LookupFile(
     *SuggestedModule = ModuleMap::KnownHeader();
 
   // If 'Filename' is absolute, check to see if it exists and no searching.
-  if (llvm::sys::path::is_absolute(Filename)) {
+  if (llvm::sys::path::is_absolute_gnu(Filename)) {
     CurDir = nullptr;
 
     // If this was an #include_next "/absolute/file", fail.
diff --git a/clang/test/Preprocessor/include-leading-double-slash.c b/clang/test/Preprocessor/include-leading-double-slash.c
new file mode 100644
index 0000000000000..d1235ab1bc02c
--- /dev/null
+++ b/clang/test/Preprocessor/include-leading-double-slash.c
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 %s -verify
+
+#include "//stddef.h" // expected-error {{'//stddef.h' file not found}}



More information about the cfe-commits mailing list