Erich Keane [Tue, 15 Jan 2019 17:51:09 +0000 (17:51 +0000)]
Fix cpu-dispatch MV regression caused by r347812
r347812 permitted forward declarations for cpu-dispatch functions, which
are occassionally useful as exposition in header files. However, this inadvertently
permitted this function to become multiversioned after a usage. This
patch ensures that the "CausesMV" checks are still run in the
forward-declaration case.
The BoundNodesTreeBuilder class is used both directly and indirectly as a local
variable in matchesAncestorOfRecursively, memoizedMatchesAncestorOfRecursively
and other functions that happen to be on long recursive call paths. By reducing
the inline storage size of the SmallVector we dramatically reduce the stack
requirements of ASTMatchers. Running clang-tidy with a large number of checks
enabled on a few arbitrarily chosen files show no performance regression.
Roman Lebedev [Tue, 15 Jan 2019 11:20:02 +0000 (11:20 +0000)]
[OpenCL] opencl-c.h: read_image*(): sampler-less, and image{1,2}d_array_t variants are OpenCL-1.2+, mark them as such
Summary:
Refer to [[ https://www.khronos.org/registry/OpenCL/specs/opencl-1.1.pdf#page=242 | `6.11.13.2 Built-in Image Functions` ]],
and [[ https://www.khronos.org/registry/OpenCL/specs/opencl-1.1.pdf#page=306 | `9.6.8 Image Read and Write Functions` ]] of the OpenCL 1.1 spec.
* There is no mention of `image1d_array_t` and `image2d_array_t` anywhere in the OpenCL 1.1 spec.
* All the `read_image{f,i,ui,h}()` functions, as of OpenCL 1.1 spec, have a second required parameter `sampler_t sampler`
Should have prevented the following regression:
https://redmine.darktable.org/issues/12493
Roman Lebedev [Tue, 15 Jan 2019 09:44:25 +0000 (09:44 +0000)]
[clang][UBSan] Sanitization for alignment assumptions.
Summary:
UB isn't nice. It's cool and powerful, but not nice.
Having a way to detect it is nice though.
[[ https://wg21.link/p1007r3 | P1007R3: std::assume_aligned ]] / http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1007r2.pdf says:
```
We propose to add this functionality via a library function instead of a core language attribute.
...
If the pointer passed in is not aligned to at least N bytes, calling assume_aligned results in undefined behaviour.
```
This differential teaches clang to sanitize all the various variants of this assume-aligned attribute.
Requires D54588 for LLVM IRBuilder changes.
The compiler-rt part is D54590.
This is a second commit, the original one was r351105,
which was mass-reverted in r351159 because 2 compiler-rt tests were failing.
Dan Gohman [Tue, 15 Jan 2019 06:58:16 +0000 (06:58 +0000)]
[WebAssembly] Support multilibs for wasm32 and add a wasm OS that uses it
This adds support for multilib paths for wasm32 targets, following
[Debian's Multiarch conventions], and also adds an experimental OS name in
order to test it.
Craig Topper [Tue, 15 Jan 2019 05:03:18 +0000 (05:03 +0000)]
[X86] Make _xgetbv/_xsetbv on non-windows platforms
Summary:
This patch attempts to redo what was tried in r278783, but was reverted.
These intrinsics should be available on non-windows platforms with "xsave" feature check. But on Windows platforms they shouldn't have feature check since that's how MSVC behaves.
To accomplish this I've added a MS builtin with no feature check. And a normal gcc builtin with a feature check. When _MSC_VER is not defined _xgetbv/_xsetbv will be macros pointing to the gcc builtin name.
I've moved the forward declarations from intrin.h to immintrin.h to match the MSDN documentation and used that as the header file for the MS builtin.
I'm not super happy with this implementation, and I'm open to suggestions for better ways to do it.
Petr Hosek [Tue, 15 Jan 2019 01:15:00 +0000 (01:15 +0000)]
[CMake][Fuchsia] Synchronize first and second stage builds
This reorders options between the first and second stage builds to make
them better lined up. The change also re-enables tests for first stage
which is useful e.g. for cross-compiling when we cannot run tests for
second stage directly (i.e. without emulation).
Roman Lebedev [Mon, 14 Jan 2019 19:09:27 +0000 (19:09 +0000)]
[clang][UBSan] Sanitization for alignment assumptions.
Summary:
UB isn't nice. It's cool and powerful, but not nice.
Having a way to detect it is nice though.
[[ https://wg21.link/p1007r3 | P1007R3: std::assume_aligned ]] / http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1007r2.pdf says:
```
We propose to add this functionality via a library function instead of a core language attribute.
...
If the pointer passed in is not aligned to at least N bytes, calling assume_aligned results in undefined behaviour.
```
This differential teaches clang to sanitize all the various variants of this assume-aligned attribute.
Requires D54588 for LLVM IRBuilder changes.
The compiler-rt part is D54590.
Kristina Brooks [Mon, 14 Jan 2019 18:16:51 +0000 (18:16 +0000)]
[Sema] Expose a control flag for integer to pointer ext warning
While building openJDK11u, it seems that some of the code in the
native core libraries make liberal use of integer to pointer
comparisons. We currently have no flag to disabled this warning.
This add such a flag.
Sam McCall [Mon, 14 Jan 2019 17:16:00 +0000 (17:16 +0000)]
[AST] Fix double-traversal of code in top-level lambdas in RAV(implicit = yes).
Summary:
Prior to r351069, lambda classes were traversed or not depending on the
{Function, Class, Namespace, TU} DeclContext containing them.
If it was a function (common case) they were not traversed.
If it was a namespace or TU (top-level lambda) they were traversed as part of
that DeclContext traversal.
r351069 "fixed" RAV to traverse these as part of the LambdaExpr, which is the
right place. But top-level lambdas are now traversed twice.
We fix that as blocks and block captures were apparently fixed in the past.
Maybe it would be nicer to avoid adding the lambda classes to the DeclContext
in the first place, but I can't work out the implications of that.
[OpenCL] Set generic addr space of 'this' in special class members.
Set address spaces of 'this' param correctly for implicit special
class members.
This also changes initialization conversion sequence to separate
address space conversion from other qualifiers in case of binding
reference to a temporary. In this case address space conversion
should happen after the binding (unlike for other quals). This is
needed to materialize it correctly in the alloca address space.
Sam McCall [Mon, 14 Jan 2019 10:31:42 +0000 (10:31 +0000)]
[AST] RecursiveASTVisitor visits lambda classes when implicit visitation is on.
Summary:
This fixes ASTContext's parent map for nodes in such classes (e.g. operator()).
https://bugs.llvm.org/show_bug.cgi?id=39949
This also changes the observed shape of the AST for implicit RAVs.
- this includes AST MatchFinder: cxxRecordDecl() now matches lambda classes,
functionDecl() matches the call operator, and the parent chain is body -> call
operator -> lambda class -> lambdaexpr rather than body -> lambdaexpr.
- this appears not to matter for the ASTImporterLookupTable builder
- this doesn't matter for the other RAVs in-tree.
In order to do this, we remove the TraverseLambdaBody hook. The problem is it's
hard/weird to ensure this hook is called when traversing via the implicit class.
There were just two users of this hook in-tree, who use it to skip bodies.
I replaced these with explicitly traversing the captures only. Another approach
would be recording the bodies when the lambda is visited, and then recognizing
them later.
I'd be open to suggestion on how to preserve this hook, instead.
Steven Wu [Fri, 11 Jan 2019 21:16:04 +0000 (21:16 +0000)]
[Darwin][Driver] Don't pass a file as object_path_lto during ThinLTO
Summary:
After r327851, Driver::GetTemporaryPath will create the file rather than
just create a potientially unqine filename. If clang driver pass the
file as parameter as -object_path_lto, ld64 will pass it back to libLTO
as GeneratedObjectsDirectory, which is going to cause a LLVM ERROR if it
is not a directory.
Now during thinLTO, pass a temp directory path to linker instread.
Stephen Kelly [Fri, 11 Jan 2019 19:16:01 +0000 (19:16 +0000)]
Implement Attr dumping in terms of visitors
Remove now-vestigial dumpType and dumpBareDeclRef methods. The old
tablegen generated code used to expect them to be present, but the new
generated code has no such requirement.
Teresa Johnson [Fri, 11 Jan 2019 18:32:07 +0000 (18:32 +0000)]
[LTO] Add option to enable LTOUnit splitting, and disable unless needed
Summary:
Adds a new -f[no]split-lto-unit flag that is disabled by default to
control module splitting during ThinLTO. It is automatically enabled
for -fsanitize=cfi and -fwhole-program-vtables.
The new EnableSplitLTOUnit codegen flag is passed down to llvm
via a new module flag of the same name.
Chris Kennelly [Fri, 11 Jan 2019 17:09:22 +0000 (17:09 +0000)]
Implementation Feature Test Macros for P0722R3
Summary:
P1353R0, adopted in San Diego, specified an implementation feature test macro for destroying delete (P0722R3).
The implementation of the feature (https://reviews.llvm.org/rL315662) is not guarded behind a flag, so the macro is not conditional on language version.
Akira Hatanaka [Fri, 11 Jan 2019 07:06:38 +0000 (07:06 +0000)]
[Sema] Make canPassInRegisters return true if the CXXRecordDecl passed
to it is a trivial_abi class.
A class that has all of its copy and move constructors deleted can still
be passed or returned in registers if the class is annotated with
trivial_abi.
Akira Hatanaka [Fri, 11 Jan 2019 04:57:34 +0000 (04:57 +0000)]
[Sema] If CheckPlaceholderExpr rewrites the initializer of an auto
variable during auto type deduction, use the rewritten initializer when
performing initialization of the variable.
This silences spurious -Warc-repeated-use-of-weak warnings that are
issued when the initializer uses a weak ObjC pointer.
Richard Smith [Fri, 11 Jan 2019 01:59:33 +0000 (01:59 +0000)]
Remember to instantiate explicit template argument lists in a friend
function declaration.
We'd previously often just drop these on the floor, and friend
redeclaration matching would usually (but not always) figure out the
right redeclaration anyway.
Also, don't try to match a dependent friend function template
specialization to a template until instantiation, and don't forget to
reject qualified friend declarations in dependent contexts that don't
name an already-declared entity.
Brian Gesiak [Fri, 11 Jan 2019 01:54:53 +0000 (01:54 +0000)]
[AST] Remove ASTContext from getThisType (NFC)
Summary:
https://reviews.llvm.org/D54862 removed the usages of `ASTContext&` from
within the `CXXMethodDecl::getThisType` method. Remove the parameter
altogether, as well as all usages of it. This does not result in any
functional change because the parameter was unused since
https://reviews.llvm.org/D54862.
Richard Trieu [Fri, 11 Jan 2019 01:32:35 +0000 (01:32 +0000)]
Fix header issues.
Several headers would fail to compile if other headers were not previously
included. The usual issue is that a class is forward declared, but the
full definition is needed. The requirement for the definition is use of
isa/dyn_cast or calling functions of pointer-packed data types such as
DenseMap or PointerIntPair. Add missing includes to these headers.
SVals.h required an out-of-line method definition in the .cpp file to avoid
circular inclusion of headers with BasicValueFactory.h
Artem Dergachev [Thu, 10 Jan 2019 23:44:44 +0000 (23:44 +0000)]
[analyzer] pr38838, pr39976: Fix crash on diagnosing before implicit destructor.
We need to be able to emit the diagnostic at PreImplicitCall,
and the patch implements this functionality.
However, for now the need for emitting such diagnostics is not all that great:
it is only necessary to not crash when emitting a false positive due to an
unrelated issue of having dead symbol collection not working properly.
Coming up with a non-false-positive test seems impossible with the current
set of checkers, though it is likely to be needed for good things as well
in the future.
Aaron Ballman [Thu, 10 Jan 2019 21:22:13 +0000 (21:22 +0000)]
Correct the source range returned from preprocessor callbacks.
This adjusts the source range passed in to the preprocessor callbacks to only include the condition range itself, rather than all of the conditionally skipped tokens.
Akira Hatanaka [Thu, 10 Jan 2019 20:12:16 +0000 (20:12 +0000)]
[Sema] Call CheckPlaceholderExpr to resolve typeof or decltype
placeholder expressions while an unevaluated context is still on the
expression evaluation context stack.
This prevents recordUseOfWeek from being called when a weak variable is
used as an operand of a decltype or a typeof expression and fixes
spurious -Warc-repeated-use-of-weak warnings.
George Karpenkov [Thu, 10 Jan 2019 18:15:44 +0000 (18:15 +0000)]
[analyzer] [NFC] Reverse the argument order for "diff" in tests
The current argument order has "expected" and "actual" the wrong way around,
so that the diff shows the change from expected to actual, not from actual to expected.
Namely, if the expected diagnostics contains the string "foo", but the analyzer emits "bar",
we really want to see:
```
- foo
+ bar
```
not
```
- bar
+ foo
```
since adapting to most changes would require applying that diff to the expected output.
The complicated machinery for passing the summary log around is actually
only used for one thing! To figure out whether the "dealloc" message was
sent.
Since I have tried to extend it for other uses and failed (it's actually
very hard to use), I think it's much better to simply use a tag and
remove the summary log altogether.
George Karpenkov [Thu, 10 Jan 2019 18:14:51 +0000 (18:14 +0000)]
[analyzer] [RetainCountChecker] [NFC] Refactor the way attributes are handled
Make sure all checks for attributes go through a centralized function,
which checks whether attribute handling is enabled, and performs
validation. The type of the attribute is returned.
Sadly, metaprogramming is required as attributes have no sensible static
getters.
Erik Pilkington [Thu, 10 Jan 2019 18:03:07 +0000 (18:03 +0000)]
Split -Wdelete-non-virtual-dtor into two groups
This group controls two diagnostics: deleting an abstract class with
a non-virtual dtor, which is a guaranteed crash, and deleting a
non-abstract polymorphic class with a non-virtual dtor, which is just
suspicious.
Rafael Stahl [Thu, 10 Jan 2019 17:44:04 +0000 (17:44 +0000)]
[analyzer][CrossTU][NFC] Generalize to external definitions instead of external functions
Summary: This is just changing naming and documentation to be general about external definitions that can be imported for cross translation unit analysis. There is at least a plan to add VarDecls: D46421
Richard Trieu [Thu, 10 Jan 2019 03:23:25 +0000 (03:23 +0000)]
Refactor declarations of ASTContext allocate functions into its own header.
Forward declarations of the allocate functions combine with the forward
declaration of the ASTContext class is enough information for some headers
without pulling in ASTContext.h in its entirety. Pull the existing
declarations from AttrIterator.h into a new header. Also place the default
alignment size into this header. Previously, new had its default in
AttrIterator.h while new[] had its default in ASTContext.h. Add new header
includes where it is needed. Specifically to ASTVector.h to make it a
standalone header, unlike previously which it was standalone as long as
none of its functions were called.
[Sema] Mark target of __attribute__((alias("target"))) used for C
Summary:
Prevents -Wunneeded-internal-delcaration warnings when the target has no
other references. This occurs frequently in device drivers in the Linux
kernel.
Sema would need to invoke the demangler on the target, since in C++ the
target name is mangled:
int f() { return 42; }
int g() __attribute__((alias("_Z1fv")));
Sema does not have the ability to demangle names at this time.
Alex Lorenz [Wed, 9 Jan 2019 22:31:37 +0000 (22:31 +0000)]
[ObjC] Allow the use of implemented unavailable methods from within
the @implementation context
In Objective-C, it's common for some frameworks to mark some methods like init
as unavailable in the @interface to prohibit their usage. However, these
frameworks then often implemented said method and refer to it in another method
that acts as a factory for that object. The recent change to how messages to
self are type checked in clang (r349841) introduced a regression which started
to prohibit this pattern with an X is unavailable error. This commit addresses
the aforementioned regression.
[OpenMP] Avoid remainder operations for loop index values on a collapsed loop nest.
Summary: Change the strategy for computing loop index variables after collapsing a loop nest via the collapse clause by replacing the expensive remainder operation with multiplications and additions.
[OpenMP] Add flag for preventing the extension to 64 bits for the collapse loop counter
Summary: Introduce a compiler flag for cases when the user knows that the collapsed loop counter can be safely represented using at most 32 bits. This will prevent the emission of expensive mathematical operations (such as the div operation) on the iteration variable using 64 bits where 32 bit operations are sufficient.