[PATCH] D135637: [clang][deps] Prevent emitting diagnostics outside of source file

Jan Svoboda via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 11 15:57:36 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rGc1c72302fe45: [clang][deps] Prevent emitting diagnostics outside of source file (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135637/new/

https://reviews.llvm.org/D135637

Files:
  clang/lib/Frontend/FrontendAction.cpp
  clang/test/ClangScanDeps/modules-implementation-module-map.c


Index: clang/test/ClangScanDeps/modules-implementation-module-map.c
===================================================================
--- /dev/null
+++ clang/test/ClangScanDeps/modules-implementation-module-map.c
@@ -0,0 +1,38 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+//--- cdb.json.template
+[{
+  "file": "DIR/tu.m",
+  "directory": "DIR",
+  "command": "clang -fmodules -fimplicit-module-maps -fmodules-cache-path=DIR/cache -fmodule-name=FWPrivate -c DIR/tu.m -o DIR/tu.o -F DIR/frameworks -Wprivate-module"
+}]
+
+//--- frameworks/FW.framework/Modules/module.modulemap
+framework module FW {}
+//--- frameworks/FW.framework/Modules/module.private.modulemap
+// The module name will trigger a diagnostic.
+framework module FWPrivate { header "private.h" }
+//--- frameworks/FW.framework/PrivateHeaders/private.h
+//--- tu.m
+
+// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
+// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full > %t/result.json
+// RUN: cat %t/result.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t
+// CHECK:      "translation-units": [
+// CHECK-NEXT:   {
+// CHECK-NEXT:     "commands": [
+// CHECK:            {
+// CHECK:              "command-line": [
+// CHECK:                "-fmodule-map-file=[[PREFIX]]/frameworks/FW.framework/Modules/module.private.modulemap",
+// CHECK:                "-fmodule-name=FWPrivate",
+// CHECK:              ],
+// CHECK-NEXT:         "executable": "clang",
+// CHECK-NEXT:         "file-deps": [
+// CHECK-NEXT:           "[[PREFIX]]/tu.m"
+// CHECK-NEXT:         ],
+// CHECK-NEXT:         "input-file": "[[PREFIX]]/tu.m"
+// CHECK-NEXT:       }
+// CHECK:          ]
+// CHECK:        }
+// CHECK:      ]
Index: clang/lib/Frontend/FrontendAction.cpp
===================================================================
--- clang/lib/Frontend/FrontendAction.cpp
+++ clang/lib/Frontend/FrontendAction.cpp
@@ -914,6 +914,9 @@
       CI.getDiagnostics().Report(diag::err_module_map_not_found) << Filename;
   }
 
+  // If compiling implementation of a module, load its module map file now.
+  (void)CI.getPreprocessor().getCurrentModuleImplementation();
+
   // Add a module declaration scope so that modules from -fmodule-map-file
   // arguments may shadow modules found implicitly in search paths.
   CI.getPreprocessor()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135637.466961.patch
Type: text/x-patch
Size: 2351 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221011/5ee98f68/attachment-0001.bin>


More information about the cfe-commits mailing list