Commit Graph

71095 Commits

Author SHA1 Message Date
Adrian Prantl 356347b58d Simplify codegen and debug info generation for block context parameters.
The exisiting code goes out of its way to put block parameters into an
alloca only at -O0, and then describes the funciton argument with a
dbg.declare, which is undocumented in the LLVM-CFE contract and does
not actually behave as intended after LLVM r642022.

This patch just generates the alloca unconditionally, the mem2reg pass
will eliminate it at -O1 and up anyway and points the dbg.declare to
the alloca as intended (which mem2reg will then correctly rewrite into
a dbg.value).

This reapplies r316684 with some dead code removed.

rdar://problem/35043980

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

llvm-svn: 316689
2017-10-26 20:08:52 +00:00
George Karpenkov ff555ce798 [Analyzer] [Tests] Write analyzers crashes to stdout, and not to a separate file
With this change it would be sufficient to look at CI console to see the
failure.

llvm-svn: 316687
2017-10-26 19:00:22 +00:00
Adrian Prantl e78a62207a Revert "Simplify codegen and debug info generation for block context parameters."
This reverts commit r316684 while investigating buildbot breakage.

llvm-svn: 316686
2017-10-26 18:32:16 +00:00
Adrian Prantl 1c45b09add Simplify codegen and debug info generation for block context parameters.
The exisiting code goes out of its way to put block parameters into an
alloca only at -O0, and then describes the funciton argument with a
dbg.declare, which is undocumented in the LLVM-CFE contract and does
not actually behave as intended after LLVM r642022.

This patch just generates the alloca unconditionally, the mem2reg pass
will eliminate it at -O1 and up anyway and points the dbg.declare to
the alloca as intended (which mem2reg will then correctly rewrite into
a dbg.value).

rdar://problem/35043980

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

llvm-svn: 316684
2017-10-26 18:16:05 +00:00
Craig Topper 6b3a09e901 [X86] Add a target attribute test for no-sse4.
llvm-svn: 316681
2017-10-26 17:54:22 +00:00
Reid Kleckner cc087f6d9f Move MS inline asm parser methods out of line to reduce indentation, NFC
llvm-svn: 316674
2017-10-26 17:07:48 +00:00
Dave Lee 55540a0ce7 Add objcCategoryImplDecl matcher
Summary:
Add `objcCategoryImplDecl` which matches ObjC category definitions
(`@implementation`). This matcher complements `objcCategoryDecl` (`@interface`)
which was added in D30854.

Reviewers: aaron.ballman, malcolm.parsons, alexshap

Reviewed By: aaron.ballman

Subscribers: klimek, cfe-commits

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

llvm-svn: 316670
2017-10-26 15:53:37 +00:00
Roman Lebedev 809df34efc [Sema] -Wzero-as-null-pointer-constant: don't warn for system macros other than NULL.
Summary:
The warning was initially introduced in D32914 by @thakis,
and the concerns were raised there, and later in rL302247
and PR33771.

I do believe that it makes sense to relax the diagnostic
e.g. in this case, when the expression originates from the
system header, which can not be modified. This prevents
adoption for the diagnostic for codebases which use pthreads
(`PTHREAD_MUTEX_INITIALIZER`), gtest, etc.

As @malcolm.parsons suggests, it *may* make sense to also
not warn for the template types, but it is not obvious to
me how to do that in here.

Though, it still makes sense to complain about `NULL` macro.

While there, add more tests.

Reviewers: dblaikie, thakis, rsmith, rjmccall, aaron.ballman

Reviewed By: thakis

Subscribers: Rakete1111, hans, cfe-commits, thakis, malcolm.parsons

Tags: #clang

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

llvm-svn: 316662
2017-10-26 13:18:14 +00:00
Eric Liu 83454aaec4 Try to fix warnings and windows test failures caused by r316653
llvm-svn: 316661
2017-10-26 13:09:50 +00:00
Aaron Ballman ffc4336665 Add a new attribute definition spelling, Clang<"attr">, that expands to two attribute spellings: GNU<"attr"> and CXX11<"clang", "attr">. This is similar to how the GCC spelling works and is intended to be used for attributes introduced for Clang.
Changes all existing attributes that currently use GNU<"attr"> and CXX11<"clang", "attr> spellings to instead use the Clang<"attr"> spelling.

No additional tests are necessary because the existing tests already use both spellings for the attributes converted to the new spelling. No functional changes are expected.

llvm-svn: 316658
2017-10-26 12:19:02 +00:00
Eric Liu 826b783214 [Tooling] A new framework for executing clang frontend actions.
Summary:
This defines a `clang::tooling::ToolExecutor` interface that can be extended to support different execution plans including standalone execution on a given set of TUs or parallel execution on all TUs in a codebase.

In order to enable multiprocessing execution, tool actions are expected to output result into a `ToolResults` interface provided by executors. The `ToolResults` interface abstracts how results are stored e.g. in-memory for standalone executions or on-disk for large-scale execution.

New executors can be registered as `ToolExecutorPlugin`s via the `ToolExecutorPluginRegistry`. CLI tools can use `createExecutorFromCommandLineArgs` to create a specific registered executor according to the command-line arguments.

This patch also implements `StandaloneToolExecutor` which has the same behavior as the current `ClangTool` interface, i.e. execute frontend actions on a given set of TUs. At this point, it's simply a wrapper around `ClangTool` at this point.

This is still experimental but expected to replace the existing `ClangTool` interface so that specific tools would not need to worry about execution.

Reviewers: klimek, arphaman, hokein, sammccall

Reviewed By: klimek

Subscribers: cfe-commits, djasper, mgorny, omtcyfz

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

llvm-svn: 316653
2017-10-26 10:38:14 +00:00
Benjamin Kramer e3962aebca Fix overloaded static functions in SemaCodeComplete
https://bugs.llvm.org/show_bug.cgi?id=33904
Happens when static function is accessed via the class variable. That leads to incorrect overloads number because the variable is considered as the first argument.

struct Bar {
  static void foo(); static void foo(int);
};

int main() {
  Bar b;
  b.foo(/*complete here*/); // did not work before
  Bar::foo(/*complete here*/); // worked fine
}

Patch by Ivan Donchevskii!

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

llvm-svn: 316646
2017-10-26 08:41:28 +00:00
Alex Shlyapnikov 797bdbbce7 [LSan] Enable -fsanitize=leak for PPC64 Linux.
Summary: .

Reviewers: eugenis

Subscribers: cfe-commits

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

llvm-svn: 316636
2017-10-26 03:09:53 +00:00
George Karpenkov 65839bd429 [Analyzer] [Tests] Consistently use exit codes. Use code=42 to signify different results
llvm-svn: 316632
2017-10-26 01:13:22 +00:00
Alex Lorenz f757961c0f Allow StmtPrinter to supress implicit 'this' and 'self' base expressions
This will be useful for certain refactoring actions.

rdar://34202062

llvm-svn: 316631
2017-10-26 00:56:54 +00:00
Alex Lorenz fbd17e17f5 Handle PragmaDebug in PPChainedCallbacks
The test is in clang-tools-extra/test/pp-trace

llvm-svn: 316621
2017-10-25 22:01:23 +00:00
George Karpenkov a932c8745c [Analyzer] [Tests] Do not discard output from CmpRuns.py when running integration tests
Contrary to the deleted comment, in most cases CmpRuns.py produces a
fairly small amount of output, which is useful to see straight away to
see what has changed when executing the integration tests.

llvm-svn: 316618
2017-10-25 21:49:46 +00:00
George Karpenkov 134d8473ef [Analyzer] Give more descriptive name to BdyFrm field.
Discussion at: https://reviews.llvm.org/D39220

llvm-svn: 316617
2017-10-25 21:49:41 +00:00
Justin Lebar 066494d8c1 [CUDA] Print an error if you try to compile with < sm_30 on CUDA 9.
Summary:
CUDA 9's minimum sm is sm_30.

Ideally we should also make sm_30 the default when compiling with CUDA
9, but that seems harder than it should be.

Subscribers: sanjoy

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

llvm-svn: 316611
2017-10-25 21:32:06 +00:00
Evgeniy Stepanov 117627c9a1 Enable -pie and --enable-new-dtags by default on Android.
Summary:
Also enable -no-pie on Gnu toolchain (previously available on Darwin only).

Non-PIE executables won't even start on recent Android, and DT_RPATH is ignored by the loader.

Reviewers: srhines, danalbert

Subscribers: cfe-commits

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

llvm-svn: 316606
2017-10-25 20:39:22 +00:00
Erich Keane 818cf5bcb3 Ignore implicity casts for zero-as-null-pointer-constant warning
The repro in https://bugs.llvm.org/show_bug.cgi?id=34362
caused the left nullptr to be cast to a int* implicitly, which
resulted diagnosing this falsely.

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

llvm-svn: 316605
2017-10-25 20:23:13 +00:00
Saleem Abdulrasool 2a5015b11b CodeGen: fix PPC Darwin variadics
Darwin uses char * for the variadic list type (va_list).  We use the PPC
SVR4 ABI for PPC, which uses a structure type for the va_list.  When
constructing the GEP, we would fail due to the incorrect handling for
the va_list.  Correct this to use the right type.

llvm-svn: 316599
2017-10-25 17:56:50 +00:00
Craig Topper 009cebfed8 [X86] Add avx512vpopcntdq to Knights Mill
As indicated by Table 1-1 in Intel Architecture Instruction Set Extensions and Future Features Programming Reference from October 2017.

