Alex Lorenz [Tue, 18 Oct 2016 10:35:27 +0000 (10:35 +0000)]
[CodeCompletion][NFC] Extract a function that looks for block decl type locs.
This commit extracts a new function named `findTypeLocationForBlockDecl` from
the function `FormatFunctionParameter` so that it can be reused in follow-up
commits that improve code completion for block property setters.
Richard Smith [Tue, 18 Oct 2016 07:13:55 +0000 (07:13 +0000)]
[c++1z] Include "noexcept" in builtin function types where appropriate. Fixes
an assertion failure looking up a matching ::operator delete for
__builtin_operator_delete.
Richard Smith [Tue, 18 Oct 2016 06:47:03 +0000 (06:47 +0000)]
[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.
Petr Hosek [Mon, 17 Oct 2016 22:02:53 +0000 (22:02 +0000)]
[Driver] Use stem rather than filename for executable name
When comparing the linker name in Fuchsia driver, use stem rather
than filename to get the name of the linker becase on Windows, the
filename will have an extension.
Adrian Prantl [Mon, 17 Oct 2016 19:36:18 +0000 (19:36 +0000)]
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.
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.
Justin Lebar [Mon, 17 Oct 2016 02:25:55 +0000 (02:25 +0000)]
[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.
NAKAMURA Takumi [Sun, 16 Oct 2016 23:00:18 +0000 (23:00 +0000)]
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
Justin Bogner [Sun, 16 Oct 2016 20:12:42 +0000 (20:12 +0000)]
AST: Improve a couple of comments and cast unused values to void
Make these comments a bit more explicit that they're initializing the
RawText member, and explicitly cast the unused result of getRawText to
void for clarity.
Devin Coughlin [Sun, 16 Oct 2016 19:26:07 +0000 (19:26 +0000)]
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.
Richard Smith [Sun, 16 Oct 2016 17:54:23 +0000 (17:54 +0000)]
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.
Devin Coughlin [Sun, 16 Oct 2016 17:26:06 +0000 (17:26 +0000)]
[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.
Devin Coughlin [Sun, 16 Oct 2016 00:30:08 +0000 (00:30 +0000)]
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.
Richard Smith [Sat, 15 Oct 2016 01:59:52 +0000 (01:59 +0000)]
Disable a silly GCC diagnostic for combining a scanf length specifier with the
'*' specifier. Apparently the GNU folks want to discourage self-documenting
code.
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.
Richard Smith [Fri, 14 Oct 2016 21:41:24 +0000 (21:41 +0000)]
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.
Richard Smith [Fri, 14 Oct 2016 19:51:36 +0000 (19:51 +0000)]
[linux] When pre-reserving stack pages to work around broken address space
layout for PIE binaries, ask the OS how much stack space is already in use to
avoid stack overflow if we are run with more than 512K of combined command line
arguments + environment variables.
Albert Gutowski [Fri, 14 Oct 2016 17:33:05 +0000 (17:33 +0000)]
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`.
Alexey Bataev [Fri, 14 Oct 2016 12:43:59 +0000 (12:43 +0000)]
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&) { }
};
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.
Eric Liu [Fri, 14 Oct 2016 09:32:06 +0000 (09:32 +0000)]
Deduplicate sets of replacements by file names.
Summary:
If there are multiple <File, Replacements> pairs with the same file
path after removing dots, we only keep one pair (with path after dots being
removed) and discard the rest.
Richard Smith [Thu, 13 Oct 2016 23:04:14 +0000 (23:04 +0000)]
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.
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.
Albert Gutowski [Thu, 13 Oct 2016 22:35:07 +0000 (22:35 +0000)]
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)
[analyzer] Remove superquadratic behaviour from DataflowWorklist
The class DataflowWorklist internally maintains a sorted list of pointers to CFGBlock
and the method enqueuePredecessors has to call sortWorklist to maintain the invariant.
The implementation based on vector + sort works well for small sizes
but gets infeasible for relatively large sizes. In particular the issue takes place
for some cryptographic libraries which use code generation.
The diff replaces vector + sort with priority queue.
For one of the implementations of AES this patch reduces
the time for analysis from 204 seconds to 8 seconds.
Justin Lebar [Thu, 13 Oct 2016 20:52:12 +0000 (20:52 +0000)]
[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.
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`.
Justin Lebar [Thu, 13 Oct 2016 18:45:08 +0000 (18:45 +0000)]
[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.
Artem Dergachev [Thu, 13 Oct 2016 11:41:12 +0000 (11:41 +0000)]
[analyzer] Link libStaticAnalyzerCheckers to libASTMatchers.
AST matchers are useful for the analyzer's checkers.
More patches on particular checkers shall follow.
This is the first time clang binary gets linked to ASTMatchers.
The binary size increase for the clang executable would be
+0.5% in release mode, +2% in debug mode.
Alexey Bataev [Thu, 13 Oct 2016 09:52:46 +0000 (09:52 +0000)]
Fix for PR30639: CGDebugInfo Null dereference with OpenMP array
access, by Erich Keane
OpenMP creates a variable array type with a a null size-expr. The Debug
generation failed to due to this. This patch corrects the openmp
implementation, updates the tests, and adds a new one for this
condition.
Devin Coughlin [Wed, 12 Oct 2016 23:57:05 +0000 (23:57 +0000)]
[analyzer] DeallocChecker: Don't warn about directly-set IBOutlet ivars on macOS
On macOS (but not iOS), if an ObjC property has no setter, the nib-loading code
for an IBOutlet is documented as directly setting the backing ivar without
retaining the value -- even if the property is 'retain'.
This resulted in false positives from the DeallocChecker for code that did not
release such ivars in -dealloc.
To avoid these false positives, treat IBOutlet ivars that back a property
without a setter as having an unknown release requirement in macOS.
Albert Gutowski [Wed, 12 Oct 2016 22:01:05 +0000 (22:01 +0000)]
Implement MS _BitScan intrinsics
Summary: _BitScan intrinsics (and some others, for example _Interlocked and _bittest) are supposed to work on both ARM and x86. This is an attempt to isolate them, avoiding repeating their code or writing separate function for each builtin.
Alex Lorenz [Wed, 12 Oct 2016 11:40:15 +0000 (11:40 +0000)]
[CodeCompletion] Show protocol properties that are accessed through qualified id
This commit improves code completion for properties that are declared in
Objective-C protocols by making sure that properties show up in completions
when they are accessed through a qualified id.
Alex Lorenz [Wed, 12 Oct 2016 09:36:35 +0000 (09:36 +0000)]
[Sema] Handle transparent_union attributes in C mode only
This commit marks the transparent_union attributes as C only because clang
doesn't support them in C++ mode. Prior to this commit, clang still tried to
verify these attributes in C++, leading to crashes when analyzing templated
transparent_union unions that have dependent field types. This commit ensures
that such crashes won't happen again.
As a result of this commit clang now displays a warning every time it encounters
a transparent_union attribute in C++ mode.