forked from OSchip/llvm-project
Support #__private_macro and #__public_macro in local submodule
visibility mode.
This commit is contained in:
parent
4cd109891c
commit
4259301aaf
|
@ -1045,12 +1045,12 @@ void Preprocessor::HandleDirective(Token &Result) {
|
|||
break;
|
||||
|
||||
case tok::pp___public_macro:
|
||||
if (getLangOpts().Modules)
|
||||
if (getLangOpts().Modules || getLangOpts().ModulesLocalVisibility)
|
||||
return HandleMacroPublicDirective(Result);
|
||||
break;
|
||||
|
||||
case tok::pp___private_macro:
|
||||
if (getLangOpts().Modules)
|
||||
if (getLangOpts().Modules || getLangOpts().ModulesLocalVisibility)
|
||||
return HandleMacroPrivateDirective();
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
module self {
|
||||
header "self.h"
|
||||
}
|
||||
|
||||
module other {
|
||||
header "other.h"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
#define OTHER_PRIVATE
|
||||
#__private_macro OTHER_PRIVATE
|
||||
|
||||
#define OTHER_PUBLIC
|
||||
#__public_macro OTHER_PUBLIC
|
||||
|
||||
#define OTHER_DEFAULT
|
|
@ -0,0 +1,7 @@
|
|||
#define SELF_PRIVATE
|
||||
#__private_macro SELF_PRIVATE
|
||||
|
||||
#define SELF_PUBLIC
|
||||
#__public_macro SELF_PUBLIC
|
||||
|
||||
#define SELF_DEFAULT
|
|
@ -0,0 +1,53 @@
|
|||
// RUN: rm -rf %t
|
||||
//
|
||||
// RUN: %clang_cc1 %s \
|
||||
// RUN: -fmodules-local-submodule-visibility \
|
||||
// RUN: -fmodule-map-file=%S/Inputs/lsv-private-macro/mod.map \
|
||||
// RUN: -I%S/Inputs/lsv-private-macro -fmodule-name=self \
|
||||
// RUN: -verify=expected-lsv
|
||||
//
|
||||
// RUN: %clang_cc1 %s \
|
||||
// RUN: -fmodules -fmodules-cache-path=%t \
|
||||
// RUN: -fmodule-map-file=%S/Inputs/lsv-private-macro/mod.map \
|
||||
// RUN: -I%S/Inputs/lsv-private-macro -fmodule-name=self \
|
||||
// RUN: -verify=expected-nolsv
|
||||
//
|
||||
// RUN: %clang_cc1 %s \
|
||||
// RUN: -fmodules -fmodules-cache-path=%t \
|
||||
// RUN: -fmodules-local-submodule-visibility \
|
||||
// RUN: -fmodule-map-file=%S/Inputs/lsv-private-macro/mod.map \
|
||||
// RUN: -I%S/Inputs/lsv-private-macro -fmodule-name=self \
|
||||
// RUN: -verify=expected-lsv
|
||||
|
||||
#include "self.h"
|
||||
|
||||
// With local submodule visibility enabled, private macros don't leak out of
|
||||
// their respective submodules, even within the same top-level module.
|
||||
// expected-lsv-no-diagnostics
|
||||
|
||||
// expected-nolsv-error@+2 {{SELF_PRIVATE defined}}
|
||||
#ifdef SELF_PRIVATE
|
||||
#error SELF_PRIVATE defined
|
||||
#endif
|
||||
|
||||
#ifndef SELF_PUBLIC
|
||||
#error SELF_PUBLIC not defined
|
||||
#endif
|
||||
|
||||
#ifndef SELF_DEFAULT
|
||||
#error SELF_DEFAULT not defined
|
||||
#endif
|
||||
|
||||
#include "other.h"
|
||||
|
||||
#ifdef OTHER_PRIVATE
|
||||
#error OTHER_PRIVATE defined
|
||||
#endif
|
||||
|
||||
#ifndef OTHER_PUBLIC
|
||||
#error OTHER_PUBLIC not defined
|
||||
#endif
|
||||
|
||||
#ifndef OTHER_DEFAULT
|
||||
#error OTHER_DEFAULT not defined
|
||||
#endif
|
Loading…
Reference in New Issue