Objective-C. Fixes a bogus warning on unimplemented
selectors because we were not going through entire
elements in list of all implemented selectors.
// rdar://16428638
Logan Chien [Wed, 26 Mar 2014 17:35:01 +0000 (17:35 +0000)]
Fix atomic libcall.
This commit fixes a cast instruction assertion failure
due to the incompatible type cast. This will only happen when
the target requires atomic libcalls.
Jordan Rose [Wed, 26 Mar 2014 17:05:46 +0000 (17:05 +0000)]
[analyzer] Handle the M_ZERO and __GFP_ZERO flags in kernel mallocs.
Add M_ZERO awareness to malloc() static analysis in Clang for FreeBSD,
NetBSD, and OpenBSD in a similar fashion to O_CREAT for open(2).
These systems have a three-argument malloc() in the kernel where the
third argument contains flags; the M_ZERO flag will zero-initialize the
allocated buffer.
This should reduce the number of false positives when running static
analysis on BSD kernels.
Additionally, add kmalloc() (Linux kernel malloc()) and treat __GFP_ZERO
like M_ZERO on Linux.
Future work involves a better method of checking for named flags without
hardcoding values.
Patch by Conrad Meyer, with minor modifications by me.
Paul Robinson [Wed, 26 Mar 2014 16:40:43 +0000 (16:40 +0000)]
Recommit r204493 with a fix to look in both clang and llvm directories.
Hopefully addresses r204539.
Make clang/test/lit.cfg pre-scan the RUN line looking for tool names,
and substitute fully qualified path names pointing to the build
directory. This ensures we're testing the just-built tools.
Reid Kleckner [Wed, 26 Mar 2014 15:38:33 +0000 (15:38 +0000)]
-fms-extensions: Add __va_start builtin, which is used for x64
The main difference between __va_start and __builtin_va_start is that
the address of the va_list has already been taken, and the va_list is
always a char*.
Move the -i[no-]system-prefix options from CC1Options.td to Options.td.
Summary:
This allows them to be used without -cc1 the same way as -I and -isystem.
Renamed the options to --system-header-prefix=/--no-system-header-prefix to avoid interference with -isystem and make the intent of the option cleaner.
Bob Wilson [Tue, 25 Mar 2014 23:26:31 +0000 (23:26 +0000)]
[PGO] Add simplified branch weights for Objective-C for-collection loops.
Conceptually one of these loops is just a while-loop, but the actual code-gen
is more complicated. We don't instrument all the different control flow edges
to get accurate counts for each conditional branch, nor do I think it makes
sense to do so. Instead, make the simplifying assumption that the loop behaves
like a while-loop. Use the same branch weights for the first check for an
empty collection as would be used for the back-edge of a while loop, and use
that same weighting for the innermost loop, ignoring the possibility that there
may be some extra code to go fetch more elements.
Benjamin Kramer [Tue, 25 Mar 2014 18:02:07 +0000 (18:02 +0000)]
Fix an logic error in the clang driver preventing crtfastmath.o from linking when -Ofast is used without -ffast-math
In gcc using -Ofast forces linking of crtfastmath.o.
In the current clang crtfastmath.o is only linked when -ffast-math/-funsafe-math-optimizations passed. It can lead to performance issues, when using only -Ofast without explicit -ffast-math (I faced with it).
My patch fixes inconsistency with gcc behaviour and also introduces few tests on it.
Jordan Rose [Tue, 25 Mar 2014 17:10:58 +0000 (17:10 +0000)]
[analyzer] Don't track retain counts of objects directly accessed through ivars.
A refinement of r198953 to handle cases where an object is accessed both through
a property getter and through direct ivar access. An object accessed through a
property should always be treated as +0, i.e. not owned by the caller. However,
an object accessed through an ivar may be at +0 or at +1, depending on whether
the ivar is a strong reference. Outside of ARC, we don't have that information,
so we just don't track objects accessed through ivars.
With this change, accessing an ivar directly will deliberately override the +0
provided by a getter, but only if the +0 hasn't participated in other retain
counting yet. That isn't perfect, but it's already unusual for people to be
mixing property access with direct ivar access. (The primary use case for this
is in setters, init methods, and -dealloc.)
Thanks to Ted for spotting a few mistakes in private review.
Manuel Klimek [Tue, 25 Mar 2014 14:39:26 +0000 (14:39 +0000)]
Fixes a bug in DynTypedNode.
Two DynTypedNodes can be equal if they do not have the same node type,
because DynTypedNodes for the same underlying object might have been
created from different types (for example, Decl vs VarDecl).
Richard Smith [Tue, 25 Mar 2014 01:14:22 +0000 (01:14 +0000)]
Save out a correct lookup table if a lookup table entry is stale (it contains
an out-of-date external decls list). This happens if we declare some names,
force the lookup table for the decl context to be built, import a module that
adds more decls for the name, then write out our module without looking up the
name.
Richard Smith [Tue, 25 Mar 2014 00:34:21 +0000 (00:34 +0000)]
If a DeclContext's lookups need to be reconciled, and we're given external declarations for a name, reconcile first. Otherwise, when we come to reconcile, we'll ask for external declarations for that name again. No functionality change intended.
David Majnemer [Mon, 24 Mar 2014 21:43:36 +0000 (21:43 +0000)]
MS ABI: Eliminate Duplicate Strings
COFF doesn't have mergeable sections so LLVM/clang's normal tactics for
string deduplication will not have any effect.
To remedy this we place each string inside it's own section and mark
the section as IMAGE_COMDAT_SELECT_ANY. However, we can only do this if the
string has an external name that we can generate from it's contents.
To be compatible with MSVC, we must use their scheme. Otherwise identical
strings in translation units from clang may not be deduplicated with
translation units in MSVC.
This fixes PR18248.
N.B. We will not attempt to do anything with a string literal which is not of
type 'char' or 'wchar_t' because their compiler does not support unicode
string literals as of this date. Further, we avoid doing this if
either -fwritable-strings or -fsanitize=address are present.
Warren Hunt [Mon, 24 Mar 2014 21:37:27 +0000 (21:37 +0000)]
[MS-ABI] Drop Special Layout in 64-bit mode.
As of cl.exe version 18, the special layout rules for structs with
alignment 16 or greater has been dropped. This patch drops the behavior
from clang. This patch also updates the lit tests to reflect the
change.
Aaron Ballman [Mon, 24 Mar 2014 19:29:19 +0000 (19:29 +0000)]
Capability attributes can now be declared on a typedef declaration as well as a structure declaration. This allows for C code to use Boolean expressions on a capability as part of another attribute. Eg) __attribute__((requires_capability(!SomeCapability)))
Will Schmidt [Mon, 24 Mar 2014 17:27:03 +0000 (17:27 +0000)]
[PPC64LE] Add a CALL_ELF macro to indicate use of the ELFv2 ABI.
Additional clarification from Uli for the background on _CALL_ELF:
"Historically GCC has provided various _CALL_... predefines depending on the
ABI currently being compiled for. (_CALL_SYSV,_CALL_AIXDESC, _CALL_DARWIN )
When we needed a new define for the current ABI, we decided on using _CALL_ELF
since the official name of the ABI is the OpenPower ElfV2 ABI, with the
current Linux ABI retro-actively being renamed the ELFv1 ABI
and so we decided on using _CALL_ELF to identify the Linux (+BSD etc.) ELF ABI,
with _CALL_ELF=1 for the v1 ABI and _CALL_ELF=2 for the v2 ABI.
(Note that this matches the gcc compiler switch -mabi=elfv1 vs. -mabi=elfv2)."
In code, a (_CALL_ELF==2) check will indicate when the ELFv2 ABI is
to be used. This is the desired default for the PPC64 LE target.
Will Schmidt [Mon, 24 Mar 2014 17:10:37 +0000 (17:10 +0000)]
Update the parameters passed to the assembler and linker for
the PPC64LE target. Specifically:
(assembler) adds/uses -mppc64 -mlittle-endian
(linker) adds/uses elf64lppc
David Majnemer [Mon, 24 Mar 2014 05:53:08 +0000 (05:53 +0000)]
MS ABI: Add tests, other cleanups for r204562
This commit cleans up a few accidents:
- Do not rely on the order in which StringLiteral lays out bytes.
- Use a more efficient mechanism for handling so-called
"special-mappings" when mangling string literals.
- There is no need to allocate a copy of the mangled name.
- Add the test written for r204562.
Richard Smith [Sun, 23 Mar 2014 20:41:56 +0000 (20:41 +0000)]
If a name is injected into an imported inline namespace without reopening that
namespace, we need to update both the visible names of that namespace and of
its enclosing namespace set.
Richard Smith [Sun, 23 Mar 2014 19:45:26 +0000 (19:45 +0000)]
When we inject a declaration into a namespace, add the primary DeclContext to
the update set rather than the current DeclContext. Add test for the local
extern case too.
Simplify test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance.cpp by forcing VFTableBuilder invocation with virtual function calls or constructors codegen
Previously the vftables were built at the end of the TU in a reverse-to-random order
David Majnemer [Sun, 23 Mar 2014 17:47:16 +0000 (17:47 +0000)]
MS ABI: Eliminate Duplicate Strings
COFF doesn't have mergeable sections so LLVM/clang's normal tactics for
string deduplication will not have any effect.
To remedy this we place each string inside it's own section and mark
the section as IMAGE_COMDAT_SELECT_ANY. However, we can only do this if the
string has an external name that we can generate from it's contents.
To be compatible with MSVC, we must use their scheme. Otherwise identical
strings in translation units from clang may not be deduplicated with
translation units in MSVC.
This fixes PR18248.
N.B. We will not attempt to do anything with a string literal which is not of
type 'char' or 'wchar_t' because their compiler does not support unicode
string literals as of this date.
Nuno Lopes [Sun, 23 Mar 2014 17:12:37 +0000 (17:12 +0000)]
remove a bunch of unused private methods
found with a smarter version of -Wunused-member-function that I'm playwing with.
Appologies in advance if I removed someone's WIP code.
Richard Smith [Sun, 23 Mar 2014 02:30:01 +0000 (02:30 +0000)]
If a template instantation introduces a name into a namespace, we need to write
out a visible update record for that namespace even if it was never declared in
this module.
Richard Smith [Sat, 22 Mar 2014 23:33:22 +0000 (23:33 +0000)]
Emit an update record if we instantiate the definition of a function template
specialization from a module. (This can also happen for function template
specializations in PCHs if they're instantiated eagerly, because they're
constexpr or have a deduced return type.)
Adrian Prantl [Fri, 21 Mar 2014 21:01:58 +0000 (21:01 +0000)]
CGDebugInfo: At the end of EmitFunctionStart, Initialize PrevLoc to the
location that the next call emitLocation() would default to. Otherwise
setLocation() may wrongly believe that the current source file didn't
change, when in fact it did.
Paul Robinson [Fri, 21 Mar 2014 18:13:35 +0000 (18:13 +0000)]
Make clang/test/lit.cfg pre-scan the RUN line looking for tool names,
and substitute fully qualified path names pointing to the build
directory. This ensures we're testing the just-built tools.
Aaron Ballman [Fri, 21 Mar 2014 14:48:48 +0000 (14:48 +0000)]
The release_capability, release_shared_capability and release_generic_capability functions are now functionally distinct for capability analysis. The unlock_function attribute maps directly to release_generic_capability.
Alexey Samsonov [Fri, 21 Mar 2014 13:09:25 +0000 (13:09 +0000)]
[CMake] Propagate top-level targets for compiler-rt runtimes and test-suites
from (external) compiler-rt build tree into LLVM/Clang build tree in
LLVM_BUILD_EXTERNAL_COMPILER_RT mode.
For instance, running
make asan -j12
in LLVM/Clang build tree will now build Clang, use it to configure
compiler-rt build tree, and invoke "make asan -j12" there. ASan runtime will
be built in the proper location, where Clang driver expects to find it.
Running
make check-asan
will build Clang, use it to configure compiler-rt build tree, build everything
there, and then run "make check-asan" in compiler-rt build tree using just-built
Clang and ASan runtime.
Richard Smith [Fri, 21 Mar 2014 00:33:59 +0000 (00:33 +0000)]
PR19215: When writing/reading a PCH that imported a module, store the location
at which that PCH imported each visible submodule of the module. Such locations
are needed when synthesizing macro directives resulting from the import.
PGO: Don't define instrumentation data available_externally
Variables with available_externally linkage can be dropped at will.
This causes link errors, since there are still references to the
instrumentation! linkonce_odr is almost equivalent, so use that
instead.
As a drive-by fix (I don't have an Elf system, so I'm not sure how to
write a testcase), use linkonce linkage for the instrumentation of
extern_weak functions.