summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExprCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Properly handle typos in the conditional of ?: expressions in C.Kaelyn Takata2015-01-271-6/+0
| | | | | | | | | | In particular, remove the OpaqueExpr transformation from r225389 and move the correction of the conditional from CheckConditionalOperands to ActOnConditionalOp before the OpaqueExpr is created. This fixes the typo correction behavior in C code that uses the GNU extension for a binary ?: (without an expression between the "?" and the ":"). llvm-svn: 227220
* Fix crash-on-invalid and name lookup when recovering from ~X::X() typo.Richard Smith2015-01-151-0/+3
| | | | llvm-svn: 226067
* Fix crash in typo correction while correcting enum within a struct in COlivier Goffart2015-01-091-2/+4
| | | | llvm-svn: 225513
* Handle OpaqueValueExprs more intelligently in the TransformTypos treeKaelyn Takata2015-01-071-0/+6
| | | | | | | | | | | | transform. Also diagnose typos in the initializer of an invalid C++ declaration. Both issues were hit using the same line of test code, depending on whether the code was treated as C or C++. Fixes PR22092. llvm-svn: 225389
* Sema: Permit an atomic type to be initialized by the same atomic typeDavid Majnemer2014-12-281-1/+5
| | | | | | | | | We forgot a conversion step when initializing an atomic type with an rvalue of the same type. This fixes PR22043. llvm-svn: 224902
* Adding a -Wunused-value warning for expressions with side effects used in an ↵Aaron Ballman2014-12-171-1/+19
| | | | | | unevaluated expression context, such as sizeof(), or decltype(). Also adds a similar warning when the expression passed to typeid() *is* evaluated, since it is equally likely that the user would expect the expression operand to be unevaluated in that case. llvm-svn: 224465
* Look at whether TransformTypos returned a different Expr instead of looking ↵Nick Lewycky2014-12-161-1/+2
| | | | | | | | at the number of uncorrected typos before and after. Correcting one typo may produce an expression with another TypoExpr in it, leading to matching counts even though a typo was corrected. Fixes PR21925! llvm-svn: 224380
* Fix typo in comment. NFC.Nick Lewycky2014-12-161-1/+1
| | | | llvm-svn: 224377
* Sema: Don't crash converting to bool from _AtomicDavid Majnemer2014-12-161-1/+1
| | | | | | | | | | | Turning our _Atomic L-value into an R-value removes its _Atomic-ness. However, we didn't update our 'FromType' which made ScalarTypeToBooleanCastKind think we were trying to pass it a non-scalar. This fixes PR21836. llvm-svn: 224322
* Fix two small bugs in typo correction. One assertion failure building member ↵Nick Lewycky2014-12-131-1/+2
| | | | | | | | expressions because the lookup finds a different name than the original, fixed by updating the LookupResult's name with the name of the found decl. Second is that we also diagnose delayed typo exprs in the index of an array subscript expression. The testcase shows a third bug with a FIXME in it. llvm-svn: 224183
* Implement feedback on r224172 in PR21899Reid Kleckner2014-12-131-1/+1
| | | | | | Based on suggestions from Kaelyn. llvm-svn: 224173
* Typo correction: Ignore temporary binding exprs after overload resolutionReid Kleckner2014-12-131-2/+7
| | | | | | | | Transformation of a CallExpr doesn't always result in a new CallExpr. Fixes PR21899. llvm-svn: 224172
* Diagnose TypoExprs in a couple of error cases in ParsePostfixExpressionSuffix.Kaelyn Takata2014-12-021-1/+1
| | | | | | | Also have CorrectDelayedTyposInExpr check that the Expr* isn't null before trying to access its members. Fixes PR21679. llvm-svn: 223162
* [c++1z] Most of N4268 (allow constant evaluation for non-type template ↵Richard Smith2014-11-261-4/+23
| | | | | | | | | arguments). We don't yet support pointer-to-member template arguments that have undergone pointer-to-member conversions, mostly because we don't have a mangling for them yet. llvm-svn: 222807
* Sema: Don't permit variably modified types in typeidDavid Majnemer2014-11-211-0/+7
| | | | | | | | | | GCC and ICC both reject this and the 'Runtime-sized arrays with automatic storage duration' (N3639) paper forbade this as well. Previously, we would crash on our way to mangling. This fixes PR21632. llvm-svn: 222569
* Use the full-Expr filter to disambiguate equidistant correctionKaelyn Takata2014-11-211-26/+41
| | | | | | candidates. llvm-svn: 222549
* Ensure all TypoExprs are diagnosed by the tree transform.Kaelyn Takata2014-11-201-0/+16
| | | | | | | | | | | | If there is more than one TypoExpr within the expr being transformed and any but the last TypoExpr seen don't have any viable candidates, the tree transform will be aborted early and the remaining TypoExprs are never seen and hence never diagnosed. This adds a simple RecursiveASTVisitor to find all of the TypoExprs to be diagnosed in the case where typo correction of the entire expr fails (and the result of the tree transform is an ExprError). llvm-svn: 222465
* Add a flag to BuildDeclarationNameExpr to not reject invalid decls.Kaelyn Takata2014-11-201-1/+2
| | | | llvm-svn: 222463
* Factor out the default recovery handling.Kaelyn Takata2014-11-201-14/+77
| | | | | | | | | | | The default handling is extended to properly create member expressions and Objective-C ivar references. Also detect and reject cases where multiple corrections have identical correction distances and are valid, instead of suggesting the first one that is found. llvm-svn: 222462
* Update for LLVM API change to make Small(Ptr)Set::insert return ↵David Blaikie2014-11-191-1/+1
| | | | | | pair<iterator, bool> as per the C++ standard's associative container concept. llvm-svn: 222335
* clang-format a recent commit I madeDavid Blaikie2014-11-191-4/+4
| | | | llvm-svn: 222317
* Wrap to 80 columns, no behavior change.Nico Weber2014-11-191-4/+4
| | | | llvm-svn: 222315
* Recommit r222044 with a test fix - it does not make sense to huntAnton Korobeynikov2014-11-141-2/+6
| | | | | | for a typedef before arithmetic conversion in all rare corner cases. llvm-svn: 222049
* Again revert r222044 to resolve darwin objc test fails.Anton Korobeynikov2014-11-141-6/+2
| | | | llvm-svn: 222047
* Follow-up to D6217Anton Korobeynikov2014-11-141-2/+6
| | | | | | | | | | | | | | | | | Summary: Ok, here is somewhat addition to D6217 aiming to preserve old darwin behavior wrt the typedefed types. The actual change to SemaChecking turned out to be pretty gross, in particular: 1. We need to extract the typedef'ed type for proper diagnostics 2. We need to walk over paren expressions as well Reviewers: chandlerc, rsmith Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D6256 llvm-svn: 222044
* Temporary revert r221818 until all the problemsAnton Korobeynikov2014-11-121-6/+2
| | | | | | with objc stuff will be resolved. llvm-svn: 221829
* Fix fallout from r219557Anton Korobeynikov2014-11-121-2/+6
| | | | | | | | | | | | | | | | | Summary: Consider the following nifty 1 liner: (0 ? csqrtl(2.0f) : sqrtl(2.0f)). One can easily obtain such code from e.g. tgmath. Right now it produces an assertion because we fail to do the promotion real => _Complex real. The case was properly handled previously (old handleOtherComplexFloatConversion routine), but was forgotten in the current version. This seems to be about fallout from r219557 Reviewers: chandlerc, rsmith Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D6217 llvm-svn: 221821
* Pass the filter function_ref by value now that r221753 fixes the bugKaelyn Takata2014-11-121-3/+3
| | | | | | that was preventing pass-by-value from working correctly. llvm-svn: 221803
* Mark TypeDecls used in explicit destructor calls as referenced.Nico Weber2014-11-121-0/+1
| | | | | | Fixes PR21221. Patch by Axel Naumann, test by me. llvm-svn: 221771
* Create two helpers for running the typo-correction tree transform.Kaelyn Takata2014-11-111-16/+28
| | | | | | | | | | | | | One takes an Expr* and the other is a simple wrapper that takes an ExprResult instead, and handles checking whether the ExprResult is invalid. Additionally, allow an optional callback that is run on the full result of the tree transform, for filtering potential corrections based on the characteristics of the resulting expression once all of the typos have been replaced. llvm-svn: 221735
* Wire up LookupMemberExpr to use the new TypoExpr.Kaelyn Takata2014-10-271-2/+45
| | | | | | | | This includes adding the new TypoExpr-based lazy typo correction to LookupMemberExprInRecord as an alternative to the existing eager typo correction. llvm-svn: 220698
* Add a callback for recovering using a typo correction.Kaelyn Takata2014-10-271-7/+11
| | | | | | | Also keep track of the stack of Exprs visited during the tree transform so the callback can be passed the parent of the TypoExpr. llvm-svn: 220697
* Start adding the infrastructure for handling TypoExprs.Kaelyn Takata2014-10-271-0/+114
| | | | | | | | | | | | | | | | Part of the infrastructure is a map from a TypoExpr to the Sema-specific state needed to correct it, along with helpers to ease dealing with the state. The the typo count is propagated up the stack of ExpressionEvaluationContextRecords when one is popped off of to avoid accidentally dropping TypoExprs on the floor. For example, the attempted correction of g() in test/CXX/class/class.mem/p5-0x.cpp happens with an ExpressionEvaluationContextRecord that is popped off the stack prior to ActOnFinishFullExpr being called and the tree transform for TypoExprs being run. llvm-svn: 220695
* -ms-extensions: Implement __super scope specifier (PR13236).Nikola Smiljanic2014-09-261-0/+2
| | | | | | | | | We build a NestedNameSpecifier that records the CXXRecordDecl in which __super appeared. Name lookup is performed in all base classes of the recorded CXXRecordDecl. Use of __super is allowed only inside class and member function scope. llvm-svn: 218484
* Simplify creation of a bunch of ArrayRefs by using None, makeArrayRef or ↵Craig Topper2014-08-271-5/+4
| | | | | | just letting them be implicitly created. llvm-svn: 216528
* C++1y is now C++14!Aaron Ballman2014-08-191-2/+2
| | | | | | Changes diagnostic options, language standard options, diagnostic identifiers, diagnostic wording to use c++14 instead of c++1y. It also modifies related test cases to use the updated diagnostic wording. llvm-svn: 215982
* MS ABI: Don't force bases to have an inheritance modelDavid Majnemer2014-08-081-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, assigning an inheritance model to a derived class would trigger further assiginments to the various bases of the class. This was done to fix a bug where we couldn't handle an implicit base-to-derived conversion for pointers-to-members when the conversion was ambiguous at an earlier point. However, this is not how the MS scheme works. Instead, assign inheritance models to *just* the class which owns to declaration we ended up referencing. N.B. This result is surprising in many ways. It means that it is possible for a base to have a "larger" inheritance model than it's derived classes. It also means that bases in the conversion path do not get assigned a model. struct A { void f(); void f(int); }; struct B : A {}; struct C : B {}; void f() { void (C::*x)() = &A::f; } We can only begin to assign an inheritance model *after* we've seen the address-of but *before* we've done the implicit conversion the more derived pointer-to-member type. After that point, both 'A' and 'C' will have an inheritance model but 'B' will not. Surprising, right? llvm-svn: 215174
* Factor out exception specification information fromRichard Smith2014-07-311-5/+4
| | | | | | | | FunctionProtoType::ExtProtoInfo. Most of the users of these fields don't care about the other ExtProtoInfo bits and just want to talk about the exception specification. llvm-svn: 214450
* PR20445: Properly transform the initializer in a CXXNewExpr rather than runningRichard Smith2014-07-251-10/+1
| | | | | | | it through the normal TreeTransform logic for Exprs (which will strip off implicit parts of the initialization and never re-create them). llvm-svn: 213913
* PR20228: don't retain a pointer to a vector element after the container has ↵Richard Smith2014-07-231-3/+4
| | | | | | been resized. llvm-svn: 213790
* Track the difference betweenRichard Smith2014-07-171-18/+15
| | | | | | | | | | | | -- a constructor list initialization that unpacked an initializer list into constructor arguments and -- a list initialization that created as std::initializer_list and passed it as the first argument to a constructor in the AST. Use this flag while instantiating templates to provide the right semantics for the resulting initialization. llvm-svn: 213224
* Remove llvm:: from uses of ArrayRef.Craig Topper2014-06-281-1/+1
| | | | llvm-svn: 211987
* [OPENMP] Loop canonical form analysis (Sema)Alexander Musman2014-06-031-1/+4
| | | | | | | | | This patch implements semantic analysis to make sure that the loop is in OpenMP canonical form. This is the form required for 'omp simd', 'omp for' and other loop pragmas. Differential revision: http://reviews.llvm.org/D3778 llvm-svn: 210095
* Fix 'this' capturing Generic lambdas used within default initializers (PR19876) Faisal Vali2014-05-301-1/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | http://llvm.org/bugs/show_bug.cgi?id=19876 The following C++1y code results in a crash: struct X { int m = 10; int n = [this](auto) { return m; }(20); }; When implicitly instantiating the generic lambda's call operator specialization body, Sema is unable to determine the current 'this' type when transforming the MemberExpr 'm' - since it looks for the nearest enclosing FunctionDeclDC - which is obviously null. I considered two ways to fix this: 1) In InstantiateFunctionDefinition, when the context is saved after the lambda scope info is created, retain the 'this' pointer. 2) Teach getCurrentThisType() to recognize it is within a generic lambda within an NSDMI/default-initializer and return the appropriate this type. I chose to implement #2 (though I confess I do not have a compelling reason for choosing it over #1). Richard Smith accepted the patch: http://reviews.llvm.org/D3935 Thank you! llvm-svn: 209874
* Refactoring. Remove Owned method from Sema.Nikola Smiljanic2014-05-291-98/+79
| | | | llvm-svn: 209812
* Refactoring. Remove release and take methods from ActionResult. Rename ↵Nikola Smiljanic2014-05-291-84/+84
| | | | | | takeAs to getAs. llvm-svn: 209800
* [C++11] Use 'nullptr'. Sema edition.Craig Topper2014-05-261-77/+81
| | | | llvm-svn: 209613
* Sema: Implement DR244David Majnemer2014-05-211-16/+9
| | | | | | | | | | | | | | | | Summary: Naming the destructor using a typedef-name for the class-name is well-formed. This fixes PR19620. Reviewers: rsmith, doug.gregor Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D3583 llvm-svn: 209319
* Push implicitly-declared allocation functions into the IdResolver. Otherwise,Richard Smith2014-05-161-3/+1
| | | | | | | declaration merging in modules is unable to find them and we get bogus errors and even crashes. llvm-svn: 208944
* Sema::FindAllocationFunctions(): Fix \param. [-Wdocumentation]NAKAMURA Takumi2014-05-141-1/+1
| | | | llvm-svn: 208758
OpenPOWER on IntegriCloud