aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-09-15 18:47:32 +0000
committerDouglas Gregor <dgregor@apple.com>2011-09-15 18:47:32 +0000
commit1a995ddaa53a20dcd063ea47eb1f533ecb0d243a (patch)
tree654baf1ea7e0c1c8f279d46431af84b4d47c6edd
parent7d7ef8298d4711206772ff9eb51f5140536cbeab (diff)
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
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139824 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Frontend/CompilerInstance.cpp2
-rw-r--r--lib/Serialization/ASTReader.cpp1
-rw-r--r--test/Modules/irgen.c15
3 files changed, 18 insertions, 0 deletions
diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp
index 9087ab58d6..07d438b556 100644
--- a/lib/Frontend/CompilerInstance.cpp
+++ b/lib/Frontend/CompilerInstance.cpp
@@ -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.
diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp
index 30c44291ee..e4f9fa693c 100644
--- a/lib/Serialization/ASTReader.cpp
+++ b/lib/Serialization/ASTReader.cpp
@@ -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
index 0000000000..0debf05f59
--- /dev/null
+++ b/test/Modules/irgen.c
@@ -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