]> granicus.if.org Git - clang/log
clang
5 years ago[LibTooling] Add "SourceCode" library for functions relating to source-code manipulation.
Yitzhak Mandelbaum [Fri, 5 Apr 2019 14:05:03 +0000 (14:05 +0000)]
[LibTooling] Add "SourceCode" library for functions relating to source-code manipulation.

Summary:
Introduces a utility library in Refactoring/ to collect routines related to
source-code manipulation.  In this change, we move "extended-range" functions
from the FixIt library (in clangTooling) to this new library.

We need to use this functionality in Refactoring/ and cannot access it if it
resides in Tooling/, because that would cause clangToolingRefactor to depend on
clangTooling, which would be a circular dependency.

Reviewers: ilya-biryukov, ioeric

Reviewed By: ilya-biryukov

Subscribers: mgorny, cfe-commits

Tags: #clang

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

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

5 years ago[test] Specify an explicit darwin version in a triple in
Alex Lorenz [Fri, 5 Apr 2019 01:48:11 +0000 (01:48 +0000)]
[test] Specify an explicit darwin version in a triple in
`test/Driver/debug-options.c` to ensure that the driver
selects the DWARF 2 version as intended by the test.

Fixes the `test/Driver/debug-options.c` test regression on GreenDragon
on macOS that started failing after r357713.

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

5 years ago[IR] Refactor attribute methods in Function class (NFC)
Evandro Menezes [Thu, 4 Apr 2019 22:40:06 +0000 (22:40 +0000)]
[IR] Refactor attribute methods in Function class (NFC)

Rename the functions that query the optimization kind attributes.

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

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

5 years agoMake SourceManager::createFileID(UnownedTag, ...) take a const llvm::MemoryBuffer*
Nico Weber [Thu, 4 Apr 2019 21:06:41 +0000 (21:06 +0000)]
Make SourceManager::createFileID(UnownedTag, ...) take a const llvm::MemoryBuffer*

Requires making the llvm::MemoryBuffer* stored by SourceManager const,
which in turn requires making the accessors for that return const
llvm::MemoryBuffer*s and updating all call sites.

The original motivation for this was to use it and fix the TODO in
CodeGenAction.cpp's ConvertBackendLocation() by using the UnownedTag
version of createFileID, and since llvm::SourceMgr* hands out a const
llvm::MemoryBuffer* this is required. I'm not sure if fixing the TODO
this way actually works, but this seems like a good change on its own
anyways.

No intended behavior change.

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

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

5 years agoSpecial case ObjCPropertyDecl for printing
David Goldman [Thu, 4 Apr 2019 20:13:22 +0000 (20:13 +0000)]
Special case ObjCPropertyDecl for printing

ObjCPropertyDecl should use the category interface as a context similar to what is done for methods.

Previously category methods would be printed as `::property`; now they are printed as `Class::property`.

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

5 years ago[OPENMP]Add codegen for task reduction vars with allocate clause, NFC.
Alexey Bataev [Thu, 4 Apr 2019 18:58:17 +0000 (18:58 +0000)]
[OPENMP]Add codegen for task reduction vars with allocate clause, NFC.

Added test for the task reduction variables with the allocate clause.

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

5 years agoVerify that Android targets generate DWARF 4 by default.
Stephen Hines [Thu, 4 Apr 2019 18:17:46 +0000 (18:17 +0000)]
Verify that Android targets generate DWARF 4 by default.

Summary:
In the future, Android releases will support DWARF 5, but we need to
ensure that older targets only have DWARF 4 generated for them. This
patch inserts that verification for all Android releases now. The patch
also fixes 2 minor mistakes (a mistakenly moved RUN line, and the
missing G_DWARF2 check label).

Reviewers: aprantl

Reviewed By: aprantl

Subscribers: chh, pirama, cfe-commits

Tags: #clang

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

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

5 years ago[OPENMP]Add codegen for linear vars with allocate clause, NFC.
Alexey Bataev [Thu, 4 Apr 2019 18:06:53 +0000 (18:06 +0000)]
[OPENMP]Add codegen for linear vars with allocate clause, NFC.

Added test for the linear variables with the allocate clause.

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

5 years ago[OPENMP]Fix lookup of the user-defined reductions in C.
Alexey Bataev [Thu, 4 Apr 2019 17:28:22 +0000 (17:28 +0000)]
[OPENMP]Fix lookup of the user-defined reductions in C.

Fixed the regression of the lookup of user-defined reductions for C.

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

5 years ago[RISCV] Fix rL357699 by adding missing zero-length files
Alex Bradbury [Thu, 4 Apr 2019 14:36:07 +0000 (14:36 +0000)]
[RISCV] Fix rL357699 by adding missing zero-length files

svn add doesn't play very nicely here...

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

5 years agoUpdating Chromium's Java import order
Nico Weber [Thu, 4 Apr 2019 14:19:45 +0000 (14:19 +0000)]
Updating Chromium's Java import order

Adding in androidx as another import group.

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

Patch from Sam Maier <smaier@chromium.org>!

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

5 years ago[RISCV] Collect library directories and triples for riscv64 triple too
Alex Bradbury [Thu, 4 Apr 2019 14:18:26 +0000 (14:18 +0000)]
[RISCV] Collect library directories and triples for riscv64 triple too

When setting up library and tools paths when detecting an accompanying GCC
installation only riscv32 was handled. As a consequence when targetting
riscv64 neither the linker nor libraries would be found. This adds handling
and tests for riscv64.

Differential Revision: https://reviews.llvm.org/D53392
Patch by Edward Jones.

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

5 years ago[clang-format] Preserve include blocks in ObjC Google style
Krasimir Georgiev [Thu, 4 Apr 2019 14:04:26 +0000 (14:04 +0000)]
[clang-format] Preserve include blocks in ObjC Google style

Summary:
r357567 started to regroup include block for Google style; it was meant to apply
only for C++. This patch reverts this for ObjC.

Reviewers: ioeric

Reviewed By: ioeric

Subscribers: thakis, cfe-commits

Tags: #clang

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

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

5 years ago[RISCV][NFC] s/riscv32-linux-unknown-elf/riscv32-unknown-linux-gnu in test/Driver...
Alex Bradbury [Thu, 4 Apr 2019 13:51:41 +0000 (13:51 +0000)]
[RISCV][NFC] s/riscv32-linux-unknown-elf/riscv32-unknown-linux-gnu in test/Driver/riscv32-toolchain.c

