]> granicus.if.org Git - clang/log
clang
6 years ago[analyzer] Create generic SMT Sort Class
Mikhail R. Gadelha [Wed, 25 Jul 2018 12:49:15 +0000 (12:49 +0000)]
[analyzer] Create generic SMT Sort Class

Summary:
New base class for all future SMT sorts.

The only change is that the class implements methods `isBooleanSort()`, `isBitvectorSort()` and `isFloatSort()` so it doesn't rely on `Z3`'s enum.

Reviewers: NoQ, george.karpenkov

Reviewed By: george.karpenkov

Subscribers: xazax.hun, szepet, a.sidorin

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

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

6 years ago[analyzer] Moved static Context to class member
Mikhail R. Gadelha [Wed, 25 Jul 2018 12:49:11 +0000 (12:49 +0000)]
[analyzer] Moved static Context to class member

Summary:
Although it is a big patch, the changes are simple:
1. There is one `Z3_Context` now, member of the `SMTConstraintManager` class.
2. `Z3Expr`, `Z3Sort`, `Z3Model` and `Z3Solver` are constructed with a reference to the `Z3_Context` in `SMTConstraintManager`.
3. All static functions are now members of `Z3Solver`, e.g, the `SMTConstraintManager` now calls `Solver.fromBoolean(false)` instead of `Z3Expr::fromBoolean(false)`.

Most of the patch only move stuff around except:
1. New method `Z3Sort MkSort(const QualType &Ty, unsigned BitWidth)`, that creates a sort based on the `QualType` and its width. Used to simplify the `fromData` method.

