]> granicus.if.org Git - clang/commitdiff
Fix missing builtin identifier infos with PCH+modules
authorBen Langmuir <blangmuir@apple.com>
Wed, 28 Oct 2015 22:25:37 +0000 (22:25 +0000)
committerBen Langmuir <blangmuir@apple.com>
Wed, 28 Oct 2015 22:25:37 +0000 (22:25 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@251565 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Serialization/ASTReader.cpp
test/Modules/Inputs/builtin_sub.h
test/Modules/Inputs/use-builtin.h [new file with mode: 0644]
test/Modules/builtins.m

index 4838a43e03304dfea46185a1d1bf8e4f0e1fec68..c54f659f09f697caeb29b65eb93270b212974636 100644 (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();
       }
 
index 79e3c0332597468dcf37584accc3bc76bea9eb06..5752ef984e94f27e8736eedb815de3829faf8220 100644 (file)
@@ -2,3 +2,4 @@ int getBos1(void) {
   return __builtin_object_size(p, 0);
 }
 
+#define IS_CONST(x) __builtin_constant_p(x)
diff --git a/test/Modules/Inputs/use-builtin.h b/test/Modules/Inputs/use-builtin.h
new file mode 100644 (file)
index 0000000..fd04741
--- /dev/null
@@ -0,0 +1,2 @@
+@import builtin;
+@import builtin.sub;
index c095f4f0164527a0ccbcc8bef2d6a46fbc4ace58..33d23979ce79e3203816ed2682d32d95be0913dd 100644 (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