summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExprCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [MSVC] Fix check for wchar_t type in case of -fno-wcharDmitry Polukhin2016-04-141-1/+2
| | | | | | | | | | | The example below should work identically with and without compiler native wchar_t support. void foo(wchar_t * t = L""); Differential Revision: http://reviews.llvm.org/D19056 llvm-svn: 266287
* Enable support for __float128 in ClangNemanja Ivanovic2016-04-131-0/+6
| | | | | | | | | | | | | | | | This patch corresponds to review: http://reviews.llvm.org/D15120 It adds support for the __float128 keyword, literals and a target feature to enable it. This support is disabled by default on all targets and any target that has support for this type is free to add it. Based on feedback that I've received from target maintainers, this appears to be the right thing for most targets. I have not heard from the maintainers of X86 which I believe supports this type. I will subsequently investigate the impact of enabling this on X86. llvm-svn: 266186
* Replace Sema-level implementation of -fassume-sane-operator-new with aRichard Smith2016-04-071-12/+3
| | | | | | | | | | | | | | CodeGen-level implementation. Instead of adding an attribute to clang's FunctionDecl, add the IR attribute directly. This means a module built with this flag is now compatible with code built without it and vice versa. This change also results in the 'noalias' attribute no longer being added to calls to operator new in the IR; it's now only added to the declaration. It also fixes a bug where we failed to add the attribute to the 'nothrow' versions (because we didn't implicitly declare them, there was no good time to inject a fake attribute). llvm-svn: 265728
* [CUDA] Remove three obsolete CUDA cc1 flags.Justin Lebar2016-03-291-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: * -fcuda-target-overloads Previously unconditionally set to true by the driver. Necessary for correct functioning of the compiler -- our CUDA headers wrapper won't compile without this. * -fcuda-disable-target-call-checks Previously unconditionally set to true by the driver. Necessary to compile almost any external CUDA code -- almost all libraries assume that host+device code can call host or device functions. * -fcuda-allow-host-calls-from-host-device No effect when target overloading is enabled. Reviewers: tra Subscribers: rsmith, cfe-commits Differential Revision: http://reviews.llvm.org/D18416 llvm-svn: 264739
* Fix serialization/deserialization for __uuidofDavid Majnemer2016-03-281-7/+9
| | | | | | | | I broke this back in r264529 because I forgot to serialize the UuidAttr member. Fix this by replacing the UuidAttr with a StringRef which is properly serialized and deserialized. llvm-svn: 264562
* Improve the representation of CXXUuidofExprDavid Majnemer2016-03-271-16/+55
| | | | | | | | Keep a pointer to the UuidAttr that the CXXUuidofExpr corresponds to. This makes translating from __uuidof to the underlying constant a lot more straightforward. llvm-svn: 264529
* [Cxx1z] Implement Lambda Capture of *this by Value as [=,*this] (P0018R3)Faisal Vali2016-03-211-26/+116
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement lambda capture of *this by copy. For e.g.: struct A { int d = 10; auto foo() { return [*this] (auto a) mutable { d+=a; return d; }; } }; auto L = A{}.foo(); // A{}'s lifetime is gone. // Below is still ok, because *this was captured by value. assert(L(10) == 20); assert(L(100) == 120); If the capture was implicit, or [this] (i.e. *this was captured by reference), this code would be otherwise undefined. Implementation Strategy: - amend the parser to accept *this in the lambda introducer - add a new king of capture LCK_StarThis - teach Sema::CheckCXXThisCapture to handle by copy captures of the enclosing object (i.e. *this) - when CheckCXXThisCapture does capture by copy, the corresponding initializer expression for the closure's data member direct-initializes it thus making a copy of '*this'. - in codegen, when assigning to CXXThisValue, if *this was captured by copy, make sure it points to the corresponding field member, and not, unlike when captured by reference, what the field member points to. - mark feature as implemented in svn Much gratitude to Richard Smith for his carefully illuminating reviews! llvm-svn: 263921
* [SemaExprCXX] Avoid calling isInSystemHeader for invalid source locationsPavel Labath2016-03-041-1/+2
| | | | | | | | | | | | | | | | | | | Summary: While diagnosing a CXXNewExpr warning, we were calling isInSystemHeader(), which expect to be called with a valid source location. This causes an assertion failure if the location is unknown. A quick grep shows it's not without precedent to guard calls to the function with a "Loc.isValid()". This fixes a test failure in LLDB, which always creates object with invalid source locations as it does not (always) have access to the source. Reviewers: nlewycky Subscribers: lldb-commits, cfe-commits Differential Revision: http://reviews.llvm.org/D17847 llvm-svn: 262700
* Sema: handle typo correction on ARC'ed ivarSaleem Abdulrasool2016-02-071-0/+4
| | | | | | | | | | | The ivar ref would be transformed by the Typo Correction TreeTransform, but not be owned, resulting in the source location being invalid. This would eventually lead to an assertion in findCapturingExpr. Prevent this assertion from triggering. Resolves PR25113. llvm-svn: 260017
* Sema: handle typo correction with ARC'ed objc propertiesSaleem Abdulrasool2016-02-071-0/+4
| | | | | | | | | | | | | We would previously assert in findCapturingExpr when performing a typo correction resulting in an assignment of an ObjC property with a strong lifetype specifier due to the expression not being rooted in the file (invalid SLoc) during the retain cycle check on the typo-corrected expression. Handle the expression type appropriately during the TreeTransform to ensure that we have a source location associated with the expression. Fixes PR26486. llvm-svn: 260016
* OpaquePtr: Use nullptr construction for ParsedType OpaquePtr typedefDavid Blaikie2016-01-151-6/+6
| | | | llvm-svn: 257958
* Make -Wdelete-non-virtual-dtor warn on explicit `a->~A()` dtor calls too.Nico Weber2016-01-151-24/+43
| | | | | | | | | | | | | | | | | | | | | | | -Wdelete-non-virtual-dtor warns if A is a type with virtual functions but without virtual dtor has its constructor called via `delete a`. This makes the warning also fire if the dtor is called via `a->~A()`. This would've found a security bug in Chromium at compile time. Fixes PR26137. To fix the warning, add a virtual destructor, make the class final, or remove its other virtual methods. If you want to silence the warning, there's also a fixit that shows how: test.cc:12:3: warning: destructor called on 'B' ... [-Wdelete-non-virtual-dtor] b->~B(); ^ test.cc:12:6: note: qualify call to silence this warning b->~B(); ^ B:: http://reviews.llvm.org/D16206 llvm-svn: 257939
* [Bugfix] Fix ICE on constexpr vector splat.George Burgess IV2016-01-131-12/+5
| | | | | | | | | | | | | In {CG,}ExprConstant.cpp, we weren't treating vector splats properly. This patch makes us treat splats more properly. Additionally, this patch adds a new cast kind which allows a bool->int cast to result in -1 or 0, instead of 1 or 0 (for true and false, respectively), so we can sanely model OpenCL bool->int casts in the AST. Differential Revision: http://reviews.llvm.org/D14877 llvm-svn: 257559
* Teach typo correction to properly handle mapping declarations to theirRichard Smith2015-12-291-4/+4
| | | | | | | | | | underlying decls. Preserve the found declaration throughout, and only map to the underlying declaration when we want to check whether it's the right kind. This allows us to provide the right source location for the found declaration, and prepares for the possibility of underlying decls with a different name from the found decl. llvm-svn: 256575
* Split RequireCompleteType into a function that actually requires that the typeRichard Smith2015-12-181-5/+6
| | | | | | | | | | | | | | | | | | | is complete (with an error produced if not) and a function that merely queries whether the type is complete. Either way we'll trigger instantiation if necessary, but only the former will diagnose and recover from missing module imports. The intent of this change is to prevent a class of bugs where code would call RequireCompleteType(..., 0) and then ignore the result. With modules, we must check the return value and use it to determine whether the definition of the type is visible. This also fixes a debug info quality issue: calls to isCompleteType do not trigger the emission of debug information for a type in limited-debug-info mode. This allows us to avoid emitting debug information for type definitions in more cases where we believe it is safe to do so. llvm-svn: 256049
* Wire a SourceLocation into IsDerivedFrom and move the RequireCompleteType callRichard Smith2015-12-181-4/+4
| | | | | | | | for the derived class into it. This is mostly just a cleanup, but could in principle be a bugfix if there is some codepath that reaches here and didn't previously require a complete type (I couldn't find any such codepath, though). llvm-svn: 256037
* [Sema] Make nullness warnings appear in C++.George Burgess IV2015-12-141-0/+7
| | | | | | | | | | | | | | | | | | | Given the following code: int *_Nullable ptr; int *_Nonnull nn = ptr; ...In C, clang will warn you about `nn = ptr`, because you're assigning a nonnull pointer to a nullable pointer. In C++, clang issues no such warning. This patch helps ensure that clang doesn't ever miss an opportunity to complain about C++ code. N.B. Though this patch has a differential revision link, the actual review took place over email. Differential Revision: http://reviews.llvm.org/D14938 llvm-svn: 255556
* Allow pseudo-destructor calls on forward-declared Objective-C class pointers.John McCall2015-12-141-1/+6
| | | | | | rdar://18522255 llvm-svn: 255531
* [Sema] Implement several unary type traits more accuratelyDavid Majnemer2015-11-161-19/+32
| | | | | | | | | | | | | | is_empty, is_polymorphic, and is_abstract didn't handle incomplete types correctly. Only non-union class types must be complete for these traits. is_final and is_sealed don't care about the particular spelling of the FinalAttr. is_interface_class should always return false regardless of its input. The type trait can only be satisfied in a mode we do not support (/CLR). llvm-svn: 253184
* Use Sema::getLocForEndOfToken instead of Preprocessor::getLocForEndOfToken. NFCCraig Topper2015-11-151-1/+1
| | | | llvm-svn: 253155
* [Sema] __is_constructible should return false for function typesDavid Majnemer2015-11-131-10/+11
| | | | | | | | While functions types are complete, they cannot be constructed. This fixes PR25513. llvm-svn: 253013
* Sema: correct typo recovery with blocksSaleem Abdulrasool2015-10-311-0/+2
| | | | | | | | | | Handle blocks in the tree transform for the typo correction as otherwise, the capture may miss. This would trigger an assertion. Thanks to Doug Gregor for the help with this! Fixes PR25001. llvm-svn: 251729
* MismatchingNewDeleteDetector uses incorrect field, and finds no initializerIsmail Pazarbasi2015-10-261-2/+4
| | | | | | | | | | | | | | | Summary: In `MismatchingNewDeleteDetector::analyzeInClassInitializer`, if `Field`'s initializer expression is null, lookup the field in implicit instantiation, and use found field's the initializer. Reviewers: rsmith, rtrieu Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D9898 llvm-svn: 251335
* Fix warning caused by r249995George Burgess IV2015-10-111-0/+1
| | | | llvm-svn: 249997
* [CUDA] Allow function overloads in CUDA based on host/device attributes.Artem Belevich2015-09-221-0/+6
| | | | | | | | | | | | | | | | | | | The patch makes it possible to parse CUDA files that contain host/device functions with identical signatures, but different attributes without having to physically split source into host-only and device-only parts. This change is needed in order to parse CUDA header files that have a lot of name clashes with standard include files. Gory details are in design doc here: https://goo.gl/EXnymm Feel free to leave comments there or in this review thread. This feature is controlled with CC1 option -fcuda-target-overloads and is disabled by default. Differential Revision: http://reviews.llvm.org/D12453 llvm-svn: 248295
* [Sema] Reject value-initialization of function typesDavid Majnemer2015-09-141-0/+9
| | | | | | | | | T in the expression T() must be a non-array complete object type or the void type. Function types are neither. This fixes PR24798. llvm-svn: 247535
* [MS ABI] Make member pointers return true for isIncompleteTypeDavid Majnemer2015-09-101-2/+0
| | | | | | | The type of a member pointer is incomplete if it has no inheritance model. This lets us reuse more general logic already embedded in clang. llvm-svn: 247346
* [MS ABI] Select a pointer to member representation more oftenDavid Majnemer2015-09-101-0/+2
| | | | | | | | | Given a reference to a pointer to member whose class's inheritance model is unspecified, make sure we come up with an inheritance model in plausible places. One place we were missing involved LValue to RValue conversion, another involved unary type traits. llvm-svn: 247248
* Add a new frontend warning for referencing members from the handler of a ↵Aaron Ballman2015-09-011-1/+1
| | | | | | | | constructor or destructor function-try-block, which is UB in C++. This corresponds to the CERT secure coding rule ERR53-CPP. llvm-svn: 246548
* [MSVC Compat] Implement __is_destructible, __is_nothrow_destructibleDavid Majnemer2015-08-111-2/+41
| | | | | | | | Our implementations of these type trait intrinsics simply mapped them to __has_trivial_destructor. Instead, flesh these intrinsics out with a full implementation which matches the standard's description. llvm-svn: 244564
* Add support for System z vector language extensionsUlrich Weigand2015-07-301-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The z13 vector facility has an associated language extension, closely modeled on AltiVec/VSX. The main differences are: - vector long, vector float and vector pixel are not supported - vector long long and vector double are supported (like VSX) - comparison operators return a vector rather than a scalar integer - shift operators behave like the OpenCL shift operators - vector bool is only supported as argument to certain operators; some operators allow mixing a bool with a non-bool vector This patch adds clang support for the extension. It is closely modelled on the AltiVec support. Similarly to the -faltivec option, there's a new -fzvector option to enable the extensions (as well as an -mzvector alias for compatibility with GCC). There's also a separate LangOpt. The extension as implemented here is intended to be compatible with the -mzvector extension recently implemented by GCC. Based on a patch by Richard Sandiford. Differential Revision: http://reviews.llvm.org/D11001 llvm-svn: 243642
* Use range-based for loops; NFC.Aaron Ballman2015-07-211-10/+6
| | | | llvm-svn: 242846
* Use a range-based for loop; NFC.Aaron Ballman2015-07-211-2/+2
| | | | llvm-svn: 242836
* Replace some uses of Self.Context with the local variable C; NFC.Aaron Ballman2015-07-211-14/+14
| | | | llvm-svn: 242835
* 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
OpenPOWER on IntegriCloud