Author: Chuanqi Xu
Date: 2023-02-15T11:00:03+08:00
New Revision: 8d995b26c7559f273809d0d29e5042850e47165a

URL: 
https://github.com/llvm/llvm-project/commit/8d995b26c7559f273809d0d29e5042850e47165a
DIFF: 
https://github.com/llvm/llvm-project/commit/8d995b26c7559f273809d0d29e5042850e47165a.diff

LOG: [C++20] [Modules] [ClangScanDeps] Ensure that we can mix the use of and 
clang modules

Add a test to ensure that the clang-scan-deps won't crash due to the
unexpected use of clang modules.

Added: 
    

Modified: 
    clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
    clang/test/ClangScanDeps/P1689.cppm

Removed: 
    


################################################################################
diff  --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp 
b/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
index 03e996a7dbd9c..c15f6e724fa14 100644
--- a/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
+++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
@@ -117,6 +117,12 @@ llvm::Expected<P1689Rule> 
DependencyScanningTool::getP1689ModuleDependencyFile(
       return Opts->OutputFile;
     }
 
+    // The lookupModuleOutput is for clang modules. P1689 format don't need it.
+    std::string lookupModuleOutput(const ModuleID &ID,
+                                 ModuleOutputKind Kind) override {
+      return "";
+    }
+
   private:
     StringRef Filename;
     P1689Rule &Rule;

diff  --git a/clang/test/ClangScanDeps/P1689.cppm 
b/clang/test/ClangScanDeps/P1689.cppm
index c9ef8f4c83fa2..bbe9cc3b2d332 100644
--- a/clang/test/ClangScanDeps/P1689.cppm
+++ b/clang/test/ClangScanDeps/P1689.cppm
@@ -37,6 +37,11 @@
 //
 // Check that we can generate multiple make-style dependency information with 
compilation database.
 // RUN: cat %t/P1689.dep | FileCheck %t/Checks.cpp -DPREFIX=%/t 
--check-prefix=CHECK-MAKE
+//
+// Check that we can mix the use of -format=p1689 and -fmodules.
+// RUN: clang-scan-deps -format=p1689 \
+// RUN:   -- %clang++ -std=c++20 -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t/cache -serialize-diagnostics -c %t/impl_part.cppm -o 
%t/impl_part.o \
+// RUN:   | FileCheck %t/impl_part.cppm -DPREFIX=%/t
 
 //--- P1689.json.in
 [
@@ -299,4 +304,7 @@ int main() {
 // CHECK-MAKE-DAG-NEXT:   [[PREFIX]]/Impl.cpp \
 // CHECK-MAKE-DAG-NEXT:   [[PREFIX]]/header.mock
 
+//--- module.modulemap
+module Mock { header "header.mock" }
+
 //--- header.mock


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to