Commit Graph

544 Commits

Author SHA1 Message Date
Richard Smith 5a4737cd6a [modules] If a module declares an entity and then imports another declaration
of that entity, ensure that the redeclaration chain is reordered properly on
reload. Otherwise, the result of name lookup for that entity may point to an
entity that is too old; if that's an injected friend name or the like, that
can result in the name not being found at all.

llvm-svn: 228371
2015-02-06 02:42:59 +00:00
Richard Smith 4eca9b9372 [modules] When using -E, we may try to merge decls despite having no Sema
object. In such a case, use the TU's DC for merging global decls rather than
giving up when we find there is no TU scope.

Ultimately, we should probably avoid all loading of decls when preprocessing,
but there are other reasonable use cases for loading an AST file with no Sema
object for which this is the right thing.

llvm-svn: 228234
2015-02-04 23:37:59 +00:00
Richard Smith 90fff92b34 Add missing file from r228104.
llvm-svn: 228105
2015-02-04 01:51:12 +00:00
Richard Smith 7483d20e77 [modules] If we already have a fake definition for one declaration of a class,
don't think we're providing a new one in an update record adding a definition
to another declaration of the same class.

llvm-svn: 228104
2015-02-04 01:23:46 +00:00
Richard Smith 2a9e5c57ef [modules] Be sure to load the lexical definition of a class template
specialization from an update record exactly once, even if we needed to fake up
the definition.

llvm-svn: 227939
2015-02-03 03:32:14 +00:00
Ben Langmuir 532d2104ce Add cc1 option '-fmodule-feature' to add custom values for 'requires' decls
This allows clang-based tools to specify custom features that can be
tested by the 'requires' declaration in a module map file.

llvm-svn: 227868
2015-02-02 21:56:15 +00:00
Richard Smith 5089542793 [modules] When we try to complete the redeclaration chain for a class template
specialization, pull in any lazy specializations of the class template.

llvm-svn: 227668
2015-01-31 03:04:55 +00:00
Richard Smith 8a63989728 [modules] Sometimes we can deserialize a class member but not have yet
encountered any definition for the class; this happens when the definition is
added by an update record that is not yet loaded. In such a case, eagerly pick
the original parent of the member as the canonical definition of the class
rather than muddling through with the canonical declaration (the latter can
lead to us failing to merge properly later if the canonical definition turns
out to be some other declaration).

llvm-svn: 226977
2015-01-24 01:07:20 +00:00
Richard Smith d2a7eda2b7 Fix reference to sysroot in this test (broken in r226875).
llvm-svn: 226885
2015-01-23 00:30:44 +00:00
Richard Smith ac425e9165 PR22299: Relocate code for handling -fmodule-map-file= so that we don't try to
produce diagnostics with source locations before the diagnostics system is
ready for them.

llvm-svn: 226882
2015-01-23 00:01:13 +00:00
Richard Smith 999500a26d Reorganize test/Modules:
* Put all input files under Inputs/, move corresponding tests into test/Modules.
 * Rename a modulemap test file to [...].modulemap, and teach lit that such files are tests.

llvm-svn: 226875
2015-01-22 23:07:47 +00:00
Richard Smith 1b65dbc477 [modules] If we add an implicit special member to a class through an update
record, and that class declaration is not the canonical definition of the
class, be sure to add the class to the list of classes that are consulted when
we look up a special member in the canonical definition.

llvm-svn: 226778
2015-01-22 03:50:31 +00:00
Richard Smith 9ba845c2e6 Fix test file names so they're picked up by lit.
llvm-svn: 226776
2015-01-22 03:24:07 +00:00
Richard Smith f1f4bc2176 [modules] If we load two declarations with typedef names for linkage purposes
on top of a local declaration of the same entity, we still need to remember
that we loaded the first one or we may fail to merge the second one properly.

llvm-svn: 226765
2015-01-22 02:21:23 +00:00
Richard Smith 5156c38570 [modules] It's possible to merge into the pattern of a class template before we
load the definition data from the declaration itself. In that case, merge
properly; don't assume the prior definition is the same as our own.

llvm-svn: 226761
2015-01-22 01:41:56 +00:00
Hans Wennborg 9cf7122ff7 Fix compiler_builtins.m test to not rely on including system stdlib.h and malloc.h
Importing _Builtin_intrinsics.sse and avx would transitively pull in those
headers, and the test would fail when building in an environment where
they were not available on the include path.

This fixes PR20995 for me.

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

llvm-svn: 226754
2015-01-22 00:45:20 +00:00
Rafael Espindola e5df59ff78 Emit DeferredDeclsToEmit in a DFS order.
Currently we emit DeferredDeclsToEmit in reverse order. This patch changes that.

The advantages of the change are that

* The output order is a bit closer to the source order. The change to
test/CodeGenCXX/pod-member-memcpys.cpp is a good example.

* If we decide to deffer more, it will not cause as large changes in the
estcases as it would without this patch.

llvm-svn: 226751
2015-01-22 00:24:57 +00:00
Ben Langmuir c1d88ea5a7 Inherit attributes when infering a framework module
If a module map contains
framework module * [extern_c] {}

