summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExprCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Implement basic __is_trivial type-trait support, enough to close PR9472.Chandler Carruth2011-04-231-0/+1
| | | | | | | | | | | | | | | | | | This introduces a few APIs on the AST to bundle up the standard-based logic so that programmatic clients have access to exactly the same behavior. There is only one serious FIXME here: checking for non-trivial move constructors and move assignment operators. Those bits need to be added to the declaration and accessors provided. This implementation should be enough for the uses of __is_trivial in libstdc++ 4.6's C++98 library implementation. Ideas for more thorough test cases or any edge cases missing would be appreciated. =D llvm-svn: 130057
* Forbid the use of C++ new/delete to allocate/free objects within anDouglas Gregor2011-04-151-2/+8
| | | | | | | | | | address space. I could see that this functionality would be useful, but not in its current form (where the address space is ignored): rather, we'd want to encode the address space into the parameter list passed to operator new/operator delete somehow, which would require a bunch more semantic analysis. llvm-svn: 129593
* Simplify calling CheckPlaceholderExpr, converge on it in a few places,John McCall2011-04-101-24/+3
| | | | | | and move a vector-splat check to follow l-value conversion. llvm-svn: 129254
* Use ExprResult& instead of Expr *& in SemaJohn Wiegley2011-04-081-233/+282
| | | | | | | | | | | | | | | | | | | | | | | | | This patch authored by Eric Niebler. Many methods on the Sema class (e.g. ConvertPropertyForRValue) take Expr pointers as in/out parameters (Expr *&). This is especially true for the routines that apply implicit conversions to nodes in-place. This design is workable only as long as those conversions cannot fail. If they are allowed to fail, they need a way to report their failures. The typical way of doing this in clang is to use an ExprResult, which has an extra bit to signal a valid/invalid state. Returning ExprResult is de riguour elsewhere in the Sema interface. We suggest changing the Expr *& parameters in the Sema interface to ExprResult &. This increases interface consistency and maintainability. This interface change is important for work supporting MS-style C++ properties. For reasons explained here <http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-February/013180.html>, seemingly trivial operations like rvalue/lvalue conversions that formerly could not fail now can. (The reason is that given the semantics of the feature, getter/setter method lookup cannot happen until the point of use, at which point it may be found that the method does not exist, or it may have the wrong type, or overload resolution may fail, or it may be inaccessible.) llvm-svn: 129143
* In C++ the argument of logical not should always be bool. Added missing ↵Abramo Bagnara2011-04-071-13/+3
| | | | | | implicit cast for scalars. llvm-svn: 129066
* Make ChainedIncludesSource an ExternalSemaSource, otherwise initialization ↵Sebastian Redl2011-03-311-1/+1
| | | | | | of the ASTReader is incomplete, leading to errors like not realizing std::type_info is already defined. llvm-svn: 128664
* Support for Transparent unions used as overloadableFariborz Jahanian2011-03-231-0/+9
| | | | | | | function parameter. // rdar:// 9129552 and PR9406. llvm-svn: 128159
* Implement a new 'availability' attribute, that allows one to specifyDouglas Gregor2011-03-231-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | which versions of an OS provide a certain facility. For example, void foo() __attribute__((availability(macosx,introduced=10.2,deprecated=10.4,obsoleted=10.6))); says that the function "foo" was introduced in 10.2, deprecated in 10.4, and completely obsoleted in 10.6. This attribute ties in with the deployment targets (e.g., -mmacosx-version-min=10.1 specifies that we want to deploy back to Mac OS X 10.1). There are several concrete behaviors that this attribute enables, as illustrated with the function foo() above: - If we choose a deployment target >= Mac OS X 10.4, uses of "foo" will result in a deprecation warning, as if we had placed attribute((deprecated)) on it (but with a better diagnostic) - If we choose a deployment target >= Mac OS X 10.6, uses of "foo" will result in an "unavailable" warning (in C)/error (in C++), as if we had placed attribute((unavailable)) on it - If we choose a deployment target prior to 10.2, foo() is weak-imported (if it is a kind of entity that can be weak imported), as if we had placed the weak_import attribute on it. Naturally, there can be multiple availability attributes on a declaration, for different platforms; only the current platform matters when checking availability attributes. The only platforms this attribute currently works for are "ios" and "macosx", since we already have -mxxxx-version-min flags for them and we have experience there with macro tricks translating down to the deprecated/unavailable/weak_import attributes. The end goal is to open this up to other platforms, and even extension to other "platforms" that are really libraries (say, through a #pragma clang define_system), but that hasn't yet been designed and we may want to shake out more issues with this narrower problem first. Addresses <rdar://problem/6690412>. As a drive-by bug-fix, if an entity is both deprecated and unavailable, we only emit the "unavailable" diagnostic. llvm-svn: 128127
* Fix an objc++ diagnostic initializing objc pointers.Fariborz Jahanian2011-03-211-4/+10
| | | | | | // rdar:// 9139947 llvm-svn: 128013
* Fix PR9488: 'auto' type substitution can fail (for instance, if it creates a ↵Richard Smith2011-03-171-4/+6
| | | | | | | | reference-to-void type). Don't crash if it does. Also fix an issue where type source information for the resulting type was being lost. llvm-svn: 127811
* Clean up our handling of template-ids that resolve down to a singleDouglas Gregor2011-03-161-7/+10
| | | | | | | | | overload, so that we actually do the resolution for full expressions and emit more consistent, useful diagnostics. Also fixes an IRGen crasher, where Sema wouldn't diagnose a resolvable bound member function template-id used in a full-expression (<rdar://problem/9108698>). llvm-svn: 127747
* Make deallocation functions implicitly noexcept in C++0x.Sebastian Redl2011-03-141-6/+24
| | | | llvm-svn: 127596
* -fwritable-strings should silence warnings about the deprecated stringDouglas Gregor2011-03-141-1/+2
| | | | | | -literal to char* conversion. Make it so. llvm-svn: 127586
* Instead of storing an ASTContext* in FunctionProtoTypes with computed ↵Sebastian Redl2011-03-131-3/+3
| | | | | | noexcept specifiers, unique FunctionProtoTypes with a ContextualFoldingSet, as suggested by John McCall. llvm-svn: 127568
* Propagate the new exception information to FunctionProtoType.Sebastian Redl2011-03-121-5/+7
| | | | | | | | Change the interface to expose the new information and deal with the enormous fallout. Introduce the new ExceptionSpecificationType value EST_DynamicNone to more easily deal with empty throw specifications. Update the tests for noexcept and fix the various bugs uncovered, such as lack of tentative parsing support. llvm-svn: 127537
* Fixed InnerLocStart.Abramo Bagnara2011-03-091-2/+2
| | | | llvm-svn: 127330
* Fixed source range for all DeclaratorDecl's.Abramo Bagnara2011-03-081-4/+5
| | | | llvm-svn: 127225
* Removed trailing whitespace as a test commitJohn Wiegley2011-03-081-1/+1
| | | | llvm-svn: 127223
* Produce a diagnostic for unused overloaded expressions, from Faisal Vali!Douglas Gregor2011-03-071-0/+23
| | | | llvm-svn: 127148
* Reinstate r127112, "Propagate new-style exception spec information to ↵Sebastian Redl2011-03-061-1/+1
| | | | | | ExtProtoInfo.", this time with the missing header. llvm-svn: 127118
* Revert r127112, "Propagate new-style exception spec information to ↵NAKAMURA Takumi2011-03-061-1/+1
| | | | | | | | ExtProtoInfo." It seems missing "clang/Basic/ExceptionSpecificationType.h". llvm-svn: 127115
* Propagate new-style exception spec information to ExtProtoInfo.Sebastian Redl2011-03-051-1/+1
| | | | llvm-svn: 127112
* When clearing a LookupResult structure, clear out the naming class,Douglas Gregor2011-03-041-3/+13
| | | | | | | | | too. Fixes PR7900. While I'm in this area, improve the diagnostic when the type being destroyed doesn't match either of the types we found. llvm-svn: 127041
* Push nested-name-specifier source-location information into dependentDouglas Gregor2011-03-021-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | template specialization types. This also required some parser tweaks, since we were losing track of the nested-name-specifier's source location information in several places in the parser. Other notable changes this required: - Sema::ActOnTagTemplateIdType now type-checks and forms the appropriate type nodes (+ source-location information) for an elaborated-type-specifier ending in a template-id. Previously, we used a combination of ActOnTemplateIdType and ActOnTagTemplateIdType that resulted in an ElaboratedType wrapped around a DependentTemplateSpecializationType, which duplicated the keyword ("class", "struct", etc.) and nested-name-specifier storage. - Sema::ActOnTemplateIdType now gets a nested-name-specifier, which it places into the returned type-source location information. - Sema::ActOnDependentTag now creates types with source-location information. llvm-svn: 126808
* For C++, enhance -Warray-bounds to recursively analyze array subscript ↵Ted Kremenek2011-03-011-2/+1
| | | | | | accesses in ?: expressions. llvm-svn: 126766
* Teach Sema::CheckTypenameType to use nested-name-specifiers withDouglas Gregor2011-02-281-13/+5
| | | | | | | | source-location information. We don't actually preserve this information in any of the resulting TypeLocs (yet), so it doesn't matter. llvm-svn: 126693
* Push nested-name-specifier location information into DeclRefExpr andDouglas Gregor2011-02-281-1/+2
| | | | | | MemberExpr, the last of the expressions with qualifiers! llvm-svn: 126688
* Add a -fcxx-exceptions flag to the frontend, which can be used to enableAnders Carlsson2011-02-281-1/+1
| | | | | | | | | | C++ exceptions, even when exceptions have been turned off using -fno-exceptions. Make the -fobjc-exceptions flag do the same thing, but for Objective-C exceptions. C++ and Objective-C exceptions can also be disabled using -fno-cxx-excptions and -fno-objc-exceptions. llvm-svn: 126630
* Sprinkle optional text of the "unavailable' attributeFariborz Jahanian2011-02-251-1/+4
| | | | | | where ever such attribute causes an error diagnostic. llvm-svn: 126509
* Remove the FIXME I introduced last night, and pull the logic forChandler Carruth2011-02-251-0/+3
| | | | | | | | | | marking selected overloads into the callers. This allows a few callers to skip it altogether (they would have anyways because they weren't interested in successful overloads) or defer until after further checks take place much like the check required for PR9323 to avoid marking unused copy constructors. llvm-svn: 126503
* Push nested-name-specifier source-location information intoDouglas Gregor2011-02-251-2/+2
| | | | | | | | pseudo-destructor expressions. Also, clean up some template-instantiation and type-checking issues with pseudo-destructors. llvm-svn: 126498
* Switch a few CXXScopeSpec::MakeTrivial() calls over to appropriateDouglas Gregor2011-02-251-1/+1
| | | | | | NestedNameSpecifierLoc handling. llvm-svn: 126486
* Formatting, etc.John McCall2011-02-251-17/+17
| | | | llvm-svn: 126475
* Retain complete source-location information for C++Douglas Gregor2011-02-241-1/+1
| | | | | | | | | | | | nested-name-specifiers throughout the parser, and provide a new class (NestedNameSpecifierLoc) that contains a nested-name-specifier along with its type-source information. Right now, this information is completely useless, because we don't actually store the source-location information anywhere in the AST. Call this Step 1/N. llvm-svn: 126391
* Tweak the CXXScopeSpec API a bit, so that we require theDouglas Gregor2011-02-241-1/+1
| | | | | | nested-name-specifier and source range to be set at the same time. llvm-svn: 126347
* Don't give an error for 'try' and 'throw' if they occur in system headers.Anders Carlsson2011-02-231-1/+3
| | | | llvm-svn: 126303
* Implement the C++0x deduced 'auto' feature.Richard Smith2011-02-201-6/+34
| | | | | | This fixes PR 8738, 9060 and 9132. llvm-svn: 126069
* There's no need to return early if we encounter a try/throw and exceptions ↵Anders Carlsson2011-02-191-1/+1
| | | | | | are disabled. llvm-svn: 126053
* Disallow try/catch/throw when exceptions are disabled.Anders Carlsson2011-02-191-0/+3
| | | | llvm-svn: 126039
* Fix a missed case in the NULL operand to conditional operatorChandler Carruth2011-02-191-0/+4
| | | | | | | | diagnostics. Patch by Stephen Hines. llvm-svn: 125998
* Initial steps to improve diagnostics when there is a NULL andChandler Carruth2011-02-181-6/+14
| | | | | | | | a non-pointer on the two sides of a conditional expression. Patch by Stephen Hines and Mihai Rusu. llvm-svn: 125995
* Enhance the array bounds checking to work for several other constructs,Chandler Carruth2011-02-171-0/+4
| | | | | | | | | especially C++ code, and generally expand the test coverage. Logic adapted from a patch by Kaelyn Uhrain <rikka@google.com> and another Googler. llvm-svn: 125775
* Change the representation of GNU ?: expressions to use a different expressionJohn McCall2011-02-171-13/+4
| | | | | | | | | | | | | | | | | | | | | | class and to bind the shared value using OpaqueValueExpr. This fixes an unnoticed problem with deserialization of these expressions where the deserialized form would lose the vital pointer-equality trait; or rather, it fixes it because this patch also does the right thing for deserializing OVEs. Change OVEs to not be a "temporary object" in the sense that copy elision is permitted. This new representation is not totally unawkward to work with, but I think that's really part and parcel with the semantics we're modelling here. In particular, it's much easier to fix things like the copy elision bug and to make the CFG look right. I've tried to update the analyzer to deal with this in at least some obvious cases, and I think we get a much better CFG out, but the printing of OpaqueValueExprs probably needs some work. llvm-svn: 125744
* Implement objective-c++'s block pointer type matching involvingFariborz Jahanian2011-02-121-1/+6
| | | | | | | types which are contravariance in argument types and covariance in return types. // rdar://8979379. llvm-svn: 125445
* Support for objextive-c++ use of property-dot syntax as receiverFariborz Jahanian2011-02-081-2/+2
| | | | | | | in liu of a class method getter. // rdar://8962253 llvm-svn: 125094
* Sema::MaybeBindToTemporary() shouldn't treat any expression returningDouglas Gregor2011-02-081-11/+3
| | | | | | | | | a glvalue as a temporary. Previously, we were enumerating all of the cases that coul return glvalues and might be called with Sema::MaybeBindToTemporary(), but that was gross and we missed the Objective-C property reference case. llvm-svn: 125070
* More capturing of 'this': implicit member expressions. Getting thatJohn McCall2011-02-031-10/+24
| | | | | | | | | | | right for anonymous struct/union members led to me discovering some seemingly broken code in that area of Sema, which I fixed, partly by changing the representation of member pointer constants so that IndirectFieldDecls aren't expanded. This led to assorted cleanups with member pointers in CodeGen, and while I was doing that I saw some random other things to clean up. llvm-svn: 124785
* An insomniac stab at making block declarations list the variables they closeJohn McCall2011-02-021-7/+17
| | | | | | | on, as well as more reliably limiting invalid references to locals from nested scopes. llvm-svn: 124721
* Implement access checking for the "delete" operator. Fixes PR9050,Douglas Gregor2011-02-011-1/+9
| | | | | | from Alex Miller! llvm-svn: 124663
* Fix some corner cases in the __is_base_of logic.John McCall2011-01-281-20/+27
| | | | llvm-svn: 124505
OpenPOWER on IntegriCloud