summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
Commit message (Collapse)AuthorAgeFilesLines
* Allow implicit conversion from function pointer to void* in Microsoft mode. Francois Pichet2011-05-081-0/+9
| | | | | | Necessary to parse MFC code. llvm-svn: 131076
* Look at all the record redeclaration when looking for a uuid attribute.Francois Pichet2011-05-081-4/+5
| | | | llvm-svn: 131066
* Relax the conversion rules for Objective-C GC qualifiers aDouglas Gregor2011-05-081-0/+7
| | | | | | | | | | | | | | | | | | | | | | bit by allowing __weak and __strong to be added/dropped as part of implicit conversions (qualification conversions in C++). A little history: GCC lets one add/remove/change GC qualifiers just about anywhere, implicitly. Clang did roughly the same before, but we recently normalized the semantics of qualifiers across the board to get a semantics that we could reason about (yay). Unfortunately, this tightened the screws a bit too much for GC qualifiers, where it's common to add/remove these qualifiers at will. Overall, we're still in better shape than we were before: we don't permit directly changing the GC qualifier (e.g., __weak -> __strong), so type safety is improved. More importantly, we're internally consistent in our handling of qualifiers, and the logic that allows adding/removing GC qualifiers (but not adding/removing address spaces!) only touches two obvious places. Fixes <rdar://problem/9402499>. llvm-svn: 131065
* Patch for PR 7409 - only error on definition of invalid typedefs. Suppress ↵Richard Trieu2011-05-071-3/+7
| | | | | | errors for additional uses of this invalid typedef. llvm-svn: 131043
* When checking for a prior declaration of the name of a namespace, skipDouglas Gregor2011-05-061-4/+15
| | | | | | | | any names that aren't in the appropriate identifier namespaces. Fixes an embarrassing bug where we give a redefinition error due to an Objective-C category (<rdar://problem/9388207>). llvm-svn: 131036
* Per Richard's suggestion, rename DefLoc to DefaultLoc where it appears.Alexis Hunt2011-05-062-20/+21
| | | | llvm-svn: 131018
* Add support for Microsoft __if_exists and __if_not_exists construct inside ↵Francois Pichet2011-05-061-0/+15
| | | | | | | | | | | | function definition. Allow to include or exclude code depending on if a symbol exists or not. Just like a #ifdef but for C/C++ symbols. More doc: http://msdn.microsoft.com/en-us/library/x7wy9xh3(v=VS.100).aspx Support at class and namespace scopes will be added later. llvm-svn: 131014
* Modify some deleted function methods to better reflect reality:Alexis Hunt2011-05-064-18/+13
| | | | | | | | | | | | | | | | | | | | - New isDefined() function checks for deletedness - isThisDeclarationADefinition checks for deletedness - New doesThisDeclarationHaveABody() does what isThisDeclarationADefinition() used to do - The IsDeleted bit is not propagated across redeclarations - isDeleted() now checks the canoncial declaration - New isDeletedAsWritten() does what it says on the tin. - isUserProvided() now correct (thanks Richard!) This fixes the bug that we weren't catching void foo() = delete; void foo() {} as being a redefinition. llvm-svn: 131013
* Warn when trying to call a pure virtual member function in a class from the ↵Anders Carlsson2011-05-061-0/+13
| | | | | | class constructor/destructor. Fixes PR7966. llvm-svn: 130982
* Do defaulted constructors properly.Alexis Hunt2011-05-062-12/+58
| | | | | | | | Explictly defaultedness is correctly reflected on the AST, but there are no changes to how that affects the definition of functions or much else really. llvm-svn: 130974
* Revert r130912 in order to approach defaulted functions from the otherAlexis Hunt2011-05-063-14/+6
| | | | | | | direction and not introduce things in the wrong place three different times. llvm-svn: 130968
* Implement support for C++0x alias templates.Richard Smith2011-05-059-67/+313
| | | | llvm-svn: 130953
* When instantiating a block expression, the instantiatedFariborz Jahanian2011-05-051-2/+5
| | | | | | | blockScopeInfo's CapturesCXXThis field need get set as well. // rdar://9362021. John M. please review. llvm-svn: 130930
* When providing code completions for an Objective-C property access,Douglas Gregor2011-05-051-13/+61
| | | | | | | also include methods with zero-argument selectors. Implements <rdar://problem/9048332>. llvm-svn: 130922
* Implement some framework for defaulted constructors.Alexis Hunt2011-05-053-6/+14
| | | | | | There's some unused stuff for now. llvm-svn: 130912
* Look through block pointers and ObjC object pointersMatt Beaumont-Gay2011-05-051-4/+3
| | | | llvm-svn: 130906
* With invalid overloaded operators, we can get into funny cases whereDouglas Gregor2011-05-051-0/+9
| | | | | | | | | | the overloading of member and non-member functions results in arity mismatches that don't fit well into our overload-printing scheme. This only happens for invalid code (which breaks the arity invariants for these cases), so just suppress the diagnostic rather than inventing anything new. Fixes <rdar://problem/9222009>. llvm-svn: 130902
* Change cycle detection to be based off of a warning flag.Alexis Hunt2011-05-052-4/+6
| | | | llvm-svn: 130898
* When adding KVC code completions, keep track of all of the selectorsDouglas Gregor2011-05-041-23/+30
| | | | | | | that we've previously seen, both in declared methods and from previous KVC completions, to eliminate duplicates. Fixes <rdar://problem/9162207>. llvm-svn: 130890
* there i fixed itAlexis Hunt2011-05-041-41/+74
| | | | | | | | | Increase robustness of the delegating constructor cycle detection mechanism. No more infinite loops on invalid or logic errors leading to false results. Ensure that this is maintained correctly accross serialization. llvm-svn: 130887
* Clean up Sema::BuildCXXNestedNameSpecifier()'s creation of TypeLocDouglas Gregor2011-05-041-7/+15
| | | | | | | | information. Rather than looking at the declaration kind to figure out what TypeLoc to build, look at the type; it makes so much more sense. Fixes <rdar://problem/9086649>. llvm-svn: 130882
* Implement Sema::isExprCallable.Matt Beaumont-Gay2011-05-042-107/+139
| | | | | | | | We can use this to produce nice diagnostics (and try to fixit-and-recover) in various cases where we might see "MyFunction" instead of "MyFunction()". The changes in SemaExpr are an example of how to use isExprCallable. llvm-svn: 130878
* When converting an integral template argument value to a non-typeDouglas Gregor2011-05-041-15/+22
| | | | | | | template parameter of type 'bool', force the value to be zero or one. Fixes <rdar://problem/9169404>. llvm-svn: 130873
* Implement a better version of delegating constructor cycle detection.Alexis Hunt2011-05-042-20/+60
| | | | | | | | | | | | | This is more efficient as it's all done at once at the end of the TU. This could still get expensive, so a flag is provided to disable it. As an added bonus, the diagnostics will now print out a cycle. The PCH test is XFAILed because we currently can't deal with a note emitted in the header and I, being tired, see no other way to verify the serialization of delegating constructors. We should probably address this problem /somehow/ but no good solution comes to mind. llvm-svn: 130836
* Ensure that delegating constructor loop detection uses canonicalAlexis Hunt2011-05-041-2/+2
| | | | | | declarations. llvm-svn: 130821
* When tag lookup finds something ambiguous, and we're defining a newDouglas Gregor2011-05-041-0/+13
| | | | | | | | | | | | | tag, filter out those ambiguous names that we found if they aren't within the declaration context where this newly-defined tag will be visible. This is basically a hack, because we really need to fix the lookup of tag declarations in this case to not find things it shouldn't. However, it's better than what we had before, and it fixes <rdar://problem/9168556>. llvm-svn: 130810
* Ensure that destructors are properly inovked when an exception leavesAlexis Hunt2011-05-031-0/+5
| | | | | | | | | | the body of a delegating constructor call. This means that the delegating constructor implementation should be complete and correct, though there are some rough edges (diagnostic quality with the cycle detection and using a deleted destructor). llvm-svn: 130803
* Move the AST modifications to after the cycle detection inAlexis Hunt2011-05-031-6/+12
| | | | | | | lib/Sema/SemaDeclCXX.cpp to avoid getting stuck in an infinite loop. See the comment for more explanation. llvm-svn: 130788
* Extend -Wnon-pod-memset to also encompass memcpy() and memmove(),Douglas Gregor2011-05-031-36/+44
| | | | | | | | checking both the source and the destination operands, renaming the warning group to -Wnon-pod-memaccess and tweaking the diagnostic text in the process. llvm-svn: 130786
* Fix delegating constructors stylistic issues.Alexis Hunt2011-05-031-2/+1
| | | | | | Material bugfixes to come this afternoon. llvm-svn: 130782
* Separate the -Wnon-pod-memset warnings into two separate warnings:Douglas Gregor2011-05-031-10/+20
| | | | | | | - a default-on warning for pointers to dynamic classes (= classes with vtables) - a default-off warning for other non-POD types llvm-svn: 130781
* When parsing a template friend declaration we dropped the templateChandler Carruth2011-05-031-1/+11
| | | | | | | | | | | | | | | | | | | | parameters on the floor in certain cases: class X { template <typename T> friend typename A<T>::Foo; }; This was parsed as a *non* template friend declaration some how, and received an ExtWarn. Fixing the parser to actually provide the template parameters to the freestanding declaration parse triggers the code which specifically looks for such constructs and hard errors on them. Along the way, this prevents us from trying to instantiate constructs like the above inside of a outer template. This is important as loosing the template parameters means we don't have a well formed declaration and template instantiation will be unable to rebuild the AST. That fixes a crash in the GCC test suite. llvm-svn: 130772
* Only check the use of memset() if we're refering to a C function namedDouglas Gregor2011-05-031-1/+3
| | | | | | 'memset' with external linkage. llvm-svn: 130770
* Added an assert to IntegerLiteral to ensure that the integer type passed in ↵Richard Trieu2011-05-021-1/+2
| | | | | | | | has the same size as the APInt passed in. Also, updated the comments around IntegerLiteral. Changed the integer type that range-based for-loops used. Switched to pointer difference type, which satisfies the new assert in IntegerLiteral. llvm-svn: 130739
* Don't abuse reinterpret cast to do something the API of PointerUnionChandler Carruth2011-05-021-2/+2
| | | | | | | | | | | | provides proper support for. This was caught by -Wundefined-reinterpret-cast, and I think a reasonable case for it to warn on. Also use is<...> instead of dyn_cast<...> when the result isn't needed. This whole thing should probably switch to using UsuallyTinyPtrVector. llvm-svn: 130707
* Add a warning for when reinterpret_cast leads to undefined behavior, patch ↵Argyrios Kyrtzidis2011-05-022-1/+67
| | | | | | by Richard Trieu! llvm-svn: 130703
* Remove redeclaration of Invalid. The code that set this to true was updating anNick Lewycky2011-05-021-1/+0
| | | | | | | | | Invalid that was never read from again, causing non-type-template-parms to be marked valid when in fact they weren't. This was caught by GCC 4.6's -Wunused-but-set-variable warning. llvm-svn: 130680
* Remove unused variable, but keep function call with side-effect.Nick Lewycky2011-05-021-1/+1
| | | | llvm-svn: 130678
* Revise the representation of parameter scope data so that theJohn McCall2011-05-021-0/+2
| | | | | | | scope depth overlaps with the ObjCDeclQualifier, dropping memory usage back to previous levels. llvm-svn: 130671
* Add an optional field attached to a DeclRefExpr which points back to theChandler Carruth2011-05-011-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Decl actually found via name lookup & overload resolution when that Decl is different from the ValueDecl which is actually referenced by the expression. This can be used by AST consumers to correctly attribute references to the spelling location of a using declaration, and otherwise gain insight into the name resolution performed by Clang. The public interface to DRE is kept as narrow as possible: we provide a getFoundDecl() which always returns a NamedDecl, either the ValueDecl referenced or the new, more precise NamedDecl if present. This way AST clients can code against getFoundDecl without know when exactly the AST has a split representation. For an example of the data this provides consider: % cat x.cc namespace N1 { struct S {}; void f(const S&); } void test(N1::S s) { f(s); using N1::f; f(s); } % ./bin/clang -fsyntax-only -Xclang -ast-dump x.cc [...] void test(N1::S s) (CompoundStmt 0x5b02010 <x.cc:5:20, line:9:1> (CallExpr 0x5b01df0 <line:6:3, col:6> 'void' (ImplicitCastExpr 0x5b01dd8 <col:3> 'void (*)(const struct N1::S &)' <FunctionToPointerDecay> (DeclRefExpr 0x5b01d80 <col:3> 'void (const struct N1::S &)' lvalue Function 0x5b01a20 'f' 'void (const struct N1::S &)')) (ImplicitCastExpr 0x5b01e20 <col:5> 'const struct N1::S' lvalue <NoOp> (DeclRefExpr 0x5b01d58 <col:5> 'N1::S':'struct N1::S' lvalue ParmVar 0x5b01b60 's' 'N1::S':'struct N1::S'))) (DeclStmt 0x5b01ee0 <line:7:3, col:14> 0x5b01e40 "UsingN1::;") (CallExpr 0x5b01fc8 <line:8:3, col:6> 'void' (ImplicitCastExpr 0x5b01fb0 <col:3> 'void (*)(const struct N1::S &)' <FunctionToPointerDecay> (DeclRefExpr 0x5b01f80 <col:3> 'void (const struct N1::S &)' lvalue Function 0x5b01a20 'f' 'void (const struct N1::S &)' (UsingShadow 0x5b01ea0 'f'))) (ImplicitCastExpr 0x5b01ff8 <col:5> 'const struct N1::S' lvalue <NoOp> (DeclRefExpr 0x5b01f58 <col:5> 'N1::S':'struct N1::S' lvalue ParmVar 0x5b01b60 's' 'N1::S':'struct N1::S')))) Now we can tell that the second call is 'using' (no pun intended) the using declaration, and *which* using declaration it sees. Without this, we can mistake calls that go through using declarations for ADL calls, and have no way to attribute names looked up with using declarations to the appropriate UsingDecl. llvm-svn: 130670
* Store a parameter index and function prototype depth in everyJohn McCall2011-05-016-21/+127
| | | | | | | | | | parameter node and use this to correctly mangle parameter references in function template signatures. A follow-up patch will improve the storage usage of these fields; here I've just done the lazy thing. llvm-svn: 130669
* Remove a stale comment, it no longer applied after my cleanups.Chandler Carruth2011-05-011-8/+5
| | | | | | | Also fix several misspellings in my comments. I cannot spell, and cannot even be trusted to ask my editor how to spell apparently. llvm-svn: 130662
* Move several more type traits' implementations into the AST. A few wereChandler Carruth2011-05-011-12/+6
| | | | | | already present in the AST, and I added the ones that weren't. llvm-svn: 130655
* Switch __is_scalar to use the isScalarType predicate rather thanChandler Carruth2011-05-011-6/+1
| | | | | | duplicating its logic. llvm-svn: 130654
* Have the array type traits build an expression with type 'size_t'Chandler Carruth2011-05-011-1/+8
| | | | | | | | | | instead of 'int'. The Embarcadero spec says 'unsigned int', not 'int'. That's what 'size_t' is on Windows, but for Clang using a 'size_t' that can be larger than int seems more appropriate. llvm-svn: 130653
* Remove an inapplicable and completely out of place comment. The type is in ↵Chandler Carruth2011-05-011-1/+1
| | | | | | fact 'bool'. llvm-svn: 130652
* Remove more dead code for emitting diagnostics. The callers of theseChandler Carruth2011-05-011-17/+8
| | | | | | | | | | | | | functions already precluded dependent types from reaching them. Also change one of the callers to not error when a trait is applied to a dependent type. This is a perfectly reasonable pattern, and both Unary and Binary type traits already support dependent types (by populating the AST with a nonce value). Remove the actual diagnostic, since these aren't errors. llvm-svn: 130651
* Simplify the flow of some of the array type trait code.Chandler Carruth2011-05-011-13/+4
| | | | | | Completely remove a switch which selected between the same two types. llvm-svn: 130649
* Convert the expression trait evaluation to a static function andChandler Carruth2011-05-011-20/+19
| | | | | | | | | a switch with any default case. This both warns when an enumerator is missing and asserts if a value sneaks through despite the warning. While in there fix a bunch of coding style issues with this code. llvm-svn: 130648
* Remove the default case from the unary type trait evaluation function,Chandler Carruth2011-05-011-2/+1
| | | | | | | adding an unreachable annotation. Remarkably this one was already enumarting every trait. llvm-svn: 130647
OpenPOWER on IntegriCloud