riscv32-linux-unknown-elf was a weird thing to test for as it doesn't match
the triple used in any common RISC-V toolchain distributions (e.g.
riscv-gnu-toolchain scripts produce riscv{32,64}-unknown-linux-gnu).

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

5 years ago[CodeComplete] Fix crash when completing ObjC block parameter with a broken type
Sam McCall [Thu, 4 Apr 2019 11:34:18 +0000 (11:34 +0000)]
[CodeComplete] Fix crash when completing ObjC block parameter with a broken type

Summary:
The fix isn't great, but it's hard to fix properly because the completion
code sensibly uses ParmVarDecl to represent parameters, but the AST-building
code sensibly doesn't synthesize them if the type is broken.
Also this case is apparently really rare, so it's probably not worth bending
over backwards for.

Reviewers: ilya-biryukov

Subscribers: javed.absar, kristof.beyls, arphaman, cfe-commits

Tags: #clang

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

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

5 years ago[PR41157][OpenCL] Prevent implicit init of local addr space var in C++ mode.
Anastasia Stulova [Thu, 4 Apr 2019 11:08:51 +0000 (11:08 +0000)]
[PR41157][OpenCL] Prevent implicit init of local addr space var in C++ mode.

Prevent adding initializers implicitly to variables declared in
local address space. This happens when they get converted into
global variables and therefore theoretically have to be default
initialized in C++.

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

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

5 years ago[PR41276] Fixed incorrect generation of addr space cast for 'this' in C++.
Anastasia Stulova [Thu, 4 Apr 2019 10:48:36 +0000 (10:48 +0000)]
[PR41276] Fixed incorrect generation of addr space cast for 'this' in C++.

Improved classification of address space cast when qualification
conversion is performed - prevent adding addr space cast for
non-pointer and non-reference types. Take address space correctly
from the pointee.

Also pass correct address space from 'this' object using
AggValueSlot when generating addrspacecast in the constructor
call.

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

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

5 years agoRevert r357452 - 'SimplifyCFG SinkCommonCodeFromPredecessors: Also sink function...
David L. Jones [Thu, 4 Apr 2019 02:27:57 +0000 (02:27 +0000)]
Revert r357452 - 'SimplifyCFG SinkCommonCodeFromPredecessors: Also sink function calls without used results (PR41259)'

This revision causes tests to fail under ASAN. Since the cause of the failures
is not clear (could be ASAN, could be a Clang bug, could be a bug in this
revision), the safest course of action seems to be to revert while investigating.

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

5 years agoadd periods
Amy Huang [Wed, 3 Apr 2019 22:19:07 +0000 (22:19 +0000)]
add periods

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

5 years ago[IR] Create new method in `Function` class (NFC)
Evandro Menezes [Wed, 3 Apr 2019 21:27:03 +0000 (21:27 +0000)]
[IR] Create new method in `Function` class (NFC)

Create method `optForNone()` testing for the function level equivalent of
`-O0` and refactor appropriately.

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

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

5 years ago[OPENMP]Add codegen for reduction vars with allocate clause, NFC.
Alexey Bataev [Wed, 3 Apr 2019 19:59:09 +0000 (19:59 +0000)]
[OPENMP]Add codegen for reduction vars with allocate clause, NFC.

Added test for the reduction variables with the allocate clause.

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

5 years ago[OPENMP]Add codegen for lastprivate vars with allocate clause, NFC.
Alexey Bataev [Wed, 3 Apr 2019 19:12:47 +0000 (19:12 +0000)]
[OPENMP]Add codegen for lastprivate vars with allocate clause, NFC.

Added test for the lastprivatized variables with the allocate clause.

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

5 years agoRevert "[analyzer] Toning down invalidation a bit".
Artem Dergachev [Wed, 3 Apr 2019 18:21:16 +0000 (18:21 +0000)]
Revert "[analyzer] Toning down invalidation a bit".

This reverts commit r352473.

The overall idea is great, but it seems to cause unintented consequences
when not only Region Store invalidation but also pointer escape mechanism
was accidentally affected.

Based on discussions in https://reviews.llvm.org/D58121#1452483
and https://reviews.llvm.org/D57230#1434161

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

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

5 years ago[OPENMP]Add codegen for firstprivate vars with allocate clause.
Alexey Bataev [Wed, 3 Apr 2019 17:57:06 +0000 (17:57 +0000)]
[OPENMP]Add codegen for firstprivate vars with allocate clause.

Added codegen/test for the firstprivatized variables with the allocate
clause.

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

5 years agoRevert "[LibTooling] Add Transformer, a library for source-to-source transformations."
Alexey Bataev [Wed, 3 Apr 2019 17:34:04 +0000 (17:34 +0000)]
Revert "[LibTooling] Add Transformer, a library for source-to-source transformations."

This reverts commit r357576 to fix the problem with the cyclic
dependencies between libTooling and libToolingRefactor.

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

5 years agoBug-40323: MS ABI adding template static member in the linker directive section to...
Jennifer Yu [Wed, 3 Apr 2019 17:21:40 +0000 (17:21 +0000)]
Bug-40323: MS ABI adding template static member in the linker directive section to make sure init function can be called before main.

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

5 years ago[clang-format] Do not emit replacements while regrouping if Cpp includes are OK
Krasimir Georgiev [Wed, 3 Apr 2019 15:16:04 +0000 (15:16 +0000)]
[clang-format] Do not emit replacements while regrouping if Cpp includes are OK

Summary:
Currently clang-format would always emit a replacement for multi-block #include
sections if `IBS_Regroup`, even if the sections are correct:
```
% cat ~/test.h
#include <a.h>

#include "b.h"
% bin/clang-format --output-replacements-xml -style=google ~/test.h
<?xml version='1.0'?>
<replacements xml:space='preserve' incomplete_format='false'>
<replacement offset='0' length='30'>#include &lt;a.h>&#10;&#10;#include "b.h"</replacement>
</replacements>
%
```

This change makes clang-format not emit replacements in this case.
The logic is similar to the one implemented for Java in r354452.

Reviewers: ioeric

Reviewed By: ioeric

Subscribers: cfe-commits

Tags: #clang

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

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

5 years agoWhitespace and formatting changes; NFC.
Aaron Ballman [Wed, 3 Apr 2019 14:40:00 +0000 (14:40 +0000)]
Whitespace and formatting changes; NFC.

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

5 years agoAdd a new attribute documentation category for declarations.
Aaron Ballman [Wed, 3 Apr 2019 14:26:32 +0000 (14:26 +0000)]
Add a new attribute documentation category for declarations.

