Commit Graph

63 Commits

Author SHA1 Message Date
Rafael Espindola fb4263f156 Consider the visibility of template template arguments. GCC doesn't, but it also
fails to consider the linkage, which we were already considering.

llvm-svn: 161070
2012-07-31 19:02:02 +00:00
Rafael Espindola a83aaa0da4 Add a missing testcase for merging the visibility of two declarations used
as arguments of a template.

llvm-svn: 160911
2012-07-28 02:51:03 +00:00
Rafael Espindola f97c636812 Record visibility pragmas when we see a tag declaration. We might use it
to build a type before seeing the definition.

llvm-svn: 160339
2012-07-17 04:22:25 +00:00
Rafael Espindola 385c04269f Apply visibility pragmas to class template declarations. This is needed because
we might use the declaration to build a type before seeing the definition.

llvm-svn: 160176
2012-07-13 18:04:45 +00:00
Rafael Espindola eca5cd20a1 Fix a bug in my previous commit. The problem is not that we were not using the
canonical decl for the template, but that we were not merging attributes for
templates at all!

llvm-svn: 160157
2012-07-13 01:19:08 +00:00
Rafael Espindola 6140847647 Use the canonical template decl when trying to find if it has a visibility
attribute.

llvm-svn: 160139
2012-07-12 20:05:04 +00:00
Rafael Espindola 4dedd0ceb8 Process #pragma visibility early in the parsing of class definitions. Fixes
pr13338.

llvm-svn: 160105
2012-07-12 04:47:34 +00:00
Rafael Espindola 1fa9fade38 Handle #pragma visibility in explicit specializations and enums.
llvm-svn: 160057
2012-07-11 18:14:09 +00:00
Rafael Espindola 5f0a1b89d7 Don't process #pragma visibility during instantiation. The visibility of the
instantiation depends on the template, its arguments and parameters, but not
where it is instantiated.

llvm-svn: 160034
2012-07-11 02:15:51 +00:00
Rafael Espindola a486f48e5b We were computing the visibility and linkage of template parameters, but
only using the linkage.

Use and test both, documenting that considering the visibility and linkage
of template parameters is a difference from gcc.

llvm-svn: 158309
2012-06-11 14:29:58 +00:00
Rafael Espindola 67a498cc5f Don't ignore linkage when ignoring visibility in the instantiation of a
method template.

llvm-svn: 157486
2012-05-25 17:22:33 +00:00
Rafael Espindola 340941dc16 Don't ignore linkage when ignoring visibility in the instantiation of a
function template.

llvm-svn: 157480
2012-05-25 16:41:35 +00:00
Rafael Espindola a28bf63d9a Consider the linkage for member class templates even when we have to ignore
the visibility.

llvm-svn: 157475
2012-05-25 15:51:26 +00:00
Rafael Espindola 0cf10ac9ab When ignoring visibility in an instantiation, still consider the linkage.
Similar fixes for function and member template to follow as I write the
testcases.

llvm-svn: 157470
2012-05-25 14:47:05 +00:00
Rafael Espindola 96dcb8d4bb Function template version of the previous patch.
llvm-svn: 157207
2012-05-21 20:31:27 +00:00
Rafael Espindola 93c289c28a Produce a hidden symbol for zed in
struct HIDDEN foo {
  };
  template <class P>
  struct bar {
  };
  template <>
  struct HIDDEN bar<foo> {
    DEFAULT static void zed();
  };
  void bar<foo>::zed() {
  }

Before we would produce a hidden symbol in

  struct HIDDEN foo {
  };
  template <class P>
  struct bar {
  };
  template <>
  struct bar<foo> {
    DEFAULT static void zed();
  };
  void bar<foo>::zed() {
  }

But adding HIDDEN to the specialization would cause us to produce a default
symbol.

llvm-svn: 157206
2012-05-21 20:15:56 +00:00
Rafael Espindola 85e91ba6f5 Test and document a difference from gcc in the handling of visibility
attributes.