We will now infer [extern_c] on the inferred framework modules (we
already inferred [system] as a special case).

llvm-svn: 225803
2015-01-13 17:47:44 +00:00
Ben Langmuir a0c32e9310 Fix bogus 'method is unavailable' errors with modules
This just tweaks the fix from r224892 (which handled PCHs) to work with
modules, where we will serialize each method individually and hence the
hasMoreThanOneDecl bit needs to be updated as we add the methods.

llvm-svn: 225659
2015-01-12 19:27:00 +00:00
Nico Weber 1b8dc9efc5 Remove unused test input.
llvm-svn: 224784
2014-12-23 19:30:13 +00:00
Yaron Keren 3a03797241 Enabling this test again on mingw. The problem seems to happen when
two identical module.modulemap are available on the include path and
so should be fixed in the mingw driver include dies, when we'll have it.

llvm-svn: 224515
2014-12-18 12:13:14 +00:00
Yaron Keren 390fe4e450 This test does not pass for -target i686-pc-windows-gnu (-mingw32)
when clang is built with mingw-w64 4.9.1 or according to 
http://llvm.org/PR20995  , mingw-w64 4.7.2 as well.

llvm-svn: 224453
2014-12-17 20:12:29 +00:00
Duncan P. N. Exon Smith b3a66691f8 IR: Make metadata typeless in assembly, clang side
Match LLVM changes from r224257.

llvm-svn: 224259
2014-12-15 19:10:08 +00:00
Justin Bogner 93e3cfcf99 Frontend: Canonicalize to native paths when dumping module dependencies
Mixed path separators (ie, both / and \\) can mess up the sort order
of the VFS map when dumping module dependencies, as was recently
exposed by r224055 and papered over in r224145. Instead, we should
simply use native paths for consistency.

This also adds a TODO to add handling of .. in paths. There was some
code for this before r224055, but it was untested and probably broken.

llvm-svn: 224164
2014-12-12 23:12:27 +00:00
Reid Kleckner fdb705318a Allow module deps to be printed in an arbitrary order
The order is different between Windows and Unix for reasons unknown, but
the compiler output appears to still be determinstic.

llvm-svn: 224145
2014-12-12 19:13:04 +00:00
Richard Smith 54cc3c2f23 [modules] When constructing paths relative to a module, strip out /./ directory
components. These sometimes get synthetically added, and we don't want -Ifoo
and -I./foo to be treated fundamentally differently here.

llvm-svn: 224055
2014-12-11 20:50:24 +00:00
NAKAMURA Takumi 1969fd52bb clang/test/Modules/modular_maps.cpp REQUIRES shell. chdir is unsupported on Lit internal runner.
llvm-svn: 223921
2014-12-10 08:20:32 +00:00
Richard Smith 9acb99e342 Reinstate r223753, reverted in r223759 due to breakage of clang-tools-extra.
Original commit message:

[modules] Add experimental -fmodule-map-file-home-is-cwd flag to -cc1.

For files named by -fmodule-map-file=, and files found by 'extern module'
directives, this flag specifies that we should resolve filenames relative to
the current working directory rather than relative to the directory in which
the module map file resides. This is aimed at fixing path handling, in
particular for relative -I paths, when building modules that represent
components of the current project (rather than libraries installed on the
current system, which the current project has as dependencies, where we'd
typically expect the module map files to be looked up implicitly).

llvm-svn: 223913
2014-12-10 03:09:48 +00:00
Duncan P. N. Exon Smith 00a4da73d5 Revert "[modules] Add experimental -fmodule-map-file-home-is-cwd flag to -cc1."
This reverts commit r223753.  It broke the Green Dragon build for a few
hours:

  http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_build/2259/
  http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_build/2259/consoleFull#43901905849ba4694-19c4-4d7e-bec5-911270d8a58c

I suspect `clang-tools-extra` just needs a follow-up for an API change,
but I'm not the right one to look into it.

llvm-svn: 223759
2014-12-09 06:35:37 +00:00
Richard Smith 0152e78146 [modules] Add experimental -fmodule-map-file-home-is-cwd flag to -cc1.
For files named by -fmodule-map-file=, and files found by 'extern module'
directives, this flag specifies that we should resolve filenames relative to
the current working directory rather than relative to the directory in which
the module map file resides. This is aimed at fixing path handling, in
particular for relative -I paths, when building modules that represent
components of the current project (rather than libraries installed on the
current system, which the current project has as dependencies, where we'd
typically expect the module map files to be looked up implicitly).

llvm-svn: 223753
2014-12-09 03:20:04 +00:00
Richard Smith 0c6387f759 [modules] If the same .pcm file is imported via two different paths, don't
complain that the contained modules are defined twice.

llvm-svn: 223724
2014-12-09 00:14:36 +00:00
Richard Smith 6ae60e70c6 Add some file content to avoid test failures on content-addressed file systems.
llvm-svn: 223596
2014-12-06 22:12:07 +00:00
Richard Smith 7ddf5f147f Add test file missed from r223561.
llvm-svn: 223595
2014-12-06 22:11:06 +00:00
Richard Smith 223d3f2e4d [modules] If we import a module, and we've seen a module map that describes the
module, use the path from the module map file in preference to the path from
the .pcm file when resolving relative paths in the .pcm file. This allows
diagnostics (and .d output) to give relative paths if the module was found via
a relative path.

