]> granicus.if.org Git - clang/log
clang
5 years ago[OPENMP][NVPTX]Use new functions from the runtime library.
Alexey Bataev [Fri, 4 Jan 2019 17:25:09 +0000 (17:25 +0000)]
[OPENMP][NVPTX]Use new functions from the runtime library.

Updated codegen to use the new functions from the runtime library.

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

5 years agoAdd two new pragmas for controlling software pipelining optimizations.
Aaron Ballman [Fri, 4 Jan 2019 17:20:00 +0000 (17:20 +0000)]
Add two new pragmas for controlling software pipelining optimizations.

This patch adds #pragma clang loop pipeline and #pragma clang loop pipeline_initiation_interval for debugging or reducing compile time purposes. It is possible to disable SWP for concrete loops to save compilation time or to find bugs by not doing SWP to certain loops. It is possible to set value of initiation interval to concrete number to save compilation time by not doing extra pipeliner passes or to check created schedule for specific initiation interval.

Patch by Alexey Lapshin.

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

5 years agoRefactor the way we handle diagnosing unused expression results.
Aaron Ballman [Fri, 4 Jan 2019 16:58:14 +0000 (16:58 +0000)]
Refactor the way we handle diagnosing unused expression results.

Rather than sprinkle calls to DiagnoseUnusedExprResult() around in places where we want diagnostics, we now diagnose unused expression statements and full expressions in a more generic way when acting on the final expression statement. This results in more appropriate diagnostics for [[nodiscard]] where we were previously lacking them, such as when the body of a for loop is not a compound statement.

This patch fixes PR39837.

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

5 years agoPrevent unreachable when checking invalid multiversion decls.
Erich Keane [Fri, 4 Jan 2019 15:24:06 +0000 (15:24 +0000)]
Prevent unreachable when checking invalid multiversion decls.

CPUSpecifc/CPUDispatch call resolution assumed that all declarations
that would be passed are valid, however this was an invalid assumption.
This patch deals with those situations by making the valid version take
priority.  Note that the checked ordering is arbitrary, since both are
replaced by calls to the resolver later.

Change-Id: I7ff2ec88c55a721d51bc1f39ea1a1fe242b4e45f

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

5 years ago[Basic] Extend DiagnosticEngine to store and format Qualifiers.
Anastasia Stulova [Fri, 4 Jan 2019 11:50:36 +0000 (11:50 +0000)]
[Basic] Extend DiagnosticEngine to store and format Qualifiers.

Qualifiers can now be streamed into the DiagnosticEngine using
regular << operator. If Qualifiers are empty 'unqualified' will
be printed in the diagnostic otherwise regular qual syntax is
used.

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

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

5 years agoAdopt SwiftABIInfo for WebAssembly.
Daniel Dunbar [Thu, 3 Jan 2019 23:24:50 +0000 (23:24 +0000)]
Adopt SwiftABIInfo for WebAssembly.