llvm-svn: 316593
2017-10-25 17:10:58 +00:00
Alexey Bataev d070a585f6 [OPENMP] Improve debug info for taskgroup implicitly generated
expressions.

llvm-svn: 316585
2017-10-25 15:54:04 +00:00
Alexey Bataev c551406ba2 [OPENMP] Constify function parameters, NFC.
llvm-svn: 316584
2017-10-25 15:44:52 +00:00
Sylvestre Ledru a3436bb21a Add support of the next Debian (Debian buster - version 10)
llvm-svn: 316579
2017-10-25 14:25:28 +00:00
Sylvestre Ledru de828bad7e Also update IsUbuntu() with Ubuntu Bionic
Follow up of r316577

llvm-svn: 316578
2017-10-25 14:23:27 +00:00
Sylvestre Ledru f8e9ffa56f Add support of the next Ubuntu (Ubuntu 18.04 - Bionic Beaver)
llvm-svn: 316577
2017-10-25 14:21:33 +00:00
Haojian Wu f8bfb34010 [rename] support renaming class member.
Reviewers: ioeric

Reviewed By: ioeric

Subscribers: klimek, cfe-commits, mgorny

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

llvm-svn: 316571
2017-10-25 11:54:45 +00:00
Haojian Wu 6ec2b8ac77 [clang-rename] Fix and enable the failing TemplatedClassFunction test.
Reviewers: ioeric

Reviewed By: ioeric

Subscribers: klimek, cfe-commits

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

llvm-svn: 316561
2017-10-25 08:25:25 +00:00
Saleem Abdulrasool ad75c7d194 CodeGen: fix a case of incorrect checks for ivars
Ensure that we check the ivar containing decl for the DLL storage
attribute rather than the ivar itself as the dll storage is associated
to the interface decl not the ivar decl.

llvm-svn: 316545
2017-10-25 03:58:15 +00:00
Petr Hosek 9f46ece85a [CMake] Build host builtins in Fuchsia toolchain even on Darwin
This is nedeeded for the toolchain to be actually usable as a host
toolchain on Darwin.

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

llvm-svn: 316542
2017-10-25 02:35:22 +00:00
Petr Hosek a9eaf1d226 [CMake] Include clang-refactor in Fuchsia toolchain
This includes the clang-refactor in the toolchain distribution.

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

llvm-svn: 316541
2017-10-25 02:31:38 +00:00
Petr Hosek 3cad20023b [clang-refactor] Use add_clang_tool CMake template
This allows including clang-refactor in LLVM_DISTRIBUTION_COMPONENTS
to build clang-refactor as part of the toolchain distribution.

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

llvm-svn: 316540
2017-10-25 01:11:27 +00:00
George Karpenkov a132938295 [Analyzer] Remove spaces inside comments mentioning the parameter name,
to aid clang-tidy comprehension.
Requested by @alexfh in https://reviews.llvm.org/D39015

llvm-svn: 316539
2017-10-25 00:03:45 +00:00
George Karpenkov f671bd26b7 [Analyzer] Remove unnecessary semicolon in analyzer tests.
llvm-svn: 316538
2017-10-25 00:03:45 +00:00
George Karpenkov 506ecbb946 [Analyzer] Store BodyFarm in std::unique_ptr
Differential Revision: https://reviews.llvm.org/D39220

llvm-svn: 316536
2017-10-24 23:53:19 +00:00
George Karpenkov bf92c44616 [Analyzer] [Tests] Minor refactor of testing infrastructure:
Move utilities functions into a separate file to make comprehension
easier.

llvm-svn: 316535
2017-10-24 23:52:48 +00:00
George Karpenkov 318cd1f263 [Analyzer] [Tests] Remove temporary fields from generated reference results.
Pointer to HTML diagnostics is removed (as it is not stored) as well as
the version (as it would be available from the commit message).

llvm-svn: 316534
2017-10-24 23:52:46 +00:00
Akira Hatanaka bc1d56eafa [Sema][ObjC] Look for either objc_bridge or objc_bridge_mutable when
determining whether a RecordDecl is CFError.

CFErrorRef used to be declared with "objc_bridge(NSError)" but is now
declared with "objc_bridge_mutable(NSError)". Look for either when
checking whether a RecordDecl is CFError.

rdar://problem/35034779

llvm-svn: 316531
2017-10-24 23:38:14 +00:00
Erich Keane 5759fa798b Correct behavior of fastcall when default CC is set.
Fastcall doesn't support variadic function calls, so
setting the default calling convention to Fastcall would
result in incorrect code being emitted for these conditions.

This patch adds a 'variadic' test to the default calling conv
test, as well as fixes the behavior of fastcall.

llvm-svn: 316528
2017-10-24 23:12:01 +00:00
George Karpenkov 43f683cb33 [Analyzer] Fix bug in testing scripts, which always marked result as failure.
llvm-svn: 316522
2017-10-24 22:24:13 +00:00
Erich Keane 9fed6c6501 Replaced unicode characters with ASCII, as introduced in r316518.
llvm-svn: 316521
2017-10-24 22:00:25 +00:00
Erich Keane e63e9d72b8 mplement __has_unique_object_representations
A helper builtin to facilitate implementing the
std::has_unique_object_representations type trait.

Requested here: https://bugs.llvm.org/show_bug.cgi?id=34942
Also already exists in GCC and MSVC.

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

llvm-svn: 316518
2017-10-24 21:31:50 +00:00
Roman Lebedev 7ade0173df [Sema] Document+test the -Wsign-compare change for enums in C code [NFC]
rL316268 / D39122 has fixed PR35009, and now when in C,
these three(?) diagnostics properly use the enum's underlying
datatype.

While it was fixed, the test coverage was clearly insufficient,
because the -Wsign-compare change didn't show up in any of the
tests, until it was reported in the post-commit mail for rL316268.

So add the test for the -Wsign-compare diagnostic for enum
for C code, and while there, document this in the release notes.

The fix itself was obviously correct, so unless we want to silence
this new diagnosed case, i deem this commit to be NFC.

llvm-svn: 316500
2017-10-24 21:05:43 +00:00
Alexey Bataev 1b48c5e56b [OPENMP] Fix PR35013: Fix passing VLAs captures to outlined functions.
Fixed passing of VLAs and variably-modified types to outlined functions.
Synchronized passing with the types codegen.

llvm-svn: 316488
2017-10-24 19:52:31 +00:00
Yaxun Liu e45b3d5dad CodeGen: Fix missing debug loc due to alloca
Builder save/restores insertion pointer when emitting addr space cast
for alloca, but does not save/restore debug loc, which causes verifier
failure for certain call instructions.

This patch fixes that.

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

llvm-svn: 316484
2017-10-24 19:14:43 +00:00
Alex Lorenz 4953114db9 Add missing clangRewrite lib dependency for clangToolingRefactor
llvm-svn: 316467
2017-10-24 17:23:53 +00:00
Alex Lorenz 7fe441b20d [refactor] Initial outline of implementation of "extract function" refactoring
This commit adds an initial, skeleton outline of the "extract function"
refactoring. The extracted function doesn't capture variables / rewrite code
yet, it just basically does a simple copy-paste.
The following initiation rules are specified:

- extraction can only be done for executable code in a function/method/block.
  This means that you can't extract a global variable initialize into a function
  right now.
- simple literals and references are not extractable.

This commit also adds support for full source ranges to clang-refactor's test
mode.

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

llvm-svn: 316465
2017-10-24 17:18:45 +00:00
Alex Lorenz b874042e32 [code completion] Complete ObjC methods in @implementation without leading
'-'/'+' prefix

rdar://12040840

llvm-svn: 316458
2017-10-24 16:39:37 +00:00
Erich Keane d232e2c726 Remove repeated function name in doxygen comment.
llvm-svn: 316453
2017-10-24 16:16:34 +00:00
Erich Keane 1216acc3c4 Fix spelling in comment, field is isMsStruct, not Strust
llvm-svn: 316447
2017-10-24 15:34:59 +00:00
Vassil Vassilev 92e22794bd [modules] Add a regression test for merging anon decls in extern C contexts.
llvm-svn: 316444
2017-10-24 14:52:35 +00:00
Erich Keane daa5f777b4 Add Forgotten test for: Fix template parameter default args missed if redecled
Addendum to differential revision: https://reviews.llvm.org/D39127

llvm-svn: 316437
2017-10-24 13:51:07 +00:00
Erik Verbruggen 6524c05d2c Do not add a colon chunk to the code completion of class inheritance access modifiers
With enabled CINDEXTEST_CODE_COMPLETE_PATTERNS env option (which enables
IncludeCodePatterns in completion options) code completion after colon
currently suggests access modifiers with 2 completion chunks which is
incorrect.

Example:
class A : <Cursor>B
{
}

Currently we get 'NotImplemented:{TypedText public}{Colon :} (40)'
but the correct line is just 'NotImplemented:{TypedText public} (40)'

The fix introduces more specific scope that occurs between ':' and '{'
It allows us to determine when we don't need to add ':' as a second
chunk to the public/protected/private access modifiers.

Patch by Ivan Donchevskii!

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

llvm-svn: 316436
2017-10-24 13:46:58 +00:00
Eric Liu e6f854353e [Tooling] Add a factory method for CommonOptionsParser
Summary: This returns error instead of exiting the program in case of error.

Reviewers: klimek, hokein

Reviewed By: hokein

Subscribers: cfe-commits

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