llvm-svn: 223577
2014-12-06 03:21:08 +00:00
NAKAMURA Takumi 8ca1b5a294 clang/test/Modules/malformed.cpp REQUIRES shell due to "cd".
llvm-svn: 223107
2014-12-02 03:55:16 +00:00
Richard Smith 3c1a41ad99 [modules] Track how 'header' directives were written in module map files,
rather than trying to extract this information from the FileEntry after the
fact.

This has a number of beneficial effects. For instance, diagnostic messages for
failed module builds give a path relative to the "module root" rather than an
absolute file path, and the contents of the module includes file is no longer
dependent on what files the including TU happened to inspect prior to
triggering the module build.

llvm-svn: 223095
2014-12-02 00:08:08 +00:00
Daniel Jasper 21a0f55755 Add flag -f(no-)modules-implicit-maps.
This suppresses the implicit search for files called 'module.modulemap' and
similar.

llvm-svn: 222745
2014-11-25 09:45:48 +00:00
Richard Smith 5b39075668 [modules] When explicitly importing a module, it's fine for the imported module
to be newer than we were expecting. That happens if .pcm's get moved between
file systems during a distributed build. (It's still not OK for them to actually
be different, though, so we still check the size and signature matches.)

llvm-svn: 222507
2014-11-21 05:37:20 +00:00
Ben Langmuir acb803e807 Validate user headers even if -fmodules-validate-once-per-build-session
is enabled. Unlike system headers, we want to be more careful about
modifications to user headers, because it's still easy to edit a header
while you're building.

llvm-svn: 221634
2014-11-10 22:13:10 +00:00
Ben Langmuir ed98258482 Check module signature when the module has already been loaded
We may need to verify the signature on subsequent imports as well, just
like we verify the size/modtime:
@import A;
@import B; // imports A
@import C; // imports A

llvm-svn: 221569
2014-11-08 00:34:30 +00:00
Ben Langmuir 6caebfda78 Remove superceded warning warn_forgotten_module_header
This DefaultIgnore warning under -Wincomplete-module was firing on
any module map files that happened to be parsed (it's only supposed to
fire on headers), and it has been superceded by
-Wnon-modular-include-in-module anyway.

For compatibility, I rewired -Wincomplete-module to imply
-Wnon-modular-include-in-module.

llvm-svn: 221357
2014-11-05 16:43:18 +00:00
NAKAMURA Takumi ed7e1cbc4c clang/test/Modules: Remove "REQUIRES:shell" since they work for me.
llvm-svn: 221261
2014-11-04 12:59:18 +00:00
Richard Smith 1e2cf0dd4b [modules] When a .pcm file is explicitly built separately from the translation
unit, allow the -O settings of the two compilations to differ.

llvm-svn: 220943
2014-10-31 02:28:58 +00:00
Richard Smith 96261ddfa1 Extend test to check that -D flags do not leak across module boundaries.
llvm-svn: 220782
2014-10-28 16:30:57 +00:00
Richard Smith 96fdab6eb5 [modules] Allow -I, -D, -W flags to change between building a module and
explicitly using the resulting .pcm file. Unlike for an implicit module build,
we don't need nor want to require these flags to match between the module
and its users.

llvm-svn: 220780
2014-10-28 16:24:08 +00:00
NAKAMURA Takumi 314df7a5aa clang/test/Modules/explicit-build.cpp: Tweak to meet win32's backslash.
llvm-svn: 220770
2014-10-28 11:34:29 +00:00
Richard Smith d4b230b378 [modules] Load .pcm files specified by -fmodule-file lazily.
llvm-svn: 220731
2014-10-27 23:01:16 +00:00
Richard Smith 202210b369 [modules] Support combining 'textual' with 'private'.
llvm-svn: 220589
2014-10-24 20:23:01 +00:00
Ben Langmuir 487ea14a46 Add a "signature" to AST files to verify that they haven't changed
Since the order of the IDs in the AST file (e.g. DeclIDs, SelectorIDs)
is not stable, it is not safe to load an AST file that depends on
another AST file that has been rebuilt since the importer was built,
even if "nothing changed". We previously used size and modtime to check
this, but I've seen cases where a module rebuilt quickly enough to foil
this check and caused very hard to debug build errors.

To save cycles when we're loading the AST, we just generate a random
nonce value and check that it hasn't changed when we load an imported
module, rather than actually hash the whole file.

This is slightly complicated by the fact that we need to verify the
signature inside addModule, since we might otherwise consider that a
mdoule is "OutOfDate" when really it is the importer that is out of
date. I didn't see any regressions in module load time after this
change.

llvm-svn: 220493
2014-10-23 18:05:36 +00:00
Richard Smith 30428bc844 Revert accidentally-committed files in r220460.
llvm-svn: 220461
2014-10-23 02:02:31 +00:00