llvm-capstone/clang/test/Modules/subframeworks.m
Richard Smith 0a088ead85 Improve diagnostics for missing import / #include of module.
Fix a few bugs where we would fail to properly determine header to
module correspondence when determining whether to suggest a #include or
import, and suggest a #include more often in language modes where there
is no import syntax. Generally, if the target is in a header with
include guards or #pragma once, we should suggest either #including or
importing that header, and not importing a module that happens to
textually include it.

In passing, improve the notes we attach to the corresponding
diagnostics: calling an entity that we couldn't see "previous" is
confusing.
2020-04-28 18:41:14 -07:00

31 lines
1.2 KiB
Objective-C

// RUN: rm -rf %t
// RUN: %clang_cc1 -Wauto-import -Wno-private-module -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs -F %S/Inputs/DependsOnModule.framework/Frameworks %s -verify
// RUN: %clang_cc1 -x objective-c++ -Wauto-import -Wno-private-module -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs -F %S/Inputs/DependsOnModule.framework/Frameworks %s -verify
@import DependsOnModule;
void testSubFramework() {
float *sf1 = sub_framework; // expected-error{{declaration of 'sub_framework' must be imported from module 'DependsOnModule.SubFramework' before it is required}}
// expected-note@Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h:2 {{here}}
}
@import DependsOnModule.SubFramework;
void testSubFrameworkAgain() {
float *sf2 = sub_framework;
double *sfo1 = sub_framework_other;
}
#ifdef __cplusplus
@import DependsOnModule.CXX;
CXXOnly cxxonly;
#endif
@import HasSubModules;
// expected-warning@Inputs/HasSubModules.framework/Frameworks/Sub.framework/PrivateHeaders/SubPriv.h:1{{treating #include as an import of module 'HasSubModules.Sub.Types'}}
#import <HasSubModules/HasSubModulesPriv.h>
struct FrameworkSubStruct ss;