| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
| |
PR18999.
llvm-svn: 202491
|
|
|
|
|
|
| |
It makes our -fdump-record-layouts a little more sane.
llvm-svn: 202457
|
|
|
|
|
|
|
|
|
|
|
| |
This is a heuristic. Many switch statements, although they look covered
over an enum, may actually handle at runtime more values than in the enum.
This is overly conservative, as there are some cases that clearly
can be ruled as being clearly unreachable, e.g. 'switch (42) { case 1: ... }'.
We can refine this later.
llvm-svn: 202436
|
|
|
|
|
|
| |
statements preceded by 'noreturn' functions.
llvm-svn: 202352
|
|
|
|
| |
llvm-svn: 202351
|
|
|
|
|
|
| |
They are covered by -Wcovered-switch-default.
llvm-svn: 202349
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
preceded by a call to a 'noreturn' function.
For example:
unreachable();
break;
This code is idiomatic and defensive. The fact that 'break' is
unreachable here is not interesting. This occurs frequently
in LLVM/Clang itself.
llvm-svn: 202328
|
|
|
|
|
|
|
| |
Upgrades the warning to an error and clarifies the message by treating the
definition as error instead of the attribute.
llvm-svn: 202300
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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);
if (&foo); // no warning
}
llvm-svn: 202216
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
llvm-svn: 202211
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
llvm-svn: 202088
|
|
|
|
| |
llvm-svn: 201947
|
|
|
|
|
|
|
|
| |
that the optimizer does not duplicate code.
Patch thanks to Marcello Maggioni!
llvm-svn: 201941
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
Differential Revision: http://llvm-reviews.chandlerc.com/D2742
llvm-svn: 201927
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
Differential Revision: http://llvm-reviews.chandlerc.com/D2795
llvm-svn: 201907
|
|
|
|
| |
llvm-svn: 201893
|
|
|
|
|
|
|
|
| |
management: asserting a capability is held, acquiring a capability and releasing a capability. Also includes some skeleton documentation for these new attributes.
This functionality should be considered a WIP.
llvm-svn: 201890
|
|
|
|
|
|
|
|
| |
pathological cases.
PR18905.
llvm-svn: 201795
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
functionality) and I have agreed to start migrating from lock-specific terminology to "capability"-specific terminology. This opens the door for future threading-related analysis passes so that a common nomenclature can be used.
The following attributes have been (silently) deprecated, with their replacements listed:
lockable => capability
exclusive_locks_required => requires_capability
shared_locks_required => requires_shared_capability
locks_excluded => requires_capability
There are no functional changes intended.
llvm-svn: 201585
|
|
|
|
|
|
|
|
|
| |
According to the GNU docs, zero-sized bitfields should not be affected by the
packed attribute.
Differential Revision: http://llvm-reviews.chandlerc.com/D2693
llvm-svn: 201288
|
|
|
|
|
|
|
|
| |
Allowing alignment past this point causes wrap around within clang.
N.B. GCC has the same restriction.
llvm-svn: 201254
|
|
|
|
|
|
| |
rdar://problem/16035743
llvm-svn: 201233
|
|
|
|
|
|
|
|
|
|
| |
-Wnon-literal-null-conversion in C code.
It is actually useful to warn in such cases, thanks to Dmitri for pushing on this and making us see the light!
Related to rdar://15925483 and rdar://15922612. The latter radar is where the usefulness of the warning is most clear.
llvm-svn: 201165
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Thanks to r199467, __attribute__((nonnull)) (without arguments) can apply
directly to parameters, instead of being applied to the whole function.
However, the old form of nonnull (with an argument index) could also apply
to the arguments of function and block pointers, and both of these can be
passed as parameters.
Now, if 'nonnull' with an argument is found on a parameter, /and/ the
parameter is a function or block pointer, it is handled the old way.
PR18795
llvm-svn: 201162
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When a lax conversion featured a vector and a non-vector, we were
only requiring the non-vector to be a scalar type, but really it
needs to be a real type (i.e. integral or real floating); it is
not reasonable to allow a pointer, member pointer, or complex
type here.
r198474 required lax conversions to match in "data size", i.e.
element size * element count, forbidding matches that happen
only because a vector is rounded up to the nearest power of two
in size. Unfortunately, the erroneous logic was repeated in
several different places; unify them to use the new condition,
so that it triggers for arbitrary conversions and not just
those performed as part of binary operator checking.
rdar://15931426
llvm-svn: 200810
|
|
|
|
|
|
|
|
|
|
| |
casts, which are used
by some projects in their null macro.
rdar://15925483
llvm-svn: 200521
|
|
|
|
|
|
|
|
| |
the diagnostic only when subsequent alignments are more strict than the alignment required by the first field.
Fixes PR15134
llvm-svn: 200277
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Due to statement expressions supported as GCC extension, it is possible
to put 'break' or 'continue' into a loop/switch statement but outside
its body, for example:
for ( ; ({ if (first) { first = 0; continue; } 0; }); )
This code is rejected by GCC if compiled in C mode but is accepted in C++
code. GCC bug 44715 tracks this discrepancy. Clang used code generation
that differs from GCC in both modes: only statement of the third
expression of 'for' behaves as if it was inside loop body.
This change makes code generation more close to GCC, considering 'break'
or 'continue' statement in condition and increment expressions of a
loop as it was inside the loop body. It also adds error for the cases
when 'break'/'continue' appear outside loop due to this syntax. If
code generation differ from GCC, warning is issued.
Differential Revision: http://llvm-reviews.chandlerc.com/D2518
llvm-svn: 199897
|
|
|
|
|
|
| |
match argument type.
llvm-svn: 199867
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
create an implicit declaration of it (because some type it depends on is
unavailable). This had the effect of causing us to not implicitly give it the
right attributes. It turns out that glibc's __sigsetjmp is declared before
sigjmp_buf is declared, and this resulted in us not implicitly giving it
__attribute__((returns_twice)), which in turn resulted in miscompiles in any C
code calling glibc's sigsetjmp.
(See also the vaguely-related sourceware.org/PR4662.)
llvm-svn: 199850
|
|
|
|
|
|
|
|
|
|
| |
'returns_nonnull'.
This involved making CheckReturnStackAddr into a static function, which
is now called by a top-level return value checking routine called
CheckReturnValExpr.
llvm-svn: 199790
|
|
|
|
|
|
| |
Patch by Alex Wang.
llvm-svn: 199762
|
|
|
|
|
|
| |
GCC warning about attributes on function definitions for both of them.
llvm-svn: 199710
|
|
|
|
| |
llvm-svn: 199663
|
|
|
|
|
|
|
|
|
|
|
| |
This attribute is supported by GCC. More generally it should
probably be a type attribute, but this behavior matches 'nonnull'.
This patch does not include warning logic for checking if a null
value is returned from a function annotated with this attribute.
That will come in subsequent patches.
llvm-svn: 199626
|
|
|
|
|
|
| |
function, Objective-C method, or parameter.
llvm-svn: 199496
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This allows the following syntax:
void baz(__attribute__((nonnull)) const char *str);
instead of:
void baz(const char *str) __attribute__((nonnull(1)));
This also extends to Objective-C methods.
The checking logic in Sema is not as clean as I would like. Effectively
now we need to check both the FunctionDecl/ObjCMethodDecl and the parameters,
so the point of truth is spread in two places, but the logic isn't that
cumbersome.
Implements <rdar://problem/14691443>.
llvm-svn: 199467
|
|
|
|
|
|
|
|
| |
This ports the last Sema tests over to use the frontend directly, and adds a
local lit substitution to disable inappropriate %clang usage under this
directory.
llvm-svn: 199348
|
|
|
|
|
|
|
|
|
| |
-verify was simply ignored by the driver.
This commit fixes the RUN line and XFAILs the test, unblocking changes to ban
use of the driver in Sema tests and avoid problems like this.
llvm-svn: 199347
|
|
|
|
|
|
|
|
|
|
|
| |
a subprocess invocation which is pretty significant on Windows. It also
likely saves a bunch of thrashing the host machine needlessly. Finally
it makes the tests much more predictable and less dependent on the host.
For example 'header_lookup1.c' was passing '-fno-ms-extensions' just to
thwart the host detection adding it into the compilation. By runnig CC1
directly we don't have to deal with such oddities.
llvm-svn: 199308
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This makes the C++ ABI depend entirely on the target: MS ABI for -win32 triples,
Itanium otherwise. It's no longer possible to do weird combinations.
To be able to run a test with a specific ABI without constraining it to a
specific triple, new substitutions are added to lit: %itanium_abi_triple and
%ms_abi_triple can be used to get the current target triple adjusted to the
desired ABI. For example, if the test suite is running with the i686-pc-win32
target, %itanium_abi_triple will expand to i686-pc-mingw32.
Differential Revision: http://llvm-reviews.chandlerc.com/D2545
llvm-svn: 199250
|
|
|
|
|
|
| |
attribute. Fixing these test cases to use the proper spelling for their syntax.
llvm-svn: 199141
|
|
|
|
|
|
|
|
|
|
| |
In preparation for making the Win32 triple imply MS ABI mode,
make all tests pass in this mode, or make them use the Itanium
mode explicitly.
Differential Revision: http://llvm-reviews.chandlerc.com/D2401
llvm-svn: 199130
|
|
|
|
|
|
| |
resolution based on the values of the function arguments at the call site.
llvm-svn: 198996
|
|
|
|
|
|
| |
rdar://15779837.
llvm-svn: 198856
|
|
|
|
|
|
| |
This test adjustment was missing from the previous patch.
llvm-svn: 198822
|
|
|
|
| |
llvm-svn: 198741
|
|
|
|
| |
llvm-svn: 198479
|
|
|
|
|
|
|
|
|
|
|
| |
consideration the num-of-elements*width-of-element width.
Disallow casts when such width is not equal between the vector types otherwise
we may end up with an invalid LLVM bitcast.
rdar://15722308.
llvm-svn: 198474
|
|
|
|
|
|
| |
how to handle Attr objects directly. Updates an associated test case due to the attribute name being properly quoted again.
llvm-svn: 198424
|