summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
Commit message (Collapse)AuthorAgeFilesLines
* Warn for "if ((a == b))" where the equality expression is needlessly wrapped ↵Argyrios Kyrtzidis2011-02-011-0/+22
| | | | | | | | | | inside parentheses. It's highly likely that the user intended an assignment used as condition. Addresses rdar://8848646. llvm-svn: 124668
* Add temporary hack to -Wuninitialize to create a separate CFG (for C++ code) ↵Ted Kremenek2011-02-011-1/+18
| | | | | | | | | | | | | that doesn't include implicit dtors. Implicit dtors confuse the ad hoc path-sensitivity of UninitializedValuesV2.cpp. This isn't the ideal solution, as it will directly impact compile time, but should significantly reduce the noise of -Wuninitialized on some code bases. This immediately "fixes" the false positive reported in PR 9063, although this isn't the right fix in the long run. llvm-svn: 124667
* Implement access checking for the "delete" operator. Fixes PR9050,Douglas Gregor2011-02-011-1/+9
| | | | | | from Alex Miller! llvm-svn: 124663
* The code trying to assign a typedef to an anonymous tag declaration wasJohn McCall2011-02-012-15/+46
| | | | | | | | extremely rambunctious, both on parsing and on template instantiation. Calm it down, fixing an internal consistency assert on anonymous enum instantiation manglings. llvm-svn: 124653
* When initializing struct members, the important thing is that the ↵Argyrios Kyrtzidis2011-02-011-1/+2
| | | | | | | | | | "initializing" expression is compatible, not having the same type. Fix rdar://8183908 in which compatible vector types weren't initialized properly leading to a crash. llvm-svn: 124637
* Perform the bad-address-space conversions check as part of John McCall2011-02-012-27/+38
| | | | | | CheckPointerTypesForAssignment. llvm-svn: 124632
* Improve the diagnostic for -Wcustom-atomic-properties. Suggestion by Fariborz!Argyrios Kyrtzidis2011-01-311-2/+2
| | | | llvm-svn: 124620
* Make Check*PointerTypesForAssignment private and tell them that they'reJohn McCall2011-01-311-73/+63
| | | | | | working on canonical types already. llvm-svn: 124618
* Slightly reorganize CheckAssignmentConstraints and remove some redundantJohn McCall2011-01-311-65/+87
| | | | | | logic. llvm-svn: 124615
* Add -Wcustom-atomic-properties which warns if an atomic-by-default property ↵Argyrios Kyrtzidis2011-01-311-4/+30
| | | | | | | | | | | has custom getter or setter. The rationale is that it is highly likely that the user's getter/setter isn't atomically implemented. Off by default. Addresses rdar://8782645. -Wcustom-atomic-properties and -Wimplicit-atomic-properties are under the -Watomic-properties group. llvm-svn: 124609
* Implement reasonable conversion ranking for Objective-C pointerDouglas Gregor2011-01-311-22/+70
| | | | | | | | | | | | | | | | | | | | | | | | conversions (<rdar://problem/8592139>) for overload resolution. The conversion ranking mirrors C++'s conversion ranking fairly closely, except that we use a same pseudo-subtyping relationship employed by Objective-C pointer assignment rather than simple checking derived-to-base conversions. This change covers: - Conversions to pointers to a specific object type are better than conversions to 'id', 'Class', qualified 'id', or qualified 'Class' (note: GCC doesn't perform this ranking, but it matches C++'s rules for ranking conversions to void*). - Conversions to qualified 'id' or qualified 'Class' are better than conversions to 'id' or 'Class', respectively. - When two conversion sequences convert to the same type, rank the conversions based on the relationship between the types we're converting from. - When two conversion sequences convert from the same non-id, non-Class type, rank the conversions based on the relationship of the types we're converting to. (note: GCC allows this ranking even when converting from 'id', which is extremeley dangerous). llvm-svn: 124591
* Only warn for -Wnon-virtual-dtor for public destructors. Thanks to Benjamin ↵Argyrios Kyrtzidis2011-01-311-2/+2
| | | | | | Kramer for the hint! llvm-svn: 124585
* Implement the suggested resolution to core issue 547, extended to alsoDouglas Gregor2011-01-311-33/+71
| | | | | | | | | allow ref-qualifiers on function types used as template type arguments. GNU actually allows cv-qualifiers on function types in many places where it shouldn't, so we currently categorize this as a GNU extension. llvm-svn: 124584
* Warn if the class has virtual methods but non-virtual destructor. Addresses ↵Argyrios Kyrtzidis2011-01-311-0/+8
| | | | | | rdar://8756445. llvm-svn: 124582
* Don't warn that variables in C++ static member functions shadow fields. ↵Argyrios Kyrtzidis2011-01-311-0/+6
| | | | | | Fixes rdar://8900456. llvm-svn: 124581
* Fix the diagnostic when we are shadowing an external variable and there ↵Argyrios Kyrtzidis2011-01-311-13/+24
| | | | | | exists a locally scoped extern with the same name. llvm-svn: 124580
* Diagnose if extern local variable is followed by non-extern and vice-versa.Argyrios Kyrtzidis2011-01-311-0/+14
| | | | llvm-svn: 124579
* 'extern' variables in functions don't shadow externs in global scope. Fixes ↵Argyrios Kyrtzidis2011-01-311-0/+13
| | | | | | rdar://8883302. llvm-svn: 124578
* If there were errors, disable 'unused' warnings since they will mostly be noise.Argyrios Kyrtzidis2011-01-311-19/+23
| | | | | | Fixes rdar://8736362. llvm-svn: 124577
* Error for use of field from anonymous struct or union should say "invalid ↵Argyrios Kyrtzidis2011-01-311-1/+1
| | | | | | | | use of nonstatic data member" not "call to non-static member function without an object argument". llvm-svn: 124576
* Amazing that there are still issues with the fields of anonymous struct/unions..Argyrios Kyrtzidis2011-01-311-9/+21
| | | | | | Allow taking the address of such a field for a pointer-to-member constant. Fixes rdar://8818236. llvm-svn: 124575
* When building with optimizations, emit vtables where the key is not in the Anders Carlsson2011-01-301-0/+7
| | | | | | | | | | | | | | | | | | | | | | | current translation unit as available_externally. This helps devirtualize the second example in PR3100, comment 18: struct S { S() {}; virtual void xyzzy(); }; inline void foo(S *s) { s->xyzzy(); } void bar() { S s; foo(&s); } This involved four major changes: 1. In DefineUsedVTables, always mark virtual member functions as referenced for non-template classes and class template specializations. 2. In CodeGenVTables::ShouldEmitVTableInThisTU return true if optimizations are enabled, even if the key function is not implemented in this translation unit. We don't ever do this for code compiled with -fapple-kext, because we don't ever want to devirtualize virtual member function calls in that case. 3. Give the correct linkage for vtables where the key function is not defined. 4. Update the linkage for RTTI structures when necessary. llvm-svn: 124565
* Fix some corner cases in the __is_base_of logic.John McCall2011-01-281-20/+27
| | | | llvm-svn: 124505
* Give OpaqueValueExpr a source location, because its source locationDouglas Gregor2011-01-284-8/+14
| | | | | | | | might be queried in places where we absolutely require a valid location (e.g., for template instantiation). Fixes some major brokenness in the use of __is_convertible_to. llvm-svn: 124465
* Allow elision of invocations of move constructors from temporary objects.Douglas Gregor2011-01-271-1/+1
| | | | llvm-svn: 124455
* Teach the evaluation of the __is_convertible_to trait to translateDouglas Gregor2011-01-273-26/+68
| | | | | | | | | | | | | | | access control errors into SFINAE errors, so that the trait provides enough support to implement the C++0x std::is_convertible type trait. To get there, the SFINAETrap now knows how to set up a SFINAE context independent of any template instantiations or template argument deduction steps, and (separately) can set a Sema flag to translate access control errors into SFINAE errors. The latter can also be useful if we decide that access control errors during template argument deduction should cause substitution failure (rather than a hard error) as has been proposed for C++0x. llvm-svn: 124446
* Separate the access-control diagnostics from other diagnostics that do not ↵Douglas Gregor2011-01-271-0/+2
| | | | | | have SFINAE behavior. llvm-svn: 124441
* Document some serious badness in our evaluation of the type traits: we need ↵Douglas Gregor2011-01-271-0/+2
| | | | | | to be sure we have complete types in many cases llvm-svn: 124428
* Implement the Microsoft __is_convertible_to type trait, modeling theDouglas Gregor2011-01-271-1/+47
| | | | | | | | | | semantics after the C++0x is_convertible type trait. This implementation is not 100% complete, because it allows access errors to be hard errors (rather than just evaluating false). Original patch by Steven Watanabe! llvm-svn: 124425
* Fixed parameter names.Abramo Bagnara2011-01-271-2/+2
| | | | llvm-svn: 124408
* Revert r124217 because it didn't catch the actual error case it was trying toJeffrey Yasskin2011-01-273-25/+1
| | | | | | | | | | catch: lock_guard(my_mutex); declares a variable instead of creating a temporary. llvm-svn: 124398
* Allow #pragma unused to be used on global variables like gcc. Fixes ↵Argyrios Kyrtzidis2011-01-271-2/+2
| | | | | | rdar://8793832. llvm-svn: 124383
* Do a proper recursive lookup when deciding whether a class's usualJohn McCall2011-01-271-3/+84
| | | | | | | | | deallocation function has a two-argument form. Store the result of this check in new[] and delete[] nodes. Fixes rdar://problem/8913519 llvm-svn: 124373
* Fix whitespace.NAKAMURA Takumi2011-01-277-2105/+2105
| | | | llvm-svn: 124364
* 7bit-ize.NAKAMURA Takumi2011-01-277-33/+33
| | | | llvm-svn: 124363
* Tweak -Wuninitialized fixit for '_Bool' types to be initialized to 0, and ↵Ted Kremenek2011-01-271-1/+1
| | | | | | C++ 'bool' types to false. llvm-svn: 124356
* Teach -Wuninitialized to suggest "= false" for initializing bool variables.Ted Kremenek2011-01-271-0/+3
| | | | llvm-svn: 124352
* When we run into a template parameter that should have a defaultDouglas Gregor2011-01-271-1/+19
| | | | | | | | | | argument but doesn't (because previous template parameters had default arguments), clear out all of the default arguments so that we maintain the invariant that a template parameter has a default argument only if subsequence template parameters also have default arguments. Fixes a crash-on-invalid <rdar://problem/8913649>. llvm-svn: 124345
* Cope with parenthesized function declarators when emitting aDouglas Gregor2011-01-271-2/+10
| | | | | | diagnostic about ref-qualifiers where they do not belong. llvm-svn: 124344
* Fix a horrible bug in our handling of C-style casting, where a C-styleDouglas Gregor2011-01-275-41/+52
| | | | | | | | | | | derived-to-base cast that also casts away constness (one of the cases for static_cast followed by const_cast) would be treated as a bit-cast rather than a derived-to-base class, causing miscompiles and heartburn. Fixes <rdar://problem/8913298>. llvm-svn: 124340
* Implement the restriction that a function with a ref-qualifier cannotDouglas Gregor2011-01-261-1/+17
| | | | | | | | overload a function without a ref-qualifier (C++0x [over.load]p2). This, apparently, completes the implementation of rvalue references for *this. llvm-svn: 124321
* Handle C-style casts to rvalue reference types that cast away constness.Douglas Gregor2011-01-261-4/+14
| | | | llvm-svn: 124319
* Rvalue references for *this: explicitly keep track of whether aDouglas Gregor2011-01-261-8/+12
| | | | | | | | | reference binding is for the implicit object parameter of a member function with a ref-qualifier. My previous comment, that we didn't need to track this explicitly, was wrong: we do in fact get rvalue-references-prefer-rvalues overloading with ref-qualifiers. llvm-svn: 124313
* Rvalue references for *this: implement the implicit conversion rulesDouglas Gregor2011-01-261-43/+104
| | | | | | | for the implicit object argument to a non-static member function with a ref-qualifier (C++0x [over.match.funcs]p4). llvm-svn: 124311
* Rvalue references for *this: allow functions to be overloaded based onDouglas Gregor2011-01-261-2/+3
| | | | | | | | | the presence and form of a ref-qualifier. Note that we do *not* yet implement the restriction in C++0x [over.load]p2 that requires either all non-static functions with a given parameter-type-list to have a ref-qualifier or none of them to have a ref-qualifier. llvm-svn: 124297
* Rvalue references for *this: tentative parsing and template argument deduction.Douglas Gregor2011-01-261-5/+5
| | | | llvm-svn: 124295
* Reference qualifiers for *this: implement C++0x [expr.mptr.oper]p6,Douglas Gregor2011-01-261-0/+26
| | | | | | | the restrictions on .* and ->* for ref-qualified pointer-to-member functions. llvm-svn: 124294
* Reinstate r124236 (tweaking the rvalue-reference overload resolutionDouglas Gregor2011-01-261-18/+53
| | | | | | rules), now that we've actually have a clean build for me to sully. llvm-svn: 124290
* Rvalue references for *this: Douglas Gregor2011-01-264-14/+66
| | | | | | | | | | | | - Add ref-qualifiers to the type system; they are part of the canonical type. Print & profile ref-qualifiers - Translate the ref-qualifier from the Declarator chunk for functions to the function type. - Diagnose mis-uses of ref-qualifiers w.r.t. static member functions, free functions, constructors, destructors, etc. - Add serialization and deserialization of ref-qualifiers. llvm-svn: 124281
* Teach -Wreturn-type that destructors can appearTed Kremenek2011-01-261-11/+14
| | | | | | | | | after a 'return' in a CFGBlock. This accidentally was working before, but the false assumption that 'return' always appeared at the end of the block was uncovered by a recent change. llvm-svn: 124280
OpenPOWER on IntegriCloud