Richard Smith [Tue, 13 Oct 2015 00:39:40 +0000 (00:39 +0000)]
[modules] Allow the error on importing a C++ module within an extern "C"
context (but otherwise at the top level) to be disabled, to support use of C++
standard library implementations that (legitimately) mark their <blah.h>
headers as being C++ headers from C libraries that wrap things in 'extern "C"'
a bit too enthusiastically.
Richard Smith [Tue, 13 Oct 2015 00:23:25 +0000 (00:23 +0000)]
[modules] Fix merging of __va_list_tag's implicit special member functions.
We model predefined declarations as not being from AST files, but in most ways
they act as if they come from some implicit prebuilt module file imported
before all others. Therefore, if we see an update to the predefined 'struct
__va_list_tag' declaration (and we've already loaded any modules), it needs a
corresponding update record, even though it didn't technically come from an AST
file.
Evgeniy Stepanov [Mon, 12 Oct 2015 23:50:19 +0000 (23:50 +0000)]
[safestack] Driver link test for safestack on android.
Safestack runtime should never be linked on Android targets because
it is implemented directly in libc. This is already the case, but
mostly by chance (collectSanitizerRuntimes would only link shared
sanitizer runtimes, and safestack has only a static one). Protect
this behavior with a test.
Add support for the `-fdebug-prefix-map=` option as in GCC. The syntax is
`-fdebug-prefix-map=OLD=NEW`. When compiling files from a path beginning with
OLD, change the debug info to indicate the path as start with NEW. This is
particularly helpful if you are preprocessing in one path and compiling in
another (e.g. for a build cluster with distcc).
Note that the linearity of the implementation is not as terrible as it may seem.
This is normally done once per file with an expectation that the map will be
small (1-2) entries, making this roughly linear in the number of input paths.
Chris Bieneman [Mon, 12 Oct 2015 16:34:23 +0000 (16:34 +0000)]
[CMake] Bug 14109 - CMake build for compiler-rt should use just-built clang
Summary:
Many small improvements to LLVM_BUILD_EXTERNAL_COMPILER_RT.
* Works correctly with Ninja by working around CMake Bug 14771 (https://cmake.org/Bug/view.php?id=14771)
* Has install-compiler-rt target, and installs as part of the default install target
* Sets the install paths properly so that it matches the non-standalone build
* Only generate the test targets if(LLVM_INCLUDE_TESTS)
Benjamin Kramer [Mon, 12 Oct 2015 16:16:39 +0000 (16:16 +0000)]
[VFS] Let the user decide if they want path normalization.
This is a more principled version of what I did earlier. Path
normalization is generally a good thing, but may break users in strange
environments, e. g. using lots of symlinks. Let the user choose and
default it to on.
This also changes adding a duplicated file into returning an error if
the file contents are different instead of an assertion failure.
Alexey Bataev [Mon, 12 Oct 2015 06:59:48 +0000 (06:59 +0000)]
[ATTR] Automatic line feed after pragma-like attribute.
Automatically insert line feed after pretty printing of all pragma-like attributes + fix printing of pragma-like pragmas on declarations.
Differential Revision: http://reviews.llvm.org/D13546
C allows for some implicit conversions that C++ does not, e.g. void* ->
char*. This patch teaches clang that these conversions are okay when
dealing with overloads in C.
NAKAMURA Takumi [Sat, 10 Oct 2015 02:37:30 +0000 (02:37 +0000)]
[CMake] Always generate and install cmake config files on CMake>=3.0.
Currently, cmake config files are only generated and installed when CLANG_BUILD_STANDALONE set, which means config file will not be generated or installed when clang is built with llvm. This change removes that restriction.
Douglas Gregor [Fri, 9 Oct 2015 20:36:17 +0000 (20:36 +0000)]
Fix inference of _Nullable for weak Objective-C properties.
The inference of _Nullable for weak Objective-C properties was broken
in several ways:
* It was back-patching the type information very late in the process
of checking the attributes for an Objective-C property, which is
just wrong.
* It was using ad hoc checks to try to suppress the warning about
missing nullability specifiers (-Wnullability-completeness), which
didn't actual work in all cases (rdar://problem/22985457)
* It was inferring _Nullable even outside of assumes-nonnull regions,
which is wrong.
Putting the inference of _Nullable for weak Objective-C properties in
the same place as all of the other inference logic fixes all of these
ills.
The goal of wanting this to avoid munging the feature list is so
that it can be used for various targets as a way of both adding
and verifying the features that are going to be output into the
IR.
Analysis: Make CFG::graph_iterator dereference to non-const
Since the original commit in r145858, we've had `CFG::graph_iterator`
and `CFG::const_graph_iterator`, and both have derefenced to a
`const`-ified `value_type`. The former has an implicit conversion to
non-`const`, which is how this worked at all until r249782 started using
the dereference operator (partially reverted in r249783).
This fixes the non-const iterator to be non-const (sometimes
const-iterators are intentional, but with a separate const-ified class
(and a non-const implicit conversion leak) that's not likely to be the
case here).
Benjamin Kramer [Fri, 9 Oct 2015 13:03:25 +0000 (13:03 +0000)]
[VFS] Wire up driver VFS through tooling.
Sadly I don't currently have a way to tests this as the driver is always
initialized with the default triple and finding system headers is system
specific.
Benjamin Kramer [Fri, 9 Oct 2015 09:54:37 +0000 (09:54 +0000)]
[VFS] Port tooling to use the in-memory file system.
This means file remappings can now be managed by ClangTool (or a
ToolInvocation user) instead of by ToolInvocation itself. The
ToolInvocation remapping is still in place so users can migrate.
Eric Fiselier [Fri, 9 Oct 2015 00:17:57 +0000 (00:17 +0000)]
Skip NonNull sema checks in unevaluated contexts.
Summary:
Currently when a function annotated with __attribute__((nonnull)) is called in an unevaluated context with a null argument a -Wnonnull warning is emitted.
This warning seems like a false positive unless the call expression is potentially evaluated. Change this behavior so that the non-null warnings use DiagRuntimeBehavior so they wont emit when they won't be evaluated.
Hans Wennborg [Thu, 8 Oct 2015 23:13:28 +0000 (23:13 +0000)]
Expose -f[no]ms-{compatibility,extensions} in clang-cl (PR25114)
These are enabled by default in clang-cl, because the whole idea is that
it should work like cl.exe, but I suppose it can make sense to disable
them if someone wants to compile code in a more strict mode.
Handle sse turning on mmx, but no -mmx not turning off SSE.
Rationale :
// sse3
__m128d test_mm_addsub_pd(__m128d A, __m128d B) {
return _mm_addsub_pd(A, B);
}
// mmx
void shift(__m64 a, __m64 b, int c) {
_mm_slli_pi16(a, c);
_mm_slli_pi32(a, c);
_mm_slli_si64(a, c);
_mm_srli_pi16(a, c);
_mm_srli_pi32(a, c);
_mm_srli_si64(a, c);
_mm_srai_pi16(a, c);
_mm_srai_pi32(a, c);
}
clang -msse3 -mno-mmx file.c -c
For this code we should be able to explicitly turn off MMX
without affecting the compilation of the SSE3 function and then
diagnose and error on compiling the MMX function.
This is a preparatory patch to the actual diagnosis code which is
coming in a future patch. This sets us up to have the correct information
where we need it and verifies that it's being emitted for the backend
to handle.
Migrate most feature map inclusion to initFeatureMap for the x86 target so
that we can build up an accurate set of features rather than relying on
TargetInfo initialization via handleTargetFeatures to munge the list
of features.
Aaron Ballman [Thu, 8 Oct 2015 19:24:08 +0000 (19:24 +0000)]
When mapping no_sanitize_* attributes to no_sanitize attributes, handle GNU-style formatting that involves prefix and suffix underscores. Cleans up other usages of similar functionality.
Reid Kleckner [Thu, 8 Oct 2015 17:29:07 +0000 (17:29 +0000)]
[clang-cl] Make /EHs turn on C++ EH once again
C++ exceptions are still off by default, which is similar to how C++
cleanups are off by default in MSVC.
If you use clang instead of clang-cl, exceptions are also still off by
default. In the future, when C++ EH is proven to be stable, we may flip
the default for that driver to be consistent with other platforms.
Renato Golin [Thu, 8 Oct 2015 16:43:26 +0000 (16:43 +0000)]
Simplify DefaultCPU in ARMTargetInfo
Simplifying the convoluted CPU handling in ARMTargetInfo.
The default base CPU on ARM is ARM7TDMI, arch ARMv4T, and
ARMTargetInfo had a different one. This wasn't visible from
Clang because the driver selects the defaults and sets the
Arch/CPU features directly, but the constructor depended
on the CPU, which was never used.
This patch corrects the mistake and greatly simplifies
how CPU is dealt with (essentially by removing the duplicated
DefaultCPU field).
David Majnemer [Thu, 8 Oct 2015 10:04:46 +0000 (10:04 +0000)]
[MSVC Compat] Try to treat an implicit, fixed enum as an unfixed enum
consider the following:
enum E *p;
enum E { e };
The above snippet is not ANSI C because 'enum E' has not bee defined
when we are processing the declaration of 'p'; however, it is a popular
extension to make the above work. This would fail using the Microsoft
enum semantics because the definition of 'E' would implicitly have a
fixed underlying type of 'int' which would trigger diagnostic messages
about a mismatch between the declaration and the definition.
Instead, treat fixed underlying types as not fixed for the purposes of
the diagnostic.
Alexey Bataev [Thu, 8 Oct 2015 09:10:53 +0000 (09:10 +0000)]
[OPENMP 4.1] Codegen for array sections/subscripts in 'reduction' clause.
OpenMP 4.1 adds support for array sections/subscripts in 'reduction' clause. Patch adds codegen for this feature.
David Majnemer [Thu, 8 Oct 2015 07:45:35 +0000 (07:45 +0000)]
[Sema] Tweak incomplete enum types on MSVC ABI targets
Enums without an explicit, fixed, underlying type are implicitly given a
fixed 'int' type for ABI compatibility with MSVC. However, we can
enforce the standard-mandated rules on these types as-if we didn't know
this fact if the tag is not part of a definition.
David Majnemer [Thu, 8 Oct 2015 06:31:22 +0000 (06:31 +0000)]
Update tests touched by r249656
These test updates almost exclusively around the change in behavior
around enum: enums without a definition are considered incomplete except
when targeting MSVC ABIs. Since these tests are interested in the
'incomplete-enum' behavior, restrict them to %itanium_abi_triple.
David Majnemer [Thu, 8 Oct 2015 04:53:31 +0000 (04:53 +0000)]
[MSVC Compat] Enable ABI impacting non-conforming behavior independently of -fms-compatibility
No ABI for C++ currently makes it possible to implement the standard
100% perfectly. We wrongly hid some of our compatible behavior behind
-fms-compatibility instead of tying it to the compiler ABI.
Douglas Katzman [Thu, 8 Oct 2015 04:24:12 +0000 (04:24 +0000)]
Stop messing with the 'g' group of options in CompilerInvocation.
With this change, most 'g' options are rejected by CompilerInvocation.
They remain only as Driver options. The new way to request debug info
from cc1 is with "-debug-info-kind={line-tables-only|limited|standalone}"
and "-dwarf-version={2|3|4}". In the absence of a command-line option
to specify Dwarf version, the Toolchain decides it, rather than placing
Toolchain-specific logic in CompilerInvocation.
Also fix a bug in the Windows compatibility argument parsing
in which the "rightmost argument wins" principle failed.
Richard Smith [Thu, 8 Oct 2015 00:17:59 +0000 (00:17 +0000)]
When pretty-printing a C++11 literal operator, don't insert whitespace between
the "" and the suffix; that breaks names such as 'operator""if'. For symmetry,
also remove the space between the 'operator' and the '""'.
Reid Kleckner [Thu, 8 Oct 2015 00:17:45 +0000 (00:17 +0000)]
Don't emit exceptional stackrestore cleanups around inalloca functions
The backend restores the stack pointer after recovering from an
exception. This is similar to r245879, but it doesn't try to use the
normal cleanup mechanism, so hopefully it won't cause the same breakage.
Ehsan Akhgari [Thu, 8 Oct 2015 00:01:20 +0000 (00:01 +0000)]
Make clang_Cursor_getMangling not mangle if the declaration isn't mangled
Right now clang_Cursor_getMangling will attempt to mangle any
declaration, even if the declaration isn't mangled (extern C). This
results in a partially mangled name which isn't useful for much. This
patch makes clang_Cursor_getMangling return an empty string if the
declaration isn't mangled.
Reid Kleckner [Wed, 7 Oct 2015 21:03:41 +0000 (21:03 +0000)]
[WinEH] Don't use lifetime markers for MS catch parameters
We don't have a good place to put them. Our previous spot was causing us
to optimize loads from the exception object to undef, because it was
after the catchpad instruction that models the write to the catch
object.
Daniel Jasper [Wed, 7 Oct 2015 19:56:12 +0000 (19:56 +0000)]
ASTMatchers: Keep AllCallbacks in a set instead of a vector
AllCallbacks is currently only used to call onStartOfTranslationUnit and
onEndOfTranslationUnit on them. In this (and any other scenario I can
come up with), it is important (or at least better) not to have
duplicates in this container. E.g. currently onEndOfTranslationUnit is
called repeatedly on the same callback for every matcher that is
registered with it.
Alexey Bataev [Wed, 7 Oct 2015 10:22:08 +0000 (10:22 +0000)]
Fix crash in codegen on casting to `bool &`.
Currently codegen crashes trying to emit casting to bool &. It happens because bool type is converted to i1 and later then lvalue for reference is converted to i1*. But when codegen tries to load this lvalue it crashes trying to load value from this i1*.
Benjamin Kramer [Wed, 7 Oct 2015 10:05:44 +0000 (10:05 +0000)]
[VFS] Refactor VFSFromYAML a bit.
- Rename it to RedirectingFileSystem. This is what it does, YAML is just a
serialization format for it.
- Consistently use unique_ptr for memory management.
Ehsan Akhgari [Tue, 6 Oct 2015 18:24:33 +0000 (18:24 +0000)]
Make clang_Cursor_getMangling don't mangle if the declaration isn't mangled
Right now clang_Cursor_getMangling will attempt to mangle any
declaration, even if the declaration isn't mangled (extern "C"). This
results in a partially mangled name which isn't useful for much. This
patch makes clang_Cursor_getMangling return an empty string if the
declaration isn't mangled.
Benjamin Kramer [Tue, 6 Oct 2015 14:45:20 +0000 (14:45 +0000)]
[Tooling] Reuse FileManager in ASTUnit.
ASTUnit was creating multiple FileManagers and throwing them away. Reuse
the one from Tooling. No functionality change now but necessary for
VFSifying tooling.
Benjamin Kramer [Tue, 6 Oct 2015 14:45:13 +0000 (14:45 +0000)]
[Tooling] Remove dead code.
It took me some time to figure out why this is not working as expected:
std:error_code converts to true if there is an error. This means we never
ever took the generated absolute path, which happens to be the right thing
anyways as it properly works with virtual files. Just remove the whole
thing, relative paths are covered by existing tooling tests.