2014-03-08 08:03:56 +08:00
|
|
|
module c_library [extern_c] { module inner { header "c-header.h" } }
|
2014-03-02 13:58:18 +08:00
|
|
|
module cxx_library { header "cxx-header.h" requires cplusplus }
|
|
|
|
module c_library_bad [extern_c] { header "c-header-bad.h" }
|
2011-11-17 07:02:25 +08:00
|
|
|
module diamond_top { header "diamond_top.h" }
|
2011-12-02 09:47:07 +08:00
|
|
|
module diamond_left {
|
|
|
|
header "diamond_left.h"
|
|
|
|
export diamond_top
|
|
|
|
}
|
|
|
|
module diamond_right {
|
|
|
|
header "diamond_right.h"
|
|
|
|
export diamond_top
|
|
|
|
}
|
|
|
|
module diamond_bottom {
|
|
|
|
header "diamond_bottom.h"
|
2011-12-06 01:28:06 +08:00
|
|
|
export *
|
2011-12-02 09:47:07 +08:00
|
|
|
}
|
2011-11-17 07:02:25 +08:00
|
|
|
module irgen { header "irgen.h" }
|
2014-03-22 09:43:32 +08:00
|
|
|
module cxx_irgen_top { header "cxx-irgen-top.h" }
|
|
|
|
module cxx_irgen_left { header "cxx-irgen-left.h" }
|
|
|
|
module cxx_irgen_right { header "cxx-irgen-right.h" }
|
2011-11-17 07:02:25 +08:00
|
|
|
module lookup_left_objc { header "lookup_left.h" }
|
|
|
|
module lookup_right_objc { header "lookup_right.h" }
|
|
|
|
module lookup_left_cxx { header "lookup_left.hpp" }
|
|
|
|
module lookup_right_cxx { header "lookup_right.hpp" }
|
|
|
|
module module_private_left { header "module_private_left.h" }
|
|
|
|
module module_private_right { header "module_private_right.h" }
|
2012-10-11 08:46:49 +08:00
|
|
|
module macros_top {
|
|
|
|
header "macros_top.h"
|
2014-03-06 11:16:27 +08:00
|
|
|
explicit module b { header "macros_top_b.h" }
|
|
|
|
explicit module c { header "macros_top_c.h" }
|
2012-10-11 08:46:49 +08:00
|
|
|
}
|
|
|
|
module macros_left {
|
|
|
|
header "macros_left.h"
|
|
|
|
export *
|
|
|
|
}
|
|
|
|
module macros_right {
|
|
|
|
header "macros_right.h"
|
|
|
|
export *
|
2012-10-12 08:16:50 +08:00
|
|
|
explicit module undef {
|
|
|
|
header "macros_right_undef.h"
|
|
|
|
}
|
2012-10-11 08:46:49 +08:00
|
|
|
}
|
2014-08-09 09:24:07 +08:00
|
|
|
module macros_bottom {
|
|
|
|
header "macros_bottom.h"
|
|
|
|
export *
|
|
|
|
}
|
2011-11-17 07:02:25 +08:00
|
|
|
module macros { header "macros.h" }
|
2014-03-01 08:08:04 +08:00
|
|
|
module macros_other { header "macros_other.h" }
|
2011-11-17 07:02:25 +08:00
|
|
|
module category_top { header "category_top.h" }
|
2011-12-03 04:08:44 +08:00
|
|
|
module category_left {
|
|
|
|
header "category_left.h"
|
|
|
|
export category_top
|
2013-01-17 07:00:23 +08:00
|
|
|
|
|
|
|
explicit module sub {
|
|
|
|
header "category_left_sub.h"
|
|
|
|
}
|
2011-12-03 04:08:44 +08:00
|
|
|
}
|
|
|
|
module category_right {
|
|
|
|
header "category_right.h"
|
|
|
|
export category_top
|
2013-01-17 07:00:23 +08:00
|
|
|
|
|
|
|
explicit module sub {
|
|
|
|
header "category_right_sub.h"
|
|
|
|
}
|
2011-12-03 04:08:44 +08:00
|
|
|
}
|
|
|
|
module category_bottom {
|
|
|
|
header "category_bottom.h"
|
|
|
|
export category_left
|
|
|
|
export category_right
|
|
|
|
}
|
2012-01-27 09:47:08 +08:00
|
|
|
module category_other { header "category_other.h" }
|
2011-11-17 07:02:25 +08:00
|
|
|
module redeclarations_left { header "redeclarations_left.h" }
|
|
|
|
module redeclarations_right { header "redeclarations_right.h" }
|
2012-04-12 15:56:21 +08:00
|
|
|
module redecl_namespaces_left { header "redecl_namespaces_left.h" }
|
|
|
|
module redecl_namespaces_right { header "redecl_namespaces_right.h" }
|
If a declaration is loaded, and then a module import adds a redeclaration, then
ensure that querying the first declaration for its most recent declaration
checks for redeclarations from the imported module.
This works as follows:
* The 'most recent' pointer on a canonical declaration grows a pointer to the
external AST source and a generation number (space- and time-optimized for
the case where there is no external source).
* Each time the 'most recent' pointer is queried, if it has an external source,
we check whether it's up to date, and update it if not.
* The ancillary data stored on the canonical declaration is allocated lazily
to avoid filling it in for declarations that end up being non-canonical.
We'll still perform a redundant (ASTContext) allocation if someone asks for
the most recent declaration from a decl before setPreviousDecl is called,
but such cases are probably all bugs, and are now easy to find.
Some finessing is still in order here -- in particular, we use a very general
mechanism for handling the DefinitionData pointer on CXXRecordData, and a more
targeted approach would be more compact.
Also, the MayHaveOutOfDateDef mechanism should now be expunged, since it was
addressing only a corner of the full problem space here. That's not covered
by this patch.
Early performance benchmarks show that this makes no measurable difference to
Clang performance without modules enabled (and fixes a major correctness issue
with modules enabled). I'll revert if a full performance comparison shows any
problems.
llvm-svn: 209046
2014-05-17 07:01:30 +08:00
|
|
|
module redecl_add_after_load_top { header "redecl-add-after-load-top.h" }
|
2014-05-20 04:59:20 +08:00
|
|
|
module redecl_add_after_load_decls { header "redecl-add-after-load-decls.h" }
|
If a declaration is loaded, and then a module import adds a redeclaration, then
ensure that querying the first declaration for its most recent declaration
checks for redeclarations from the imported module.
This works as follows:
* The 'most recent' pointer on a canonical declaration grows a pointer to the
external AST source and a generation number (space- and time-optimized for
the case where there is no external source).
* Each time the 'most recent' pointer is queried, if it has an external source,
we check whether it's up to date, and update it if not.
* The ancillary data stored on the canonical declaration is allocated lazily
to avoid filling it in for declarations that end up being non-canonical.
We'll still perform a redundant (ASTContext) allocation if someone asks for
the most recent declaration from a decl before setPreviousDecl is called,
but such cases are probably all bugs, and are now easy to find.
Some finessing is still in order here -- in particular, we use a very general
mechanism for handling the DefinitionData pointer on CXXRecordData, and a more
targeted approach would be more compact.
Also, the MayHaveOutOfDateDef mechanism should now be expunged, since it was
addressing only a corner of the full problem space here. That's not covered
by this patch.
Early performance benchmarks show that this makes no measurable difference to
Clang performance without modules enabled (and fixes a major correctness issue
with modules enabled). I'll revert if a full performance comparison shows any
problems.
llvm-svn: 209046
2014-05-17 07:01:30 +08:00
|
|
|
module redecl_add_after_load { header "redecl-add-after-load.h" }
|
2011-11-17 07:02:25 +08:00
|
|
|
module load_failure { header "load_failure.h" }
|
2011-12-15 00:03:29 +08:00
|
|
|
|
|
|
|
module decldef {
|
|
|
|
explicit module Decl { header "decl.h" }
|
2011-12-16 11:12:41 +08:00
|
|
|
explicit module Decl2 { header "decl2.h" }
|
2011-12-15 00:03:29 +08:00
|
|
|
explicit module Def { header "def.h" }
|
Completely re-implement (de-)serialization of declaration
chains. The previous implementation relied heavily on the declaration
chain being stored as a (circular) linked list on disk, as it is in
memory. However, when deserializing from multiple modules, the
different chains could get mixed up, leading to broken declaration chains.
The new solution keeps track of the first and last declarations in the
chain for each module file. When we load a declaration, we search all
of the module files for redeclarations of that declaration, then
splice together all of the lists into a coherent whole (along with any
redeclarations that were actually parsed).
As a drive-by fix, (de-)serialize the redeclaration chains of
TypedefNameDecls, which had somehow gotten missed previously. Add a
test of this serialization.
This new scheme creates a redeclaration table that is fairly large in
the PCH file (on the order of 400k for Cocoa.h's 12MB PCH file). The
table is mmap'd in and searched via a binary search, but it's still
quite large. A future tweak will eliminate entries for declarations
that have no redeclarations anywhere, and should
drastically reduce the size of this table.
llvm-svn: 146841
2011-12-18 07:38:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
module redecl_merge_top {
|
2011-12-21 02:11:52 +08:00
|
|
|
header "redecl-merge-top.h"
|
|
|
|
explicit module Explicit { header "redecl-merge-top-explicit.h" }
|
2012-11-16 03:47:16 +08:00
|
|
|
exclude header "nonexistent.h"
|
Completely re-implement (de-)serialization of declaration
chains. The previous implementation relied heavily on the declaration
chain being stored as a (circular) linked list on disk, as it is in
memory. However, when deserializing from multiple modules, the
different chains could get mixed up, leading to broken declaration chains.
The new solution keeps track of the first and last declarations in the
chain for each module file. When we load a declaration, we search all
of the module files for redeclarations of that declaration, then
splice together all of the lists into a coherent whole (along with any
redeclarations that were actually parsed).
As a drive-by fix, (de-)serialize the redeclaration chains of
TypedefNameDecls, which had somehow gotten missed previously. Add a
test of this serialization.
This new scheme creates a redeclaration table that is fairly large in
the PCH file (on the order of 400k for Cocoa.h's 12MB PCH file). The
table is mmap'd in and searched via a binary search, but it's still
quite large. A future tweak will eliminate entries for declarations
that have no redeclarations anywhere, and should
drastically reduce the size of this table.
llvm-svn: 146841
2011-12-18 07:38:30 +08:00
|
|
|
}
|
|
|
|
module redecl_merge_left {
|
|
|
|
header "redecl-merge-left.h"
|
|
|
|
export *
|
|
|
|
}
|
2011-12-23 03:44:59 +08:00
|
|
|
module redecl_merge_left_left {
|
|
|
|
header "redecl-merge-left-left.h"
|
|
|
|
export *
|
|
|
|
}
|
Completely re-implement (de-)serialization of declaration
chains. The previous implementation relied heavily on the declaration
chain being stored as a (circular) linked list on disk, as it is in
memory. However, when deserializing from multiple modules, the
different chains could get mixed up, leading to broken declaration chains.
The new solution keeps track of the first and last declarations in the
chain for each module file. When we load a declaration, we search all
of the module files for redeclarations of that declaration, then
splice together all of the lists into a coherent whole (along with any
redeclarations that were actually parsed).
As a drive-by fix, (de-)serialize the redeclaration chains of
TypedefNameDecls, which had somehow gotten missed previously. Add a
test of this serialization.
This new scheme creates a redeclaration table that is fairly large in
the PCH file (on the order of 400k for Cocoa.h's 12MB PCH file). The
table is mmap'd in and searched via a binary search, but it's still
quite large. A future tweak will eliminate entries for declarations
that have no redeclarations anywhere, and should
drastically reduce the size of this table.
llvm-svn: 146841
2011-12-18 07:38:30 +08:00
|
|
|
module redecl_merge_right {
|
|
|
|
header "redecl-merge-right.h"
|
|
|
|
export *
|
|
|
|
}
|
|
|
|
module redecl_merge_bottom {
|
2013-02-12 02:16:18 +08:00
|
|
|
explicit module prefix {
|
|
|
|
header "redecl-merge-bottom-prefix.h"
|
|
|
|
}
|
|
|
|
|
Completely re-implement (de-)serialization of declaration
chains. The previous implementation relied heavily on the declaration
chain being stored as a (circular) linked list on disk, as it is in
memory. However, when deserializing from multiple modules, the
different chains could get mixed up, leading to broken declaration chains.
The new solution keeps track of the first and last declarations in the
chain for each module file. When we load a declaration, we search all
of the module files for redeclarations of that declaration, then
splice together all of the lists into a coherent whole (along with any
redeclarations that were actually parsed).
As a drive-by fix, (de-)serialize the redeclaration chains of
TypedefNameDecls, which had somehow gotten missed previously. Add a
test of this serialization.
This new scheme creates a redeclaration table that is fairly large in
the PCH file (on the order of 400k for Cocoa.h's 12MB PCH file). The
table is mmap'd in and searched via a binary search, but it's still
quite large. A future tweak will eliminate entries for declarations
that have no redeclarations anywhere, and should
drastically reduce the size of this table.
llvm-svn: 146841
2011-12-18 07:38:30 +08:00
|
|
|
header "redecl-merge-bottom.h"
|
|
|
|
export *
|
|
|
|
}
|
2012-01-07 17:11:48 +08:00
|
|
|
module namespaces_top {
|
|
|
|
header "namespaces-top.h"
|
|
|
|
export *
|
|
|
|
}
|
|
|
|
module namespaces_left {
|
|
|
|
header "namespaces-left.h"
|
|
|
|
export *
|
|
|
|
}
|
|
|
|
module namespaces_right {
|
|
|
|
header "namespaces-right.h"
|
|
|
|
export *
|
|
|
|
}
|
2012-10-02 17:09:43 +08:00
|
|
|
module templates_top {
|
|
|
|
header "templates-top.h"
|
|
|
|
export *
|
|
|
|
}
|
|
|
|
module templates_left {
|
|
|
|
header "templates-left.h"
|
|
|
|
export *
|
|
|
|
}
|
|
|
|
module templates_right {
|
|
|
|
header "templates-right.h"
|
|
|
|
export *
|
|
|
|
}
|
2012-01-25 08:59:09 +08:00
|
|
|
module MethodPoolA {
|
|
|
|
header "MethodPoolA.h"
|
2013-01-17 02:47:38 +08:00
|
|
|
|
2013-02-08 03:13:24 +08:00
|
|
|
explicit module Sub2 {
|
|
|
|
header "MethodPoolASub2.h"
|
|
|
|
}
|
|
|
|
|
2013-01-17 02:47:38 +08:00
|
|
|
explicit module Sub {
|
|
|
|
header "MethodPoolASub.h"
|
|
|
|
}
|
2012-01-25 08:59:09 +08:00
|
|
|
}
|
|
|
|
module MethodPoolB {
|
|
|
|
header "MethodPoolB.h"
|
2013-01-17 02:47:38 +08:00
|
|
|
|
2013-06-21 08:20:25 +08:00
|
|
|
explicit module Sub2 {
|
|
|
|
header "MethodPoolBSub2.h"
|
|
|
|
}
|
|
|
|
|
2013-01-17 02:47:38 +08:00
|
|
|
explicit module Sub {
|
|
|
|
header "MethodPoolBSub.h"
|
|
|
|
}
|
2012-01-25 08:59:09 +08:00
|
|
|
}
|
2012-05-17 00:31:58 +08:00
|
|
|
module import_decl {
|
|
|
|
header "import-decl.h"
|
|
|
|
}
|
2012-11-07 03:39:40 +08:00
|
|
|
|
|
|
|
framework module * {
|
|
|
|
exclude NotAModule
|
|
|
|
}
|
2013-01-09 08:47:56 +08:00
|
|
|
|
|
|
|
module linkage_merge_left {
|
|
|
|
explicit module sub {
|
|
|
|
header "linkage-merge-sub.h"
|
|
|
|
}
|
|
|
|
}
|
2013-01-15 01:21:00 +08:00
|
|
|
|
|
|
|
module autolink {
|
|
|
|
header "autolink.h"
|
|
|
|
link "autolink"
|
|
|
|
|
|
|
|
explicit module sub {
|
|
|
|
header "autolink-sub.h"
|
|
|
|
link "autolink_sub"
|
|
|
|
}
|
|
|
|
|
|
|
|
explicit module sub2 {
|
|
|
|
header "autolink-sub2.h"
|
|
|
|
link framework "autolink_framework"
|
|
|
|
}
|
2014-01-31 09:06:56 +08:00
|
|
|
|
|
|
|
explicit module sub3 {
|
|
|
|
header "autolink-sub3.h"
|
|
|
|
link "autolink_from_pch"
|
|
|
|
}
|
2013-01-15 01:21:00 +08:00
|
|
|
}
|
2013-02-02 07:45:03 +08:00
|
|
|
|
|
|
|
module weird_objc {
|
|
|
|
header "weird_objc.h"
|
|
|
|
}
|
2013-02-07 06:40:31 +08:00
|
|
|
|
2020-02-13 07:40:00 +08:00
|
|
|
module objc_type_param {
|
|
|
|
header "objc_type_param.h"
|
|
|
|
}
|
|
|
|
|
2013-02-07 06:40:31 +08:00
|
|
|
module ignored_macros {
|
|
|
|
header "ignored_macros.h"
|
|
|
|
}
|
2013-02-08 08:37:45 +08:00
|
|
|
|
|
|
|
module cxx_many_overloads {
|
|
|
|
header "cxx-many-overloads.h"
|
|
|
|
}
|
2013-02-12 10:32:35 +08:00
|
|
|
|
|
|
|
module cxx_inline_namespace {
|
|
|
|
header "cxx-inline-namespace.h"
|
|
|
|
}
|
2013-02-12 13:48:23 +08:00
|
|
|
|
2014-03-24 04:41:56 +08:00
|
|
|
module cxx_inline_namespace_b {
|
|
|
|
header "cxx-inline-namespace-b.h"
|
|
|
|
}
|
|
|
|
|
2013-02-12 13:48:23 +08:00
|
|
|
module cxx_linkage_cache {
|
|
|
|
header "cxx-linkage-cache.h"
|
|
|
|
}
|
2013-03-20 08:22:05 +08:00
|
|
|
|
2013-06-25 09:25:15 +08:00
|
|
|
module cxx_templates_common {
|
|
|
|
header "cxx-templates-common.h"
|
2016-05-05 08:56:12 +08:00
|
|
|
|
|
|
|
explicit module unimported { header "cxx-templates-unimported.h" }
|
2013-06-25 09:25:15 +08:00
|
|
|
}
|
|
|
|
|
2013-06-24 12:45:28 +08:00
|
|
|
module cxx_templates_a {
|
|
|
|
header "cxx-templates-a.h"
|
|
|
|
}
|
|
|
|
|
When we perform dependent name lookup during template instantiation, it's not
sufficient to only consider names visible at the point of instantiation,
because that may not include names that were visible when the template was
defined. More generally, if the instantiation backtrace goes through a module
M, then every declaration visible within M should be available to the
instantiation. Any of those declarations might be part of the interface that M
intended to export to a template that it instantiates.
The fix here has two parts:
1) If we find a non-visible declaration during name lookup during template
instantiation, check whether the declaration was visible from the defining
module of all entities on the active template instantiation stack. The defining
module is not the owning module in all cases: we look at the module in which a
template was defined, not the module in which it was first instantiated.
2) Perform pending instantiations at the end of a module, not at the end of the
translation unit. This is general goodness, since it significantly cuts down
the amount of redundant work that is performed in every TU importing a module,
and also implicitly adds the module containing the point of instantiation to
the set of modules checked for declarations in a lookup within a template
instantiation.
There's a known issue here with template instantiations performed while
building a module, if additional imports are added later on. I'll fix that
in a subsequent commit.
llvm-svn: 187167
2013-07-26 07:08:39 +08:00
|
|
|
module cxx_templates_b_impl {
|
|
|
|
header "cxx-templates-b-impl.h"
|
|
|
|
}
|
|
|
|
|
2013-06-24 12:45:28 +08:00
|
|
|
module cxx_templates_b {
|
|
|
|
header "cxx-templates-b.h"
|
|
|
|
}
|
|
|
|
|
2013-10-16 07:19:58 +08:00
|
|
|
module cxx_templates_c {
|
|
|
|
header "cxx-templates-c.h"
|
|
|
|
}
|
|
|
|
|
2014-08-28 13:44:07 +08:00
|
|
|
module cxx_templates_d {
|
|
|
|
header "cxx-templates-d.h"
|
|
|
|
}
|
|
|
|
|
2013-07-14 10:01:48 +08:00
|
|
|
module cxx_decls {
|
|
|
|
module unimported {
|
|
|
|
header "cxx-decls-unimported.h"
|
|
|
|
}
|
|
|
|
module imported {
|
|
|
|
header "cxx-decls-imported.h"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-30 06:33:38 +08:00
|
|
|
module cxx_decls_premerged {
|
|
|
|
header "cxx-decls-premerged.h"
|
|
|
|
}
|
|
|
|
|
2014-06-17 04:26:19 +08:00
|
|
|
module cxx_decls_merged {
|
|
|
|
header "cxx-decls-merged.h"
|
|
|
|
}
|
|
|
|
|
2013-03-20 08:22:05 +08:00
|
|
|
module config {
|
|
|
|
header "config.h"
|
|
|
|
config_macros [exhaustive] WANT_FOO, WANT_BAR
|
|
|
|
}
|
2013-03-28 01:17:23 +08:00
|
|
|
|
2017-05-02 06:10:47 +08:00
|
|
|
module diag_flags {
|
|
|
|
header "diag_flags.h"
|
|
|
|
}
|
|
|
|
|
2013-03-28 01:17:23 +08:00
|
|
|
module diag_pragma {
|
|
|
|
header "diag_pragma.h"
|
|
|
|
}
|
2013-04-04 07:06:26 +08:00
|
|
|
|
Modules: Do not serialize #pragma pack state
The modules side of r299226, which serializes #pragma pack state,
doesn't work well.
The main purpose was to make -include and -include-pch match semantics
(the PCH side). We also started serializing #pragma pack in PCMs, in
the hopes of making modules and non-modules builds more consistent. But
consider:
$ cat a.h
$ cat b.h
#pragma pack(push, 2)
$ cat module.modulemap
module M {
module a { header "a.h" }
module b { header "b.h" }
}
$ cat t.cpp
#include "a.h"
#pragma pack(show)
As of r299226, the #pragma pack(show) gives "2", even though we've only
included "a.h".
- With -fmodules-local-submodule-visibility, this is clearly wrong. We
should get the default state (8 on x86_64).
- Without -fmodules-local-submodule-visibility, this kind of matches how
other things work (as if include-the-whole-module), but it's still
really terrible, and it doesn't actually make modules and non-modules
builds more consistent.
This commit disables the serialization for modules, essentially a
partial revert of r299226.
Going forward:
1. Having this #pragma pack stuff escape is terrible design (or, more
often, a horrible bug). We should prioritize adding warnings (maybe
-Werror by default?).
2. If we eventually reintroduce this for modules, it should only apply
to -fmodules-local-submodule-visibility, and it should be tracked on
a per-submodule basis.
llvm-svn: 300380
2017-04-15 08:07:57 +08:00
|
|
|
module pragma_pack {
|
|
|
|
module set { header "pragma_pack_set.h" }
|
|
|
|
module empty { header "empty.h" }
|
2017-03-31 23:36:21 +08:00
|
|
|
}
|
|
|
|
|
2013-08-30 08:23:29 +08:00
|
|
|
module dummy {
|
|
|
|
header "dummy.h"
|
|
|
|
}
|
|
|
|
|
2013-04-04 07:06:26 +08:00
|
|
|
module builtin {
|
|
|
|
header "builtin.h"
|
|
|
|
explicit module sub {
|
|
|
|
header "builtin_sub.h"
|
|
|
|
}
|
|
|
|
}
|
2013-04-04 12:40:17 +08:00
|
|
|
|
|
|
|
module linkage_merge {
|
|
|
|
explicit module foo {
|
|
|
|
header "linkage-merge-foo.h"
|
|
|
|
}
|
|
|
|
explicit module bar {
|
|
|
|
header "linkage-merge-bar.h"
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2013-05-20 21:49:41 +08:00
|
|
|
|
|
|
|
module incomplete_mod {
|
|
|
|
header "incomplete_mod.h"
|
|
|
|
}
|
2013-06-22 00:28:10 +08:00
|
|
|
|
|
|
|
module warning {
|
|
|
|
header "warning.h"
|
|
|
|
}
|
2013-10-18 14:54:39 +08:00
|
|
|
|
Add -Wunused-local-typedef, a warning that finds unused local typedefs.
The warning warns on TypedefNameDecls -- typedefs and C++11 using aliases --
that are !isReferenced(). Since the isReferenced() bit on TypedefNameDecls
wasn't used for anything before this warning it wasn't always set correctly,
so this patch also adds a few missing MarkAnyDeclReferenced() calls in
various places for TypedefNameDecls.
This is made a bit complicated due to local typedefs possibly being used only
after their local scope has closed. Consider:
template <class T>
void template_fun(T t) {
typename T::Foo s3foo; // YYY
(void)s3foo;
}
void template_fun_user() {
struct Local {
typedef int Foo; // XXX
} p;
template_fun(p);
}
Here the typedef in XXX is only used at end-of-translation unit, when YYY in
template_fun() gets instantiated. To handle this, typedefs that are unused when
their scope exits are added to a set of potentially unused typedefs, and that
set gets checked at end-of-TU. Typedefs that are still unused at that point then
get warned on. There's also serialization code for this set, so that the
warning works with precompiled headers and modules. For modules, the warning
is emitted when the module is built, for precompiled headers each time the
header gets used.
Finally, consider a function using C++14 auto return types to return a local
type defined in a header:
auto f() {
struct S { typedef int a; };
return S();
}
Here, the typedef escapes its local scope and could be used by only some
translation units including the header. To not warn on this, add a
RecursiveASTVisitor that marks all delcs on local types returned from auto
functions as referenced. (Except if it's a function with internal linkage, or
the decls are private and the local type has no friends -- in these cases, it
_is_ safe to warn.)
Several of the included testcases (most of the interesting ones) were provided
by Richard Smith.
(gcc's spelling -Wunused-local-typedefs is supported as an alias for this
warning.)
llvm-svn: 217298
2014-09-06 09:25:55 +08:00
|
|
|
module warn_unused_local_typedef {
|
|
|
|
header "warn-unused-local-typedef.h"
|
|
|
|
}
|
|
|
|
|
2013-10-23 10:17:46 +08:00
|
|
|
module using_decl {
|
|
|
|
module a { header "using-decl-a.h" export * }
|
|
|
|
module b { header "using-decl-b.h" export * }
|
|
|
|
}
|
2013-11-05 05:51:33 +08:00
|
|
|
|
|
|
|
module recursive_visibility_a1 {
|
|
|
|
module inner { header "recursive_visibility_a1_inner.h" }
|
|
|
|
}
|
|
|
|
module recursive_visibility_a2 {
|
|
|
|
module inner {
|
|
|
|
module more_inner {
|
|
|
|
header "recursive_visibility_a2_more_inner.h"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
module recursive_visibility_b {
|
|
|
|
header "recursive_visibility_b.h"
|
|
|
|
export *
|
|
|
|
}
|
|
|
|
module recursive_visibility_c {
|
|
|
|
header "recursive_visibility_c.h"
|
|
|
|
}
|
2014-03-06 04:51:45 +08:00
|
|
|
module recursive1 {
|
|
|
|
header "recursive1.h"
|
|
|
|
}
|
|
|
|
module recursive2 {
|
|
|
|
header "recursive2.h"
|
|
|
|
}
|
2015-06-30 01:09:24 +08:00
|
|
|
module crash {
|
|
|
|
header "crash.h"
|
|
|
|
}
|
2015-07-01 01:39:51 +08:00
|
|
|
|
2015-09-09 03:20:27 +08:00
|
|
|
module DebugCXX {
|
|
|
|
header "DebugCXX.h"
|
|
|
|
}
|
|
|
|
|
2015-09-09 04:41:52 +08:00
|
|
|
module DebugObjC {
|
|
|
|
header "DebugObjC.h"
|
|
|
|
}
|
|
|
|
|
2017-07-19 08:09:58 +08:00
|
|
|
module DebugObjCImport {
|
|
|
|
module SubModule {
|
|
|
|
header "DebugObjCImport.h"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-02 21:19:48 +08:00
|
|
|
module ImportNameInDir {
|
|
|
|
header "ImportNameInDir.h"
|
|
|
|
export *
|
|
|
|
}
|
2015-07-14 03:48:52 +08:00
|
|
|
|
|
|
|
module RequiresWithMissingHeader {
|
|
|
|
module HeaderBefore {
|
|
|
|
header "RequiresWithMissingHeader-Missing1.h"
|
|
|
|
requires missing
|
|
|
|
}
|
|
|
|
module HeaderAfter {
|
|
|
|
requires missing
|
|
|
|
header "RequiresWithMissingHeader-Missing2.h"
|
|
|
|
}
|
|
|
|
}
|
2015-08-07 09:59:56 +08:00
|
|
|
|
|
|
|
module TargetFeatures {
|
|
|
|
module arm {
|
|
|
|
requires arm
|
|
|
|
module aarch32 { requires aarch32 }
|
|
|
|
module aarch64 { requires aarch64 }
|
|
|
|
}
|
|
|
|
module x86 {
|
|
|
|
requires x86
|
|
|
|
module x86_32 { requires x86_32 }
|
|
|
|
module x86_64 { requires x86_64 }
|
|
|
|
}
|
2018-04-05 20:54:00 +08:00
|
|
|
module riscv {
|
|
|
|
requires riscv
|
|
|
|
module riscv32 { requires riscv32 }
|
|
|
|
module riscv64 { requires riscv64 }
|
|
|
|
}
|
2015-08-07 09:59:56 +08:00
|
|
|
}
|
2015-09-21 00:51:35 +08:00
|
|
|
|
|
|
|
module DebugSubmodules {
|
|
|
|
module DebugSubmoduleA {
|
|
|
|
header "DebugSubmoduleA.h"
|
|
|
|
export *
|
|
|
|
}
|
|
|
|
module DebugSubmoduleB {
|
|
|
|
header "DebugSubmoduleB.h"
|
|
|
|
export *
|
|
|
|
}
|
|
|
|
}
|
2015-11-04 02:33:07 +08:00
|
|
|
|
|
|
|
module ExtensionTestA {
|
|
|
|
header "ExtensionTestA.h"
|
|
|
|
}
|
2015-11-14 11:26:14 +08:00
|
|
|
|
|
|
|
module TypedefTag {
|
|
|
|
header "typedef-tag.h"
|
|
|
|
explicit module Hidden {
|
|
|
|
header "typedef-tag-hidden.h"
|
|
|
|
}
|
|
|
|
}
|
2015-12-12 06:05:13 +08:00
|
|
|
|
|
|
|
module ElaboratedTypeStructs {
|
|
|
|
module Empty {}
|
|
|
|
module Structs {
|
|
|
|
header "elaborated-type-structs.h"
|
|
|
|
}
|
|
|
|
}
|
2016-04-30 03:04:05 +08:00
|
|
|
|
|
|
|
// We import a module, then declare a method with selector stringValue in
|
|
|
|
// MethodPoolCombined1.h. In MethodPoolCombined2.h, we import another module
|
|
|
|
// that also contains a method for selector stringValue. We make sure that
|
|
|
|
// the method pool entry for stringValue in this module is complete.
|
|
|
|
module MethodPoolCombined {
|
|
|
|
header "MethodPoolCombined1.h"
|
|
|
|
header "MethodPoolCombined2.h"
|
|
|
|
}
|
|
|
|
|
|
|
|
module MethodPoolString1 {
|
|
|
|
header "MethodPoolString1.h"
|
|
|
|
}
|
|
|
|
|
|
|
|
module MethodPoolString2 {
|
|
|
|
header "MethodPoolString2.h"
|
|
|
|
}
|
2016-05-04 08:53:13 +08:00
|
|
|
|
|
|
|
module Empty {}
|
2016-06-01 02:19:32 +08:00
|
|
|
|
|
|
|
module MacroFabs1 {
|
|
|
|
header "MacroFabs1.h"
|
|
|
|
}
|
2016-07-27 01:12:17 +08:00
|
|
|
|
|
|
|
module DiagOutOfDate {
|
|
|
|
header "DiagOutOfDate.h"
|
|
|
|
}
|
2016-08-23 06:23:58 +08:00
|
|
|
|
|
|
|
module DebugNestedA {
|
|
|
|
header "DebugNestedA.h"
|
|
|
|
export *
|
|
|
|
}
|
|
|
|
|
|
|
|
module DebugNestedB {
|
|
|
|
header "DebugNestedB.h"
|
|
|
|
export *
|
|
|
|
}
|
2017-05-17 19:08:36 +08:00
|
|
|
|
|
|
|
module objcAtKeywordMissingEnd {
|
|
|
|
header "objcAtKeywordMissingEnd.h"
|
|
|
|
}
|
2017-08-11 20:06:52 +08:00
|
|
|
|
|
|
|
module innerstructredef {
|
|
|
|
module one {
|
|
|
|
header "empty.h"
|
|
|
|
}
|
|
|
|
module two {
|
|
|
|
header "innerstructredef.h"
|
|
|
|
}
|
|
|
|
}
|
2018-03-20 01:38:40 +08:00
|
|
|
|
|
|
|
module template_nontrivial0 {
|
|
|
|
header "template-nontrivial0.h"
|
|
|
|
export *
|
|
|
|
}
|
|
|
|
|
|
|
|
module template_nontrivial1 {
|
|
|
|
header "template-nontrivial1.h"
|
|
|
|
export *
|
|
|
|
}
|