summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ExprCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [Concepts] Requires ExpressionsSaar Raz2020-01-241-78/+1
| | | | | | | | | | Implement support for C++2a requires-expressions. Re-commit after compilation failure on some platforms due to alignment issues with PointerIntPair. Differential Revision: https://reviews.llvm.org/D50360 (cherry picked from commit a0f50d731639350c7a79f140f026c27a18215531)
* [Concepts] Type ConstraintsSaar Raz2020-01-151-16/+14
| | | | | | | Add support for type-constraints in template type parameters. Also add support for template type parameters as pack expansions (where the type constraint can now contain an unexpanded parameter pack). Differential Revision: https://reviews.llvm.org/D44352
* Fix crash if a user-defined conversion is applied in the middle of aRichard Smith2019-12-051-1/+1
| | | | rewrite of an operator in terms of operator<=>.
* [Concepts] Constraint Enforcement & DiagnosticsSaar Raz2019-12-061-8/+9
| | | | | | | | | Part of the C++20 concepts implementation effort. - Associated constraints (requires clauses, currently) are now enforced when instantiating/specializing templates and when considering partial specializations and function overloads. - Elaborated diagnostics give helpful insight as to why the constraints were not satisfied. Phabricator: D41569 Re-commit, after fixing some memory bugs.
* [NFC] Refactor representation of materialized temporariesTyker2019-11-191-7/+21
| | | | | | | | | | | | | | | Summary: this patch refactor representation of materialized temporaries to prevent an issue raised by rsmith in https://reviews.llvm.org/D63640#inline-612718 Reviewers: rsmith, martong, shafik Reviewed By: rsmith Subscribers: thakis, sammccall, ilya-biryukov, rnkovacs, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69360
* Revert "[NFC] Refactor representation of materialized temporaries"Nico Weber2019-11-171-21/+7
| | | | | | This reverts commit 08ea1ee2db5f9d6460fef1d79d0d1d1a5eb78982. It broke ./ClangdTests/FindExplicitReferencesTest.All on the bots, see comments on https://reviews.llvm.org/D69360
* [NFC] Refactor representation of materialized temporariesTyker2019-11-161-7/+21
| | | | | | | | | | | | | | | Summary: this patch refactor representation of materialized temporaries to prevent an issue raised by rsmith in https://reviews.llvm.org/D63640#inline-612718 Reviewers: rsmith, martong, shafik Reviewed By: rsmith Subscribers: rnkovacs, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69360
* Revert "[Concepts] Constraint Enforcement & Diagnostics"Vlad Tsyrklevich2019-10-281-9/+8
| | | | | This reverts commit ffa214ef22892d75340dc6720271863901dc2c90, it was causing ASAN test failures on sanitizer-x86_64-linux-bootstrap.
* [Concepts] Constraint Enforcement & DiagnosticsSaar Raz2019-10-251-8/+9
| | | | | | Part of the C++20 concepts implementation effort. - Associated constraints (requires clauses, currently) are now enforced when instantiating/specializing templates and when considering partial specializations and function overloads. - Elaborated diagnostics give helpful insight as to why the constraints were not satisfied. Phabricator: D41569
* [c++20] Add rewriting from comparison operators to <=> / ==.Richard Smith2019-10-191-2/+2
| | | | | | | | | | | | | | | | | This adds support for rewriting <, >, <=, and >= to a normal or reversed call to operator<=>, for rewriting != to a normal or reversed call to operator==, and for rewriting <=> and == to reversed forms of those same operators. Note that this is a breaking change for various C++17 code patterns, including some in use in LLVM. The most common patterns (where an operator== becomes ambiguous with a reversed form of itself) are still accepted under this patch, as an extension (with a warning). I'm hopeful that we can get the language rules fixed before C++20 ships, and the extension warning is aimed primarily at providing data to inform that decision. llvm-svn: 375306
* [c++20] Add CXXRewrittenBinaryOperator to represent a comparisonRichard Smith2019-10-191-0/+70
| | | | | | | | operator that is rewritten as a call to multiple other operators. No functionality change yet: nothing creates these expressions. llvm-svn: 375305
* [Concepts] Remove unused and illegal Sema includes from ExprCXX.cppSaar Raz2019-10-151-4/+1
| | | | | | Fixing accidental includes introduced in 374903 llvm-svn: 374907
* [Concepts] Concept Specialization ExpressionsSaar Raz2019-10-151-0/+82
| | | | | | | | | | Part of C++20 Concepts implementation effort. Added Concept Specialization Expressions that are created when a concept is refe$ D41217 on Phabricator. (recommit after fixing failing Parser test on windows) llvm-svn: 374903
* Revert 374882 "[Concepts] Concept Specialization Expressions"Nico Weber2019-10-151-79/+0
| | | | | | | | | | This reverts commit ec87b003823d63f3342cf648f55a134c1522e612. The test fails on Windows, see e.g. http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/11533/steps/stage%201%20check/logs/stdio Also revert follow-up r374893. llvm-svn: 374899
* [AST] Remove unused Sema includes to fix a cyclic dependency from Sema to ASTBenjamin Kramer2019-10-151-4/+1
| | | | llvm-svn: 374893
* [Concepts] Concept Specialization ExpressionsSaar Raz2019-10-151-0/+82
| | | | | | Part of C++20 Concepts implementation effort. Added Concept Specialization Expressions that are created when a concept is referenced with arguments, and tests thereof. llvm-svn: 374882
* AST - silence static analyzer getAs<> null dereference warnings. NFCI.Simon Pilgrim2019-10-071-6/+3
| | | | | | The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us. llvm-svn: 373904
* Teach CallGraph to look into Generic Lambdas.Erich Keane2019-09-301-0/+5
| | | | | | | | | | | | | | | | | | | | CallGraph visited LambdaExpr by getting the Call Operator from CXXRecordDecl (LambdaExpr::getCallOperator calls CXXRecordDecl::getLambdaCallOperator), which replaced generic lambda call operators with the non-instantiated FunctionDecl. The result was that the CallGraph would only pick up non-dependent calls. This patch does a few things: 1- Extend CXXRecordDecl to have a getDependentLambdaCallOperator, which will get the FunctionTemplateDecl, rather than immediately getting the TemplateDecl. 2- Define getLambdaCallOperator and getDependentLambdaCallOperator in terms of a common function. 3- Extend LambdaExpr with a getDependentCallOperator, which just calls the above function. 4- Changes CallGraph to handle Generic LambdaExprs. llvm-svn: 373247
* For P0784R7: Add support for dynamic allocation with new / delete duringRichard Smith2019-09-271-0/+6
| | | | | | constant evaluation. llvm-svn: 373036
* [OpenCL] Improve destructor support in C++ for OpenCLMarco Antognini2019-07-221-0/+7
| | | | | | | This re-applies r366422 with a fix for Bug PR42665 and a new regression test. llvm-svn: 366670
* [c++20] P0780R2: Support pack-expansion of init-captures.Richard Smith2019-05-211-7/+7
| | | | | | | | | | | This permits an init-capture to introduce a new pack: template<typename ...T> auto x = [...a = T()] { /* a is a pack */ }; To support this, the mechanism for allowing ParmVarDecls to be packs has been extended to support arbitrary local VarDecls. llvm-svn: 361300
* Implement __builtin_LINE() et. al. to support source location capture.Eric Fiselier2019-05-161-2/+3
| | | | | | | | | | | | | | | | | Summary: This patch implements the source location builtins `__builtin_LINE(), `__builtin_FUNCTION()`, `__builtin_FILE()` and `__builtin_COLUMN()`. These builtins are needed to implement [`std::experimental::source_location`](https://rawgit.com/cplusplus/fundamentals-ts/v2/main.html#reflection.src_loc.creation). With the exception of `__builtin_COLUMN`, GCC also implements these builtins, and Clangs behavior is intended to match as closely as possible. Reviewers: rsmith, joerg, aaron.ballman, bogner, majnemer, shafik, martong Reviewed By: rsmith Subscribers: rnkovacs, loskutov, riccibruno, mgorny, kunitoki, alexr, majnemer, hfinkel, cfe-commits Differential Revision: https://reviews.llvm.org/D37035 llvm-svn: 360937
* [c++20] Implement P1009R2: allow omitting the array bound in an arrayRichard Smith2019-05-061-12/+15
| | | | | | | | | | new expression. This was voted into C++20 as a defect report resolution, so we retroactively apply it to all prior language modes (though it can never actually be used before C++11 mode). llvm-svn: 360006
* [c++20] Implement P0428R2 - Familiar template syntax for generic lambdasHamza Sood2019-05-041-0/+4
| | | | | | Differential Revision: https://reviews.llvm.org/D36527 llvm-svn: 359967
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* [AST] Move back BasePathSize to the bit-fields of CastExprBruno Ricci2019-01-091-24/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | The number of trailing CXXBaseSpecifiers in CastExpr was moved from CastExprBitfields to a trailing object in r338489 (D50050). At this time these bit-fields classes were only 32 bits wide. However later r345459 widened these bit-field classes to 64 bits. The reason for this change was that on 64 bit archs alignment requirements caused 4 bytes of padding after the Stmt sub-object in nearly all expression classes. Reusing this padding yielded an >10% reduction in the size used by all statement/expressions when parsing all of Boost (on a 64 bit arch). This increased the size of statement/expressions for 32 bits archs, but this can be mitigated by moving more data to the bit-fields of Stmt (and moreover most people now care about 64 bits archs as a host). Therefore move back the number of CXXBaseSpecifiers in CastExpr to the bit-fields of Stmt. This in effect mostly revert r338489 while keeping the added test. Differential Revision: https://reviews.llvm.org/D56358 Reviewed By: lebedev.ri Reviewers: lebedev.ri, rjmccall llvm-svn: 350741
* [AST] Store the results in OverloadExpr in a trailing arrayBruno Ricci2019-01-091-109/+125
| | | | | | | | | | | | | | | Use the newly available space in the bit-fields of Stmt to pack OverloadExpr, UnresolvedLookupExpr and UnresolvedMemberExpr. Additionally store the results in the overload set in a trailing array. This saves 1 pointer + 8 bytes per UnresolvedLookupExpr and UnresolvedMemberExpr. Differential Revision: https://reviews.llvm.org/D56368 Reviewed By: rjmccall llvm-svn: 350732
* [AST][NFC] Pack CXXScalarValueInitExprBruno Ricci2019-01-081-1/+1
| | | | | | | Use the newly available space in the bit-fields of Stmt. This saves one pointer per CXXScalarValueInitExpr. NFC. llvm-svn: 350635
* [AST] Pack CXXDependentScopeMemberExprBruno Ricci2019-01-081-51/+51
| | | | | | | | | | | | | | | | | | | | Use the newly available space in the bit-fields of Stmt. Additionally store FirstQualifierFoundInScope as a trailing object since it is most of the time null (non-null for 2 of the 35446 CXXDependentScopeMemberExpr when parsing all of Boost). It would be possible to move the data for the nested-name-specifier to a trailing object too to save another 2 pointers, however doing so did actually regress the time taken to parse all of Boost slightly. This saves 8 bytes + 1 pointer per CXXDependentScopeMemberExpr in the vast majority of cases. Differential Revision: https://reviews.llvm.org/D56367 Reviewed By: rjmccall llvm-svn: 350625
* [AST] Store some data of CXXNewExpr as trailing objectsBruno Ricci2019-01-071-50/+94
| | | | | | | | | | | | | | | | | Store the optional array size expression, optional initialization expression and optional placement new arguments in a trailing array. Additionally store the range for the parenthesized type-id in a trailing object if needed since in the vast majority of cases the type is not parenthesized (not a single new expression in the translation unit of SemaDecl.cpp has a parenthesized type-id). This saves 2 pointers per CXXNewExpr in all cases, and 2 pointers + 8 bytes per CXXNewExpr in the common case where the type is not parenthesized. Differential Revision: https://reviews.llvm.org/D56134 Reviewed By: rjmccall llvm-svn: 350527
* [AST][NFC] Pack DependentScopeDeclRefExpr and CXXUnresolvedConstructExprBruno Ricci2019-01-071-58/+52
| | | | | | | | | | | Use the newly available space in the bit-fields of Stmt. This saves 1 pointer per DependentScopeDeclRefExpr/CXXUnresolvedConstructExpr. Additionally rename "TypeSourceInfo *Type;" to "TypeSourceInfo *TSI;" as was done in D56022 (r350003) (but this is an internal detail anyway), and clang-format both classes. NFC. llvm-svn: 350525
* [AST] Store the arguments of CXXConstructExpr in a trailing arrayBruno Ricci2018-12-221-73/+99
| | | | | | | | | | | | | | | Store the arguments of CXXConstructExpr in a trailing array. This is very similar to the CallExpr case in D55771, with the exception that there is only one derived class (CXXTemporaryObjectExpr) and that we compute the offset to the trailing array instead of storing it. This saves one pointer per CXXConstructExpr and CXXTemporaryObjectExpr. Reviewed By: rjmccall Differential Revision: https://reviews.llvm.org/D56022 llvm-svn: 350003
* [AST][NFC] Fix Wsign-compare warning introduced in CXXOperatorCallExprBruno Ricci2018-12-211-2/+3
| | | | llvm-svn: 349934
* [AST][NFC] Pack CXXOperatorCallExprBruno Ricci2018-12-211-2/+7
| | | | | | | Use the space available in the bit-fields of Stmt. This saves 8 bytes per CXXOperatorCallExpr. NFC. llvm-svn: 349924
* [AST] Store the callee and argument expressions of CallExpr in a trailing array.Bruno Ricci2018-12-211-0/+145
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since CallExpr::setNumArgs has been removed, it is now possible to store the callee expression and the argument expressions of CallExpr in a trailing array. This saves one pointer per CallExpr, CXXOperatorCallExpr, CXXMemberCallExpr, CUDAKernelCallExpr and UserDefinedLiteral. Given that CallExpr is used as a base of the above classes we cannot use llvm::TrailingObjects. Instead we store the offset in bytes from the this pointer to the start of the trailing objects and manually do the casts + arithmetic. Some notes: 1.) I did not try to fit the number of arguments in the bit-fields of Stmt. This leaves some space for future additions and avoid the discussion about whether x bits are sufficient to hold the number of arguments. 2.) It would be perfectly possible to recompute the offset to the trailing objects before accessing the trailing objects. However the trailing objects are frequently accessed and benchmarks show that it is slightly faster to just load the offset from the bit-fields. Additionally, because of 1), we have plenty of space in the bit-fields of Stmt. Differential Revision: https://reviews.llvm.org/D55771 Reviewed By: rjmccall llvm-svn: 349910
* [AST][NFC] Make ArrayTypeTraitExpr non polymorphicBruno Ricci2018-12-041-2/+0
| | | | | | | | | | | ArrayTypeTraitExpr is the only expression class which is polymorphic. As far as I can tell this is completely pointless. Differential Revision: https://reviews.llvm.org/D55221 Reviewed By: aaron.ballman llvm-svn: 348276
* [AST][NFC] Pack CXXDefaultInitExprBruno Ricci2018-11-171-5/+6
| | | | | | | Use the newly available space in the bit-fields of Stmt. This saves one pointer per CXXDefaultInitExpr. llvm-svn: 347138
* Create ConstantExpr classBill Wendling2018-10-311-7/+2
| | | | | | | | | | | | | | | | A ConstantExpr class represents a full expression that's in a context where a constant expression is required. This class reflects the path the evaluator took to reach the expression rather than the syntactic context in which the expression occurs. In the future, the class will be expanded to cache the result of the evaluated expression so that it's not needlessly re-evaluated Reviewed By: rsmith Differential Revision: https://reviews.llvm.org/D53475 llvm-svn: 345692
* Port getLocEnd -> getEndLocStephen Kelly2018-08-091-7/+7
| | | | | | | | | | Reviewers: teemperor! Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50351 llvm-svn: 339386
* Port getLocStart -> getBeginLocStephen Kelly2018-08-091-6/+6
| | | | | | | | | | Reviewers: teemperor! Subscribers: jholewinski, whisperity, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D50350 llvm-svn: 339385
* Add getEndLoc API to replace getLocEndStephen Kelly2018-08-091-4/+4
| | | | | | | | Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50348 llvm-svn: 339374
* Add getBeginLoc API to replace getLocStartStephen Kelly2018-08-091-5/+5
| | | | | | | | Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50346 llvm-svn: 339372
* [AST] CastExpr: BasePathSize is not large enough.Roman Lebedev2018-08-011-8/+24
| | | | | | | | | | | | | | | | | | | | | | | | Summary: rC337815 / D49508 had to cannibalize one bit of `CastExprBitfields::BasePathSize` in order to squeeze `PartOfExplicitCast` boolean. That reduced the maximal value of `PartOfExplicitCast` from 9 bits (~512) down to 8 bits (~256). Apparently, that mattered. Too bad there weren't any tests. It caused [[ https://bugs.llvm.org/show_bug.cgi?id=38356 | PR38356 ]]. So we need to increase `PartOfExplicitCast` back at least to 9 bits, or a bit more. For obvious reasons, we can't do that in `CastExprBitfields` - that would blow up the size of every `Expr`. So we need to either just add a variable into the `CastExpr` (as done here), or use `llvm::TrailingObjects`. The latter does not seem to be straight-forward. Perhaps, that needs to be done not for the `CastExpr` itself, but for all of it's `final` children. Reviewers: rjmccall, rsmith, erichkeane Reviewed By: rjmccall Subscribers: bricci, hans, cfe-commits, waddlesplash Differential Revision: https://reviews.llvm.org/D50050 llvm-svn: 338489
* Remove trailing spaceFangrui Song2018-07-301-31/+31
| | | | | | sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338291
* Track the result of evaluating a computed noexcept specification on theRichard Smith2018-05-031-2/+2
| | | | | | | | | | | | | | FunctionProtoType. We previously re-evaluated the expression each time we wanted to know whether the type is noexcept or not. We now evaluate the expression exactly once. This is not quite "no functional change": it fixes a crasher bug during AST deserialization where we would try to evaluate the noexcept specification in a situation where we have not deserialized sufficient portions of the AST to permit such evaluation. llvm-svn: 331428
* [AST] Fix some Clang-tidy modernize-use-auto and Include What You Use ↵Eugene Zelenko2018-04-101-35/+34
| | | | | | warnings; other minor fixes (NFC). llvm-svn: 329766
* Fix a couple of places where we assumed that non-type template parameters ↵Richard Smith2018-02-141-1/+2
| | | | | | are always rvalues. llvm-svn: 325095
* Silence a bunch of implicit fallthrough warningsAdrian Prantl2017-12-191-2/+2
| | | | llvm-svn: 321115
* [AST] Fix some Clang-tidy modernize and Include What You Use warnings; other ↵Eugene Zelenko2017-11-181-108/+109
| | | | | | minor fixes (NFC). llvm-svn: 318582
* Support for destroying operator delete, per C++2a proposal P0722.Richard Smith2017-10-131-0/+16
| | | | | | | | | | This feature is not (yet) approved by the C++ committee, so this is liable to be reverted or significantly modified based on committee feedback. No functionality change intended for existing code (a new type must be defined in namespace std to take advantage of this feature). llvm-svn: 315662
OpenPOWER on IntegriCloud