This moves documentation for some attributes into new categories that are hopefully a bit more clear. In general, "Type" documentation should be for attributes that appertain to types while "Declaration" documentation should be for attributes that appertain to declarations other than functions or variables.

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

5 years agoFixing a typo; NFC.
Aaron Ballman [Wed, 3 Apr 2019 13:37:56 +0000 (13:37 +0000)]
Fixing a typo; NFC.

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

5 years agoFix typos in tests. NFC.
Xing GUO [Wed, 3 Apr 2019 13:15:09 +0000 (13:15 +0000)]
Fix typos in tests. NFC.

Reviewers: Higuoxing

Reviewed By: Higuoxing

Subscribers: kubamracek, cfe-commits, #sanitizers, llvm-commits

Tags: #clang, #sanitizers, #llvm

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

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

5 years ago[LibTooling] Add Transformer, a library for source-to-source transformations.
Yitzhak Mandelbaum [Wed, 3 Apr 2019 13:05:19 +0000 (13:05 +0000)]
[LibTooling] Add Transformer, a library for source-to-source transformations.

Summary: Adds a basic version of Transformer, a library supporting the concise specification of clang-based source-to-source transformations.  A full discussion of the end goal can be found on the cfe-dev list with subject "[RFC] Easier source-to-source transformations with clang tooling".

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: mgorny, jfb, jdoerfert, cfe-commits

Tags: #clang

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

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

5 years ago[clang-format] Regroup #includes into blocks for Google style
Eric Liu [Wed, 3 Apr 2019 09:25:16 +0000 (09:25 +0000)]
[clang-format] Regroup #includes into blocks for Google style

Summary:
Regrouping #includes in blocks separated by blank lines when sorting C++ #include
headers was implemented recently, and it has been preferred in Google's C++ style guide:
https://google.github.io/styleguide/cppguide.html#Names_and_Order_of_Includes

Reviewers: sammccall, klimek

Subscribers: cfe-commits

Tags: #clang

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

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

5 years agoAdding 'CLion integration' to clang-format doc
Sylvestre Ledru [Wed, 3 Apr 2019 08:56:30 +0000 (08:56 +0000)]
Adding 'CLion integration' to clang-format doc

Summary:
This commit adds a chapter 'CLion integration' to ClangFormat.rst.
The official announcement of clang-format support in CLion 2019.1: https://blog.jetbrains.com/clion/2019/03/clion-2019-1-embedded-dev-clangformat-memory-view/

Patch by Marina Kalashina

Reviewers: djasper, sylvestre.ledru, krasimir

Reviewed By: sylvestre.ledru

Subscribers: jdoerfert, cfe-commits

Tags: #clang

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

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

5 years ago[libclang][test] Suppress annoying 'LIBCLANG TOOLING ERROR' output
Fangrui Song [Wed, 3 Apr 2019 07:25:04 +0000 (07:25 +0000)]
[libclang][test] Suppress annoying 'LIBCLANG TOOLING ERROR' output

check-all invokes check-clang-python which prints the annoying message:

LIBCLANG TOOLING ERROR: fixed-compilation-database: Error while opening fixed database: No such file or directory
json-compilation-database: Error while opening JSON database: No such file or directory

Let's fix it now with os.dup os.dup2 trick.

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

5 years ago[analyzer] When failing to evaluate a __builtin_constant_p, presume it's false.
Artem Dergachev [Wed, 3 Apr 2019 01:53:40 +0000 (01:53 +0000)]
[analyzer] When failing to evaluate a __builtin_constant_p, presume it's false.

__builtin_constant_p(x) is a compiler builtin that evaluates to 1 when
its argument x is a compile-time constant and to 0 otherwise. In CodeGen
it is simply lowered to the respective LLVM intrinsic. In the Analyzer
we've been trying to delegate modeling to Expr::EvaluateAsInt, which is
allowed to sometimes fail for no apparent reason.

When it fails, let's conservatively return false. Modeling it as false
is pretty much never wrong, and it is only required to return true
on a best-effort basis, which every user should expect.

Fixes VLAChecker false positives on code that tries to emulate
static asserts in C by constructing a VLA of dynamic size -1 under the
assumption that this dynamic size is actually a constant
in the sense of __builtin_constant_p.

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

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

5 years ago[WebAssembly] Add Emscripten OS definition + small_printf
Alon Zakai [Wed, 3 Apr 2019 01:08:35 +0000 (01:08 +0000)]
[WebAssembly] Add Emscripten OS definition + small_printf

The Emscripten OS provides a definition of __EMSCRIPTEN__, and also that it
supports iprintf optimizations.

Also define small_printf optimizations, which is a printf with float support
but not long double (which in wasm can be useful since long doubles are 128
bit and force linking of float128 emulation code). This part is based on
sunfish's https://reviews.llvm.org/D57620 (which can't land yet since
the WASI integration isn't ready yet).

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

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

5 years ago[HIP-Clang] Fat binary should not be produced for non GPU code
Aaron Enye Shi [Tue, 2 Apr 2019 21:54:41 +0000 (21:54 +0000)]
[HIP-Clang] Fat binary should not be produced for non GPU code

clang-format the changes to CUDA and HIP fat binary.

Reviewers: yaxunl, tra

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

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

5 years ago[HIP-Clang] Fat binary should not be produced for non GPU code 2
Aaron Enye Shi [Tue, 2 Apr 2019 20:49:41 +0000 (20:49 +0000)]
[HIP-Clang] Fat binary should not be produced for non GPU code 2

Also for CUDA, we need to disable producing these fat binary functions when there is no GPU code.

Reviewers: yaxunl, tra

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

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

5 years ago[HIP-Clang] Fat binary should not be produced for non GPU code
Aaron Enye Shi [Tue, 2 Apr 2019 20:10:18 +0000 (20:10 +0000)]
[HIP-Clang] Fat binary should not be produced for non GPU code

Skip producing the fat binary functions for HIP when no device code is present.

Reviewers: yaxunl

Differential Review: https://reviews.llvm.org/D60141

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

5 years ago[Sema] Fix a use-after-deallocate of a ParsedAttr
Erik Pilkington [Tue, 2 Apr 2019 19:48:11 +0000 (19:48 +0000)]
[Sema] Fix a use-after-deallocate of a ParsedAttr

moveAttrFromListToList only makes sense when moving an attribute to a list with
a pool that's either equivalent, or has a shorter lifetime. Therefore, using it
to move a ParsedAttr from a declarator to a declaration specifier doesn't make
sense, since the declaration specifier's pool outlives the declarator's. The
patch adds a new function, ParsedAttributes::takeOneFrom, which transfers the
attribute from one pool to another, fixing the use-after-deallocate.

