summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [OPENMP] Capture references to global variables.Alexey Bataev2017-10-061-1/+2
| | | | | | | | In C++11 variable to global variables are considered as constant expressions and these variables are not captured in the outlined regions. Patch allows capturing of such variables in the OpenMP regions. llvm-svn: 315074
* [OpenCL] Fix checking of vector type castingYaxun Liu2017-10-031-3/+3
| | | | | | | | | | | | | | | | | | Currently clang allows the following code int a; int b = (const int) a; However it does not the following code int4 a; int4 b = (const int4) a; This is because Clang compares the qualified types instead of unqualified types for vector type casting, which causes the inconsistency. This patch fixes that. Differential Revision: https://reviews.llvm.org/D38463 llvm-svn: 314802
* [Sema] Null check in BuildDeclarationNameExprYi Kong2017-09-251-0/+2
| | | | | | | | | | Qualtype may point to null if we cannot infer its type yet. Fixes PR33843 Differential Revision: https://reviews.llvm.org/D38158 llvm-svn: 314124
* Don't warn about runtime behavior problems in variable initializers that weRichard Smith2017-09-231-3/+17
| | | | | | | | know are going to be constant-evaluated. Any relevant diagnostics should be produced by constant expression evaluation. llvm-svn: 314067
* Promote storage-only __fp16 vector operands to float vectors.Akira Hatanaka2017-09-231-2/+119
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit fixes a bug in the handling of storage-only __fp16 vectors where clang didn't promote __fp16 vector operands to float vectors. Conceptually, it performs the following transformation on the AST in CreateBuiltinBinOp and CreateBuiltinUnaryOp: (Before) typedef __fp16 half4 __attribute__ ((vector_size (8))); typedef float float4 __attribute__ ((vector_size (16))); half4 hv0, hv1, hv2, hv3; hv0 = hv1 + hv2 + hv3; (After) float4 t0 = (float4)hv1 + (float4)hv2; float4 t1 = t0 + (float4)hv3; hv0 = (half4)t1; Note that this commit fixes the bug for targets that set HalfArgsAndReturns to true (ARM and ARM64). Targets using intrinsics such as llvm.convert.to.fp16 to handle __fp16 are still broken. rdar://problem/20625184 Differential Revision: https://reviews.llvm.org/D32520 llvm-svn: 314056
* Implement C++ [basic.link]p8.Richard Smith2017-09-201-0/+2
| | | | | | | | | | | | | | If a function or variable has a type with no linkage (and is not extern "C"), any use of it requires a definition within the same translation unit; the idea is that it is not possible to define the entity elsewhere, so any such use is necessarily an error. There is an exception, though: some types formally have no linkage but nonetheless can be referenced from other translation units (for example, this happens to anonymous structures defined within inline functions). For entities with those types, we suppress the diagnostic except under -pedantic. llvm-svn: 313729
* Teach clang to tolerate the 'p = nullptr + n' idiom used by glibcAndrew Kaylor2017-09-191-0/+46
| | | | | | Differential Revision: https://reviews.llvm.org/D37042 llvm-svn: 313666
* [Sema] Disallow assigning record lvalues with nested const-qualified fields.Bjorn Pettersson2017-09-191-10/+74
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: According to C99 6.3.2.1p1, structs and unions with nested const-qualified fields (that is, const-qualified fields declared at some recursive level of the aggregate) are not modifiable lvalues. However, Clang permits assignments of these lvalues. With this patch, we both prohibit the assignment of records with const-qualified fields and emit a best-effort diagnostic. This fixes https://bugs.llvm.org/show_bug.cgi?id=31796 . Committing on behalf of bevinh (Bevin Hansson). Reviewers: rtrieu, rsmith, bjope Reviewed By: bjope Subscribers: Ka-Ka, rogfer01, bjope, fhahn, cfe-commits Differential Revision: https://reviews.llvm.org/D37254 llvm-svn: 313628
* Fix the second half of PR34266: Don't implicitly capture '*this' if the ↵Faisal Vali2017-09-171-0/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | members are found in a class unrelated to the enclosing class. https://bugs.llvm.org/show_bug.cgi?id=34266 For e.g. struct A { void f(int); static void f(char); }; struct B { auto foo() { return [&] (auto a) { A::f(a); // this should not cause a capture of '*this' }; } }; The patch does the following: 1) It moves the check to attempt an implicit capture of '*this' by reference into the more logical location of when the call is actually built within ActOnCallExpr (as opposed to when the unresolved-member-lookup node is created). - Reminder: A capture of '*this' by value has to always be an explicit capture. 2) It additionally checks whether the naming class of the UnresolvedMemberExpr ('A' in the example above) is related to the enclosing class ('B' above). P.S. If you have access to ISO-C++'s CWG reflector, see this thread for some potentially related discussion: http://lists.isocpp.org/core/2017/08/2851.php llvm-svn: 313487
* [Sema] Correct typos in LHS, RHS before building a binop expression.Volodymyr Sapsai2017-09-151-15/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Specifically, typo correction should be done before dispatching between different kinds of binary operations like pseudo-object assignment, overloaded binary operation, etc. Without this change we hit an assertion Assertion failed: (!LHSExpr->hasPlaceholderType(BuiltinType::PseudoObject)), function CheckAssignmentOperands when in Objective-C we reference a property without `self` and there are 2 equally good typo correction candidates: ivar and a class name. In this case LHS expression in `BuildBinOp` is CXXDependentScopeMemberExpr `-TypoExpr and instead of handling Obj-C property assignment as pseudo-object assignment, we call `CreateBuiltinBinOp` which corrects typo to ObjCPropertyRefExpr '<pseudo-object type>' but cannot handle pseudo-objects and asserts about it (indirectly, through `CheckAssignmentOperands`). rdar://problem/33102722 Reviewers: rsmith, ahatanak, majnemer Reviewed By: ahatanak Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D37322 llvm-svn: 313323
* Catch more cases with -Wenum-compareRichard Trieu2017-09-091-2/+4
| | | | | | | Treat typedef enum as named enums instead of anonymous enums. Anonymous enums are ignored by the warning, so previously, typedef enums were ignored as well. llvm-svn: 312842
* Recommit "Add _Float16 as a C/C++ source language type"Sjoerd Meijer2017-09-081-2/+6
| | | | | | | | This is a recommit of r312781; in some build configurations variable names are omitted, so changed the new regression test accordingly. llvm-svn: 312794
* Revert "Add _Float16 as a C/C++ source language type"Sjoerd Meijer2017-09-081-6/+2
| | | | | | | The clang-with-lto-ubuntu bot didn't like the new regression test, revert while I investigate the issue. llvm-svn: 312784
* Add _Float16 as a C/C++ source language typeSjoerd Meijer2017-09-081-2/+6
| | | | | | | | | | | This adds _Float16 as a source language type, which is a 16-bit floating point type defined in C11 extension ISO/IEC TS 18661-3. In follow up patches documentation and more tests will be added. Differential Revision: https://reviews.llvm.org/D33719 llvm-svn: 312781
* [OpenCL] Handle taking an address of block captures.Anastasia Stulova2017-09-071-12/+11
| | | | | | | | | | | | | | | | Block captures can have different physical locations in memory segments depending on the use case (as a function call or as a kernel enqueue) and in different vendor implementations. Therefore it's unclear how to add address space to capture addresses uniformly. Currently it has been decided to disallow taking addresses of captured variables until further clarifications in the spec. Differential Revision: https://reviews.llvm.org/D36410 llvm-svn: 312728
* Fix typos, remove unused private members of CommonOptionsParser, NFCJohannes Altmanninger2017-08-231-1/+1
| | | | llvm-svn: 311544
* [OPENMP] Fix for PR34014: OpenMP 4.5: Target construct in static methodAlexey Bataev2017-08-221-0/+1
| | | | | | | | | | of class fails to map class static variable. If the global variable is captured and it has several redeclarations, sometimes it may lead to a compiler crash. Patch fixes this by working only with canonical declarations. llvm-svn: 311479
* Fix typos in comments; NFCGeorge Burgess IV2017-08-161-1/+1
| | | | llvm-svn: 311051
* Reapply Sema: allow imaginary constants via GNU extension if UDL overloads ↵Tim Northover2017-08-091-8/+17
| | | | | | | | | | | | | | | | | | not present. C++14 added user-defined literal support for complex numbers so that you can write something like "complex<double> val = 2i". However, there is an existing GNU extension supporting this syntax and interpreting the result as a _Complex type. This changes parsing so that such literals are interpreted in terms of C++14's operators if an overload is present but otherwise falls back to the original GNU extension. (We now have more robust diagnostics for implicit conversions so the libc++ test that caused the original revert still passes). llvm-svn: 310478
* Sema: disable implicit conversion from _Complex to real types in C++.Tim Northover2017-08-081-0/+6
| | | | | | | | | | | Converting a _Complex type to a real one simply discards the imaginary part. This can easily lead to loss of information so for safety (and GCC compatibility) this patch disallows that when the conversion would be implicit. The one exception is bool, which actually compares both real and imaginary parts and so is safe. llvm-svn: 310427
* [OPENMP][DEBUG] Set proper address space info if required by target.Alexey Bataev2017-08-081-0/+2
| | | | | | | | | | | Arguments, passed to the outlined function, must have correct address space info for proper Debug info support. Patch sets global address space for arguments that are mapped and passed by reference. Also, cuda-gdb does not handle reference types correctly, so reference arguments are represented as pointers. llvm-svn: 310387
* Revert "[OPENMP][DEBUG] Set proper address space info if required by target."Alexey Bataev2017-08-081-2/+0
| | | | | | This reverts commit r310377. llvm-svn: 310379
* [OPENMP][DEBUG] Set proper address space info if required by target.Alexey Bataev2017-08-081-0/+2
| | | | | | | | | | | Arguments, passed to the outlined function, must have correct address space info for proper Debug info support. Patch sets global address space for arguments that are mapped and passed by reference. Also, cuda-gdb does not handle reference types correctly, so reference arguments are represented as pointers. llvm-svn: 310377
* Revert "[OPENMP][DEBUG] Set proper address space info if required by target."Alexey Bataev2017-08-081-2/+0
| | | | | | This reverts commit r310360. llvm-svn: 310364
* [OPENMP][DEBUG] Set proper address space info if required by target.Alexey Bataev2017-08-081-0/+2
| | | | | | | | | | | Arguments, passed to the outlined function, must have correct address space info for proper Debug info support. Patch sets global address space for arguments that are mapped and passed by reference. Also, cuda-gdb does not handle reference types correctly, so reference arguments are represented as pointers. llvm-svn: 310360
* Revert "[OPENMP][DEBUG] Set proper address space info if required by target."Alexey Bataev2017-08-041-2/+0
| | | | | | This reverts commit r310104. llvm-svn: 310135
* [OPENMP][DEBUG] Set proper address space info if required by target.Alexey Bataev2017-08-041-0/+2
| | | | | | | | | | | Arguments, passed to the outlined function, must have correct address space info for proper Debug info support. Patch sets global address space for arguments that are mapped and passed by reference. Also, cuda-gdb does not handle reference types correctly, so reference arguments are represented as pointers. llvm-svn: 310104
* [Sema] Add a comment on an identified bug on default arguments.Tim Shen2017-08-031-0/+16
| | | | | | | | | | | | | | | Summary: The mis-compile is triggered by internal code, but I haven't reduced it to a small piece of code. Add a FIXME here, since a decent fix doesn't seem to be trivial. The decent fix can be changing Decl::Init to PointerUnion<Stmt *, EvaluatedStmt *, ParamVarDecl *>, and make setUninstantiatedDefaultArg take a ParamVarDecl *, which contains the Expr * as the default argument. This way, getTemplateInstantiationArgs can take that ParamVarDecl and do the right thing. Reviewers: rsmith Subscribers: sanjoy, cfe-commits Differential Revision: https://reviews.llvm.org/D36253 llvm-svn: 309908
* [Sema] Fix lax conversion between non ext vectorsBruno Cardoso Lopes2017-08-011-1/+1
| | | | | | | | | | r282968 introduced a regression due to the lack of proper testing. Re-add lax conversion support between non ext vectors for compound assignments and add a test for that. rdar://problem/28639467 llvm-svn: 309722
* [Sema] NFC: Move all availability checking code to SemaDeclAttr.cppErik Pilkington2017-07-181-78/+1
| | | | | | Previously, this was awkwardly split up between SemaExpr.cpp. llvm-svn: 308356
* [Sema] Mark a virtual CXXMethodDecl as used if a call to it can beAkira Hatanaka2017-07-131-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | devirtualized. The code to detect devirtualized calls is already in IRGen, so move the code to lib/AST and make it a shared utility between Sema and IRGen. This commit fixes a linkage error I was seeing when compiling the following code: $ cat test1.cpp struct Base { virtual void operator()() {} }; template<class T> struct Derived final : Base { void operator()() override {} }; Derived<int> *d; int main() { if (d) (*d)(); return 0; } rdar://problem/33195657 Differential Revision: https://reviews.llvm.org/D34301 llvm-svn: 307883
* [ObjC] Avoid the -Wunguarded-availability warnings for protocolAlex Lorenz2017-07-071-3/+8
| | | | | | | | | | | | | | | requirements in protocol/class/category declarations The unguarded availability warnings in the protocol requirements of a protocol /class/category declaration can be avoided. This matches the behaviour of Swift's diagnostics. The warnings for deprecated/unavailable protocols are preserved. rdar://33156429 Differential Revision: https://reviews.llvm.org/D35061 llvm-svn: 307368
* [Sema] Don't allow -Wunguarded-availability to be silenced with redeclsErik Pilkington2017-07-051-66/+31
| | | | | | Differential revision: https://reviews.llvm.org/D33816 llvm-svn: 307175
* Prevent devirtualization of calls to un-instantiated functions.Sunil Srivastava2017-06-201-0/+1
| | | | | | | | PR 27895 Differential Revision: https://reviews.llvm.org/D22057 llvm-svn: 305862
* [coroutines] Remove pass-through operator co_await; Replace it with the ↵Eric Fiselier2017-06-151-1/+7
| | | | | | | | | | | | input expression Reviewers: GorNishanov, rsmith Reviewed By: GorNishanov Differential Revision: https://reviews.llvm.org/D34216 llvm-svn: 305498
* Catch invalid bitwise operation on vector of floatsSerge Pavlov2017-06-081-10/+7
| | | | | | | | | | | | Bitwise complement applied to vector of floats described with attribute `ext_vector_type` is not diagnosed as error. Attempt to compile such construct causes assertion violation in Instruction.cpp. With this change the complement is treated similar to the case of vector type described with attribute `vector_size`. Differential Revision: https://reviews.llvm.org/D33732 llvm-svn: 304963
* Simplify.Richard Smith2017-06-081-8/+4
| | | | llvm-svn: 304960
* [Sema] Silence unused variable warning.Benjamin Kramer2017-06-071-1/+1
| | | | llvm-svn: 304892
* Improve error recovery for missing 'template' keyword in contexts where theRichard Smith2017-06-071-0/+26
| | | | | | | | | | | | | | template is valid with or without it (with different meanings). If we see "dependent.x<...", and what follows the '<' is a valid expression, we must parse the '<' as a comparison rather than a template angle bracket. When we later come to instantiate, if we find that the LHS of the '<' actually names an overload set containing function templates, produce a diagnostic suggesting that the 'template' keyword was missed rather than producing a mysterious diagnostic saying that the function must be called (and pointing at what looks to already be a function call!). llvm-svn: 304852
* Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.Galina Kistanova2017-06-031-0/+2
| | | | llvm-svn: 304651
* [OpenCL] An error shall occur if any scalar operand has greater rank than ↵Egor Churaev2017-05-301-8/+20
| | | | | | | | | | | | | | | | | | | | the type of the vector element Summary: This is the fix for patch https://reviews.llvm.org/D33353 @uweigand, could you please verify that everything will be good on SystemZ? I added triple spir-unknown-unknown. Thank you in advance! Reviewers: uweigand Reviewed By: uweigand Subscribers: yaxunl, cfe-commits, bader, Anastasia, uweigand Differential Revision: https://reviews.llvm.org/D33648 llvm-svn: 304191
* Revert "[OpenCL] An error shall occur if any scalar operand has greater rank ↵Renato Golin2017-05-261-20/+8
| | | | | | | | | | | | | than the type of the vector element" This reverts commit r303986 as it broke all ARM and AArch64 buildbots... http://lab.llvm.org:8011/builders/clang-cmake-aarch64-39vma/builds/7007 http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/6705 http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/7509 etc. llvm-svn: 303996
* [OpenCL] An error shall occur if any scalar operand has greater rank than ↵Egor Churaev2017-05-261-8/+20
| | | | | | | | | | | | | | the type of the vector element Reviewers: Anastasia Reviewed By: Anastasia Subscribers: cfe-commits, bader, yaxunl Differential Revision: https://reviews.llvm.org/D33353 llvm-svn: 303986
* Revert "Sema: allow imaginary constants via GNU extension if UDL overloads ↵Tim Northover2017-05-241-17/+8
| | | | | | | | | not present." This reverts commit r303697. It broke libc++ tests that were specifically checking incompatibility in C++14 mode. llvm-svn: 303813
* Address follow-up feedback for r303712Argyrios Kyrtzidis2017-05-241-4/+3
| | | | llvm-svn: 303789
* Warn about uses of `@available` that can't suppress theAlex Lorenz2017-05-241-0/+7
| | | | | | | | | | -Wunguarded-availability warnings rdar://32306520 Differential Revision: https://reviews.llvm.org/D33450 llvm-svn: 303761
* Enhance the 'diagnose_if' attribute so that we can apply it for ObjC methods ↵Argyrios Kyrtzidis2017-05-241-1/+12
| | | | | | | | and properties as well This is an initial commit to allow using it with constant expressions, a follow-up commit will enable full support for it in ObjC methods. llvm-svn: 303712
* Sema: allow imaginary constants via GNU extension if UDL overloads not present.Tim Northover2017-05-231-8/+17
| | | | | | | | | | | | | C++14 added user-defined literal support for complex numbers so that you can write something like "complex<double> val = 2i". However, there is an existing GNU extension supporting this syntax and interpreting the result as a _Complex type. This changes parsing so that such literals are interpreted in terms of C++14's operators if an overload is present but otherwise falls back to the original GNU extension. llvm-svn: 303694
* [Sema] Use CK_NoOp instead CK_Invalid in tryGCCVectorConvertAndSplatVitaly Buka2017-05-151-2/+2
| | | | | | | | | | | | This fix UBSAN bots after r302935. Storing non-defined values in enum is undefined behavior. Other places, where "if (ScalarCast != CK_Invalid)" is used, never get to the "if" with CK_Invalid. tryGCCVectorConvertAndSplat can get to the "if" with CK_Invalid and it looks like expected case. So we have to use something other than CK_Invalid, e.g. CK_NoOp. llvm-svn: 303121
* [Sema] Support implicit scalar to vector conversionsSimon Dardis2017-05-121-11/+228
| | | | | | | | | | | | | | | | | | This patch teaches clang to perform implicit scalar to vector conversions when one of the operands of a binary vector expression is a scalar which can be converted to the element type of the vector without truncation following GCC's implementation. If the (constant) scalar is can be casted safely, it is implicitly casted to the vector elements type and splatted to produce a vector of the same type. Contributions from: Petar Jovanovic Reviewers: bruno, vkalintiris Differential Revision: https://reviews.llvm.org/D25866 llvm-svn: 302935
OpenPOWER on IntegriCloud