Malcolm Parsons [Thu, 20 Oct 2016 14:58:45 +0000 (14:58 +0000)]
[Format] Cleanup after replacing constructor body with = default
Summary:
Remove colon and commas after replacing constructor body with = default.
Fix annotation of TT_CtorInitializerColon when preceded by a comment.
Richard Smith [Thu, 20 Oct 2016 07:53:17 +0000 (07:53 +0000)]
Work around MSVC rejects-valid. Apparenty (some versions of) MSVC will check
that a member is default-initializable even if it's initialized by a default
member initializer.
Victor Leschuk [Thu, 20 Oct 2016 00:13:19 +0000 (00:13 +0000)]
DebugInfo: pass alignment value only if it was forced
Preparation to implement DW_AT_alignment support:
- We pass non-zero align value to DIBuilder only when alignment was forced
- Modify tests to match this change
[cmake] Follow LLVM's lead in creating exported tool targets for clang tools.
This is needed by downstream projects such as swift to get proper cmake
dependency information for LLVM/Clang targets.
A few months ago I added support for exporting this information for Clang
libraries. In order to be incremental, I did not add support for exporting clang
tools as well at that time. Now such support is needed, so I am committing this
incremental code.
Richard Smith [Wed, 19 Oct 2016 22:18:42 +0000 (22:18 +0000)]
Add optimization to sizeof...(X) handling: if none of parameter pack X's
corresponding arguments are unexpanded pack expansions, we can compute the
result without substituting them. This significantly improves the memory usage
and performance of make_integer_sequence implementations that do this kind of
thing:
using result = integer_sequence<T, Ns ..., sizeof...(Ns) + Ns ...>;
... but note that such an implementation will still perform O(sizeof...(Ns)^2)
work while building the second pack expansion (we just have a somewhat lower
constant now).
In principle we could get this down to linear time by caching whether the
number of expansions of a pack is constant, or checking whether we're within an
alias template before scanning the pack for pack expansions (since that's the
only case in which we do substitutions within a dependent context at the
moment), but this patch doesn't attempt that.
Chris Bieneman [Wed, 19 Oct 2016 21:18:48 +0000 (21:18 +0000)]
[CMake] Add clang-bootstrap-deps target
Having this target allows other parts of the build system to add to the bootstrap dependencies without needing to be defined before the bootstrap targets are created.
This will specifically be used connect the builtins build from the LLVM runtimes directory as a dependency of the next build stage.
Justin Lebar [Wed, 19 Oct 2016 21:15:01 +0000 (21:15 +0000)]
[CUDA] When we emit an error that might have been deferred, also print a callstack.
Summary:
Previously, when you did something not allowed in a host+device function
and then caused it to be codegen'ed, we would print out an error telling
you that you did something bad, but we wouldn't tell you how we decided
that the function needed to be codegen'ed.
This change causes us to print out a callstack when emitting deferred
errors. This is immensely helpful when debugging highly-templated code,
where it's often unclear how a function became known-emitted.
We only print the callstack once per function, after we print the all
deferred errors.
This patch also switches all of our hashtables to using canonical
FunctionDecls instead of regular FunctionDecls. This prevents a number
of bugs, some of which are caught by tests added here, in which we
assume that two FDs for the same function have the same pointer value.
Justin Lebar [Wed, 19 Oct 2016 21:03:38 +0000 (21:03 +0000)]
[CUDA] Emit errors for wrong-side calls made on the same line as non-wrong-side calls.
Summary:
This fixes two related bugs:
1) Previously, if you had a non-wrong side call at some source code
location L, we wouldn't emit errors for wrong-side calls that appeared
at L.
2) We'd only emit one wrong-side error per source code location, when we
actually want to emit it twice if we hit this line more than once due to
e.g. template instantiation.
Vedant Kumar [Wed, 19 Oct 2016 20:28:35 +0000 (20:28 +0000)]
[ubsan] Re-work check lines to try to appease a bot (NFC)
This bot does not produce the IR I expect -- it's missing some
'handler.dynamic_type_cache_miss:' labels. We don't need to rely on
those labels, so get rid of them in hopes of making the bot happy.
Vedant Kumar [Wed, 19 Oct 2016 20:21:16 +0000 (20:21 +0000)]
[ubsan] Use the object pointer's type info for devirtualized calls
ubsan reports a false positive 'invalid member call' diagnostic on the
following example (PR30478):
struct Base1 {
virtual int f1() { return 1; }
};
struct Base2 {
virtual int f1() { return 2; }
};
struct Derived2 final : Base1, Base2 {
int f1() override { return 3; }
};
int t1() {
Derived2 d;
return static_cast<Base2 *>(&d)->f1();
}
Adding the "final" attribute to a most-derived class allows clang to
devirtualize member calls into an instance of that class. We should pass
along the type info of the object pointer to avoid the FP. In this case,
that means passing along the type info for 'Derived2' instead of 'Base2'
when checking the dynamic type of static_cast<Base2 *>(&d2).
Simon Dardis [Wed, 19 Oct 2016 17:50:52 +0000 (17:50 +0000)]
[mips][msa] Range check MSA intrinsics with immediates
This patch teaches clang to range check immediates for MIPS MSA instrinsics.
This checking is done strictly in comparison to some existing GCC
implementations. E.g. msa_andvi_b(var, 257) does not result in andvi $wX, 1.
Similarily msa_ldi_b takes a range of -128 to 127.
As part of this effort, correct the existing MSA test as it has both illegal
types and immediates.
Michal Gorny [Wed, 19 Oct 2016 12:21:39 +0000 (12:21 +0000)]
[cmake] Use LLVM_CMAKE_PATH for GetSVN script
Use the LLVM_CMAKE_PATH variable to locate the GetSVN.cmake script.
The variable was already available in stand-alone builds, and is also
set by LLVM since r284581.
Eric Liu [Wed, 19 Oct 2016 08:19:46 +0000 (08:19 +0000)]
[clang-format] Add comment manipulation header
Summary:
Introduces a separate target for comment manipulation.
Currently, comment manipulation is in BreakableComment.cpp.
Towards implementing comment reflowing, we want to factor out the
comment-related functionality, so it can be reused.
Start simple by just moving out getLineCommentIndentPrefix.
Justin Lebar [Wed, 19 Oct 2016 00:06:49 +0000 (00:06 +0000)]
[CUDA] Rework tests now that we emit deferred diagnostics during sema. Test-only change.
Summary:
Previously we had to split out a lot of our tests into a test that
checked only immediate errors and a test that checked only deferred
errors. This was because, if you emitted any immediate errors, we
wouldn't run codegen, where the deferred errors were emitted.
We've fixed this, and now emit deferred errors during sema. This lets
us merge a bunch of tests, and lets us convert some other tests to
-fsyntax-only.
Richard Smith [Tue, 18 Oct 2016 23:39:12 +0000 (23:39 +0000)]
DR1330: instantiate exception-specifications when "needed". We previously did
not instantiate exception specifications of functions if they were only used in
unevaluated contexts (other than 'noexcept' expressions).
In C++17 onwards, this becomes essential since the exception specification is
now part of the function's type.
Note that this means that constructs like the following no longer work:
struct A {
static T f() noexcept(...);
decltype(f()) *p;
};
... because the decltype expression now needs the exception specification of
'f', which has not yet been parsed.
Richard Smith [Tue, 18 Oct 2016 19:29:18 +0000 (19:29 +0000)]
When two function types have equivalent (but distinct) noexcept specifications, create separate type sugar nodes. This is necessary so that substitution into the exception specification will substitute into the correct expression.
Akira Hatanaka [Tue, 18 Oct 2016 19:05:41 +0000 (19:05 +0000)]
[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.
Michal Gorny [Tue, 18 Oct 2016 17:07:30 +0000 (17:07 +0000)]
[cmake] Update lit search to match the one in LLVM
Update the lit search logic to support all names supported in LLVM
(since r283029). The search order (i.e. PATHS vs HINTS) does no really
matter since the established path is not used, except for determining
whether lit is available.
Artem Dergachev [Tue, 18 Oct 2016 11:06:28 +0000 (11:06 +0000)]
[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).
Alex Lorenz [Tue, 18 Oct 2016 10:55:01 +0000 (10:55 +0000)]
[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.
Alex Lorenz [Tue, 18 Oct 2016 10:38:58 +0000 (10:38 +0000)]
[CodeCompletion][NFC] Extract a function that formats block placeholders.
This commit extracts a new function named `formatBlockPlaceholder` from
the function `FormatFunctionParameter` so that it can be reused in follow-up
commits that improve code completion for block property setters.
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.