summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/ModuleMap.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2015-03-09 23:46:50 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2015-03-09 23:46:50 +0000
commit00bc95ec9a7b373baaf8f36f55f8022a59f4fb8b (patch)
tree272cec25fa09eb27468e7c013e493077f5fa8e38 /clang/lib/Lex/ModuleMap.cpp
parent3197fb4a89dc9cddb23ad4298e6121354f1d488b (diff)
downloadbcm5719-llvm-00bc95ec9a7b373baaf8f36f55f8022a59f4fb8b.tar.gz
bcm5719-llvm-00bc95ec9a7b373baaf8f36f55f8022a59f4fb8b.zip
[modules] Don't assert if the same header is named as both a public and a
private header within the same module. llvm-svn: 231725
Diffstat (limited to 'clang/lib/Lex/ModuleMap.cpp')
-rw-r--r--clang/lib/Lex/ModuleMap.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index 0bb98568b21..b4fe98488bc 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -222,15 +222,24 @@ static bool violatesPrivateInclude(Module *RequestingModule,
// Check for consistency between the module header role
// as obtained from the lookup and as obtained from the module.
// This check is not cheap, so enable it only for debugging.
- bool IsPrivate = false;
- SmallVectorImpl<Module::Header> *HeaderList[] =
- {&RequestedModule->Headers[Module::HK_Private],
- &RequestedModule->Headers[Module::HK_PrivateTextual]};
- for (auto *Hdrs : HeaderList)
- IsPrivate |=
- std::find_if(Hdrs->begin(), Hdrs->end(), [&](const Module::Header &H) {
- return H.Entry == IncFileEnt;
- }) != Hdrs->end();
+ auto IsInHeaderList = [&](std::initializer_list<SmallVectorImpl<
+ Module::Header>*> HeaderList) -> bool {
+ for (auto *Hs : HeaderList) {
+ if (std::find_if(Hs->begin(), Hs->end(), [&](const Module::Header &H) {
+ return H.Entry == IncFileEnt;
+ }) != Hs->end())
+ return true;
+ }
+ return false;
+ };
+ // If a header is both public and private, then it's available as a public
+ // header and that's OK.
+ // FIXME: Should we reject this when parsing the module map?
+ bool IsPrivate =
+ IsInHeaderList({&RequestedModule->Headers[Module::HK_Private],
+ &RequestedModule->Headers[Module::HK_PrivateTextual]}) &&
+ !IsInHeaderList({&RequestedModule->Headers[Module::HK_Normal],
+ &RequestedModule->Headers[Module::HK_Textual]});
assert(IsPrivate == IsPrivateRole && "inconsistent headers and roles");
#endif
return IsPrivateRole &&
OpenPOWER on IntegriCloud