Matt 4630d464c5
[clang] Fix a segfault when M is a nullptr (#130712)
If `MM->getOwningModule` returns nullptr, then `isVisible` is called
with nullptr, which then calls `getImportLoc(nullptr)`


077e0c134a/clang/lib/Lex/PPMacroExpansion.cpp (L208)
2025-05-15 10:50:45 +08:00

34 lines
1.1 KiB
C++

// 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.
// In the following example, when compiling module C, A_H has no owning module.
// 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>