https://github.com/HazardyKnusperkeks created 
https://github.com/llvm/llvm-project/pull/166447

... the path passed to -I ends with /include.

I've brought it up, when the special handling for Qt was added 
(https://reviews.llvm.org/D112996#3349609) but got no feedback.

From 00630965ddf956654d5d00cb6f20259756af7280 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Sch=C3=A4pers?= <[email protected]>
Date: Tue, 4 Nov 2025 22:25:53 +0100
Subject: [PATCH] [CodeCompletion] Consider header files without extension,
 if...

... the path passed to -I ends with /include.

I've brought it up, when the special handling for Qt was added
(https://reviews.llvm.org/D112996#3349609) but got no feedback.
---
 clang/lib/Sema/SemaCodeComplete.cpp          | 5 +++--
 clang/test/CodeCompletion/included-files.cpp | 9 +++++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Sema/SemaCodeComplete.cpp 
b/clang/lib/Sema/SemaCodeComplete.cpp
index aa93507ab5c30..24b8e4bab0f88 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -10365,8 +10365,9 @@ void 
SemaCodeCompletion::CodeCompleteIncludedFile(llvm::StringRef Dir,
 
     const StringRef &Dirname = llvm::sys::path::filename(Dir);
     const bool isQt = Dirname.starts_with("Qt") || Dirname == "ActiveQt";
-    const bool ExtensionlessHeaders =
-        IsSystem || isQt || Dir.ends_with(".framework/Headers");
+    const bool ExtensionlessHeaders = IsSystem || isQt ||
+                                      Dir.ends_with(".framework/Headers") ||
+                                      IncludeDir.ends_with("/include");
     std::error_code EC;
     unsigned Count = 0;
     for (auto It = FS.dir_begin(Dir, EC);
diff --git a/clang/test/CodeCompletion/included-files.cpp 
b/clang/test/CodeCompletion/included-files.cpp
index 9ad3e28b21231..1ab8e5ee2ac21 100644
--- a/clang/test/CodeCompletion/included-files.cpp
+++ b/clang/test/CodeCompletion/included-files.cpp
@@ -1,6 +1,6 @@
-// RUN: rm -rf %t && mkdir %t && cp %s %t/main.cc && mkdir %t/a && mkdir 
%t/QtCore && mkdir %t/Headers %t/Some.framework %t/Some.framework/Headers
+// RUN: rm -rf %t && mkdir %t && cp %s %t/main.cc && mkdir %t/a && mkdir 
%t/QtCore && mkdir %t/Headers %t/Some.framework %t/Some.framework/Headers 
%t/include %t/include/Headers
 // RUN: touch %t/foo.h %t/foo.hxx %t/foo.cc %t/a/foosys %t/a/foosys.h 
%t/QtCore/foosys %t/QtCore/foo.h
-// RUN: touch %t/Headers/foosys %t/Headers/foo.h 
%t/Some.framework/Headers/foosys %t/Some.framework/Headers/foo.h
+// RUN: touch %t/Headers/foosys %t/Headers/foo.h 
%t/Some.framework/Headers/foosys %t/Some.framework/Headers/foo.h 
%t/include/Headers/foosys
 
 // Quoted string shows header-ish files from CWD, and all from system.
 #include "foo.h"
@@ -56,3 +56,8 @@
 // CHECK-8-NOT: foo.cc>
 // CHECK-8: foo.h>
 // CHECK-8-NOT: foosys>
+
+// But simply naming a directory "include" is enough to allow extension-less 
headers.
+#include <Headers/foosys>
+// RUN: %clang -fsyntax-only -isystem %t/a -I %t/include -Xclang 
-code-completion-at=%t/main.cc:61:21 %t/main.cc -fms-compatibility | FileCheck 
-check-prefix=CHECK-9 %s
+// CHECK-9: foosys>

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to