[PATCH] D132833: [clangd] Fail more gracefully if QueryDriverDatabase cannot determine file type

Nathan Ridge via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 29 01:27:53 PDT 2022


nridge created this revision.
nridge added reviewers: kadircet, sammccall.
Herald added a subscriber: arphaman.
Herald added a project: All.
nridge requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Currently, QueryDriverDatabase returns an empty compile command
if it could not determine the file type.

This failure mode is unnecessarily destructive; it's better to
just return the incoming compiler command, which is still more
likely to be useful than an empty command.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132833

Files:
  clang-tools-extra/clangd/QueryDriverDatabase.cpp


Index: clang-tools-extra/clangd/QueryDriverDatabase.cpp
===================================================================
--- clang-tools-extra/clangd/QueryDriverDatabase.cpp
+++ clang-tools-extra/clangd/QueryDriverDatabase.cpp
@@ -341,7 +341,7 @@
       auto Type = driver::types::lookupTypeForExtension(Ext);
       if (Type == driver::types::TY_INVALID) {
         elog("System include extraction: invalid file type for {0}", Ext);
-        return {};
+        return Cmd;
       }
       Lang = driver::types::getTypeName(Type);
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132833.456280.patch
Type: text/x-patch
Size: 542 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220829/0088d6ea/attachment.bin>


More information about the cfe-commits mailing list