]> granicus.if.org Git - clang/log
clang
6 years ago[analyzer] suppress nullability inference from a macro when result is used in another...
George Karpenkov [Wed, 10 Jan 2018 01:22:14 +0000 (01:22 +0000)]
[analyzer] suppress nullability inference from a macro when result is used in another macro

The current code used to not suppress the report, if the dereference was
performed in a macro, assuming it is that same macro.
However, the assumption might not be correct, and XNU has quite a bit of
code where dereference is actually performed in a different macro.

As the code uses macro name and not a unique identifier it might be fragile,
but in a worst-case scenario we would simply emit an extra diagnostic.

rdar://36160245

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

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

6 years ago[cmake] Delete redundant install command for clang-refactor.
Don Hinton [Wed, 10 Jan 2018 01:00:28 +0000 (01:00 +0000)]
[cmake] Delete redundant install command for clang-refactor.

Summary: Install targets for clang tools are controlled by
CLANG_BUILD_TOOLS, and when OFF, cmake issues the following warning:

WARNING: Target "clang-refactor" has EXCLUDE_FROM_ALL set and will not
be built by default but an install rule has been provided for it.
CMake does not define behavior for this case.

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

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

6 years agoReland "Emit Function IDs table for Control Flow Guard"
Adrian McCarthy [Tue, 9 Jan 2018 23:49:30 +0000 (23:49 +0000)]
Reland "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.

The original patch didn't have the lit.local.cfg file that restricts the new
test to x86, thus the new test was failing on the non-x86 bots.

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

The reverts r322008, which was a revert of r322005.

This reverts commit a05b89f9aca70597dc79fe97bc49b50b51f525ba.

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

6 years agoWire up GCOV to the new pass manager
David Blaikie [Tue, 9 Jan 2018 22:03:47 +0000 (22:03 +0000)]
Wire up GCOV to the new pass manager

GCOV in the old pass manager also strips debug info (if debug info is
disabled/only produced for profiling anyway) after the GCOV pass runs.

I think the strip pass hasn't been ported to the new pass manager, so it
might take me a little while to wire that up.

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

6 years ago[Frontend] Remove unused FileMgr in pp arg parse
Brian Gesiak [Tue, 9 Jan 2018 21:26:47 +0000 (21:26 +0000)]
[Frontend] Remove unused FileMgr in pp arg parse

Summary:
A FIXME added 8 years ago (2010) in https://reviews.llvm.org/rL118203
mentioned that a FileManager should not need to be used when parsing
preprocessor arguments. In fact, its only use was removed 6 years ago
(2012), in https://reviews.llvm.org/rL166452. Remove the unused
variable and the obsolete FIXME.

Test Plan: `check-clang`

Reviewers: v.g.vassilev

Reviewed By: v.g.vassilev

Subscribers: cfe-commits

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

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

6 years ago[OPENMP] Fix directive kind on stand-alone target data directives, NFC.
Alexey Bataev [Tue, 9 Jan 2018 19:59:25 +0000 (19:59 +0000)]
[OPENMP] Fix directive kind on stand-alone target data directives, NFC.

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

6 years ago[OpenMP] Fix handling of clause on wrong directive, by Joel. E. Denny
Alexey Bataev [Tue, 9 Jan 2018 19:21:04 +0000 (19:21 +0000)]
[OpenMP] Fix handling of clause on wrong directive, by Joel. E. Denny

Summary:
First, this patch fixes an assert failure when, for example, "omp for"
has num_teams.

Second, this patch prevents duplicate diagnostics when, for example,
"omp for" has uniform.

This patch makes the general assumption (even where it doesn't
necessarily fix an existing bug) that it is worthless to perform sema
for a clause that appears on a directive on which OpenMP does not
permit that clause.  However, due to this assumption, this patch
suppresses some diagnostics that were expected in the test suite.  I
assert that those diagnostics were likely just distracting to the
user.

Reviewers: ABataev

Reviewed By: ABataev

Subscribers: cfe-commits

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

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

6 years ago[ASTImporter] Support importing CXXUnresolvedConstructExpr and UnresolvedLookupExpr
Aleksei Sidorin [Tue, 9 Jan 2018 16:40:40 +0000 (16:40 +0000)]
[ASTImporter] Support importing CXXUnresolvedConstructExpr and UnresolvedLookupExpr

* Note: This solution is based on
  https://github.com/haoNoQ/clang/blob/summary-ipa-draft/lib/AST/ASTImporter.cpp#L7605.

Patch by Peter Szecsi!

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

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

6 years agoExplicitly specify output file.
Alexander Kornienko [Tue, 9 Jan 2018 15:05:13 +0000 (15:05 +0000)]
Explicitly specify output file.

Otherwise the test fails when LLVM sources are on a read-only partition.

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

6 years ago[ASTImporter] Fix missing SourceLoc import for ObjCMethodDecl selectors
Aleksei Sidorin [Tue, 9 Jan 2018 14:25:05 +0000 (14:25 +0000)]
[ASTImporter] Fix missing SourceLoc import for ObjCMethodDecl selectors

Patch by Nico Rieck, test case by Sean Callanan!

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

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

6 years agoTrack in the AST whether the operand to a UnaryOperator can overflow and then use...
Aaron Ballman [Tue, 9 Jan 2018 13:07:03 +0000 (13:07 +0000)]
Track in the AST whether the operand to a UnaryOperator can overflow and then use that logic when evaluating constant expressions and emitting codegen.

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

6 years agoAvoid assumption that lit tests are writable (in a couple more places). NFC
Sam McCall [Tue, 9 Jan 2018 09:32:53 +0000 (09:32 +0000)]
Avoid assumption that lit tests are writable (in a couple more places). NFC

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

