summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExprCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix a typo correction crash when resolving ambiguous corrections.Kaelyn Takata2015-06-251-0/+6
| | | | | | | | | | | In certain cases, the tree transform would introduce new TypoExprs while trying one of the corrections, invalidating the unique_ptr in the state reference, and also causing a TypoExpr to exist that will never be corrected since it doesn't exist in the final corrected expression. The simple solution to both problems is to temporarily disable typo correction while handling potentially ambiguous typo corrections. llvm-svn: 240734
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-221-2/+2
| | | | llvm-svn: 240353
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-221-2/+2
| | | | | | | | | | | | The patch is generated using this command: $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ work/llvm/tools/clang To reduce churn, not touching namespaces spanning less than 10 lines. llvm-svn: 240270
* [MS ABI] Lock-in the derived memptr rep. for base-to-derived conversionsDavid Majnemer2015-06-121-4/+4
| | | | | | | | | We would get this right in the case where an explicit cast was formed but not when we were performing an implicit conversion. This fixes PR23828. llvm-svn: 239625
* add ConstEvaluatedExprVisitorScott Douglass2015-06-101-1/+0
| | | | | | Differential Revision: http://reviews.llvm.org/D10210 llvm-svn: 239474
* SemaExprCXX.cpp: Try to fix \param in r237608. [-Wdocumentation]NAKAMURA Takumi2015-05-191-2/+1
| | | | llvm-svn: 237668
* Detect uses of mismatching forms of 'new' and 'delete'Ismail Pazarbasi2015-05-181-8/+259
| | | | | | | | | | | | | | | | | Emit warning when operand to `delete` is allocated with `new[]` or operand to `delete[]` is allocated with `new`. rev 2 update: `getNewExprFromInitListOrExpr` should return `dyn_cast_or_null` instead of `dyn_cast`, since `E` might be null. Reviewers: rtrieu, jordan_rose, rsmith Subscribers: majnemer, cfe-commits Differential Revision: http://reviews.llvm.org/D4661 llvm-svn: 237608
* Revert "Detect uses of mismatching forms of 'new' and 'delete'"Diego Novillo2015-05-141-259/+8
| | | | | | | | | This reverts commit 742dc9b6c9686ab52860b7da39c3a126d8a97fbc. This is generating multiple segfaults in our internal builds. Test case coming up shortly. llvm-svn: 237391
* Detect uses of mismatching forms of 'new' and 'delete'Ismail Pazarbasi2015-05-141-8/+259
| | | | | | | | | | | | | Emit warning when operand to `delete` is allocated with `new[]` or operand to `delete[]` is allocated with `new`. Reviewers: rtrieu, jordan_rose, rsmith Subscribers: majnemer, cfe-commits Differential Revision: http://reviews.llvm.org/D4661 llvm-svn: 237368
* Allow TransformTypos to ignore corrections to a specified VarDecl.Kaelyn Takata2015-05-051-5/+10
| | | | | | | | | | | | | This is needed to prevent a TypoExpr from being corrected to a variable when the TypoExpr is a subexpression of that variable's initializer. Also exclude more keywords from the correction candidate pool when the subsequent token is .* or ->* since keywords like "new" or "return" aren't valid on the left side of those operators. Fixes PR23140. llvm-svn: 236519
* Check whether the operand to a noexcept expression is valid or not. Fixes ↵Aaron Ballman2015-04-271-0/+10
| | | | | | PR15842. llvm-svn: 235931
* Use 'override/final' instead of 'virtual' for overridden methodsAlexander Kornienko2015-04-111-2/+3
| | | | | | | | | | | | | | | | | | | | Summary: The patch is generated using clang-tidy misc-use-override check. This command was used: tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py \ -checks='-*,misc-use-override' -header-filter='llvm|clang' -j=32 -fix Reviewers: dblaikie Reviewed By: dblaikie Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D8926 llvm-svn: 234678
* Track the source location of the dot or arrow operator in a MemberExpr.Aaron Ballman2015-03-241-4/+3
| | | | | | Patch by Joe Ranieri! llvm-svn: 233085
* C++14: Disable sized deallocation by default due to ABI breakageReid Kleckner2015-03-201-9/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are no widely deployed standard libraries providing sized deallocation functions, so we have to punt and ask the user if they want us to use sized deallocation. In the future, when such libraries are deployed, we can teach the driver to detect them and enable this feature. N3536 claimed that a weak thunk from sized to unsized deallocation could be emitted to avoid breaking backwards compatibility with standard libraries not providing sized deallocation. However, this approach and other variations don't work in practice. With the weak function approach, the thunk has to have default visibility in order to ensure that it is overridden by other DSOs providing sized deallocation. Weak, default visibility symbols are particularly expensive on MachO, so John McCall was considering disabling this feature by default on Darwin. It also changes behavior ELF linking behavior, causing certain otherwise unreferenced object files from an archive to be pulled into the link. Our second approach was to use an extern_weak function declaration and do an inline conditional branch at the deletion call site. This doesn't work because extern_weak only works on MachO if you have some archive providing the default value of the extern_weak symbol. Arranging to provide such an archive has the same challenges as providing the symbol in the standard library. Not to mention that extern_weak doesn't really work on COFF. Reviewers: rsmith, rjmccall Differential Revision: http://reviews.llvm.org/D8467 llvm-svn: 232788
* Revert "Improvement on sized deallocation from r230160"Reid Kleckner2015-03-191-10/+9
| | | | | | | | | This reverts commit r230580. extern_weak functions don't appear to work on Darwin (PR22951), so we'll need to come up with a new approach. llvm-svn: 232731
* MS ABI: Implement __GetExceptionInfo for std::make_exception_ptrDavid Majnemer2015-03-131-45/+43
| | | | | | | | | std::make_exception_ptr calls std::__GetExceptionInfo in order to figure out how to properly copy the exception object. Differential Revision: http://reviews.llvm.org/D8280 llvm-svn: 232188
* MS ABI: Implement copy-ctor closures, finish implementing throwDavid Majnemer2015-03-111-4/+41
| | | | | | | | | | | | | | | This adds support for copy-constructor closures. These are generated when the C++ runtime has to call a copy-constructor with a particular calling convention or with default arguments substituted in to the call. Because the runtime has no mechanism to call the function with a different calling convention or know-how to evaluate the default arguments at run-time, we create a thunk which will do all the appropriate work and package it in a way the runtime can use. Differential Revision: http://reviews.llvm.org/D8225 llvm-svn: 231952
* MS ABI: Correctly generate throw-info for pointer to const qual typesDavid Majnemer2015-03-061-3/+2
| | | | | | | We didn't create type info based on the unqualified pointee type, causing RTTI mismatches. llvm-svn: 231533
* MS ABI: Insert copy-constructors into the CatchableTypeDavid Majnemer2015-03-061-10/+70
| | | | | | | | | | | | | | | | Find all unambiguous public classes of the exception object's class type and reference all of their copy constructors. Yes, this is not conforming but it is necessary in order to implement their ABI. This is because the copy constructor is actually referenced by the metadata describing which catch handlers are eligible to handle the exception object. N.B. This doesn't yet handle the copy constructor closure case yet, that work is ongoing. Differential Revision: http://reviews.llvm.org/D8101 llvm-svn: 231499
* [PATCH] Patch to fix the AST for vector splat from any Fariborz Jahanian2015-03-051-2/+12
| | | | | | | | arithmetic type to a vector so that the arithmatic type matches the vector element type. Without which it crashes in Code Gen. rdar://20000762 llvm-svn: 231419
* Sema: Properly initialize the thrown exception objectDavid Majnemer2015-03-031-21/+6
| | | | | | | We would create the exception object with the wrong qualifiers, ensuring that the wrong copy constructor would get called. llvm-svn: 231049
* Silence unused variable warning in NDEBUG buildReid Kleckner2015-02-261-2/+2
| | | | llvm-svn: 230590
* Improvement on sized deallocation from r230160:Larisse Voufo2015-02-251-9/+10
| | | | | | Do not declare sized deallocation functions dependently on whether it is found in global scope. Instead, enforce the branching in emitted code by (1) declaring the functions extern_weak and (2) emitting sized delete expressions as a branching between both forms delete. llvm-svn: 230580
* Sema: Parenthesized bound destructor member expressions can be calledDavid Majnemer2015-02-251-27/+7
| | | | | | | | | We would wrongfully reject (a.~A)() in both the destructor and pseudo-destructor cases. This fixes PR22668. llvm-svn: 230512
* PR22673 again: diagnose use of the used decl, not the found decl. This is alsoRichard Smith2015-02-241-2/+2
| | | | | | | wrong (DiagnoseUseOfDecl should take both), but it's more consistent with what we do in other places. llvm-svn: 230384
* PR22673: Don't forget to check a constructor for deletedness when we use it toRichard Smith2015-02-241-3/+7
| | | | | | implicitly construct a temporary in a reference binding. llvm-svn: 230381
* Relax the requirement on sized deallocation a bit: Default on unsized delete ↵Larisse Voufo2015-02-221-0/+9
| | | | | | if sized delete is not provided in global scope, and -fdefine-sized-deallocation option is disabled. llvm-svn: 230160
* Cleanup: remove artificial division between lookup results and const lookupRichard Smith2015-02-211-4/+4
| | | | | | | results. No-one was ever modifying a lookup result, and it would not be reasonable to do so. llvm-svn: 230123
* Wrap to 80 columns. No behavior change.Nico Weber2015-02-161-4/+5
| | | | llvm-svn: 229450
* Sema: Add support for __declspec(restrict)David Majnemer2015-02-041-5/+7
| | | | | | | | | | __declspec(restrict) and __attribute(malloc) are both handled identically by clang: they are allowed to the noalias LLVM attribute. Seeing as how noalias models the C99 notion of 'restrict', rename the internal clang attribute to Restrict from Malloc. llvm-svn: 228120
* Generalize r228066 to give all implicit global allocation functions default ↵Larisse Voufo2015-02-041-0/+4
| | | | | | visibility. llvm-svn: 228107
* PR22367: Don't forget to create a CXXFunctionalCastExpr aroundRichard Smith2015-01-281-6/+9
| | | | | | | | | list-initialization that gets converted to some form other than an InitListExpr. CXXTemporaryObjectExpr is a special case here, because it represents a fused CXXFunctionalCastExpr + CXXConstructExpr. That, in itself, is probably a design error... llvm-svn: 227377
* Revert a change from r222797 that is no longer needed and can causeKaelyn Takata2015-01-281-0/+4
| | | | | | | | | | | | | infinite recursion. Also guard against said infinite recursion by adding an assert that will trigger if CorrectDelayedTyposInExpr is called before a previous call to CorrectDelayedTyposInExpr returns (i.e. if the TreeTransform run by CorrectDelayedTyposInExpr calls a sequence of methods that end up calling CorrectDelayedTyposInExpr, as the new test case had done prior to this commit). Fixes PR22292. llvm-svn: 227368
* Fix a think-o in handling ambiguous corrections for a TypoExpr.Kaelyn Takata2015-01-271-4/+7
| | | | | | | | | | | | | | | | | | | | Under certain circumstances, the identifier mentioned in the diagnostic won't match the intended correction even though the replacement expression and the note pointing to the decl are both correct. Basically, the TreeTransform assumes the TypoExpr's Consumer points to the correct TypoCorrection, but the handling of typos that appear to be ambiguous from the point of view of TransformTypoExpr would cause that assumption to be violated by altering the Consumer's correction stream. This fix allows the Consumer's correction stream to be reset to the right TypoCorrection after successfully resolving the percieved ambiguity. Included is a fix to suppress correcting the RHS of an assignment to the LHS of that assignment for non-C++ code, to prevent a regression in test/SemaObjC/provisional-ivar-lookup.m. This fixes PR22297. llvm-svn: 227251
* 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
OpenPOWER on IntegriCloud