Commit Graph

985 Commits

Author SHA1 Message Date
Vassil Vassilev e53a4b7402 [modules] PR28812: Modules can return duplicate field decls.
If two modules contain duplicate class definitions the lookup result can contain
more than 2 elements. Sift the lookup results until we find a field decl.

It is not necessary to do ODR checks in place as they done elsewhere.

This should fix issues when compiling with libstdc++ 5.2 and 6.2.

Patch developed in collaboration with Richard Smith!

llvm-svn: 285184
2016-10-26 10:24:29 +00:00
Richard Smith 842e46e606 [modules] Fix assert if multiple update records provide a definition for a
class template specialization and that specialization has attributes.

llvm-svn: 285160
2016-10-26 02:31:56 +00:00
Richard Smith 15881ed009 Treat module headers wrapped by our builtin headers as implicitly being textual
headers. We previously got this check backwards and treated the wrapper header
as being textual.

This is important because our wrapper headers sometimes inject macros into the
system headers that they #include_next, and sometimes replace them entirely.

llvm-svn: 285152
2016-10-26 01:08:55 +00:00
Manman Ren c8c9415644 Module: correctly set the module file kind when emitting file_modified.
rdar://28503343

Differential Revision: http://reviews.llvm.org/D25806

llvm-svn: 284899
2016-10-21 23:35:03 +00:00
Manman Ren 70a7738f84 Module: improve the diagnostic message for include of non-modular header.
Emit the actual path to the non-modular include.

rdar://28897010

llvm-svn: 284897
2016-10-21 23:27:37 +00:00
Benjamin Kramer ae8de9bc75 Remove non-existing file from modulemap.
This picked up a builtin header if it happened to be available.

llvm-svn: 284815
2016-10-21 10:19:37 +00:00
Bruno Cardoso Lopes ed84df008f [Modules] Add 'no_undeclared_includes' module map attribute
The 'no_undeclared_includes' attribute should be used in a module to
tell that only non-modular headers and headers from used modules are
accepted.

The main motivation behind this is to prevent dep cycles between system
libraries (such as darwin) and libc++.

Patch by Richard Smith!

llvm-svn: 284797
2016-10-21 01:41:56 +00:00
Reid Kleckner 2e1538f282 Remove 24 instances of 'REQUIRES: shell'
Tests fall into one of the following categories:

- The requirement was unnecessary

- Additional quoting was required for backslashes in paths (see "sed -e
  's/\\/\\\\/g'") in the sanitizer tests.

- OpenMP used 'REQUIRES: shell' as a proxy for the test failing on
  Windows. Those tests fail there reliably, so use XFAIL instead.

I tried not to remove shell requirements that were added to suppress
flaky test failures, but if I screwed up, we can add it back as needed.

llvm-svn: 284793
2016-10-20 23:11:45 +00:00
Vassil Vassilev c774a23bd9 [modules] Do not report missing definitions of demoted constexpr variable templates.
This is a followup to regression introduced in r284284.

This should fix our libstdc++ modules builds.

https://reviews.llvm.org/D25678

Reviewed by Richard Smith!

llvm-svn: 284577
2016-10-19 11:19:30 +00:00
Benjamin Kramer a72a70aeb9 Revert "Reinstate r281429, reverted in r281452, with a fix for its mishandling of"
This reverts commit r284176. It still marks some modules as invisible
that should be visible. Will follow up with the author with a test case.

llvm-svn: 284382
2016-10-17 13:00:44 +00:00
Richard Smith edbc6e93e1 Reinstate r284008 reverted in r284081, with two fixes:
1) Merge and demote variable definitions when we find a redefinition in
MergeVarDecls, not only when we find one in AddInitializerToDecl (we only reach
the second case if it's the addition of the initializer itself that converts an
existing declaration into a definition). 

2) When rebuilding a redeclaration chain for a variable, if we merge two
definitions together, mark the definitions as merged so the retained definition
is made visible whenever the demoted definition would have been.

Original commit message (from r283882):

[modules] PR28752: Do not instantiate variable declarations which are not visible.

Original patch by Vassil Vassilev! Changes listed above are mine.

llvm-svn: 284284
2016-10-14 21:41:24 +00:00
Manman Ren 3b5dbf23a4 Module: emit initializers in submodules when importing the parent module.
When importing the parent module, module initializers in submodules should
be emitted.

rdar://28740482

llvm-svn: 284263
2016-10-14 18:55:44 +00:00
Richard Smith b50df91178 Reinstate r281429, reverted in r281452, with a fix for its mishandling of
compiles without -fmodules-local-submodule-visibility. Original commit message:

[modules] When merging one definition into another, propagate the list of
re-exporting modules from the discarded definition to the retained definition.

llvm-svn: 284176
2016-10-13 23:04:14 +00:00
Manman Ren aa0178e57a Module: emit initializers for C/ObjC after r276159.
In r276159, we started to defer emitting initializers for VarDecls, but
forgot to add the initializers for non-C++ language.

rdar://28740482

llvm-svn: 284142
2016-10-13 18:42:14 +00:00
Richard Smith 88d10b68e0 Revert r284008. This is us to fail to instantiate static data members in some
cases. I'm working on reducing a testcase.

llvm-svn: 284081
2016-10-12 23:29:02 +00:00
Vassil Vassilev bb8fe3175a Reinstate r283887 and r283882.
Original message:
"[modules] PR28752: Do not instantiate variable declarations which are not visible.

https://reviews.llvm.org/D24508

Patch developed in collaboration with Richard Smith!"

llvm-svn: 284008
2016-10-12 11:57:08 +00:00
Manman Ren a58f92f09d Module: for ObjectiveC, be consistent when checking hidden decls.
In MatchAllMethodDeclarations, when checking a hidden decl, be sure
to allow hidden when searching for methods.

rdar://28699972

llvm-svn: 283943
2016-10-11 21:18:20 +00:00
Vassil Vassilev f6b491041f Revert r283887 and r283882, until the issue is understood and fixed.
llvm-svn: 283890
2016-10-11 15:51:06 +00:00
Vassil Vassilev 4b3e7388d1 [modules] PR28752: Do not instantiate variable declarations which are not visible.
https://reviews.llvm.org/D24508

Patch developed in collaboration with Richard Smith!

llvm-svn: 283882
2016-10-11 13:57:36 +00:00
Richard Smith c26d97401c [modules] Be sure to emit local specializations of imported templates, even if
the resulting specialization is not referenced by the rest of the AST. This
both avoids performing unnecessary reinstantiations in downstream users of the
AST file and fixes a bug (breaking modules self-host right now) where we would
sometimes fail to emit a definition of a class template specialization if we
imported just a declaration of it from elsewhere (see new testcase for reduced
example).

llvm-svn: 283489
2016-10-06 20:30:51 +00:00
Manman Ren a0042c4922 ObjectiveC: fix a seg fault when deserialing redeclaration of ObjCMethodDecl.
The deserialization of redeclartion can cause seg fault since getCanonicalDecl
of the redeclaration returns the lookup result on the ObjCContainerDecl,
which can be null if FindExternalVisibleDeclsByName is not done updating
the lookup results.

The fix is to return the redeclaration itself as the canonical decl. Note that
the handling for redeclaration of ObjCMethodDecl is not in line with other
redeclarables.

rdar://28488466

llvm-svn: 283145
2016-10-03 21:26:46 +00:00
Eric Liu 762b4887c2 Revert "[modules] When merging one definition into another, propagate the list of re-exporting modules from the discarded definition to the retained definition."
This reverts commit r281429.

llvm-svn: 281452
2016-09-14 10:05:10 +00:00
Richard Smith 1c16d1b576 [modules] When merging one definition into another, propagate the list of
re-exporting modules from the discarded definition to the retained definition.

llvm-svn: 281429
2016-09-14 01:05:35 +00:00
Richard Trieu ffa532d7a1 Fix interaction between serialization and c++1z feature.
In c++1z, static_assert is not required to have a StringLiteral message, where
previously it was required.  Update the AST Reader to be able to handle a
null StringLiteral.

llvm-svn: 281286
2016-09-13 01:20:40 +00:00
Peter Collingbourne eeb56abe64 Update Clang for D20147 ("DebugInfo: New metadata representation for global variables.")
Differential Revision: http://reviews.llvm.org/D20415

llvm-svn: 281285
2016-09-13 01:13:19 +00:00
Richard Smith 7707c4a109 Add a couple of test files missed in r281258.
llvm-svn: 281259
2016-09-12 21:07:09 +00:00
Richard Smith 6561f92b62 [modules] When we merge two definitions of a function, mark the retained
definition as visible in the discarded definition's module, as we do for
other kinds of definition.

llvm-svn: 281258
2016-09-12 21:06:40 +00:00
Manman Ren ec315f1002 Modules: for ObjectiveC try to keep the definition invariant.
When deserializing ObjCInterfaceDecl with definition data, if we already have
a definition, try to keep the definition invariant; also pull in the
categories even if it is not what getDefinition returns (this effectively
combines categories).

rdar://27926200
rdar://26708823

llvm-svn: 281119
2016-09-09 23:48:27 +00:00
Manman Ren 7d2f5c4a91 Modules: revert r280728.
In post-commit review, Richard suggested a better way to fix this.
rdar://27926200

llvm-svn: 281078
2016-09-09 19:03:07 +00:00
Vassil Vassilev 714b81c40a [modules] Apply ODR merging for function scoped tags only in C++ mode.
In C mode, if we have a visible declaration but not a visible definition, a tag
defined in the declaration should be have a visible definition. In C++ we rely
on the ODR merging, whereas in C we cannot because each declaration of a
function gets its own set of declarations in its prototype scope.

Patch developed in collaboration with Richard Smith!

llvm-svn: 280984
2016-09-08 20:34:41 +00:00
Manman Ren c748359c14 Modules: Fix an assertion in DeclContext::buildLookup.
When calling getMostRecentDecl, we can pull in more definitions from
a module. We call getPrimaryContext afterwards to make sure that
we buildLookup on a primary context.

rdar://27926200

llvm-svn: 280728
2016-09-06 18:16:54 +00:00
NAKAMURA Takumi f852ac88f3 clang/test/Modules/compiler_builtins_x86.c: Fix r280658.
llvm-svn: 280659
2016-09-05 13:14:54 +00:00
James Molloy 3ddbb81ea0 Attempt to fix buildbots not targetting x86
r280613 introduced failures for all builds that don't target x86 by default. Add an explicit target to avoid a missing feature diagnostic.

llvm-svn: 280658
2016-09-05 12:28:49 +00:00
Elad Cohen fb6358d2b5 [Modules] Add 'freestanding' to the 'requires-declaration' feature-list.
This adds support for modules that require (non-)freestanding
environment, such as the compiler builtin mm_malloc submodule.

Differential Revision: https://reviews.llvm.org/D23871

llvm-svn: 280613
2016-09-04 06:00:42 +00:00
Richard Smith 30fc9a9339 When we reach the end of a #include of a header of a local submodule that we
textually included, create an ImportDecl just as we would if we reached a
#include of any other modular header. This is necessary in order to correctly
determine the set of variables to initialize for an imported module.

This should hopefully make the modules selfhost buildbot green again.

llvm-svn: 280409
2016-09-01 20:15:25 +00:00
Bruno Cardoso Lopes 6736e199c7 [Modules] Add 'gnuinlineasm' to the 'requires-declaration' feature-list.
This adds support for modules that require (no-)gnu-inline-asm
environment, such as the compiler builtin cpuid submodule.

This is the gnu-inline-asm variant of https://reviews.llvm.org/D23871

Differential Revision: https://reviews.llvm.org/D23905

rdar://problem/26931199

llvm-svn: 280159
2016-08-30 21:25:42 +00:00
Richard Smith 3fb1a8554d PR29166: when merging declarations with typedef names for linkage purposes,
don't assume that the anonymous struct will be part of the most recent
declaration of the typedef.

llvm-svn: 280136
2016-08-30 19:13:18 +00:00
Adrian Prantl b3b5a7362c Fix a bug preventing the cause for a module file-not-found from being displayed
llvm-svn: 280010
2016-08-29 20:46:59 +00:00
Adrian Prantl 9a06a882bc Fix a bug preventing the cause of a module-out-of-date error from being printed
llvm-svn: 280009
2016-08-29 20:46:56 +00:00
Richard Smith 0bae624934 Lazily load the ContextDecl for a lambda's DefinitionData, to fix a
deserialization cycle caused by the ContextDecl recursively importing members
of the lambda's closure type.

llvm-svn: 279694
2016-08-25 00:34:00 +00:00
Richard Smith 6f4e2e038d Fix regression introduced by r279164: only pass definitions as the PatternDef
to DiagnoseUninstantiableTemplate, teach hasVisibleDefinition to correctly
determine whether a function definition is visible, and mark both the function
and the template as visible when merging function template definitions to
provide hasVisibleDefinition with the relevant information.

The change to always pass the right declaration as the PatternDef to
DiagnoseUninstantiableTemplate also caused those checks to happen before other
diagnostics in InstantiateFunctionDefinition, giving worse diagnostics for the
same situations, so I sunk the relevant diagnostics into
DiagnoseUninstantiableTemplate. Those parts of this patch are based on changes
in reviews.llvm.org/D23492 by Vassil Vassilev.


This reinstates r279486, reverted in r279500, with a fix to
DiagnoseUninstantiableTemplate to only mark uninstantiable explicit
instantiation declarations as invalid if we actually diagnosed them. (When we
trigger an explicit instantiation of a class member from an explicit
instantiation declaration for the class, it's OK if there is no corresponding
definition and we certainly don't want to mark the member invalid in that
case.) This previously caused a build failure during bootstrap.

llvm-svn: 279557
2016-08-23 19:41:39 +00:00
Chandler Carruth c6c937f2a6 Revert r279486 "Fix regression introduced by r279164"
Build bots seem unhappy and as Richard was leaving he asked me to revert
this for him. Doing so.

llvm-svn: 279500
2016-08-23 02:00:51 +00:00
Adrian Prantl 5e30490644 Typo.
llvm-svn: 279491
2016-08-22 22:38:18 +00:00
Adrian Prantl 8ff4c08e34 Add the second half of the testcase I should have added in 279485.
llvm-svn: 279489
2016-08-22 22:30:34 +00:00
Richard Smith 2fbcbb7b38 Fix regression introduced by r279164: only pass definitions as the PatternDef
to DiagnoseUninstantiableTemplate, teach hasVisibleDefinition to correctly
determine whether a function definition is visible, and mark both the function
and the template as visible when merging function template definitions to
provide hasVisibleDefinition with the relevant information.

The change to always pass the right declaration as the PatternDef to
DiagnoseUninstantiableTemplate also caused those checks to happen before other
diagnostics in InstantiateFunctionDefinition, giving worse diagnostics for the
same situations, so I sunk the relevant diagnostics into
DiagnoseUninstantiableTemplate. Those parts of this patch are based on changes
in reviews.llvm.org/D23492 by Vassil Vassilev.

llvm-svn: 279486
2016-08-22 22:25:03 +00:00
Adrian Prantl a72972b985 Module debug info: Don't assert when encountering an incomplete definition
in isDefinedInClangModule() and assume that the incomplete definition
is not defined in the module.

This broke the -gmodules self host recently.
rdar://problem/27894367

llvm-svn: 279485
2016-08-22 22:23:58 +00:00
NAKAMURA Takumi cc980fc55f clang/test/Modules/prebuilt-module.m: Prune "-triple" to fix a configuration mismatch.
llvm-svn: 279207
2016-08-19 05:25:26 +00:00
Vassil Vassilev b21ee08e57 PR28794: Don't try to instantiate function templates which are not visible.
Reviewed by Richard Smith.

llvm-svn: 279164
2016-08-18 22:01:25 +00:00
Manman Ren 11f2a47772 Module: add -fprebuilt-module-path to support loading prebuilt modules.
In this mode, there is no need to load any module map and the programmer can
simply use "@import" syntax to load the module directly from a prebuilt
module path. When loading from prebuilt module path, we don't support
rebuilding of the module files and we ignore compatible configuration
mismatches.

rdar://27290316
Differential Revision: http://reviews.llvm.org/D23125

llvm-svn: 279096
2016-08-18 17:42:15 +00:00
Richard Smith ceaf5ad041 Remove debugging aids from this test and fix its expectations.
llvm-svn: 279034
2016-08-18 06:15:19 +00:00