summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema
Commit message (Collapse)AuthorAgeFilesLines
...
* CFG: Also apply the filter to the first block in a FilteredCFGBlockIterator.Benjamin Kramer2014-02-281-0/+7
| | | | | | PR18999. llvm-svn: 202491
* -fdump-record-layouts: Sort nvbases by offset before printing themReid Kleckner2014-02-281-2/+2
| | | | | | It makes our -fdump-record-layouts a little more sane. llvm-svn: 202457
* [-Wunreachable-code] always treat 'case:' and 'default:' cases as reachable.Ted Kremenek2014-02-271-0/+3
| | | | | | | | | | | 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
* [-Wunreachable-code] Don't warn about trivially unreachable return ↵Ted Kremenek2014-02-271-0/+13
| | | | | | statements preceded by 'noreturn' functions. llvm-svn: 202352
* Fix test case indentation.Ted Kremenek2014-02-271-1/+1
| | | | llvm-svn: 202351
* [-Wunreachable-code] Don't warn about unreachable 'default:' cases.Ted Kremenek2014-02-271-1/+24
| | | | | | They are covered by -Wcovered-switch-default. llvm-svn: 202349
* [-Wunreachable-code] Prune out unreachable warnings where a 'break' is ↵Ted Kremenek2014-02-271-0/+21
| | | | | | | | | | | | | | | 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
* Sema: Definition of dllimport globals is not allowedNico Rieck2014-02-262-8/+12
| | | | | | | Upgrades the warning to an error and clarifies the message by treating the definition as error instead of the attribute. llvm-svn: 202300
* PR16074, implement warnings to catch pointer to boolean true and pointer toRichard Trieu2014-02-262-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add -Wabsolute-value, warnings about absolute value functions.Richard Trieu2014-02-262-0/+818
| | | | | | | | | | | | | | | | | | 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
* Sema: Make getPreferredTypeAlign respect alignments specified with an ↵David Majnemer2014-02-241-0/+6
| | | | | | | | | | | | 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
* Reorganize and improve semantic tests for dllexport/importNico Rieck2014-02-223-48/+181
| | | | llvm-svn: 201947
* Exposing the noduplicate attribute within Clang, which marks functions so ↵Aaron Ballman2014-02-221-0/+8
| | | | | | | | that the optimizer does not duplicate code. Patch thanks to Marcello Maggioni! llvm-svn: 201941
* Do not add enums to prototype scope in C++ modes.Peter Collingbourne2014-02-221-2/+2
| | | | | | | | | | | | | | 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
* Complete Rewrite of CGRecordLayoutBuilderWarren Hunt2014-02-211-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add test that -Wunreachable-code warnings are suppressed in headers.Ted Kremenek2014-02-212-1/+10
| | | | llvm-svn: 201893
* Adding role-based capability attributes that allow you to express role ↵Aaron Ballman2014-02-211-0/+32
| | | | | | | | 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
* Sema: Emit a warning for non-null terminated format strings and other ↵Benjamin Kramer2014-02-201-0/+15
| | | | | | | | pathological cases. PR18905. llvm-svn: 201795
* DeLesley Hutchins (who wrote the original thread-safety attribute ↵Aaron Ballman2014-02-181-0/+25
| | | | | | | | | | | | | | | 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
* Fixing a compiler assertion with zero-width bit-fields in packed structs.Yunzhong Gao2014-02-131-0/+15
| | | | | | | | | 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
* Sema: Restrict alignment to 2**28.David Majnemer2014-02-121-0/+1
| | | | | | | | Allowing alignment past this point causes wrap around within clang. N.B. GCC has the same restriction. llvm-svn: 201254
* ARM & NEON: add test for r101232Tim Northover2014-02-121-0/+217
| | | | | | rdar://problem/16035743 llvm-svn: 201233
* [Sema] Revert the change in r200622 that allowed integer casts to silence ↵Argyrios Kyrtzidis2014-02-111-2/+2
| | | | | | | | | | -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
* 'nonnull(1)' on a block parameter should apply to the block's argument.Jordan Rose2014-02-111-0/+8
| | | | | | | | | | | | | | | 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
* Tighten lax vector-conversion rules and enforce them consistently.John McCall2014-02-042-1/+11
| | | | | | | | | | | | | | | | | | | | 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
* [Sema] For -Wnon-literal-null-conversion warning, look through integer ↵Argyrios Kyrtzidis2014-01-311-0/+3
| | | | | | | | | | casts, which are used by some projects in their null macro. rdar://15925483 llvm-svn: 200521
* Relaxing the alignment requirements for fields in a transparent_union. Emits ↵Aaron Ballman2014-01-281-1/+19
| | | | | | | | the diagnostic only when subsequent alignments are more strict than the alignment required by the first field. Fixes PR15134 llvm-svn: 200277
* Fix to PR8880 (clang dies processing a for loop)Serge Pavlov2014-01-232-3/+121
| | | | | | | | | | | | | | | | | | | | | | | 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
* Change an absolute value function in a test from floating to integer toRichard Trieu2014-01-231-1/+1
| | | | | | match argument type. llvm-svn: 199867
* Don't forget about a builtin if we're about to redeclare it and we couldn'tRichard Smith2014-01-221-0/+9
| | | | | | | | | | | | | 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
* Add basic checking for returning null from functions/methods marked ↵Ted Kremenek2014-01-221-0/+6
| | | | | | | | | | '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
* Correct the function name shown in diagnostics in warn-thread-safety-analysis.cDavid Blaikie2014-01-211-14/+7
| | | | | | Patch by Alex Wang. llvm-svn: 199762
* Neither attribute overloadable nor enable_if are supported by GCC. Disable theNick Lewycky2014-01-211-2/+2
| | | | | | GCC warning about attributes on function definitions for both of them. llvm-svn: 199710
* Making some minor improvements to r199626.Aaron Ballman2014-01-201-4/+4
| | | | llvm-svn: 199663
* Wire up basic parser/sema support for attribute 'returns_nonnull'.Ted Kremenek2014-01-201-0/+6
| | | | | | | | | | | 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
* Adding a test case for nonnull being attached to something other than a ↵Aaron Ballman2014-01-171-0/+1
| | | | | | function, Objective-C method, or parameter. llvm-svn: 199496
* Enhance attribute 'nonnull' to be applicable to parameters directly (infix).Ted Kremenek2014-01-171-0/+11
| | | | | | | | | | | | | | | | | | | | | 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
* Forbid driver use in Sema testsAlp Toker2014-01-168-12/+12
| | | | | | | | 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
* Disable and XFAIL a test that never workedAlp Toker2014-01-161-1/+3
| | | | | | | | | -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
* Move a bunch of tests to directly use the CC1 layer. This at least savesChandler Carruth2014-01-153-4/+4
| | | | | | | | | | | 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
* Remove the -cxx-abi command-line flag.Hans Wennborg2014-01-143-6/+5
| | | | | | | | | | | | | | | 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
* There is no such thing as __attribute__((align)); that's a __declspec ↵Aaron Ballman2014-01-132-2/+2
| | | | | | attribute. Fixing these test cases to use the proper spelling for their syntax. llvm-svn: 199141
* Update tests in preparation for using the MS ABI for Win32 targetsHans Wennborg2014-01-131-1/+4
| | | | | | | | | | 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
* Add a new attribute 'enable_if' which can be used to control overload ↵Nick Lewycky2014-01-111-0/+97
| | | | | | resolution based on the values of the function arguments at the call site. llvm-svn: 198996
* In areVectorOperandsLaxBitCastable() allow bitcast between a vector and scalar.Argyrios Kyrtzidis2014-01-091-0/+8
| | | | | | rdar://15779837. llvm-svn: 198856
* [ms-abi] Fixed failing lit test.Warren Hunt2014-01-091-1/+1
| | | | | | This test adjustment was missing from the previous patch. llvm-svn: 198822
* For AArch64, support builtin neon vector type with 'long' as base element type.Jiangning Liu2014-01-081-0/+15
| | | | llvm-svn: 198741
* Add an additional check in test/Sema/ext_vector_casts.cArgyrios Kyrtzidis2014-01-041-0/+1
| | | | llvm-svn: 198479
* [Sema] When checking if a bitcast is appropriate between vector types, take intoArgyrios Kyrtzidis2014-01-041-0/+4
| | | | | | | | | | | 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
* Simplifying the mutual exclusion check now that the diagnostics engine knows ↵Aaron Ballman2014-01-031-2/+2
| | | | | | how to handle Attr objects directly. Updates an associated test case due to the attribute name being properly quoted again. llvm-svn: 198424
OpenPOWER on IntegriCloud