llvm-svn: 316433
2017-10-24 13:10:58 +00:00
Peter Smith 820e46f3b2 [AArch64] Fix PR34625 -mtune without -mcpu should not set -target-cpu
When -mtune is used on AArch64 the -target-cpu is passed the value of the
cpu given to -mtune. As well as setting micro-architectural features of the
-mtune cpu, this will also add the architectural features such as support
for instructions. This can result in the backend using instructions that
are supported in the -mtune cpu but not supported in the target
architecture. For example use of the v8.1-a LSE extensions with -march=v8.
    
This change removes the setting of -target-cpu for -mtune, the -mcpu must
be used to set -target-cpu. This has the effect of removing all non-hard
coded benefits of mtune but it does produce correct output when -mtune cpu
with a later architecture than v8 is used.
    
Fixes PR34625
    
Differential Revision: https://reviews.llvm.org/D39179

llvm-svn: 316424
2017-10-24 09:51:55 +00:00
Tim Shen cc5bf00f1d [test] Fix clang-test for FreeBSD and NetBSD
Lit tries to inject the shared library paths, but no action is taken
when platform.system() is not recognized, results in an environment
variable with an empty name, which is illegal.

The patch fixes this mechanism for FreeBSD and NetBSD, and gives an
warning on other platforms, so that the latecomers don't have to spend
time on debugging lit.

Thanks Zhihao Yuan for the patch!

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

llvm-svn: 316411
2017-10-24 03:11:02 +00:00
Jordan Rose d4503da40c Unnamed bitfields don't block constant evaluation of constexpr ctors
C++14 [dcl.constexpr]p4 states that in the body of a constexpr
constructor,

> every non-variant non-static data member and base class sub-object
  shall be initialized

However, [class.bit]p2 notes that

> Unnamed bit-fields are not members and cannot be initialized.

Therefore, we should make sure to filter them out of the check that
all fields are initialized.

Fixing this makes the constant evaluator a bit smarter, and
specifically allows constexpr constructors to avoid tripping
-Wglobal-constructors when the type contains unnamed bitfields.

Reviewed at https://reviews.llvm.org/D39035.

llvm-svn: 316408
2017-10-24 02:17:07 +00:00
Erich Keane af0795b906 Fix template parameter default args missed if redecled
This bug was found via self-build on lld, and worked around
here: https://reviews.llvm.org/rL316180

The issue is that the 'using' causes the lookup to pick up the
first decl. However, when setting inherited default parameters,
we only update 'forward', not 'backward'. SO, only the newest param
list has all the information about the default arguments.

This patch ensures that the list of parameters we look through checks
the newest decl's template parameter list so it doesn't miss a default.

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

llvm-svn: 316405
2017-10-24 01:39:56 +00:00
George Karpenkov 0501f97cef [Analyzer] Fix for the memory leak: fix typo in if-statement.
llvm-svn: 316403
2017-10-24 01:09:43 +00:00
George Karpenkov 98e81cd3be [Analyzer] Handle implicit function reference in bodyfarming std::call_once
Differential Revision: https://reviews.llvm.org/D39201

llvm-svn: 316402
2017-10-24 00:13:18 +00:00
George Karpenkov 3d64d6ee54 [Analyzer] Do not use static storage to for implementations created in BodyFarm.cpp
Differential Revision: https://reviews.llvm.org/D39208

llvm-svn: 316400
2017-10-23 23:59:52 +00:00
Alexander Shaposhnikov 9a21d28b5d [analyzer] Fix handling of labels in getLValueElement
In getLValueElement Base may represent the address of a label 
(as in the newly-added test case), in this case it's not a loc::MemRegionVal 
and Base.castAs<loc::MemRegionVal>() triggers an assert, this diff makes 
getLValueElement return UnknownVal instead.

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

llvm-svn: 316399
2017-10-23 23:46:06 +00:00
Volodymyr Sapsai 30680e9437 [Sema] Add support for flexible array members in Obj-C.
Allow Obj-C ivars with incomplete array type but only as the last ivar.
Also add a requirement for ivars that contain a flexible array member to
be at the end of class too. It is possible to add in a subclass another
ivar at the end but we'll emit a warning in this case. Also we'll emit a
warning if a variable sized ivar is declared in class extension or in
implementation because subclasses won't know they should avoid adding
new ivars.

In ARC incomplete array objects are treated as __unsafe_unretained so
require them to be marked as such.

Prohibit synthesizing ivars with flexible array members because order of
synthesized ivars is not obvious and tricky to control. Spelling out
ivar explicitly gives control to developers and helps to avoid surprises
with unexpected ivar ordering.

For C and C++ changed diagnostic to tell explicitly a field is not the
last one and point to the next field. It is not as useful as in Obj-C
but it is an improvement and it is consistent with Obj-C. For C for
unions emit more specific err_flexible_array_union instead of generic
err_field_incomplete.

rdar://problem/21054495

Reviewers: rjmccall, theraven

Reviewed By: rjmccall

Subscribers: cfe-commits

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

llvm-svn: 316381
2017-10-23 22:01:41 +00:00
Petr Hosek 3e199ecdad [Driver] Use ld.lld directly for Fuchsia rather than passing flavor
Passing a flavor to LLD requires command line argument, but if these
are being passed through a response file, this will fail because LLD
needs to know which driver to use before processing the response file.
Use ld.lld directly instead to avoid this issue.

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

llvm-svn: 316379
2017-10-23 21:31:05 +00:00
Jonas Hahnfeld 4525c82428 [OpenMP] Avoid VLAs for some reductions on array sections
In some cases the compiler can deduce the length of an array section
as constants. With this information, VLAs can be avoided in place of
a constant sized array or even a scalar value if the length is 1.
Example:
int a[4], b[2];
pragma omp parallel reduction(+: a[1:2], b[1:1])
{ }

For chained array sections, this optimization is restricted to cases
where all array sections except the last have a constant length 1.
This trivially guarantees that there are no holes in the memory region
that needs to be privatized.
Example:
int c[3][4];
pragma omp parallel reduction(+: c[1:1][1:2])
{ }

This relands commit r316229 that I reverted in r316235 because it
failed on some bots. During investigation I found that this was because
Clang and GCC evaluate the two arguments to emplace_back() in
ReductionCodeGen::emitSharedLValue() in a different order, hence
leading to a different order of generated instructions in the final
LLVM IR. Fix this by passing in the arguments from temporary variables
that are evaluated in a defined order.

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

llvm-svn: 316362
2017-10-23 19:01:35 +00:00
Yaxun Liu bd3823618d CodeGen: Fix invalid bitcast in partial initialization of automatic arrary variable
Differential Revision: https://reviews.llvm.org/D39184

llvm-svn: 316353
2017-10-23 17:49:26 +00:00
Benjamin Kramer 82e2fbad41 [ASTMatchers] Expose forEachOverriden in dynamic AST matchers.
llvm-svn: 316344
2017-10-23 16:48:46 +00:00
Erich Keane 9ec60988cd Pull X86 "CPUKind" checking into .cpp file. [NFC]
Preparing to do a refactor of CPU/feature checking, this
patch pulls the one CPU implementation from the .h file
to the .cpp file.

llvm-svn: 316338
2017-10-23 16:20:15 +00:00
Nico Weber ce2d749ed3 clang-cl: Expose --version.
This is for consistency with lld-link, see https://reviews.llvm.org/D38972
Also give --version a help text so it shows up in --help / /? output (for
both clang-cl and regular clang).

llvm-svn: 316335
2017-10-23 15:54:44 +00:00
Haojian Wu 54e84b3966 [rename] Don't overwrite the template argument when renaming a template function.
Reviewers: ioeric

Reviewed By: ioeric

Subscribers: cierpuchaw, cfe-commits, klimek

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

llvm-svn: 316314
2017-10-23 08:58:50 +00:00
Richard Smith 8910fe699e For better compatibility with C++11 and C++14, emit a nondiscardable definition
of a static constexpr data member if it's defined 'constexpr' out of line, not
only if it's defined 'constexpr' in the class.

llvm-svn: 316310
2017-10-23 03:58:34 +00:00
Faisal Vali 39ff401026 [c++2a] Update cxx_status w __VA_OPT__ marked as completed in SVN.
llvm-svn: 316304
2017-10-22 22:29:52 +00:00
Benjamin Kramer 24952ce5b9 Create fewer copies of StringMaps. No functionality change intended.
llvm-svn: 316301
2017-10-22 20:16:28 +00:00
Faisal Vali 81b756e6a3 [C++17] Fix PR34970 - tweak overload resolution for class template deduction-guides in line with WG21's p0620r0.
In order to identify the copy deduction candidate, I considered two approaches:
  - attempt to determine whether an implicit guide is a copy deduction candidate by checking certain properties of its subsituted parameter during overload-resolution.
  - using one of the many bits (WillHaveBody) from FunctionDecl (that CXXDeductionGuideDecl inherits from) that are otherwise irrelevant for deduction guides

After some brittle gymnastics w the first strategy, I settled on the second, although to avoid confusion and to give that bit a better name, i turned it into a member of an anonymous union.

Given this identification 'bit', the tweak to overload resolution was a simple reordering of the deduction guide checks (in SemaOverload.cpp::isBetterOverloadCandidate), in-line with Jason Merrill's p0620r0 drafting which made it into the working paper.  Concordant with that, I made sure the copy deduction candidate is always added.


References:
See https://bugs.llvm.org/show_bug.cgi?id=34970 
See http://wg21.link/p0620r0

llvm-svn: 316292
2017-10-22 14:45:08 +00:00
Aaron Ballman 5b4f81ec14 Reverting r316278 due to failing build bots.
http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/11896
http://lab.llvm.org:8011/builders/clang-s390x-linux/builds/12380

llvm-svn: 316279
2017-10-21 21:52:48 +00:00
Masud Rahman 5b3fa2cd99 [libclang, bindings]: add spelling location
o) Add a 'Location' class that represents the four properties of a
    physical location

 o) Enhance 'SourceLocation' to provide 'expansion' and 'spelling'
    locations, maintaining backwards compatibility with existing code by
    forwarding the four properties to 'expansion'.

 o) Update the implementation to use 'clang_getExpansionLocation'
    instead of the deprecated 'clang_getInstantiationLocation', which
    has been present since 2011.

 o) Update the implementation of 'clang_getSpellingLocation' to actually
    obtain spelling location instead of file location.

llvm-svn: 316278
2017-10-21 20:53:49 +00:00
Aaron Ballman 6173655639 Fix a typo with -fno-double-square-bracket-attributes and add a test to demonstrate that it works as expected in C++11 mode. Additionally corrected the handling of -fdouble-square-bracket-attributes to be properly passed down to the cc1 option.
llvm-svn: 316275
2017-10-21 20:28:58 +00:00
Aaron Ballman 2b3bc4ce2b Add release notes for the recent -fdouble-square-bracket-attributes and -fno-double-square-bracket-attributes compiler flags.
llvm-svn: 316269
2017-10-21 16:45:08 +00:00
Roman Lebedev ca1aaacc32 [Sema] Fixes for enum handling for tautological comparison diagnostics
Summary:
As Mattias Eriksson has reported in PR35009, in C, for enums, the underlying type should
be used when checking for the tautological comparison, unlike C++, where the enumerator
values define the value range. So if not in CPlusPlus mode, use the enum underlying type.

Also, i have discovered a problem (a crash) when evaluating tautological-ness of the following comparison:
```
enum A { A_a = 0 };
if (a < 0) // expected-warning {{comparison of unsigned enum expression < 0 is always false}}
return 0;
```
This affects both the C and C++, but after the first fix, only C++ code was affected.
That was also fixed, while preserving (i think?) the proper diagnostic output.

And while there, attempt to enhance the test coverage.
Yes, some tests got moved around, sorry about that :)

Fixes PR35009

Reviewers: aaron.ballman, rsmith, rjmccall

Reviewed By: aaron.ballman

Subscribers: Rakete1111, efriedma, materi, cfe-commits

Tags: #clang

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

llvm-svn: 316268
2017-10-21 16:44:03 +00:00
Aaron Ballman f45629d2bb Fixing broken attribute documentation for __attribute__((noescape)); a code block was missing and the existing code block was missing a mandatory newline.
llvm-svn: 316267
2017-10-21 16:43:01 +00:00
Masud Rahman c739affc43 [bindings] allow null strings in Python 3
Some API calls accept 'NULL' instead of a char array (e.g. the second
argument to 'clang_ParseTranslationUnit').  For Python 3 compatibility,
all strings are passed through 'c_interop_string' which expects to
receive only 'bytes' or 'str' objects.  This change extends this
behavior to additionally allow 'None' to be supplied.

A test case was added which breaks in Python 3, and is fixed by this
change.  All the test cases pass in both, Python 2 and Python 3.

llvm-svn: 316264
2017-10-21 16:13:41 +00:00
Masud Rahman 93135cb89a Test commit
llvm-svn: 316263
2017-10-21 16:03:17 +00:00
Sanjay Patel 0c203d6b6d [CodeGen] add tests for __builtin_sqrt*; NFC
I don't know if this is correct, but this is what we currently do.
More discussion in PR27108 and PR27435 and D27618.

llvm-svn: 316250
2017-10-20 23:32:41 +00:00
George Karpenkov bd4254c692 [Analyzer] Correctly handle parameters passed by reference when bodyfarming std::call_once
Explicitly not supporting functor objects.

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

llvm-svn: 316249
2017-10-20 23:29:59 +00:00
Richard Smith 6f4f0f1865 Implement current CWG direction for support of arrays of unknown bounds in
constant expressions.

We permit array-to-pointer decay on such arrays, but disallow pointer
arithmetic (since we do not know whether it will have defined behavior).

This is based on r311970 and r301822 (the former by me and the latter by Robert
Haberlach). Between then and now, two things have changed: we have committee
feedback indicating that this is indeed the right direction, and the code
broken by this change has been fixed.

This is necessary in C++17 to continue accepting certain forms of non-type
template argument involving arrays of unknown bound.

llvm-svn: 316245
2017-10-20 22:56:25 +00:00
Jonas Hahnfeld c95a6985bd Revert "[OpenMP] Avoid VLAs for some reductions on array sections"
This breaks at least two buildbots:
http://lab.llvm.org:8011/builders/clang-cmake-x86_64-avx2-linux/builds/1175
http://lab.llvm.org:8011/builders/clang-atom-d525-fedora-rel/builds/10478

This reverts commit r316229 during local investigation.

llvm-svn: 316235
2017-10-20 20:16:17 +00:00
Jonas Hahnfeld b6229be460 [OpenMP] Avoid VLAs for some reductions on array sections
In some cases the compiler can deduce the length of an array section
as constants. With this information, VLAs can be avoided in place of
a constant sized array or even a scalar value if the length is 1.
Example:
int a[4], b[2];
pragma omp parallel reduction(+: a[1:2], b[1:1])
{ }

For chained array sections, this optimization is restricted to cases
where all array sections except the last have a constant length 1.
This trivially guarantees that there are no holes in the memory region
that needs to be privatized.
Example:
int c[3][4];
pragma omp parallel reduction(+: c[1:1][1:2])
{ }

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

llvm-svn: 316229
2017-10-20 19:40:40 +00:00
Erich Keane 87baae2162 Allow /showIncludes with /P
r213589 was checked in as a solution to
https://bugs.llvm.org/show_bug.cgi?id=20336.

However, it is possible to use /EP with /P
to suppress #line directives AND output to
a file. There is no reason in that case to
suppress /showIncludes.

This was reported here:
https://bugs.llvm.org/show_bug.cgi?id=34997

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

llvm-svn: 316225
2017-10-20 19:18:30 +00:00
Haojian Wu 55186786a9 [clang-refactor] Add "-Inplace" option to the commandline tool.
Summary:
Change clang-refactor default behavior to print the new code after refactoring
(instead of editing the source files), which would make it easier to use
and debug the refactoring action.

Reviewers: arphaman, ioeric

Reviewed By: arphaman

Subscribers: cfe-commits

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

llvm-svn: 316212
2017-10-20 12:37:16 +00:00
Ivan A. Kosarev f761d0e514 [CodeGen] Fix generation of TBAA info for array-to-pointer conversions
Resolves:
Fatal error: Offset not zero at the point of scalar access.
http://llvm.org/PR34992

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

llvm-svn: 316211
2017-10-20 12:35:17 +00:00
Saleem Abdulrasool e5696580aa Basic: restore {,u}intptr_t on NetBSD/ARM
NetBSD uses `long int` for `intptr_t` on ARM.  This was changed in SVN
r316046, referenced against other compilers.  However, NetBSD's
reference was incorrect as the current clang behaviour is more
up-to-date.  Restore the original behaviour for that target.

llvm-svn: 316204
2017-10-20 04:11:28 +00:00
Richard Smith daae9528b7 Revert r316193.
This patch breaks users using -fno-canonical-prefixes, for whom resolving
symlinks is not acceptable.

llvm-svn: 316195
2017-10-20 00:25:07 +00:00
Peter Wu 90161dad75 Try to shorten system header paths when using -MD depfiles
GCC tries to shorten system headers in depfiles using its real path
(resolving components like ".." and following symlinks). Mimic this
feature to ensure that the Ninja build tool detects the correct
dependencies when a symlink changes directory levels, see
https://github.com/ninja-build/ninja/issues/1330

An option to disable this feature is added in case "these changed header
paths may conflict with some compilation environments", see
https://gcc.gnu.org/ml/gcc-patches/2012-09/msg00287.html

Note that the original feature request for GCC
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52974) also included paths
preprocessed output (-E) and diagnostics. That is not implemented now
since I am not sure if it breaks something else.

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

llvm-svn: 316193
2017-10-19 23:53:27 +00:00
Aaron Ballman df2d839928 These attributes are not supported by GCC and should not be in the gnu namespace. Switching from the GCC spelling to the GNU spelling so that they are only supported with __attribute__(()).
llvm-svn: 316186
2017-10-19 21:20:28 +00:00
Aaron Ballman bcec5cd5a3 These attributes are supported by GCC with the gnu vendor namespace for C++11-style attributes. Enabling the gnu namespace by switching to the GCC spelling.
llvm-svn: 316184
2017-10-19 21:09:39 +00:00
Jan Vesely cda72c9c3c AMDGPU: Parse r600 CPU name early and expose FMAF capability
Improve amdgcn macro test
Differential Revision: https://reviews.llvm.org/D38667

llvm-svn: 316181
2017-10-19 20:40:13 +00:00
Guozhi Wei 769095bd07 [CGExprScalar] Add missing types in function GetIntrinsic
In function GetIntrinsic, not all types are covered. Types double and long long are missed, type long is wrongly treated same as int, it should be same as long long. These problems cause compiler crashes when compiling code in PR31161. This patch fixed the problem.

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

llvm-svn: 316179
2017-10-19 20:11:23 +00:00
Benjamin Kramer 93a1771aaf [Sema] Fix assertion failure when checking for unused variables in a dependent context.
llvm-svn: 316177
2017-10-19 19:07:13 +00:00
Erich Keane 80b0fb04a6 Fix nodiscard for volatile references
As reported here https://bugs.llvm.org/show_bug.cgi?id=34988
[[nodiscard]] warnings were not being suppressed for
volatile-ref return values.

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

llvm-svn: 316166
2017-10-19 15:58:58 +00:00
Yaxun Liu f2127d1728 [AMDGPU] Fix bug in enqueued block codegen due to an extra line
llvm-svn: 316165
2017-10-19 15:56:13 +00:00
Gabor Horvath d3a8570231 [analyzer] Dump signed integers in SymIntExpr and IntSymExpr correctly
Patch by: Adam Balogh!

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

llvm-svn: 316157
2017-10-19 11:58:21 +00:00
Haojian Wu 4fa23a100e Fix a few nits in RenamingAction.
* Add missing override keyword.
* avoid unnecessary copy of std::string.

llvm-svn: 316152
2017-10-19 08:20:55 +00:00
Martin Storsjo 5aa613ed2f [Headers] Fix typoed __ARM_DWARF_EH__ ifdefs
These typos appeared in SVN r309226 and r309327.

llvm-svn: 316149
2017-10-19 07:40:45 +00:00
Richard Smith 4309b66710 Don't suppress instantiation of definitions for variables subject to explicit
instantiation declarations if they are usable from constant expressions.

We are permitted to instantiate in these cases, and required to do so in order
to have an initializer available for use within constant evaluation.

llvm-svn: 316136
2017-10-18 22:45:01 +00:00
Erich Keane 1f7362e0fc Fix capitalization of parameter
The .cpp file has this properly capitalized, but 
the header does not.  Simply fixed it.

llvm-svn: 316132
2017-10-18 22:17:16 +00:00
Krasimir Georgiev 9da65aa858 [clang-format] Sort whole block of using declarations while partially formatting
Summary:
This patch enables sorting the full block of using declarations when
some line is affected.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

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

llvm-svn: 316130
2017-10-18 22:13:25 +00:00
Benjamin Kramer 2023e21327 [Driver] Fix use after free in Hexagon toolchain code.
No functionality change intended.

llvm-svn: 316127
2017-10-18 21:43:42 +00:00
Alex Lorenz ce781e4010 [refactor] Add a doc comment to the test function in the selection
unittest.

As suggested by Haojian Wu!

llvm-svn: 316105
2017-10-18 18:51:48 +00:00
Alex Lorenz cd6c78386f [refactor] selection: new CodeRangeASTSelection represents a set of selected
consecutive statements

This commit adds a CodeRangeASTSelection value to the refactoring library. This
value represents a set of selected statements in one body of code.

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

llvm-svn: 316104
2017-10-18 18:48:58 +00:00
Matt Morehouse 54ffd1cfe8 [clang-proto-fuzzer] Use ToT protobuf-mutator.
llvm-svn: 316103
2017-10-18 18:38:04 +00:00
Sumanth Gundapaneni 57098f5ac3 [Hexagon] Handling of new HVX flags and target-features
This patch has the following changes
A new flag "-mhvx-length={64B|128B}" is introduced to specify the length of the vector.
Previously we have used "-mhvx-double" for 128 Bytes. This adds the target-feature "+hvx-length{64|128}b"

The "-mhvx" flag must be provided on command line to enable HVX for Hexagon. If no -mhvx-length flag
is specified, a default length is picked from the arch mentioned in this priority order from either -mhvx=vxx
or -mcpu. For v60 and v62 the default length is 64 Byte. For unknown versions, the length is 128 Byte. The 
-mhvx flag adds the target-feature "+hvxv{hvx_version}"

The 64 Byte mode is soon going to be deprecated. A warning is emitted if 64 Byte is enabled. A warning is
still emitted for the default 64 Byte as well. This warning can be suppressed with a -Wno flag.

The "-mhvx-double" and "-mno-hvx-double" flags are deprecated. A warning is emitted if the driver sees
them on commandline. "-mhvx-double" is an alias to "-mhvx-length=128B"

The compilation will error out if -mhvx-length is specified with out an -mhvx/-mhvx= flag

The macro HVX_LENGTH is defined and is set to the length of the vector. 
Eg: #define HVX_LENGTH 64

The macro HVX_ARCH is defined and is set to the version of the HVX. 
Eg: #define HVX_ARCH 62

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

llvm-svn: 316102
2017-10-18 18:10:13 +00:00
Aaron Ballman 15d267bb75 Enable support for the [[maybe_unused]] attribute from WG14 N2053 when enabling double square bracket attributes in C code.
llvm-svn: 316096
2017-10-18 16:59:27 +00:00
Aaron Ballman 8eab4e5856 Silencing a redefinition warning that was not germane to the test.
llvm-svn: 316086
2017-10-18 14:48:33 +00:00
Aaron Ballman 8c6b1a3bf2 Enable support for the [[fallthrough]] attribute from WG14 N2052 when enabling double square bracket attributes in C code.
llvm-svn: 316083
2017-10-18 14:33:27 +00:00
Aaron Ballman 4ff3b5ab10 Silence -Wimplicit-fallthrough warnings with the generated code; NFC.
llvm-svn: 316075
2017-10-18 12:11:58 +00:00
Haojian Wu c906390163 [clang-rename] Rename alias.
Summary:
* Support rename alias.
* Add unittests for renaming alias.
* Don't generate fixes for the SourceLocations that are invalid or in temporary
  buffer, otherwise crash would be happened when generating AtomicChanges.

Reviewers: ioeric

Reviewed By: ioeric

Subscribers: klimek, mgorny, cfe-commits

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

llvm-svn: 316074
2017-10-18 12:10:11 +00:00
Gabor Horvath 480892b75f [ASTImporter] Import SubStmt of CaseStmt
Patch by: Rafael Stahl!

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

llvm-svn: 316069
2017-10-18 09:25:18 +00:00
NAKAMURA Takumi d97398240c [CMake] Use #cmakedefine01 for CLANG_ENABLE_(ARCMT|OBJC_REWRITER|STATIC_ANALYZER)
It'd be better that they are #cmakedefine01 rather than #cmakedefine.
(#if FOO rather than #if defined(FOO))
Then we can find missing #include "clang/Config/config.h" in the future.

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

llvm-svn: 316061
2017-10-18 05:21:17 +00:00
Richard Smith f90b6f197c Provide a flag group to turn on/off all "binary literals" extension warnings.
llvm-svn: 316056
2017-10-18 02:19:24 +00:00
Richard Smith 17ad3ac2aa [modules] When finding the owning module of an instantiated context in template
instantiation, follow lexical parents not semantic ones: we want to find the
module where the pattern was written.

llvm-svn: 316055
2017-10-18 01:41:38 +00:00
Petr Hosek 9e148e9590 [CMake] Build Fuchsia toolchain as -O3
Differential Revision: https://reviews.llvm.org/D39017

llvm-svn: 316053
2017-10-18 01:27:54 +00:00
Saleem Abdulrasool 8d799f8ef9 Basic: fix __{,U}INTPTR_TYPE__ on ARM
Darwin and OpenBSD are the only platforms which use `long int` for
`__INTPTR_TYPE__`.  The other platforms use `int` in 32-bit, and `long
int` on 64-bit (except for VMS and Windows which are LLP64).  Adjust the
type definitions to match the platform definitions.  We now generate the
same definition as GCC on all the targets.

llvm-svn: 316046
2017-10-18 00:00:50 +00:00
Zachary Turner 8eb7005e21 Resubmit "[lit] Raise the logic for enabling clang & lld substitutions to llvm."
The substitution for %debuginfo_tests had been inadvertently removed.
This adds it back.

llvm-svn: 316043
2017-10-17 23:43:36 +00:00
Saleem Abdulrasool f78f7c05d4 Basic: fix `__INTPTR_TYPE__` for Windows ARM
The `IntPtrType` for Windows ARM should be `int` as per MSVC.  Adjust
the type accordingly.

llvm-svn: 316042
2017-10-17 22:49:53 +00:00
George Karpenkov b2a60c6a9b [Analyzer] Always use non-reference types when creating expressions in BodyFarm.
Remove an option to use a reference type (on by default!) since a
non-reference type is always needed for creating expressions, functions
with multiple boolean parameters are very hard to use, and in general it
was just a booby trap for further crashes.
Furthermore, generalize call_once test case to fix some of the crashes mentioned
https://bugs.llvm.org/show_bug.cgi?id=34869
Also removes std::call_once crash.

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

llvm-svn: 316041
2017-10-17 22:28:18 +00:00
Nico Weber 3dc67a1d8a Fix PR34981, a crash-on-invalid merging dllimport to an invalid redecl.
This is basically like r288207, just the other way round.

llvm-svn: 316032
2017-10-17 21:14:02 +00:00
Erich Keane 8e61b3e50c [CFG] Relax Wexceptions warning on rethrow
As reported here: https://bugs.llvm.org/show_bug.cgi?id=34973

"catch(...)" should catch EVERYTHING, even a rethrow. This
patch changes the order in which things are checked to ensure
that a '...' catch will get a rethrow.

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

llvm-svn: 316030
2017-10-17 20:57:24 +00:00
Aaron Ballman b95dc1f794 This test case was missing -fsyntax-only, so I've added it. NFC to the actual test contents, just how the test is executed.
llvm-svn: 316028
2017-10-17 20:49:30 +00:00
Aaron Ballman 35713eba56 Enable support for the [[nodiscard]] attribute from WG14 N2050 when enabling double square bracket attributes in C code.
llvm-svn: 316026
2017-10-17 20:33:35 +00:00
Vassil Vassilev 4068fc1b28 Expose ConsumeAnyToken interface to external clients.
llvm-svn: 316022
2017-10-17 19:38:57 +00:00
Bruno Cardoso Lopes 9e5751894d [OpenCL] Restrict swizzle length check to OpenCL mode
Changes behavior introduced in r298369 to only error out on
vector component invalid length access on OpenCL mode.

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

rdar://problem/33568748

llvm-svn: 316016
2017-10-17 17:54:57 +00:00
Erich Keane cbb287c2ec Replace use of SmallVector::back + pop_back with pop_back_val
I ran across an instance where the value was being loaded
out via back, then immediately popped.  Since pop_back_val
is more efficient at this (it moves out), replace this 
instance.

llvm-svn: 316015
2017-10-17 17:45:21 +00:00
Saleem Abdulrasool a01ed93e8c Sema: use new `getNS{,U}IntegerType` for NS{,U}Integer
Use the new helper methods to get the underlying type for NSUInteger,
NSInteger types.  This avoids spreading the knowledge of the underlying
types in various sites.  For non-LLP64 targets, this has no change.

llvm-svn: 316013
2017-10-17 17:39:32 +00:00
Alexey Bataev 7ba57afd6e [OPENMP] Fix capturing of boolean variables in debug mode.
If the variables is boolean and we generating inner function with real
types, the codegen may crash because of not loading boolean value from
memory.

llvm-svn: 316011
2017-10-17 16:47:34 +00:00
Jonas Hahnfeld 23604a8399 [OpenMP] Implement omp_is_initial_device() as builtin
This allows to return the static value that we know at compile time.

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

llvm-svn: 316001
2017-10-17 14:28:14 +00:00
Yaxun Liu 8ab5ab066a CodeGen: Fix invalid bitcasts for atomic builtins
Currently clang assumes the temporary variables emitted during
codegen of atomic builtins have address space 0, which
is not true for target triple amdgcn---amdgiz and causes invalid
bitcasts.

This patch fixes that.

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

llvm-svn: 316000
2017-10-17 14:19:29 +00:00
Haojian Wu 63c7c040bc [clang-rename] Rename enum.
Summary:
* Add unit tests for renaming enum.
* Support unscoped enum constants in expressions.

Reviewers: ioeric

Reviewed By: ioeric

Subscribers: klimek, mgorny, cfe-commits

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

llvm-svn: 315999
2017-10-17 14:14:41 +00:00
Jonas Hahnfeld 30b4418e5a [CMake][OpenMP] Customize default offloading arch
For the shuffle instructions in reductions we need at least sm_30
but the user may want to customize the default architecture.

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

llvm-svn: 315996
2017-10-17 13:37:36 +00:00
Ivan A. Kosarev 17db3a10f5 [CodeGen] Refine generation of TBAA info for bit-field lvalues
The main change is that now we generate TBAA info before
constructing the resulting lvalue instead of constructing lvalue
with some default TBAA info and fixing it as necessary
afterwards. We also keep the TBAA info close to lvalue base info,
which is supposed to simplify their future merging.

This patch should not bring in any functional changes.

This is part of D38126 reworked to be a separate patch to
simplify review.

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

llvm-svn: 315989
2017-10-17 11:20:19 +00:00
Ivan A. Kosarev d17f12a35d [CodeGen] Pass TBAA info along with lvalue base info everywhere
This patch addresses the rest of the cases where we pass lvalue
base info, but do not provide corresponding TBAA info.

This patch should not bring in any functional changes.

This is part of D38126 reworked to be a separate patch to make
reviewing easier.

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

llvm-svn: 315986
2017-10-17 10:17:43 +00:00
Ivan A. Kosarev ed141bab63 [CodeGen] EmitPointerWithAlignment() to generate TBAA info along with LValue base info
Differential Revision: https://reviews.llvm.org/D38796

llvm-svn: 315984
2017-10-17 09:12:13 +00:00
Vedant Kumar 341bf42991 [Coverage] Discard deferred region in closing if-else
A trailing deferred region isn't necessary in a function that ends with
this pattern:

  ...
  else {
    ...
    return;
  }

Special-case this pattern so that the closing curly brace of the
function isn't marked as uncovered. This issue came up in PR34962.

llvm-svn: 315982
2017-10-17 07:47:39 +00:00
Vedant Kumar e5f06a81a8 [Coverage] Explicitly mark the l.h.s of && and || (fixes PR33465)
This makes it possible to view sub-line region counts for the l.h.s of
&& and || expressions in coverage reports.

It also fixes PR33465, which shows an example of incorrect coverage
output for an assignment statement containing '||'.

llvm-svn: 315979
2017-10-17 06:51:54 +00:00
Saleem Abdulrasool 4e319ca894 Basic: make the nan family pure
The nan family of math routines do not rely on global state.  They do
however depend on their parameter.  This fits the description of pure:
  Functions which have no effects except the return value and their
  return value depends only on the parameters and/or global variables.
Mark the family as `readonly`.

llvm-svn: 315968
2017-10-17 03:30:25 +00:00
Jonathan Coe 1fada3b90a [libclang] Add support for querying cursor availability
Summary:
This patch allows checking the availability of cursors through libclang and clang.cindex (Python).
This e.g. allows to check whether a C++ member function has been marked as deleted.

Reviewers: arphaman, jbcoe

Reviewed By: jbcoe

Subscribers: cfe-commits

Tags: #clang

Patch by jklaehn (Johann Klähn)

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

llvm-svn: 315959
2017-10-16 23:46:02 +00:00
Jonathan Coe 578ac7a2ec [libclang] Visit attributes for function and class templates
Summary: Previously, `VisitAttributes` was not called for function and class templates and thus their attributes were not accessible using libclang.

Reviewers: bkramer, arphaman, rsmith, jbcoe

Reviewed By: jbcoe

Subscribers: cfe-commits

Tags: #clang

Patch by jklaehn (Johann Klähn)

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

llvm-svn: 315958
2017-10-16 23:43:02 +00:00
Erich Keane 3bff414cde Fix usage in TableGen of getValueAsString
Record::getValueAsString returns a stringref to an interned
string (apparently had been changed since most of tablegen was
written). In this patch, I audited the usage of getValueAsString
to find places where we can trivially stop storing 'std::string' and instead
keep the stringref.

There was one instance where an unnecessary 'stringstream' was being used,
so that has been removed as well to unblock the stringref replacing string fix.

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

llvm-svn: 315956
2017-10-16 23:25:24 +00:00
Reid Kleckner 400a64e81b Don't print end-of-directive tokens in -E output
This comes up when pre-processing standalone .s files containing
hash-prefixed comments. The pre-processor should skip the unknown
directive and not emit an extra newline as we were doing.

Fixes PR34950

llvm-svn: 315953
2017-10-16 23:07:15 +00:00
George Burgess IV 31ac1fae68 Make __builtin_types_compatible_p more like GCC's
GCC ignore qualifiers on array types. Since we seem to have this
function primarily for GCC compatibility, we should try to match that
behavior.

This also adds a few more test-cases __builtin_types_compatible_p,
which were inspired by GCC's documentation on the builtin.

llvm-svn: 315951
2017-10-16 22:58:37 +00:00
Erich Keane df9e8aef6d Replace usage of std::stringstream with raw_string_ostream
Typically we don't use the stringstream, so instead use
raw_string_stream.  Additionally, the dependent function
changed to use raw_ostream.

llvm-svn: 315950
2017-10-16 22:47:26 +00:00
Erich Keane 038f4ea367 Remove AnyX86Interrupt documentation
This documentation was copied directly from the GCC
documentaiton in r257867.  Reverting and alterting
the original author so that it can be rewritten in
copyright-safe language.

llvm-svn: 315934
2017-10-16 20:44:14 +00:00
Erich Keane a98a2be869 Sort Attributes by "HeaderName"
Attributes in the docs were previously sorted (apparently)
by the attribute name, so AnyX86Interrupt ended up being the
first one, rather than in a meaningful place. This resulted in the
4 'interrupt' titled sections being all in different places.

This replaces it with a naive alphabetical sort (case sensitive, underscore
and special characters first, etc).

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

llvm-svn: 315931
2017-10-16 20:31:05 +00:00
Erich Keane c15f4b9fa7 Clarify the 'interrupt' names in Attribute Docs
All 4 of the 'interrupt' headers were automatically named
'interrupt'. This patch gives them unique names.

llvm-svn: 315929
2017-10-16 20:13:36 +00:00
Alex Lorenz f5ca27cc37 [refactor] allow the use of refactoring diagnostics
This commit allows the refactoring library to use its own set of
refactoring-specific diagnostics to reports things like initiation errors.

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

llvm-svn: 315924
2017-10-16 18:28:26 +00:00
Alex Lorenz 528435002a clang-refactor: Use llvm_unreachable in an unused override
As suggested by David Blaikie!

llvm-svn: 315923
2017-10-16 18:07:16 +00:00
Evgeniy Stepanov d5d36a162d Do not link clang_rt.cfi on Android.
Summary:
The OS provides cross-dso CFI support starting with Android O.
Trapping mode does not require any runtime at all, and diagnostic mode
requires just ubsan-standalone.

Reviewers: pcc

Subscribers: srhines, cfe-commits

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

llvm-svn: 315921
2017-10-16 18:02:57 +00:00
Alex Lorenz e1b7b95901 Recommit r315738 "[clang-refactor] Apply source replacements"
The fixed commit ensures that ParsedSourceRange works correctly
with Windows paths.

Original message:

This commit actually brings clang-refactor to a usable state as it can now
apply the refactoring changes to source files.
The -selection option is now also fully supported.

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

llvm-svn: 315918
2017-10-16 17:31:16 +00:00
Wei Mi 9b3d627280 [Bitfield] Add an option to access bitfield in a fine-grained manner.
Currently all the consecutive bitfields are wrapped as a large integer unless there is unamed zero sized bitfield in between. The patch provides an alternative manner which makes the bitfield to be accessed as separate memory location if it has legal integer width and is naturally aligned. Such separate bitfield may split the original consecutive bitfields into subgroups of consecutive bitfields, and each subgroup will be wrapped as an integer. Now This is all controlled by an option -ffine-grained-bitfield-accesses. The alternative of bitfield access manner can improve the access efficiency of those bitfields with legal width and being aligned, but may reduce the chance of load/store combining of other bitfields, so it depends on how the bitfields are defined and actually accessed to choose when to use the option. For now the option is off by default.

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

llvm-svn: 315915
2017-10-16 16:50:27 +00:00
Jonas Hahnfeld e2c342fc65 [CUDA] Require libdevice only if needed
If the user passes -nocudalib, we can live without it being present.
Simplify the code by just checking whether LibDeviceMap is empty.

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

llvm-svn: 315902
2017-10-16 13:31:30 +00:00
Haojian Wu 6f60ff84cd [clang-rename] Add function unit tests.
Summary:
Also contain a fix:

* Fix a false positive of renaming a using shadow function declaration.

Reviewers: ioeric

Reviewed By: ioeric

Subscribers: klimek, mgorny, cfe-commits

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

llvm-svn: 315898
2017-10-16 10:37:42 +00:00
Krasimir Georgiev 35599fdfa0 [clang-format] Break non-trailing comments, try 2
Summary:
This patch enables `BreakableToken` to manage the formatting of non-trailing
block comments. It is a refinement of https://reviews.llvm.org/D37007.
We discovered that the optimizer outsmarts us on cases where breaking the comment
costs considerably less than breaking after the comment. This patch addresses
this by ensuring that a newline is inserted between a block comment and the next
token.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

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

llvm-svn: 315893
2017-10-16 09:08:53 +00:00
Roman Lebedev 6de129e710 [Sema] Re-land: Diagnose tautological comparison with type's min/max values
The first attempt, rL315614 was reverted because one libcxx
test broke, and i did not know at the time how to deal with it.

Summary:
Currently, clang only diagnoses completely out-of-range comparisons (e.g. `char` and constant `300`),
and comparisons of unsigned and `0`. But gcc also does diagnose the comparisons with the
`std::numeric_limits<>::max()` / `std::numeric_limits<>::min()` so to speak

Finally Fixes https://bugs.llvm.org/show_bug.cgi?id=34147
Continuation of https://reviews.llvm.org/D37565

Reviewers: rjmccall, rsmith, aaron.ballman

Reviewed By: rsmith

Subscribers: rtrieu, jroelofs, cfe-commits

Tags: #clang

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

llvm-svn: 315875
2017-10-15 20:13:17 +00:00
Alexander Richardson 6d989436d0 Convert clang::LangAS to a strongly typed enum
Summary:
Convert clang::LangAS to a strongly typed enum

Currently both clang AST address spaces and target specific address spaces
are represented as unsigned which can lead to subtle errors if the wrong
type is passed. It is especially confusing in the CodeGen files as it is
not possible to see what kind of address space should be passed to a
function without looking at the implementation.
I originally made this change for our LLVM fork for the CHERI architecture
where we make extensive use of address spaces to differentiate between
capabilities and pointers. When merging the upstream changes I usually
run into some test failures or runtime crashes because the wrong kind of
address space is passed to a function. By converting the LangAS enum to a
C++11 we can catch these errors at compile time. Additionally, it is now
obvious from the function signature which kind of address space it expects.

I found the following errors while writing this patch:

- ItaniumRecordLayoutBuilder::LayoutField was passing a clang AST address
  space to  TargetInfo::getPointer{Width,Align}()
- TypePrinter::printAttributedAfter() prints the numeric value of the
  clang AST address space instead of the target address space.
  However, this code is not used so I kept the current behaviour
- initializeForBlockHeader() in CGBlocks.cpp was passing
  LangAS::opencl_generic to TargetInfo::getPointer{Width,Align}()
- CodeGenFunction::EmitBlockLiteral() was passing a AST address space to
  TargetInfo::getPointerWidth()
- CGOpenMPRuntimeNVPTX::translateParameter() passed a target address space
  to Qualifiers::addAddressSpace()
- CGOpenMPRuntimeNVPTX::getParameterAddress() was using
  llvm::Type::getPointerTo() with a AST address space
- clang_getAddressSpace() returns either a LangAS or a target address
  space. As this is exposed to C I have kept the current behaviour and
  added a comment stating that it is probably not correct.

Other than this the patch should not cause any functional changes.

Reviewers: yaxunl, pcc, bader

Reviewed By: yaxunl, bader

Subscribers: jlebar, jholewinski, nhaehnle, Anastasia, cfe-commits

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

llvm-svn: 315871
2017-10-15 18:48:14 +00:00
Martell Malone 4806f70060 Fix test case regresstion from rL315864
The patch should have been checking against STDCXX17 not STDCXX14.

llvm-svn: 315868
2017-10-15 18:01:28 +00:00
Martell Malone e5639e9dd9 Driver: use ld64.lld when -fuse-ld=lld for darwin
When using lld on macOS the current level of detection between ld and
ld64 forces us to rename lld to ld.

For ELF targets we have the ld.lld alias so for MACHO we should have
ld64.lld so we can use lld without replacing the system compiler.

This also solves the additional issue of cross compiling for MACHO
where renaming lld to ld with only target ELF.

This is the clang driver component change to use this new alias.

Reviewers: ruiu, rnk

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

llvm-svn: 315867
2017-10-15 17:53:45 +00:00
Martell Malone f6f6a9c199 [driver] [cl] Add/fix c++17/c++latest
Patch by: daxpedda

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

llvm-svn: 315864
2017-10-15 17:27:58 +00:00
Aaron Ballman 606093a53b Add -f[no-]double-square-bracket-attributes as new driver options to control use of [[]] attributes in all language modes. This is the initial implementation of WG14 N2165, which is a proposal to add [[]] attributes to C2x, but also allows you to enable these attributes in C++98, or disable them in C++11 or later.
llvm-svn: 315856
2017-10-15 15:01:42 +00:00
Benjamin Kramer 8b54a1c686 [Lex] Remove unused variables. No functionality change.
llvm-svn: 315845
2017-10-15 04:27:37 +00:00
Faisal Vali b7c0b089f2 [c++2a] Fix failing regression test related to not adding the extension warning to a diagnostic group (in r315840)
In passing also complete a comment that I left uncompleted.

For ease of reference, here's the parent commit: https://reviews.llvm.org/rL315840

llvm-svn: 315842
2017-10-15 02:13:17 +00:00
Faisal Vali 1826842865 [c++2a] Implement P0306 __VA_OPT__ (Comma omission and comma deletion)
This patch implements an extension to the preprocessor:

__VA_OPT__(contents) --> which expands into its contents if variadic arguments are supplied to the parent macro, or behaves as an empty token if none.

  - Currently this feature is only enabled for C++2a (this could be enabled, with some careful tweaks, for other dialects with the appropriate extension or compatibility warnings)

  - The patch was reviewed here: https://reviews.llvm.org/D35782 and asides from the above (and moving some of the definition and expansion recognition logic into the corresponding state machines), I believe I incorporated all of Richard's suggestions.

A few technicalities (most of which were clarified through private correspondence between rsmith, hubert and thomas) are worth mentioning.  Given:

    #define F(a,...) a #__VA_OPT__(a ## a)  a ## __VA_OPT__(__VA_ARGS__)

    - The call F(,) Does not supply any tokens for the variadic arguments and hence VA_OPT behaves as a placeholder.
    - When expanding VA_OPT (for e.g. F(,1) token pasting occurs eagerly within its contents if the contents need to be stringified.
    - A hash or a hashhash prior to VA_OPT does not inhibit expansion of arguments if they are the first token within VA_OPT.
    - When a variadic argument is supplied, argument substitution occurs within the contents as does stringification - and these resulting tokens are inserted back into the macro expansions token stream just prior to the entire stream being rescanned and concatenated.

See wg21.link/P0306 for further details on the feature.


Acknowledgment: This patch would have been poorer if not for Richard Smith's usual thoughtful analysis and feedback.
llvm-svn: 315840
2017-10-15 01:26:26 +00:00
Konstantin Zhuravlyov 202c1b715f Revert "Mark test as unsupported until r315808 is fixed"
Test is fixed in r315830

llvm-svn: 315831
2017-10-14 22:24:31 +00:00
Bruno Cardoso Lopes b37d05c9c1 Mark test as unsupported until r315808 is fixed
This is causing:
http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/43381

llvm-svn: 315829
2017-10-14 22:14:23 +00:00
Benjamin Kramer 2b8ad7312d Re-land r315787, "[Sema] Warn about unused variables if we can constant evaluate the initializer."
The warnings in libc++ tests were fixed in the meantime.

llvm-svn: 315811
2017-10-14 15:59:34 +00:00
NAKAMURA Takumi 93638b751a Revert rL315787, "[Sema] Warn about unused variables if we can constant evaluate the initializer."
check-libcxx dislikes it.

llvm-svn: 315806
2017-10-14 14:46:04 +00:00
Yaxun Liu 98f0c43f85 Fix build failure on android due to missing std::to_string()
llvm-svn: 315805
2017-10-14 12:51:52 +00:00
Yaxun Liu c2a87a05f1 [OpenCL] Emit enqueued block as kernel
In OpenCL the kernel function and non-kernel function has different calling conventions.
For certain targets they have different argument ABIs. Also kernels have special function
attributes and metadata for runtime to launch them.

The blocks passed to enqueue_kernel is supposed to be executed as kernels. As such,
the block invoke function should be emitted as kernel with proper calling convention and
argument ABI.

This patch emits enqueued block as kernel. If a block is both called directly and passed
to enqueue_kernel, separate functions will be generated.

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

llvm-svn: 315804
2017-10-14 12:23:50 +00:00
Benjamin Kramer 819ec01ce3 [Sema] Warn about unused variables if we can constant evaluate the initializer.
If the variable construction can be constant evaluated it doesn't have
side effects, so removing it is always safe. We only try to evaluate
variables that are unused, there should be no impact on compile time.

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

llvm-svn: 315787
2017-10-14 01:30:49 +00:00
Vedant Kumar aa4ea5fb45 [ubsan] Don't emit function signatures for non-static member functions
The function sanitizer only checks indirect calls through function
pointers. This excludes all non-static member functions (constructor
calls, calls through thunks, etc. all use a separate code path). Don't
emit function signatures for functions that won't be checked.

Apart from cutting down on code size, this should fix a regression on
Linux caused by r313096. For context, see the mailing list discussion:

r313096 - [ubsan] Function Sanitizer: Don't require writable text segments

Testing: check-clang, check-ubsan

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

llvm-svn: 315786
2017-10-14 01:23:30 +00:00
Alex Lorenz d5bf436d3a [Lex] Avoid out-of-bounds dereference in SkipLineComment
Credit to OSS-Fuzz for discovery:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=3145

rdar://34526482

llvm-svn: 315785
2017-10-14 01:18:30 +00:00
Richard Smith 40e202f7d9 Fix backwards warning for use of C++17 attributes-on-namespaces-and-enumerators feature.
llvm-svn: 315784
2017-10-14 00:56:24 +00:00
George Karpenkov cb24b14995 Allow building libFuzzer tests in two-stage compiler-rt build.
llvm-svn: 315776
2017-10-13 23:50:53 +00:00
Alex Lorenz 9ce566fc18 Revert r315738
The ParsedSourceRange class does not work correctly on Windows with the ':'
drive separators

llvm-svn: 315774
2017-10-13 22:47:44 +00:00
Benjamin Kramer 17ba669ad9 [Sema] Avoid iterator invalidation when code completing.
It's possible for the code completion consumer to add new decls to the
current scope while lookup happens on it. Avoid this by making a copy
first.

Sadly I wasn't able to get a self-contained test case for this as it
requires code completion + precompiled preamble + the stars aligning to
deserialize at exactly the right time.

llvm-svn: 315772
2017-10-13 22:14:34 +00:00
George Karpenkov a3cd5247b3 Allow building libFuzzer in two-stage compiler-rt build
When LLVM_BUILD_EXTERNAL_COMPILER_RT option is set to true,
all of projects in compiler-rt are built with a freshly-built compiler using
a recursive CMake invocation.
(e.g. that's how compiler-rt is used in Swift)

Just now I have noticed that libFuzzer binaries were missing in such a case,
and ninja fuzzer returned "no such target", while ninja asan worked just fine.

To my surprise, the list of allowed targets was actually hardcoded in Clang!
While the current setup is clearly suboptimal, for the lack of a better fix
I'm just adding `fuzzer` to a list of `compiler-rt` targets.

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

llvm-svn: 315771
2017-10-13 22:03:09 +00:00
Alex Lorenz 3e3dd1dbd7 Fix -Woverloaded-virtual warning in clang-refactor
llvm-svn: 315755
2017-10-13 21:15:25 +00:00
Artem Dergachev cd25c38dc0 [analyzer] pr28449: Fix support for various array initializers.
In some cases the analyzer didn't expect an array-type variable to be
initialized with anything other than a string literal. The patch essentially
removes the assertion, and ensures relatively sane behavior.

There is a bigger problem with these initializers. Currently our memory model
(RegionStore) is being ordered to initialize the array with a region that
is assumed to be storing the initializer rvalue, and it guesses to copy
the contents of that region to the array variable. However, it would make
more sense for RegionStore to receive the correct initializer in the first
place. This problem isn't addressed with this patch.

rdar://problem/27248428
Differential Revision: https://reviews.llvm.org/D23963

llvm-svn: 315750
2017-10-13 20:54:56 +00:00
Artem Dergachev db65f969f2 [analyzer] CStringChecker: pr34460: Avoid a crash when a cast is not modeled.
The checker used to crash when a mempcpy's length argument is symbolic. In this
case the cast from 'void *' to 'char *' failed because the respective
ElementRegion that represents cast is hard to add on top of the existing
ElementRegion that represents the offset to the last copied byte, while
preseving a sane memory region structure.

Additionally, a few test cases are added (to casts.c) which demonstrate problems
caused by existing sloppy work we do with multi-layer ElementRegions. If said
cast would be modeled properly in the future, these tests would need to be
taken into account.

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

llvm-svn: 315742
2017-10-13 20:11:00 +00:00
Saleem Abdulrasool 52dbdc04fe Basic: adjust attributes on `nan` LIBBUILTINs
The `nan` family of functions will inspect the contents of the parameter
that they are passed. As a result, the function cannot be annotated as
`const`.  The documentation of the `const` attribute explicitly states
this:
  Note that a function that has pointer arguments and examines the data
  pointed to must not be declared const.
Adjust the annotations on this family of functions.

llvm-svn: 315741
2017-10-13 20:07:30 +00:00
Ivan A. Kosarev ce601eedf6 Revert "[CodeGen] EmitPointerWithAlignment() to generate TBAA info along with LValue base info", r315731.
With this change we fail on the clang-x86_64-linux-selfhost-modules builder.

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

llvm-svn: 315739
2017-10-13 19:55:01 +00:00
Alex Lorenz 57e060b309 [clang-refactor] Apply source replacements
This commit actually brings clang-refactor to a usable state as it can now
apply the refactoring changes to source files.
The -selection option is now also fully supported.

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

llvm-svn: 315738
2017-10-13 19:42:05 +00:00
Artem Dergachev 2041cbdcf5 [analyzer] RetainCount: Ignore annotations on user-made CFRetain wrappers.
It is not uncommon for the users to make their own wrappers around
CoreFoundation's CFRetain and CFRelease functions that are defensive
against null references. In such cases CFRetain is often incorrectly
marked as CF_RETURNS_RETAINED. Ignore said annotation and treat such
wrappers similarly to the regular CFRetain.

rdar://problem/31699502
Differential Revision: https://reviews.llvm.org/D38877

llvm-svn: 315736
2017-10-13 19:10:42 +00:00
Ivan A. Kosarev 0e528202b8 [CodeGen] EmitPointerWithAlignment() to generate TBAA info along with LValue base info
Differential Revision: https://reviews.llvm.org/D38796

llvm-svn: 315731
2017-10-13 18:40:18 +00:00
Craig Topper 9c6a31ae1d [X86] Remove 'knm' defines from predefined-arch-macros.c test.
Direction seems to be that we dont' want to keep adding these, but I forgot to remove it from the test before I committed r315723.

llvm-svn: 315729
2017-10-13 18:38:10 +00:00
Craig Topper f8c10aa3a3 [X86] Add skeleton support for knm cpu
This adds support Knights Mill CPU. Preprocessor defines match gcc's implementation.

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

llvm-svn: 315723
2017-10-13 18:14:24 +00:00
Ivan A. Kosarev cbee219700 [CodeGen] emitOMPArraySectionBase() to generate TBAA info along with LValue base info
Differential Revision: https://reviews.llvm.org/D38795

llvm-svn: 315715
2017-10-13 17:34:18 +00:00
Bruno Cardoso Lopes 7ccaff7db0 Revert "[lit] Raise the logic for enabling clang & lld substitutions to llvm."
This reverts commit r315627, fixing bot failures:
http://green.lab.llvm.org/green/job/clang-stage1-configure-RA

LIT is failing to properly apply substitution to debuginfo-tests
after this change.

rdar://problem/34979568

llvm-svn: 315712
2017-10-13 17:11:13 +00:00
Ivan A. Kosarev 78f486d136 [CodeGen] getNaturalTypeAlignment() to generate TBAA info along with LValue base info
This patch should not bring in any functional changes.

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

llvm-svn: 315708
2017-10-13 16:58:30 +00:00
Reid Kleckner 65fa869c23 [SEH] Use the SEH personality on frontend-outlined funclets
This allows __try inside __finally to work.

Fixes PR34939

llvm-svn: 315707
2017-10-13 16:55:14 +00:00