Commit Graph

1333 Commits

Author SHA1 Message Date
Adrian Prantl 7b6b9a1afc -gmodules: Don't emit incomplete breadcrumbs pointing to nonexistant PCM files.
When a module name is specified as -fmodule-name, that module gets a
clang::Module object, but it won't actually be built or imported; it
will be textual. CGDebugInfo wouldn't detect this and them emit a
DICompileUnit that had a hash but no name and that confused both
dsymutil, LLDB, and myself.

rdar://problem/47926508

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

llvm-svn: 353578
2019-02-08 23:15:42 +00:00
James Y Knight f5f1b0e59e [opaque pointer types] Cleanup CGBuilder's Create*GEP.
Some of these functions take some extraneous arguments, e.g. EltSize,
Offset, which are computable from the Type and DataLayout.

Add some asserts to ensure that the computed values are consistent
with the passed-in values, in preparation for eliminating the
extraneous arguments. This also asserts that the Type is an Array for
the calls named "Array" and a Struct for the calls named "Struct".

Then, correct a couple of errors:

1. Using CreateStructGEP on an array type. (this causes the majority
   of the test differences, as struct GEPs are created with i32
   indices, while array GEPs are created with i64 indices)

2. Passing the wrong Offset to CreateStructGEP in TargetInfo.cpp on
   x86-64 NACL (which uses 32-bit pointers).

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

llvm-svn: 353529
2019-02-08 15:34:12 +00:00
Richard Smith 520a37f52f [modules] Fix handling of initializers for templated global variables.
For global variables with unordered initialization that are instantiated
within a module, we previously did not emit the global (or its
initializer) at all unless it was used in the importing translation unit
(and sometimes not even then!), leading to misbehavior and link errors.

We now emit the initializer for an instantiated global variable with
unordered initialization with side-effects in a module into every
translation unit that imports the module. This is unfortunate, but
mostly matches the behavior of a non-modular compilation and seems to be
the best that we can reasonably do.

llvm-svn: 353240
2019-02-05 23:37:13 +00:00
Nemanja Ivanovic db64e7e9fa [NFC] Explicitly add -std=c++14 option to tests that rely on the C++14 default
When Clang/LLVM is built with the CLANG_DEFAULT_STD_CXX CMake macro that sets
the default standard to something other than C++14, there are a number of lit
tests that fail as they rely on the C++14 default.
This patch just adds the language standard option explicitly to such test cases.

Differential revision: https://reviews.llvm.org/D57581