llvm-svn: 157186
2012-05-21 14:22:37 +00:00
Rafael Espindola 96e6824c31 Fix the visibility of instantiations of static data members.
Fixes pr12835.

llvm-svn: 156897
2012-05-16 02:10:38 +00:00
Rafael Espindola 7f90b7d4c2 Fix our handling of visibility in explicit template instantiations.
* Don't copy the visibility attribute during instantiations. We have to be able
  to distinguish

 struct HIDDEN foo {};
 template<class T>
 DEFAULT void bar() {}
 template DEFAULT void bar<foo>();

from

 struct HIDDEN foo {};
 template<class T>
 DEFAULT void bar() {}
 template void bar<foo>();

* If an instantiation has an attribute, it takes precedence over an attribute
  in the template.

* With instantiation attributes handled with the above logic, we can now
  select the minimum visibility when looking at template arguments.

llvm-svn: 156821
2012-05-15 14:09:55 +00:00
Rafael Espindola b522a5f246 Fix visibility when we have two types with explicit visibility in a template
argument list.

llvm-svn: 155368
2012-04-23 17:51:55 +00:00
Rafael Espindola 23fd21d4ee Add another testcase that was not being covered.
llvm-svn: 155351
2012-04-23 14:02:53 +00:00
Rafael Espindola cba4879534 Add a testcase that we already get right but was not being tested. Found
by a chrome build on OS X. Thanks to Nico Weber for testing a patch and
providing the .ii file.

llvm-svn: 155326
2012-04-22 22:31:25 +00:00
Rafael Espindola 1e762442c7 Cleanup testcase.
llvm-svn: 155317
2012-04-22 16:03:00 +00:00
Rafael Espindola bbc5cbc410 An attribute in a explicit template installation should take precedence over
the tempale arguments in deciding the visibility.

This agrees with gcc 4.7.

Found by trying to build chrome with component=shared_library with 155314
reverted.

llvm-svn: 155316
2012-04-22 15:31:59 +00:00
Rafael Espindola 6b6e879221 Revert 155102 but add a fixme while I debug what is wrong with chrome's
components build.

llvm-svn: 155314
2012-04-22 12:37:27 +00:00
Rafael Espindola fae3f908d8 Add another missing testcase.
llvm-svn: 155304
2012-04-22 02:41:22 +00:00
Rafael Espindola 4304101fb2 Add a testcase we were already getting right, but were not testing for.
llvm-svn: 155302
2012-04-22 01:22:25 +00:00
Rafael Espindola 8add48ec9e Fix handling of template parameters. Found by inspection. GCC 4.7 agrees
with this testcase.

llvm-svn: 155301
2012-04-22 00:43:48 +00:00
Rafael Espindola 53cf219367 In mergeVisibility, if we already have an explicit visibility, keep it.
This fixes the included testcase and lets us simplify the code a bit. It
does require using mergeWithMin when merging class information to its
members. Expand the comments to explain why that works.

llvm-svn: 155103
2012-04-19 05:50:08 +00:00
Rafael Espindola 1280fe6245 In mergeVisibilityWithMin, let an implicit hidden symbol take precedence over
an explicit default one. This means that with -fvisibility hidden we
now produce a hidden symbol for

template <typename T>
class DEFAULT foo {
  void bar() {}
};
class zed {};
template class foo<zed>;

This matches the behaviour of gcc 4.7.

llvm-svn: 155102
2012-04-19 05:34:51 +00:00
Rafael Espindola 78158af59c Revert r154749 for now at John McCall's request.
llvm-svn: 154846
2012-04-16 18:46:26 +00:00
Rafael Espindola 0aec8ece52 Consider visibility attributes last, so that they take precedence.
I am working on a cleaner fix, but this gets the case in PR12552 passing.

