summaryrefslogtreecommitdiffstats
path: root/clang/test/Modules
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2013-02-12 05:48:23 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2013-02-12 05:48:23 +0000
commit8858159fb543624c61459f3afa219404bf3cf6fa (patch)
treeaac154f261ad359c0bce13ea779444c4ce117929 /clang/test/Modules
parent277775b8afbc517731d4846d0fbd43ac7f8ac8d2 (diff)
downloadbcm5719-llvm-8858159fb543624c61459f3afa219404bf3cf6fa.tar.gz
bcm5719-llvm-8858159fb543624c61459f3afa219404bf3cf6fa.zip
Fix a bug reduced from a crash when trying to use modules with libc++. We check
the linkage of functions and variables while merging declarations from modules, and we don't necessarily have enough of the rest of the AST loaded at that point to allow us to compute linkage, so serialize it instead. llvm-svn: 174943
Diffstat (limited to 'clang/test/Modules')
-rw-r--r--clang/test/Modules/Inputs/cxx-linkage-cache.h11
-rw-r--r--clang/test/Modules/Inputs/module.map4
-rw-r--r--clang/test/Modules/cxx-linkage-cache.cpp8
3 files changed, 23 insertions, 0 deletions
diff --git a/clang/test/Modules/Inputs/cxx-linkage-cache.h b/clang/test/Modules/Inputs/cxx-linkage-cache.h
new file mode 100644
index 00000000000..df829279761
--- /dev/null
+++ b/clang/test/Modules/Inputs/cxx-linkage-cache.h
@@ -0,0 +1,11 @@
+// Reduced from a crash encountered with a modularized libc++, where
+// we would try to compute the linkage of a declaration before we
+// finish loading the relevant pieces of it.
+inline namespace D {
+ template<class>
+ struct U {
+ friend bool f(const U &);
+ };
+
+ template class U<int>;
+}
diff --git a/clang/test/Modules/Inputs/module.map b/clang/test/Modules/Inputs/module.map
index f219036e21d..53f2fd65d34 100644
--- a/clang/test/Modules/Inputs/module.map
+++ b/clang/test/Modules/Inputs/module.map
@@ -179,3 +179,7 @@ module cxx_many_overloads {
module cxx_inline_namespace {
header "cxx-inline-namespace.h"
}
+
+module cxx_linkage_cache {
+ header "cxx-linkage-cache.h"
+}
diff --git a/clang/test/Modules/cxx-linkage-cache.cpp b/clang/test/Modules/cxx-linkage-cache.cpp
new file mode 100644
index 00000000000..296cc8034f5
--- /dev/null
+++ b/clang/test/Modules/cxx-linkage-cache.cpp
@@ -0,0 +1,8 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -x objective-c++ -fmodules -fmodules-cache-path=%t -I %S/Inputs %s -verify -std=c++11
+
+@import cxx_linkage_cache;
+
+T x; // expected-error {{unknown type name 'T'}}
+D::U<int> u;
+bool b = f(u);
OpenPOWER on IntegriCloud