summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ExprCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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
* PR33489: A function-style cast to a deduced class template specialization ↵Richard Smith2017-08-111-1/+3
| | | | | | type is type-dependent if it can't be resolved due to a type-dependent argument. llvm-svn: 310691
* [c++1z] P0091R3: Basic support for deducing class template arguments via ↵Richard Smith2017-02-091-5/+5
| | | | | | deduction-guides. llvm-svn: 294613
* Remove custom handling of array copies in lambda by-value array capture andRichard Smith2016-12-141-41/+8
| | | | | | | | | | | copy constructors of classes with array members, instead using ArrayInitLoopExpr to represent the initialization loop. This exposed a bug in the static analyzer where it was unable to differentiate between zero-initialized and unknown array values, which has also been fixed here. llvm-svn: 289618
* Retire llvm::alignOf in favor of C++11 alignof.Benjamin Kramer2016-10-201-16/+15
| | | | | | No functionality change intended. llvm-svn: 284730
* PR26276: Fix detection of non-cast-expressions as operands of fold-expressions.Richard Smith2016-10-201-0/+16
| | | | llvm-svn: 284684
* Re-commit r283722, reverted in r283750, with a fix for a CUDA-specific use ofRichard Smith2016-10-101-2/+3
| | | | | | | | | | | past-the-end iterator. Original commit message: P0035R4: Semantic analysis and code generation for C++17 overaligned allocation. llvm-svn: 283789
* Revert "P0035R4: Semantic analysis and code generation for C++17 overaligned ↵Daniel Jasper2016-10-101-3/+2
| | | | | | | | | | | | allocation." This reverts commit r283722. Breaks: Clang.SemaCUDA.device-var-init.cu Clang.CodeGenCUDA.device-var-init.cu http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-expensive/884/ llvm-svn: 283750
* P0035R4: Semantic analysis and code generation for C++17 overalignedRichard Smith2016-10-101-2/+3
| | | | | | allocation. llvm-svn: 283722
* Re-commit "[Temporary] Add an ExprWithCleanups for each C++ ↵Tim Shen2016-06-211-1/+5
| | | | | | | | | | MaterializeTemporaryExpr." Since D21243 fixes relative clang-tidy tests. This reverts commit a71d9fbd41e99def9159af2b01ef6509394eaeed. llvm-svn: 273312
* Don't use static variables in LambdaCaptureJohn Brawn2016-06-151-12/+6
| | | | | | | | | | | | | | | | | | | | | | | When static variables are used in inline functions in header files anything that uses that function ends up with a reference to the variable. Because RecursiveASTVisitor uses the inline functions in LambdaCapture that use static variables any AST plugin that uses RecursiveASTVisitor, such as the PrintFunctionNames example, ends up with a reference to these variables. This is bad on Windows when building with MSVC with LLVM_EXPORT_SYMBOLS_FOR_PLUGINS=ON as variables used across a DLL boundary need to be explicitly dllimported in the DLL using them. This patch avoids that by adjusting LambdaCapture to be similar to before r263921, with a capture of either 'this' or a VLA represented by a null Decl pointer in DeclAndBits with an extra flag added to the bits to distinguish between the two. This requires the use of an extra bit, and while Decl does happen to be sufficiently aligned to allow this it's done in a way that means PointerIntPair doesn't realise it and gives an assertion failure. Therefore I also adjust Decl slightly to use LLVM_ALIGNAS to allow this. Differential Revision: http://reviews.llvm.org/D20732 llvm-svn: 272788
* Remove CXXConstructExpr::getFoundDecl(); it turned out to not be useful.Richard Smith2016-06-101-13/+3
| | | | llvm-svn: 272357
* Revert "[Temporary] Add an ExprWithCleanups for each C++ ↵Tim Shen2016-06-091-5/+1
| | | | | | | | | MaterializeTemporaryExpr." This reverts r272296, since there are clang-tidy failures that appear to be caused by this change. llvm-svn: 272310
* [Temporary] Add an ExprWithCleanups for each C++ MaterializeTemporaryExpr.Tim Shen2016-06-091-1/+5
| | | | | | | | | | | These ExprWithCleanups are added for holding a RunCleanupsScope not for destructor calls; rather, they are for lifetime marks. This requires ExprWithCleanups to keep a bit to indicate whether it have cleanups with side effects (e.g. dtor calls). Differential Revision: http://reviews.llvm.org/D20498 llvm-svn: 272296
* Preserve the FoundDecl when performing overload resolution for constructors.Richard Smith2016-05-111-16/+28
| | | | | | | | | This is in preparation for C++ P0136R1, which switches the model for inheriting constructors over from synthesizing a constructor to finding base class constructors (via using shadow decls) when looking for derived class constructors. llvm-svn: 269231
* Fix serialization/deserialization for __uuidofDavid Majnemer2016-03-281-4/+0
| | | | | | | | 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-71/+2
| | | | | | | | 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-8/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Only instantiate a default argument once.John McCall2016-01-061-8/+0
| | | | | | | | | | | | | | | | | | | By storing the instantiated expression back in the ParmVarDecl, we remove the last need for separately storing the sub-expression of a CXXDefaultArgExpr. This makes PCH/Modules merging quite simple: CXXDefaultArgExpr records are serialized as references to the ParmVarDecl, and we ignore redundant attempts to overwrite the instantiated expression. This has some extremely marginal impact on user-facing semantics. However, the major effect is that it avoids IRGen errors about conflicting definitions due to lambdas in the argument being instantiated multiple times while sharing the same mangling. It should also slightly improve memory usage and module file size. rdar://23810407 llvm-svn: 256983
* [TrailingObjects] Convert remaining classes in Expr.h and ExprCXX.hJames Y Knight2015-12-311-73/+49
| | | | llvm-svn: 256658
* [TrailingObjects] Convert CastExpr and subclasses.James Y Knight2015-12-301-20/+20
| | | | llvm-svn: 256608
* [TrailingObjects] Convert AST classes that had a ASTTemplateKWAndArgsInfo.James Y Knight2015-12-291-119/+85
| | | | | | | | | | | | | | | | | | | | So, also: - Moved the TemplateArgumentLoc array out of the ASTTemplateKWAndArgsInfo class (making it a simple fixed-size object), to avoid needing to have a variable-length object as part of a variable-length object. Now the objects that have a ASTTemplateKWAndArgsInfo also have some TemplateArgumentLoc objects appended directly. - Removed some internal-use accessors which became simply a wrapper on getTrailingObjects. - Moved MemberNameQualifier out of the MemberExpr class, renamed it MemberExprNameQualifier, because the template can't refer to a class nested within the class it's defining. llvm-svn: 256570
* Fix FunctionParmPackExpr::Create() to take a ParmVarDecl* array.James Y Knight2015-09-301-6/+6
| | | | | | | | | | | | FunctionParmPackExpr actually stores an array of ParmVarDecl* (and accessors return that). But, the FunctionParmPackExpr::Create() constructor accepted an array of Decl *s instead. It was easy for this mismatch to occur without any obvious sign of something wrong, since both the store and the access used independent 'reinterpet_cast<XX>(this+1)' calls. llvm-svn: 248905
* PR14858: Initial support for proper sizeof... handling within alias templates.Richard Smith2015-09-231-0/+19
| | | | | | | This doesn't quite get alias template equivalence right yet, but handles the egregious cases where we would silently give the wrong answers. llvm-svn: 248431
* [AST] ArrayRefize template argument packs. No functionality change intended.Benjamin Kramer2015-08-051-1/+1
| | | | llvm-svn: 244026
* Fix alignment issues in Clang.James Y Knight2015-07-171-6/+10
| | | | | | | | | | | | | | | | | Some const-correctness changes snuck in here too, since they were in the area of code I was modifying. This seems to make Clang actually work without Bus Error on 32bit-sparc. Follow-up patches will factor out a trailing-object helper class, to make classes using the idiom of appending objects to other objects easier to understand, and to ensure (with static_assert) that required alignment guarantees continue to hold. Differential Revision: http://reviews.llvm.org/D10272 llvm-svn: 242554
* Replace the broken LambdaCapture::isInitCapture API.James Dennett2015-05-071-0/+5
| | | | | | | | | | | | | | | A LambdaCapture does not have sufficient information to correctly determine whether it is an init-capture or not. Doing so requires knowledge held in the LambdaExpr itself. It the case of a nested capture of an init-capture it is not sufficient to check (as LambdaCapture::isInitCapture did) whether the associated VarDecl was from an init-capture. This patch moves isInitCapture to LambdaExpr and updates Capture->isInitCapture() to Lambda->isInitCapture(Capture). llvm-svn: 236760
* Sema: Parenthesized bound destructor member expressions can be calledDavid Majnemer2015-02-251-4/+1
| | | | | | | | | We would wrongfully reject (a.~A)() in both the destructor and pseudo-destructor cases. This fixes PR22668. llvm-svn: 230512
* DR1748: the reserved placement allocation functions have undefined behavior ifRichard Smith2015-02-141-2/+3
| | | | | | | they're given a null pointer as an argument, so we do not need to emit null checks on their results. llvm-svn: 229213
* Reimplement iterator wrappers on top of llvm::iterator_adaptor_base.Benjamin Kramer2015-02-011-4/+2
| | | | | | Eliminates a ton of boilerplate proxying the iterator methods. NFC. llvm-svn: 227764
* -ms-extensions: Implement __super scope specifier (PR13236).Nikola Smiljanic2014-09-261-1/+2
| | | | | | | | | We build a NestedNameSpecifier that records the CXXRecordDecl in which __super appeared. Name lookup is performed in all base classes of the recorded CXXRecordDecl. Use of __super is allowed only inside class and member function scope. llvm-svn: 218484
* [C++11] Support for capturing of variable length arrays in lambda expression.Alexey Bataev2014-08-281-2/+7
| | | | | | Differential Revision: http://reviews.llvm.org/D4368 llvm-svn: 216649
* Simplify creation of a bunch of ArrayRefs by using None, makeArrayRef or ↵Craig Topper2014-08-271-2/+2
| | | | | | just letting them be implicitly created. llvm-svn: 216528
* Track the difference betweenRichard Smith2014-07-171-1/+8
| | | | | | | | | | | | -- a constructor list initialization that unpacked an initializer list into constructor arguments and -- a list initialization that created as std::initializer_list and passed it as the first argument to a constructor in the AST. Use this flag while instantiating templates to provide the right semantics for the resulting initialization. llvm-svn: 213224
* AST: Don't walk all redeclarations when looking for a uuid attrDavid Majnemer2014-07-151-6/+4
| | | | | | No funcionality changed, just a simplification of the existing code. llvm-svn: 213044
* AST: Fix __uuidof for template specializationsDavid Majnemer2014-07-141-5/+5
| | | | | | | | | | | While we previously supported __uuidof applied to a template specialization, we would only find the uuid attribute if it was applied to the template argument. We would erroneously ignore the uuid attribute on the specialization itself. This is required to parse Windows Runtime C++ Template Library headers. llvm-svn: 213016
* AST: Cleanup __uuidof related codeDavid Majnemer2014-07-141-9/+8
| | | | | | | | Switch some things to use range-based for loops. Change CXXUuidofExpr::GetUuidAttrOfType's return type to be const. No functionality changed. llvm-svn: 213009
* Add range accessors for captures of a LambdaExpr.James Dennett2014-05-271-0/+12
| | | | | | | | | | | | | Summary: This adds LambdaExpr::captures(), LambdaExpr::explicit_captures() and LambdaExpr::implicit_captures() as simple wrappers over the underlying *_begin()/*_end() functions. Reviewers: aaron.ballman Differential Revision: http://reviews.llvm.org/D3926 llvm-svn: 209679
* [C++11] Use 'nullptr'. AST edition.Craig Topper2014-05-121-32/+34
| | | | llvm-svn: 208517
OpenPOWER on IntegriCloud