r251565 - Fix missing builtin identifier infos with PCH+modules
Ben Langmuir via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 28 15:25:37 PDT 2015
Author: benlangmuir
Date: Wed Oct 28 17:25:37 2015
New Revision: 251565
URL: http://llvm.org/viewvc/llvm-project?rev=251565&view=rev
Log:
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
Added:
cfe/trunk/test/Modules/Inputs/use-builtin.h
Modified:
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/test/Modules/Inputs/builtin_sub.h
cfe/trunk/test/Modules/builtins.m
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=251565&r1=251564&r2=251565&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Wed Oct 28 17:25:37 2015
@@ -780,7 +780,8 @@ IdentifierInfo *ASTIdentifierLookupTrait
}
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::Read
// 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();
}
Modified: cfe/trunk/test/Modules/Inputs/builtin_sub.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/builtin_sub.h?rev=251565&r1=251564&r2=251565&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/builtin_sub.h (original)
+++ cfe/trunk/test/Modules/Inputs/builtin_sub.h Wed Oct 28 17:25:37 2015
@@ -2,3 +2,4 @@ int getBos1(void) {
return __builtin_object_size(p, 0);
}
+#define IS_CONST(x) __builtin_constant_p(x)
Added: cfe/trunk/test/Modules/Inputs/use-builtin.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/use-builtin.h?rev=251565&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/use-builtin.h (added)
+++ cfe/trunk/test/Modules/Inputs/use-builtin.h Wed Oct 28 17:25:37 2015
@@ -0,0 +1,2 @@
+ at import builtin;
+ at import builtin.sub;
Modified: cfe/trunk/test/Modules/builtins.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/builtins.m?rev=251565&r1=251564&r2=251565&view=diff
==============================================================================
--- cfe/trunk/test/Modules/builtins.m (original)
+++ cfe/trunk/test/Modules/builtins.m Wed Oct 28 17:25:37 2015
@@ -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
More information about the cfe-commits
mailing list