diff options
author | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2017-02-07 21:54:57 +0000 |
---|---|---|
committer | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2017-02-07 21:54:57 +0000 |
commit | 17da34d2bd42e763ad9995a01a5d8784137a476c (patch) | |
tree | 0a305b1566f5a4478097027dc5b6bf0ecca09c01 /clang/lib/Serialization | |
parent | c0d5590a3b908ce583b9e24099b5028026a93456 (diff) | |
download | bcm5719-llvm-17da34d2bd42e763ad9995a01a5d8784137a476c.tar.gz bcm5719-llvm-17da34d2bd42e763ad9995a01a5d8784137a476c.zip |
[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
Diffstat (limited to 'clang/lib/Serialization')
-rw-r--r-- | clang/lib/Serialization/ASTWriter.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 69136015f48..5dee86c1419 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -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++; |