Summary:
 - This adopts SwiftABIInfo as the base class for WebAssemblyABIInfo, which is in keeping with what is done for other targets for which Swift is supported.

 - This is a minimal patch to unblock exploration of WASM support for Swift (https://bugs.swift.org/browse/SR-9307)

Reviewers: rjmccall, sunfish

Reviewed By: rjmccall

Subscribers: ahti, dschuff, sbc100, jgravelle-google, aheejin, cfe-commits

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

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

5 years agoFix MSVC visualizations for ActionResult and OpaquePtr
Mike Spertus [Thu, 3 Jan 2019 23:24:39 +0000 (23:24 +0000)]
Fix MSVC visualizations for ActionResult and OpaquePtr

Mainly just fixing buggy code. Also removed unnecessary visualizers
for specializations of OpaquePtr

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

5 years agoFix check-hwasan with LLVM_BUILD_EXTERNAL_COMPILER_RT=ON
Evgeniy Stepanov [Thu, 3 Jan 2019 22:50:45 +0000 (22:50 +0000)]
Fix check-hwasan with LLVM_BUILD_EXTERNAL_COMPILER_RT=ON

Add a forwarding target for check-hwasan in clang.

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

5 years ago[cmake] Fix monorepo + LLVM_BUILD_EXTERNAL_COMPILER_RT=ON.
Evgeniy Stepanov [Thu, 3 Jan 2019 22:41:10 +0000 (22:41 +0000)]
[cmake] Fix monorepo + LLVM_BUILD_EXTERNAL_COMPILER_RT=ON.

In cmake 3.10.2, if (${VARIABLE_NAME}) seems to always be false no
matter what documentation says (or maybe I just failed at reading).

Anyway, if (VARIABLE_NAME) seems to do what this code intended.

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

5 years agoValidate -add-plugin arguments.
Nico Weber [Thu, 3 Jan 2019 18:26:06 +0000 (18:26 +0000)]
Validate -add-plugin arguments.

-plugin already prints an error if the name of an unknown plugin is passed.
-add-plugin used to silently ignore that, now it errors too.

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

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

5 years agoMake -Wstring-plus-int warns even if when the result is not out of bounds
Arnaud Bienner [Thu, 3 Jan 2019 17:45:28 +0000 (17:45 +0000)]
Make -Wstring-plus-int warns even if when the result is not out of bounds

Summary: Patch by Arnaud Bienner

Reviewers: sylvestre.ledru, thakis, serge-sans-paille

Reviewed By: thakis

Subscribers: arphaman, dyung, anemet, llvm-commits, cfe-commits

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

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

5 years ago[OPENMP][NVPTX]Use __kmpc_barrier_simple_spmd(nullptr, 0) instead of
Alexey Bataev [Thu, 3 Jan 2019 16:25:35 +0000 (16:25 +0000)]
[OPENMP][NVPTX]Use __kmpc_barrier_simple_spmd(nullptr, 0) instead of
nvvm_barrier0.

Use runtime functions instead of the direct call to the nvvm intrinsics.
It allows to prevent some dangerous LLVM optimizations, that breaks the
code for the NVPTX target.

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

5 years agoPortable Python script across Python version
Serge Guelton [Thu, 3 Jan 2019 14:27:05 +0000 (14:27 +0000)]
Portable Python script across Python version

Get rid of Python version specific shebang.

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

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

5 years agoPortable Python script across Python version
Serge Guelton [Thu, 3 Jan 2019 14:26:56 +0000 (14:26 +0000)]
Portable Python script across Python version

StringIO is obsoleted in Python3, replaced by io.BytesIO or io.StringIO depending on the use.

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

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

5 years agoDiagnose an unused result from a call through a function pointer whose return type...
Aaron Ballman [Thu, 3 Jan 2019 14:24:31 +0000 (14:24 +0000)]
Diagnose an unused result from a call through a function pointer whose return type is marked [[nodiscard]].

When a function returns a type and that type was declared [[nodiscard]], we diagnose any unused results from that call as though the function were marked nodiscard. The same behavior should apply to calls through a function pointer.

This addresses PR31526.

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

5 years ago[NewPM] Port Msan
Philip Pfaffe [Thu, 3 Jan 2019 13:42:44 +0000 (13:42 +0000)]
[NewPM] Port Msan

Summary:
Keeping msan a function pass requires replacing the module level initialization:
That means, don't define a ctor function which calls __msan_init, instead just
declare the init function at the first access, and add that to the global ctors
list.

Changes:
- Pull the actual sanitizer and the wrapper pass apart.
- Add a newpm msan pass. The function pass inserts calls to runtime
  library functions, for which it inserts declarations as necessary.
- Update tests.

Caveats:
- There is one test that I dropped, because it specifically tested the
  definition of the ctor.

Reviewers: chandlerc, fedor.sergeev, leonardchan, vitalybuka

Subscribers: sdardis, nemanjai, javed.absar, hiraditya, kbarton, bollu, atanasyan, jsji

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

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

5 years agoFix incorrect column numbers in test from r350282.
Alex Lorenz [Thu, 3 Jan 2019 01:30:50 +0000 (01:30 +0000)]
Fix incorrect column numbers in test from r350282.

After the test was reformatted using clang-format the numbers became invalid.

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

5 years ago[libclang] CoroutineBody/Coreturn statements are UnexposedStmts and not Exprs
Alex Lorenz [Thu, 3 Jan 2019 01:13:33 +0000 (01:13 +0000)]
[libclang] CoroutineBody/Coreturn statements are UnexposedStmts and not Exprs

This change ensures that the libclang CXCursor represents the CoroutineBody
and the Coreturn statement using the appropriate CXCursor_UnexposedStmt kind
instead of CXCursor_UnexposedExpr. The problem with CXCursor_UnexposedExpr is
that the consumer functions assumed that CoroutineBody/Coreturn statements
were valid expressions and performed an invalid downcast to Expr causing
assertion failures or other crashes.

rdar://40204290

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

5 years agoMake test/Driver/darwin-sdk-version.c pass if the host triple is 32-bit
Nico Weber [Thu, 3 Jan 2019 00:17:02 +0000 (00:17 +0000)]
Make test/Driver/darwin-sdk-version.c pass if the host triple is 32-bit

For some reason, the cmake build on my macbook has
LLVM_HOST_TRIPLE:STRING=i386-apple-darwin16.7.0 .
test/Driver/darwin-sdk-version.c assumed that the host triple is 64-bit, so
make it resilient against 32-bit host triples.

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

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

5 years ago[OpenMP] Added support for explicit mapping of classes using 'this' pointer. Differen...
Patrick Lyster [Wed, 2 Jan 2019 19:28:48 +0000 (19:28 +0000)]
[OpenMP] Added support for explicit mapping of classes using 'this' pointer. Differential revision: https://reviews.llvm.org/D55982

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

5 years agoOnly convert objc messages to alloc to objc_alloc if the receiver is a class.
Pete Cooper [Wed, 2 Jan 2019 17:25:30 +0000 (17:25 +0000)]
Only convert objc messages to alloc to objc_alloc if the receiver is a class.

r348687 converted [Foo alloc] to objc_alloc(Foo).  However the objc runtime method only takes a Class, not an arbitrary pointer.

This makes sure we are messaging a class before we convert these messages.

rdar://problem/46943703

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

5 years ago[CMake][Fuchsia] Include check-lld in the list of bootstrap targets
Petr Hosek [Wed, 2 Jan 2019 05:11:57 +0000 (05:11 +0000)]
[CMake][Fuchsia] Include check-lld in the list of bootstrap targets

This allows running lld tests when doing 2-stage toolchain build.

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

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

5 years agoFix some typos in the clang doc.
Sylvestre Ledru [Tue, 1 Jan 2019 12:51:14 +0000 (12:51 +0000)]
Fix some typos in the clang doc.
Fixed with:
$ codespell -w ClangFormatStyleOptions.rst Toolchain.rst LanguageExtensions.rst ClangCommandLineReference.rst

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

5 years agoclang-format-diff: add an example with hg
Sylvestre Ledru [Tue, 1 Jan 2019 12:32:08 +0000 (12:32 +0000)]
clang-format-diff: add an example with hg

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

5 years agoMake clearer which clang::type subclasses have visualizers
Mike Spertus [Mon, 31 Dec 2018 23:01:34 +0000 (23:01 +0000)]
Make clearer which clang::type subclasses have visualizers

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

5 years agoDeclAccessPair visualizer should be expandable
Mike Spertus [Sun, 30 Dec 2018 20:22:37 +0000 (20:22 +0000)]
DeclAccessPair visualizer should be expandable

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

5 years ago[CodeGen] Replace '@' characters in block descriptors' symbol names with
Akira Hatanaka [Sat, 29 Dec 2018 17:28:30 +0000 (17:28 +0000)]
[CodeGen] Replace '@' characters in block descriptors' symbol names with
'\1'.

'@' can't be used in block descriptors' symbol names since it is
reserved on ELF platforms as a separator between symbol names and symbol
versions.

See the discussion here: https://reviews.llvm.org/D50783.

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

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

5 years agoAdd vtable anchor to classes.
Richard Trieu [Sat, 29 Dec 2018 02:02:30 +0000 (02:02 +0000)]
Add vtable anchor to classes.

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

5 years ago[objc-gnustep2] Fix a bug in category generation.
David Chisnall [Fri, 28 Dec 2018 17:44:54 +0000 (17:44 +0000)]
[objc-gnustep2] Fix a bug in category generation.

We were not emitting a protocol definition while generating the category
method list.  This was fine in most cases, because something else in the
library typically referenced any given protocol, but it caused linker
failures if the category was the only reference to a given protocol.

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

5 years ago[OPENMP]Fix processing of the clauses on target combined directives.
Alexey Bataev [Fri, 28 Dec 2018 17:27:32 +0000 (17:27 +0000)]
[OPENMP]Fix processing of the clauses on target combined directives.

For constants with the predefined data-sharing clauses we may had
troubles with the target combined directives. It may cause compiler
crash in some corner cases.

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

5 years ago[objc-gnustep] Fix a copy-and-paste error.
David Chisnall [Thu, 27 Dec 2018 14:44:36 +0000 (14:44 +0000)]
[objc-gnustep] Fix a copy-and-paste error.

We were emitting the null class symbol in the wrong section, which meant
that programs that contained no Objective-C classes would fail to link.

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

5 years ago[clang-cl] Treat inputs as C++ with /E, like MSVC
Reid Kleckner [Wed, 26 Dec 2018 21:04:08 +0000 (21:04 +0000)]
[clang-cl] Treat inputs as C++ with /E, like MSVC

midl invokes the compiler on .idl files with /E. Before this change, we
would treat unrecognized inputs as object files. Now we pre-process to
stdout as expected. I checked that MSVC defines __cplusplus when invoked
this way, so treating the input as C++ seems like the right thing to do.

After this change, I was able to run midl like this with clang-cl:
$ midl -cpp_cmd clang-cl.exe foo.idl

Things worked for the example IDL file in the Microsoft documentation,
but beyond that, I don't know if this will work well.

Fixes PR40140

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

5 years ago[MS] Mangle return adjusting thunks with the public access specifier
Reid Kleckner [Wed, 26 Dec 2018 20:07:52 +0000 (20:07 +0000)]
[MS] Mangle return adjusting thunks with the public access specifier

MSVC does this, so we should too.

Fixes PR40138

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

5 years agoIgnore ConstantExpr in IgnoreParens
Reid Kleckner [Wed, 26 Dec 2018 17:44:40 +0000 (17:44 +0000)]
Ignore ConstantExpr in IgnoreParens

Summary:
This moves it up from IgnoreParenImpCasts to IgnoreParens, so that more
helpers ignore it. For most clients, this ensures that these helpers
behave the same with and without C++17 enabled, which is what appears to
introduce these new expression nodes.

Fixes PR39881

Reviewers: void, rsmith

Subscribers: cfe-commits

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

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

5 years agoPass a concrete triple for two OpenMP tests that depend on TLS
Nico Weber [Wed, 26 Dec 2018 16:06:26 +0000 (16:06 +0000)]
Pass a concrete triple for two OpenMP tests that depend on TLS

Not all %itanium_abi_triple values support TLS. Makes
OpenMP/declare_reduction_codegen.cpp, OpenMP/parallel_copyin_codegen.cpp for
%itanium_abi_triples without TLS support.

Alternatively we could pass -fnoopenmp-use-tls and tweak some of the CHECK
lines, but this seems a bit simpler.

Fixes PR40156.

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

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

5 years ago[analyzer] [NFC] Clean up the mess of constructing argument effects in RetainCountChecker
George Karpenkov [Mon, 24 Dec 2018 18:45:18 +0000 (18:45 +0000)]
[analyzer] [NFC] Clean up the mess of constructing argument effects in RetainCountChecker

Previously, argument effects were stored in a method variable, which was
effectively global.
The global state was reset at each (hopefully) entrance point to the
summary construction,
and every function could modify it.

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

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

5 years ago[Driver] Disable -faddrsig on Gentoo by default
Michal Gorny [Sun, 23 Dec 2018 15:07:26 +0000 (15:07 +0000)]
[Driver] Disable -faddrsig on Gentoo by default

Gentoo supports combining clang toolchain with GNU binutils, and many
users actually do that.  As -faddrsig is not supported by GNU strip,
this results in a lot of warnings.  Disable it by default and let users
enable it explicitly if they want it; with the intent of reevaluating
when the underlying feature becomes standarized.

See also: https://bugs.gentoo.org/667854

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

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

5 years ago[Distro] Support detecting Gentoo
Michal Gorny [Sun, 23 Dec 2018 15:07:19 +0000 (15:07 +0000)]
[Distro] Support detecting Gentoo

Add support for distinguishing plain Gentoo distribution, and a unit
test for it.  This is going to be used to introduce distro-specific
customizations in the driver code; most notably, it is going to be used
to disable -faddrsig.

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

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

5 years agoImproving this fatal diagnostic to help checker developers figure out what's actually...
Aaron Ballman [Sat, 22 Dec 2018 15:31:57 +0000 (15:31 +0000)]
Improving this fatal diagnostic to help checker developers figure out what's actually gone wrong when they hit it.

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

5 years ago[AST] Store the arguments of CXXConstructExpr in a trailing array
Bruno Ricci [Sat, 22 Dec 2018 14:39:30 +0000 (14:39 +0000)]
[AST] Store the arguments of CXXConstructExpr in a trailing array

Store the arguments of CXXConstructExpr in a trailing array. This is very
similar to the CallExpr case in D55771, with the exception that there is
only one derived class (CXXTemporaryObjectExpr) and that we compute the
offset to the trailing array instead of storing it.

This saves one pointer per CXXConstructExpr and CXXTemporaryObjectExpr.

Reviewed By: rjmccall

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

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

5 years ago[analyzer] pr38668: Do not attempt to cast loaded integers to floats.
Artem Dergachev [Sat, 22 Dec 2018 02:06:51 +0000 (02:06 +0000)]
[analyzer] pr38668: Do not attempt to cast loaded integers to floats.

This patch is a different approach to landing the reverted r349701.

It is expected to have the same object (memory region) treated as if it has
different types in different program points. The correct behavior for
RegionStore when an object is stored as an object of type T1 but loaded as
an object of type T2 is to store the object as if it has type T1 but cast it
to T2 during load.

Note that the cast here is some sort of a "reinterpret_cast" (even in C). For
instance, if you store an integer and load a float, you won't get your integer
represented as a float; instead, you will get garbage.

Admit that we cannot perform the cast and return an unknown value.

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

rdar://problem/45062567

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

5 years ago[CUDA] Treat extern global variable shadows same as regular extern vars.
Artem Belevich [Sat, 22 Dec 2018 01:11:09 +0000 (01:11 +0000)]
[CUDA] Treat extern global variable shadows same as regular extern vars.

This fixes compiler crash when we attempted to compile this code:

extern __device__ int data;
__device__ int data = 1;

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

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

5 years agoSwitch from static_cast<> to cast<>, update identifier for coding conventions; NFC.
Aaron Ballman [Fri, 21 Dec 2018 21:11:36 +0000 (21:11 +0000)]
Switch from static_cast<> to cast<>, update identifier for coding conventions; NFC.

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

5 years agoConvert some ObjC retain/release msgSends to runtime calls.
Pete Cooper [Fri, 21 Dec 2018 21:00:32 +0000 (21:00 +0000)]
Convert some ObjC retain/release msgSends to runtime calls.

It is faster to directly call the ObjC runtime for methods such as retain/release instead of sending a message to those functions.

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

Reviewed By: rjmccall

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

5 years ago[Sema][NFC] Fix a Wimplicit-fallthrough warning in CheckSpecializationInstantiationRedecl
Bruno Ricci [Fri, 21 Dec 2018 20:38:06 +0000 (20:38 +0000)]
[Sema][NFC] Fix a Wimplicit-fallthrough warning in CheckSpecializationInstantiationRedecl

All cases are covered so add an llvm_unreachable. NFC.

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

5 years ago[AST][NFC] Remove stale comment in CXXRecordDecl::is(Virtually)DerivedFrom.
Bruno Ricci [Fri, 21 Dec 2018 20:23:07 +0000 (20:23 +0000)]
[AST][NFC] Remove stale comment in CXXRecordDecl::is(Virtually)DerivedFrom.

The "this" capture was removed in r291939.

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

5 years ago[analyzer] Tests quickfix.
George Karpenkov [Fri, 21 Dec 2018 19:40:44 +0000 (19:40 +0000)]
[analyzer] Tests quickfix.

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

5 years agoRemove stat cache chaining as it's no longer needed after PTH support has been
Alex Lorenz [Fri, 21 Dec 2018 19:33:09 +0000 (19:33 +0000)]
Remove stat cache chaining as it's no longer needed after PTH support has been
removed

Stat cache chaining was implemented for a StatListener in the PTH writer so that
it could write out the stat information to PTH. r348266 removed support for PTH,
and it doesn't seem like there are other uses of stat cache chaining. We can
remove the chaining support.

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

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

5 years agoSwitch from cast<> to dyn_cast<>.
Aaron Ballman [Fri, 21 Dec 2018 19:16:38 +0000 (19:16 +0000)]
Switch from cast<> to dyn_cast<>.

This avoids a potential failed assertion that is happening on someone's out-of-tree build.

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

5 years agoRevert "Revert rL349876 from cfe/trunk: [analyzer] Perform escaping in RetainCountChe...
George Karpenkov [Fri, 21 Dec 2018 19:13:40 +0000 (19:13 +0000)]
Revert "Revert rL349876 from cfe/trunk: [analyzer] Perform escaping in RetainCountChecker on type mismatch even for inlined functions"

This reverts commit b44b33f6e020a2c369da2b0c1d53cd52975f2526.

Revert the revert with the fix.

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

5 years ago[analyzer] Correct the summary violation diagnostics for the retain count checker
George Karpenkov [Fri, 21 Dec 2018 19:13:28 +0000 (19:13 +0000)]
[analyzer] Correct the summary violation diagnostics for the retain count checker

It should be in the past tense.

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

5 years ago[AST][NFC] Fix Wsign-compare warning introduced in CXXOperatorCallExpr
Bruno Ricci [Fri, 21 Dec 2018 17:54:51 +0000 (17:54 +0000)]
[AST][NFC] Fix Wsign-compare warning introduced in CXXOperatorCallExpr

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

5 years ago[Sema][NFC] Fix Wimplicit-fallthrough warning in getCursorKindForDecl
Bruno Ricci [Fri, 21 Dec 2018 17:52:13 +0000 (17:52 +0000)]
[Sema][NFC] Fix Wimplicit-fallthrough warning in getCursorKindForDecl

All cases are covered so add an llvm_unreachable. NFC.

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

5 years ago[AST][NFC] Pack CXXOperatorCallExpr
Bruno Ricci [Fri, 21 Dec 2018 16:51:57 +0000 (16:51 +0000)]
[AST][NFC] Pack CXXOperatorCallExpr

Use the space available in the bit-fields of Stmt.
This saves 8 bytes per CXXOperatorCallExpr. NFC.

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

5 years ago[AST] Store the callee and argument expressions of CallExpr in a trailing array.
Bruno Ricci [Fri, 21 Dec 2018 15:20:32 +0000 (15:20 +0000)]
[AST] Store the callee and argument expressions of CallExpr in a trailing array.

Since CallExpr::setNumArgs has been removed, it is now possible to store the
callee expression and the argument expressions of CallExpr in a trailing array.
This saves one pointer per CallExpr, CXXOperatorCallExpr, CXXMemberCallExpr,
CUDAKernelCallExpr and UserDefinedLiteral.

Given that CallExpr is used as a base of the above classes we cannot use
llvm::TrailingObjects. Instead we store the offset in bytes from the this pointer
to the start of the trailing objects and manually do the casts + arithmetic.

Some notes:

1.) I did not try to fit the number of arguments in the bit-fields of Stmt.
    This leaves some space for future additions and avoid the discussion about
    whether x bits are sufficient to hold the number of arguments.

2.) It would be perfectly possible to recompute the offset to the trailing
    objects before accessing the trailing objects. However the trailing objects
    are frequently accessed and benchmarks show that it is slightly faster to
    just load the offset from the bit-fields. Additionally, because of 1),
    we have plenty of space in the bit-fields of Stmt.

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

Reviewed By: rjmccall

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

5 years ago[Sema][NFC] Remove some unnecessary calls to getASTContext.
Bruno Ricci [Fri, 21 Dec 2018 14:35:24 +0000 (14:35 +0000)]
[Sema][NFC] Remove some unnecessary calls to getASTContext.

The AST context is already easily available. NFC.

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

5 years ago[AST][NFC] Pass the AST context to one of the ctor of DeclRefExpr.
Bruno Ricci [Fri, 21 Dec 2018 14:10:18 +0000 (14:10 +0000)]
[AST][NFC] Pass the AST context to one of the ctor of DeclRefExpr.

All of the other constructors already take a reference to the AST context.
This avoids calling Decl::getASTContext in most cases. Additionally move
the definition of the constructor from Expr.h to Expr.cpp since it is calling
DeclRefExpr::computeDependence. NFC.

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

5 years agoRevert rL349876 from cfe/trunk: [analyzer] Perform escaping in RetainCountChecker...
Simon Pilgrim [Fri, 21 Dec 2018 10:11:23 +0000 (10:11 +0000)]
Revert rL349876 from cfe/trunk: [analyzer] Perform escaping in RetainCountChecker on type mismatch even for inlined functions

The fix done in D55465 did not previously apply when the function was inlined.

rdar://46889541

Differential Revision: https://reviews.llvm.org/D55976
........
Fixes broken buildbot: http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/14764

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

5 years ago[Sema] Produce diagnostics when C++17 aligned allocation/deallocation
Akira Hatanaka [Fri, 21 Dec 2018 07:05:36 +0000 (07:05 +0000)]
[Sema] Produce diagnostics when C++17 aligned allocation/deallocation
functions that are unavailable on Darwin are explicitly called or called
from deleting destructors.

rdar://problem/40736230

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

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

5 years ago[analyzer] Perform escaping in RetainCountChecker on type mismatch even for inlined...
George Karpenkov [Fri, 21 Dec 2018 02:16:36 +0000 (02:16 +0000)]
[analyzer] Perform escaping in RetainCountChecker on type mismatch even for inlined functions

The fix done in D55465 did not previously apply when the function was inlined.

rdar://46889541

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

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

5 years ago[analyzer] Fix a bug in RetainCountDiagnostics while printing a note on mismatched...
George Karpenkov [Fri, 21 Dec 2018 02:16:23 +0000 (02:16 +0000)]
[analyzer] Fix a bug in RetainCountDiagnostics while printing a note on mismatched summary in inlined functions

