forked from OSchip/llvm-project
[PCH] Fix a regression when PCH is used with -fmodules
Following up on r291465 after a regression in r276159. When we use -fmodule-name=X while building a PCH, modular headers in X will be textually included and the compiler knows that we are not building module X, so don't serialize such headers in the PCH as being part of a module, because at this point they are not. This was causing subtle bugs and malformed AST crashes, for instance, when using the PCH in subsequent compiler invocation with -fmodules, the HFI for a modular header would map to the PCH, which would force a module load of and unexistent module ID. rdar://problem/30171164 llvm-svn: 294361
This commit is contained in:
parent
c0d5590a3b
commit
17da34d2bd
|
@ -2544,7 +2544,8 @@ unsigned ASTWriter::getLocalOrImportedSubmoduleID(Module *Mod) {
|
|||
|
||||
auto *Top = Mod->getTopLevelModule();
|
||||
if (Top != WritingModule &&
|
||||
!Top->fullModuleNameIs(StringRef(getLangOpts().CurrentModule)))
|
||||
(getLangOpts().CompilingPCH ||
|
||||
!Top->fullModuleNameIs(StringRef(getLangOpts().CurrentModule))))
|
||||
return 0;
|
||||
|
||||
return SubmoduleIDs[Mod] = NextSubmoduleID++;
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
#ifdef __OBJC__
|
||||
#import <NC/NULog.h>
|
||||
#endif
|
|
@ -0,0 +1 @@
|
|||
#import <NC/NUGeometry.h>
|
|
@ -0,0 +1 @@
|
|||
// NU-Visibility.h
|
|
@ -0,0 +1 @@
|
|||
#import <NC/NU-Visibility.h>
|
|
@ -0,0 +1,6 @@
|
|||
framework module NC {
|
||||
umbrella header "NC.h"
|
||||
|
||||
export *
|
||||
module * { export * }
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
explicit module NC.Private
|
||||
{
|
||||
header "NULog.h"
|
||||
header "NUAssert.h"
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
#import <NC/NULog.h>
|
|
@ -0,0 +1 @@
|
|||
#import <NC/NU-Visibility.h>
|
|
@ -0,0 +1,13 @@
|
|||
// RUN: rm -rf %t.cache
|
||||
//
|
||||
// RUN: %clang_cc1 -x objective-c-header -fmodules -F%S/Inputs/invalid-module-id \
|
||||
// RUN: -fmodule-implementation-of NC -fmodules-cache-path=%t.cache \
|
||||
// RUN: -fimplicit-module-maps \
|
||||
// RUN: -emit-pch %S/Inputs/invalid-module-id/NC-Prefix.pch -o %t.pch
|
||||
//
|
||||
// RUN: %clang_cc1 -x objective-c -fmodules -F%S/Inputs/invalid-module-id \
|
||||
// RUN: -fmodule-implementation-of NC -fmodules-cache-path=%t.cache \
|
||||
// RUN: -fimplicit-module-maps -include-pch %t.pch %s -fsyntax-only
|
||||
|
||||
#import <NC/NULog.h>
|
||||
#import <NC/NUGeometry.h>
|
Loading…
Reference in New Issue