diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2018-07-04 02:25:38 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2018-07-04 02:25:38 +0000 |
commit | 600adef31bdb2dcc20f89a1633a55d27966e9de6 (patch) | |
tree | c6cc4cc98ec051e5605d0a2293b996c36a2c1e86 /clang/test/Modules | |
parent | f18adbb3cb327d119e6ba595a211afcc4a6ba196 (diff) | |
download | bcm5719-llvm-600adef31bdb2dcc20f89a1633a55d27966e9de6.tar.gz bcm5719-llvm-600adef31bdb2dcc20f89a1633a55d27966e9de6.zip |
PR33924: merge local declarations that have linkage of some kind within
merged function definitions; also merge functions with deduced return
types.
This seems like two independent fixes, but unfortunately they are hard
to separate because it's challenging to reliably test either one of them
without also testing the other.
A complication arises with deduced return type support: we need the type
of the function in order to know how to merge it, but we can't load the
actual type of the function because it might reference an entity
declared within the function (and we need to have already merged the
function to correctly merge that entity, which we would need to do to
determine if the function types match). So we instead compare the
declared function type when merging functions, and defer loading the
actual type of a function with a deduced type until we've finished
loading and merging the function.
This reverts r336175, reinstating r336021, with one change (for PR38015):
we look at the TypeSourceInfo of the first-so-far declaration of each
function when considering whether to merge two functions. This works
around a problem where the calling convention in the TypeSourceInfo for
subsequent redeclarations may not match if it was implicitly adjusted.
llvm-svn: 336240
Diffstat (limited to 'clang/test/Modules')
-rw-r--r-- | clang/test/Modules/cxx-dtor.cpp | 1 | ||||
-rw-r--r-- | clang/test/Modules/friend-definition-2.cpp | 1 | ||||
-rw-r--r-- | clang/test/Modules/merge-deduced-return.cpp | 33 | ||||
-rw-r--r-- | clang/test/Modules/merge-lambdas.cpp | 48 | ||||
-rw-r--r-- | clang/test/Modules/merge-static-locals.cpp | 27 | ||||
-rw-r--r-- | clang/test/Modules/pr27401.cpp | 1 |
6 files changed, 111 insertions, 0 deletions
diff --git a/clang/test/Modules/cxx-dtor.cpp b/clang/test/Modules/cxx-dtor.cpp index 63427ee0afd..d685b69d511 100644 --- a/clang/test/Modules/cxx-dtor.cpp +++ b/clang/test/Modules/cxx-dtor.cpp @@ -1,3 +1,4 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -x c++ -std=c++11 -fmodules-cache-path=%t -I %S/Inputs/cxx-dtor -emit-llvm-only %s +// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -x c++ -std=c++11 -fmodules-cache-path=%t -I %S/Inputs/cxx-dtor -emit-llvm-only %s -triple i686-windows #include "b.h" diff --git a/clang/test/Modules/friend-definition-2.cpp b/clang/test/Modules/friend-definition-2.cpp index 7f876b762af..b226b5c0d1e 100644 --- a/clang/test/Modules/friend-definition-2.cpp +++ b/clang/test/Modules/friend-definition-2.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -fmodules %s -verify +// RUN: %clang_cc1 -fmodules %s -verify -triple i686-windows // expected-no-diagnostics #pragma clang module build A module A {} diff --git a/clang/test/Modules/merge-deduced-return.cpp b/clang/test/Modules/merge-deduced-return.cpp new file mode 100644 index 00000000000..0a4de7b9755 --- /dev/null +++ b/clang/test/Modules/merge-deduced-return.cpp @@ -0,0 +1,33 @@ +// RUN: %clang_cc1 -fmodules -std=c++17 -verify %s +// RUN: %clang_cc1 -fmodules -std=c++17 -verify %s -DLOCAL +// expected-no-diagnostics + +#pragma clang module build A +module A {} +#pragma clang module contents +#pragma clang module begin A +inline auto f() { struct X {}; return X(); } +inline auto a = f(); +#pragma clang module end +#pragma clang module endbuild + +#pragma clang module build B +module B {} +#pragma clang module contents +#pragma clang module begin B +inline auto f() { struct X {}; return X(); } +inline auto b = f(); +#pragma clang module end +#pragma clang module endbuild + +#ifdef LOCAL +inline auto f() { struct X {}; return X(); } +inline auto b = f(); +#else +#pragma clang module import B +#endif + +#pragma clang module import A + +using T = decltype(a); +using T = decltype(b); diff --git a/clang/test/Modules/merge-lambdas.cpp b/clang/test/Modules/merge-lambdas.cpp new file mode 100644 index 00000000000..d14483aa3aa --- /dev/null +++ b/clang/test/Modules/merge-lambdas.cpp @@ -0,0 +1,48 @@ +// RUN: %clang_cc1 -fmodules -verify %s +// expected-no-diagnostics + +#pragma clang module build A +module A {} +#pragma clang module contents +#pragma clang module begin A +template<typename T> auto f() { return []{}; } +#pragma clang module end +#pragma clang module endbuild + +#pragma clang module build B +module B {} +#pragma clang module contents +#pragma clang module begin B +#pragma clang module import A +inline auto x1() { return f<int>(); } +inline auto z() { return []{}; } +inline auto x2() { return z(); } +#pragma clang module end +#pragma clang module endbuild + +#pragma clang module build C +module C {} +#pragma clang module contents +#pragma clang module begin C +#pragma clang module import A +inline auto y1() { return f<int>(); } +inline auto z() { return []{}; } +inline auto y2() { return z(); } +inline auto q() { return []{}; } +inline auto y3() { return q(); } +#pragma clang module end +#pragma clang module endbuild + +inline auto q() { return []{}; } +inline auto x3() { return q(); } + +#pragma clang module import B +#pragma clang module import C +using T = decltype(x1); +using T = decltype(y1); + +using U = decltype(x2); +using U = decltype(y2); + +using V = decltype(x3); +using V = decltype(y3); diff --git a/clang/test/Modules/merge-static-locals.cpp b/clang/test/Modules/merge-static-locals.cpp new file mode 100644 index 00000000000..37ae22ee38a --- /dev/null +++ b/clang/test/Modules/merge-static-locals.cpp @@ -0,0 +1,27 @@ +// RUN: %clang_cc1 -std=c++17 -fmodules -verify %s +// expected-no-diagnostics + +#pragma clang module build A +module A {} +#pragma clang module contents +#pragma clang module begin A +template<int*> struct X {}; +auto get() { static int n; return X<&n>(); } +using A = decltype(get()); +#pragma clang module end +#pragma clang module endbuild + +#pragma clang module build B +module B {} +#pragma clang module contents +#pragma clang module begin B +template<int*> struct X {}; +auto get() { static int n; return X<&n>(); } +using B = decltype(get()); +#pragma clang module end +#pragma clang module endbuild + +#pragma clang module import A +#pragma clang module import B +using T = A; +using T = B; diff --git a/clang/test/Modules/pr27401.cpp b/clang/test/Modules/pr27401.cpp index 7d5479cb924..8db3bbb0094 100644 --- a/clang/test/Modules/pr27401.cpp +++ b/clang/test/Modules/pr27401.cpp @@ -1,6 +1,7 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -std=c++11 -I%S/Inputs/PR27401 -verify %s // RUN: %clang_cc1 -std=c++11 -fmodules -fmodule-map-file=%S/Inputs/PR27401/module.modulemap -fmodules-cache-path=%t -I%S/Inputs/PR27401 -verify %s +// RUN: %clang_cc1 -std=c++11 -fmodules -fmodule-map-file=%S/Inputs/PR27401/module.modulemap -fmodules-cache-path=%t -I%S/Inputs/PR27401 -verify %s -triple i686-windows #include "a.h" #define _LIBCPP_VECTOR |