rdar://49175426

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

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

5 years ago[CodeGen] Fix a regression by emitting lambda expressions in EmitLValue
Erik Pilkington [Tue, 2 Apr 2019 19:48:07 +0000 (19:48 +0000)]
[CodeGen] Fix a regression by emitting lambda expressions in EmitLValue

This ability was removed in r351487, but it's needed when a lambda appears as an
OpaqueValueExpr subexpression of a PseudoObjectExpr.

rdar://49030379

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

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

5 years ago[OPENMP]Add codegen for private vars with allocate clause.
Alexey Bataev [Tue, 2 Apr 2019 19:44:46 +0000 (19:44 +0000)]
[OPENMP]Add codegen for private vars with allocate clause.

Added codegen/test for the privatized variables with the allocate
clause.

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

5 years ago[driver][mips] Check both `gnuabi64` and `gnu` suffixes in `getMultiarchTriple`
Simon Atanasyan [Tue, 2 Apr 2019 18:03:31 +0000 (18:03 +0000)]
[driver][mips] Check both `gnuabi64` and `gnu` suffixes in `getMultiarchTriple`

In case of N64 ABI toolchain paths migth have `mips-linux-gnuabi64`
or `mips-linux-gnu` directory regardless of selected environment.
Check both variants while detecting a multiarch triple.

Fix for the bug https://bugs.llvm.org/show_bug.cgi?id=41204

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

5 years ago[driver] clang-format. Fix indentation, split long lines. NFC
Simon Atanasyan [Tue, 2 Apr 2019 18:03:15 +0000 (18:03 +0000)]
[driver] clang-format. Fix indentation, split long lines. NFC

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

5 years ago[os_log] Mark os_log_helper `nounwind`
Vedant Kumar [Tue, 2 Apr 2019 17:42:38 +0000 (17:42 +0000)]
[os_log] Mark os_log_helper `nounwind`

Allow the optimizer to remove unnecessary EH cleanups surrounding calls
to os_log_helper, to save some code size.

As a follow-up, it might be worthwhile to add a BasicNoexcept exception
spec to os_log_helper, and to then teach CGCall to emit direct calls for
callees which can't throw. This could save some compile-time.

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

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

5 years ago[OPENMP]Fix mapping of the pointers captured by reference.
Alexey Bataev [Tue, 2 Apr 2019 16:03:40 +0000 (16:03 +0000)]
[OPENMP]Fix mapping of the pointers captured by reference.

If the pointer is captured by reference, it must be mapped as
_PTR_AND_OBJ kind of mapping to correctly translate the pointer address
on the device.

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

5 years ago[Driver] Enable -fsanitize-address-globals-dead-stripping by default on PS4.
Pierre Gousseau [Tue, 2 Apr 2019 15:20:26 +0000 (15:20 +0000)]
[Driver] Enable -fsanitize-address-globals-dead-stripping by default on PS4.

Can be safely enabled on PS4.

Reviewed By: probinson

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

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

5 years agoFix Wimplicit-fallthrough warning introduced in rL357466. NFCI.
Simon Pilgrim [Tue, 2 Apr 2019 11:25:38 +0000 (11:25 +0000)]
Fix Wimplicit-fallthrough warning introduced in rL357466. NFCI.

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

5 years ago[PowerPC] Fix issue with inline asm - soft float mode
Strahinja Petrovic [Tue, 2 Apr 2019 11:00:09 +0000 (11:00 +0000)]
[PowerPC] Fix issue with inline asm - soft float mode

This patch prevents floating point register
constraints in soft float mode.

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

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

5 years agoFix compiler warning, remove extra ";" [NFC]
Mikael Holmen [Tue, 2 Apr 2019 10:01:09 +0000 (10:01 +0000)]
Fix compiler warning, remove extra ";" [NFC]

At least gcc 7.4 complained with
../tools/clang/lib/StaticAnalyzer/Checkers/Taint.cpp:26:53: warning: extra ';' [-Wpedantic]
                                        TaintTagType);
                                                     ^

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

5 years agoSimplifyCFG SinkCommonCodeFromPredecessors: Also sink function calls without used...
Hans Wennborg [Tue, 2 Apr 2019 08:01:38 +0000 (08:01 +0000)]
SimplifyCFG SinkCommonCodeFromPredecessors: Also sink function calls without used results (PR41259)

