Richard Trieu [Wed, 26 Feb 2014 02:36:06 +0000 (02:36 +0000)]
PR16074, implement warnings to catch pointer to boolean true and pointer to
null comparison when the pointer is known to be non-null.
This catches the array to pointer decay, function to pointer decay and
address of variables. This does not catch address of function since this
has been previously used to silence a warning.
Pointer to bool conversion is under -Wbool-conversion.
Pointer to null comparison is under -Wtautological-pointer-compare, a sub-group
of -Wtautological-compare.
void foo() {
int arr[5];
int x;
// warn on these conditionals
if (foo);
if (arr);
if (&x);
if (foo == null);
if (arr == null);
if (&x == null);
Richard Trieu [Wed, 26 Feb 2014 01:17:28 +0000 (01:17 +0000)]
Add -Wabsolute-value, warnings about absolute value functions.
The warnings fall into three groups.
1) Using an absolute value function of the wrong type, for instance, using the
int absolute value function when the argument is a floating point type.
2) Using the improper sized absolute value function, for instance, using abs
when the argument is a long long. llabs should be used instead.
From these two cases, an implicit conversion will occur which may cause
unexpected behavior. Where possible, suggest the proper absolute value
function to use, and which header to include if the function is not available.
3) Taking the absolute value of an unsigned value. In addition to this warning,
suggest to remove the function call. This usually indicates a logic error
since the programmer assumed negative values would have been possible.
Roman Divacky [Tue, 25 Feb 2014 18:35:30 +0000 (18:35 +0000)]
Give sparcv9 the ability to set the target cpu. Change it from accepting
-march which doesnt exist on sparc gcc to -mcpu. While here adjust a
few tests to not write an unused temporary file.
Reid Kleckner [Tue, 25 Feb 2014 18:08:48 +0000 (18:08 +0000)]
MS ABI: Just use getTypeInfoInChars to get the field size
This was changed to use manual desugaring and multiplication in r201832
and fixed for multi-dimensional arrays in r201917. However, it breaks
down in the presence of typedefs. Rather than attempting to handle all
the desugaring, just go back to calling the generic type info code.
This was discovered while compiling SIInstrWaits.cpp in the R600
backend.
Benjamin Kramer [Tue, 25 Feb 2014 17:26:26 +0000 (17:26 +0000)]
Pretty Printer: Fix printing of conversion operator decls and calls.
- Don't emit anything when we encounter a call to a conversion operator.
"bar(a & b)" instead of "bar(a & b.operator int())"
This preserves the semantics and is still idempotent if we print the AST multiple times.
- Properly print declarations of conversion operators.
"explicit operator bool();" instead of "bool operator _Bool();"
Tim Northover [Tue, 25 Feb 2014 13:53:01 +0000 (13:53 +0000)]
AArch64: use different type modifier in arm_neon.td
The 'f' modifier is designed for integer type arguments really (according to
its documentation). It's better to use the "half width, same number" modifier.
Add documentation for these attributes, it includes:
- Motivation for their existence.
- Examples on how to use them.
- Examples on how to misuse them.
which not only simplifies reading and writing these files (for humans),
but makes it possible to easily modify locations via textual
replacement, which would not have worked in the old scheme.
Reid Kleckner [Tue, 25 Feb 2014 00:59:14 +0000 (00:59 +0000)]
MS ABI: Return sret parameters when using inalloca
Previously the X86 backend would look for the sret attribute and handle
this for us. inalloca takes that all away, so we have to do the return
ourselves now.
David Majnemer [Mon, 24 Feb 2014 23:34:17 +0000 (23:34 +0000)]
Sema: Make getPreferredTypeAlign respect alignments specified with an aligned attribute on a typedef
When calculating the preferred alignment of a type, consider if a alignment
attribute came from a typedef declaration. If one did, do not naturally align
the type.
Patch by Stephan Tolksdorf, with a little tweaking and an additional testcase by me.
Richard Smith [Mon, 24 Feb 2014 20:50:36 +0000 (20:50 +0000)]
If preprocessing results in a token with leading whitespace that was expanded
from a macro in column 0, ensure that we print whitespace before it in the -E
output. Patch by Harald van Dijk!
Richard Smith [Mon, 24 Feb 2014 20:45:00 +0000 (20:45 +0000)]
If the first token in a macro that appears at the start of a line expands to
nothing, be sure to inform the *next* token expanded from the macro that it is
now at the start of a line. Patch by Harald van Dijk!
Hans Wennborg [Mon, 24 Feb 2014 15:58:24 +0000 (15:58 +0000)]
[Win32 ABI] Defer operator delete checks until vtable is marked used
We were previously checking at every destructor declaration, but that was a bit
excessive. Since the deleting destructor is emitted with the vtable, do the
check when the vtable is marked used.
Manuel Klimek [Mon, 24 Feb 2014 10:28:36 +0000 (10:28 +0000)]
Fix docs generation for the AST matchers:
1. Move internal functions into ASTMatchersInternal.
2. Adapt dump_ast_matchers.py to the new VariadicOperatorMatcherFunc
signature.
3. Update the actual docs with the updated tool / code.
Kevin Qin [Mon, 24 Feb 2014 02:45:03 +0000 (02:45 +0000)]
[AArch64] Change int64_t from 'long long int' to 'long int' for AArch64 target.
Most 64-bit targets define int64_t as long int, and AArch64 should
make same definition to follow LP64 model. In GNU tool chain, int64_t
is defined as long int for 64-bit target. So to get consistent with GNU,
it's better Changing int64_t from 'long long int' to 'long int',
otherwise clang will get different name mangling suffix compared with g++.
- Only include offsets with local (in function scope) symbols, where we don't encode scoping
- Only include the filename with non-system symbols. Presumably the system headers will not provide conflicting definitions.
Aaron Ballman [Sun, 23 Feb 2014 16:27:21 +0000 (16:27 +0000)]
Fixing the indentation of the RST content in the release notes. Fixes two warnings when building the HTML content and improves the format of the resulting content.
Now that the integrated assembler is considered a first class feature of the
compiler and has a proper feature flag, document the change in the compiler
flags. Ensure that we indicate that the legacy flags are still available, but,
encourage users to switch to the feature flags.
clang: add -f{no-,}integrate-as as consistent parameters
The integrated assembler is a feature. This makes the new flags the default
option, and the previous versions aliases. Ideally, at some point the aliases
would be entirely removed.
Bob Wilson [Sun, 23 Feb 2014 00:11:56 +0000 (00:11 +0000)]
Remove support for the QA_OVERRIDE_GCC3_OPTIONS environment variable.
In r199283 I switched the name of this variable to CCC_OVERRIDE_OPTIONS, but
I kept some code to continue recognizing the old name temporarily. As far as
I know, the only use of this was for some internal testing at Apple, and we've
now switched to use the new name. If anyone else is still using this and needs
more time to switch names, I guess we'll find out! <rdar://problem/15821425>
Forward the -no-integrated-as option to -cc1 rather than simply invoking the
appropriate tool. This is useful since this option has been overloaded to
permit disabling of parsing inline assembly at the MC layer.
This re-applies the previous version of the patch with a renaming of the driver
option to the public name rather than the internal name (-target vs -triple).
The actual failure is fixed separately of an overly aggressive negative pattern
match in the MIPS driver tests. It also fixes the incorrect test for targets
that have the integrated assembler disabled by default.
The tests attempt to validate the invocation of the assembler program with the
integrated assembler disabled. However, the match pattern for the negative
tests are lax and will match both the driver invocation as well as the assembler
invocation. Make the tests more strict by ensuring that we only match the
assembler invocation.
Forward the -no-integrated-as option to -cc1 rather than simply invoking the
appropriate tool. This is useful since this option has been overloaded to
permit disabling of parsing inline assembly at the MC layer.
The language forbids defining enums in prototypes, so this check is normally
redundant, but if an enum is defined during template instantiation it should
not be added to the prototype scope.
While at it, clean up the code that deals with tag definitions in prototype
scope and expand the visibility warning to cover the case where an anonymous
enum is defined.
Warren Hunt [Sat, 22 Feb 2014 00:47:24 +0000 (00:47 +0000)]
[_mm_prefetch] Returning previously deleted comment.
No functional change. It's unclear if the word FIXME is relevant given
that the macro behaves as intended.
Warren Hunt [Sat, 22 Feb 2014 00:40:37 +0000 (00:40 +0000)]
[MS-ABI] Fix MSRecordLayout to handel MultiDimensionalArrays
A recent change caused multi-dimensional arrays not to be handled
correctly, this patch fixes that. Also, it adds a lit test for
multi-dimensional arrays.
Ted Kremenek [Sat, 22 Feb 2014 00:02:03 +0000 (00:02 +0000)]
[ObjC] Make attribute 'objc_protocol_requires_explicit_implementation' behave correctly with default property synthesis.
In particular, if we see an @property within the @interface of a class
conforming to a protocol with this attribute, we treat that as
if the implementation were available, per the rules of default
property synthesis.
Warren Hunt [Fri, 21 Feb 2014 23:49:50 +0000 (23:49 +0000)]
Complete Rewrite of CGRecordLayoutBuilder
CGRecordLayoutBuilder was aging, complex, multi-pass, and shows signs of
existing before ASTRecordLayoutBuilder. It redundantly performed many
layout operations that are now performed by ASTRecordLayoutBuilder and
asserted that the results were the same. With the addition of support
for the MS-ABI, such as placement of vbptrs, vtordisps, different
bitfield layout and a variety of other features, CGRecordLayoutBuilder
was growing unwieldy in its redundancy.
This patch re-architects CGRecordLayoutBuilder to not perform any
redundant layout but rather, as directly as possible, lower an
ASTRecordLayout to an llvm::type. The new architecture is significantly
smaller and simpler than the CGRecordLayoutBuilder and contains fewer
ABI-specific code paths. It's also one pass.
The architecture of the new system is described in the comments. For the
most part, the new system simply takes all of the fields and bases from
an ASTRecordLayout, sorts them, inserts padding and dumps a record.
Bitfields, unions and primary virtual bases make this process a bit more
complicated. See the inline comments.
In addition, this patch updates a few lit tests due to the fact that the
new system computes more accurate llvm types than CGRecordLayoutBuilder.
Each change is commented individually in the review.
Ben Langmuir [Fri, 21 Feb 2014 23:39:37 +0000 (23:39 +0000)]
Add a VFSFromYAML class and a parser to create it
Provides a way to create a virtual file system using a YAML file that
supports mapping a file to a path on an 'external' file system. The
external file system will typically be the 'real' file system, but for
testing it can be changed.
A future patch will add a clang option to allow the user to specify such
a file and overlay it, but for now this code is only exercised by the
unit tests.
Warren Hunt [Fri, 21 Feb 2014 23:08:53 +0000 (23:08 +0000)]
Reapply 201734 but with appropriate gcc compatibility
Because GCC incorrectly defines _mm_prefetch to take anything that casts
to void*, people have started using that behavior. The previous patch
that made _mm_prefetch actually take a const char * broke compatibility
with existing code. This update to the patch leaves the macro that
defines _mm_prefetch with the (void*) cast when _MSC_VER is not defined.