summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaChecking.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Rip out CK_GetObjCProperty.John McCall2011-11-071-16/+0
| | | | llvm-svn: 143910
* Change the AST representation of operations on Objective-CJohn McCall2011-11-061-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | property references to use a new PseudoObjectExpr expression which pairs a syntactic form of the expression with a set of semantic expressions implementing it. This should significantly reduce the complexity required elsewhere in the compiler to deal with these kinds of expressions (e.g. IR generation's special l-value kind, the static analyzer's Message abstraction), at the lower cost of specifically dealing with the odd AST structure of these expressions. It should also greatly simplify efforts to implement similar language features in the future, most notably Managed C++'s properties and indexed properties. Most of the effort here is in dealing with the various clients of the AST. I've gone ahead and simplified the ObjC rewriter's use of properties; other clients, like IR-gen and the static analyzer, have all the old complexity *and* all the new complexity, at least temporarily. Many thanks to Ted for writing and advising on the necessary changes to the static analyzer. I've xfailed a small diagnostics regression in the static analyzer at Ted's request. llvm-svn: 143867
* Rename Expr::Evaluate to Expr::EvaluateAsRValue to make it clear that it willRichard Smith2011-10-291-3/+3
| | | | | | | | implicitly perform an lvalue-to-rvalue conversion if used on an lvalue expression. Also improve the documentation of Expr::Evaluate* to indicate which of them will accept expressions with side-effects. llvm-svn: 143263
* Fix for PR9751 to change the behavior of -Wformat warnings. If the formatRichard Trieu2011-10-281-117/+218
| | | | | | | | | | | string is part of the function call, then there is no difference. If the format string is not, the warning will point to the call site and a note will point to where the format string is. Fix-it hints for strings are moved to the note if a note is emitted. This will prevent changes to format strings that may be used in multiple places. llvm-svn: 143168
* Restore r142914 and r142915, now with missing file and apparentJohn McCall2011-10-251-1/+2
| | | | | | GCC compiler workaround. llvm-svn: 142931
* Revert r142914 and r142915, due to possibly missing file.NAKAMURA Takumi2011-10-251-2/+1
| | | | | | r142914: "Introduce a placeholder type for "pseudo object"" r142915: "Pull the pseudo-object stuff into its own file." llvm-svn: 142921
* Introduce a placeholder type for "pseudo object"John McCall2011-10-251-1/+2
| | | | | | | | | | | | | | | expressions: expressions which refer to a logical rather than a physical l-value, where the logical object is actually accessed via custom getter/setter code. A subsequent patch will generalize the AST for these so that arbitrary "implementing" sub-expressions can be provided. Right now the only client is ObjC properties, but this should be generalizable to similar language features, e.g. Managed C++'s __property methods. llvm-svn: 142914
* Only emit implicit constant conversion truncation warnings in reachable ↵Ted Kremenek2011-10-221-3/+5
| | | | | | code. Apparently this is what GCC does, and some code depends on this. Fixes <rdar://problem/10321089>. llvm-svn: 142716
* Move static array parameter checks to SemaExpr, per Doug's requestPeter Collingbourne2011-10-191-61/+0
| | | | llvm-svn: 142465
* Suggest %zu for size_t args to printf.Hans Wennborg2011-10-181-1/+1
| | | | | | | | For PR11152. Make PrintSpecifier::fixType() suggest "%zu" for size_t, etc. rather than looking at the underlying type and suggesting "%llu" or other platform-specific length modifiers. Applies to C99 and C++11. llvm-svn: 142342
* Add sema checks for calls to functions taking static array parametersPeter Collingbourne2011-10-161-0/+61
| | | | llvm-svn: 142157
* Add template instantiation support for AtomicExpr.Eli Friedman2011-10-141-22/+15
| | | | llvm-svn: 142012
* Only warn in -Wliteral-conversion if the conversion loses informationMatt Beaumont-Gay2011-10-141-19/+7
| | | | llvm-svn: 141955
* Extend -Wno-sizeof-array-argument to strncpy and friends.Nico Weber2011-10-131-4/+43
| | | | | | This finds 2 bugs in chromium and 1 in hunspell, with 0 false positives. llvm-svn: 141902
* Initial implementation of __atomic_* (everything except __atomic_is_lock_free).Eli Friedman2011-10-111-0/+170
| | | | llvm-svn: 141632
* Constant expression evaluation refactoring:Richard Smith2011-10-101-11/+4
| | | | | | | | | | | - Remodel Expr::EvaluateAsInt to behave like the other EvaluateAs* functions, and add Expr::EvaluateKnownConstInt to capture the current fold-or-assert behaviour. - Factor out evaluation of bitfield bit widths. - Fix a few places which would evaluate an expression twice: once to determine whether it is a constant expression, then again to get the value. llvm-svn: 141561
* Don't analyze comparisons in type- or value-dependentDouglas Gregor2011-10-101-0/+3
| | | | | | subexpressions. Fixes PR10291. llvm-svn: 141552
* 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
OpenPOWER on IntegriCloud