The code was previously checking that candidates for sinking had exactly
one use or were a store instruction (which can't have uses). This meant
we could sink call instructions only if they had a use.

That limitation seemed a bit arbitrary, so this patch changes it to
"instruction has zero or one use" which seems more natural and removes
the need to special-case stores.

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

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

5 years ago[CodeGen] Generate follow-up metadata for loops with more than one transformation.
Michael Kruse [Mon, 1 Apr 2019 17:47:41 +0000 (17:47 +0000)]
[CodeGen] Generate follow-up metadata for loops with more than one transformation.

Before this patch, CGLoop would dump all transformations for a loop into
a single LoopID without encoding any order in which to apply them.
rL348944 added the possibility to encode a transformation order using
followup-attributes.

When a loop has more than one transformation, use the follow-up
attribute define the order in which they are applied. The emitted order
is the defacto order as defined by the current LLVM pass pipeline,
which is:

  LoopFullUnrollPass
  LoopDistributePass
  LoopVectorizePass
  LoopUnrollAndJamPass
  LoopUnrollPass
  MachinePipeliner

This patch should therefore not change the assembly output, assuming
that all explicit transformations can be applied, and no implicit
transformations in-between. In the former case,
WarnMissedTransformationsPass should emit a warning (except for
MachinePipeliner which is not implemented yet). The latter could be
avoided by adding 'llvm.loop.disable_nonforced' attributes.

Because LoopUnrollAndJamPass processes a loop nest, generation of the
MDNode is delayed to after the inner loop metadata have been processed.
A temporary LoopID is therefore used to annotate instructions and
RAUW'ed by the actual LoopID later.

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

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

5 years ago[OPENMP]Allocate clause allocator in target region.
Alexey Bataev [Mon, 1 Apr 2019 16:56:59 +0000 (16:56 +0000)]
[OPENMP]Allocate clause allocator in target region.

According to OpenMP 5.0, 2.11.4 allocate Clause, Restrictions, allocate
clauses that appear on a target construct or on constructs in a target
region must specify an allocator expression unless a requires directive
with the dynamic_allocators clause is present in the same compilation
unit. Patch adds a check for this restriction.

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

5 years agoAttempt to fix failing buildbot (ppc64le)
Gabor Marton [Mon, 1 Apr 2019 15:48:29 +0000 (15:48 +0000)]
Attempt to fix failing buildbot (ppc64le)

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

5 years ago[ASTImporter] Convert ODR diagnostics inside ASTImporter implementation
Gabor Marton [Mon, 1 Apr 2019 15:29:55 +0000 (15:29 +0000)]
[ASTImporter] Convert ODR diagnostics inside ASTImporter implementation

Summary:
ASTStructuralEquivalence uses a flag to indicate whether ODR diagnostics
should be considered errors or warnings as module Sema is more strict than
ASTMerge. The implementation of ASTImporter should allso follow
along the same lines.

Reviewers: martong, a.sidorin, shafik, a_sidorin

Reviewed By: shafik, a_sidorin

Subscribers: rnkovacs, martong, dkrupp, Szelethus, cfe-commits

Tags: #clang

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

Patch by Endre Fulop!

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

5 years ago[ASTImporter] Make ODR error handling configurable
Gabor Marton [Mon, 1 Apr 2019 14:46:53 +0000 (14:46 +0000)]
[ASTImporter] Make ODR error handling configurable

Summary:
ODR errors are not necessarily true errors during the import of ASTs.
ASTMerge and CrossTU should use the warning equivalent of every CTU error,
while Sema should emit errors as before.

Reviewers: martong, a_sidorin, shafik, a.sidorin

Reviewed By: a_sidorin

Subscribers: rnkovacs, dkrupp, Szelethus, jdoerfert, cfe-commits

Tags: #clang

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

Patch by Endre Fulop!

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

5 years ago[OPENMP] Check that allocated variables are used in private clauses.
Alexey Bataev [Mon, 1 Apr 2019 14:25:31 +0000 (14:25 +0000)]
[OPENMP] Check that allocated variables are used in private clauses.

According to OpenMP 5.0 standard, 2.11.4 allocate Clause, Restrictions,
For any list item that is specified in the allocate clause on a
directive, a data-sharing attribute clause that may create a private
copy of that list item must be specified on the same directive. Patch
adds the checks for this restriction.

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

5 years ago[InstCombine] canonicalize select shuffles by commuting
Sanjay Patel [Sun, 31 Mar 2019 15:01:30 +0000 (15:01 +0000)]
[InstCombine] canonicalize select shuffles by commuting

In PR41304:
https://bugs.llvm.org/show_bug.cgi?id=41304
...we have a case where we want to fold a binop of select-shuffle (blended) values.

Rather than try to match commuted variants of the pattern, we can canonicalize the
shuffles and check for mask equality with commuted operands.

We don't produce arbitrary shuffle masks in instcombine, but select-shuffles are a
special case that the backend is required to handle because we already canonicalize
vector select to this shuffle form.

So there should be no codegen difference from this change. It's possible that this
improves CSE in IR though.

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

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

5 years ago[gnustep-objc] Make the GNUstep v2 ABI work for Windows DLLs.
David Chisnall [Sun, 31 Mar 2019 11:22:33 +0000 (11:22 +0000)]
[gnustep-objc] Make the GNUstep v2 ABI work for Windows DLLs.

Summary:
Based on a patch by Dustin Howett, modified to not change the ABI for
ELF platforms.

Use more Windows-like section names.

This also makes things more readable by PE/COFF debug tools that assume
sections fit in the first header.

With these changes in, it is now possible to build a working WinObjC
with clang and the WinObjC version of GNUstep libobjc (upstream GNUstep
libobjc + a work around for incremental linking, which can be removed
once LINK.EXE gains a feature to opt sections out of receiving extra
padding during an incremental link).

Patch by Dustin Howett!

Reviewers: DHowett-MSFT

Subscribers: cfe-commits

Tags: #clang

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

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

5 years agoCOMDAT-fold block descriptors.
David Chisnall [Sun, 31 Mar 2019 11:22:26 +0000 (11:22 +0000)]
COMDAT-fold block descriptors.

Without this change, linking multiple objects containing block
descriptors together on Windows will generate duplicate symbol errors.

Patch by Dustin Howett!

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

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

5 years ago[objc-gnustep] Use .init_array not .ctors when requested.
David Chisnall [Sun, 31 Mar 2019 11:22:19 +0000 (11:22 +0000)]
[objc-gnustep] Use .init_array not .ctors when requested.

This doesn't make a difference most of the time but FreeBSD/ARM doesn't
run anything in the .ctors array.

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

5 years agoRange-style std::find{,_if} -> llvm::find{,_if}. NFC
Fangrui Song [Sun, 31 Mar 2019 08:48:19 +0000 (08:48 +0000)]
Range-style std::find{,_if} -> llvm::find{,_if}. NFC

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

5 years ago[cmake] Change deprecated $<CONFIG> to $<CONFIGURATION>. NFC
Fangrui Song [Sat, 30 Mar 2019 14:38:51 +0000 (14:38 +0000)]
[cmake] Change deprecated $<CONFIG> to $<CONFIGURATION>. NFC

See rL357338 for a similar change. The informational expression
$<CONFIGURATION> has been deprecated since CMake 3.0

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

5 years ago[clang-format] [PR41187] moves Java import statements to the wrong location if code...
Paul Hoad [Sat, 30 Mar 2019 13:05:40 +0000 (13:05 +0000)]
[clang-format] [PR41187] moves Java import statements to the wrong location if code contains statements that start with the word import

Summary:
Import sorting of java file, incorrectly move import statement to after a function beginning with the word import.

Make 1 character change to regular expression to ensure there is always at least one space/tab after the word import

Previously clang-format --style="LLVM" would format

```
import X;

class C {
  void m() {
    importFile();
  }
}
```
as

```
class C {
  void m() {
    importFile();
import X;
  }
}
```

Reviewers: djasper, klimek, reuk, JonasToth

Reviewed By: klimek

Subscribers: cfe-commits

Tags: #clang-tools-extra

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

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

5 years ago[clang-format]: Add NonEmptyParentheses spacing option
Reuben Thomas [Sat, 30 Mar 2019 12:32:35 +0000 (12:32 +0000)]
[clang-format]: Add NonEmptyParentheses spacing option

This patch aims to add support for the following rules from the JUCE coding standards:

- Always put a space before an open parenthesis that contains text - e.g. foo (123);
- Never put a space before an empty pair of open/close parenthesis - e.g. foo();

Patch by Reuben Thomas

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

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

5 years agoAdds `-ftime-trace` option to clang that produces Chrome `chrome://tracing` compatibl...
Anton Afanasyev [Sat, 30 Mar 2019 08:42:48 +0000 (08:42 +0000)]
Adds `-ftime-trace` option to clang that produces Chrome `chrome://tracing` compatible JSON profiling output dumps.

This change adds hierarchical "time trace" profiling blocks that can be visualized in Chrome, in a "flame chart" style. Each profiling block can have a "detail" string that for example indicates the file being processed, template name being instantiated, function being optimized etc.

This is taken from GitHub PR: https://github.com/aras-p/llvm-project-20170507/pull/2

Patch by Aras Pranckevičius.

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

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

5 years ago[analyzer] MIGChecker: Add support for more deallocator APIs.
Artem Dergachev [Fri, 29 Mar 2019 23:56:53 +0000 (23:56 +0000)]
[analyzer] MIGChecker: Add support for more deallocator APIs.

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

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

5 years ago[lit] Set shlibpath_var on AIX
Hubert Tong [Fri, 29 Mar 2019 23:33:04 +0000 (23:33 +0000)]
[lit] Set shlibpath_var on AIX

Summary:
When building the `check-all` target on AIX, lit produces
```
warning: unable to inject shared library path on 'AIX'
```

This patch addresses this. `LIBPATH` is the environment variable of
interest on AIX. Newer versions of AIX may consider `LD_LIBRARY_PATH`,
but only when `LIBPATH` is unset.

Reviewers: xingxue, jasonliu, sfertile, serge-sans-paille

Reviewed By: xingxue

Subscribers: jsji, cfe-commits, llvm-commits

Tags: #clang

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

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

5 years agoRevert "[analyzer] Introduce a simplified API for adding custom path notes."
Artem Dergachev [Fri, 29 Mar 2019 23:11:10 +0000 (23:11 +0000)]
Revert "[analyzer] Introduce a simplified API for adding custom path notes."

This reverts commit r357323.

ASan leaks found by a buildbot :)

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

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