6 years agoananas: Add shared library support
Ed Schouten [Tue, 9 Jan 2018 09:18:14 +0000 (09:18 +0000)]
ananas: Add shared library support

The Ananas Operating System (https://github.com/zhmu/ananas) has shared
library support as of commit 57739c0b6ece56dd4872aedf30264ed4b9412c77.

This change adds the necessary settings to clang so that shared
executables and libraries can be build correctly.

Submitted by: Rink Springer
Differential Revision: https://reviews.llvm.org/D41500

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

6 years agoAdded Control Flow Protection Flag
Oren Ben Simhon [Tue, 9 Jan 2018 08:53:59 +0000 (08:53 +0000)]
Added Control Flow Protection Flag

Cf-protection is a target independent flag that instructs the back-end to instrument control flow mechanisms like: Branch, Return, etc.
For example in X86 this flag will be used to instrument Indirect Branch Tracking instructions.

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

Change-Id: I5126e766c0e6b84118cae0ee8a20fe78cc373dea

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

6 years agoFix use-after-free found by address-san on -r322028.
Erich Keane [Tue, 9 Jan 2018 01:09:12 +0000 (01:09 +0000)]
Fix use-after-free found by address-san on -r322028.

r322028 attempted to remove something from the "Manglings"
list when it was no longer valid, and did so with 'erase'.

However, StringRefs to these were stored, so these became
dangling references.  This patch changes to using 'remove' instead
of 'erase' to keep the strings valid.

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

6 years agoDocument attribute target multiversioning.
Erich Keane [Mon, 8 Jan 2018 23:36:29 +0000 (23:36 +0000)]
Document attribute target multiversioning.

Add attribute target multiversioning to the release notes.
Additionally adds multiversioning support to the attribute
documentation for 'target'.

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

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

6 years ago[X86] Replace cvt*2mask intrinsics with native IR using 'icmp slt X, zeroinitializer.
Craig Topper [Mon, 8 Jan 2018 22:37:56 +0000 (22:37 +0000)]
[X86] Replace cvt*2mask intrinsics with native IR using 'icmp slt X, zeroinitializer.

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

6 years agoPR35862: Suppress -Wmissing-variable-declarations warning on inline variables,
Richard Smith [Mon, 8 Jan 2018 21:46:42 +0000 (21:46 +0000)]
PR35862: Suppress -Wmissing-variable-declarations warning on inline variables,
variable templates, and instantiations thereof.

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

6 years agoImplement Attribute Target MultiVersioning
Erich Keane [Mon, 8 Jan 2018 21:34:17 +0000 (21:34 +0000)]
Implement Attribute Target MultiVersioning

GCC's attribute 'target', in addition to being an optimization hint,
also allows function multiversioning. We currently have the former
implemented, this is the latter's implementation.

This works by enabling functions with the same name/signature to coexist,
so that they can all be emitted. Multiversion state is stored in the
FunctionDecl itself, and SemaDecl manages the definitions.
Note that it ends up having to permit redefinition of functions so
that they can all be emitted. Additionally, all versions of the function
must be emitted, so this also manages that.

Note that this includes some additional rules that GCC does not, since
defining something as a MultiVersion function after a usage has been made illegal.

The only 'history rewriting' that happens is if a function is emitted before
it has been converted to a multiversion'ed function, at which point its name
needs to be changed.

Function templates and virtual functions are NOT yet supported (not supported
in GCC either).

Additionally, constructors/destructors are disallowed, but the former is
planned.

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

6 years ago[DOXYGEN] Fix doxygen and content issues in avxintrin.h
Douglas Yung [Mon, 8 Jan 2018 21:21:17 +0000 (21:21 +0000)]
[DOXYGEN] Fix doxygen and content issues in avxintrin.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".
- Fix a few typos and errors found during review.
- Restore new line endings.

This patch was made by Craig Flores

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

6 years agoFactor out comparison handling for arithmetic types.
Richard Smith [Mon, 8 Jan 2018 21:12:04 +0000 (21:12 +0000)]
Factor out comparison handling for arithmetic types.

This is not quite NFC: we don't perform the usual arithmetic conversions unless
we have an operand of arithmetic or enumeration type any more. This matches the
standard rule, but actually has no effect other than to marginally improve our
diagnostics for the non-arithmetic, non-enumeration cases (by not performing
integral promotions on one operand if the other is a pointer).

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

6 years ago[Myriad] Remove invalidated -elf flag for MoviAsm
Walter Lee [Mon, 8 Jan 2018 20:36:08 +0000 (20:36 +0000)]
[Myriad] Remove invalidated -elf flag for MoviAsm

Summary:
The flag has been deprecated, and is becoming invalid in the latest
MDK.

Reviewers: jyknight

Subscribers: cfe-commits

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

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

6 years ago[OPENMP] Fix debug info for outlined functions in NVPTX + add more tests.
Alexey Bataev [Mon, 8 Jan 2018 20:09:47 +0000 (20:09 +0000)]
[OPENMP] Fix debug info for outlined functions in NVPTX  + add more tests.

Fixed name of emitted outlined functions in NVPTX target + extra tests
for the debug info.

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

6 years ago[OPENMP] Current status of OpenMP support.
Alexey Bataev [Mon, 8 Jan 2018 19:02:51 +0000 (19:02 +0000)]
[OPENMP] Current status of OpenMP support.

Summary: Some info about supported features of OpenMP 4.5-5.0.

Reviewers: hfinkel, rsmith

Subscribers: kkwli0, Hahnfeld, cfe-commits

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

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

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