Skip to content

Conversation

@HazardyKnusperkeks
Copy link
Contributor

... 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.

... 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.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Nov 4, 2025
@llvmbot
Copy link
Member

llvmbot commented Nov 4, 2025

@llvm/pr-subscribers-clang

Author: Björn Schäpers (HazardyKnusperkeks)

Changes

... 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.


Full diff: https://github.com/llvm/llvm-project/pull/166447.diff

2 Files Affected:

  • (modified) clang/lib/Sema/SemaCodeComplete.cpp (+3-2)
  • (modified) clang/test/CodeCompletion/included-files.cpp (+7-2)
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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants