Commit Graph

1016 Commits

Author SHA1 Message Date
Manman Ren dfcf1cb175 Revert r292508 given that we intend to remove driver options for cxx modules.
llvm-svn: 292639
2017-01-20 20:03:00 +00:00
Manman Ren 4798302d87 Module: Improve diagnostic message when cxx modules are disabled and @import is used in Objective CXX.
rdar://problem/19399671

llvm-svn: 292508
2017-01-19 19:05:55 +00:00
Graydon Hoare dc0405f74c [Modules] Correct test comment from obsolete earlier version of code. NFC
Summary:
Code committed in rL290219 went through a few iterations; test wound up with
stale comment.

Reviewers: doug.gregor, manmanren

Reviewed By: manmanren

Subscribers: cfe-commits

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

llvm-svn: 292435
2017-01-18 20:34:44 +00:00
Bruno Cardoso Lopes 052d95a6d6 [Modules] Fix misleading warning about missing textual header in umbrella header
When a textual header is present inside a umbrella dir but not in the
header, we get the misleading warning:

warning: umbrella header for module 'FooFramework' does not include
header 'Baz_Private.h'

The module map in question:

framework module FooFramework {
    umbrella header "FooUmbrella.h"

    export *
    module * { export * }

    module Private {
        textual header "Baz_Private.h"
    }
}

Fix this by taking textual headers into account.

llvm-svn: 291794
2017-01-12 19:15:33 +00:00
Vassil Vassilev 352e4412e1 PR31469: Don't add friend template class decls to redecl chain in dependent contexts.
Fixes a crash in modules where the template class decl becomes the most recent
decl in the redeclaration chain and forcing the template instantiator try to
instantiate the friend declaration, rather than the template definition.
    
In practice, A::list<int> produces a TemplateSpecializationType
A::__1::list<int, allocator<type-parameter-0-0> >' failing to replace to
subsitute the default argument to allocator<int>.
    
Kudos Richard Smith (D28399).

llvm-svn: 291753
2017-01-12 09:16:26 +00:00
Manman Ren 9803ee8e9a Module: Do not add any link flags when an implementation TU of a module imports
a header of that same module.

This fixes a regression caused by r280409.
rdar://problem/29930553

This is an updated version for r291628 (which was reverted in r291688).

llvm-svn: 291689
2017-01-11 18:47:38 +00:00
Manman Ren 3e9dea024e This reverts r291628. As suggested by Richard, we can simply
filter out the implicilty imported modules at CodeGen instead of removing the
implicit ImportDecl when an implementation TU of a module imports a header of
that same module.

llvm-svn: 291688
2017-01-11 18:32:30 +00:00
Bruno Cardoso Lopes ba1b5c98ba [Modules] Support #import when entering files with modules
Textual headers and builtins that are #import'd from different
modules should get re-entered when these modules are independent
from each other.

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

rdar://problem/25881934

llvm-svn: 291644
2017-01-11 02:14:51 +00:00
Manman Ren 7f41c4d802 Module: Do not create Implicit ImportDecl for module X if we
are building an implemenation of module X.

This fixes a regression caused by r280409.
rdar://problem/29930553

llvm-svn: 291628
2017-01-11 00:48:19 +00:00
Richard Smith 43a833bec4 Check that template template arguments match template template parameters
properly even when a non-type template parameter has a dependent type.

Previously, if a non-type template parameter was dependent, but not dependent
on an outer level of template parameter, we would not match the type of the
parameter. Under [temp.arg.template], we are supposed to check that the types
are equivalent, which means checking for syntactic equivalence in the dependent
case.

This also fixes some accepts-invalids when passing templates with auto-typed
non-type template parameters as template template arguments.

llvm-svn: 291512
2017-01-09 23:54:33 +00:00
Manman Ren ffd3e9d766 PCH: fix a regression that reports a module is defined in both pch and pcm.
In r276159, we started to say that a module X is defined in a pch if we specify
-fmodule-name when building the pch. This caused a regression that reports
module X is defined in both pch and pcm if we generate the pch with
-fmodule-name=X and then in a separate clang invocation, we include the pch and
also import X.pcm.

This patch adds an option CompilingPCH similar to CompilingModule. When we use
-fmodule-name=X while building a pch, modular headers in X will be textually
included and the compiler knows that we are not building module X, so we don't
put module X in SUBMODULE_DEFINITION of the pch.

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

llvm-svn: 291465
2017-01-09 19:20:18 +00:00
Richard Smith 792c22dbd4 When producing a name of a partial specialization in a diagnostic, use the
template arguments as written rather than the canonical template arguments,
so we print more user-friendly names for template parameters.

llvm-svn: 290483
2016-12-24 04:09:05 +00:00
Chandler Carruth 93786da2cb Make '-disable-llvm-optzns' an alias for '-disable-llvm-passes'.
Much to my surprise, '-disable-llvm-optzns' which I thought was the
magical flag I wanted to get at the raw LLVM IR coming out of Clang
deosn't do that. It still runs some passes over the IR. I don't want
that, I really want the *raw* IR coming out of Clang and I strongly
suspect everyone else using it is in the same camp.

There is actually a flag that does what I want that I didn't know about
called '-disable-llvm-passes'. I suspect many others don't know about it
either. It both does what I want and is much simpler.

This removes the confusing version and makes that spelling of the flag
an alias for '-disable-llvm-passes'. I've also moved everything in Clang
to use the 'passes' spelling as it seems both more accurate (*all* LLVM
passes are disabled, not just optimizations) and much easier to remember
and spell correctly.

This is part of simplifying how Clang drives LLVM to make it cleaner to
wire up to the new pass manager.

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

llvm-svn: 290392
2016-12-23 00:23:01 +00:00
Bruno Cardoso Lopes 82ec4fde42 [CrashReproducer] Add support for merging -ivfsoverlay
Merge all VFS mapped files inside -ivfsoverlay inputs into the vfs
overlay provided by the crash reproducer. This is the last missing piece
to allow crash reproducers to fully work with user frameworks; when
combined with headermaps, it allows clang to find additional frameworks.

rdar://problem/27913709

llvm-svn: 290326
2016-12-22 07:06:03 +00:00
Graydon Hoare ca0f4faa46 Fix windows build breakage in r290219. Unix path separators in testcase.
llvm-svn: 290233
2016-12-21 03:00:11 +00:00
Graydon Hoare 4d8676407b [modules] Handle modules with nonstandard names in module.private.modulemaps
Summary:
The module system supports accompanying a primary module (say Foo) with
an auxiliary "private" module (defined in an adjacent module.private.modulemap
file) that augments the primary module when associated private headers are
available. The feature is intended to be used to augment the primary
module with a submodule (say Foo.Private), however some users in the wild
are choosing to augment the primary module with an additional top-level module
with a "similar" name (in all cases so far: FooPrivate).

This "works" when a user of the module initially imports a private header,
such as '#import "Foo/something_private.h"' since the Foo import winds up
importing FooPrivate in passing. But if the import is subsequently recorded
in a PCH file, reloading the PCH will fail to validate because of a cross-check
that attempts to find the module.modulemap (or module.private.modulemap) using
HeaderSearch algorithm, applied to the "FooPrivate" name. Since it's stored in
Foo.framework/Modules, not FooPrivate.framework/Modules, the check fails and
the PCH is rejected.

This patch adds a compensatory workaround in the HeaderSearch algorithm
when searching (and failing to find) a module of the form FooPrivate: the
name used to derive filesystem paths is decoupled from the module name
being searched for, and if the initial search fails and the module is
named "FooPrivate", the filesystem search name is altered to remove the
"Private" suffix, and the algorithm is run a second time (still looking for
a module named FooPrivate, but looking in directories derived from Foo).

Accompanying this change is a new warning that triggers when a user loads
a module.private.modulemap that defines a top-level module with a different
name from the top-level module defined in its adjacent module.modulemap.

Reviewers: doug.gregor, manmanren, bruno

Subscribers: bruno, cfe-commits

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

llvm-svn: 290219
2016-12-21 00:24:39 +00:00
Bruno Cardoso Lopes 7aff2bb3d2 [CrashReproducer] Collect PCH included via -include-pch
Collect the necessary input PCH files.

Do not try to validate the AST before copying it out because if the
crash is in this path, we won't be able to collect it. Instead only
check if it's a file containg an AST.

rdar://problem/27913709

llvm-svn: 289460
2016-12-12 19:28:25 +00:00
Bruno Cardoso Lopes 66e9627b02 [CrashReproducer] Setup a module collector callback for HeaderInclude
Collect missing include that cannot be fetched otherwise (e.g. when
using headermaps).

rdar://problem/27913709

llvm-svn: 289361
2016-12-11 04:27:31 +00:00
Bruno Cardoso Lopes 181225b8a3 [CrashReproducer] Collect headermap files
Include headermaps (.hmap files) in the .cache directory and
add VFS entries. All headermaps are known after HeaderSearch
setup, collect them right after.

rdar://problem/27913709

llvm-svn: 289360
2016-12-11 04:27:28 +00:00
Bruno Cardoso Lopes 1c10872150 [CrashReproducer] Provide a clean dir path for -fmodules-cache-path
The most common workflow with module reproducers involves deleting the
module cache before running the script. This happens because leftovers
from the crash are present in the cache and could trigger unrelated and
confusing errors, misleading from the initial reproduction intent.
Change this to point to a clean path but leave the leftovers untouched.

rdar://problem/28655070

llvm-svn: 289176
2016-12-09 03:11:48 +00:00
Bruno Cardoso Lopes e3a0aef2cf [CrashReproducer] Rewrite relative include paths
When -fmodules is on, the reproducer invocation currently leave paths
for include-like flags as is. If the path is relative, the reproducer
doesn't know how to access that file during reproduction time because
the VFS cannot reason about relative paths.

