Fix missing builtin identifier infos with PCH+modules

Use the *current* state of "is-moduleness" rather than the state at
serialization time so that if we read a builtin identifier from a module
that wasn't "interesting" to that module, we will still write it out to
a PCH that imports that module.

Otherwise, we would get mysterious "unknown builtin" errors when using
PCH+modules.

rdar://problem/23287656

llvm-svn: 251565
This commit is contained in:
Ben Langmuir 2015-10-28 22:25:37 +00:00
parent a309efef39
commit b9ad4e6063
4 changed files with 15 additions and 2 deletions

View File

@ -780,7 +780,8 @@ IdentifierInfo *ASTIdentifierLookupTrait::ReadData(const internal_key_type& k,
}
if (!II->isFromAST()) {
II->setIsFromAST();
if (isInterestingIdentifier(Reader, *II, F.isModule()))
bool IsModule = Reader.PP.getCurrentModule() != nullptr;
if (isInterestingIdentifier(Reader, *II, IsModule))
II->setChangedSinceDeserialization();
}
Reader.markIdentifierUpToDate(II);
@ -3511,7 +3512,8 @@ ASTReader::ASTReadResult ASTReader::ReadAST(const std::string &FileName,
// whether we need to serialize it.
if (!II.isFromAST()) {
II.setIsFromAST();
if (isInterestingIdentifier(*this, II, F.isModule()))
bool IsModule = PP.getCurrentModule() != nullptr;
if (isInterestingIdentifier(*this, II, IsModule))
II.setChangedSinceDeserialization();
}

View File

@ -2,3 +2,4 @@ int getBos1(void) {
return __builtin_object_size(p, 0);
}
#define IS_CONST(x) __builtin_constant_p(x)

View File

@ -0,0 +1,2 @@
@import builtin;
@import builtin.sub;

View File

@ -10,7 +10,15 @@ int bar() {
return __builtin_object_size(p, 0);
}
int baz() {
return IS_CONST(0);
}
// RUN: rm -rf %t
// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs %s -verify
// RUN: rm -rf %t.pch.cache
// RUN: %clang_cc1 -fmodules-cache-path=%t.pch.cache -fmodules -fimplicit-module-maps -I %S/Inputs -emit-pch -o %t.pch -x objective-c-header %S/Inputs/use-builtin.h
// RUN: %clang_cc1 -fmodules-cache-path=%t.pch.cache -fmodules -fimplicit-module-maps -I %S/Inputs %s -include-pch %t.pch %s -verify
// expected-no-diagnostics