]> granicus.if.org Git - clang/log
clang
6 years ago[index] Return when DC is null in handleReference
Fangrui Song [Mon, 8 Jan 2018 18:57:38 +0000 (18:57 +0000)]
[index] Return when DC is null in handleReference

Summary:
DC may sometimes be NULL and getContainerInfo(DC, Container) will dereference a null pointer.

Default template arguments (the following example and many test files in https://github.com/nlohmann/json)
may cause null pointer dereference.

```c++
template <typename>
struct actor;

template <template <typename> class Actor = actor>
struct terminal;
```

In tools/libclang/CXIndexDataConsumer.cpp#L203

    handleReference(ND, Loc, Cursor,
                    dyn_cast_or_null<NamedDecl>(ASTNode.Parent),
                    ASTNode.ContainerDC, ASTNode.OrigE, Kind);

`dyn_cast_or_null<NamedDecl>(ASTNode.Parent)` is somehow a null pointer and in tools/libclang/CXIndexDataConsumer.cpp:935

  ContainerInfo Container;
  getContainerInfo(DC, Container);

The null DC is casted `ContInfo.cursor = getCursor(cast<Decl>(DC));` and SIGSEGV.

```

See discussions in https://github.com/jacobdufault/cquery/issues/219 https://github.com/jacobdufault/cquery/issues/192

Reviewers: akyrtzi, sammccall, yvvan

Reviewed By: sammccall

Subscribers: mehdi_amini, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@322017 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert "Emit Function IDs table for Control Flow Guard"
Adrian McCarthy [Mon, 8 Jan 2018 17:12:01 +0000 (17:12 +0000)]
Revert "Emit Function IDs table for Control Flow Guard"

The new test fails on the Hexagon bot.  Reverting while I investigate.

This reverts https://reviews.llvm.org/rL322005

This reverts commit b7e0026b4385180c378edc658ec91a39566f2942.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@322008 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoEmit Function IDs table for Control Flow Guard
Adrian McCarthy [Mon, 8 Jan 2018 16:33:42 +0000 (16:33 +0000)]
Emit Function IDs table for Control Flow Guard

Adds option /guard:cf to clang-cl and -cfguard to cc1 to emit function IDs
of functions that have their address taken into a section named .gfids$y for
compatibility with Microsoft's Control Flow Guard feature.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@322005 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix test added in r321992 failing on some buildbots (again), test requires x86.
Sean Eveson [Mon, 8 Jan 2018 15:46:18 +0000 (15:46 +0000)]
Fix test added in r321992 failing on some buildbots (again), test requires x86.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@322000 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CodeGen] Fix TBAA info for accesses to members of base classes
Ivan A. Kosarev [Mon, 8 Jan 2018 15:36:06 +0000 (15:36 +0000)]
[CodeGen] Fix TBAA info for accesses to members of base classes

Resolves:
Bug 35724 - regression (r315984): fatal error: error in backend:
Broken function found (Did not see access type in access path!)
https://bugs.llvm.org/show_bug.cgi?id=35724

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321999 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAvoid assumption that lit tests are writable. NFC
Sam McCall [Mon, 8 Jan 2018 15:05:01 +0000 (15:05 +0000)]
Avoid assumption that lit tests are writable. NFC

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321997 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix test added in r321992 failing on some buildbots.
Sean Eveson [Mon, 8 Jan 2018 14:43:28 +0000 (14:43 +0000)]
Fix test added in r321992 failing on some buildbots.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321995 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Driver] Add flag enabling the function stack size section that was added in r319430
Sean Eveson [Mon, 8 Jan 2018 13:42:26 +0000 (13:42 +0000)]
[Driver] Add flag enabling the function stack size section that was added in r319430

Adds the -fstack-size-section flag to enable the .stack_sizes section. The flag defaults to on for the PS4 triple.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321992 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRemove bogus check for template specialization from self-comparison warning.
Richard Smith [Sun, 7 Jan 2018 22:25:55 +0000 (22:25 +0000)]
Remove bogus check for template specialization from self-comparison warning.

The important check is that we're not within a template *instantiation*, which
we check separately.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321977 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix a couple of wrong self-comparison diagnostics.
Richard Smith [Sun, 7 Jan 2018 22:18:05 +0000 (22:18 +0000)]
Fix a couple of wrong self-comparison diagnostics.

Check whether we are comparing the same entity, not merely the same
declaration, and don't assume that weak declarations resolve to distinct
entities.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321976 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAdd tests for three-way self- and array comparison.
Richard Smith [Sun, 7 Jan 2018 22:03:44 +0000 (22:03 +0000)]
Add tests for three-way self- and array comparison.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321973 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFactor out common tautological comparison code from scalar and vector compare checking.
Richard Smith [Sun, 7 Jan 2018 21:57:48 +0000 (21:57 +0000)]
Factor out common tautological comparison code from scalar and vector compare checking.

In passing, improve vector compare diagnostic to match scalar compare diagnostic.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321972 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRemove outdated doxygen comment [-Wdocumentation]
Benjamin Kramer [Sun, 7 Jan 2018 09:11:16 +0000 (09:11 +0000)]
Remove outdated doxygen comment [-Wdocumentation]

No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321960 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoSimplify the internal API for checking whether swiftcall passes a type indirectly...
John McCall [Sun, 7 Jan 2018 06:28:49 +0000 (06:28 +0000)]
Simplify the internal API for checking whether swiftcall passes a type indirectly and expose that API externally.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321957 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAdd support for a limited subset of TS 18661-3 math builtins.
Benjamin Kramer [Sat, 6 Jan 2018 21:49:54 +0000 (21:49 +0000)]
Add support for a limited subset of TS 18661-3 math builtins.

These just overloads for _Float128. They're supported by GCC 7 and used
by glibc. APFloat support is already there so just add the overloads.

__builtin_copysignf128
__builtin_fabsf128
__builtin_huge_valf128
__builtin_inff128
__builtin_nanf128
__builtin_nansf128

This is the same support that GCC has, according to the documentation,
but limited to _Float128.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321948 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Fix some check's output plist not containing the check name
Gabor Horvath [Sat, 6 Jan 2018 10:51:00 +0000 (10:51 +0000)]
[analyzer] Fix some check's output plist not containing the check name

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321933 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoTest case for r321396
Richard Trieu [Sat, 6 Jan 2018 03:20:59 +0000 (03:20 +0000)]
Test case for r321396

Any hashing for methods should be able to compile this test case without
emitting an error.  Since the class and method come from the same header from
each module, there should be no messages about ODR violations.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321924 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoSerialize the IDNS for a UsingShadowDecl rather than recomputing it.
Richard Smith [Sat, 6 Jan 2018 01:07:05 +0000 (01:07 +0000)]
Serialize the IDNS for a UsingShadowDecl rather than recomputing it.

Attempting to recompute it are doomed to fail because the IDNS of a declaration
is not necessarily preserved across serialization and deserialization (in turn
because whether a friend declaration is visible depends on whether some prior
non-friend declaration exists).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321921 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Driver] Suggest correctly spelled driver options
Brian Gesiak [Sat, 6 Jan 2018 00:25:40 +0000 (00:25 +0000)]
[Driver] Suggest correctly spelled driver options

Summary:
Depends on https://reviews.llvm.org/D41732.

Utilities such as `opt`, when invoked with arguments that are very
nearly spelled correctly, suggest the correctly spelled options:

```
bin/opt -hel
opt: Unknown command line argument '-hel'.  Try: 'bin/opt -help'
opt: Did you mean '-help'?
```

Clang, on the other hand, prior to this commit, does not:

```
bin/clang -hel
clang-6.0: error: unknown argument: '-hel'
```

This commit makes use of the new libLLVMOption API from
https://reviews.llvm.org/D41732 in order to provide correct suggestions:

```
bin/clang -hel
clang-6.0: error: unknown argument: '-hel', did you mean '-help'?
```

Test Plan: `check-clang`

Reviewers: yamaguchi, v.g.vassilev, teemperor, ruiu, bruno

Reviewed By: bruno

Subscribers: bruno, jroelofs, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321917 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoWhen name lookup finds a non-imported declaration and looks back along the
Richard Smith [Sat, 6 Jan 2018 00:09:23 +0000 (00:09 +0000)]
When name lookup finds a non-imported declaration and looks back along the
redecl chain for an imported declaration, make sure to check the IDNS of prior
imported decls.

Otherwise we can end up finding an invisible friend declaration and incorrectly
believing that it should be visible.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321916 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoPreserve unknown STDC pragma through preprocessor
Steven Wu [Fri, 5 Jan 2018 22:45:03 +0000 (22:45 +0000)]
Preserve unknown STDC pragma through preprocessor

Summary:
#pragma STDC FP_CONTRACT handler is only registered in parser so we
should keep the unknown STDC pragma through preprocessor and we also
should not emit warning for unknown STDC pragma during preprocessor.

rdar://problem/35724351

Reviewers: efriedma, rsmith, arphaman

Reviewed By: efriedma

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321909 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoTrack shadow modules with a generation counter.
Bruno Cardoso Lopes [Fri, 5 Jan 2018 22:13:56 +0000 (22:13 +0000)]
Track shadow modules with a generation counter.

This is a follow up to r321855, closing the gap between our internal shadow
modules implementation and upstream. It has been tested for longer and
provides a better approach for tracking shadow modules. Mostly NFCI.

rdar://problem/23612102

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321906 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAdd AST dumping support for _Generic expressions.
Richard Smith [Fri, 5 Jan 2018 21:31:07 +0000 (21:31 +0000)]
Add AST dumping support for _Generic expressions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321899 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix TLS support check for Darwin 32-bit simulator targets.
Volodymyr Sapsai [Fri, 5 Jan 2018 20:20:03 +0000 (20:20 +0000)]
Fix TLS support check for Darwin 32-bit simulator targets.

Also instead of checking architecture explicitly, use recently added
"simulator" environment in the triple.

rdar://problem/35083787

Reviewers: arphaman, bob.wilson

Reviewed By: arphaman

Subscribers: gparker42, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321890 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAdd a tool executor that runs actions on all TUs in the compilation database.
Eric Liu [Fri, 5 Jan 2018 10:32:16 +0000 (10:32 +0000)]
Add a tool executor that runs actions on all TUs in the compilation database.

Summary: Tool results are deduplicated by the result key.

Reviewers: hokein

Subscribers: klimek, mgorny, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321864 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoCommit new test file forgotten in previous commit
Stephan Bergmann [Fri, 5 Jan 2018 07:59:57 +0000 (07:59 +0000)]
Commit new test file forgotten in previous commit

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321861 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoNo -fsanitize=function warning when calling noexcept function through non-noexcept...
Stephan Bergmann [Fri, 5 Jan 2018 07:57:12 +0000 (07:57 +0000)]
No -fsanitize=function warning when calling noexcept function through non-noexcept pointer in C++17

As discussed in the mail thread <https://groups.google.com/a/isocpp.org/forum/
#!topic/std-discussion/T64_dW3WKUk> "Calling noexcept function throug non-
noexcept pointer is undefined behavior?", such a call should not be UB.
However, Clang currently warns about it.

This change removes exception specifications from the function types recorded
for -fsanitize=function, both in the functions themselves and at the call sites.
That means that calling a non-noexcept function through a noexcept pointer will
also not be flagged as UB.  In the review of this change, that was deemed
acceptable, at least for now.  (See the "TODO" in compiler-rt
test/ubsan/TestCases/TypeCheck/Function/function.cpp.)

To remove exception specifications from types, the existing internal
ASTContext::getFunctionTypeWithExceptionSpec was made public, and some places
otherwise unrelated to this change have been adapted to call it, too.

This is the cfe part of a patch covering both cfe and compiler-rt.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321859 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoReapply r321781: [Modules] Allow modules specified by -fmodule-map-file to shadow...
Bruno Cardoso Lopes [Fri, 5 Jan 2018 02:33:18 +0000 (02:33 +0000)]
Reapply r321781: [Modules] Allow modules specified by -fmodule-map-file to shadow implicitly found ones

When modules come from module map files explicitly specified by
-fmodule-map-file= arguments, allow those to override/shadow modules
with the same name that are found implicitly by header search. If such a
module is looked up by name (e.g. @import), we will always find the one
from -fmodule-map-file. If we try to use a shadowed module by including
one of its headers report an error.

This enables developers to force use of a specific copy of their module
to be used if there are multiple copies that would otherwise be visible,
for example if they develop modules that are installed in the default
search paths.

Patch originally by Ben Langmuir,
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20151116/143425.html

Based on cfe-dev discussion:
http://lists.llvm.org/pipermail/cfe-dev/2015-November/046164.html

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

rdar://problem/23612102

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321855 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoNFC.
Evgeny Stupachenko [Fri, 5 Jan 2018 02:22:52 +0000 (02:22 +0000)]
NFC.
The patch fixes r321395, that cuased
 -Werror=unused-but-set-variable issue for
 Diagnosed var on prod build.

From: Evgeny Stupachenko <evstupac@gmail.com>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321854 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRemove redundant test
Adrian Prantl [Fri, 5 Jan 2018 01:28:59 +0000 (01:28 +0000)]
Remove redundant test

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321846 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoDebug Info: Support DW_AT_calling_convention on composite types.
Adrian Prantl [Fri, 5 Jan 2018 01:13:52 +0000 (01:13 +0000)]
Debug Info: Support DW_AT_calling_convention on composite types.
This implements the DWARF 5 feature described at
http://www.dwarfstd.org/ShowIssue.php?issue=141215.1

This allows a consumer to understand whether a composite data type is
trivially copyable and thus should be passed by value instead of by
reference. The canonical example is being able to distinguish the
following two types:

  // S is not trivially copyable because of the explicit destructor.
  struct S {
     ~S() {}
  };

  // T is a POD type.
  struct T {
    ~T() = default;
  };

<rdar://problem/36034993>
Differential Revision: https://reviews.llvm.org/D41039

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321845 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoMake attribute instantiation instantiate all attributes, not just the first of
Richard Smith [Thu, 4 Jan 2018 23:42:29 +0000 (23:42 +0000)]
Make attribute instantiation instantiate all attributes, not just the first of
each kind.

Attribute instantiation would previously default to instantiating each kind of
attribute only once. This was overridden by a flag whose intended purpose was
to permit attributes from a prior declaration to be inherited onto a new
declaration even if that new declaration had its own copy of the attribute.
This is the wrong behavior: when instantiating attributes from a template, we
should always instantiate all the attributes that were written on that
template.

This patch renames the flag in the Attr class (and TableGen sources) to more
clearly identify what it's actually for, and removes the usage of the flag from
template instantiation. I also removed the flag from AlignedAttr, which was
only added to work around the incorrect suppression of duplicate attribute
instantiation.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321834 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoUse POSIX argument syntax in test rewrite-includes-messages.c
Hubert Tong [Thu, 4 Jan 2018 23:03:48 +0000 (23:03 +0000)]
Use POSIX argument syntax in test rewrite-includes-messages.c

Invoke diff such that options precede operands. Not doing so leads to
unspecified behaviour under the LSB.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321830 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoUse backslash escape, replacing xargs -0 in test macro-multiline.c
Hubert Tong [Thu, 4 Jan 2018 22:58:30 +0000 (22:58 +0000)]
Use backslash escape, replacing xargs -0 in test macro-multiline.c

Summary:
xargs supports escaping of newline characters with backslash.
xargs -0 is neither part of POSIX nor the LSB.

This patch removes the -0 option and adjusts the input to xargs
accordingly; that is, the input is a text file not ending in an
incomplete line, and the newline of interest is preceded by a backslash.

Note: The treatment of escaped newline characters is not as clearly
specified by POSIX as for escaped blank characters; however, the same
can be said for escaped backslashes. It is slightly more clear for the
case where the -I option is used; however, -I is also of limited
portability.

Reviewers: bruno

Reviewed By: bruno

Subscribers: bruno, rcraik, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321828 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[OPENMP] Fix capturing of expressions in clauses.
Alexey Bataev [Thu, 4 Jan 2018 20:50:08 +0000 (20:50 +0000)]
[OPENMP] Fix capturing of expressions in clauses.

Patch fixes incorrect capturing of the expressions in clauses with
expressions that must be captured for the combined constructs. Incorrect
capturing may lead to compiler crash during codegen phase.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321820 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[OPENMP] Fix casting in NVPTX support library.
Alexey Bataev [Thu, 4 Jan 2018 20:18:55 +0000 (20:18 +0000)]
[OPENMP] Fix casting in NVPTX support library.

If the reduction required shuffle in the NVPTX codegen, we may need to
cast the reduced value to the integer type. This casting was implemented
incorrectly and may cause compiler crash. Patch fixes this problem.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321818 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[OPENMP] Add debug info for generated functions.
Alexey Bataev [Thu, 4 Jan 2018 19:45:16 +0000 (19:45 +0000)]
[OPENMP] Add debug info for generated functions.

Most of the generated functions for the OpenMP were generated with
disabled debug info. Patch fixes this for better user experience.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321816 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[libclang] Support querying whether a declaration is invalid
Ivan Donchevskii [Thu, 4 Jan 2018 10:59:50 +0000 (10:59 +0000)]
[libclang] Support querying whether a declaration is invalid

This is useful for e.g. highlighting purposes in an IDE.

Note: First version of this patch was reverted due to failing tests in
opencl-types.cl with -target ppc64le-unknown-linux. These tests are
adapted now.

Patch by Nikolai Kosjar.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321794 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert "[Modules] Allow modules specified by -fmodule-map-file to shadow implicitly...
Bruno Cardoso Lopes [Thu, 4 Jan 2018 07:31:24 +0000 (07:31 +0000)]
Revert "[Modules] Allow modules specified by -fmodule-map-file to shadow implicitly found ones"

This reverts r321781 until I fix the leaks pointed out by bots:

http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/12146
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/3741

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321786 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Modules] Allow modules specified by -fmodule-map-file to shadow implicitly found...
Bruno Cardoso Lopes [Thu, 4 Jan 2018 02:17:40 +0000 (02:17 +0000)]
[Modules] Allow modules specified by -fmodule-map-file to shadow implicitly found ones

When modules come from module map files explicitly specified by
-fmodule-map-file= arguments, allow those to override/shadow modules
with the same name that are found implicitly by header search. If such a
module is looked up by name (e.g. @import), we will always find the one
from -fmodule-map-file. If we try to use a shadowed module by including
one of its headers report an error.

This enables developers to force use of a specific copy of their module
to be used if there are multiple copies that would otherwise be visible,
for example if they develop modules that are installed in the default
search paths.

Patch originally by Ben Langmuir,
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20151116/143425.html

Based on cfe-dev discussion:
http://lists.llvm.org/pipermail/cfe-dev/2015-November/046164.html

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

rdar://problem/23612102

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321781 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoPR35045: Convert injected-class-name to its corresponding simple-template-id
Richard Smith [Thu, 4 Jan 2018 01:24:17 +0000 (01:24 +0000)]
PR35045: Convert injected-class-name to its corresponding simple-template-id
during template argument deduction.

We already did this when the injected-class-name was in P, but missed the case
where it was in A. This (probably) can't happen except in implicit deduction
guides.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321779 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoReplace cp -a in various Clang tests
Hubert Tong [Thu, 4 Jan 2018 01:15:52 +0000 (01:15 +0000)]
Replace cp -a in various Clang tests

Summary:
cp -a is neither part of POSIX nor the LSB. The nearest equivalent under
POSIX is cp -RPp; however, cp -R is sufficient for the intended purpose.

test/Modules/crash-vfs-headermaps.m is not updated since it requires
system-darwin anyway.

Reviewers: bruno

Reviewed By: bruno

Subscribers: bruno, rcraik, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321778 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoPR35028: Retain duplicate alignas attributes in template instantiation.
Richard Smith [Thu, 4 Jan 2018 01:02:18 +0000 (01:02 +0000)]
PR35028: Retain duplicate alignas attributes in template instantiation.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321777 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix test to use -S instead of -c so it doesn't unnecessarily run the assembler.
Douglas Yung [Thu, 4 Jan 2018 00:16:57 +0000 (00:16 +0000)]
Fix test to use -S instead of -c so it doesn't unnecessarily run the assembler.

Reviewed by Paul Robinson

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321776 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoPR35815: Separate out the ns-consumed diagnostic into an error and
Alex Lorenz [Wed, 3 Jan 2018 23:52:42 +0000 (23:52 +0000)]
PR35815: Separate out the ns-consumed diagnostic into an error and
a warning

This commit separates out the warn_nsconsumed_attribute_mismatch and
warn_nsreturns_retained_attribute_mismatch diagnostic into a warning and error.
This is needed to avoid a module import regression introduced by r313717 that
turned these errors into warnings and started promoting them only when needed,
which caused an error when importing a module as it had different warning
settings.

rdar://36265651

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321775 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CGBuiltin] Handle unsigned mul overflow properly (PR35750)
Vedant Kumar [Wed, 3 Jan 2018 23:11:32 +0000 (23:11 +0000)]
[CGBuiltin] Handle unsigned mul overflow properly (PR35750)

r320902 fixed the IRGen for some types of checked multiplications. It
did not handle unsigned overflow correctly in the case where the signed
operand is negative (PR35750).

Eli pointed out that on overflow, the result must be equal to the unique
value that is equivalent to the mathematically-correct result modulo two
raised to the k power, where k is the number of bits in the result type.

This patch fixes the specialized IRGen from r320902 accordingly.

Testing: Apart from check-clang, I modified the test harness from
r320902 to validate the results of all multiplications -- not just the
ones which don't overflow:

  https://gist.github.com/vedantk/3eb9c88f82e5c32f2e590555b4af5081

llvm.org/PR35750, rdar://34963321

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321771 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoPR33503: When a qualified name in a redeclaration names a prior declaration in
Richard Smith [Wed, 3 Jan 2018 23:03:54 +0000 (23:03 +0000)]
PR33503: When a qualified name in a redeclaration names a prior declaration in
an inline namespace, update its semantic DeclContext to match.

We would previously get the semantic DeclContext wrong (pointing to the named
scope rather than the inline namespace within it), resulting in wrong lookup
results and linkage-related problems if the inline namespace was an anonymous
namespace.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321770 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoIntroduce some infrastructure for adding C attributes with [[]] syntax.
Aaron Ballman [Wed, 3 Jan 2018 22:22:48 +0000 (22:22 +0000)]
Introduce some infrastructure for adding C attributes with [[]] syntax.

This patch adds support to the attribute tablegen for specifying a [[]] attribute is allowed in C mode. This patch also adds the annotate attribute to the list of double square bracket attributes we support in C mode.

Eventually, I anticipate that this logic will be reversed (you have to opt out of allowing an attribute in C rather than opting in), but I want to see how the design plays out as more attributes are considered.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321763 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[OpenMP] Initial implementation of code generation for pragma 'target teams distribut...
Carlo Bertolli [Wed, 3 Jan 2018 21:12:44 +0000 (21:12 +0000)]
[OpenMP] Initial implementation of code generation for pragma 'target teams distribute parallel for' on host

https://reviews.llvm.org/D41709

This patch includes code generation and testing for offloading when target device is host.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321759 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoCalculate size of buffer instead of using a magic value.
Paul Robinson [Wed, 3 Jan 2018 20:29:49 +0000 (20:29 +0000)]
Calculate size of buffer instead of using a magic value.

Patch by Matthew Davis!

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321757 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago-gmodules: Emit debug info for implicit module imports via #include.
Adrian Prantl [Wed, 3 Jan 2018 19:10:21 +0000 (19:10 +0000)]
-gmodules: Emit debug info for implicit module imports via #include.

When a type is only used as a template parameter and that type is the
only type imported from another #include'd module, no skeleton CU for
that module is generated, so a consumer doesn't know where to find the
type definition. By emitting an import declaration, we can force a
skeleton CU to be generated for each imported module.

rdar://problem/36266156

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321754 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoSimplify code (NFC)
Adrian Prantl [Wed, 3 Jan 2018 18:31:04 +0000 (18:31 +0000)]
Simplify code (NFC)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321750 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Docs] Re-generate command line documentation, primarily to get the icelake feature...
Craig Topper [Wed, 3 Jan 2018 18:29:12 +0000 (18:29 +0000)]
[Docs] Re-generate command line documentation, primarily to get the icelake feature command line options in, but there were a couple other changes too.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321749 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoUpdate docs version and clear release notes for 7.0.0
Hans Wennborg [Wed, 3 Jan 2018 15:49:39 +0000 (15:49 +0000)]
Update docs version and clear release notes for 7.0.0

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321728 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[libclang] Fix cursors for functions with trailing return type
Ivan Donchevskii [Wed, 3 Jan 2018 14:35:48 +0000 (14:35 +0000)]
[libclang] Fix cursors for functions with trailing return type

This one was rolled back as follow-up to the failing commit.
Second try.

For the function declaration

auto foo5(Foo) -> Foo;
the parameter tokens were mapped to cursors representing the
FunctionDecl:

Keyword: "auto" [1:1 - 1:5] FunctionDecl=test5:1:6
Identifier: "test5" [1:6 - 1:11] FunctionDecl=test5:1:6
Punctuation: "(" [1:11 - 1:12] FunctionDecl=test5:1:6
Identifier: "X" [1:12 - 1:13] FunctionDecl=test5:1:6 // Ops, not a TypeRef
Punctuation: ")" [1:13 - 1:14] FunctionDecl=test5:1:6
Punctuation: "->" [1:15 - 1:17] FunctionDecl=test5:1:6
Identifier: "X" [1:18 - 1:19] TypeRef=struct X:7:8
Punctuation: ";" [1:19 - 1:20]

Fix this by ensuring that the trailing return type is not visited as
first.

Patch by Nikolai Kosjar.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321709 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert r321697 "[libclang] Support querying whether a declaration is invalid" and...
Hans Wennborg [Wed, 3 Jan 2018 14:20:15 +0000 (14:20 +0000)]
Revert r321697 "[libclang] Support querying whether a declaration is invalid" and follow-ups.

This broke test/Index/opencl-types.cl on several buildbots:
http://lab.llvm.org:8011/builders/clang-cmake-aarch64-lld/builds/3294
http://lab.llvm.org:8011/builders/clang-ppc64be-linux-multistage/builds/6498
http://lab.llvm.org:8011/builders/clang-ppc64le-linux-multistage/builds/5239

> [libclang] Support querying whether a declaration is invalid
>
> This is useful for e.g. highlighting purposes in an IDE.
>
> Patch by Nikolai Kosjar.
>
> Differential Revision: https://reviews.llvm.org/D40072

Also reverting follow-ups that otherwise caused conflicts for the
revert:

r321700 "Fix line endings."
r321701 "Fix more line endings."

r321698 "[libclang] Fix cursors for functions with trailing return type"
> For the function declaration
>
> auto foo5(Foo) -> Foo;
> the parameter tokens were mapped to cursors representing the
> FunctionDecl:
>
> Keyword: "auto" [1:1 - 1:5] FunctionDecl=test5:1:6
> Identifier: "test5" [1:6 - 1:11] FunctionDecl=test5:1:6
> Punctuation: "(" [1:11 - 1:12] FunctionDecl=test5:1:6
> Identifier: "X" [1:12 - 1:13] FunctionDecl=test5:1:6 // Ops, not a TypeRef
> Punctuation: ")" [1:13 - 1:14] FunctionDecl=test5:1:6
> Punctuation: "->" [1:15 - 1:17] FunctionDecl=test5:1:6
> Identifier: "X" [1:18 - 1:19] TypeRef=struct X:7:8
> Punctuation: ";" [1:19 - 1:20]
>
> Fix this by ensuring that the trailing return type is not visited as
> first.
>
> Patch by Nikolai Kosjar.
>
> Differential Revision: https://reviews.llvm.org/D40561

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321708 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoUserManual: Update with the latest clang-cl flags
Hans Wennborg [Wed, 3 Jan 2018 13:20:25 +0000 (13:20 +0000)]
UserManual: Update with the latest clang-cl flags

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321705 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix more line endings.
Ivan Donchevskii [Wed, 3 Jan 2018 10:40:11 +0000 (10:40 +0000)]
Fix more line endings.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321701 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix line endings.
Ivan Donchevskii [Wed, 3 Jan 2018 10:33:21 +0000 (10:33 +0000)]
Fix line endings.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321700 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[libclang] Fix cursors for functions with trailing return type
Ivan Donchevskii [Wed, 3 Jan 2018 10:04:37 +0000 (10:04 +0000)]
[libclang] Fix cursors for functions with trailing return type

For the function declaration

auto foo5(Foo) -> Foo;
the parameter tokens were mapped to cursors representing the
FunctionDecl:

Keyword: "auto" [1:1 - 1:5] FunctionDecl=test5:1:6
Identifier: "test5" [1:6 - 1:11] FunctionDecl=test5:1:6
Punctuation: "(" [1:11 - 1:12] FunctionDecl=test5:1:6
Identifier: "X" [1:12 - 1:13] FunctionDecl=test5:1:6 // Ops, not a TypeRef
Punctuation: ")" [1:13 - 1:14] FunctionDecl=test5:1:6
Punctuation: "->" [1:15 - 1:17] FunctionDecl=test5:1:6
Identifier: "X" [1:18 - 1:19] TypeRef=struct X:7:8
Punctuation: ";" [1:19 - 1:20]

Fix this by ensuring that the trailing return type is not visited as
first.

Patch by Nikolai Kosjar.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321698 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[libclang] Support querying whether a declaration is invalid
Ivan Donchevskii [Wed, 3 Jan 2018 09:49:31 +0000 (09:49 +0000)]
[libclang] Support querying whether a declaration is invalid

This is useful for e.g. highlighting purposes in an IDE.

Patch by Nikolai Kosjar.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321697 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[libclang] Add clang_getFileContents to libclang.exports
Ivan Donchevskii [Wed, 3 Jan 2018 09:17:08 +0000 (09:17 +0000)]
[libclang] Add clang_getFileContents to libclang.exports

This is the follow up patch for rL319881 which introduced
the function but did not put it into .exports file.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321695 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoUpdate clang cc1as for createMCAsmBackend change in r321692
Alex Bradbury [Wed, 3 Jan 2018 08:53:24 +0000 (08:53 +0000)]
Update clang cc1as for createMCAsmBackend change in r321692

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321693 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Sema] -Wtautological-constant-compare is too good. Cripple it.
Roman Lebedev [Wed, 3 Jan 2018 08:45:19 +0000 (08:45 +0000)]
[Sema] -Wtautological-constant-compare is too good. Cripple it.

Summary:
The diagnostic was mostly introduced in D38101 by me, as a reaction to wasting a lot of time, see [[ https://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20171009/206427.html | mail ]].
However, the diagnostic is pretty dumb. While it works with no false-positives,
there are some questionable cases that are diagnosed when one would argue that they should not be.

The common complaint is that it diagnoses the comparisons between an `int` and
`long` when compiling for a 32-bit target as tautological, but not when
compiling for 64-bit targets. The underlying problem is obvious: data model.
In most cases, 64-bit target is `LP64` (`int` is 32-bit, `long` and pointer are
64-bit), and the 32-bit target is `ILP32` (`int`, `long`, and pointer are 32-bit).

I.e. the common pattern is: (pseudocode)
```
#include <limits>
#include <cstdint>
int main() {
  using T1 = long;
  using T2 = int;

  T1 r;
  if (r < std::numeric_limits<T2>::min()) {}
  if (r > std::numeric_limits<T2>::max()) {}
}
```
As an example, D39149 was trying to fix this diagnostic in libc++, and it was not well-received.

This *could* be "fixed", by changing the diagnostics logic to something like
`if the types of the values being compared are different, but are of the same size, then do diagnose`,
and i even attempted to do so in D39462, but as @rjmccall rightfully commented,
that implementation is incomplete to say the least.

So to stop causing trouble, and avoid contaminating upcoming release, lets do this workaround:
* move these three diags (`warn_unsigned_always_true_comparison`, `warn_unsigned_enum_always_true_comparison`, `warn_tautological_constant_compare`) into it's own `-Wtautological-constant-in-range-compare`
* Disable them by default
* Make them part of `-Wextra`
* Additionally, give `warn_tautological_constant_compare` it's own flag `-Wtautological-type-limit-compare`.
  I'm not happy about that name, but i can't come up with anything better.

This way all three of them can be enabled/disabled either altogether, or one-by-one.

Reviewers: aaron.ballman, rsmith, smeenai, rjmccall, rnk, mclow.lists, dim

Reviewed By: aaron.ballman, rsmith, dim

Subscribers: thakis, compnerd, mehdi_amini, dim, hans, cfe-commits, rjmccall

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321691 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoPR35697: look at the first declaration when determining whether a function or
Richard Smith [Wed, 3 Jan 2018 02:34:35 +0000 (02:34 +0000)]
PR35697: look at the first declaration when determining whether a function or
variable is extern "C" in linkage calculations.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321686 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix and simplify handling of return type for (generic) lambda conversion function...
Richard Smith [Tue, 2 Jan 2018 23:52:42 +0000 (23:52 +0000)]
Fix and simplify handling of return type for (generic) lambda conversion function to function pointer.

Previously, we would:
 * compute the type of the conversion function and static invoker as a
   side-effect of template argument deduction for a conversion
 * re-compute the type as part of deduced return type deduction when building
   the conversion function itself

Neither of these turns out to be quite correct. There are other ways to reach a
declaration of the conversion function than in a conversion (such as an
explicit call or friend declaration), and performing auto deduction causes the
function type to be rebuilt in the context of the lambda closure type (which is
different from the context in which it originally appeared, resulting in
spurious substitution failures for constructs that are valid in one context but
not the other, such as the use of an enclosing class's "this" pointer).

This patch switches us to use a different strategy: as before, we use the
declared type of the operator() to form the type of the conversion function and
invoker, but we now populate that type as part of return type deduction for the
conversion function. And the invoker is now treated as simply being an
implementation detail of building the conversion function, and isn't given
special treatment by template argument deduction for the conversion function
any more.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321683 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] do not crash with assertion on processing locations of bodyfarmed functions
George Karpenkov [Tue, 2 Jan 2018 23:05:47 +0000 (23:05 +0000)]
[analyzer] do not crash with assertion on processing locations of bodyfarmed functions

This addresses an issue introduced in r183451: since
`removePiecesWithInvalidLocations` is called *after* `adjustCallLocations`,
it is not necessary, and in fact harmful, to have this assertion in
adjustCallLocations.

Addresses rdar://36170689

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321682 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[WinEH] Allow for multiple terminatepads
Reid Kleckner [Tue, 2 Jan 2018 21:34:16 +0000 (21:34 +0000)]
[WinEH] Allow for multiple terminatepads

Fixes verifier errors with Windows EH and OpenMP, which injects a
terminate scope around parallel blocks.

Fixes PR35778

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321676 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[DOXYGEN] Fix doxygen and content issues in smmintrin.h
Douglas Yung [Tue, 2 Jan 2018 20:45:29 +0000 (20:45 +0000)]
[DOXYGEN] Fix doxygen and content issues in smmintrin.h

- Fix formatting issue due to hyphenated terms at line breaks.
- Fix typo

This patch was made by Craig Flores

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321671 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[DOXYGEN] Fix doxygen and content issues in pmmintrin.h
Douglas Yung [Tue, 2 Jan 2018 20:42:53 +0000 (20:42 +0000)]
[DOXYGEN] Fix doxygen and content issues in pmmintrin.h

- Fix incorrect wording in various intrinsic descriptions. Previously the descriptions used "low-order" and "high-order" when the intended meaning was "even-indexed" and "odd-indexed".

This patch was made by Craig Flores

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321670 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[DOXYGEN] Fix doxygen and content issues in emmintrin.h
Douglas Yung [Tue, 2 Jan 2018 20:39:29 +0000 (20:39 +0000)]
[DOXYGEN] Fix doxygen and content issues in emmintrin.h

- Fixed innaccurate instruction mappings for various intrinsics.
- Fixed description of NaN handling in comparison intrinsics.
- Unify description of _mm_store_pd1 to match _mm_store1_pd.
- Fix incorrect wording in various intrinsic descriptions. Previously the descriptions used "low-order" and "high-order" when the intended meaning was "even-indexed" and "odd-indexed".
- Fix typos.
- Add missing italics command (\a) for params and fixed some parameter spellings.

This patch was made by Craig Flores

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321669 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoSuppress undefined-template warnings when the pattern is declared in a system header.
Nick Lewycky [Tue, 2 Jan 2018 19:10:12 +0000 (19:10 +0000)]
Suppress undefined-template warnings when the pattern is declared in a system header.

The way to fix an undefined-template warning is to add lines to the header file that defines the template pattern. We should suppress the warnings when the template pattern is in a system header because we don't expect users to edit those.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321665 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Sema] Don't emit the -Wstrict-prototypes warning for variadic functions.
Volodymyr Sapsai [Tue, 2 Jan 2018 18:02:19 +0000 (18:02 +0000)]
[Sema] Don't emit the -Wstrict-prototypes warning for variadic functions.

rdar://problem/33251668

Reviewers: arphaman, ahatanak

Reviewed By: arphaman

Subscribers: ptitei, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321660 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert "ASan+operator new[]: Fix operator new[] cookie poisoning"
Filipe Cabecinhas [Tue, 2 Jan 2018 13:46:12 +0000 (13:46 +0000)]
Revert "ASan+operator new[]: Fix operator new[] cookie poisoning"

This reverts r321645.

I missed a compiler-rt test that needs updating.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321647 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoASan+operator new[]: Fix operator new[] cookie poisoning
Filipe Cabecinhas [Tue, 2 Jan 2018 13:21:50 +0000 (13:21 +0000)]
ASan+operator new[]: Fix operator new[] cookie poisoning

Summary:
The C++ Itanium ABI says:
No cookie is required if the new operator being used is ::operator new[](size_t, void*).

We should only avoid poisoning the cookie if we're calling this
operator, not others. This is dealt with before the call to
InitializeArrayCookie.

Reviewers: rjmccall, kcc, rsmith

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321645 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Driver] Fix unused variables and test-writing-into-workdir after r321621
Sam McCall [Tue, 2 Jan 2018 09:35:10 +0000 (09:35 +0000)]
[Driver] Fix unused variables and test-writing-into-workdir after r321621

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321639 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAgain reverting an attempt to convert the DeclSpec enums into scoped enums.
Faisal Vali [Mon, 1 Jan 2018 18:23:28 +0000 (18:23 +0000)]
Again reverting an attempt to convert the DeclSpec enums into scoped enums.
  - reverts r321622, r321625, and r321626.
  - the use of bit-fields is still resulting in warnings - even though we can use static-asserts to harden the code and ensure the bit-fields are wide enough.  The bots still complain of warnings being seen.
  - to silence the warnings requires specifying the bit-fields with the underlying enum type (as opposed to the enum type itself), which then requires lots of unnecessary static casts of each enumerator within DeclSpec to the underlying-type, which even though could be seen as implementation details, it does hamper readability - and given the additional litterings, makes me question the value of the change.

So in short - I give up (for now at least).

Sorry about the noise.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321628 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Sema] Fix build with GCC
Benjamin Kramer [Mon, 1 Jan 2018 17:07:23 +0000 (17:07 +0000)]
[Sema] Fix build with GCC

tools/clang/lib/Sema/DeclSpec.cpp: In member function 'void clang::DeclSpec::Finish(clang::Sema&, const clang::PrintingPolicy&)':
tools/clang/lib/Sema/DeclSpec.cpp:1116:8: error: could not convert 'clang::DeclSpec::TSW_unspecified' from 'const TSW {aka const clang::TypeSpecifierWidth}' to 'int'
tools/clang/lib/Sema/DeclSpec.cpp:1117:8: error: could not convert 'clang::DeclSpec::TSW_short' from 'const TSW {aka const clang::TypeSpecifierWidth}' to 'int'
tools/clang/lib/Sema/DeclSpec.cpp:1118:8: error: could not convert 'clang::DeclSpec::TSW_longlong' from 'const TSW {aka const clang::TypeSpecifierWidth}' to 'int'
tools/clang/lib/Sema/DeclSpec.cpp:1128:8: error: could not convert 'clang::DeclSpec::TSW_long' from 'const TSW {aka const clang::TypeSpecifierWidth}' to 'int'

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321626 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoUse 'unsigned int' instead of enum bit-fields to silence some warnings from r321622
Faisal Vali [Mon, 1 Jan 2018 16:36:47 +0000 (16:36 +0000)]
Use 'unsigned int' instead of enum bit-fields to silence some warnings from r321622
  - bots were complaining that the bit-field width was less than the width of the underlying type (note, underlying types of enums can not be bit-fields)
  - add static_asserts for TSS and TSW to ensure that the bit-fields can hold all the enumerators - and add comments next to the last enumerator warning not to reorder.

See https://reviews.llvm.org/rC321622 for the patch that introduced the warnings.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321625 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFixed markup formatting
Serge Pavlov [Mon, 1 Jan 2018 15:53:16 +0000 (15:53 +0000)]
Fixed markup formatting

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321623 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[NFC] Modernize enums TypeSpecifierWidth, TypeSpecifierSign & TypeSpecifierType into...
Faisal Vali [Mon, 1 Jan 2018 15:42:13 +0000 (15:42 +0000)]
[NFC] Modernize enums TypeSpecifierWidth, TypeSpecifierSign & TypeSpecifierType into scoped enums with underlying types.
  - Since these enums are used as bit-fields - for the bit-fields to be interpreted as unsigned, the underlying type must be specified as unsigned.

Previous failed attempt - wherein I did not specify an underlying type - was the sum of:
https://reviews.llvm.org/rC321614
https://reviews.llvm.org/rC321615

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321622 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoEnable configuration files in clang
Serge Pavlov [Mon, 1 Jan 2018 13:27:01 +0000 (13:27 +0000)]
Enable configuration files in clang

Clang is inherently a cross compiler and can generate code for any target
enabled during build. It however requires to specify many parameters in the
invocation, which could be hardcoded during configuration process in the
case of single-target compiler. The purpose of configuration files is to
make specifying clang arguments easier.

A configuration file is a collection of driver options, which are inserted
into command line before other options specified in the clang invocation.
It groups related options together and allows specifying them in simpler,
more flexible and less error prone way than just listing the options
somewhere in build scripts. Configuration file may be thought as a "macro"
that names an option set and is expanded when the driver is called.

Use of configuration files is described in `UserManual.rst`.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321621 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert r321614 and r321615
Faisal Vali [Mon, 1 Jan 2018 02:49:17 +0000 (02:49 +0000)]
Revert r321614 and r321615
  - the enum changes to TypeSpecifierType are breaking some tests - and will require a more careful integration.

Sorry about rushing these changes - thought I could sneak them in prior to heading out for new years ;)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321616 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAdd scope specifiers to updated scoped-enums (that I somehow missed in r321614)
Faisal Vali [Mon, 1 Jan 2018 02:35:43 +0000 (02:35 +0000)]
Add scope specifiers to updated scoped-enums (that I somehow missed in r321614)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321615 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[NFC] Modernize enums TypeSpecifierWidth, TypeSpecifierSign & TypeSpecifierType into...
Faisal Vali [Mon, 1 Jan 2018 02:19:52 +0000 (02:19 +0000)]
[NFC] Modernize enums TypeSpecifierWidth, TypeSpecifierSign & TypeSpecifierType into scoped enums.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321614 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Sema] Improve diagnostics for const- and ref-qualified member functions
Jacob Bandes-Storch [Sun, 31 Dec 2017 18:27:29 +0000 (18:27 +0000)]
[Sema] Improve diagnostics for const- and ref-qualified member functions

(Re-submission of D39937 with fixed tests.)

Adjust wording for const-qualification mismatch to be a little more clear.

Also add another diagnostic for a ref qualifier mismatch, which previously produced a useless error (this error path is simply very old; see rL119336):

Before:
  error: cannot initialize object parameter of type 'X0' with an expression of type 'X0'

After:
  error: 'this' argument to member function 'rvalue' is an lvalue, but function has rvalue ref-qualifier

Reviewers: aaron.ballman

Reviewed By: aaron.ballman

Subscribers: lebedev.ri, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321609 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoReverted 321592: [Sema] Improve diagnostics for const- and ref-qualified member functions
Jacob Bandes-Storch [Sun, 31 Dec 2017 05:13:03 +0000 (05:13 +0000)]
Reverted 321592: [Sema] Improve diagnostics for const- and ref-qualified member functions

A few tests need to be fixed

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321593 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Sema] Improve diagnostics for const- and ref-qualified member functions
Jacob Bandes-Storch [Sun, 31 Dec 2017 04:49:39 +0000 (04:49 +0000)]
[Sema] Improve diagnostics for const- and ref-qualified member functions

Summary:
Adjust wording for const-qualification mismatch to be a little more clear.

Also add another diagnostic for a ref qualifier mismatch, which previously produced a useless error (this error path is simply very old; see rL119336):

Before:
  error: cannot initialize object parameter of type 'X0' with an expression of type 'X0'

After:
  error: 'this' argument to member function 'rvalue' is an lvalue, but function has rvalue ref-qualifier

Reviewers: rsmith, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: lebedev.ri, aaron.ballman, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321592 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[NFC] Modernize enum DeclSpecContext into a scoped enum.
Faisal Vali [Sun, 31 Dec 2017 00:06:40 +0000 (00:06 +0000)]
[NFC] Modernize enum DeclSpecContext into a scoped enum.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321590 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoReverted 321587: Enable configuration files in clang
Serge Pavlov [Sat, 30 Dec 2017 18:38:44 +0000 (18:38 +0000)]
Reverted 321587: Enable configuration files in clang

Need to check targets in tests more carefully.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321588 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoEnable configuration files in clang
Serge Pavlov [Sat, 30 Dec 2017 17:59:26 +0000 (17:59 +0000)]
Enable configuration files in clang

Clang is inherently a cross compiler and can generate code for any target
enabled during build. It however requires to specify many parameters in the
invocation, which could be hardcoded during configuration process in the
case of single-target compiler. The purpose of configuration files is to
make specifying clang arguments easier.

A configuration file is a collection of driver options, which are inserted
into command line before other options specified in the clang invocation.
It groups related options together and allows specifying them in simpler,
more flexible and less error prone way than just listing the options
somewhere in build scripts. Configuration file may be thought as a "macro"
that names an option set and is expanded when the driver is called.

Use of configuration files is described in `UserManual.rst`.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321587 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[NFC] Modernize enum 'UnqualifiedId::IdKind' into a scoped enum UnqualifiedIdKind.
Faisal Vali [Sat, 30 Dec 2017 04:15:27 +0000 (04:15 +0000)]
[NFC] Modernize enum 'UnqualifiedId::IdKind' into a scoped enum UnqualifiedIdKind.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321574 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[docs] Added description of `-f[no]-openmp-simd` option to UsersManual.
Alexey Bataev [Fri, 29 Dec 2017 18:27:00 +0000 (18:27 +0000)]
[docs] Added description of `-f[no]-openmp-simd` option to UsersManual.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321562 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[docs] Updated ReleaseNotes for OpenMP part.
Alexey Bataev [Fri, 29 Dec 2017 18:23:12 +0000 (18:23 +0000)]
[docs] Updated ReleaseNotes for OpenMP part.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321561 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[OPENMP] Support for -fopenmp-simd option with compilation of simd loops
Alexey Bataev [Fri, 29 Dec 2017 18:07:07 +0000 (18:07 +0000)]
[OPENMP] Support for -fopenmp-simd option with compilation of simd loops
only.

Added support for -fopenmp-simd option that allows compilation of
simd-based constructs without emission of OpenMP runtime calls.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321560 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[driver][darwin] Take the OS version from -m<os>-version-min argument when
Alex Lorenz [Fri, 29 Dec 2017 17:42:40 +0000 (17:42 +0000)]
[driver][darwin] Take the OS version from -m<os>-version-min argument when
-target has no OS version

This ensures that Clang won't warn about redundant -m<os>-version-min
argument for an invocation like
`-target x86_64-apple-macos -mmacos-version-min=10.11`

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321559 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[OPENMP] Initial support for `-fopenmp-simd` option.
Alexey Bataev [Fri, 29 Dec 2017 17:36:15 +0000 (17:36 +0000)]
[OPENMP] Initial support for `-fopenmp-simd` option.

Added basic support for `-fopenmp-simd` options.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321558 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert r321504 "[X86] Don't accidentally enable PKU on cannon lake and icelake or...
Craig Topper [Fri, 29 Dec 2017 06:39:16 +0000 (06:39 +0000)]
Revert r321504 "[X86] Don't accidentally enable PKU on cannon lake and icelake or CLWB on cannonlake."

I based that commit on what was in Intel's public documentation here https://software.intel.com/sites/default/files/managed/c5/15/architecture-instruction-set-extensions-programming-reference.pdf

Which specifically said CLWB wasn't until Icelake.

But I've since cross checked with SDE and it thinks these features exist on CNL and ICL. So now I don't know what to believe.

I've added test coverage of the current behavior as part of the revert so at least now have proof of what we're doing.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321547 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[NFC] Modernize enum Declarator::TheContext to a type-safe scoped enum.
Faisal Vali [Fri, 29 Dec 2017 05:41:00 +0000 (05:41 +0000)]
[NFC] Modernize enum Declarator::TheContext to a type-safe scoped enum.

Note, we don't do any bitwise manipulations when using them.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321546 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAvoid int to string conversion in Twine or raw_ostream contexts.
Benjamin Kramer [Thu, 28 Dec 2017 16:58:54 +0000 (16:58 +0000)]
Avoid int to string conversion in Twine or raw_ostream contexts.

Some output changes from uppercase hex to lowercase hex, no other functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321526 91177308-0d34-0410-b5e6-96231b3b80d8