]> granicus.if.org Git - clang/commitdiff
When we load the first module, make sure that we wire up the ASTConsumer to the newly...
authorDouglas Gregor <dgregor@apple.com>
Thu, 15 Sep 2011 18:47:32 +0000 (18:47 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 15 Sep 2011 18:47:32 +0000 (18:47 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139824 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/CompilerInstance.cpp
lib/Serialization/ASTReader.cpp
test/Modules/irgen.c [new file with mode: 0644]

index 9087ab58d6e2a19a55c6a5d68d49b50e705b4cc4..07d438b556a40078c9788895e839ffd4c654b56f 100644 (file)
@@ -756,6 +756,8 @@ ModuleKey CompilerInstance::loadModule(SourceLocation ImportLoc,
     getASTContext().setExternalSource(Source);
     if (hasSema())
       ModuleManager->InitializeSema(getSema());
+    if (hasASTConsumer())
+      ModuleManager->StartTranslationUnit(&getASTConsumer());
   }
   
   // Try to load the module we found.
index 30c44291ee308d9b530e97043d37bd05d9033e1c..e4f9fa693c8ad7c2d252e81989762554c6c52987 100644 (file)
@@ -4092,6 +4092,7 @@ void ASTReader::StartTranslationUnit(ASTConsumer *Consumer) {
     // passing to the consumer.
     GetDecl(ExternalDefinitions[I]);
   }
+  ExternalDefinitions.clear();
 
   PassInterestingDeclsToConsumer();
 }
diff --git a/test/Modules/irgen.c b/test/Modules/irgen.c
new file mode 100644 (file)
index 0000000..0debf05
--- /dev/null
@@ -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