[PATCH] D112996: [CodeCompletion] Generally consider header files without extension
Christian Kandeler via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 8 04:25:19 PST 2021
ckandeler updated this revision to Diff 385453.
ckandeler added a comment.
Addressed formatting comments.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D112996/new/
https://reviews.llvm.org/D112996
Files:
clang/lib/Sema/SemaCodeComplete.cpp
Index: clang/lib/Sema/SemaCodeComplete.cpp
===================================================================
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -9613,6 +9613,10 @@
}
}
+ const StringRef &Dirname = llvm::sys::path::filename(Dir);
+ const bool isQt = Dirname.startswith("Qt") || Dirname == "ActiveQt";
+ const bool ExtensionlessHeaders =
+ IsSystem || isQt || Dir.endswith(".framework/Headers");
std::error_code EC;
unsigned Count = 0;
for (auto It = FS.dir_begin(Dir, EC);
@@ -9639,18 +9643,19 @@
AddCompletion(Filename, /*IsDirectory=*/true);
break;
- case llvm::sys::fs::file_type::regular_file:
- // Only files that really look like headers. (Except in system dirs).
- if (!IsSystem) {
- // Header extensions from Types.def, which we can't depend on here.
- if (!(Filename.endswith_insensitive(".h") ||
- Filename.endswith_insensitive(".hh") ||
- Filename.endswith_insensitive(".hpp") ||
- Filename.endswith_insensitive(".inc")))
- break;
- }
+ case llvm::sys::fs::file_type::regular_file: {
+ // Only files that really look like headers. (Except in special dirs).
+ // Header extensions from Types.def, which we can't depend on here.
+ const bool IsHeader = Filename.endswith_insensitive(".h") ||
+ Filename.endswith_insensitive(".hh") ||
+ Filename.endswith_insensitive(".hpp") ||
+ Filename.endswith_insensitive(".inc") ||
+ (ExtensionlessHeaders && !Filename.contains('.'));
+ if (!IsHeader)
+ break;
AddCompletion(Filename, /*IsDirectory=*/false);
break;
+ }
default:
break;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112996.385453.patch
Type: text/x-patch
Size: 1903 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211108/aa127fad/attachment.bin>
More information about the cfe-commits
mailing list