5 years ago[analyzer] PR41239: Fix a crash on invalid source location in NoStoreFuncVisitor.
Artem Dergachev [Fri, 29 Mar 2019 22:57:49 +0000 (22:57 +0000)]
[analyzer] PR41239: Fix a crash on invalid source location in NoStoreFuncVisitor.

It turns out that SourceManager::isInSystemHeader() crashes when an invalid
source location is passed into it. Invalid source locations are relatively
common: not only they come from body farms, but also, say, any function in C
that didn't come with a forward declaration would have an implicit
forward declaration with invalid source locations.

There's a more comfy API for us to use in the Static Analyzer:
CallEvent::isInSystemHeader(), so just use that.

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

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

5 years ago[analyzer] Move taint API from ProgramState to a separate header. NFC.
Artem Dergachev [Fri, 29 Mar 2019 22:49:30 +0000 (22:49 +0000)]
[analyzer] Move taint API from ProgramState to a separate header. NFC.

It is now an inter-checker communication API, similar to the one that
connects MallocChecker/CStringChecker/InnerPointerChecker: simply a set of
setters and getters for a state trait.

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

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

5 years ago[analyzer] PR37501: Disable assertion for logical op short circuit evaluation.
Artem Dergachev [Fri, 29 Mar 2019 22:43:34 +0000 (22:43 +0000)]
[analyzer] PR37501: Disable assertion for logical op short circuit evaluation.

The transfer function for the CFG element that represents a logical operation
computes the value of the operation and does nothing else. The element
appears after all the short circuit decisions were made, so they don't need
to be made again at this point.

Because our expression evaluation is imprecise, it is often hard to
discriminate between:

  (1) we don't know the value of the RHS because we failed to evaluate it

and

  (2) we don't know the value of the RHS because it didn't need to be evaluated.

