https://github.com/matts1 updated https://github.com/llvm/llvm-project/pull/130712
>From 2c0dc1e7ee6a7ec499f4fcb88c79dc1aff8ce2ca Mon Sep 17 00:00:00 2001 From: Matt Stark <m...@google.com> Date: Mon, 10 Mar 2025 13:07:29 +1100 Subject: [PATCH 1/2] [clang] Fix a segfault when M is a nullptr --- clang/docs/ReleaseNotes.rst | 1 + clang/include/clang/Basic/Module.h | 2 +- clang/test/Modules/pr130712.cppm | 31 ++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 clang/test/Modules/pr130712.cppm diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 2a1c5ee2d788e..c7f8a564fe63a 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -318,6 +318,7 @@ Bug Fixes to C++ Support - Fixed an assertion failure affecting code that uses C++23 "deducing this". (#GH130272) - Clang now properly instantiates destructors for initialized members within non-delegating constructors. (#GH93251) - Correctly diagnoses if unresolved using declarations shadows template paramters (#GH129411) +- Clang no longer segfaults when there is a configuration mismatch between modules and their users (http://crbug.com/400353616). Bug Fixes to AST Handling ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/include/clang/Basic/Module.h b/clang/include/clang/Basic/Module.h index 62cc8acf9588b..3d035f0a5f787 100644 --- a/clang/include/clang/Basic/Module.h +++ b/clang/include/clang/Basic/Module.h @@ -888,7 +888,7 @@ class VisibleModuleSet { /// Get the location at which the import of a module was triggered. SourceLocation getImportLoc(const Module *M) const { - return M->getVisibilityID() < ImportLocs.size() + return M && M->getVisibilityID() < ImportLocs.size() ? ImportLocs[M->getVisibilityID()] : SourceLocation(); } diff --git a/clang/test/Modules/pr130712.cppm b/clang/test/Modules/pr130712.cppm new file mode 100644 index 0000000000000..f908f1cb50bca --- /dev/null +++ b/clang/test/Modules/pr130712.cppm @@ -0,0 +1,31 @@ +// RUN: split-file %s %t + +// There are two requirements here to result in the owner of a macro being null. +// 1) There must be a configuration mismatch between a header and a file it depends on +// 2) -fmodules-local-submodule-visibility must be enabled. + +// RUN: %clang_cc1 -I%t -emit-module -o %t/a.pcm -fmodules %t/module.modulemap -fmodule-name=a -fmodules-local-submodule-visibility +// RUN: %clang_cc1 -fexceptions -Wno-module-file-config-mismatch -I%t -emit-module -o %t/b.pcm -fmodules %t/module.modulemap -fmodule-name=b -fmodules-local-submodule-visibility -fmodule-file=%t/a.pcm +// RUN: %clang_cc1 -fexceptions -Wno-module-file-config-mismatch -I%t -emit-module -o %t/c.pcm -fmodules %t/module.modulemap -fmodule-name=c -fmodules-local-submodule-visibility -fmodule-file=%t/a.pcm -fmodule-file=%t/b.pcm + +//--- module.modulemap +module a { header "a.h" } +module b { header "b.h" } +module c { header "c.h" } + +//--- a.h +#ifndef A_H +#define A_H +#endif + +//--- b.h +#ifndef B_H +#define B_H + +#include <a.h> + +#endif + +//--- c.h +#include <a.h> +#include <b.h> >From a249bae4509df467d76ad786977ce9711148c7e5 Mon Sep 17 00:00:00 2001 From: Matt <mattstar...@gmail.com> Date: Tue, 18 Mar 2025 15:54:31 +1100 Subject: [PATCH 2/2] Update clang/docs/ReleaseNotes.rst Co-authored-by: Takuto Ikuta <atetu...@gmail.com> --- clang/docs/ReleaseNotes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index c7f8a564fe63a..f6f3157d398a4 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -318,7 +318,7 @@ Bug Fixes to C++ Support - Fixed an assertion failure affecting code that uses C++23 "deducing this". (#GH130272) - Clang now properly instantiates destructors for initialized members within non-delegating constructors. (#GH93251) - Correctly diagnoses if unresolved using declarations shadows template paramters (#GH129411) -- Clang no longer segfaults when there is a configuration mismatch between modules and their users (http://crbug.com/400353616). +- Clang no longer segfaults when there is a configuration mismatch between modules and their users (#GH130712). Bug Fixes to AST Handling ^^^^^^^^^^^^^^^^^^^^^^^^^ _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits