summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaChecking.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Rename TagDecl::isDefinition -> isCompleteDefinitionJohn McCall2011-10-071-1/+1
| | | | | | | for better self-documenting code, since the semantics are subtly different from getDefinition(). llvm-svn: 141355
* Refactor the analysis of C++ cast expressions so that evenJohn McCall2011-10-051-7/+8
| | | | | | | | C-style and functional casts are built in SemaCXXCast.cpp. Introduce a helper class to encapsulate most of the random state being passed around, at least one level down. llvm-svn: 141170
* Do not warn about empty format strings when there are no data arguments. ↵Ted Kremenek2011-09-291-7/+6
| | | | | | Fixes <rdar://problem/9473155>. llvm-svn: 140777
* Unnecessary elseDavid Blaikie2011-09-291-2/+1
| | | | llvm-svn: 140775
* Only print _Bool as 'bool' when 'bool' is defined as an object-likeDouglas Gregor2011-09-271-1/+1
| | | | | | macro whose only replacement token is '_Bool'. llvm-svn: 140656
* When 'bool' is not a built-in type but is defined as a macro, printDouglas Gregor2011-09-271-1/+1
| | | | | | | 'bool' rather than '_Bool' within types, to make things a bit more readable. Fixes <rdar://problem/10063263>. llvm-svn: 140650
* Rename Diagnostic to DiagnosticsEngine as per issue 5397David Blaikie2011-09-251-1/+1
| | | | llvm-svn: 140478
* Add a new warning to -Wliteral-conversion to catch cases where a string literalRichard Trieu2011-09-231-5/+21
| | | | | | | | | | | | | | is cast to a boolean. An exception has been made for string literals in logical expressions to allow the common case of use in assert statements. bool x; x = "hi"; // Warn here void foo(bool x); foo("hi"); // Warn here assert(0 && "error"); assert("error); // Warn here llvm-svn: 140405
* Switch assert(0/false) llvm_unreachable.David Blaikie2011-09-231-1/+1
| | | | llvm-svn: 140367
* Rename SourceLocation::getFileLocWithOffset -> getLocWithOffset.Argyrios Kyrtzidis2011-09-191-1/+1
| | | | | | It already works (and is useful with) macro locs as well. llvm-svn: 140057
* Let -Warray-bounds handle casted array types without false positives.Nico Weber2011-09-171-1/+1
| | | | | | Fixes PR10771. llvm-svn: 139990
* Finish the lex->LHS and rex->RHS cleanup in Sema.Richard Trieu2011-09-151-22/+19
| | | | llvm-svn: 139856
* Refactoring, mostly to give ObjCPropertyDecls stronger invariants forJohn McCall2011-09-131-4/+1
| | | | | | their semantic attributes and then to take advantage of that. llvm-svn: 139615
* Rename the ARC cast kinds to start with "ARC".John McCall2011-09-101-3/+3
| | | | llvm-svn: 139466
* Bring llvm.annotation* intrinsics support back to where it was in llvm-gcc: canJulien Lerouge2011-09-091-1/+17
| | | | | | | annotate global, local variables, struct fields, or arbitrary statements (using the __builtin_annotation), rdar://8037476. llvm-svn: 139423
* When type-checking a call to an overloaded, builtin atomic operation,Douglas Gregor2011-09-091-4/+11
| | | | | | | construct a new DeclRefExpr rather than re-using the existing DeclRefExpr. Patch by Likai Liu, fixes PR8345. llvm-svn: 139373
* The integer type of an enumeration type isn't always canonicalDouglas Gregor2011-09-081-1/+1
| | | | llvm-svn: 139334
* Extend -Wliteral-conversion to catch "int i = -1.234"Matt Beaumont-Gay2011-09-081-0/+5
| | | | llvm-svn: 139326
* Extend the ASTContext constructor to delay the initialization ofDouglas Gregor2011-09-021-1/+1
| | | | | | | | builtin types (When requested). This is another step toward making ASTUnit build the ASTContext as needed when loading an AST file, rather than doing so after the fact. No actual functionality change (yet). llvm-svn: 138985
* The lvalue-to-rvalue on structs in C++ is actually partJohn McCall2011-08-271-0/+29
| | | | | | | of default argument promotion and needs to happen unconditionally. This is particularly semantically important in C++0x. llvm-svn: 138691
* Improve the correctness and accuracy of the message for ↵Matt Beaumont-Gay2011-08-191-10/+13
| | | | | | -Wdynamic-class-memaccess llvm-svn: 138074
* Enhance -Wstrl-incorrect-size to not report a FIXIT for destinations that ↵Ted Kremenek2011-08-181-10/+18
| | | | | | are flexible arrays or have size 1. llvm-svn: 138004
* Reapply r137903, but fix the definition of size_t in the test case to use ↵Ted Kremenek2011-08-181-1/+96
| | | | | | | | __SIZE_TYPE__ (and hence be portable). Also, change the warning to -Wstrl-incorrect-size. llvm-svn: 137980
* Revert r137903, "Add experimental -Wstrlcpy-size warning that looks to see ↵Ted Kremenek2011-08-181-96/+1
| | | | | | | | if the size argument for strlcpy/strlcat is the size of the *source*, and not the size of the *destination*. This warning is off by default (for now)." This currently doesn't work on Windows. llvm-svn: 137920
* Add experimental -Wstrlcpy-size warning that looks to see if the size ↵Ted Kremenek2011-08-171-1/+96
| | | | | | | | argument for strlcpy/strlcat is the size of the *source*, and not the size of the *destination*. This warning is off by default (for now). Warning logic provided by Geoff Keating. llvm-svn: 137903
* Add a test case for the divide-by-zero fix in r137234Kaelyn Uhrain2011-08-101-0/+1
| | | | llvm-svn: 137240
* Make sure ptrarith_typesize is at least 1 to avoid division by zeroKaelyn Uhrain2011-08-101-0/+1
| | | | llvm-svn: 137234
* Only look at decls after the current one when checking if it's the last ↵Benjamin Kramer2011-08-061-10/+6
| | | | | | field in a record. llvm-svn: 137009
* Perform array bounds checking in more situations and properly handle specialKaelyn Uhrain2011-08-051-26/+89
| | | | | | | | | | | | | | | | case situations with the unary operators & and *. Also extend the array bounds checking to work with pointer arithmetic; the pointer arithemtic checking can be turned on using -Warray-bounds-pointer-arithmetic. The changes to where CheckArrayAccess gets called is based on some trial & error and a bunch of digging through source code and gdb backtraces in order to have the check performed under as many situations as possible (such as for variable initializers, arguments to function calls, and within conditional in addition to the simpler cases of the operands to binary and unary operator) while not being called--and triggering warnings--more than once for a given ArraySubscriptExpr. llvm-svn: 136997
* Flesh out the -Warray-bounds detection of C89 tail-padded one-elementChandler Carruth2011-08-051-10/+39
| | | | | | | | | | | | | | | | | | | | | | | | | arrays. This now suppresses the warning only in the case of a one-element array as the last field in a struct where the array size is a literal '1' rather than any macro expansion or template parameter. This doesn't distinguish between the language standard in use to allow code which dates from C89 era to compile without the warning even in C99 and C++ builds. We could add a separate warning (under a different flag) with fixit hints to switch to a flexible array, but its not clear that this would be desirable. Much of the code using this idiom is striving for maximum portability. Tests were also fleshed out a bit, and the diagnostic itself tweaked to be more pretty w.r.t. single elment arrays. This is more ugly than I would like due to APInt's not being supported by the diagnostic rendering engine. A pseudo-patch for this was proposed by Nicola Gigante, but I reworked it both for several correctness issues and for code style. Sorry this was so long in coming. llvm-svn: 136965
* Finally getting around to re-working this to more accurately white-listChandler Carruth2011-08-051-8/+22
| | | | | | | | | 1-element character arrays which are serving as flexible arrays. This is the initial step, which is to restrict the 1-element array whitelist to arrays that are member declarations. I'll refine it from here based on the proposed patch. llvm-svn: 136964
* Extend memset/memcpy/memmove checking to include memcmpMatt Beaumont-Gay2011-08-051-6/+13
| | | | llvm-svn: 136950
* disable array bounds overflow warning for cases where an array Chris Lattner2011-08-021-1/+3
| | | | | | | | | | | | | has a single element. This disables the warning in cases where there is a clear bug, but this is really rare (who uses arrays with one element?) and it also silences a large class of false positive issues with C89 code that is using tail padding in structs. A better version of this patch would detect when an array is in a tail position in a struct, but at least patch fixes the huge false positives that are hitting postgres and other code. llvm-svn: 136724
* Add support for C++0x unicode string and character literals, from Craig Topper!Douglas Gregor2011-07-271-2/+2
| | | | llvm-svn: 136210
* Revert r136046 while fixing handling of e.g. &foo[index_one_past_size]Kaelyn Uhrain2011-07-261-68/+21
| | | | llvm-svn: 136113
* Cleanup the stray comments and variables I could dig out of Sema toChandler Carruth2011-07-261-5/+5
| | | | | | refer to 'expansion' instead of 'instantiation'. llvm-svn: 136060
* Expand array bounds checking to work in the presence of unary & and *,Kaelyn Uhrain2011-07-261-21/+68
| | | | | | | | | and to work with pointer arithmetic in addition to array indexing. The new pointer arithmetic porition of the array bounds checking can be turned on by -Warray-bounds-pointer-arithmetic (and is off by default). llvm-svn: 136046
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-11/+11
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* Remove warning for conditional operands of differend signedness from ↵Richard Trieu2011-07-211-20/+7
| | | | | | -Wsign-compare. Cases that previously warn on this will have a different warning emitted from -Wsign-conversion. llvm-svn: 135664
* Use the new APFloat::convertToInt(APSInt) function to simplify uses ofJeffrey Yasskin2011-07-151-7/+5
| | | | | | convertToInt(integerParts*) and make them more reliable. llvm-svn: 135279
* Teach -Wconversion, -Wsign-compare etc. about division and remainder.John McCall2011-07-141-4/+44
| | | | llvm-svn: 135208
* Make the integer-range analysis recognize ^= correctly,John McCall2011-07-131-2/+11
| | | | | | | | | and (while I'm at it) teach it to grok the results of simple assignments. The first is PR10336. llvm-svn: 135034
* In ARC, reclaim all return values of retainable type, not just thoseJohn McCall2011-07-071-0/+1
| | | | | | | | | | | | where we have an immediate need of a retained value. As an exception, don't do this when the call is made as the immediate operand of a __bridge retain. This is more in the way of a workaround than an actual guarantee, so it's acceptable to be brittle here. rdar://problem/9504800 llvm-svn: 134605
* objc-arc: Check on a variety of unsafe assignment of retained Fariborz Jahanian2011-06-241-4/+39
| | | | | | objects. // rdar://9495837 llvm-svn: 133806
* Rename objc_lifetime -> objc_ownership, and modify diagnostics to talk about ↵Argyrios Kyrtzidis2011-06-241-1/+1
| | | | | | | | 'ownership', not 'lifetime'. rdar://9477613. llvm-svn: 133779
* Fix some grammar nits in the comments from Nick.Chandler Carruth2011-06-211-2/+2
| | | | llvm-svn: 133571
* Introduce a new AST node describing reference binding to temporaries.Douglas Gregor2011-06-211-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | MaterializeTemporaryExpr captures a reference binding to a temporary value, making explicit that the temporary value (a prvalue) needs to be materialized into memory so that its address can be used. The intended AST invariant here is that a reference will always bind to a glvalue, and MaterializeTemporaryExpr will be used to convert prvalues into glvalues for that binding to happen. For example, given const int& r = 1.0; The initializer of "r" will be a MaterializeTemporaryExpr whose subexpression is an implicit conversion from the double literal "1.0" to an integer value. IR generation benefits most from this new node, since it was previously guessing (badly) when to materialize temporaries for the purposes of reference binding. There are likely more refactoring and cleanups we could perform there, but the introduction of MaterializeTemporaryExpr fixes PR9565, a case where IR generation would effectively bind a const reference directly to a bitfield in a struct. Addresses <rdar://problem/9552231>. llvm-svn: 133521
* Teach the warning about non-POD memset/memcpy/memmove to deal with theDouglas Gregor2011-06-161-12/+40
| | | | | | | | | __builtin_ versions of these functions as well as the normal function versions, so that it works on platforms where memset/memcpy/memmove are macros that map down to the builtins (e.g., Darwin). Fixes <rdar://problem/9372688>. llvm-svn: 133173
* Rework the warning for 'memset(p, 0, sizeof(p))' where 'p' is a pointerChandler Carruth2011-06-161-22/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | and the programmer intended to write 'sizeof(*p)'. There are several elements to the new version: 1) The actual expressions are compared in order to more accurately flag the case where the pattern that works for an array has been used, or a '*' has been omitted. 2) Only do a loose type-based check for record types. This prevents us from warning when we happen to be copying around chunks of data the size of a pointer and the pointer types for the sizeof and source/dest match. 3) Move all the diagnostics behind the runtime diagnostic filter. Not sure this is really important for this particular diagnostic, but almost everything else in SemaChecking.cpp does so. 4) Make the wording of the diagnostic more precise and informative. At least to my eyes. 5) Provide highlighting for the two expressions which had the unexpected similarity. 6) Place this diagnostic under a flag: -Wsizeof-pointer-memaccess This uses the Stmt::Profile system for computing #1. Because of the potential cost, this is guarded by the warning flag. I'd be interested in feedback on how bad this is in practice; I would expect it to be quite cheap in practice. Ideas for a cheaper / better way to do this are also welcome. The diagnostic wording could likely use some further wordsmithing. Suggestions welcome here. The goals I had were to: clarify that its the interaction of 'memset' and 'sizeof' and give more reasonable suggestions for a resolution. An open question is whether these diagnostics should have the note attached for silencing by casting the dest/source pointer to void*. llvm-svn: 133155
* Skip both character pointers and void pointers when diagnosing badChandler Carruth2011-06-161-1/+3
| | | | | | | | | | | | | argument types for mem{set,cpy,move}. Character pointers, much like void pointers, often point to generic "memory", so trying to check whether they match the type of the argument to 'sizeof' (or other checks) is unproductive and often results in false positives. Nico, please review; does this miss any of the bugs you were trying to find with this warning? The array test case you had should be caught by the array-specific sizeof warning I think. llvm-svn: 133136
OpenPOWER on IntegriCloud