llvm-svn: 154749
2012-04-14 15:21:19 +00:00
Rafael Espindola 1f71a23985 The type of a definition should not increase its visibility. Fixes PR12221.
llvm-svn: 152493
2012-03-10 13:01:40 +00:00
Rafael Espindola 8093fdfab1 Two fixes to how we compute visibility:
* Handle some situations where we should never make a decl more visible,
  even when merging in an explicit visibility.

* Handle attributes in members of classes that are explicitly specialized.

Thanks Nico for the report and testing, Eric for the initial review, and dgregor
for the awesome test27 :-)

llvm-svn: 151236
2012-02-23 04:17:32 +00:00
Rafael Espindola 2f869a3f4f Remember if a type has its visibility set explicitly or implicitly.
With that, centralize the way we merge visibility, always preferring explicit over
implicit and then picking the most restrictive one.
Fixes pr10113 and pr11690.

llvm-svn: 148163
2012-01-14 00:30:36 +00:00
Rafael Espindola 2aa7acfadb Process attributes in explicit function template instantiations. Fixes part of
PR11690.

llvm-svn: 147523
2012-01-04 05:40:59 +00:00
Rafael Espindola 0b0620776a Process attributes in explicit template instatiation definitions. Fixes PR11690.
llvm-svn: 147441
2012-01-03 06:04:21 +00:00
Rafael Espindola eeb9d9fef6 Small cosmetic cleanups in code I will change anyway.
llvm-svn: 147424
2012-01-02 06:26:22 +00:00
Rafael Espindola 0f960a0a5a Consider visibility attributes in namespaces as being explicit. I.e., they
take precedence over command line options. Fixes PR10113.

llvm-svn: 147405
2012-01-01 18:06:40 +00:00
Eli Friedman e321795c60 Remove a non-gcc-compatible extension that would apply attributes on declarations without a declarator to structs. Add a warning for ignored attributes. Patch by Michael Han.
llvm-svn: 146796
2011-12-17 00:36:09 +00:00
Peter Collingbourne 71c26936a0 Remove CodeGenVTables::ComputeVTableRelatedInformation dependency on CodeGen
llvm-svn: 140503
2011-09-26 01:56:36 +00:00
John McCall b8c604abfd Don't factor in visibility for templates and template arguments
for explicit specializations with their own explicit visibility.

llvm-svn: 133958
2011-06-27 23:06:04 +00:00
John McCall 8bc6d5b919 Don't consider visibility from template parameter lists if we're
computing for a nested decl with explicit visibility.  This is all part
of the general philosophy of explicit visibility attributes, where
any information that was obviously available at the attribute site
should probably be ignored.  Fixes PR9371.

llvm-svn: 126992
2011-03-04 10:39:25 +00:00
Anders Carlsson 571e2ad042 Mark VTables and RTTI data linkonce_odr instead of weak_odr, with the exception of explicit template instantiations, which have to be weak_odr.
This fixes PR6996.

llvm-svn: 124089
2011-01-24 00:46:19 +00:00
Rafael Espindola facb7d0ade Also set unnamed_addr on declarations.
llvm-svn: 123531
2011-01-15 08:23:14 +00:00
Rafael Espindola d09776b945 Only add unnamed_addr to definitions.
llvm-svn: 123354
2011-01-13 01:12:55 +00:00
Rafael Espindola bb7f7686c5 Set unnamed_addr in VTTs.
llvm-svn: 123280
2011-01-11 22:29:55 +00:00
Rafael Espindola 5674c644cf Add unnamed_addr to vtables.
llvm-svn: 123272
2011-01-11 21:10:26 +00:00
John McCall ec00cd9713 Fix test. I added one last test and then forget to re-check.
llvm-svn: 122137
2010-12-18 03:52:04 +00:00
John McCall 659a337c74 Apply attributes to explicit specializations. Specializations which
don't provide their own explicit visibility attributes should get them
from the template.  Fixes rdar://problem/8778497.

llvm-svn: 122136
2010-12-18 03:30:47 +00:00