[cfe-commits] r145709 - in /cfe/trunk: lib/Serialization/ASTReader.cpp test/Modules/diamond-pch.c

Douglas Gregor dgregor at apple.com
Fri Dec 2 13:56:06 PST 2011


Author: dgregor
Date: Fri Dec  2 15:56:05 2011
New Revision: 145709

URL: http://llvm.org/viewvc/llvm-project?rev=145709&view=rev
Log:
Only perform checking of the predefines buffer when loading a
precompiled header. Previously, we were trying to gather predefines
buffers from all kinds of AST files (which doesn't make sense) and
were performing some validation when AST files were loaded as main
files. 

With these tweaks, using PCH files that import modules no longer fails
immediately (due to mismatched predefines buffers). However, module
visibility is lost, so this feature does not yet work.


Added:
    cfe/trunk/test/Modules/diamond-pch.c   (with props)
Modified:
    cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=145709&r1=145708&r2=145709&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri Dec  2 15:56:05 2011
@@ -1210,7 +1210,7 @@
     FileID BufferID = SourceMgr.createFileIDForMemBuffer(Buffer, ID,
                                                          BaseOffset + Offset);
 
-    if (strcmp(Name, "<built-in>") == 0) {
+    if (strcmp(Name, "<built-in>") == 0 && F->Kind == MK_PCH) {
       PCHPredefinesBlock Block = {
         BufferID,
         StringRef(BlobStart, BlobLen - 1)
@@ -2530,7 +2530,7 @@
   // Here comes stuff that we only do once the entire chain is loaded.
   
   // Check the predefines buffers.
-  if (!DisableValidation && Type != MK_Module && Type != MK_Preamble &&
+  if (!DisableValidation && Type == MK_PCH &&
       // FIXME: CheckPredefinesBuffers also sets the SuggestedPredefines;
       // if DisableValidation is true, defines that were set on command-line
       // but not in the PCH file will not be added to SuggestedPredefines.

Added: cfe/trunk/test/Modules/diamond-pch.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/diamond-pch.c?rev=145709&view=auto
==============================================================================
--- cfe/trunk/test/Modules/diamond-pch.c (added)
+++ cfe/trunk/test/Modules/diamond-pch.c Fri Dec  2 15:56:05 2011
@@ -0,0 +1,32 @@
+
+
+
+// in diamond-bottom.h: expected-note{{passing argument to parameter 'x' here}}
+
+// FIXME: The module import below shouldn't be necessary, because importing the
+// precompiled header should make all of the modules visible that were
+// visible when the PCH file was built.
+__import_module__ diamond_bottom;
+
+void test_diamond(int i, float f, double d, char c) {
+  top(&i);
+  left(&f);
+  right(&d);
+  bottom(&c);
+  bottom(&d); // expected-warning{{incompatible pointer types passing 'double *' to parameter of type 'char *'}}
+
+  // Names in multiple places in the diamond.
+  top_left(&c);
+
+  left_and_right(&i);
+  struct left_and_right lr;
+  lr.left = 17;
+}
+
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -emit-module -fmodule-cache-path %t -fmodule-name=diamond_top %S/Inputs/module.map
+// RUN: %clang_cc1 -emit-module -fmodule-cache-path %t -fmodule-name=diamond_left %S/Inputs/module.map
+// RUN: %clang_cc1 -emit-module -fmodule-cache-path %t -fmodule-name=diamond_right %S/Inputs/module.map
+// RUN: %clang_cc1 -emit-module -fmodule-cache-path %t -fmodule-name=diamond_bottom %S/Inputs/module.map
+// RUN: %clang_cc1 -emit-pch -fmodule-cache-path %t -o %t.pch %S/Inputs/diamond.h
+// RUN: %clang_cc1 -fmodule-cache-path %t -include-pch %t.pch %s -verify

Propchange: cfe/trunk/test/Modules/diamond-pch.c
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cfe/trunk/test/Modules/diamond-pch.c
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cfe/trunk/test/Modules/diamond-pch.c
------------------------------------------------------------------------------
    svn:mime-type = text/plain





More information about the cfe-commits mailing list