[cfe-commits] r139824 - in /cfe/trunk: lib/Frontend/CompilerInstance.cpp lib/Serialization/ASTReader.cpp test/Modules/irgen.c

Douglas Gregor dgregor at apple.com
Thu Sep 15 11:47:32 PDT 2011


Author: dgregor
Date: Thu Sep 15 13:47:32 2011
New Revision: 139824

URL: http://llvm.org/viewvc/llvm-project?rev=139824&view=rev
Log:
When we load the first module, make sure that we wire up the ASTConsumer to the newly-created ASTReader. This makes sure that CodeGen sees the declarations it is interested in

Added:
    cfe/trunk/test/Modules/irgen.c
Modified:
    cfe/trunk/lib/Frontend/CompilerInstance.cpp
    cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=139824&r1=139823&r2=139824&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Thu Sep 15 13:47:32 2011
@@ -756,6 +756,8 @@
     getASTContext().setExternalSource(Source);
     if (hasSema())
       ModuleManager->InitializeSema(getSema());
+    if (hasASTConsumer())
+      ModuleManager->StartTranslationUnit(&getASTConsumer());
   }
   
   // Try to load the module we found.

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=139824&r1=139823&r2=139824&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Thu Sep 15 13:47:32 2011
@@ -4092,6 +4092,7 @@
     // passing to the consumer.
     GetDecl(ExternalDefinitions[I]);
   }
+  ExternalDefinitions.clear();
 
   PassInterestingDeclsToConsumer();
 }

Added: cfe/trunk/test/Modules/irgen.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/irgen.c?rev=139824&view=auto
==============================================================================
--- cfe/trunk/test/Modules/irgen.c (added)
+++ cfe/trunk/test/Modules/irgen.c Thu Sep 15 13:47:32 2011
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -emit-module -triple x86_64-apple-darwin10 -o %t/module.pcm -DBUILD_MODULE %s
+// RUN: %clang_cc1 -fmodule-cache-path %t -triple x86_64-apple-darwin10 -fdisable-module-hash -emit-llvm -o - %s | FileCheck %s
+
+#ifdef BUILD_MODULE
+static inline int triple(int x) { return x * 3; }
+#else
+__import_module__ module;
+
+// CHECK: define void @triple_value
+void triple_value(int *px) {
+  *px = triple(*px);
+}
+
+// CHECK: define internal i32 @triple(i32
+#endif





More information about the cfe-commits mailing list