Previously, we were not printing a note at all if at least one of the parameters was not annotated.

rdar://46888422

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

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

5 years ago[mingw] Don't mangle thiscall like fastcall etc
Reid Kleckner [Fri, 21 Dec 2018 01:40:29 +0000 (01:40 +0000)]
[mingw] Don't mangle thiscall like fastcall etc

GCC does not mangle it when it is not explicit in the source.  The
mangler as currently written cannot differentiate between explicit and
implicit calling conventions, so we can't match GCC. Explicit thiscall
conventions are rare, so mangle as if the convention was implicit to be
as ABI compatible as possible.

Also fixes some tests using %itanium_abi_triple in some configurations
as a side effect.

Fixes PR40107.

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

5 years ago[driver] [analyzer] Fix --analyze -Xanalyzer after r349863.
Artem Dergachev [Fri, 21 Dec 2018 01:11:21 +0000 (01:11 +0000)]
[driver] [analyzer] Fix --analyze -Xanalyzer after r349863.

If an -analyzer-config is passed through -Xanalyzer, it is not found while
looking for -Xclang.

Additionally, don't emit -analyzer-config-compatibility-mode for *every*
-analyzer-config flag we encounter; one is enough.

https://reviews.llvm.org/D55823

rdar://problem/46504165

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

5 years agoRevert "Revert "[driver] [analyzer] Fix a backward compatibility issue after r348038.""
George Karpenkov [Fri, 21 Dec 2018 00:26:19 +0000 (00:26 +0000)]
Revert "Revert "[driver] [analyzer] Fix a backward compatibility issue after r348038.""

This reverts commit 144927939587b790c0536f4ff08245043fc8d733.

Fixes the bug in the original commit.

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

5 years ago[analyzer] RetainCount: Suppress retain detection heuristic on some CM methods.
Artem Dergachev [Fri, 21 Dec 2018 00:18:58 +0000 (00:18 +0000)]
[analyzer] RetainCount: Suppress retain detection heuristic on some CM methods.

If it ends with "Retain" like CFRetain and returns a CFTypeRef like CFRetain,
then it is not necessarily a CFRetain. But it is indeed true that these two
return something retained.

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

rdar://problem/39390714

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

5 years ago[CodeGen] Fix a test from r349848 by replacing `objc_` with `llvm.objc.`
Volodymyr Sapsai [Thu, 20 Dec 2018 23:26:29 +0000 (23:26 +0000)]
[CodeGen] Fix a test from r349848 by replacing `objc_` with `llvm.objc.`

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