Unfortunate consequence of this patch:
1. `getInterpretation` was moved from `Z3Model` class to `Z3Solver`, because it needs to create a `Z3Sort` before returning the interpretation. This can be fixed by changing both `toAPFloat` and `toAPSInt` by removing the dependency of `Z3Sort` (it's only used to check which Sort was created and to retrieve the type width).

Reviewers: NoQ, george.karpenkov, ddcc

Reviewed By: george.karpenkov

Subscribers: xazax.hun, szepet, a.sidorin

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

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

6 years ago[analyzer] Create generic SMT Context class
Mikhail R. Gadelha [Wed, 25 Jul 2018 12:49:07 +0000 (12:49 +0000)]
[analyzer] Create generic SMT Context class

Summary:
This patch creates `SMTContext` which will wrap a specific SMT context, through `SMTSolverContext`.

The templated `SMTSolverContext` class it's a simple wrapper around a SMT specific context (currently only used in the Z3 backend), while `Z3Context` inherits `SMTSolverContext<Z3_context>` and implements solver specific operations like initialization and destruction of the context.

This separation was done because:

1. We might want to keep one single context, shared across different `SMTConstraintManager`s. It can be achieved by constructing a `SMTContext`, through a function like `CreateSMTContext(Z3)`, `CreateSMTContext(BOOLECTOR)`, etc. The rest of the CSA only need to know about `SMTContext`, so maybe it's a good idea moving `SMTSolverContext` to a separate header in the future.

2. Any generic SMT operation will only require one `SMTSolverContext`object, which can access the specific context by calling `getContext()`.

Reviewers: NoQ, george.karpenkov

Reviewed By: george.karpenkov

Subscribers: xazax.hun, szepet, a.sidorin

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

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

6 years ago[clang-format ]Extend IncludeCategories regex documentation
Krasimir Georgiev [Wed, 25 Jul 2018 10:21:47 +0000 (10:21 +0000)]
[clang-format ]Extend IncludeCategories regex documentation

Summary:
Extend the Clang-Format IncludeCategories documentation by adding a link to the supported regular expression standard (POSIX).
And extenting the example with a system header regex.
[[ https://bugs.llvm.org/show_bug.cgi?id=35041 | bug 35041]]

Contributed by WimLeflere!

Reviewers: krasimir, Typz

Reviewed By: krasimir

Subscribers: cfe-commits

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

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

6 years ago[ASTImporter] Add support for import of CXXInheritedCtorInitExpr.
Balazs Keri [Wed, 25 Jul 2018 10:21:06 +0000 (10:21 +0000)]
[ASTImporter] Add support for import of CXXInheritedCtorInitExpr.

Reviewers: a.sidorin, martong

Reviewed By: martong

Subscribers: rnkovacs, a_sidorin, martong, cfe-commits

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

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

6 years agocc1_main: fix -Wsign-compare on FreeBSD
Fangrui Song [Wed, 25 Jul 2018 06:57:31 +0000 (06:57 +0000)]
cc1_main: fix -Wsign-compare on FreeBSD

Its __rlim_t is intentionally signed (__int64_t) because of legacy code
that uses -1 for RLIM_INFINITY.

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

6 years agoCodeGen: use non-zero memset when possible for automatic variables
JF Bastien [Wed, 25 Jul 2018 04:29:03 +0000 (04:29 +0000)]
CodeGen: use non-zero memset when possible for automatic variables

Summary:
Right now automatic variables are either initialized with bzero followed by a few stores, or memcpy'd from a synthesized global. We end up encountering a fair amount of code where memcpy of non-zero byte patterns would be better than memcpy from a global because it touches less memory and generates a smaller binary. The optimizer could reason about this, but it's not really worth it when clang already knows.

This code could definitely be more clever but I'm not sure it's worth it. In particular we could track a histogram of bytes seen and figure out (as we do with bzero) if a memset could be followed by a handful of stores. Similarly, we could tune the heuristics for GlobalSize, but using the same as for bzero seems conservatively OK for now.

<rdar://problem/42563091>

Reviewers: dexonsmith

Subscribers: cfe-commits

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

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

6 years ago[profile] Support profiling runtime on Fuchsia
Petr Hosek [Wed, 25 Jul 2018 03:01:35 +0000 (03:01 +0000)]
[profile] Support profiling runtime on Fuchsia

This ports the profiling runtime on Fuchsia and enables the
instrumentation. Unlike on other platforms, Fuchsia doesn't use
files to dump the instrumentation data since on Fuchsia, filesystem
may not be accessible to the instrumented process. We instead use
the data sink to pass the profiling data to the system the same
sanitizer runtimes do.

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

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

6 years ago[CMake] Link static libunwind and libc++abi into libc++ in Fuchsia toolchain
Petr Hosek [Wed, 25 Jul 2018 01:44:22 +0000 (01:44 +0000)]
[CMake] Link static libunwind and libc++abi into libc++ in Fuchsia toolchain

When building libc++ for Fuchsia, we want to distribute shared libc++,
libc++abi and libunwind as separate libraries, but for static versions
we would like to link all of them into libc++ so -lc++ flag has the same
effect whether shared or static library is being used.

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

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

6 years ago[analyzer] Syntactic matcher for leaks associated with run loop and autoreleasepool
George Karpenkov [Wed, 25 Jul 2018 01:27:15 +0000 (01:27 +0000)]
[analyzer] Syntactic matcher for leaks associated with run loop and autoreleasepool

A checker for detecting leaks resulting from allocating temporary
autoreleasing objects before starting the main run loop.

Checks for two antipatterns:

1. ObjCMessageExpr followed by [[NARunLoop mainRunLoop] run] in the same
autorelease pool.

2. ObjCMessageExpr followed by [[NARunLoop mainRunLoop] run] in no
autorelease pool.

Happens-before relationship is modeled purely syntactically.

rdar://39299145

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

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

6 years agoRevert "[analyzer] Extend NoStoreFuncVisitor to insert a note on IVars"
George Karpenkov [Tue, 24 Jul 2018 23:23:33 +0000 (23:23 +0000)]
Revert "[analyzer] Extend NoStoreFuncVisitor to insert a note on IVars"

This reverts commit a9e21bd727112cd69eabc1af648c5da6b773d06e.
Reverted because the dependency has not landed yet.

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

6 years ago[analyzer] Extend NoStoreFuncVisitor to insert a note on IVars
George Karpenkov [Tue, 24 Jul 2018 23:14:29 +0000 (23:14 +0000)]
[analyzer] Extend NoStoreFuncVisitor to insert a note on IVars

The note is added in the following situation:

 - We are throwing a nullability-related warning on an IVar
 - The path goes through a method which *could have* (syntactically
 determined) written into that IVar, but did not

rdar://42444460

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

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

6 years ago[Sema] Destroy tokens in DeclaratorChunk params
Benjamin Kramer [Tue, 24 Jul 2018 22:47:16 +0000 (22:47 +0000)]
[Sema] Destroy tokens in DeclaratorChunk params

Otherwise this leaks in some edge cases.

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

6 years agoDon't lifetime-extend or track lifetime problems through the LHS of '->*'.
Richard Smith [Tue, 24 Jul 2018 21:18:30 +0000 (21:18 +0000)]
Don't lifetime-extend or track lifetime problems through the LHS of '->*'.

Fixes a false-positive warning found by selfhost.

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

6 years agoRevert "[VFS] Cleanups to VFS interfaces."
Jordan Rupprecht [Tue, 24 Jul 2018 20:28:07 +0000 (20:28 +0000)]
Revert "[VFS] Cleanups to VFS interfaces."

This reverts commit r337834 due to test failures.

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

6 years agoRemove stale documentation from InternalsManual.rst
Erich Keane [Tue, 24 Jul 2018 16:11:30 +0000 (16:11 +0000)]
Remove stale documentation from InternalsManual.rst

The DuplicatesAllowedWhileMerging was removed a while ago,
but the documentation remained.

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

6 years ago[VFS] Cleanups to VFS interfaces.
Sam McCall [Tue, 24 Jul 2018 16:00:55 +0000 (16:00 +0000)]
[VFS] Cleanups to VFS interfaces.

Summary:
- add comments clarifying semantics
- Status::copyWithNewName(Status, Name) --> instance method
- Status::copyWithNewName(fs::file_status, Name) --> constructor (it's not a copy)
- File::getName() -> getRealPath(), reflecting its actual behavior/function
  and stop returning status().getName() in the base class (callers can do this
  fallback if they want to, it complicates the contracts).

This is mostly NFC, but the behavior of File::getName() affects FileManager's
FileEntry::tryGetRealPathName(), which now fails in more cases:
 - non-real file cases
 - real-file cases where the underlying vfs::File was opened in a way that
   doesn't call realpath().
(In these cases we don't know a distinct real name, so in principle it seems OK)

Reviewers: klimek

Subscribers: cfe-commits

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

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

6 years ago[Sema] Mark implicitly-inserted ICE's as being part of explicit cast (PR38166)
Roman Lebedev [Tue, 24 Jul 2018 08:16:50 +0000 (08:16 +0000)]
[Sema] Mark implicitly-inserted ICE's as being part of explicit cast (PR38166)

Summary:
As discussed in [[ https://bugs.llvm.org/show_bug.cgi?id=38166 | PR38166 ]], we need to be able to distinqush whether the cast
we are visiting is actually a cast, or part of an `ExplicitCast`.
There are at least four ways to get there:
1. Introduce a new `CastKind`, and use it instead of `IntegralCast` if we are in `ExplicitCast`.

   Would work, but does not scale - what if we will need more of these cast kinds?
2. Introduce a flag in `CastExprBits`, whether this cast is part of `ExplicitCast` or not.

   Would work, but it isn't immediately clear where it needs to be set.
2. Fix `ScalarExprEmitter::VisitCastExpr()` to visit these `NoOp` casts.

   As pointed out by @rsmith, CodeGenFunction::EmitMaterializeTemporaryExpr calls

   skipRValueSubobjectAdjustments, which steps over the CK_NoOp cast`,

   which explains why we currently don't visit those.

   This is probably impossible, as @efriedma points out, that is intentional as per `[class.temporary]` in the standard
3. And the simplest one, just record which NoOp casts we skip.

   It just kinda works as-is afterwards.

But, the approach with a flag is the least intrusive one, and is probably the best one overall.

Reviewers: rsmith, rjmccall, majnemer, efriedma

Reviewed By: rsmith

Subscribers: cfe-commits, aaron.ballman, vsk, llvm-commits, rsmith

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

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

6 years agoAdd a .keep file to prevent svn from skipping over an empty folder.
Jiading Gai [Tue, 24 Jul 2018 06:49:27 +0000 (06:49 +0000)]
Add a .keep file to prevent svn from skipping over an empty folder.

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

6 years agoFor x86_64, gcc 7.2 under Amazon Linux AMI sets its path to x86_64-amazon-linux.
Jiading Gai [Tue, 24 Jul 2018 06:07:22 +0000 (06:07 +0000)]
For x86_64, gcc 7.2 under Amazon Linux AMI sets its path to x86_64-amazon-linux.

gcc 7.2 under Amazon Linux AMI sets its paths to x86_64-amazon-linux. Adding
this triple to the list of search, plus a test case to cover this.

The patch fixes the following bug reported in bugzilla:

https://bugs.llvm.org/show_bug.cgi?id=35992

Reviewers: echristo

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

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

6 years ago[Test commit] Fix a spelling error.
Jiading Gai [Tue, 24 Jul 2018 03:34:15 +0000 (03:34 +0000)]
[Test commit] Fix a spelling error.

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

6 years agoRevert "[DebugInfo] Generate debug information for labels. (Fix PR37395)"
Shiva Chen [Tue, 24 Jul 2018 02:57:11 +0000 (02:57 +0000)]
Revert "[DebugInfo] Generate debug information for labels. (Fix PR37395)"

This reverts commit 4288dd3bf082482e02c8a044c611c18168cb0180.

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

6 years ago[DebugInfo] Generate debug information for labels. (Fix PR37395)
Shiva Chen [Tue, 24 Jul 2018 02:23:59 +0000 (02:23 +0000)]
[DebugInfo] Generate debug information for labels. (Fix PR37395)

Generate DILabel metadata and call llvm.dbg.label after label
statement to associate the metadata with the label.

After fixing PR37395.

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

Patch by Hsiangkai Wang.

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

6 years agoAttempt to fix regression due to r337791
Yaxun Liu [Tue, 24 Jul 2018 02:12:24 +0000 (02:12 +0000)]
Attempt to fix regression due to r337791

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

6 years agoFix unused variable warnings; NFC
George Burgess IV [Tue, 24 Jul 2018 02:10:53 +0000 (02:10 +0000)]
Fix unused variable warnings; NFC

Looks like MTE was previously used for its SourceLoc, but we're now
using a seperate SourceLocation here.

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

6 years ago[HIP] pass -target-cpu when running the device-mode compiler
Yaxun Liu [Tue, 24 Jul 2018 01:40:44 +0000 (01:40 +0000)]
[HIP] pass -target-cpu when running the device-mode compiler

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

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

6 years agoAdd missing testcase update for r337790.
Richard Smith [Tue, 24 Jul 2018 01:23:36 +0000 (01:23 +0000)]
Add missing testcase update for r337790.

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

6 years agoEnable .hip files for test/Driver
Yaxun Liu [Tue, 24 Jul 2018 01:03:44 +0000 (01:03 +0000)]
Enable .hip files for test/Driver

Partially revert r334128 due to regressions.

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

6 years agoWarn if a local variable's initializer retains a pointer/reference to a
Richard Smith [Tue, 24 Jul 2018 00:55:08 +0000 (00:55 +0000)]
Warn if a local variable's initializer retains a pointer/reference to a
non-lifetime-extended temporary object.

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

6 years agoBorrow visibility from __fundamental_type_info for generated fundamental type infos
Thomas Anderson [Tue, 24 Jul 2018 00:43:47 +0000 (00:43 +0000)]
Borrow visibility from __fundamental_type_info for generated fundamental type infos

This is necessary so the clang gives hidden visibility to fundamental types when
-fvisibility=hidden is passed. Fixes
https://bugs.llvm.org/show_bug.cgi?id=35066

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

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

6 years ago[WebAssembly] Change size_t to `unsigned long`.
Dan Gohman [Tue, 24 Jul 2018 00:29:58 +0000 (00:29 +0000)]
[WebAssembly] Change size_t to `unsigned long`.

Changing it to unsigned long (which is 32-bit on wasm32) makes it the same
type as wasm64 (where unsigned long is 64-bit), which would eliminate the most
common cause for mangled names being different between wasm32 and wasm64. For
example, export lists containing symbol names could now often be the same
between wasm32 and wasm64.

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

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

6 years agoNFC: Add the emacs c++ mode hint "-*- C++ -*-" to the headers that don't have it
Erik Pilkington [Tue, 24 Jul 2018 00:07:49 +0000 (00:07 +0000)]
NFC: Add the emacs c++ mode hint "-*- C++ -*-" to the headers that don't have it

https://llvm.org/docs/CodingStandards.html#file-headers

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

6 years ago[analyzer] Add a no-crash to a recently added test.
Artem Dergachev [Mon, 23 Jul 2018 23:48:13 +0000 (23:48 +0000)]
[analyzer] Add a no-crash to a recently added test.

No functional change intended.

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

6 years ago[analyzer] pr38273: Legalize Loc<>NonLoc comparison symbols.
Artem Dergachev [Mon, 23 Jul 2018 23:09:44 +0000 (23:09 +0000)]
[analyzer] pr38273: Legalize Loc<>NonLoc comparison symbols.

Remove an assertion in RangeConstraintManager that expects such symbols to never
appear, while admitting that the constraint manager doesn't yet handle them.

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

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

6 years agoSupport lifetime-extension of conditional temporaries.
Richard Smith [Mon, 23 Jul 2018 22:56:45 +0000 (22:56 +0000)]
Support lifetime-extension of conditional temporaries.

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

6 years ago[Sema] Fix crash on BlockExprs in a default member initializers
Erik Pilkington [Mon, 23 Jul 2018 22:47:37 +0000 (22:47 +0000)]
[Sema] Fix crash on BlockExprs in a default member initializers

Clang would crash when instantiating a BlockDecl that appeared in a
default-member-initializer of a class template. Fix this by deferring the
instantiation until we instantate the BlockExpr.

rdar://41200624

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

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

6 years ago[ASTMatchers] Add an isMain() matcher
George Karpenkov [Mon, 23 Jul 2018 22:29:35 +0000 (22:29 +0000)]
[ASTMatchers] Add an isMain() matcher

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

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

6 years ago[ASTMatchers] [NFC] Regenerate HTML docs.
George Karpenkov [Mon, 23 Jul 2018 22:29:10 +0000 (22:29 +0000)]
[ASTMatchers] [NFC] Regenerate HTML docs.

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

6 years ago[clang-cl] Expose -fblocks and -fno-builtin as driver flags
Reid Kleckner [Mon, 23 Jul 2018 21:29:43 +0000 (21:29 +0000)]
[clang-cl] Expose -fblocks and -fno-builtin as driver flags

Users have requested them.

Helps with PR36427.

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

6 years agoDo not try to perform lifetime-extension through conditional
Richard Smith [Mon, 23 Jul 2018 21:21:24 +0000 (21:21 +0000)]
Do not try to perform lifetime-extension through conditional
expressions.

CodeGen can't cope with that yet. Instead, produce a "not supported"
warning for now and don't extend lifetime.

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

6 years agoFold -Wreturn-stack-address into general initialization lifetime
Richard Smith [Mon, 23 Jul 2018 21:21:22 +0000 (21:21 +0000)]
Fold -Wreturn-stack-address into general initialization lifetime
checking.

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

6 years agoUpdate to -r337585, allow scoped enum inits in -pedantic
Erich Keane [Mon, 23 Jul 2018 21:08:13 +0000 (21:08 +0000)]
Update to -r337585, allow scoped enum inits in -pedantic

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

6 years ago[CodeGen] Record if a C++ record is a trivial type
Aaron Smith [Mon, 23 Jul 2018 20:49:07 +0000 (20:49 +0000)]
[CodeGen] Record if a C++ record is a trivial type

Summary: This has a dependence on D45122

Reviewers: rnk, zturner, llvm-commits, aleksandr.urakov

Reviewed By: rnk

Subscribers: cfe-commits

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

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

6 years ago[ms] Fix mangling of vector types in QMM_Result contexts.
Nico Weber [Mon, 23 Jul 2018 20:04:00 +0000 (20:04 +0000)]
[ms] Fix mangling of vector types in QMM_Result contexts.

If QMM_Result is set (which it is for return types, RTTI descriptors, and
exception type descriptors), tag types (structs, enums, classes, unions) get
their qualifiers mangled in.

__m64 and friends is a struct/union thingy in MSVC, but not in clang's headers.
To make mangling work, we call mangleArtificalTagType(TTK_Union/TTK_Struct for
the vector types to mangle them as tag types -- but the isa<TagType> check when
mangling in QMM_Result mode isn't true for these vector types. Add an
isArtificialTagType() function and check for that too. Fixes PR37276 and some
other issues.

I tried to audit all references to TagDecl and TagType in MicrosoftMangle.cpp
to find other places where we need to call mangleArtificalTagType(), but
couldn't find any.

I tried to audit all calls to mangleArtificalTagType() to see if
isArtificialTagType() needs to handle more than just the vector types, but as
far as I can tell all other types we use it for are types that MSVC can't
handle at all (Objective-C types etc).

https://reviews.llvm.org/D49597

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

6 years agoSeparate out the initialization kind for a statement expression result
Richard Smith [Mon, 23 Jul 2018 19:19:08 +0000 (19:19 +0000)]
Separate out the initialization kind for a statement expression result
from that for a return value.

No functionality change intended: I don't believe any of the diagnostics
affected by this patch are reachable when initializing the result of
statement expression.

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

6 years agoFold dangling-field warning into general initialization lifetime checks.
Richard Smith [Mon, 23 Jul 2018 18:50:26 +0000 (18:50 +0000)]
Fold dangling-field warning into general initialization lifetime checks.

This reinstates r337627, reverted in r337671, with a fix to correctly
handle the lvalueness of array subscript expressions on pointers.

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

6 years agoRevert "[OPENMP] Fix PR38026: Link -latomic when -fopenmp is used."
Jonas Hahnfeld [Mon, 23 Jul 2018 18:27:09 +0000 (18:27 +0000)]
Revert "[OPENMP] Fix PR38026: Link -latomic when -fopenmp is used."

This reverts commit r336467: libatomic is not available on all Linux
systems and this commit completely breaks OpenMP on them, even if there
are no atomic operations or all of them can be lowered to hardware
instructions.

See http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180716/234816.html
for post-commit discussion.

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

6 years ago[CStringSyntaxChecker] Improvements of strlcpy check
David Carlier [Mon, 23 Jul 2018 18:26:38 +0000 (18:26 +0000)]
[CStringSyntaxChecker] Improvements of strlcpy check

Adding an additional check whenwe offset fro the buffer base address.

Reviewers: george.karpenkov,NoQ

Reviewed By: george.karpenkov

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

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

6 years ago[DebugInfo] Error out when enabling -fdebug-types-section on non-ELF target.
Jonas Devlieghere [Mon, 23 Jul 2018 17:50:15 +0000 (17:50 +0000)]
[DebugInfo] Error out when enabling -fdebug-types-section on non-ELF target.

Currently, support for debug_types is only present for ELF and trying to
pass -fdebug-types-section for other targets results in a crash in the
backend. Until this is fixed, we should emit a diagnostic in the front
end when the option is passed for non-linux targets.

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

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

6 years ago[MS] Update _MSVC_LANG values for C++17 and C++2a
Reid Kleckner [Mon, 23 Jul 2018 17:44:00 +0000 (17:44 +0000)]
[MS] Update _MSVC_LANG values for C++17 and C++2a

Fixes PR38262

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

6 years ago[Sema] Don't emit -Wmemset-transposed-args for memset(p,0,0)
Erik Pilkington [Mon, 23 Jul 2018 16:24:14 +0000 (16:24 +0000)]
[Sema] Don't emit -Wmemset-transposed-args for memset(p,0,0)

Thanks to Arthur O'Dwyer for the suggestion!

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

6 years ago[NEON] Define half-precision vmaxnm intrinsics only when available
Ivan A. Kosarev [Mon, 23 Jul 2018 16:01:35 +0000 (16:01 +0000)]
[NEON] Define half-precision vmaxnm intrinsics only when available

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

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

6 years ago[ASTMatchers] add matcher for decltypeType and its underlyingType
Jonas Toth [Mon, 23 Jul 2018 15:59:27 +0000 (15:59 +0000)]
[ASTMatchers] add matcher for decltypeType and its underlyingType

Summary:
This patch introduces a new matcher for `DecltypeType` and its underlying type
in order to fix a bug in clang-tidy, see https://reviews.llvm.org/D48717 for more.

Reviewers: aaron.ballman, alexfh, NoQ, dcoughlin

Reviewed By: aaron.ballman

Subscribers: cfe-commits

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

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

6 years ago[NEON] Define half-precision vrnd intrinsics only when available
Ivan A. Kosarev [Mon, 23 Jul 2018 14:53:44 +0000 (14:53 +0000)]
[NEON] Define half-precision vrnd intrinsics only when available

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

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

6 years ago[NEON] Fix support for vrndi_f32(), vrndiq_f32() and vrndns_f32() intrinsics
Ivan A. Kosarev [Mon, 23 Jul 2018 13:26:37 +0000 (13:26 +0000)]
[NEON] Fix support for vrndi_f32(), vrndiq_f32() and vrndns_f32() intrinsics

This patch adds support for vrndi_f32() and vrndiq_f32()
intrinsics in AArch32 mode and for vrndns_f32() intrinsic in
AArch64 mode.

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

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

6 years ago[AST] Use llvm::TrailingObjects in CXXTryStmt
Benjamin Kramer [Mon, 23 Jul 2018 12:45:24 +0000 (12:45 +0000)]
[AST] Use llvm::TrailingObjects in CXXTryStmt

1. Use llvm::TrailingObjects in CXXTryStmt instead of manually doing the reinterpret_casts + pointer arithmetic. This is more consistent with other classes using this idiom and this make it clearer that this class has trailing objects.
2. Make the class CXXTryStmt final since it has trailing objects.
3. Move the friend declarations together.

No functional changes.

Patch by Bruno Ricci!

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

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

6 years ago[Tooling] Use UniqueStringSaver. NFC
Sam McCall [Mon, 23 Jul 2018 11:25:25 +0000 (11:25 +0000)]
[Tooling] Use UniqueStringSaver. NFC

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

6 years agoFix for last commit: adding new test file forgotten.
Adam Balogh [Mon, 23 Jul 2018 10:53:02 +0000 (10:53 +0000)]
Fix for last commit: adding new test file forgotten.

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

6 years ago[Analyzer] Quick Fix for exponential execution time when simpilifying complex additiv...
Adam Balogh [Mon, 23 Jul 2018 10:50:20 +0000 (10:50 +0000)]
[Analyzer] Quick Fix for exponential execution time when simpilifying complex additive expressions

Patch https://reviews.llvm.org/rC329780 not only rearranges comparisons but
also binary expressions. This latter behavior is not protected by the analyzer
option. Hower, since no complexity threshold is enforced to the symbols this
may result in exponential execution time if the expressions are too complex:
https://bugs.llvm.org/show_bug.cgi?id=38208. For a quick fix we extended the
analyzer option to also cover the additive cases.

This is only a temporary fix, the final solution should be enforcing the
complexity threshold to the symbols.

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

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

6 years agoRevert "Fold dangling-field warning into general initialization lifetime checks."
Ilya Biryukov [Mon, 23 Jul 2018 06:32:36 +0000 (06:32 +0000)]
Revert "Fold dangling-field warning into general initialization lifetime checks."

This reverts commit r337627.
After the change, clang started producing invalid warning on the following code:
    struct foo {
      foo(char *x) : x_(&x[10]) {}
    private:
      char *x_;
    };

1.cpp:2:21: warning: initializing pointer member 'x_' with the stack address of parameter 'x' [-Wdangling-field]

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

6 years agoFix the test
Brad Smith [Sun, 22 Jul 2018 22:04:28 +0000 (22:04 +0000)]
Fix the test

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

6 years agoOpenBSD/arm has switched to float ABI SoftFP.
Brad Smith [Sun, 22 Jul 2018 21:39:54 +0000 (21:39 +0000)]
OpenBSD/arm has switched to float ABI SoftFP.

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

6 years agoPR38257: don't perform ADL when instantiating a unary & operator that turns out
Richard Smith [Sun, 22 Jul 2018 05:21:47 +0000 (05:21 +0000)]
PR38257: don't perform ADL when instantiating a unary & operator that turns out
to be forming a pointer-to-member.

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

6 years ago[HIP] Support -fcuda-flush-denormals-to-zero for amdgcn
Yaxun Liu [Sat, 21 Jul 2018 02:02:22 +0000 (02:02 +0000)]
[HIP] Support -fcuda-flush-denormals-to-zero for amdgcn

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

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

6 years ago[NFC] CodeGen: rename memset to bzero
JF Bastien [Fri, 20 Jul 2018 23:37:12 +0000 (23:37 +0000)]
[NFC] CodeGen: rename memset to bzero

The optimization looks for opportunities to emit bzero, not memset. Rename the functions accordingly (and clang-format the diff) because I want to add a fallback optimization which actually tries to generate memset. bzero is still better and it would confuse the code to merge both.

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

6 years ago[Driver] Sanitizer support based on runtime library presence
George Karpenkov [Fri, 20 Jul 2018 23:34:39 +0000 (23:34 +0000)]
[Driver] Sanitizer support based on runtime library presence

The runtime libraries of sanitizers are built in compiler-rt, and Clang
can be built without compiler-rt, or compiler-rt can be configured to
only build certain sanitizers. The driver should provide reasonable
diagnostics and not a link-time error when a runtime library is missing.

This patch changes the driver for OS X to only support sanitizers of
which we can find the runtime libraries. The discussion for this patch
explains the rationale

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

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

6 years ago[HIP] Register/unregister device fat binary only once
Yaxun Liu [Fri, 20 Jul 2018 22:45:24 +0000 (22:45 +0000)]
[HIP] Register/unregister device fat binary only once

HIP generates one fat binary for all devices after linking. However, for each compilation
unit a ctor function is emitted which register the same fat binary. Measures need to be
taken to make sure the fat binary is only registered once.

Currently each ctor function calls __hipRegisterFatBinary and stores the returned value
to __hip_gpubin_handle. This patch changes the linkage of __hip_gpubin_handle to be linkonce
so that they are shared between LLVM modules. Then this patch adds check of value of
__hip_gpubin_handle to make sure __hipRegisterFatBinary is only called once. The code
is equivalent to

void *_gpubin_handle;
void ctor() {
  if (__hip_gpubin_handle == 0) {
    __hip_gpubin_handle = __hipRegisterFatBinary(...);
  }
  // register kernels and variables.
}
The patch also does similar change to dtors so that __hipUnregisterFatBinary
is called once.

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

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

6 years agoDisable clang crash-report-modules.m test on Windows again
Reid Kleckner [Fri, 20 Jul 2018 22:36:33 +0000 (22:36 +0000)]
Disable clang crash-report-modules.m test on Windows again

It still appears to be failing:
http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/12825

$ "rm" "-rf" "C:\b\slave\clang-x86-windows-msvc2015\clang-x86-windows-msvc2015\stage1\tools\clang\test\Driver\Output/crmdir"
Error: 'rm' command failed, [Error 3] The system cannot find the path specified: 'C:\\b\\slave\\clang-x86-windows-msvc2015\\clang-x86-windows-msvc2015\\stage1\\tools\\clang\\test\\Driver\\Output/crmdir\\crash-report-modules-300567.cache\\vfs\\b\\slave\\clang-x86-windows-msvc2015\\clang-x86-windows-msvc2015\\llvm\\tools\\clang\\test\\Driver\\Inputs\\module\\module.modulemap'
error: command failed with exit status: 1

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

6 years agoFold dangling-field warning into general initialization lifetime checks.
Richard Smith [Fri, 20 Jul 2018 22:25:55 +0000 (22:25 +0000)]
Fold dangling-field warning into general initialization lifetime checks.

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

6 years agofix typo
Nico Weber [Fri, 20 Jul 2018 21:06:41 +0000 (21:06 +0000)]
fix typo

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

6 years ago[ms] Add __shiftleft128 / __shiftright128 intrinsics
Nico Weber [Fri, 20 Jul 2018 21:02:09 +0000 (21:02 +0000)]
[ms] Add __shiftleft128 / __shiftright128 intrinsics

Carefully match the pattern matched by ISel so that this produces shld / shrd
(unless Subtarget->isSHLDSlow() is true).

Thanks to Craig Topper for providing the LLVM IR pattern that gets successfully
matched.

Fixes PR37755.

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

6 years ago[codeview] Don't emit variable templates as class members
Reid Kleckner [Fri, 20 Jul 2018 20:55:00 +0000 (20:55 +0000)]
[codeview] Don't emit variable templates as class members

MSVC doesn't, so neither should we.

Fixes PR38004, which is a crash that happens when we try to emit debug
info for a still-dependent partial variable template specialization.

As a follow-up, we should review what we're doing for function and class
member templates. It looks like we don't filter those out, but I can't
seem to get clang to emit any.

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

6 years agoAMDGPU: Switch default dwarf version to 2
Konstantin Zhuravlyov [Fri, 20 Jul 2018 20:46:25 +0000 (20:46 +0000)]
AMDGPU: Switch default dwarf version to 2

There were some problems unearthed with version 5,
which I am going to look at.

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

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

6 years ago[CStringSyntaxChecker] Fix build bot builds != x86 archs
David Carlier [Fri, 20 Jul 2018 20:39:49 +0000 (20:39 +0000)]
[CStringSyntaxChecker] Fix build bot builds != x86 archs

Reviewers: NoQ,george.karpenkov

Reviewed By: NoQ

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

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

6 years ago[AST] Various micro-optimizations in CXXInheritance
Benjamin Kramer [Fri, 20 Jul 2018 20:13:08 +0000 (20:13 +0000)]
[AST] Various micro-optimizations in CXXInheritance

1. Pack std::pair<bool, unsigned> in CXXBasePaths::ClassSubobjects.
2. Use a SmallPtrSet instead of a SmallDenseSet for CXXBasePaths::VisitedDependentRecords.
3. Reorder some members of CXXBasePaths to save 8 bytes.
4. Use a SmallSetVector instead of a SetVector in CXXBasePaths::ComputeDeclsFound to avoid some allocations.

This speeds up an -fsyntax-only on all of Boost by approx 0.15%,
mainly by speeding up CXXBasePaths::lookupInBases by
approx 10%. No functional changes.

Patch by Bruno Ricci!

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

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

6 years ago[CUDA] Provide integer SIMD functions for CUDA-9.2
Artem Belevich [Fri, 20 Jul 2018 17:44:34 +0000 (17:44 +0000)]
[CUDA] Provide integer SIMD functions for CUDA-9.2

CUDA-9.2 made all integer SIMD functions into compiler builtins,
so clang no longer has access to the implementation of these
functions in either headers of libdevice and has to provide
its own implementation.

This is mostly a 1:1 mapping to a corresponding PTX instructions
with an exception of vhadd2/vhadd4 that don't have an equivalent
instruction and had to be implemented with a bit hack.

Performance of this implementation will be suboptimal for SM_50
and newer GPUs where PTXAS generates noticeably worse code for
the SIMD instructions compared to the code it generates
for the inline assembly generated by nvcc (or used to come
with CUDA headers).

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

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

6 years agoPrevent Scoped Enums from being Integral constant expressions:
Erich Keane [Fri, 20 Jul 2018 17:42:09 +0000 (17:42 +0000)]
Prevent Scoped Enums from being Integral constant expressions:

Discovered because of: https://bugs.llvm.org/show_bug.cgi?id=38235

It seems to me that a scoped enum should NOT be an integral constant expression
without a cast, so this seems like a sensical change.

Attributes that check for an integer parameter simply use this function to
ensure that they have an integer, so it was previously allowing a scoped enum.

Also added a test based on Richard's feedback to ensure that case labels still work.

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

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

6 years ago[CodeGen][ObjC] Make copying and disposing of a non-escaping block
Akira Hatanaka [Fri, 20 Jul 2018 17:10:32 +0000 (17:10 +0000)]
[CodeGen][ObjC] Make copying and disposing of a non-escaping block
no-ops.

A non-escaping block on the stack will never be called after its
lifetime ends, so it doesn't have to be copied to the heap. To prevent
a non-escaping block from being copied to the heap, this patch sets
field 'isa' of the block object to NSConcreteGlobalBlock and sets the
BLOCK_IS_GLOBAL bit of field 'flags', which causes the runtime to treat
the block as if it were a global block (calling _Block_copy on the block
just returns the original block and calling _Block_release is a no-op).

Also, a new flag bit 'BLOCK_IS_NOESCAPE' is added, which allows the
runtime or tools to distinguish between true global blocks and
non-escaping blocks.

rdar://problem/39352313

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

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

6 years agoRewrite the VS integration scripts.
Zachary Turner [Fri, 20 Jul 2018 16:30:02 +0000 (16:30 +0000)]
Rewrite the VS integration scripts.

This is a new modernized VS integration installer.  It adds a
Visual Studio .sln file which, when built, outputs a VSIX that can
be used to install ourselves as a "real" Visual Studio Extension.
We can even upload this extension to the visual studio marketplace.

This fixes a longstanding problem where we didn't support installing
into VS 2017 and higher.  In addition to supporting VS 2017, due
to the way this is written we now longer need to do anything special
to support future versions of VS as well.  Everything should
"just work".  This also fixes several bugs with our old integration,
such as MSBuild triggering full rebuilds when /Zi was used.

Finally, we add a new UI page called "LLVM" which becomes visible
when the LLVM toolchain is selected.  For now this only contains
one option which is the path to clang-cl.exe, but in the future
we can add more things here.

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

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

6 years ago[analyzer] Rename DanglingInternalBufferChecker to InnerPointerChecker.
Reka Kovacs [Fri, 20 Jul 2018 15:14:49 +0000 (15:14 +0000)]
[analyzer] Rename DanglingInternalBufferChecker to InnerPointerChecker.

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

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

6 years ago[www] Add CodeCompass and CodeChecker to Clang Related Projects page
Bruno Cardoso Lopes [Fri, 20 Jul 2018 14:46:10 +0000 (14:46 +0000)]
[www] Add CodeCompass and CodeChecker to Clang Related Projects page

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

6 years agoImplement cpu_dispatch/cpu_specific Multiversioning
Erich Keane [Fri, 20 Jul 2018 14:13:28 +0000 (14:13 +0000)]
Implement cpu_dispatch/cpu_specific Multiversioning

As documented here: https://software.intel.com/en-us/node/682969 and
https://software.intel.com/en-us/node/523346. cpu_dispatch multiversioning
is an ICC feature that provides for function multiversioning.

This feature is implemented with two attributes: First, cpu_specific,
which specifies the individual function versions. Second, cpu_dispatch,
which specifies the location of the resolver function and the list of
resolvable functions.

This is valuable since it provides a mechanism where the resolver's TU
can be specified in one location, and the individual implementions
each in their own translation units.

The goal of this patch is to be source-compatible with ICC, so this
implementation diverges from the ICC implementation in a few ways:
1- Linux x86/64 only: This implementation uses ifuncs in order to
properly dispatch functions. This is is a valuable performance benefit
over the ICC implementation. A future patch will be provided to enable
this feature on Windows, but it will obviously more closely fit ICC's
implementation.
2- CPU Identification functions: ICC uses a set of custom functions to identify
the feature list of the host processor. This patch uses the cpu_supports
functionality in order to better align with 'target' multiversioning.
1- cpu_dispatch function def/decl: ICC's cpu_dispatch requires that the function
marked cpu_dispatch be an empty definition. This patch supports that as well,
however declarations are also permitted, since the linker will solve the
issue of multiple emissions.

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

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

6 years agoSema: Fix explicit address space cast in C++
Yaxun Liu [Fri, 20 Jul 2018 11:32:51 +0000 (11:32 +0000)]
Sema: Fix explicit address space cast in C++

Currently clang does not allow implicit cast of a pointer to a pointer type
in different address space but allows C-style cast of a pointer to a pointer
type in different address space. However, there is a bug in Sema causing
incorrect Cast Expr in AST for the latter case, which in turn results in
invalid LLVM IR in codegen.

This is because Sema::IsQualificationConversion returns true for a cast of
pointer to a pointer type in different address space, which in turn allows
a standard conversion and results in a cast expression with no op in AST.

This patch fixes that by let Sema::IsQualificationConversion returns false
for a cast of pointer to a pointer type in different address space, which
in turn disallows standard conversion, implicit cast, and static cast.
Finally it results in an reinterpret cast and correct conversion kind is set.

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

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

6 years agoChange \t to spaces
Fangrui Song [Fri, 20 Jul 2018 08:19:20 +0000 (08:19 +0000)]
Change \t to spaces

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

6 years ago[Index] Set OrigD before D is changed.
Eric Liu [Fri, 20 Jul 2018 08:08:56 +0000 (08:08 +0000)]
[Index] Set OrigD before D is changed.

Reviewers: akyrtzi, arphaman

Reviewed By: akyrtzi

Subscribers: cfe-commits

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

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

6 years agoDocument -fobjc-weak as an extension.
John McCall [Fri, 20 Jul 2018 05:40:12 +0000 (05:40 +0000)]
Document -fobjc-weak as an extension.

Fixes rdar://24091053.

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

6 years agoFix and improve the ARC spec's wording about unmanaged objects.
John McCall [Fri, 20 Jul 2018 05:40:09 +0000 (05:40 +0000)]
Fix and improve the ARC spec's wording about unmanaged objects.

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

6 years agoFix typo causing assert in self-host.
Richard Smith [Thu, 19 Jul 2018 23:24:41 +0000 (23:24 +0000)]
Fix typo causing assert in self-host.

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

6 years ago[docs] Correct -fvisibility-inlines-hidden description
Fangrui Song [Thu, 19 Jul 2018 22:45:41 +0000 (22:45 +0000)]
[docs] Correct -fvisibility-inlines-hidden description

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

6 years ago[CStringSyntaxChecker] Check strlcpy sizeof syntax
David Carlier [Thu, 19 Jul 2018 21:50:03 +0000 (21:50 +0000)]
[CStringSyntaxChecker] Check strlcpy sizeof syntax

The last argument is expected to be the destination buffer size (or less).

    Detects if it points to destination buffer size directly or via a variable.
    Detects if it is an integral, try to detect if the destination buffer can receive the source length.

Updating bsd-string.c unit tests as it make it fails now.

Reviewers: george.karpenpov, NoQ

Reviewed By: george.karpenkov

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

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

6 years agoWhen we choose to use zeroinitializer for a trailing portion of an array
Richard Smith [Thu, 19 Jul 2018 21:38:56 +0000 (21:38 +0000)]
When we choose to use zeroinitializer for a trailing portion of an array
constant, don't convert the rest into a packed struct.

If an array constant has a large non-zero portion and a large zero
portion, we want to emit the first part as an array and the rest as a
zeroinitializer if possible. This fixes a memory usage regression from
r333141 when compiling PHP.

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

6 years ago[Sema] Diagnose an invalid dependent function template specialization
Erik Pilkington [Thu, 19 Jul 2018 20:40:20 +0000 (20:40 +0000)]
[Sema] Diagnose an invalid dependent function template specialization

Previously, clang marked the specialization as invalid without emitting a
diagnostic. This lead to an assert in CodeGen.

rdar://41806724

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

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

6 years agoFix failing testcase to actually be valid.
Richard Smith [Thu, 19 Jul 2018 19:05:13 +0000 (19:05 +0000)]
Fix failing testcase to actually be valid.

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

6 years agoFix template argument deduction when a parameter pack has a value
Richard Smith [Thu, 19 Jul 2018 19:00:37 +0000 (19:00 +0000)]
Fix template argument deduction when a parameter pack has a value
provided by an outer template.

We made the incorrect assumption in various places that the only way we
can have any arguments already provided for a pack during template
argument deduction was from a partially-specified pack. That's not true;
we can also have arguments from an enclosing already-instantiated
template, and that can even result in the function template's own pack
parameters having a fixed length and not being packs for the purposes of
template argument deduction.

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

6 years agofix typo in comment
Nico Weber [Thu, 19 Jul 2018 18:59:38 +0000 (18:59 +0000)]
fix typo in comment

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

6 years ago[analyzer] Fix memory sanitizer error in MallocChecker.
Reka Kovacs [Thu, 19 Jul 2018 17:43:09 +0000 (17:43 +0000)]
[analyzer] Fix memory sanitizer error in MallocChecker.

StringRef's data() returns a string that may be non-null-terminated.
Switch to using StringRefs from const char pointers in visitor notes
to avoid problems.

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

6 years agoFix unused variable warning.
Erich Keane [Thu, 19 Jul 2018 17:19:16 +0000 (17:19 +0000)]
Fix unused variable warning.

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

6 years ago[analyzer] Memoize complexity of SymExpr
Mikhail R. Gadelha [Thu, 19 Jul 2018 17:03:12 +0000 (17:03 +0000)]
[analyzer] Memoize complexity of SymExpr

Summary:
This patch introduces a new member to SymExpr, which stores the symbol complexity, avoiding recalculating it every time computeComplexity() is called.

Also, increase the complexity of conjured Symbols by one, so it's clear that it has a greater complexity than its underlying symbols.

Reviewers: NoQ, george.karpenkov

Reviewed By: NoQ, george.karpenkov

Subscribers: xazax.hun, szepet, a.sidorin

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

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

6 years ago[Sema] Add a new warning, -Wmemset-transposed-args
Erik Pilkington [Thu, 19 Jul 2018 16:46:15 +0000 (16:46 +0000)]
[Sema] Add a new warning, -Wmemset-transposed-args

This diagnoses calls to memset that have the second and third arguments
transposed, for example:

  memset(buf, sizeof(buf), 0);

This is done by checking if the third argument is a literal 0, or if the second
is a sizeof expression (and the third isn't). The first check is also done for
calls to bzero.

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

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

6 years agoThe patch adds support for the new map interface between clang and libomptarget....
Alexey Bataev [Thu, 19 Jul 2018 16:34:13 +0000 (16:34 +0000)]
The patch adds support for the new map interface between clang and libomptarget. The changes in the interface are the following:

device IDs are now 64-bit integers (as opposed to 32-bit)
map flags are 64-bit long (used to be 32-bit)
mappings for partially mapped structs are now calculated at compile time and members of partially mapped structs are flagged using the MEMBER_OF field
Support for is_device_ptr on struct members was dropped - this functionality is not supported by the OpenMP standard and its implementation is technically infeasible (however, use_device_ptr on struct members works as a non-standard extension of the compiler)

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