================ @@ -0,0 +1,72 @@ +// This test verifies that the modules visible to the translation unit are computed in dependency scanning. +// "client" represents the translation unit that imports an explicit submodule, that only exports one other module. +// Thus, the dependencies of the top level module for the submodule differ from what is visible to the TU. + +// RUN: rm -rf %t +// RUN: split-file %s %t +// RUN: sed -e "s|DIR|%/t|g" %t/compile-commands.json.in > %t/compile-commands.json +// RUN: clang-scan-deps -compilation-database %t/compile-commands.json \ +// RUN: -j 1 -format experimental-full 2>&1 > %t/result.json +// RUN: cat %t/result.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t + +// CHECK: "visible-clang-modules": [ +// CHECK-NEXT: "A", +// CHECK-NEXT: "visible" +// CHECK-NEXT: ] + +//--- compile-commands.json.in +[ +{ + "directory": "DIR", + "command": "clang -c DIR/client.c -isysroot DIR/Sysroot -IDIR/Sysroot/usr/include -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-module-maps", + "file": "DIR/client.c" +} +] + +//--- Sysroot/usr/include/A/module.modulemap +module A { + explicit module visibleToTU { + header "visibleToTU.h" + } + explicit module invisibleToTU { + header "invisibleToTU.h" + } +} +//--- Sysroot/usr/include/A/visibleToTU.h +#include <visible/visible.h> +typedef int A_visibleToTU; + +//--- Sysroot/usr/include/A/invisibleToTU.h +#include <invisible/invisible.h> +typedef int A_invisibleToTU; + +//--- Sysroot/usr/include/invisible/module.modulemap +module invisible { + umbrella "." +} + +//--- Sysroot/usr/include/invisible/invisible.h +typedef int invisible_t; + +//--- Sysroot/usr/include/visible/module.modulemap +module visible { + umbrella "." +} + +//--- Sysroot/usr/include/visible/visible.h +#include <transitive/transitive.h> +typedef int visible_t; + +//--- Sysroot/usr/include/transitive/module.modulemap +module transitive { + umbrella "." +} + +//--- Sysroot/usr/include/transitive/transitive.h +typedef int transitive_t; + +//--- client.c +#include <A/visibleToTU.h> +// Both decls are not visible, thus should fail to actually compile. +transitive_t foo_t(void); +invisible_t foo(void); ---------------- jansvoboda11 wrote:
Adding this also fails to compile: ```c visible_t foo_v(void); ``` I verified that by adding this to the test file: ```shell // RUN: %deps-to-rsp %t/result.json --module-name=transitive > %t/transitive.rsp // RUN: %deps-to-rsp %t/result.json --module-name=visible > %t/visible.rsp // RUN: %deps-to-rsp %t/result.json --module-name=invisible > %t/invisible.rsp // RUN: %deps-to-rsp %t/result.json --module-name=A > %t/A.rsp // RUN: %deps-to-rsp %t/result.json --tu-index=0 > %t/tu.rsp // RUN: %clang @%t/transitive.rsp // RUN: %clang @%t/visible.rsp // RUN: %clang @%t/invisible.rsp // RUN: %clang @%t/A.rsp // RUN: %clang @%t/tu.rsp ``` That seems unexpected based on the test description. https://github.com/llvm/llvm-project/pull/147969 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits