Richard Smith [Wed, 23 Mar 2016 20:39:06 +0000 (20:39 +0000)]
Make SemaAccess smarter about determining when a dependent class might
instantiate to match a friend class declaration. It's still pretty dumb,
though.
Richard Smith [Wed, 23 Mar 2016 20:07:07 +0000 (20:07 +0000)]
Make sure to perform dependent access checks when instantiating a
lambda-expression. We don't actually instantiate the closure type / operator()
in the template in order to produce the closure type / operator() in the
instantiation, so this isn't caught by the normal path.
Nico Weber [Wed, 23 Mar 2016 18:46:57 +0000 (18:46 +0000)]
clang-cl: Fix remaining bugs in interaction of /Yc and /FI /showIncludes.
Instead of putting the /Yc header into ExtraDeps, give DependencyOutputOptions
a dedicated field for /Yc mode, and let HeaderIncludesCallback hang on to the
full DependencyOutputOptions object, not just ExtraDeps.
Reverts parts of r263352 that are now no longer needed.
Nico Weber [Wed, 23 Mar 2016 18:17:02 +0000 (18:17 +0000)]
clang-cl: Add more tests for the interaction of /FI and /Yc /Yu.
Most things even work; see the included FIXMEs for things that need polishing.
Also don't warn about unused flags for the `/Yuh2.h /FIh1.h /FIh2.h`. The
common case is that the pch was built with `/Ych2.h /FIh1.h /FIh2.h`, so h1.h
is in the PCH, and we shouldn't warn about /FIh1.h not having an effect.
(If we wanted to get fancy, we could store the list of -include flags in the
pch and then check that it matches later on.)
Nico Weber [Wed, 23 Mar 2016 18:00:22 +0000 (18:00 +0000)]
clang-cl: Include /FI headers in /showIncludes output.
-H in gcc mode doesn't print -include headers, but they are included in
depfiles written by MMD and friends. Since /showIncludes is what's used instead
of depfiles, printing /FI there seems important (and matches cl.exe).
Instead of giving HeaderIncludeGen more options, just switch on ShowAllHeaders
in clang-cl mode and let clang::InitializePreprocessor() not put -include flags
in the <command line> block. This changes the behavior of -E slightly, and it
removes the <command line> flag from the output triggered by setting the
obscure CC_PRINT_HEADERS=1 env var to true while running clang. Both of these
seem ok to change.
Manman Ren [Wed, 23 Mar 2016 16:28:28 +0000 (16:28 +0000)]
ObjC: Handle boolean fixed type for enum.
Before this commit, we assert failure in ImplicitCastExpr
"unheralded conversion to bool". This commit fixes the assertion by using
the correct cast type when the fixed type is boolean.
This commit also fixes the behavior for Microsoft mode as well, since
Obj-C and Microsoft mode share the same code path.
void *fp = f; // OK. This is C and the target is void*.
void (*fp2)(void) = f; // Error. This is C, but the target isn't void*.
```
This patch makes the assignment of `fp2` select the `f(int)` overload,
rather than emitting an error (N.B. you'll still get a warning about the
`fp2` assignment if you use -Wincompatible-pointer-types).
Justin Bogner [Tue, 22 Mar 2016 17:50:05 +0000 (17:50 +0000)]
StaticAnalyzer: Avoid an unintentional copy
The range here isn't over references, so using `auto &` here incites a
copy. Switching to `auto *` would do, but we might as well list an
explicit type for clarity.
Summary: A checker (will be uploaded after this patch) needs to check implicit casts. Existing generic matcher "has" ignores implicit casts and parenthesized expressions and no specific matcher for matching return value expression preexisted. The patch adds such a matcher (hasReturnValue).
Akira Hatanaka [Tue, 22 Mar 2016 05:00:21 +0000 (05:00 +0000)]
[Objective-c] Do not set IsExact to true when the receiver is a class.
IsExact shouldn't be set to true in WeakObjectProfileTy::getBaseInfo
when the receiver is a class because having a class as the receiver
doesn't guarantee that the Base is exact.
Mike Spertus [Tue, 22 Mar 2016 02:29:22 +0000 (02:29 +0000)]
Visual Studio Native Visualizations for constructors and methods
With this change, the class
struct A {
A(int _i);
~A();
int foo(double d);
double bar(A *a) { return 1.3; }
};
appears in the VS2015 Locals Window as
D 0x02dbb378 struct A
|- DeclKind CXXRecord
|- Members
|- [0] implicit struct A
|- [1] Constructor {A(int _i)}
|- [2] Destructor {~A()}
|- [3] Method {int foo(double d)}
|- [4] Method {double bar(struct A *)}
|- [Raw View] /* Other stuff */
Note that these changes only benefit VS2015 as
VS2013 does not have views and only displays the
struct name "A", but the change does no apparent
harm in VS2013, so is still a win.
Justin Lebar [Tue, 22 Mar 2016 00:09:28 +0000 (00:09 +0000)]
[CUDA] Implement atomicInc and atomicDec builtins
These functions cannot be implemented as atomicrmw or cmpxchg
instructions, so they are implemented as a call to the NVVM intrinsics
@llvm.nvvm.atomic.load.inc.32.p0i32 and
@llvm.nvvm.atomic.load.dec.32.p0i32.
Chris Bieneman [Mon, 21 Mar 2016 22:37:14 +0000 (22:37 +0000)]
[Perf-training] Adding support for tests to skip the clang driver
This patch adds a new set of substitutions to the lit run lines for order files and PGO generation which run the clang driver to get the cc1 command, then execute the cc1 command directly. This allows the scripts to bypass profiling the clang driver over and over again.
The approach in this patch was discussed via IRC with Sean Silvas.
Special thanks to Daniel Dunbar whose out-of-tree code I liberally plagiarized.
Richard Smith [Mon, 21 Mar 2016 21:16:01 +0000 (21:16 +0000)]
[modules] Renumber DECL_UPDATES from 30 to 50, so it no longer collides with
TYPE_TEMPLATE_SPECIALIZATION. This was fine in practice because both record
kinds are only ever found by offset, but made the llvm-bcanalyzer -dump output
very confusing.
Pete Cooper [Mon, 21 Mar 2016 20:50:03 +0000 (20:50 +0000)]
Revert "Convert some ObjC msgSends to runtime calls."
This reverts commit r263607.
This change caused more objc_retain/objc_release calls in the IR but those
are then incorrectly optimized by the ARC optimizer. Work is going to have
to be done to ensure the ARC optimizer doesn't optimize user written RR, but
that should land before this change.
This change will also need to be updated to take account for any changes required
to ensure that user written calls to RR are distinct from those inserted by ARC.
Daniel Jasper [Mon, 21 Mar 2016 14:11:27 +0000 (14:11 +0000)]
clang-format: Make include sorting's main include detection configurable.
This patch adds a regular expression to configure suffixes of an
included file to check whether it is the "main" include of the current
file. Previously, clang-format has allowed arbitrary suffixes on the
formatted file, which is still the case when no IncludeMainRegex is
specified.
Faisal Vali [Mon, 21 Mar 2016 09:25:37 +0000 (09:25 +0000)]
[Cxx1z] Implement Lambda Capture of *this by Value as [=,*this] (P0018R3)
Implement lambda capture of *this by copy.
For e.g.:
struct A {
int d = 10;
auto foo() { return [*this] (auto a) mutable { d+=a; return d; }; }
};
auto L = A{}.foo(); // A{}'s lifetime is gone.
// Below is still ok, because *this was captured by value.
assert(L(10) == 20);
assert(L(100) == 120);
If the capture was implicit, or [this] (i.e. *this was captured by reference), this code would be otherwise undefined.
Implementation Strategy:
- amend the parser to accept *this in the lambda introducer
- add a new king of capture LCK_StarThis
- teach Sema::CheckCXXThisCapture to handle by copy captures of the
enclosing object (i.e. *this)
- when CheckCXXThisCapture does capture by copy, the corresponding
initializer expression for the closure's data member
direct-initializes it thus making a copy of '*this'.
- in codegen, when assigning to CXXThisValue, if *this was captured by
copy, make sure it points to the corresponding field member, and
not, unlike when captured by reference, what the field member points
to.
- mark feature as implemented in svn
Much gratitude to Richard Smith for his carefully illuminating reviews!
Devin Coughlin [Sun, 20 Mar 2016 18:24:33 +0000 (18:24 +0000)]
[tsan] Allow -fsanitize=thread for iOS-style simulator targets
Update the clang driver to allow -fsanitize=thread when targeting x86_64 iOS and tvOS
simulators. Also restrict TSan targeting OS X to only be supported on x86_64 and not i386.
Reapply [2] [VFS] Add 'overlay-relative' field to YAML files
This reapplies r261552 and r263748. Fixed testcase to reapply.
The VFS overlay mapping between virtual paths and real paths is done through
the 'external-contents' entries in YAML files, which contains hardcoded paths
to the real files.
When a module compilation crashes, headers are dumped into <name>.cache/vfs
directory and are mapped via the <name>.cache/vfs/vfs.yaml. The script
generated for reproduction uses -ivfsoverlay pointing to file to gather the
mapping between virtual paths and files inside <name>.cache/vfs. Currently, we
are only capable of reproducing such crashes in the same machine as they
happen, because of the hardcoded paths in 'external-contents'.
To be able to reproduce a crash in another machine, this patch introduces a new
option in the VFS yaml file called 'overlay-relative'. When it's equal to
'true' it means that the provided path to the YAML file through the
-ivfsoverlay option should also be used to prefix the final path for every
'external-contents'.
Example, given the invocation snippet "... -ivfsoverlay
<name>.cache/vfs/vfs.yaml" and the following entry in the yaml file:
Here, a file manager request for virtual "/usr/include/stdio.h", that will map
into real path "/<absolute_path_to>/<name>.cache/vfs/usr/include/stdio.h.
This is a useful feature for debugging module crashes in machines other than
the one where the error happened.
[Sema] Make type deduction work with some overloadable functions
Some functions can't have their address taken. If we encounter an
overload set where only one of the candidates can have its address
taken, we should automatically select that candidate's type in type
deduction.
Some functions can't have their address taken. If we encounter an
overload set where only one of the candidates can have its address
taken, we should automatically select that candidate in cast
expressions.
Carlo Bertolli [Fri, 18 Mar 2016 21:43:32 +0000 (21:43 +0000)]
[OPENMP] Implementation of codegen for firstprivate clause of target directive
This patch implements the following aspects:
It extends sema to check that a variable is not reference in both a map clause and firstprivate or private. This is needed to ensure correct functioning at codegen level, apart from being useful for the user.
It implements firstprivate for target in codegen. The implementation applies to both host and nvptx devices.
It adds regression tests for codegen of firstprivate, host and device side when using the host as device, and nvptx side.
Please note that the regression test for nvptx codegen is missing VLAs. This is because VLAs currently require saving and restoring the stack which appears not to be a supported operation by nvptx backend.
It adds a check in sema regression tests for target map, firstprivate, and private clauses.
Steven Watanabe [Fri, 18 Mar 2016 21:35:59 +0000 (21:35 +0000)]
Fix printing of anonymous struct typedefs.
clang -cc1 -ast-print put the struct
definition in the wrong place, like this:
struct {} typedef S;
The reason that this happens is that the printing code
first prints the struct definition, and then tells the next
declaration to leave out the type. This behavior
is correct for simple variable declarations, but fails for
typedefs (or extern, mutable, etc).
The patch address this problem by skipping the struct
declaration when we first see it, and then telling the first
subsequent declaration that it needs to print out the full
struct definition.
Akira Hatanaka [Fri, 18 Mar 2016 19:03:50 +0000 (19:03 +0000)]
[Objective-c] Fix a crash in WeakObjectProfileTy::getBaseInfo.
The crash occurs in WeakObjectProfileTy::getBaseInfo when getBase() is
called on an ObjCPropertyRefExpr object whose receiver is an interface.
This commit fixes the crash by checking the type of the receiver and
setting IsExact to true if it is an interface.
Summary:
r246764 handled __fp16 arguments and returns for AAPCS, but skipped this
handling for OpenCL. Simlar to OpenCL, RenderScript also handles __fp16
type natively.
This patch adds the -fnative-half-arguments-and-returns command line
flag to allow such languages to skip this coercion of __fp16.
Mike Spertus [Fri, 18 Mar 2016 16:38:34 +0000 (16:38 +0000)]
Show members of DeclContexts (i.e., class members) in Visual Studio native visualizers
This change shows members of DeclContext objects in the Visual Studio debugger. It will also cast a TagType like a class or a struct to a DeclContext, so its methods and fields are visualized.
Benjamin Kramer [Fri, 18 Mar 2016 13:31:00 +0000 (13:31 +0000)]
Make LookupResult movable again.
We lost copy semantics in r263730, because it only worked for a few very
specific cases. Move semantics don't have this issue. Sadly the
implementation is a bit messy but I don't know how to clean it up
without losing support for msvc 2013 :/
Reapply [VFS] Add 'overlay-relative' field to YAML files
This reapplies r261552.
The VFS overlay mapping between virtual paths and real paths is done through
the 'external-contents' entries in YAML files, which contains hardcoded paths
to the real files.
When a module compilation crashes, headers are dumped into <name>.cache/vfs
directory and are mapped via the <name>.cache/vfs/vfs.yaml. The script
generated for reproduction uses -ivfsoverlay pointing to file to gather the
mapping between virtual paths and files inside <name>.cache/vfs. Currently, we
are only capable of reproducing such crashes in the same machine as they
happen, because of the hardcoded paths in 'external-contents'.
To be able to reproduce a crash in another machine, this patch introduces a new
option in the VFS yaml file called 'overlay-relative'. When it's equal to
'true' it means that the provided path to the YAML file through the
-ivfsoverlay option should also be used to prefix the final path for every
'external-contents'.
Example, given the invocation snippet "... -ivfsoverlay
<name>.cache/vfs/vfs.yaml" and the following entry in the yaml file:
Here, a file manager request for virtual "/usr/include/stdio.h", that will map
into real path "/<absolute_path_to>/<name>.cache/vfs/usr/include/stdio.h.
This is a useful feature for debugging module crashes in machines other than
the one where the error happened.
Benjamin Kramer [Thu, 17 Mar 2016 16:19:51 +0000 (16:19 +0000)]
Use a simpler set of mock headers for the vfs+modules crash recovery tests.
The System/ mock is large and too complex for this test. It can cause
the tests to fail in mysterious ways as it depends on the resource dir
being present, which is not really supported for driver tests (using
%clang instead of %clang_cc1). Copy the tree and trim out all the
%unnecessary fat.
If a call takes a single argument, using AlwaysBreak can lead to lots
of wasted lines and additional indentation without improving the
readability in a significant way.
Alexey Bataev [Thu, 17 Mar 2016 10:50:17 +0000 (10:50 +0000)]
[OPENMP 4.5] Allow to use private data members in 'copyprivate' clause.
OpenMP 4.5 allows privatization of non-static data members in non-static
member functions. This patch adds support of private data members in
'copyprivate' clauses.
Alexey Bataev [Thu, 17 Mar 2016 10:19:46 +0000 (10:19 +0000)]
[OPENMP 4.0] Use 'declare reduction' constructs in 'reduction' clauses.
OpenMP 4.0 allows to define custom reduction operations using '#pragma
omp declare reduction' construct. Patch allows to use this custom
defined reduction operations in 'reduction' clauses.
Manman Ren [Thu, 17 Mar 2016 03:09:55 +0000 (03:09 +0000)]
Add an optional named argument (replacement = "xxx") to AvailabilityAttr.
This commit adds a named argument to AvailabilityAttr, while r263652 adds an
optional string argument to __attribute__((deprecated)). This enables the
compiler to provide Fix-Its for deprecated declarations.
Reapply [2]: [VFS] Add support for handling path traversals
This was applied twice r261551 and 263617 and later reverted because:
(1) Windows bot failing on unittests. Change the current behavior to do
not handle path traversals on windows.
(2) Windows bot failed to include llvm/Config/config.h in order to use
HAVE_REALPATH. Use LLVM_ON_UNIX instead, as done in lib/Basic/FileManager.cpp.
Handle ".", ".." and "./" with trailing slashes while collecting files
to be dumped into the vfs overlay directory.
Include the support for symlinks into components. Given the path:
/install-dir/bin/../lib/clang/3.8.0/include/altivec.h, if "bin"
component is a symlink, it's not safe to use `path::remove_dots` here,
and `realpath` is used to get the right answer. Since `realpath`
is expensive, we only do it at collecting time (which only happens
during the crash reproducer) and cache the base directory for fast lookups.
Overall, this makes the input to the VFS YAML file to be canonicalized
to never contain traversal components.
Carlo Bertolli [Wed, 16 Mar 2016 19:04:22 +0000 (19:04 +0000)]
[OPENMP] Support for codegen of private clause of target, host side
This patch adds support for codegen of private clause of target and a regression test for host code generation, when the host is used as target device. I believe that code generation for nvptx backend would not require anything additional or different to what is done for the host.
Roman Levenstein [Wed, 16 Mar 2016 18:00:46 +0000 (18:00 +0000)]
Add attributes for preserve_mostcc/preserve_allcc calling conventions to the C/C++ front-end
Till now, preserve_mostcc/preserve_allcc calling convention attributes were only
available at the LLVM IR level. This patch adds attributes for
preserve_mostcc/preserve_allcc calling conventions to the C/C++ front-end.
The code was mostly written by Juergen Ributzka.
I just added support for the AArch64 target and tests.
Olivier Goffart [Wed, 16 Mar 2016 14:36:11 +0000 (14:36 +0000)]
Fix destructor definition of invalid classes
The declaration of the destructor of an invalid class was not properly marked
as noexcept. As a result, the definition of the same destructor, which was
properly implicitly marked as noexcept, would not match the definition.
This would cause the definition CXXDestructorDecl to be matked as invalid
and omited from the AST.