Correcting some comments. (1) the function is named throughUsingDecl() and not throughUsingDeclaration(). (2) Testing shows that this does work for shadowed variables as well as shadowed functions. I could not find an example where this matcher was failing. NFC.
Add extensive tests for the mingw toolchain and remove trailing slash from Arch.
Address Richard Smith comments: remove the trailing seperator from the Arch
variable, implement six mingw_* trees under tools/clangtest/Driver/Inputs
and merge linux and Windows tests into a universal test that uses these trees.
David Majnemer [Fri, 24 Jul 2015 05:54:19 +0000 (05:54 +0000)]
[AST] Perform additional canonicalization for DependentSizedArrayType
We treated DependentSizedArrayTypes with the same element type but
differing size expressions as equivalently canonical. This would lead
to bizarre behavior during template instantiation.
Piotr Padlewski [Fri, 24 Jul 2015 04:04:49 +0000 (04:04 +0000)]
Generating available_externally vtables for outline virtual functions
Generating available_externally vtables for optimizations purposes.
Unfortunatelly ItaniumABI doesn't guarantee that we will be able to
refer to virtual inline method by name.
But when we don't have any inline virtual methods, and key function is
not defined in this TU, we can generate that there will be vtable and
mark it as available_externally.
This is patch will help devirtualize better.
Differential Revision: http://reviews.llvm.org/D11441
Steven Wu [Fri, 24 Jul 2015 02:12:43 +0000 (02:12 +0000)]
Fix the cc1as crash when it outputs assembly
In clang cc1as_main, when the output file type is “asm”, AsmStreamer
owns a formatted_raw_ostream which has a reference to FDOS
(raw_ostream), so AsmStreamer must be closed before FDOS is closed.
John McCall [Thu, 23 Jul 2015 23:54:07 +0000 (23:54 +0000)]
Fix the equal-vector-size rule for reinterpret_casts in C++
to consider the storage size of the vector instead of its
sizeof. In other words, ban <3 x int> to <4 x int> casts,
which produced invalid IR anyway.
Also, attempt to be a little more rigorous, or at least
explicit, about when enums are allowed in these casts.
InstrProf: Don't extend coverage regions into the catch keyword
The catch keyword isn't really part of a region, so it's fairly
meaningless to extend into it. This was usually harmless, but it could
crash when catch blocks involved macros in strange ways.
Sema: Split out helper from checkForFunctionCall(), NFC
Split out `hasRecursiveCallInPath()` from `checkForFunctionCall()` to
flatten nesting and clarify the code. This also simplifies a follow-up
patch that refactors the other logic in `checkForFunctionCall()`.
Currently, for --rtlib=compiler-rt on GNU systems, we're assuming
that one has libgcc_s and libgcc_eh as low-level libraries, which
when used in conjunction with -lunwind or -lc++abi, breaks that
assumption.
My original fix was wrong, and this patch reverts it to prepare for
a new flag to choose the unwinder/C++ libraries. For the time being,
people can use "-lgcc_s -lgcc_eh" or "-lunwind -lc++abi" or any
combination they need explicitly.
David Majnemer [Wed, 22 Jul 2015 23:46:18 +0000 (23:46 +0000)]
[MS Compat] Allow _Atomic(Type) and 'struct _Atomic' to coexist
MSVC 2013 ships, as part of its STL implementation, a class named
'_Atomic'. This is unfortunate because this keyword is in conflict with
the C11 keyword with the same name. Our solution was to disable this
keyword when targeting MSVC 2013 and reenable it for 2015.
However, this makes it impossible for clang's headers to make use of
_Atomic. This is problematic in the case of libc++ as it makes heavy
use of this keyword.
Let the keywordness of _Atomic float under certain circumstances:
the body of a class named _Atomic, or a class with a base specifier
named _Atomic, will not have the keyword variant of _Atomic for the
duration of the class body. This is sufficient to allow us to correctly
handle _Atomic in the STL while permitting us to use _Atomic as a
keyword everywhere else.
Richard Smith [Wed, 22 Jul 2015 02:08:40 +0000 (02:08 +0000)]
[modules] Stop performing PCM lookups for all identifiers when building with C++ modules. Instead, serialize a list of interesting identifiers and mark those ones out of date on module import. Avoiding the identifier lookups here gives a 20-30% speedup in builds with large numbers of modules. No functionality change intended.
Richard Smith [Wed, 22 Jul 2015 01:28:05 +0000 (01:28 +0000)]
[modules] Change module manager visitation order to be a bit more stable when
more modules are added: visit modules depth-first rather than breadth-first.
The visitation is still (approximately) oldest-to-newest, and still guarantees
that a module is visited before anything it imports, so modules that are
imported by others sometimes need to jump to a later position in the visitation
order when more modules are loaded, but independent module trees don't
interfere with each other any more.
Davide Italiano [Wed, 22 Jul 2015 00:30:58 +0000 (00:30 +0000)]
[Sema] Diagnose use of declaration correctly.
Before we skipped that for virtual functions not fully qualified (r81507).
This commit basically reverts this to the older behaviour, which seems
more consistent. We now also correctly consider ill-formed calls to deleted
member functions, which were silently passed before in some cases.
The review contains the whole discussion.
Richard Smith [Tue, 21 Jul 2015 23:54:07 +0000 (23:54 +0000)]
[modules] In C++, stop serializing and deserializing a list of declarations in
the identifier table. This is redundant, since the TU-scope lookups are also
serialized as part of the TU DeclContext, and wasteful in a number of ways. We
still emit the decls for PCH / preamble builds, since for those we want
identical results, not merely semantically equivalent ones.
Richard Smith [Tue, 21 Jul 2015 18:07:47 +0000 (18:07 +0000)]
[modules] Produce an error if -cc1 wants to implicitly build a module and no
module cache has been provided, rather than creating one in the current
directory.
Fix mingw toolchain to honor sysroot on Linux and add tests.
It should now support three mingw distributions running on Windows
and three Linux distributions. The include directories for each are
listed in the comments.
This recommits r242736, which had to be reverted because the llvm-side
change that was committed in r242737 caused the number of subtarget
features to go over the limit of 64.
This change is needed since backend options do not make it to the backend
when doing LTO and are not capable of changing the behavior of code-gen
passes on a per-function basis.
This change is needed since backend options do not make it to the backend
when doing LTO and are not capable of changing the behavior of code-gen
passes on a per-function basis.
Bob Wilson [Mon, 20 Jul 2015 22:57:36 +0000 (22:57 +0000)]
Refactor TableGen backend for ClangAttrEmitter to avoid duplication.
GenerateHasAttrSpellingStringSwitch and GenerateTargetRequirements had
duplicated code to check the conditions for target-specific attributes.
Refactor the duplicated code into a separate function. NFC.
Bob Wilson [Mon, 20 Jul 2015 22:57:31 +0000 (22:57 +0000)]
Ignore the "novtable" declspec when not using the Microsoft C++ ABI.
Clang used to silently ignore __declspec(novtable). It is implemented
now, but leaving the vtable uninitialized does not work when using the
Itanium ABI, where the class layout for complex class hierarchies is
stored in the vtable. It might be possible to honor the novtable
attribute in some simple cases and either report an error or ignore
it in more complex situations, but it’s not clear if that would be
worthwhile. There is also value in having a simple and predictable
behavior, so this changes clang to simply ignore novtable when not using
the Microsoft C++ ABI.
Fix code completion tests to use an explicit modules cache path
Otherwise the stale module cache data may cause the test to fail. These
two tests are new and are the only instances of c-index-test with
-fmodules that doesn't have an explicit module cache path.
Fix a case where we forgot to make a static local variable comdat
Sometimes we can provide an initializer for static locals, in which case
we sometimes might need to change the type. Changing the type requires
making a new LLVM GlobalVariable, and in this codepath we were
forgetting to transfer the comdat.
This is the PS4 counterpart to r229376, which quotes the library name if the
name contains space. It was discovered that if a library name contains both
double-quote and space characters, quoting the name might produce unexpected
results, but we are mostly concerned with a Windows host environment, which
does not allow double-quote or slashes in file/folder names.
Allow case-insensitive values for -mtune for AArch64 target in line with GCC.
GCC allows case-insensitive values for -mcpu, -march and -mtune options.
This patch implements the same behaviour for the -mtune option for the AArch64 target.
Richard Smith [Mon, 20 Jul 2015 08:40:51 +0000 (08:40 +0000)]
Attempt to fix greendragon buildbot failures; apparently wc sometimes inserts a leading space into its output. Just check for a matching number anywhere in the output.
Richard Smith [Sun, 19 Jul 2015 21:41:12 +0000 (21:41 +0000)]
[modules] Don't save uninteresting identifiers, and don't consider identifiers
to be interesting just because they are the name of a builtin. Reduces the size
of an empty module by over 80% (~100KB).
Benjamin Kramer [Sat, 18 Jul 2015 17:09:36 +0000 (17:09 +0000)]
[AST] Remove StmtRange in favor of an iterator_range.
StmtRange was just a convenient wrapper for two StmtIterators before
we had real range support. This removes some of the implicit conversions
StmtRange had leading to slightly more verbose code but also should make
more obvious what's going on. No functional change intended.
Benjamin Kramer [Sat, 18 Jul 2015 14:35:53 +0000 (14:35 +0000)]
[AST] Cleanup ExprIterator.
- Make it a proper random access iterator with a little help from iterator_adaptor_base
- Clean up users of magic dereferencing. The iterator should behave like an Expr **.
- Make it an implementation detail of Stmt. This allows inlining of the assertions.
Silence the driver warnings, if we see "-w" on the Driver.
Summary:
We can enable warnings after that -w, so the patch might not be 100%
correct.
The problem that triggered this is: we have some amount of tests that
expect 0 warnings (including unit tests for -w), but -w ends up not fully
silencing everything.
David Majnemer [Fri, 17 Jul 2015 23:36:49 +0000 (23:36 +0000)]
[MS ABI] Explicit specialization of static data members are weak
Normally, explicit specializations are treated like strong external
definitions. However, MSVC treats explicit specializations of static
data members as weak. MSVC 2013's <regex> implementation has such an
explicit specialization which leads to clang emitting a strong
definition in each translation unit which includes it. Tweak clang's
linkage calculation to give such entities GVA_StrongODR linkage instead.
InstrProf: Promote this assert to a report_fatal_error
If this assert does fire, the no-asserts behaviour is an infinite
loop. It's better to crash in this case so we get a crash report and
stop wasting the user's cpu cycles.
James Y Knight [Fri, 17 Jul 2015 21:58:11 +0000 (21:58 +0000)]
Hopefully fix android i386 build after r242554.
That platform has alignof(uint64_t) == 4, but, since LLVM_ALIGNAS(...)
cannot take anything but literal integers due to MSVC limitations, the
literal '8' used there didn't match. Switch ScopeStackAlignment to
just use 8, as well.
The "armv7-windows", "i686-windows", and "x86_64-windows" targets should be
equivalent to the MSVC environment. This was previously discussed when the
triples for Windows werw canonicalised. Im not sure how this was overlooked.
This fixes the emission of non-COFF formats on Windows.