[llvm-branch-commits] [cfe-branch] r115280 - in /cfe/branches/Apple/whitney: lib/Serialization/ASTWriter.cpp test/PCH/Inputs/chain-macro-override1.h test/PCH/Inputs/chain-macro-override2.h test/PCH/chain-macro-override.c

Daniel Dunbar daniel at zuster.org
Thu Sep 30 20:42:11 PDT 2010


Author: ddunbar
Date: Thu Sep 30 22:42:11 2010
New Revision: 115280

URL: http://llvm.org/viewvc/llvm-project?rev=115280&view=rev
Log:
Merge r115259:
--
Author: Douglas Gregor <dgregor at apple.com>
Date:   Fri Oct 1 01:03:07 2010 +0000

    When an identifier that has a macro definition in the original PCH
    file is somehow changed in a chained PCH file, make sure that we write
    out the macro definition. Fixes part of <rdar://problem/8499034>.

Modified:
    cfe/branches/Apple/whitney/lib/Serialization/ASTWriter.cpp
    cfe/branches/Apple/whitney/test/PCH/Inputs/chain-macro-override1.h
    cfe/branches/Apple/whitney/test/PCH/Inputs/chain-macro-override2.h
    cfe/branches/Apple/whitney/test/PCH/chain-macro-override.c

Modified: cfe/branches/Apple/whitney/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/Serialization/ASTWriter.cpp?rev=115280&r1=115279&r2=115280&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/branches/Apple/whitney/lib/Serialization/ASTWriter.cpp Thu Sep 30 22:42:11 2010
@@ -1276,7 +1276,13 @@
     // Don't emit builtin macros like __LINE__ to the AST file unless they have
     // been redefined by the header (in which case they are not isBuiltinMacro).
     // Also skip macros from a AST file if we're chaining.
-    if (MI->isBuiltinMacro() || (Chain && MI->isFromAST()))
+
+    // FIXME: There is a (probably minor) optimization we could do here, if
+    // the macro comes from the original PCH but the identifier comes from a
+    // chained PCH, by storing the offset into the original PCH rather than
+    // writing the macro definition a second time.
+    if (MI->isBuiltinMacro() || 
+        (Chain && I->first->isFromAST() && MI->isFromAST()))
       continue;
 
     AddIdentifierRef(I->first, Record);

Modified: cfe/branches/Apple/whitney/test/PCH/Inputs/chain-macro-override1.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/test/PCH/Inputs/chain-macro-override1.h?rev=115280&r1=115279&r2=115280&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/test/PCH/Inputs/chain-macro-override1.h (original)
+++ cfe/branches/Apple/whitney/test/PCH/Inputs/chain-macro-override1.h Thu Sep 30 22:42:11 2010
@@ -2,3 +2,4 @@
 void g();
 #define g() f()
 #define h() f()
+#define x x

Modified: cfe/branches/Apple/whitney/test/PCH/Inputs/chain-macro-override2.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/test/PCH/Inputs/chain-macro-override2.h?rev=115280&r1=115279&r2=115280&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/test/PCH/Inputs/chain-macro-override2.h (original)
+++ cfe/branches/Apple/whitney/test/PCH/Inputs/chain-macro-override2.h Thu Sep 30 22:42:11 2010
@@ -2,3 +2,4 @@
 #undef g
 #undef h
 #define h() g()
+int x;

Modified: cfe/branches/Apple/whitney/test/PCH/chain-macro-override.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/test/PCH/chain-macro-override.c?rev=115280&r1=115279&r2=115280&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/test/PCH/chain-macro-override.c (original)
+++ cfe/branches/Apple/whitney/test/PCH/chain-macro-override.c Thu Sep 30 22:42:11 2010
@@ -6,8 +6,9 @@
 // RUN: %clang_cc1 -emit-pch -o %t2 %S/Inputs/chain-macro-override2.h -include-pch %t1 -chained-pch
 // RUN: %clang_cc1 -include-pch %t2 -fsyntax-only -verify %s
 
-void foo() {
+int foo() {
   f();
   g();
   h();
+  return x;
 }





More information about the llvm-branch-commits mailing list