llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clangd

Author: Dmitry Polukhin (dmpolukhin)

<details>
<summary>Changes</summary>

Summary:

After https://reviews.llvm.org/D143436 response files stopped working with CDB 
interpolation. It has happened because interpolation removes all unknwn flags 
and extra input files. Response file is treated as an extra input because it is 
not a flag. Moreover inference needs full command line for driver mode and file 
type detection so all response files have to be expanded for correct inference.

This patch implements the simplest approach that add extra response file 
expansion before inference. Response file expansion in CommandMangler keep 
working for CDB pushed via LSP and will do nothing if all response files are 
already expanded.

Test Plan: TBD

Reviewers:

Subscribers:

Tasks: https://github.com/llvm/llvm-project/issues/69690

Tags:

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


1 Files Affected:

- (modified) clang-tools-extra/clangd/GlobalCompilationDatabase.cpp (+10-1) 


``````````diff
diff --git a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp 
b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
index d1833759917a30..03ac1aa132d0bf 100644
--- a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -244,7 +244,16 @@ static std::unique_ptr<tooling::CompilationDatabase>
 parseJSON(PathRef Path, llvm::StringRef Data, std::string &Error) {
   if (auto CDB = tooling::JSONCompilationDatabase::loadFromBuffer(
           Data, Error, tooling::JSONCommandLineSyntax::AutoDetect)) {
-    return tooling::inferMissingCompileCommands(std::move(CDB));
+    // FS used for expanding response files.
+    // FIXME: ExpandResponseFilesDatabase appears not to provide the usual
+    // thread-safety guarantees, as the access to FS is not locked!
+    // For now, use the real FS, which is known to be threadsafe (if we don't
+    // use/change working directory, which ExpandResponseFilesDatabase 
doesn't).
+    // NOTE: response files have to be expanded before inference because 
inference
+    // needs full command line to check/fix driver mode and file type.
+    auto FS = llvm::vfs::getRealFileSystem();
+    return tooling::inferMissingCompileCommands(
+            expandResponseFiles(std::move(CDB), std::move(FS)));
   }
   return nullptr;
 }

``````````

</details>


https://github.com/llvm/llvm-project/pull/75753
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to