Expand relative paths to absolute ones when creating the reproducer
command line. This allows, for example, the reproducer to work for
crashes while building clang with modules; this wasn't possible before
because building clang requires using relative inc dir from within the
build directory.

rdar://problem/28655070

llvm-svn: 289174
2016-12-09 02:22:47 +00:00
Richard Smith a114c46e87 Revert r288626, which reverts r288449. Original commit message:
Recover better from an incompatible .pcm file being provided by -fmodule-file=. We try to include the headers of the module textually in this case, still enforcing the modules semantic rules. In order to make that work, we need to still track that we're entering and leaving the module. Also, if the module was also marked as unavailable (perhaps because it was missing a file), we shouldn't mark the module unavailable -- we don't need the module to be complete if we're going to enter it textually.

llvm-svn: 288741
2016-12-06 00:40:17 +00:00
Richard Smith 8893f35a89 Additional test file missed from r288737.
llvm-svn: 288738
2016-12-06 00:14:22 +00:00
Richard Smith b9d0193e59 [modules] Use the "redundant #include" diagnostic rather than the "module
import can't appear here" diagnostic if an already-visible module is textually
entered (because we have the module map but not the AST file) within a
function/namespace scope.

llvm-svn: 288737
2016-12-06 00:12:39 +00:00
Daniel Jasper ad3ba6be31 Revert "Recover better from an incompatible .pcm file being provided by -fmodule-file=. We try to include the headers of the module textually in this case, still enforcing the modules semantic rules. In order to make that work, we need to still track that we're entering and leaving the module. Also, if the module was also marked as unavailable (perhaps because it was missing a file), we shouldn't mark the module unavailable -- we don't need the module to be complete if we're going to enter it textually."
This reverts commit r288449.

I believe that this is currently faulty wrt. modules being imported
inside namespaces. Adding these lines to the new test:

  namespace n {
  #include "foo.h"
  }

Makes it break with

  fatal error: import of module 'M' appears within namespace 'n'

However, I believe it should fail with

  error: redundant #include of module 'M' appears within namespace 'n'

I have tracked this down to us now inserting a tok::annot_module_begin
instead of a tok::annot_module_include in
Preprocessor::HandleIncludeDirective() and then later in
Parser::parseMisplacedModuleImport(), we hit the code path for
tok::annot_module_begin, which doesn't set FromInclude of
checkModuleImportContext to true (thus leading to the "wrong"
diagnostic).

llvm-svn: 288626
2016-12-04 22:34:37 +00:00
Richard Smith 444e6f3d82 Recover better from an incompatible .pcm file being provided by -fmodule-file=.
We try to include the headers of the module textually in this case, still
enforcing the modules semantic rules. In order to make that work, we need to
still track that we're entering and leaving the module. Also, if the module was
also marked as unavailable (perhaps because it was missing a file), we
shouldn't mark the module unavailable -- we don't need the module to be
complete if we're going to enter it textually.

llvm-svn: 288449
2016-12-02 01:52:28 +00:00
Manman Ren b666573238 ObjC Module: try to make objc module deterministic.
Make sure that comparing selectors in DeclarationName does its job.
rdar://problem/28988750

llvm-svn: 287244
2016-11-17 18:41:18 +00:00
Eric Fiselier 525a351447 [modules] Mark deleted functions as implicitly inline to allow merging
Summary: When merging definitions with ModulesLocalVisibility enabled it's important to make deleted definitions implicitly inline, otherwise they'll be diagnosed as a redefinition.

Reviewers: silvas, manmanren, rsmith

Subscribers: cfe-commits

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

llvm-svn: 285655
2016-10-31 23:07:15 +00:00
Elad Cohen 938f516424 [Modules] Add a command line option for loading the clang builtins modulemap.
-fbuiltin-module-map loads the clang builtins modulemap file. (This is
equivalent to -fmodule-map-file=<resource dir>/include/module.modulemap)

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

llvm-svn: 285548
2016-10-31 08:21:54 +00:00
Bruno Cardoso Lopes a0d9acafe1 [Modules] Make test from r285377 darwin specific
Appease buildbots:
http://bb.pgr.jp/builders/cmake-clang-x86_64-linux/builds/55876

llvm-svn: 285378
2016-10-28 02:37:04 +00:00
Bruno Cardoso Lopes 0ac158a528 [Modules] Add testcase for builtins used in umbrella headers
This used to work before r284797 + r285152, which exposed something
interesting; some users include builtins from umbrella headers.

Clang should emit a warning to warn users this is not a good practice
and umbrella headers shouldn't get the
implicitly-add-the-builtin-version behavior for builtin header names.

While we're not there, add the testcase to represent the way it
currently works.

llvm-svn: 285377
2016-10-28 02:30:45 +00:00
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