5 years ago[CodeGen] Fix assertion on emitting cleanup for object with inlined inherited constru...
Volodymyr Sapsai [Thu, 20 Dec 2018 22:43:26 +0000 (22:43 +0000)]
[CodeGen] Fix assertion on emitting cleanup for object with inlined inherited constructor and non-trivial destructor.

Fixes assertion
> Assertion failed: (isa<X>(Val) && "cast<Ty>() argument of incompatible type!"), function cast, file llvm/Support/Casting.h, line 255.

It was triggered by trying to cast `FunctionDecl` to `CXXMethodDecl` as
`CGF.CurCodeDecl` in `CallBaseDtor::Emit`. It was happening because
cleanups were emitted in `ScalarExprEmitter::VisitExprWithCleanups`
after destroying `InlinedInheritingConstructorScope`, so
`CodeGenFunction.CurCodeDecl` didn't correspond to expected cleanup decl.

Fix the assertion by emitting cleanups before leaving
`InlinedInheritingConstructorScope` and changing `CurCodeDecl`.

Test cases based on a patch by Shoaib Meenai.

Fixes PR36748.

rdar://problem/45805151

Reviewers: rsmith, rjmccall

Reviewed By: rjmccall

Subscribers: jkorous, dexonsmith, cfe-commits, smeenai, compnerd

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

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

5 years agoAdd support for namespaces on #pragma clang attribute
Erik Pilkington [Thu, 20 Dec 2018 22:32:04 +0000 (22:32 +0000)]
Add support for namespaces on #pragma clang attribute

Namespaces are introduced by adding an "identifier." before a
push/pop directive. Pop directives with namespaces can only pop a
attribute group that was pushed with the same namespace. Push and pop
directives that don't opt into namespaces have the same semantics.

This is necessary to prevent a pitfall of using multiple #pragma
clang attribute directives spread out in a large file, particularly
when macros are involved. It isn't easy to see which pop corripsonds
to which push, so its easy to inadvertently pop the wrong group.

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

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

5 years agoRevert "[driver] [analyzer] Fix a backward compatibility issue after r348038."
Artem Dergachev [Thu, 20 Dec 2018 22:29:49 +0000 (22:29 +0000)]
Revert "[driver] [analyzer] Fix a backward compatibility issue after r348038."

This reverts commits r349824, r349828, r349835.

More buildbot failures were noticed.

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

rdar://problem/46504165

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

5 years ago[ObjC] Messages to 'self' in class methods that return 'instancetype' should
Alex Lorenz [Thu, 20 Dec 2018 22:11:11 +0000 (22:11 +0000)]
[ObjC] Messages to 'self' in class methods that return 'instancetype' should
use the pointer to the class as the result type of the message

Prior to this commit, messages to self in class methods were treated as instance
methods to a Class value. When these methods returned instancetype the compiler
only saw id through the instancetype, and not the Interface *. This caused
problems when that return value was a receiver in a message send, as the
compiler couldn't select the right method declaration and had to rely on a
selection from the global method pool.

This commit modifies the semantics of such message sends and uses class messages
that are dispatched to the interface that corresponds to the class that contains
the class method. This ensures that instancetypes are correctly interpreted by
the compiler. This change is safe under ARC (as self can't be reassigned),
however, it also applies to MRR code as we are assuming that the user isn't
doing anything unreasonable.

rdar://20940997

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

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

5 years agocmake: Remove uses of add_llvm_loadable_module macro
Tom Stellard [Thu, 20 Dec 2018 22:04:36 +0000 (22:04 +0000)]
cmake: Remove uses of add_llvm_loadable_module macro

This was removed from llvm in r349839.

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

5 years ago[driver] [analyzer] Fix redundant test output.
Artem Dergachev [Thu, 20 Dec 2018 21:56:49 +0000 (21:56 +0000)]
[driver] [analyzer] Fix redundant test output.

The -c flag causes a .o file to appear every time we run a test.
Remove it.

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

rdar://problem/46504165

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

5 years ago[driver] [analyzer] Fix buildbots after r349824.
Artem Dergachev [Thu, 20 Dec 2018 21:45:33 +0000 (21:45 +0000)]
[driver] [analyzer] Fix buildbots after r349824.

Buildbots can't find the linker, which we don't really need in our tests.

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

rdar://problem/46504165

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

5 years agoDeclares __cpu_model as dso local
Haibo Huang [Thu, 20 Dec 2018 21:33:59 +0000 (21:33 +0000)]
Declares __cpu_model as dso local

__builtin_cpu_supports and __builtin_cpu_is use information in __cpu_model to decide cpu features. Before this change, __cpu_model was not declared as dso local. The generated code looks up the address in GOT when reading __cpu_model. This makes it impossible to use these functions in ifunc, because at that time GOT entries have not been relocated. This change makes it dso local.

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

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

5 years ago[driver] [analyzer] Fix a backward compatibility issue after r348038.
Artem Dergachev [Thu, 20 Dec 2018 21:26:40 +0000 (21:26 +0000)]
[driver] [analyzer] Fix a backward compatibility issue after r348038.

Since r348038 we emit an error every time an -analyzer-config option is not
found. The driver, however, suppresses this error with another flag,
-analyzer-config-compatibility-mode, so backwards compatibility is maintained,
while analyzer developers still enjoy the new typo-free experience.

The backwards compatibility turns out to be still broken when the -analyze
action is not specified; it is still possible to specify -analyzer-config
in that case. This should be fixed now.

Patch by Kristóf Umann!

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

rdar://problem/46504165

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

5 years ago[CodeGen] Generate llvm.loop.parallel_accesses instead of llvm.mem.parallel_loop_acce...
Michael Kruse [Thu, 20 Dec 2018 21:24:54 +0000 (21:24 +0000)]
[CodeGen] Generate llvm.loop.parallel_accesses instead of llvm.mem.parallel_loop_access metadata.

Instead of generating llvm.mem.parallel_loop_access metadata, generate
llvm.access.group on instructions and llvm.loop.parallel_accesses on
loops. There is one access group per generated loop.

This is clang part of D52116/r349725.

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

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

5 years agoMake the "too many braces in scalar initialization" extension cause
Richard Smith [Thu, 20 Dec 2018 20:58:53 +0000 (20:58 +0000)]
Make the "too many braces in scalar initialization" extension cause
SFINAE failures.

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

5 years agoFix the example checker plugin after r349812.
Aaron Ballman [Thu, 20 Dec 2018 20:35:01 +0000 (20:35 +0000)]
Fix the example checker plugin after r349812.

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

5 years agoFix build failures from r349812 due to a missing argument.
Aaron Ballman [Thu, 20 Dec 2018 20:32:59 +0000 (20:32 +0000)]
Fix build failures from r349812 due to a missing argument.

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

5 years agoAllow direct navigation to static analysis checker documentation through SARIF exports.
Aaron Ballman [Thu, 20 Dec 2018 20:20:20 +0000 (20:20 +0000)]
Allow direct navigation to static analysis checker documentation through SARIF exports.

This adds anchors to all of the documented checks so that you can directly link to a check by a stable name. This is useful because the SARIF file format has a field for specifying a URI to documentation for a rule and some viewers, like CodeSonar, make use of this information. These links are then exposed through the SARIF exporter.

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

5 years ago[Sema] Don't try to account for the size of an incomplete type in CheckArrayAccess
Bruno Ricci [Thu, 20 Dec 2018 20:05:11 +0000 (20:05 +0000)]
[Sema] Don't try to account for the size of an incomplete type in CheckArrayAccess

When checking that the array access is not out-of-bounds in CheckArrayAccess
it is possible that the type of the base expression after IgnoreParenCasts is
incomplete, even though the type of the base expression before IgnoreParenCasts
is complete. In this case we have no information about whether the array access
is out-of-bounds and we should just bail-out instead. This fixes PR39746 which
was caused by trying to obtain the size of an incomplete type.

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

Reviewed By: efriedma

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

5 years agoRevert "[analyzer] pr38668: Do not attempt to cast loaded values..."
Artem Dergachev [Thu, 20 Dec 2018 19:36:06 +0000 (19:36 +0000)]
Revert "[analyzer] pr38668: Do not attempt to cast loaded values..."

This reverts commit r349701.

The patch was incorrect. The whole point of CastRetrievedVal()
is to handle the case in which the type from which the cast is made
(i.e., the "type" of value `V`) has nothing to do with the type of
the region it was loaded from (i.e., `R->getValueType()`).

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

rdar://problem/45062567

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

5 years ago[X86] Auto upgrade XOP/AVX512 rotation intrinsics to generic funnel shift intrinsics...
Simon Pilgrim [Thu, 20 Dec 2018 19:01:13 +0000 (19:01 +0000)]
[X86] Auto upgrade XOP/AVX512 rotation intrinsics to generic funnel shift intrinsics (clang)

This emits FSHL/FSHR generic intrinsics for the XOP VPROT and AVX512 VPROL/VPROR rotation intrinsics.

LLVM counterpart: https://reviews.llvm.org/D55938

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

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

5 years agoUse @llvm.objc.clang.arc.use intrinsic instead of clang.arc.use function.
Pete Cooper [Thu, 20 Dec 2018 18:05:41 +0000 (18:05 +0000)]
Use @llvm.objc.clang.arc.use intrinsic instead of clang.arc.use function.

Calls to this function are deleted in the ARC optimizer.  However when the ARC
optimizer was updated to use intrinsics instead of functions (r349534), the corresponding
clang change (r349535) to use intrinsics missed this one so it wasn't being deleted.

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

5 years agoCorrect the diagnose_if attribute documentation. Fixes PR35845.
Aaron Ballman [Thu, 20 Dec 2018 17:28:32 +0000 (17:28 +0000)]
Correct the diagnose_if attribute documentation. Fixes PR35845.

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

5 years ago[Sema][NFC] Add test for static_assert diagnistics with constexpr template functions.
Clement Courbet [Thu, 20 Dec 2018 13:30:40 +0000 (13:30 +0000)]
[Sema][NFC] Add test for static_assert diagnistics with constexpr template functions.

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

5 years ago[Driver] Fix accidentally reversed condition in r349752
Michal Gorny [Thu, 20 Dec 2018 13:27:37 +0000 (13:27 +0000)]
[Driver] Fix accidentally reversed condition in r349752

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

5 years ago[SystemZ] Improve testing of vecintrin.h intrinsics
Ulrich Weigand [Thu, 20 Dec 2018 13:10:47 +0000 (13:10 +0000)]
[SystemZ] Improve testing of vecintrin.h intrinsics

This adds assembly-level tests to verify that the high-level
intrinsics generate the instructions they're supposed to.
These tests would have caught the codegen bugs I just fixed.

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

5 years agoReplace getOS() == llvm::Triple::*BSD with isOS*BSD() [NFCI]
Michal Gorny [Thu, 20 Dec 2018 13:09:30 +0000 (13:09 +0000)]
Replace getOS() == llvm::Triple::*BSD with isOS*BSD() [NFCI]

Replace multiple comparisons of getOS() value with FreeBSD, NetBSD,
OpenBSD and DragonFly with matching isOS*BSD() methods.  This should
improve the consistency of coding style without changing the behavior.
Direct getOS() comparisons were left whenever used in switch or switch-
like context.

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

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

5 years ago[SystemZ] Fix wrong codegen caused by typos in vecintrin.h
Ulrich Weigand [Thu, 20 Dec 2018 13:09:09 +0000 (13:09 +0000)]
[SystemZ] Fix wrong codegen caused by typos in vecintrin.h

The following two bugs in SystemZ high-level vector intrinsics are
fixes by this patch:

- The float case of vec_insert_and_zero should generate a VLLEZF
  pattern, but currently erroneously generates VLLEZLF.

- The float and double versions of vec_orc erroneously generate
  and-with-complement instead of or-with-complement.

The patch also fixes a couple of typos in the associated test.

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

5 years ago[X86][SSE] Auto upgrade PADDS/PSUBS intrinsics to SADD_SAT/SSUB_SAT generic intrinsic...
Simon Pilgrim [Thu, 20 Dec 2018 11:53:45 +0000 (11:53 +0000)]
[X86][SSE] Auto upgrade PADDS/PSUBS intrinsics to SADD_SAT/SSUB_SAT generic intrinsics (clang)

This emits SADD_SAT/SSUB_SAT generic intrinsics for the SSE signed saturated math intrinsics.

LLVM counterpart: https://reviews.llvm.org/D55894

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

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

5 years ago[Sema] Better static assert diagnostics for expressions involving temporaries/casts...
Clement Courbet [Thu, 20 Dec 2018 09:05:15 +0000 (09:05 +0000)]
[Sema] Better static assert diagnostics for expressions involving temporaries/casts/....

Summary:
Handles expressions such as:
 - `std::is_const<T>()`
 - `std::is_const<T>()()`;
 - `std::is_same(decltype(U()), V>::value`;

Reviewers: aaron.ballman, Quuxplusone

Subscribers: cfe-commits, llvm-commits

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

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

5 years ago[analyzer] pr38668: Do not attempt to cast loaded values of non-scalar types.
Artem Dergachev [Wed, 19 Dec 2018 23:48:44 +0000 (23:48 +0000)]
[analyzer] pr38668: Do not attempt to cast loaded values of non-scalar types.

It is expected to have the same object (memory region) treated as if it has
different types in different program points. The correct behavior for
RegionStore when an object is stored as an object of type T1 but loaded as
an object of type T2 is to store the object as if it has type T1 but cast it
to T2 during load.

Note that the cast here is some sort of a "reinterpret_cast" (even in C). For
instance, if you store a float and load an integer, you won't have your float
rounded to an integer; instead, you will have garbage.

Admit that we cannot perform the cast as long as types we're dealing with are
non-trivial (neither integers, nor pointers).

Of course, if the cast is not necessary (eg, T1 == T2), we can still load the
value just fine.

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

rdar://problem/45062567

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

5 years ago[analyzer] GenericTaint: Fix formatting to prepare for incoming improvements.
Artem Dergachev [Wed, 19 Dec 2018 23:35:08 +0000 (23:35 +0000)]
[analyzer] GenericTaint: Fix formatting to prepare for incoming improvements.

Patch by Gábor Borsik!

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

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

5 years ago[analyzer] Improve modeling for returning an object from the top frame with RVO.
Artem Dergachev [Wed, 19 Dec 2018 23:14:06 +0000 (23:14 +0000)]
[analyzer] Improve modeling for returning an object from the top frame with RVO.

Static Analyzer processes the program function-by-function, sometimes diving
into other functions ("inlining" them). When an object is returned from an
inlined function, Return Value Optimization is modeled, and the returned object
is constructed at its return location directly.

When an object is returned from the function from which the analysis has started
(the top stack frame of the analysis), the return location is unknown. Model it
with a SymbolicRegion based on a conjured symbol that is specifically tagged for
that purpose, because this is generally the correct way to symbolicate
unknown locations in Static Analyzer.

Fixes leak false positives when an object is returned from top frame in C++17:
objects that are put into a SymbolicRegion-based memory region automatically
"escape" and no longer get reported as leaks. This only applies to C++17 return
values with destructors, because it produces a redundant CXXBindTemporaryExpr
in the call site, which confuses our liveness analysis. The actual fix
for liveness analysis is still pending, but it is no longer causing problems.

Additionally, re-enable temporary destructor tests in C++17.

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

rdar://problem/46217550

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

5 years agoDisable -faddsig by default for PS4 target.
Douglas Yung [Wed, 19 Dec 2018 22:45:26 +0000 (22:45 +0000)]
Disable -faddsig by default for PS4 target.

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

5 years ago[analyzer] CStringChecker: Add the forgotten test file.
Artem Dergachev [Wed, 19 Dec 2018 21:51:59 +0000 (21:51 +0000)]
[analyzer] CStringChecker: Add the forgotten test file.

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

rdar://problem/45366551

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

5 years ago[analyzer] CStringChecker: Fix a crash on C++ overloads of standard functions.
Artem Dergachev [Wed, 19 Dec 2018 21:50:46 +0000 (21:50 +0000)]
[analyzer] CStringChecker: Fix a crash on C++ overloads of standard functions.

It turns out that it's not all that uncommon to have a C++ override of, say,
memcpy that receives a structure (or two) by reference (or by value, if it's
being copied from) and copies memory from it (or into it, if it's passed
by reference). In this case the argument will be of structure type (recall that
expressions of reference type do not exist: instead, C++ classifies expressions
into prvalues and lvalues and xvalues).

In this scenario we crash because we are trying to assume that, say,
a memory region is equal to an empty CompoundValue (the non-lazy one; this is
what makeZeroVal() return for compound types and it represents prvalue of
an object that is initialized with an empty initializer list).

Add defensive checks.

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

rdar://problem/45366551

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

5 years agoPR40096: Forwards-compatible with C++20 rule regarding aggregates not having user...
David Blaikie [Wed, 19 Dec 2018 19:33:35 +0000 (19:33 +0000)]
PR40096: Forwards-compatible with C++20 rule regarding aggregates not having user-declared ctors

Looks like these were in place to make these types move-only. That's
generally not a feature that the type should prescribe (unless it's an
inherent limitation) - instead leaving it up to the users of a type.

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

5 years ago[OPENMP]Mark the loop as started when initialized.
Alexey Bataev [Wed, 19 Dec 2018 18:16:37 +0000 (18:16 +0000)]
[OPENMP]Mark the loop as started when initialized.

Need to mark the loop as started when the initialization statement is
found. It is required to prevent possible incorrect loop iteraton
variable detection during template instantiation and fix the compiler
crash during the codegen.

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