Commit Graph

29489 Commits

Author SHA1 Message Date
Akira Hatanaka 642f799b0d [CodeGen][ObjC] Do not call objc_storeStrong when initializing a
constexpr variable.

When compiling a constexpr NSString initialized with an objective-c
string literal, CodeGen emits objc_storeStrong on an uninitialized
alloca, which causes a crash.

This patch folds the code in EmitScalarInit into EmitStoreThroughLValue
and fixes the crash by calling objc_retain on the string instead of
using objc_storeStrong.

rdar://problem/28562009

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

llvm-svn: 284516
2016-10-18 19:05:41 +00:00
Erik Pilkington d080746c19 Revert r284265 "[Sema] Refactor context checking for availability diagnostics"
This has a bug in it, pointed out by Bob Wilson!

llvm-svn: 284486
2016-10-18 15:26:43 +00:00
Daniel Marjamaki fa1bf447d9 alpha.core.UnreachableCode - don't warn about unreachable code inside macro
In macros, 'do {...} while (0)' is often used. Don't warn about the condition 0 when it is unreachable.

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

llvm-svn: 284477
2016-10-18 13:16:53 +00:00
Artem Dergachev 940c770d27 [analyzer] Add NumberObjectConversion checker.
When dealing with objects that represent numbers, such as Objective-C NSNumber,
the language provides little protection from accidentally interpreting
the value of a pointer to such object as the value of the number represented
by the object. Results of such mis-interpretation may be unexpected.

The checker attempts to fill this gap in cases when the code is obviously
incorrect.

With "Pedantic" option enabled, this checker enforces a coding style to
completely prevent errors of this kind (off by default).

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

llvm-svn: 284473
2016-10-18 11:06:28 +00:00
Alex Lorenz f0b4e5db16 [CodeCompletion] Add a block property setter completion result
This commit changes code completion results for Objective-C block properties:
clang now suggests an additional completion result that displays the block
property together with '=' and the block literal placeholder for the appropriate
readwrite block properties.

This commit uses a simple heuristic to determine when it's appropriate to
suggest a setter completion for block properties: the additional block setter
completion is provided iff the member access that's being completed is a
standalone statement.

rdar://28481726

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

llvm-svn: 284472
2016-10-18 10:55:01 +00:00
Richard Smith 391fb8662a [c++1z] Include "noexcept" in builtin function types where appropriate. Fixes
an assertion failure looking up a matching ::operator delete for
__builtin_operator_delete.

llvm-svn: 284458
2016-10-18 07:13:55 +00:00
Richard Smith 99677afd54 [c++1z] Use canonical expression equivalence to determine whether two different
dependent noexcept specifications result in the same canonical function type.

We still use non-canonical hashing when deduplicating type sugar so that
diagnostics will point to the right place.

llvm-svn: 284457
2016-10-18 06:47:03 +00:00
Adrian Prantl fac32f3f6a Explicitly pass an isysroot to avoid the SDKROOT overriding the deployment target.
This fixes the green dragon builders after r284416.

llvm-svn: 284423
2016-10-17 20:37:56 +00:00
Adrian Prantl 3e23c04f0a Improve the CHECK lines in debug-options.c by separating out the check
for debug info kind and dwarf version.

llvm-svn: 284420
2016-10-17 20:14:23 +00:00
Davide Italiano 877428dee1 [Coverage] Update test after r284418.
We now strip coverage metadata if debug info are not present.

llvm-svn: 284419
2016-10-17 20:06:32 +00:00
Adrian Prantl 119a998ae3 Update testcase for r284416.
llvm-svn: 284417
2016-10-17 19:46:26 +00:00
Adrian Prantl d50d56c774 Driver/Darwin: Set the DWARF version based on the deployment target.
System utilities such as atos only support DWARF 4 on OS X 10.11+ and
iOS 9+. We thus want to enable DWARF 4 only if the deployment target
has a recent enough operating system version and use DWARF 2 for older
systems.

<rdar://problem/28766743>

llvm-svn: 284416
2016-10-17 19:36:18 +00:00
Krzysztof Parzyszek ff5ee6a36a Add a dummy file in each subdirectory in test/Driver/Inputs/hexagon_tree
Git does not store empty subdirectories (while SVN does). Git clone of
the clang repository did not create the fake Hexagon installation tree
used for testing the driver. This only became evident after a change
in the Hexagon toolchain that started checking for existence of certain
directories.

