r294361 - [PCH] Fix a regression when PCH is used with -fmodules
Bruno Cardoso Lopes via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 7 13:54:58 PST 2017
Author: bruno
Date: Tue Feb 7 15:54:57 2017
New Revision: 294361
URL: http://llvm.org/viewvc/llvm-project?rev=294361&view=rev
Log:
[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
Added:
cfe/trunk/test/Modules/Inputs/invalid-module-id/
cfe/trunk/test/Modules/Inputs/invalid-module-id/NC-Prefix.pch
cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/
cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Headers/
cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Headers/NC.h
cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Headers/NU-Visibility.h
cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Headers/NUGeometry.h
cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Modules/
cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Modules/module.modulemap
cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Modules/module.private.modulemap
cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/PrivateHeaders/
cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/PrivateHeaders/NUAssert.h
cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/PrivateHeaders/NULog.h
cfe/trunk/test/Modules/invalid-pch-module-id.m
Modified:
cfe/trunk/lib/Serialization/ASTWriter.cpp
Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=294361&r1=294360&r2=294361&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Tue Feb 7 15:54:57 2017
@@ -2544,7 +2544,8 @@ unsigned ASTWriter::getLocalOrImportedSu
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++;
Added: cfe/trunk/test/Modules/Inputs/invalid-module-id/NC-Prefix.pch
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/invalid-module-id/NC-Prefix.pch?rev=294361&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/invalid-module-id/NC-Prefix.pch (added)
+++ cfe/trunk/test/Modules/Inputs/invalid-module-id/NC-Prefix.pch Tue Feb 7 15:54:57 2017
@@ -0,0 +1,3 @@
+#ifdef __OBJC__
+ #import <NC/NULog.h>
+#endif
Added: cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Headers/NC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Headers/NC.h?rev=294361&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Headers/NC.h (added)
+++ cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Headers/NC.h Tue Feb 7 15:54:57 2017
@@ -0,0 +1 @@
+#import <NC/NUGeometry.h>
Added: cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Headers/NU-Visibility.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Headers/NU-Visibility.h?rev=294361&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Headers/NU-Visibility.h (added)
+++ cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Headers/NU-Visibility.h Tue Feb 7 15:54:57 2017
@@ -0,0 +1 @@
+// NU-Visibility.h
Added: cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Headers/NUGeometry.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Headers/NUGeometry.h?rev=294361&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Headers/NUGeometry.h (added)
+++ cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Headers/NUGeometry.h Tue Feb 7 15:54:57 2017
@@ -0,0 +1 @@
+#import <NC/NU-Visibility.h>
Added: cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Modules/module.modulemap
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Modules/module.modulemap?rev=294361&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Modules/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Modules/module.modulemap Tue Feb 7 15:54:57 2017
@@ -0,0 +1,6 @@
+framework module NC {
+ umbrella header "NC.h"
+
+ export *
+ module * { export * }
+}
Added: cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Modules/module.private.modulemap
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Modules/module.private.modulemap?rev=294361&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Modules/module.private.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Modules/module.private.modulemap Tue Feb 7 15:54:57 2017
@@ -0,0 +1,5 @@
+explicit module NC.Private
+{
+ header "NULog.h"
+ header "NUAssert.h"
+}
Added: cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/PrivateHeaders/NUAssert.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/PrivateHeaders/NUAssert.h?rev=294361&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/PrivateHeaders/NUAssert.h (added)
+++ cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/PrivateHeaders/NUAssert.h Tue Feb 7 15:54:57 2017
@@ -0,0 +1 @@
+#import <NC/NULog.h>
Added: cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/PrivateHeaders/NULog.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/PrivateHeaders/NULog.h?rev=294361&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/PrivateHeaders/NULog.h (added)
+++ cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/PrivateHeaders/NULog.h Tue Feb 7 15:54:57 2017
@@ -0,0 +1 @@
+#import <NC/NU-Visibility.h>
Added: cfe/trunk/test/Modules/invalid-pch-module-id.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/invalid-pch-module-id.m?rev=294361&view=auto
==============================================================================
--- cfe/trunk/test/Modules/invalid-pch-module-id.m (added)
+++ cfe/trunk/test/Modules/invalid-pch-module-id.m Tue Feb 7 15:54:57 2017
@@ -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>
More information about the cfe-commits
mailing list