This is hard because it depends on our knowledge about the value of the LHS
(eg., if LHS is true, then RHS in (LHS || RHS) doesn't need to be computed)
but LHS itself may have been evaluated imprecisely and we don't know whether
it is true or not. Additionally, the Analyzer wouldn't necessarily even remember
what the value of the LHS was because theoretically it's not really necessary
to know it for any future evaluations.

In order to work around these issues, the transfer function for logical
operations consists in looking at the ExplodedGraph we've constructed so far
in order to figure out from which CFG direction did we arrive here.
Such post-factum backtracking that doesn't involve looking up LHS and RHS values
is usually possible. However sometimes it fails because when we deduplicate
exploded nodes with the same program point and the same program state we may end
up in a situation when we reached the same program point from two or more
different directions.

By removing the assertion, we admit that the procedure indeed sometimes fails to
work. When it fails, we also admit that we don't know the value of the logical
operator.

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

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

5 years ago[analyzer] Introduce a simplified API for adding custom path notes.
Artem Dergachev [Fri, 29 Mar 2019 22:21:00 +0000 (22:21 +0000)]
[analyzer] Introduce a simplified API for adding custom path notes.

Almost all path-sensitive checkers need to tell the user when something specific
to that checker happens along the execution path but does not constitute a bug
on its own. For instance, a call to operator delete in C++ has consequences
that are specific to a use-after-free bug. Deleting an object is not a bug
on its own, but when the Analyzer finds an execution path on which a deleted
object is used, it'll have to explain to the user when exactly during that path
did the deallocation take place.

Historically such custom notes were added by implementing "bug report visitors".
These visitors were post-processing bug reports by visiting every ExplodedNode
along the path and emitting path notes whenever they noticed that a change that
is relevant to a bug report occurs within the program state. For example,
it emits a "memory is deallocated" note when it notices that a pointer changes
its state from "allocated" to "deleted".

The "visitor" approach is powerful and efficient but hard to use because
such preprocessing implies that the developer first models the effects
of the event (say, changes the pointer's state from "allocated" to "deleted"
as part of operator delete()'s transfer function) and then forgets what happened
and later tries to reverse-engineer itself and figure out what did it do
by looking at the report.

The proposed approach tries to avoid discarding the information that was
available when the transfer function was evaluated. Instead, it allows the
developer to capture all the necessary information into a closure that
will be automatically invoked later in order to produce the actual note.

This should reduce boilerplate and avoid very painful logic duplication.

On the technical side, the closure is a lambda that's put into a special kind of
a program point tag, and a special bug report visitor visits all nodes in the
report and invokes all note-producing closures it finds along the path.

For now it is up to the lambda to make sure that the note is actually relevant
to the report. For instance, a memory deallocation note would be irrelevant when
we're reporting a division by zero bug or if we're reporting a use-after-free
of a different, unrelated chunk of memory. The lambda can figure these thing out
by looking at the bug report object that's passed into it.

A single checker is refactored to make use of the new functionality: MIGChecker.
Its program state is trivial, making it an easy testing ground for the first
version of the API.

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

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

5 years ago[WebAssembly] Add mutable globals feature
Thomas Lively [Fri, 29 Mar 2019 22:00:18 +0000 (22:00 +0000)]
[WebAssembly] Add mutable globals feature

Summary:
This feature is not actually used for anything in the WebAssembly
backend, but adding it allows users to get it into the target features
sections of their objects, which makes these objects
future-compatible.

Reviewers: aheejin, dschuff

Subscribers: sbc100, jgravelle-google, hiraditya, sunfish, jdoerfert, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

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

5 years ago[Sema] Avoid sending a dependent expression to the constant evaluator.
Erik Pilkington [Fri, 29 Mar 2019 19:53:41 +0000 (19:53 +0000)]
[Sema] Avoid sending a dependent expression to the constant evaluator.

Fixes llvm.org/PR41286

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

5 years ago[Sema] Fix assertion when `auto` parameter in lambda has an attribute.
Volodymyr Sapsai [Fri, 29 Mar 2019 18:47:07 +0000 (18:47 +0000)]
[Sema] Fix assertion when `auto` parameter in lambda has an attribute.

Fixes the assertion
> no Attr* for AttributedType*
> UNREACHABLE executed at llvm-project/clang/lib/Sema/SemaType.cpp:298!

In `TypeProcessingState::getAttributedType` we put into `AttrsForTypes`
types with `auto` but later in
`TypeProcessingState::takeAttrForAttributedType` we use transformed
types and that's why cannot find `Attr` corresponding to
`AttributedType`.

Fix by keeping `AttrsForTypes` up to date after replacing `AutoType`.

rdar://problem/47689465

Reviewers: rsmith, arphaman, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: jkorous, dexonsmith, jdoerfert, cfe-commits

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

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

5 years ago[Driver] Use --warn-shared-textrel for Android.
Dan Albert [Fri, 29 Mar 2019 18:34:25 +0000 (18:34 +0000)]
[Driver] Use --warn-shared-textrel for Android.

Android does not allow shared text relocations. Enable the linker
warning to detect them by default.

Reviewers: srhines, pirama

Reviewed By: srhines

Subscribers: cfe-commits

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

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

5 years agoVarious fixes and additions to creduce-clang-crash.py
George Burgess IV [Fri, 29 Mar 2019 17:50:43 +0000 (17:50 +0000)]
Various fixes and additions to creduce-clang-crash.py

Some more additions to the script - mainly reducing the clang args after
the creduce run by removing them one by one and seeing if the crash
reproduces. Other things:

- remove the --crash flag when "fatal error" occurs
- fixed to read stack trace functions from the top
- run creduce on a copy of the original file

Patch by Amy Huang!

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

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

5 years ago[AMDGPU] Switch default DWARF version to 5
Scott Linder [Fri, 29 Mar 2019 17:45:40 +0000 (17:45 +0000)]
[AMDGPU] Switch default DWARF version to 5

Effectively reverts r337612. The issues that cropped up with the last
attempt appear to have gone away.

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

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

5 years ago[fuchsia] Add clang-doc to Fuchsia distribution
Julie Hockett [Fri, 29 Mar 2019 16:56:37 +0000 (16:56 +0000)]
[fuchsia] Add clang-doc to Fuchsia distribution

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

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

5 years agoclang-cl: Expose -fprofile-generate and -fcs-profile-generate (PR41252)
Hans Wennborg [Fri, 29 Mar 2019 14:03:34 +0000 (14:03 +0000)]
clang-cl: Expose -fprofile-generate and -fcs-profile-generate (PR41252)

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

5 years ago[AArch64] Support selecting TPIDR_EL[1-3] as the thread base
Oliver Stannard [Fri, 29 Mar 2019 13:32:41 +0000 (13:32 +0000)]
[AArch64] Support selecting TPIDR_EL[1-3] as the thread base

Add an -mtp=el[0-3] option to select which of the AArch64 thread ID registers
will be used for the TLS base pointer.

This is a followup to rL356657 which added subtarget features to enable
accesses to the privileged thread ID registers.

Patch by Philip Derrin!

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

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

5 years ago[PowerPC] Add the support for __builtin_setrnd() in clang
Kang Zhang [Fri, 29 Mar 2019 09:11:52 +0000 (09:11 +0000)]
[PowerPC] Add the support for __builtin_setrnd() in clang

Summary:
PowerPC64/PowerPC64le supports the builtin function __builtin_setrnd to set the floating point rounding mode. This function will use the least significant two bits of integer argument to set the floating point rounding mode.
double __builtin_setrnd(int mode);
The effective values for mode are:
0 - round to nearest
1 - round to zero
2 - round to +infinity
3 - round to -infinity
Note that the mode argument will modulo 4, so if the int argument is greater than 3, it will only use the least significant two bits of the mode. Namely, builtin_setrnd(102)) is equal to builtin_setrnd(2).

Reviewed By: jsji

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

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

5 years ago[Sema] Fix a crash when nonnull checking
Michael Liao [Fri, 29 Mar 2019 03:55:52 +0000 (03:55 +0000)]
[Sema] Fix a crash when nonnull checking

Summary:
- If a parameter is used, nonnull checking needs function prototype to
  retrieve the corresponding parameter's attributes. However, at the
  prototype substitution phase when a template is being instantiated,
  expression may be created and checked without a fully specialized
  prototype. Under such a scenario, skip nonnull checking on that
  argument.

Reviewers: rjmccall, tra, yaxunl

Subscribers: javed.absar, kristof.beyls, cfe-commits

Tags: #clang

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

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

5 years ago[CodeGen][ObjC] Adjust the addresses passed to calls to synthesized
Akira Hatanaka [Fri, 29 Mar 2019 00:23:20 +0000 (00:23 +0000)]
[CodeGen][ObjC] Adjust the addresses passed to calls to synthesized
copy/move constructor/assignment operator functions for non-trivial C
structs.

This commit fixes a bug where the offset of struct fields weren't being
taken into account when computing the addresses passed to calls to the
special functions.

For example, the copy constructor for S1 (__copy_constructor_8_8_s0_s8)
would pass the start addresses of the destination and source structs to
the call to S0's copy constructor (_copy_constructor_8_8_s0) without
adding the offset of field f1 to the addresses.

typedef struct {
  id f0;
  S0 f1;
} S1;

void test(S1 s1) {
  S1 t = s1;
}

rdar://problem/49400610

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

5 years agoFix typos and formatting. NFC.
Akira Hatanaka [Fri, 29 Mar 2019 00:23:17 +0000 (00:23 +0000)]
Fix typos and formatting. NFC.

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

5 years ago[MS] Make __iso_volatile_* available on all targets
Reid Kleckner [Thu, 28 Mar 2019 22:59:09 +0000 (22:59 +0000)]
[MS] Make __iso_volatile_* available on all targets

Future versions of MSVC make these intrinsics available on x86 & x64,
according to:
http://lists.llvm.org/pipermail/cfe-dev/2019-March/061711.html

The purpose of these builtins is to emit plain, non-atomic, volatile
stores when /volatile:ms (-cc1 -fms-volatile) is enabled.

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

5 years ago[OPENMP]Add check for undefined behavior with thread allocators on
Alexey Bataev [Thu, 28 Mar 2019 19:15:36 +0000 (19:15 +0000)]
[OPENMP]Add check for undefined behavior with thread allocators on
target and task-based directives.

According to OpenMP 5.0, 2.11.4 allocate Clause, Restrictions, For task,
taskloop or target directives, allocation requests to memory allocators
with the trait access set to thread result in unspecified behavior.
Patch introduces a check for omp_thread_mem_alloc predefined allocator
on target- and trask-based directives.

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

5 years ago[Driver] Default Android toolchains to noexecstack.
Dan Albert [Thu, 28 Mar 2019 18:08:28 +0000 (18:08 +0000)]
[Driver] Default Android toolchains to noexecstack.

Android does not support executable stacks.

Reviewers: srhines, pirama

Reviewed By: pirama

Subscribers: cfe-commits

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

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

5 years ago[WebAssembly] Reland of rL356953 (4dcf3acce6)
Sam Clegg [Thu, 28 Mar 2019 17:45:18 +0000 (17:45 +0000)]
[WebAssembly] Reland of rL356953 (4dcf3acce6)

The previous patch was missing GetProgramPath() in the return value
of getLinkerPath().

See https://reviews.llvm.org/D59743

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

5 years agoMake helper functions static. NFC.
Benjamin Kramer [Thu, 28 Mar 2019 17:18:42 +0000 (17:18 +0000)]
Make helper functions static. NFC.

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

5 years ago[CodeGen] Add additional mangling for struct members of non trivial structs
Shoaib Meenai [Thu, 28 Mar 2019 17:01:20 +0000 (17:01 +0000)]
[CodeGen] Add additional mangling for struct members of non trivial structs

In https://bugs.llvm.org/show_bug.cgi?id=41206 we observe bad codegen
when embedding a non-trivial C struct within a C struct. This is due to
the fact that name mangling for non-trivial structs marks the two
structs as identical. This diff contains a fix for this issue.

Patch by Dan Zimmerman <daniel.zimmerman@me.com>.

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

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

5 years ago[Analyzer] Constraint Manager - Calculate Effective Range for Differences
Adam Balogh [Thu, 28 Mar 2019 13:05:59 +0000 (13:05 +0000)]
[Analyzer] Constraint Manager - Calculate Effective Range for Differences

Since rL335814, if the constraint manager cannot find a range set for `A - B`
(where `A` and `B` are symbols) it looks for a range for `B - A` and returns
it negated if it exists. However, if a range set for both `A - B` and `B - A`
is stored then it only returns the first one. If we both use `A - B` and
`B - A`, these expressions behave as two totally unrelated symbols. This way
we miss some useful deductions which may lead to false negatives or false
positives.

This tiny patch changes this behavior: if the symbolic expression the
constraint manager is looking for is a difference `A - B`, it tries to
retrieve the range for both `A - B` and `B - A` and if both exists it returns
the intersection of range `A - B` and the negated range of `B - A`. This way
every time a checker applies new constraints to the symbolic difference or to
its negated it always affects both the original difference and its negated.

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

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

5 years agoFix Wdocumentation warning. NFCI.
Simon Pilgrim [Thu, 28 Mar 2019 12:03:49 +0000 (12:03 +0000)]
Fix Wdocumentation warning. NFCI.

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

5 years ago[PR41247] Fixed parsing of private keyword in C++.
Anastasia Stulova [Thu, 28 Mar 2019 11:47:14 +0000 (11:47 +0000)]
[PR41247] Fixed parsing of private keyword in C++.

Fixed bug in C++ to prevent parsing 'private' as a
valid address space qualifier.

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

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

5 years agoFix tests after rC357150
Fangrui Song [Thu, 28 Mar 2019 08:41:17 +0000 (08:41 +0000)]
Fix tests after rC357150

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

5 years ago[Driver] Allow -gsplit-dwarf on ELF OSes other than Linux and Fuchsia
Fangrui Song [Thu, 28 Mar 2019 08:24:00 +0000 (08:24 +0000)]
[Driver] Allow -gsplit-dwarf on ELF OSes other than Linux and Fuchsia

In gcc, -gsplit-dwarf is handled in gcc/gcc.c as a spec
(ASM_FINAL_SPEC): objcopy --extract-dwo + objcopy --strip-dwo. In
gcc/opts.c, -gsplit_dwarf has the same semantic of a -g. Except for the
availability of the external command 'objcopy', nothing precludes the
feature working on other ELF OSes. llvm doesn't use objcopy, so it doesn't
have to exclude other OSes.

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

5 years agoRevert "[WebAssembly] Don't use default GetLinkerPath"
Derek Schuff [Wed, 27 Mar 2019 22:22:18 +0000 (22:22 +0000)]
Revert "[WebAssembly] Don't use default GetLinkerPath"

This reverts commit 4dcf3acce6d7455fd079d8e57441906ca2bad254.
(reverts LLVM SVN r356953)

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

5 years ago[ASTImporter] Fix IsStructuralMatch specialization for EnumDecl to prevent re-importi...
Shafik Yaghmour [Wed, 27 Mar 2019 17:47:36 +0000 (17:47 +0000)]
[ASTImporter] Fix IsStructuralMatch specialization for EnumDecl to prevent re-importing an EnumDecl while trying to complete it

Summary:
We may try and re-import an EnumDecl while trying to complete it in IsStructuralMatch(...) specialization for EnumDecl. This change mirrors a similar fix for the specialization for RecordDecl.

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

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