llvm-svn: 284402
2016-10-17 18:04:05 +00:00
Tim Northover a43458bfe4 Hexagon: add dummy files to test dir so git keeps them.
Should fix hexagon-elf-toolchain.c tests on Git.

llvm-svn: 284401
2016-10-17 18:00:27 +00:00
Benjamin Kramer a72a70aeb9 Revert "Reinstate r281429, reverted in r281452, with a fix for its mishandling of"
This reverts commit r284176. It still marks some modules as invisible
that should be visible. Will follow up with the author with a test case.

llvm-svn: 284382
2016-10-17 13:00:44 +00:00
Justin Lebar d692dfb65e [CUDA] Fix false-positive in known-emitted handling.
Previously: When compiling for host, our constructed call graph went
*through* kernel calls.  This meant that if we had

  host calls kernel calls HD

we would incorrectly mark the HD function as known-emitted on the host
side, and thus perform host-side checks on it.

Fixing this exposed another issue, wherein when marking a function as
known-emitted, we also need to traverse the callgraph of its template,
because non-dependent calls are attached to a function's template, not
its instantiation.

llvm-svn: 284355
2016-10-17 02:25:55 +00:00
NAKAMURA Takumi e04c253a94 clang/test/CXX/conv/conv.fctptr/p1.cpp: Appease for targeting i686-win32.
error: 'error' diagnostics seen but not expected:
    File clang\test\CXX\conv\conv.fctptr\p1.cpp Line 16: assigning to 'void (S::*)() __attribute__((thiscall)) noexcept' from incompatible type 'void (S::*)() __attribute__((thiscall))': different exception specifications

llvm-svn: 284352
2016-10-16 23:00:18 +00:00
Devin Coughlin 684d19d879 Revert "Revert "[analyzer] Make MallocChecker more robust against custom redeclarations""
This reverts commit r284340 to reapply r284335. The bot breakage was due to
an unrelated change in the polybench test suite.

llvm-svn: 284351
2016-10-16 22:19:03 +00:00
Devin Coughlin eeb8d20db4 Revert "[analyzer] Make MallocChecker more robust against custom redeclarations"
This reverts commit r284335.

It appears to be causing test-suite compile-time and execution-time
performance measurements to take longer than expected on several bots.
This is surprising, because r284335 is a static-analyzer-only change.

llvm-svn: 284340
2016-10-16 19:26:07 +00:00
Richard Smith 3c4f8d2e96 P0012R1: Make exception specifications be part of the type system. This
implements the bulk of the change (modifying the type system to include
exception specifications), but not all the details just yet.

llvm-svn: 284337
2016-10-16 17:54:23 +00:00
Devin Coughlin 62ce463a35 [analyzer] Make MallocChecker more robust against custom redeclarations
Add additional checking to MallocChecker to avoid crashing when memory
routines have unexpected numbers of arguments. You wouldn't expect to see much
of this in normal code (-Wincompatible-library-redeclaration warns on this),
but, for example, CMake tests can generate these.

This is PR30616.

rdar://problem/28631974

llvm-svn: 284335
2016-10-16 17:26:06 +00:00
Richard Smith ebb006e875 Extend this test and make it a bit clearer which cases Clang is getting wrong.
llvm-svn: 284331
2016-10-16 06:23:29 +00:00
Devin Coughlin 4fba10c394 Revert "[analyzer] Re-apply r283093 "Add extra notes to ObjCDeallocChecker""
Revert:
r283662: [analyzer] Re-apply r283093 "Add extra notes to ObjCDeallocChecker"
r283660: [analyzer] Fix build error after r283660 - remove constexpr strings.

It was causing an internal build bot to fail. It looks like in some cases
adding an extra note can cause scan-build plist output to drop a diagnostic
altogether.

llvm-svn: 284317
2016-10-16 00:30:08 +00:00
Vedant Kumar 9d2a16b9b1 [Coverage] Support for C++17 if initializers
Differential Revision: https://reviews.llvm.org/D25572

llvm-svn: 284293
2016-10-14 23:38:16 +00:00
Vedant Kumar f2a6ec5521 [Coverage] Support for C++17 switch initializers
Differential Revision: https://reviews.llvm.org/D25539

llvm-svn: 284292
2016-10-14 23:38:13 +00:00
Saleem Abdulrasool 8bbc3158c3 Sema: honour dllexport in itanium more faithfully
Although the itanium environment uses the itanium layout for C++, treat the
dllexport semantics more similarly to the MSVC specification.  This preserves
the existing behaviour for the use of the itanium ABI on non-windows-itanium
environments.  Export the inline definitions too.

llvm-svn: 284288
2016-10-14 22:25:46 +00:00
Arnold Schwaighofer b715eb4504 Add more swift calling convention tests
llvm-svn: 284285
2016-10-14 21:55:56 +00:00
Richard Smith edbc6e93e1 Reinstate r284008 reverted in r284081, with two fixes:
1) Merge and demote variable definitions when we find a redefinition in
MergeVarDecls, not only when we find one in AddInitializerToDecl (we only reach
the second case if it's the addition of the initializer itself that converts an
existing declaration into a definition). 

2) When rebuilding a redeclaration chain for a variable, if we merge two
definitions together, mark the definitions as merged so the retained definition
is made visible whenever the demoted definition would have been.

Original commit message (from r283882):

[modules] PR28752: Do not instantiate variable declarations which are not visible.

Original patch by Vassil Vassilev! Changes listed above are mine.

llvm-svn: 284284
2016-10-14 21:41:24 +00:00
David L Kreitzer d397ea4d6f Define Contiki OS toolchain
Patch by Michael LeMay

Differential revision: http://reviews.llvm.org/D19854

llvm-svn: 284278
2016-10-14 20:44:33 +00:00
David Sheinkman c37a49896a __builtin_fpclassify missing one int parameter
Patch by Tania Albarghouthi.

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

llvm-svn: 284277
2016-10-14 20:43:37 +00:00
Douglas Katzman 3ed0f643fc Implement no_sanitize_address for global vars
llvm-svn: 284272
2016-10-14 19:55:09 +00:00
Erik Pilkington 88eff2575e [Sema] Refactor context checking for availability diagnostics
This commit combines a couple of redundant functions that do availability
attribute context checking into a more correct/simpler one.

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

llvm-svn: 284265
2016-10-14 19:08:01 +00:00
Manman Ren 3b5dbf23a4 Module: emit initializers in submodules when importing the parent module.
When importing the parent module, module initializers in submodules should
be emitted.

rdar://28740482

llvm-svn: 284263
2016-10-14 18:55:44 +00:00
Ed Maste 55633f7682 Revert r284256 due to test failure
llvm-svn: 284259
2016-10-14 18:20:12 +00:00
Ed Maste aaa44fe5cd Link static PIE programs against rcrt0.o on OpenBSD
Patch by Stefan Kempf.

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

llvm-svn: 284256
2016-10-14 17:59:53 +00:00
Albert Gutowski 1deab38717 Implement __stosb intrinsic as a volatile memset
Summary: We need `__stosb` to be an intrinsic, because SecureZeroMemory function uses it without including intrin.h. Implementing it as a volatile memset is not consistent with MSDN specification, but it gives us target-independent IR while keeping the most important properties of `__stosb`.

Reviewers: rnk, hans, thakis, majnemer

Subscribers: cfe-commits

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

llvm-svn: 284253
2016-10-14 17:33:05 +00:00
Alexey Bataev bef6aa6ea9 Fix for PR30632: Name mangling issue.
There was a bug in the implementation of captured statements. If it has
a lambda expression in it and the same lambda expression is used outside
the captured region, clang produced an error:
```
error: definition with same mangled name as another definition
```
Here is an example:
```
struct A {
 template <typename L>
 void g(const L&) { }
};

template<typename T>
void f() {
  {
    A().g([](){});
  }
  A().g([](){});
}

int main() {
  f<void>();
}
```

Error report:
```
main.cpp:3:10: error: definition with same mangled name as another
definition
    void g(const L&) { }
             ^
main.cpp:3:10: note: previous definition is here
```
Patch fixes this bug.

llvm-svn: 284229
2016-10-14 12:43:59 +00:00
Michael Zuckerman 387530ffe3 [x86][ms-inline-asm] use of "jmp short" in asm is not supported
Test linked to: https://reviews.llvm.org/D24957

Committing in the name of Ziv Izhar: After check-all and LGTM .

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

llvm-svn: 284213
2016-10-14 08:13:27 +00:00
Richard Smith 869d37e333 Use SubstInitializer instead of SubstExpr when instantiating a default
argument, in order to correctly instantiate the initializer.

llvm-svn: 284184
2016-10-14 01:12:20 +00:00
Richard Smith b50df91178 Reinstate r281429, reverted in r281452, with a fix for its mishandling of
compiles without -fmodules-local-submodule-visibility. Original commit message:

[modules] When merging one definition into another, propagate the list of
re-exporting modules from the discarded definition to the retained definition.

llvm-svn: 284176
2016-10-13 23:04:14 +00:00
Arnold Schwaighofer 18fad46fe3 Disable swiftcall test on windows: More brutal way to appease windows bots
The backtrace on the bot does not give me any indication what is wrong.
The test case interestingly passes in stage2 of the build.
I don't have a way of debugging this.

Disable the test on windows and hope if there is truly a bug in the code that
was causing we will eventually run into this on other platforms.

llvm-svn: 284174
2016-10-13 22:47:03 +00:00
Albert Gutowski 5e08df0266 Add 64-bit MS _Interlocked functions as builtins again
Summary: Previously global 64-bit versions of _Interlocked functions broke buildbots on i386, so now I'm adding them as builtins for x86-64 and ARM only (should they be also on AArch64? I had problems with testing it for AArch64, so I left it)

Reviewers: hans, majnemer, mstorsjo, rnk

Subscribers: cfe-commits, aemerson

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

llvm-svn: 284172
2016-10-13 22:35:07 +00:00
Arnold Schwaighofer c45025e763 Add required targets to tests to (hopefully) appease bots
llvm-svn: 284162
2016-10-13 20:59:23 +00:00
Justin Lebar 23d954241b [CUDA] Emit deferred diagnostics during Sema rather than during codegen.
Summary:
Emitting deferred diagnostics during codegen was a hack.  It did work,
but usability was poor, both for us as compiler devs and for users.  We
don't codegen if there are any sema errors, so for users this meant that
they wouldn't see deferred errors if there were any non-deferred errors.
For devs, this meant that we had to carefully split up our tests so that
when we tested deferred errors, we didn't emit any non-deferred errors.

This change moves checking for deferred errors into Sema.  See the big
comment in SemaCUDA.cpp for an overview of the idea.

This checking adds overhead to compilation, because we have to maintain
a partial call graph.  As a result, this change makes deferred errors a
CUDA-only concept (whereas before they were a general concept).  If
anyone else wants to use this framework for something other than CUDA,
we can generalize at that time.

This patch makes the minimal set of test changes -- after this lands,
I'll go back through and do a cleanup of the tests that we no longer
have to split up.

Reviewers: rnk

Subscribers: cfe-commits, rsmith, tra

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

llvm-svn: 284158
2016-10-13 20:52:12 +00:00
Saleem Abdulrasool 7eef502ed0 test: attempt to repair SCEI buildbots
The tests target ARM, ensure that the ARM target is registered.

llvm-svn: 284156
2016-10-13 20:10:22 +00:00
Saleem Abdulrasool 887a82c5d6 CodeGen: ensure that the runtime calling convention matches
Incorrect specification of the calling convention results in UB which can cause
the code path to be eliminated.  Simplify the existing code by using the
RuntimeCall constructor in `CodeGenFunction`.

llvm-svn: 284154
2016-10-13 19:45:08 +00:00
Arnold Schwaighofer 3d01ad116c Swift Calling Convention: Fix out of bounds access
Use iterator instead of address of element in vector

It is not valid to access one after the last element.

rdar://28759508

llvm-svn: 284150
2016-10-13 19:19:37 +00:00
Justin Lebar 44f547aa3f [CUDA] Allow static variables in __host__ __device__ functions, so long as they're never codegen'ed for device.
Reviewers: tra, rnk

Subscribers: cfe-commits

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

llvm-svn: 284145
2016-10-13 18:45:17 +00:00
Justin Lebar aa370bd0d7 [CUDA] Disallow __shared__ variables in host functions.
Reviewers: tra, rnk

Subscribers: cfe-commits

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

llvm-svn: 284144
2016-10-13 18:45:13 +00:00
Justin Lebar 179bdce72a [CUDA] Add Sema::CUDADiagBuilder and Sema::CUDADiagIf{Device,Host}Code().
Summary:
Together these let you easily create diagnostics that

 - are never emitted for host code
 - are always emitted for __device__ and __global__ functions, and
 - are emitted for __host__ __device__ functions iff these functions are
   codegen'ed.

At the moment there are only three diagnostics that need this treatment,
but I have more to add, and it's not sustainable to write code for emitting
every such diagnostic twice, and from a special wrapper in SemaCUDA.cpp.

While we're at it, don't emit the function name in
err_cuda_device_exceptions: It's not necessary to print it, and making
this work in the new framework in the face of a null value for
dyn_cast<FunctionDecl>(CurContext) isn't worth the effort.

Reviewers: rnk

Subscribers: cfe-commits, tra

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

llvm-svn: 284143
2016-10-13 18:45:08 +00:00