summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
Commit message (Collapse)AuthorAgeFilesLines
...
* [Sema] Fix diagnostic for addr spaces in reference bindingAnastasia Stulova2019-06-211-8/+18
| | | | | | | | Extend reference binding behavior to account for address spaces. Differential Revision: https://reviews.llvm.org/D62914 llvm-svn: 364032
* [Sema] Improved diagnostic for qualifiers in reference bindingAnastasia Stulova2019-06-211-1/+2
| | | | | | | | | Improved wording and also simplified by using printing method from qualifiers. Differential Revision: https://reviews.llvm.org/D62914 llvm-svn: 364023
* [clang] Small improvments after Adding APValue to ConstantExprGauthier Harnisch2019-06-212-7/+8
| | | | | | | | | | | | | | | | | | | | | | | Summary: this patch has multiple small improvements related to the APValue in ConstantExpr. changes: - APValue in ConstantExpr are now cleaned up using ASTContext::addDestruction instead of there own system. - ConstantExprBits Stores the ValueKind of the result beaing stored. - VerifyIntegerConstantExpression now stores the evaluated value in ConstantExpr. - the Constant Evaluator uses the stored value of ConstantExpr when available. Reviewers: rsmith Reviewed By: rsmith Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63376 llvm-svn: 364011
* P0840R2: support for [[no_unique_address]] attributeRichard Smith2019-06-201-0/+3
| | | | | | | | | | | | | | | | | Summary: Add support for the C++2a [[no_unique_address]] attribute for targets using the Itanium C++ ABI. This depends on D63371. Reviewers: rjmccall, aaron.ballman Subscribers: dschuff, aheejin, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63451 llvm-svn: 363976
* Fix crash and rejects-valid when a later template parameter or defaultRichard Smith2019-06-202-11/+38
| | | | | | | | | | | | | | | | | | | | template argument contains a backreference to a dependently-typed earlier parameter. In a case like: template<typename T, T A, decltype(A) = A> struct X {}; template<typename U> auto Y = X<U, 0>(); we previously treated both references to `A` in the third parameter as being of type `int` when checking the template-id in `Y`. That`s wrong; the type of `A` in these contexts is the dependent type `U`. When we encounter a non-type template argument that we can't convert to the parameter type because of type-dependence, we now insert a dependent conversion node so that the SubstNonTypeTemplateParmExpr for the template argument will have the parameter's type rather than whatever type the argument had. llvm-svn: 363972
* [Sema] Diagnose addr space mismatch while constructing objectsAnastasia Stulova2019-06-203-3/+34
| | | | | | | | | | | | | | If we construct an object in some arbitrary non-default addr space it should fail unless either: - There is an implicit conversion from the address space to default /generic address space. - There is a matching ctor qualified with an address space that is either exactly matching or convertible to the address space of an object. Differential Revision: https://reviews.llvm.org/D62156 llvm-svn: 363944
* Allow copy/move assignment operator to be coroutine as per N4775Vivek Pandya2019-06-191-12/+2
| | | | | | | | | | | | This change fixes https://bugs.llvm.org/show_bug.cgi?id=40997. Reviewers: GorNishanov, rsmith Reviewed by: GorNishanov Subscribers: cfe-commits, lewissbaker, modocache, llvm-commits Differential Revision: https://reviews.llvm.org/D63381 llvm-svn: 363804
* Suggestions to fix -Wmissing-{prototypes,variable-declarations}Aaron Puchert2019-06-181-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: I've found that most often the proper way to fix this warning is to add `static`, because if the code otherwise compiles and links, the function or variable is apparently not needed outside of the TU. We can't provide a fix-it hint for variable declarations, because multiple VarDecls can share the same type, and if we put static in front of that, we affect all declared variables, some of which might have previous declarations. We also provide no fix-it hint for the rare case of an `extern` function definition, because that would require removing `extern` and I have no idea how to get the source location of the storage class specifier from a FunctionDecl. I believe this information is only available earlier in the AST construction from DeclSpec::getStorageClassSpecLoc(), but we don't have that here. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D59402 llvm-svn: 363749
* Show note for -Wmissing-prototypes for functions with parametersAaron Puchert2019-06-181-16/+15
| | | | | | | | | | | | | | Summary: There was a search for non-prototype declarations for the function, but we only showed the results for zero-parameter functions. Now we show the note for functions with parameters as well, but we omit the fix-it hint suggesting to add `void`. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D62750 llvm-svn: 363748
* [OPENMP]Use host's long double when compiling the code for device.Alexey Bataev2019-06-181-1/+3
| | | | | | | | | The device code must use the same long double type as the host. Otherwise the code cannot be linked and executed properly. Patch adds only basic support and checks for supporting of the host long double double on the device. llvm-svn: 363717
* Recommit [OpenCL] Move OpenCLBuiltins.td and remove unused includeSven van Haastregt2019-06-173-1/+305
| | | | | | | | | | Reland r363242 after fixing an issue with the tablegen dependence. Patch by Pierre Gondois and Sven van Haastregt. Differential revision: https://reviews.llvm.org/D62849 llvm-svn: 363541
* [clang] Add storage for APValue in ConstantExprGauthier Harnisch2019-06-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: When using ConstantExpr we often need the result of the expression to be kept in the AST. Currently this is done on a by the node that needs the result and has been done multiple times for enumerator, for constexpr variables... . This patch adds to ConstantExpr the ability to store the result of evaluating the expression. no functional changes expected. Changes: - Add trailling object to ConstantExpr that can hold an APValue or an uint64_t. the uint64_t is here because most ConstantExpr yield integral values so there is an optimized layout for integral values. - Add basic* serialization support for the trailing result. - Move conversion functions from an enum to a fltSemantics from clang::FloatingLiteral to llvm::APFloatBase. this change is to make it usable for serializing APValues. - Add basic* Import support for the trailing result. - ConstantExpr created in CheckConvertedConstantExpression now stores the result in the ConstantExpr Node. - Adapt AST dump to print the result when present. basic* : None, Indeterminate, Int, Float, FixedPoint, ComplexInt, ComplexFloat, the result is not yet used anywhere but for -ast-dump. Reviewers: rsmith, martong, shafik Reviewed By: rsmith Subscribers: rnkovacs, hiraditya, dexonsmith, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D62399 llvm-svn: 363493
* [clang] perform semantic checking in constant contextGauthier Harnisch2019-06-152-68/+111
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Since the addition of __builtin_is_constant_evaluated the result of an expression can change based on whether it is evaluated in constant context. a lot of semantic checking performs evaluations with out specifying context. which can lead to wrong diagnostics. for example: ``` constexpr int i0 = (long long)__builtin_is_constant_evaluated() * (1ll << 33); //#1 constexpr int i1 = (long long)!__builtin_is_constant_evaluated() * (1ll << 33); //#2 ``` before the patch, #2 was diagnosed incorrectly and #1 wasn't diagnosed. after the patch #1 is diagnosed as it should and #2 isn't. Changes: - add a flag to Sema to passe in constant context mode. - in SemaChecking.cpp calls to Expr::Evaluate* are now done in constant context when they should. - in SemaChecking.cpp diagnostics for UB are not checked for in constant context because an error will be emitted by the constant evaluator. - in SemaChecking.cpp diagnostics for construct that cannot appear in constant context are not checked for in constant context. - in SemaChecking.cpp diagnostics on constant expression are always emitted because constant expression are always evaluated. - semantic checking for initialization of constexpr variables is now done in constant context. - adapt test that were depending on warning changes. - add test. Reviewers: rsmith Reviewed By: rsmith Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62009 llvm-svn: 363488
* [X86] Add checks that immediate for reducesd/ss fits in 8-bits.Craig Topper2019-06-141-0/+2
| | | | llvm-svn: 363472
* Use unsigned for bitfields to avoid sign extensionReid Kleckner2019-06-141-3/+3
| | | | llvm-svn: 363450
* PR42071: Reject weird names for non-type template parameters.Richard Smith2019-06-142-24/+44
| | | | | | Also reject default arguments appearing in invalid locations. llvm-svn: 363447
* Use getOperatorSpelling to get the spelling of an overloaded operatorRichard Smith2019-06-141-2/+3
| | | | | | rather than duplicating operator name tables in multiple places. llvm-svn: 363446
* [OpenMP] Avoid emitting maps for target link variables when unified memory ↵Gheorghe-Teodor Bercea2019-06-141-1/+2
| | | | | | | | | | | | | | | | | | is used Summary: This patch avoids the emission of maps for target link variables when unified memory is present. Reviewers: ABataev, caomhin Reviewed By: ABataev Subscribers: guansong, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60883 llvm-svn: 363435
* Remove unused SK_LValueToRValue initialization step.Richard Smith2019-06-141-27/+0
| | | | | | | | | In addition to being unused and duplicating code, this was also wrong (it didn't properly mark the operand as being potentially not odr-used). This reinstates r363340, reverted in r363352. llvm-svn: 363430
* PR23833, DR2140: an lvalue-to-rvalue conversion on a glvalue of typeRichard Smith2019-06-142-5/+11
| | | | | | | | | | | nullptr_t does not access memory. We now reuse CK_NullToPointer to represent a conversion from a glvalue of type nullptr_t to a prvalue of nullptr_t where necessary. This reinstates r363337, reverted in r363352. llvm-svn: 363429
* C++ DR712 and others: handle non-odr-use resulting from an lvalue-to-rvalue ↵Richard Smith2019-06-141-26/+127
| | | | | | | | | | | | | | | | | | | | | | | | | | | conversion applied to a member access or similar not-quite-trivial lvalue expression. Summary: When a variable is named in a context where we can't directly emit a reference to it (because we don't know for sure that it's going to be defined, or it's from an enclosing function and not captured, or the reference might not "work" for some reason), we emit a copy of the variable as a global and use that for the known-to-be-read-only access. This reinstates r363295, reverted in r363352, with a fix for PR42276: we now produce a proper name for a non-odr-use reference to a static constexpr data member. The name <mangled-name>.const is used in that case; such names are reserved to the implementation for cases such as this and should demangle nicely. Reviewers: rjmccall Subscribers: jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63157 llvm-svn: 363428
* Revert "[OpenCL] Move OpenCLBuiltins.td and remove unused include"Sven van Haastregt2019-06-143-304/+1
| | | | | | | | | This reverts commit r363242 as it broke some builds with make[2]: *** No rule to make target 'ClangOpenCLBuiltinsImpl', needed by 'tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaLookup.cpp.o'. llvm-svn: 363376
* [C++20] add Basic consteval specifierGauthier Harnisch2019-06-1412-103/+133
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: this revision adds Lexing, Parsing and Basic Semantic for the consteval specifier as specified by http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1073r3.html with this patch, the consteval specifier is treated as constexpr but can only be applied to function declaration. Changes: - add the consteval keyword. - add parsing of consteval specifier for normal declarations and lambdas expressions. - add the whether a declaration is constexpr is now represented by and enum everywhere except for variable because they can't be consteval. - adapt diagnostic about constexpr to print constexpr or consteval depending on the case. - add tests for basic semantic. Reviewers: rsmith, martong, shafik Reviewed By: rsmith Subscribers: eraman, efriedma, rnkovacs, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61790 llvm-svn: 363362
* [clang] Fixing incorrect implicit deduction guides (PR41549)Gauthier Harnisch2019-06-141-0/+6
| | | | | | | | | | | | | | | | | | | | | Summary: [[ https://bugs.llvm.org/show_bug.cgi?id=41549 | bug report ]] Before this patch, implicit deduction guides were generated from the first declaration found by lookup. With this patch implicit deduction guides are generated from the definition of the class template. Also added test that was previously failing. Reviewers: rsmith Reviewed By: rsmith Subscribers: cfe-commits, Quuxplusone Tags: #clang Differential Revision: https://reviews.llvm.org/D63072 llvm-svn: 363361
* [clang] Don't segfault on incorrect using directive (PR41400)Gauthier Harnisch2019-06-141-1/+1
| | | | | | | | | | | | | | | | | | | Summary: this is a bugfixe for [[ https://bugs.llvm.org/show_bug.cgi?id=41400 | PR41400 ]] added nullptr check at the relevent place and test Reviewers: rsmith, riccibruno Reviewed By: rsmith Subscribers: jkooker, jkorous, riccibruno, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60523 llvm-svn: 363360
* Revert 363295, it caused PR42276. Also revert follow-ups 363337, 363340.Nico Weber2019-06-142-131/+51
| | | | | | | | Revert 363340 "Remove unused SK_LValueToRValue initialization step." Revert 363337 "PR23833, DR2140: an lvalue-to-rvalue conversion on a glvalue of type" Revert 363295 "C++ DR712 and others: handle non-odr-use resulting from an lvalue-to-rvalue conversion applied to a member access or similar not-quite-trivial lvalue expression." llvm-svn: 363352
* Remove unused SK_LValueToRValue initialization step.Richard Smith2019-06-131-27/+0
| | | | | | | In addition to being unused and duplicating code, this was also wrong (it didn't properly mark the operand as being potentially not odr-used). llvm-svn: 363340
* PR23833, DR2140: an lvalue-to-rvalue conversion on a glvalue of typeRichard Smith2019-06-132-5/+11
| | | | | | | | | | | | nullptr_t does not access memory. We now reuse CK_NullToPointer to represent a conversion from a glvalue of type nullptr_t to a prvalue of nullptr_t where necessary. This reinstates r345562, reverted in r346065, now that CodeGen's handling of non-odr-used variables has been fixed. llvm-svn: 363337
* C++ DR712 and others: handle non-odr-use resulting from an lvalue-to-rvalue ↵Richard Smith2019-06-131-26/+127
| | | | | | | | | | | | | | | | | | | | | conversion applied to a member access or similar not-quite-trivial lvalue expression. Summary: When a variable is named in a context where we can't directly emit a reference to it (because we don't know for sure that it's going to be defined, or it's from an enclosing function and not captured, or the reference might not "work" for some reason), we emit a copy of the variable as a global and use that for the known-to-be-read-only access. Reviewers: rjmccall Subscribers: jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63157 llvm-svn: 363295
* [OpenCL] Move OpenCLBuiltins.td and remove unused includeSven van Haastregt2019-06-133-1/+304
| | | | | | | | Patch by Pierre Gondois. Differential revision: https://reviews.llvm.org/D62849 llvm-svn: 363242
* PR42220: take into account the possibility of aggregates with baseRichard Smith2019-06-121-0/+3
| | | | | | classes when checking an InitListExpr for lifetime extension. llvm-svn: 363188
* Mark declarations as referenced by a default argument in aRichard Smith2019-06-111-0/+2
| | | | | | | | | potentially-evaluated context. This applies even if the use of the default argument is within an unevaluated context. llvm-svn: 363113
* For DR712: store on a MemberExpr whether it constitutes an odr-use.Richard Smith2019-06-112-29/+51
| | | | llvm-svn: 363087
* For DR712: store on a DeclRefExpr whether it constitutes an odr-use.Richard Smith2019-06-116-85/+305
| | | | | | | Begin restructuring to support the forms of non-odr-use reference permitted by DR712. llvm-svn: 363086
* Require stdcall etc parameters to be complete on ODR useReid Kleckner2019-06-101-0/+81
| | | | | | | | | | | | | | | | | | | Functions using stdcall, fastcall, or vectorcall with C linkage mangle in the size of the parameter pack. Calculating the size of the pack requires the parameter types to complete, which may require template instantiation. Previously, we would crash during IRgen when requesting the size of incomplete or uninstantiated types, as in this reduced example: struct Foo; void __fastcall bar(struct Foo o); void (__fastcall *fp)(struct Foo) = &bar; Reported in Chromium here: https://crbug.com/971245 Differential Revision: https://reviews.llvm.org/D62975 llvm-svn: 363000
* Re-land "[CodeComplete] Improve overload handling for C++ qualified and ↵Sam McCall2019-06-101-20/+121
| | | | | | | | ref-qualified methods." ShadowMapEntry is now really, truly a normal class. llvm-svn: 362950
* Revert "[CodeComplete] Improve overload handling for C++ qualified and ↵Sam McCall2019-06-101-112/+20
| | | | | | | | ref-qualified methods." This reverts commit r362924, which causes a double-free of ShadowMapEntry. llvm-svn: 362944
* Revert "Revert "[CodeComplete] Improve overload handling for C++ qualified ↵Sam McCall2019-06-101-20/+112
| | | | | | | | and ref-qualified methods."" This reverts commit r362830, and relands r362785 with the leak fixed. llvm-svn: 362924
* Revert "[CodeComplete] Improve overload handling for C++ qualified and ↵Vlad Tsyrklevich2019-06-071-111/+14
| | | | | | | | | | ref-qualified methods." This reverts commit f1f6e0fc2468e9c120b22b939507c527d08b8ee8, it was causing LSan failures on the sanitizer bots: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/32809 llvm-svn: 362830
* [CodeComplete] Improve overload handling for C++ qualified and ref-qualified ↵Sam McCall2019-06-071-14/+111
| | | | | | | | | | | | | | | | | | | | | methods. Summary: - when a method is not available because of the target value kind (e.g. an && method on a Foo& variable), then don't offer it. - when a method is effectively shadowed by another method from the same class with a) an identical argument list and b) superior qualifiers, then don't offer it. Reviewers: ilya-biryukov Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62582 llvm-svn: 362785
* Factor out duplicated code building a MemberExpr and marking itRichard Smith2019-06-063-44/+53
| | | | | | | | referenced. This reinstates r362563, reverted in r362597. llvm-svn: 362757
* Convert MemberExpr creation and serialization to work the same way asRichard Smith2019-06-061-3/+6
| | | | | | | | | | most / all other Expr subclasses. This reinstates r362551, reverted in r362597, with a fix to a bug that caused MemberExprs to sometimes have a null FoundDecl after a round-trip through an AST file. llvm-svn: 362756
* [OpenCL][PR42031] Prevent deducing addr space in type alias.Anastasia Stulova2019-06-051-0/+3
| | | | | | | | | Similar to typedefs we shouldn't deduce addr space in type alias. Differential Revision: https://reviews.llvm.org/D62591 llvm-svn: 362611
* Avoid using NoThrow Exception Specifier in non-C++ Modes.Erich Keane2019-06-051-13/+12
| | | | | | | | | | | | | | | | | As reported in https://bugs.llvm.org/show_bug.cgi?id=42113, there are a number of locations in Clang where it is assumed that exception specifications are only valid in C++ mode. Since the original justification for the NoThrow Exception Specifier Type was C++ related, this patch just makes C mode use the attribute-based nothrow handling. Additionally, I noticed that the handling of non-prototype functions regressed the behavior of the nothrow attribute, in part because it is was listed in the function type macro(which I did in the previous patch). In reality, it should only be doing so in a conditional nature, so this patch removes it there and puts it directly in the switch to be handled correctly. llvm-svn: 362607
* [Sema] Prevent binding incompatible addr space ref to temporariesAnastasia Stulova2019-06-051-1/+18
| | | | | | | | | | | | References to arbitrary address spaces can't always be bound to temporaries. This change extends the reference binding logic to check that the address space of a temporary can be implicitly converted to the address space in a reference when temporary materialization is performed. Differential Revision: https://reviews.llvm.org/D61318 llvm-svn: 362604
* Revert "Factor out duplicated code building a MemberExpr and marking it" and ↵Benjamin Kramer2019-06-053-53/+41
| | | | | | | | "Convert MemberExpr creation and serialization to work the same way as" This reverts commits r362551 and r362563. Crashes during modules selfhost. llvm-svn: 362597
* Factor out duplicated code building a MemberExpr and marking itRichard Smith2019-06-053-44/+53
| | | | | | referenced. llvm-svn: 362563
* Convert MemberExpr creation and serialization to work the same way asRichard Smith2019-06-041-3/+6
| | | | | | most / all other Expr subclasses. llvm-svn: 362551
* Factor out repeated code to build a DeclRefExpr and mark it referenced.Richard Smith2019-06-044-54/+35
| | | | llvm-svn: 362537
* PR42104: Support instantiations of lambdas that implicitly captureRichard Smith2019-06-045-56/+108
| | | | | | | | | | | | | | | | | packs. Two changes: * Track odr-use via FunctionParmPackExprs to properly handle dependent odr-uses of packs in generic lambdas. * Do not instantiate implicit captures; instead, regenerate them by instantiating the body of the lambda. This is necessary to distinguish between cases where only one element of a pack is captured and cases where the entire pack is captured. This reinstates r362358 (reverted in r362375) with a fix for an uninitialized variable use in UpdateMarkingForLValueToRValue. llvm-svn: 362531
OpenPOWER on IntegriCloud