summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
Commit message (Collapse)AuthorAgeFilesLines
...
* De-Unicode-ify in comments.NAKAMURA Takumi2011-06-211-3/+3
| | | | llvm-svn: 133501
* objc-arc: allow explicit unbridged casts if the source of the cast is aFariborz Jahanian2011-06-201-0/+10
| | | | | | | message sent to an objc method (or property access) // rdar://9474349 llvm-svn: 133469
* Warn for un-parenthesized '&' inside '|' (a & b | c), rdar://9553326.Argyrios Kyrtzidis2011-06-201-1/+30
| | | | | | Patch by Henry Mason with tweaks by me. llvm-svn: 133453
* llvm-gcc treats a tentative definition with a previousFariborz Jahanian2011-06-201-0/+6
| | | | | | | | | (or follow up) extern declaration with weak_import as an actual definition. make clang follows this behavior. // rdar://9538608 llvm-gcc treats an extern declaration with weak_import llvm-svn: 133450
* Fix a problem with the diagnostics of invalid arithmetic with functionChandler Carruth2011-06-201-2/+2
| | | | | | | | pointers I found while working on the NULL arithmetic warning. We here always assuming the LHS was the pointer, instead of using the selected pointer expression. llvm-svn: 133428
* Move away from the poor "abstraction" I added to Type. John arguedChandler Carruth2011-06-201-24/+32
| | | | | | | | | | | | | | effectively that this abstraction simply doesn't exist. That is highlighted by the fact that by using it we were papering over a more serious error in this warning: the fact that we warned for *invalid* constructs involving member pointers and block pointers. I've fixed the obvious issues with the warning here, but this is confirming an original suspicion that this warning's implementation is flawed. I'm looking into how we can implement this more reasonably. WIP on that front. llvm-svn: 133425
* Remove more unnecessary #include <llvm/ADT/SmallVector.h>Francois Pichet2011-06-201-1/+0
| | | | llvm-svn: 133418
* Restructure the API in Type based on a conversation with Richard Smith.Chandler Carruth2011-06-201-1/+4
| | | | | | | | | | | This makes 'isPointerLikeType' a little less confusing, and pulls the decay check into a separate interface that is much more clear and concrete. Also, just implement these as logical wrappers around other predicates. Having a switch based implementation isn't likely to be necessary. We can try to optimize them later if they show up on a profile. llvm-svn: 133405
* Add test cases for false positives on -Wnull-arithmetic from RichardChandler Carruth2011-06-191-25/+8
| | | | | | | | | | | | | Trieu, and fix them by checking for array and function types as well as pointer types. I've added a predicate method on Type to bundle together the logic we're using here: isPointerLikeType(). I'd welcome better names for this predicate, this is the best I came up with. It's implemented as a switch to be a touch lighter weight than all the chained isa<...> casts that would result otherwise. llvm-svn: 133383
* Accept no-return stripping conversions for pointer type arguments afterChandler Carruth2011-06-182-7/+14
| | | | | | | | | | | | | | | | | | | deducing template parameter types. Recently Clang began enforcing the more strict checking that the argument type and the deduced function parameter type (after substitution) match, but that only consideres qualification conversions. One problem with this patch is that we check noreturn conversions and qualification conversions independently. If a valid conversion would require *both*, perhaps interleaved with each other, it will be rejected. If this actually occurs (I'm not yet sure it does) and is in fact a problem (I'm not yet sure it is), there is a FIXME to implement more intelligent conversion checking. However, this step at least allows Clang to resume accepting valid code we're seeing in the wild. llvm-svn: 133327
* Objective-C++ ARC: eliminate the utterly unjustified loophole thatDouglas Gregor2011-06-172-12/+17
| | | | | | | | | | | silently dropped ownership qualifiers that were being applied to ownership-qualified, substituted type that was *not* a substituted template type parameter. We now provide a diagnostic in such cases, and recover by dropping the added qualifiers. Document this behavior in the ARC specification. llvm-svn: 133309
* Objective-ARC++: infer template type arguments ofDouglas Gregor2011-06-174-9/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | ownership-unqualified retainable object type as __strong. This allows us to write, e.g., std::vector<id> and we'll infer that the vector's element types have __strong ownership semantics, which is far nicer than requiring: std::vector<__strong id> Note that we allow one to override the ownership qualifier of a substituted template type parameter, e.g., given template<typename T> struct X { typedef __weak T type; }; X<id> is treated the same as X<__strong id>. At instantiation type, the __weak in "__weak T" overrides the (inferred or specified) __strong on the template argument type, so that we can still provide metaprogramming transformations. This is part of <rdar://problem/9595486>. llvm-svn: 133303
* Add a minor hack to avoid using isNullPointerConstant on a hot path. Fixes ↵Eli Friedman2011-06-171-6/+5
| | | | | | | | -O0 compile-time regressions from r133196. rdar://9629775 . llvm-svn: 133290
* Don't emit 'unavailable' errors inside an unavailable function. rdar://9623855.Argyrios Kyrtzidis2011-06-171-12/+14
| | | | llvm-svn: 133264
* Fix refactoro, silencing an MSVC warning. Thanks, Francois.Douglas Gregor2011-06-171-1/+1
| | | | llvm-svn: 133257
* Initialize a couple of variables to shut GCC up.John McCall2011-06-171-1/+1
| | | | llvm-svn: 133246
* Objective-C fast enumeration loop variables are not retained in ARC, butJohn McCall2011-06-172-25/+29
| | | | | | | | | | | | they should still be officially __strong for the purposes of errors, block capture, etc. Make a new bit on variables, isARCPseudoStrong(), and set this for 'self' and these enumeration-loop variables. Change the code that was looking for the old patterns to look for this bit, and change IR generation to find this bit and treat the resulting variable as __unsafe_unretained for the purposes of init/destroy in the two places it can come up. llvm-svn: 133243
* Extend the deduced/actual argument type checking of C++Douglas Gregor2011-06-171-1/+12
| | | | | | | [temp.deduct.call]p4 to the deduction performed for 'auto', finishing the fix for PR9233. llvm-svn: 133239
* Factor the checking of the deduced argument type against the actualDouglas Gregor2011-06-171-73/+84
| | | | | | | argument type for C++ [temp.deduct.call]p4 out of Sema::FinishTemplateArgumentDeduction(). No functionality change. llvm-svn: 133237
* When an explicit specialization has a storage specifier, error if thatDouglas Gregor2011-06-171-3/+12
| | | | | | | | | storage specifier is different from the storage specifier on the template. If that storage specifier is the same, then we only warn. Thanks to John for the prodding. llvm-svn: 133236
* Implement proper support for generating code for compound literals inDouglas Gregor2011-06-171-2/+3
| | | | | | | | | | | | | C++, which means: - binding the temporary as needed in Sema, so that we generate the appropriate call to the destructor, and - emitting the compound literal into the appropriate location for the aggregate, rather than trying to emit it as a temporary and memcpy() it. Fixes PR10138 / <rdar://problem/9615901>. llvm-svn: 133235
* Downgrade the error complaining about presence of a storage classDouglas Gregor2011-06-171-1/+1
| | | | | | | specifier on an explicit specialization to a warning, since neither EDG nor GCC diagnose this code as ill-formed. llvm-svn: 133232
* When synthesizing implicit copy/move constructors and copy/move assignmentJohn McCall2011-06-171-5/+14
| | | | | | | operators, don't make an initializer or sub-operation for zero-width bitfields. llvm-svn: 133221
* Check for placeholder expressions before promoting an argument passedDouglas Gregor2011-06-171-1/+5
| | | | | | through an ellipsis. Fixes <rdar://problem/9623945>. llvm-svn: 133219
* Be sure to try a final ARC-production even in Objective-C++.John McCall2011-06-162-1/+3
| | | | llvm-svn: 133215
* For the purpose of @encode'ing, accept 'void' typeFariborz Jahanian2011-06-161-1/+2
| | | | | | | (even though it is incomplete type) because gcc says so. // rdar://9622422 llvm-svn: 133208
* Add a new warning when a NULL constant is used in arithmetic operations. ↵Richard Trieu2011-06-161-0/+54
| | | | | | | | The warning will fire on cases such as: int x = 1 + NULL; llvm-svn: 133196
* Allow comparison between block pointers and NULL pointerDouglas Gregor2011-06-161-2/+4
| | | | | | constants. Fixes PR10145. llvm-svn: 133179
* 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
* arc: diagnose dereferencing a __weak pointer which may beFariborz Jahanian2011-06-161-0/+10
| | | | | | null at any time. // rdar://9612030 llvm-svn: 133168
* Implement the consistency checking for C++ [temp.deduct.call]p3, whichDouglas Gregor2011-06-161-13/+139
| | | | | | | | | | | | | | | checks that the deduced argument type for a function call matches the actual argument type provided. The only place we've found where the consistency checking should actually cause template argument deduction failure is due to qualifier differences that don't fall into the realm of qualification conversions (which are *not* checked when we initially perform deduction). However, we're performing the full checking as specified in the standard to ensure that no other cases exist. Fixes PR9233 / <rdar://problem/9039590>. llvm-svn: 133163
* 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
* Weaken the type-matching rules for methods that return aggregates whenJohn McCall2011-06-161-2/+37
| | | | | | complaining about mismatches in the global method pool. llvm-svn: 133123
* Refactor parentheses suggestion notes to have less code duplication andChandler Carruth2011-06-161-63/+36
| | | | | | | | | | be more consistent in how parenthesized ranges which hit macros are handled. Also makes the code significantly shorter, and the diagnostics when macros are present a bit more useful. Pair programmed w/ Matthew. llvm-svn: 133122
* Cleanup the parameter naming style.Chandler Carruth2011-06-161-8/+8
| | | | llvm-svn: 133120
* Automatic Reference Counting.John McCall2011-06-1523-485/+3470
| | | | | | | | | | Language-design credit goes to a lot of people, but I particularly want to single out Blaine Garst and Patrick Beard for their contributions. Compiler implementation credit goes to Argyrios, Doug, Fariborz, and myself, in no particular order. llvm-svn: 133103
* Eliminate a 'default' case in template argument deduction, where weDouglas Gregor2011-06-153-7/+170
| | | | | | | | | | | | | | | | | | were just punting on template argument deduction for a number of type nodes. Most of them, obviously, didn't matter. As a consequence of this, make extended vector types (via the ext_vector_type attribute) actually work properly for several important cases: - If the attribute appears in a type-id (i.e, not attached to a typedef), actually build a proper vector type - Build ExtVectorType whenever the size is constant; previously, we were building DependentSizedExtVectorType when the size was constant but the type was dependent, which makes no sense at all. - Teach template argument deduction to handle ExtVectorType/DependentSizedExtVectorType. llvm-svn: 133060
* Eliminate an unnecessary include. FIXMEs -=1 Douglas Gregor2011-06-151-1/+0
| | | | llvm-svn: 133056
* When performing substitution of default template template parametersDouglas Gregor2011-06-152-12/+14
| | | | | | | | | | before the template parameters have acquired a proper context (e.g., because the enclosing context has yet to be built), provide empty parameter lists for all outer template parameter scopes to inhibit any substitution for those template parameters. Fixes PR9643 / <rdar://problem/9251019>. llvm-svn: 133055
* Don't add redundant FormatAttr, ConstAttr, or NoThrowAttr attributes,Douglas Gregor2011-06-152-5/+35
| | | | | | | either imlicitly (for builtins) or explicitly (due to multiple specification of the same attributes). Fixes <rdar://problem/9612060>. llvm-svn: 133045
* Properly implement C++0x [stmt.dcl]p3, which requires a scope to beDouglas Gregor2011-06-151-0/+3
| | | | | | | protected in the case where a variable is being initialized by a trivial default constructor but has a non-trivial destructor. llvm-svn: 133037
* Warn on "void f(int a[10]) { sizeof(a); }"Nico Weber2011-06-151-0/+14
| | | | llvm-svn: 133036
* Sema: show shift result in hexadecimalTed Kremenek2011-06-151-3/+8
| | | | | | | | | | | | | | | | | Change the output for -Wshift-overflow and -Wshift-sign-overflow to an unsigned hexadecimal. It makes more sense for looking at bits than a signed decimal does. Also, change the diagnostic's wording from "overrides" to "sets". This uses a new optional argument in APInt::toString() that adds the '0x' prefix to hexademical numbers. This fixes PR 9651. Patch by nobled@dreamwidth.org! llvm-svn: 133033
* Introduce a -cc1-level option to turn off related result typeDouglas Gregor2011-06-141-1/+2
| | | | | | inference, to be used (only) by the Objective-C rewriter. llvm-svn: 133025
* Warn on memset(ptr, 0, sizeof(ptr)). Diagnostic wording by Jordy Rose.Nico Weber2011-06-141-1/+27
| | | | llvm-svn: 132996
* when compiling in a GNU mode (e.g. gnu99) treat VLAs with a size that can be ↵Chris Lattner2011-06-141-5/+29
| | | | | | | | | | folded to a constant as constant size arrays. This has slightly different semantics in some insane cases, but allows us to accept some constructs that GCC does. Continue to be pedantic in -std=c99 and other modes. This addressed rdar://8733881 - error "variable-sized object may not be initialized"; g++ accepts same code llvm-svn: 132983
* fix rdar://9204520 - Accept int(0.85 * 10) as an initializer in a class memberChris Lattner2011-06-141-9/+17
| | | | | | as an extension. llvm-svn: 132980
* Properly diagnose using abstract and incomplete types in va_argDavid Majnemer2011-06-141-5/+17
| | | | | | | - Move a test from test/SemaTemplate/instantiate-expr-3.cpp, it did not belong there - Incomplete and abstract types are considered hard errors llvm-svn: 132979
* fix rdar://9546171 - -Wshorten-64-to-32 shouldn't warn on vector bitcasts.Chris Lattner2011-06-141-3/+6
| | | | llvm-svn: 132975
OpenPOWER on IntegriCloud