llvm-capstone/clang/test/Modules/module-name-used-by-objc-bridge.m
Jan Svoboda a2d805c020 [clang][modules] Delay creating IdentifierInfo for names of explicit modules
When using explicit Clang modules, some declarations might unexpectedly become invisible.

This is caused by the mechanism that loads PCM files passed via `-fmodule-file=<path>` and creates an `IdentifierInfo` for the module name. The `IdentifierInfo` creation takes place when the `ASTReader` is in a weird state, with modules that are loaded but not yet set up properly. This patch delays the creation of `IdentifierInfo` until the `ASTReader` is done with reading the PCM.

Note that the `-fmodule-file=<name>=<path>` form of the argument doesn't suffer from this issue, since it doesn't create `IdentifierInfo` for the module name.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D111543
2021-10-18 11:50:29 +02:00

26 lines
1.2 KiB
Objective-C

// RUN: rm -rf %t && mkdir %t
// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-name=InterfaceBridge \
// RUN: %S/Inputs/module-name-used-by-objc-bridge/module.modulemap -o %t/InterfaceBridge.pcm
// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-name=Interface \
// RUN: %S/Inputs/module-name-used-by-objc-bridge/module.modulemap -o %t/Interface.pcm
// Check that the `-fmodule-file=<name>=<path>` form succeeds:
// RUN: %clang_cc1 -fmodules -fsyntax-only %s -I %S/Inputs/module-name-used-by-objc-bridge \
// RUN: -fmodule-file=InterfaceBridge=%t/InterfaceBridge.pcm -fmodule-file=Interface=%t/Interface.pcm \
// RUN: -fmodule-map-file=%S/Inputs/module-name-used-by-objc-bridge/module.modulemap -verify
// Check that the `-fmodule-file=<path>` form succeeds:
// RUN: %clang_cc1 -fmodules -fsyntax-only %s -I %S/Inputs/module-name-used-by-objc-bridge \
// RUN: -fmodule-file=%t/InterfaceBridge.pcm -fmodule-file=%t/Interface.pcm \
// RUN: -fmodule-map-file=%S/Inputs/module-name-used-by-objc-bridge/module.modulemap -verify
#import "InterfaceBridge.h"
#import "Interface.h"
@interface Interface (User)
@end
// expected-no-diagnostics