llvm-svn: 353163
2019-02-05 12:05:53 +00:00
James Y Knight 3f8b916698 Fix the behavior of clang's -w flag.
It is intended to disable _all_ warnings, even those upgraded to
errors via `-Werror=warningname` or `#pragma clang diagnostic error'

Fixes: https://llvm.org/PR38231
Differential Revision: https://reviews.llvm.org/D53199

llvm-svn: 352535
2019-01-29 19:33:48 +00:00
Saleem Abdulrasool 175890e1eb CodeGen: fix autolink emission on ELF
The autolinking extension for ELF uses a slightly different format for
encoding the autolink information compared to COFF and MachO.  Account
for this in the CGM to ensure that we do not assert when emitting
assembly or an object file.

llvm-svn: 350476
2019-01-05 19:27:12 +00:00
Adrian Prantl 212c104ea3 Reapply "Avoid emitting redundant or unusable directories in DIFile metadata entries.""
This reverts commit r348280 and reapplies D55085 without modifications.

Original commit message:

    Avoid emitting redundant or unusable directories in DIFile metadata entries.

    As discussed on llvm-dev recently, Clang currently emits redundant
    directories in DIFile entries, such as

      .file      1 "/Volumes/Data/llvm" "/Volumes/Data/llvm/tools/clang/test/CodeGen/debug-info-abspath.c"

    This patch looks at any common prefix between the compilation
    directory and the (absolute) file path and strips the redundant
    part. More importantly it leaves the compilation directory empty if
    the two paths have no common prefix.

    After this patch the above entry is (assuming a compilation dir of "/Volumes/Data/llvm/_build"):

      .file 1 "/Volumes/Data/llvm" "tools/clang/test/CodeGen/debug-info-abspath.c"

    When building the FileCheck binary with debug info, this patch makes
    the build artifacts ~1kb smaller.

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

llvm-svn: 348513
2018-12-06 18:44:50 +00:00
Serge Pavlov acfcd78aec Diagnose friend function template redefinitions.
Friend function template defined in a class template becomes available if
the enclosing class template is instantiated. Until the function template
is used, it does not have a body, but still is considered a definition for
the purpose of redeclaration checks.

This change modifies redefinition check so that it can find the friend
function template definitions in instantiated classes.

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

llvm-svn: 348473
2018-12-06 09:35:04 +00:00
Michal Gorny 29935acdb1 [test] Disable Modules/prune.m on NetBSD as it requires 'touch -a'
llvm-svn: 348356
2018-12-05 11:17:50 +00:00
Ilya Biryukov 660d233ea5 Revert "Avoid emitting redundant or unusable directories in DIFile metadata entries."
This reverts commit r348154 and follow-up commits r348211 and r3248213.
Reason: the original commit broke compiler-rt tests and a follow-up fix
(r348203) broke our integrate and was reverted.

llvm-svn: 348280
2018-12-04 16:30:45 +00:00
Adrian Prantl ca054dd384 Relax tests to also work on Windows
llvm-svn: 348211
2018-12-03 23:11:19 +00:00
Adrian Prantl 40c04e4942 Avoid emitting redundant or unusable directories in DIFile metadata entries.
As discussed on llvm-dev recently, Clang currently emits redundant
directories in DIFile entries, such as

  .file	     1 "/Volumes/Data/llvm" "/Volumes/Data/llvm/tools/clang/test/CodeGen/debug-info-abspath.c"

This patch looks at any common prefix between the compilation
directory and the (absolute) file path and strips the redundant
part. More importantly it leaves the compilation directory empty if
the two paths have no common prefix.

After this patch the above entry is (assuming a compilation dir of "/Volumes/Data/llvm/_build"):

  .file 1 "/Volumes/Data/llvm" "tools/clang/test/CodeGen/debug-info-abspath.c"

When building the FileCheck binary with debug info, this patch makes
the build artifacts ~1kb smaller.

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

llvm-svn: 348154
2018-12-03 17:55:27 +00:00
Adrian Prantl 55fcb4e90e [-gmodules] Honor -fdebug-prefix-map in the debug info inside PCMs.
This patch passes -fdebug-prefix-map (a feature for renaming source
paths in the debug info) through to the per-module codegen options and
adds the debug prefix map to the module hash.

<rdar://problem/46045865>

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

llvm-svn: 347926
2018-11-29 22:33:09 +00:00
JF Bastien 3a881e6bbc CGDecl::emitStoresForConstant fix synthesized constant's name
Summary: The name of the synthesized constants for constant initialization was using mangling for statics, which isn't generally correct and (in a yet-uncommitted patch) causes the mangler to assert out because the static ends up trying to mangle function parameters and this makes no sense. Instead, mangle to `"__const." + FunctionName + "." + DeclName`.

Reviewers: rjmccall

Subscribers: dexonsmith, cfe-commits

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

llvm-svn: 346915
2018-11-15 00:19:18 +00:00
Alex Lorenz 7d76ef9b3d [HeaderSearch] loadSubdirectoryModuleMaps should respect -working-directory
Include search paths can be relative paths. The loadSubdirectoryModuleMaps function
should account for that and respect the -working-directory parameter given to Clang.

rdar://46045849

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

llvm-svn: 346822
2018-11-14 01:08:03 +00:00
Douglas Yung 6fa1248f50 Fix test from r346439 to also work on Windows due to path separator differences.
llvm-svn: 346468
2018-11-09 02:44:07 +00:00
David Blaikie 436f7b6d8a [Frontend/Modules] Show diagnostics on prebuilt module configuration mismatch too
The current version only emits  the below error for a module (attempted to be loaded) from the `prebuilt-module-path`:

```
error: module file blabla.pcm cannot be loaded due to a configuration mismatch with the current compilation [-Wmodule-file-config-mismatch]
```

With this change, if the prebuilt module is used, we allow the proper diagnostic behind the configuration mismatch to be shown.

```
error: POSIX thread support was disabled in PCH file but is currently enabled
error: module file blabla.pcm cannot be loaded due to a configuration mismatch with the current compilation [-Wmodule-file-config-mismatch]
```

(A few lines later an error is emitted anyways, so there is no reason not to complain for configuration mismatches if a config mismatch is found and kills the build.)

Reviewed By: dblaikie

Tags: #clang

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

llvm-svn: 346439
2018-11-08 20:47:30 +00:00
Benjamin Kramer 5904c41ed2 Reapply "Fix regression in behavior of clang -x c++-header -fmodule-name=XXX"
This reverts commit r345963. We have a path forward now.

Original commit message:
The driver accidentally stopped passing the input filenames on to -cc1
in this mode due to confusion over what action was being requested.

This change also fixes a couple of crashes I encountered when passing
multiple files to such a -cc1 invocation.

llvm-svn: 346130
2018-11-05 12:46:02 +00:00
Adrian Prantl d1932dcdd3 Add an explicit -std=c++14 to this test.
rdar://problem/45642490

llvm-svn: 346048
2018-11-02 22:19:02 +00:00
Ilya Biryukov dfc56b43fa Revert "Fix regression in behavior of clang -x c++-header -fmodule-name=XXX"
This reverts commit r345803 and r345915 (a follow-up fix to r345803).

Reason: r345803 blocks our internal integrate because of the new
warnings showing up in too many places. The fix is actually correct,
we will reland it after figuring out how to integrate properly.

llvm-svn: 345963
2018-11-02 10:50:26 +00:00
Richard Smith 17f00260ab Fix regression in behavior of clang -x c++-header -fmodule-name=XXX
-fsyntax-only.

The driver accidentally stopped passing the input filenames on to -cc1
in this mode due to confusion over what action was being requested.

This change also fixes a couple of crashes I encountered when passing
multiple files to such a -cc1 invocation.

llvm-svn: 345803
2018-11-01 00:46:54 +00:00
Erik Pilkington fa98390b3c NFC: Remove the ObjC1/ObjC2 distinction from clang (and related projects)
We haven't supported compiling ObjC1 for a long time (and never will again), so
there isn't any reason to keep these separate. This patch replaces
LangOpts::ObjC1 and LangOpts::ObjC2 with LangOpts::ObjC.

Differential revision: https://reviews.llvm.org/D53547

llvm-svn: 345637
2018-10-30 20:31:30 +00:00
Volodymyr Sapsai ee89b2e01d [VFS] Remove 'ignore-non-existent-contents' attribute for YAML-based VFS.
'ignore-non-existent-contents' stopped working after r342232 in a way
that the actual attribute value isn't used and it works as if it is
always `true`.

Common use case for VFS iteration is iterating through files in umbrella
directories for modules. Ability to detect if some VFS entries point to
non-existing files is nice but non-critical. Instead of adding back
support for `'ignore-non-existent-contents': false` I am removing the
attribute, because such scenario isn't used widely enough and stricter
checks don't provide enough value to justify the maintenance.

rdar://problem/45176119

Reviewers: bruno

Reviewed By: bruno

Subscribers: hiraditya, dexonsmith, sammccall, cfe-commits

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

llvm-svn: 345212
2018-10-24 22:39:38 +00:00
Adrian Prantl ba6fdc57b4 Debug Info (-gmodules): emit full types for non-anchored template specializations
Before this patch, clang would emit a (module-)forward declaration for
template instantiations that are not anchored by an explicit template
instantiation, but still are guaranteed to be available in an imported
module. Unfortunately detecting the owning module doesn't reliably
work when local submodule visibility is enabled and the template is
inside a cross-module namespace.

This make clang debuggable again with -gmodules and LSV enabled.

rdar://problem/41552377

llvm-svn: 345109
2018-10-24 00:06:02 +00:00
Erik Pilkington abacc253a7 Fix an assert in -Wquoted-include-in-framework-header
Fixes rdar://43692300

Differential revision: https://reviews.llvm.org/D52253

llvm-svn: 342679
2018-09-20 19:00:03 +00:00
Bruno Cardoso Lopes e7240f024f [Modules] Add platform and environment features to requires clause
Allows module map writers to add build requirements based on
platform/os. This helps when target features and language dialects
aren't enough to conditionalize building a module, among other things,
it allow module maps for different platforms to live in the same file.

rdar://problem/43909745

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

llvm-svn: 342499
2018-09-18 17:11:13 +00:00
Richard Smith 8b464f299f [modules] Support use of -E on modules built from the command line.
llvm-svn: 342306
2018-09-15 01:21:18 +00:00
Richard Smith d6509cf21d [modules] Frontend support for building a header module from a list of
headaer files.

llvm-svn: 342304
2018-09-15 01:21:15 +00:00
Richard Trieu d8673901ab [ODRHash] Fix early exit that skipped code.
There is a bit of code at the end of AddDeclaration that should be run on
every exit of the function.  However, there was an early exit beforehand
that could be triggered, which causes a small amount of data to skip the
hashing, leading to false positive mismatch.  Use a separate function so
that this code is always run.

llvm-svn: 342199
2018-09-14 01:15:28 +00:00
David Bolvansky c96cb25a8b Print correctly dependency paths on Windows
Summary:
Before:
main.o: main.c ../include/lib\test.h

After:
main.o: main.c ../include/lib/test.h

Fixes PR38877

Reviewers: zturner

Subscribers: xbolva00, cfe-commits

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

llvm-svn: 342139
2018-09-13 14:27:32 +00:00
Richard Smith 13897ebb00 Track definition merging on the canonical declaration even when local
submodule visibility is disabled.

Attempting to pick a specific declaration to make visible when the
module containing the merged declaration becomes visible is error-prone,
as we don't yet know which declaration we'll choose to be the definition
when we are informed of the merging.

This reinstates r342019, reverted in r342020. The regression previously
observed after this commit was fixed in r342096.

llvm-svn: 342097
2018-09-12 23:37:00 +00:00
Richard Smith 841dbda3ba When we leave a module header, make that header visible in its
includer's context, even if its overall module is unavailable.

llvm-svn: 342096
2018-09-12 23:09:23 +00:00
Richard Smith 4034461abd Revert r342019, "Track definition merging on the canonical declaration
even when [...]"

Further testing has revealed that this causes build breaks during
explicit module compilations.

llvm-svn: 342020
2018-09-12 02:28:14 +00:00
Richard Smith e731d9acff Track definition merging on the canonical declaration even when local
submodule visibility is disabled.

Attempting to pick a specific declaration to make visible when the
module containing the merged declaration becomes visible is error-prone,
as we don't yet know which declaration we'll choose to be the definition
when we are informed of the merging.

llvm-svn: 342019
2018-09-12 02:13:48 +00:00
Richard Smith c457766c6d Consistently create a new declaration when merging a pre-existing but
hidden definition with a would-be-parsed redefinition.

This permits a bunch of cleanups. In particular, we no longer need to
take merged definitions into account when checking declaration
visibility, only when checking definition visibility, which makes
certain visibility checks take linear instead of quadratic time.

We could also now remove the UPD_DECL_EXPORTED update record and track
on each declaration whether it was demoted from a definition (as we
already do for variables), but I'm not doing that in this patch to keep
the changes here simpler.

llvm-svn: 342018
2018-09-12 02:13:47 +00:00
Richard Smith 20fbdb347c Fix tracking of merged definitions when the merge target is also merged
into something else.

llvm-svn: 342017
2018-09-12 02:13:46 +00:00
Bruno Cardoso Lopes 6fc8a564cf [Modules] Add imported modules to the output of -module-file-info
Fix a bug in the deserialization of IMPORTS section and allow for
imported modules to also be printed with -module-file-info.

rdar://problem/43867753

llvm-svn: 341902
2018-09-11 05:17:13 +00:00
Richard Smith 5159bbad8b PR38627: Fix handling of exception specification adjustment for
destructors.

We previously tried to patch up the exception specification after
completing the class, which went wrong when the exception specification
was needed within the class body (in particular, by a friend
redeclaration of the destructor in a nested class). We now mark the
destructor as having a not-yet-computed exception specification
immediately after creating it.

This requires delaying various checks against the exception
specification (where we'd previously have just got the wrong exception
specification, and now find we have an exception specification that we
can't compute yet) when those checks fire while the class is being
defined.

This also exposed an issue that we were missing a CodeSynthesisContext
for computation of exception specifications (otherwise we'd fail to make
the module containing the definition of the class visible when computing
its members' exception specs). Adding that incidentally also gives us a
diagnostic quality improvement.

This has also exposed an pre-existing problem: making the exception
specification evaluation context a non-SFINAE context (as it should be)
results in a bootstrap failure; PR38850 filed for this.

llvm-svn: 341499
2018-09-05 22:30:37 +00:00
Richard Trieu 0b9234b915 Remove unnecessary options from test RUN lines.
These tests do not check the color printing, so color options should not
be used when running them.

llvm-svn: 341498
2018-09-05 22:14:46 +00:00
Richard Trieu a7f38f7ca3 Add triple to test case.
This test uses enums, which have different behavior when targeting different
systems.  Specifying a triple will give predictable behavior to this test.

llvm-svn: 341496
2018-09-05 21:55:09 +00:00
Richard Trieu 22ddc282b5 [ODRHash] Extend hash to support all Type's.
llvm-svn: 341421
2018-09-04 22:53:19 +00:00
Richard Trieu a986a31242 Ensure canonical type is actually canonical.
ASTContext::applyObjCProtocolQualifiers will return a canonical type when given
a canonical type and an array of canonical protocols.  If the protocols are not
canonical then the returned type is also not canonical.  Since a canonical type is needed, canonicalize the returned type before using it.  This later prevents
a type from having a non-canonical canonical type.

llvm-svn: 341013
2018-08-30 01:57:52 +00:00
Petr Hosek eb46c95c3e [CMake] Use normalized Windows target triples
Changes the default Windows target triple returned by
GetHostTriple.cmake from the old environment names (which we wanted to
move away from) to newer, normalized ones. This also requires updating
all tests to use the new systems names in constraints.

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

llvm-svn: 339307
2018-08-09 02:16:18 +00:00
Eli Friedman 7499610e1b Diagnose invalid cv-qualifiers for friend decls.
Differential Revision: https://reviews.llvm.org/D45712

llvm-svn: 338931
2018-08-03 22:09:44 +00:00
Richard Smith a62d198ef5 [modules] Defer merging deduced return types.
We can't read a deduced return type until we are sure that the types referred
to by it are not in the middle of being loaded. So defer all reading of such
deduced return types until the end of the recursive deserialization step.

Also, when we load a function type that has a deduced return type, update all
other redeclarations of the function to have that deduced return type.

llvm-svn: 338798
2018-08-03 01:00:01 +00:00
Richard Smith 2425338bac Fix assertion failure when emitting code for a merged lambda.
llvm-svn: 338766
2018-08-02 20:30:52 +00:00
Yuka Takahashi d8baec2f46 [Modules] Do not emit relocation error when -fno-validate-pch is set
Summary:
Clang emits error when implicit modules was relocated from the
first build directory. However this was biting our usecase where we copy
the contents of build directory to another directory in order to
distribute.

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

llvm-svn: 338503
2018-08-01 09:50:02 +00:00
Richard Trieu ab4d730f14 [ODRHash] Support hashing enums.
llvm-svn: 337978
2018-07-25 22:52:05 +00:00
Bruno Cardoso Lopes 7315d2d721 [PCH+Modules] Load -fmodule-map-file content before including PCHs
Consider:
1) Generate PCH with -fmodules and -fmodule-map-file
2) Use PCH with -fmodules and the same -fmodule-map-file

If we don't load -fmodule-map-file content before including PCHs,
the modules that are dependencies in PCHs cannot get loaded,
since there's no matching module map file when reading back the AST.

rdar://problem/40852867

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

llvm-svn: 337447
2018-07-19 12:32:06 +00:00
Bruno Cardoso Lopes 52431f39a3 Reapply r336660: [Modules] Autoload subdirectory modulemaps with specific LangOpts
Summary:
Reproducer and errors:
https://bugs.llvm.org/show_bug.cgi?id=37878

lookupModule was falling back to loadSubdirectoryModuleMaps when it couldn't
find ModuleName in (proper) search paths. This was causing iteration over all
files in the search path subdirectories for example "/usr/include/foobar" in
bugzilla case.

Users don't expect Clang to load modulemaps in subdirectories implicitly, and
also the disk access is not cheap.

if (AllowExtraModuleMapSearch) true with ObjC with @import ModuleName.

Reviewers: rsmith, aprantl, bruno

Subscribers: cfe-commits, teemperor, v.g.vassilev

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

llvm-svn: 337430
2018-07-18 23:21:19 +00:00