summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Expr.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Use ranges to concisely express iterationDavid Majnemer2016-06-231-8/+7
| | | | | | | No functional change is intended, this should just clean things up a little. llvm-svn: 273522
* Re-commit "[Temporary] Add an ExprWithCleanups for each C++ ↵Tim Shen2016-06-211-1/+6
| | | | | | | | | | MaterializeTemporaryExpr." Since D21243 fixes relative clang-tidy tests. This reverts commit a71d9fbd41e99def9159af2b01ef6509394eaeed. llvm-svn: 273312
* Revert "[Temporary] Add an ExprWithCleanups for each C++ ↵Tim Shen2016-06-091-6/+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/+6
| | | | | | | | | | | 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
* [AST] Move operations enum to a definition file.Etienne Bergeron2016-05-121-160/+6
| | | | | | | | | | | | | | | | | | | Summary: This patch moves the enum definitions to a definition (.def) file. These modifications provide way to list enumerators of a given type. As an example, this allow parsing of "kinds" in the dynamic matchers. see: http://reviews.llvm.org/D19871 The dynamic matcher "ofKind" also required this patch to be fixed. Reviewers: klimek, aaron.ballman, rsmith Subscribers: klimek, sbenza, alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D20207 llvm-svn: 269347
* [OPENMP 4.0] Fixed support of array sections/array subscripts.Alexey Bataev2016-02-041-2/+4
| | | | | | Codegen for array sections/array subscripts worked only for expressions with arrays as base. Patch fixes codegen for bases with pointer/reference types. llvm-svn: 259776
* ObjCXX: fix a crash during typo correction.Manman Ren2016-02-021-2/+7
| | | | | | | | | | | | | For ObjCXX, we can create a CastExpr with Kind being CK_UserDefinedConversion and SubExpr being BlockExpr. Specifically one can return BlockExpr from BuildCXXMemberCallExpr and the result can be used to build a CastExpr. Fix the assumption in CastExpr::getSubExprAsWritten that SubExpr can only be CXXMemberCallExpr. rdar://problem/24364077 llvm-svn: 259591
* assert(false) -> llvm_unreachable().Davide Italiano2016-01-301-1/+1
| | | | llvm-svn: 259302
* [CUDA] Warn undeclared identifiers in CUDA kernel callsJustin Lebar2016-01-141-21/+32
| | | | | | | | | | | | | | | | | | Value, type, and instantiation dependence were not being handled correctly for CUDAKernelCallExpr AST nodes. As a result, if an undeclared identifier was used in the triple-angle-bracket kernel call configuration, there would be no error during parsing, and there would be a crash during code gen. This patch makes sure that an error will be issued during parsing in this case, just as there would be for any other use of an undeclared identifier in C++. Patch by Jason Henline. Reviewers: jlebar, rsmith Differential Revision: http://reviews.llvm.org/D15858 llvm-svn: 257839
* [Bugfix] Fix ICE on constexpr vector splat.George Burgess IV2016-01-131-0/+3
| | | | | | | | | | | | | 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
* [TrailingObjects] Convert remaining classes in Expr.h and ExprCXX.hJames Y Knight2015-12-311-15/+10
| | | | llvm-svn: 256658
* [TrailingObjects] Convert CastExpr and subclasses.James Y Knight2015-12-301-18/+13
| | | | llvm-svn: 256608
* [TrailingObjects] Convert OffsetOfExpr.James Y Knight2015-12-291-7/+5
| | | | | | That necessitated moving the OffsetOfNode class out of OffsetOfExpr. llvm-svn: 256590
* [TrailingObjects] Convert AST classes that had a ASTTemplateKWAndArgsInfo.James Y Knight2015-12-291-46/+34
| | | | | | | | | | | | | | | | | | | | 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
* [OpenCL 2.0] In OpenCL v2.0 s6.5 all pointers are implicitly in genericAnastasia Stulova2015-12-111-3/+14
| | | | | | | | | | | address space unless address space is explicitly specified. Correct the behavior of NULL constant detection - generic AS void pointer should be accepted as a valid NULL constant. http://reviews.llvm.org/D15293 llvm-svn: 255346
* Reverting r255337 as it seems to kill bots. Needs investigation.Anastasia Stulova2015-12-111-14/+3
| | | | llvm-svn: 255339
* [OpenCL 2.0] In OpenCL v2.0 s6.5 all pointers are implicitly in genericAnastasia Stulova2015-12-111-3/+14
| | | | | | | | | | | address space unless address space is explicitly specified. Correct the behavior of NULL constant detection - generic AS void pointer should be accepted as a valid NULL constant. http://reviews.llvm.org/D15293 llvm-svn: 255337
* PR25416: Improve performance of processing inline assembly consisting of manyRichard Smith2015-12-101-10/+39
| | | | | | | | | | implicitly-concatenated string literals. When looking for the start of a token in the inline assembly, start from the end of the previous token, not the start of the entire string. Patch by Yunlian Jiang! llvm-svn: 255198
* Explicitly permit undefined behavior in constant initializers for globalRichard Smith2015-12-081-1/+4
| | | | | | | | variables in C, in the cases where we can constant-fold it to a value regardless (such as floating-point division by zero and signed integer overflow). Strictly enforcing this rule breaks too much code. llvm-svn: 254992
* [MSVC] 'property' with an empty array in array subscript expression.Alexey Bataev2015-11-251-0/+1
| | | | | | | | | | | | MSVC supports 'property' attribute and allows to apply it to the declaration of an empty array in a class or structure definition. For example: ``` __declspec(property(get=GetX, put=PutX)) int x[]; ``` The above statement indicates that x[] can be used with one or more array indices. In this case, i=p->x[a][b] will be turned into i=p->GetX(a, b), and p->x[a][b] = i will be turned into p->PutX(a, b, i); Differential Revision: http://reviews.llvm.org/D13336 llvm-svn: 254067
* [coroutines] Creation of promise object, lookup of operator co_await, buildingRichard Smith2015-10-271-0/+8
| | | | | | of await_* calls, and AST representation for same. llvm-svn: 251387
* [OPENMP 4.1] Codegen for array sections/subscripts in 'reduction' clause.Alexey Bataev2015-10-081-0/+4
| | | | | | OpenMP 4.1 adds support for array sections/subscripts in 'reduction' clause. Patch adds codegen for this feature. llvm-svn: 249672
* [OPENMP 4.1] Sema analysis for array sections in 'reduction' clause.Alexey Bataev2015-09-301-0/+23
| | | | | | OpenMP 4.1 allows to use array sections|subscript expressions in 'reduction' clauses. Added sema analysis, updated tests. llvm-svn: 248880
* Move functions declared in ExprObjC.h into ExprObjC.cpp.James Y Knight2015-09-291-402/+0
| | | | | | | | r51703 back in 2008 split out all the ObjC Expr subclasses from Expr.h to a new ExprObjC.h file, but failed to also split the implementation from Expr.cpp to ExprObjC.cpp. Do so, finally, for readability's sake. llvm-svn: 248836
* [OPENMP 4.0] Initial support for array sections.Alexey Bataev2015-08-251-0/+1
| | | | | | | | Adds parsing/sema analysis/serialization/deserialization for array sections in OpenMP constructs (introduced in OpenMP 4.0). Currently it is allowed to use array sections only in OpenMP clauses that accepts list of expressions. Differential Revision: http://reviews.llvm.org/D10732 llvm-svn: 245937
* Remove and forbid raw_svector_ostream::flush() calls.Yaron Keren2015-08-131-3/+0
| | | | | | | | | | After r244870 flush() will only compare two null pointers and return, doing nothing but wasting run time. The call is not required any more as the stream and its SmallString are always in sync. Thanks to David Blaikie for reviewing. llvm-svn: 244928
* Additional fix for PR14269: Crash on vector elements / global register vars ↵Andrey Bokhanko2015-08-031-0/+12
| | | | | | | | | | in inline assembler. Compiler crashed when vector elements / global register vars were used in inline assembler with "m" restriction. This patch fixes this. Differential Revision: http://reviews.llvm.org/D10476 llvm-svn: 243870
* [CodeGen] Simplify creation of shuffle masks.Benjamin Kramer2015-07-281-1/+1
| | | | | | No functional change intended. llvm-svn: 243439
* [AST] Remove StmtRange in favor of an iterator_range.Benjamin Kramer2015-07-181-2/+2
| | | | | | | | | StmtRange was just a convenient wrapper for two StmtIterators before we had real range support. This removes some of the implicit conversions StmtRange had leading to slightly more verbose code but also should make more obvious what's going on. No functional change intended. llvm-svn: 242615
* [AST] Cleanup ExprIterator.Benjamin Kramer2015-07-181-13/+0
| | | | | | | | - Make it a proper random access iterator with a little help from iterator_adaptor_base - Clean up users of magic dereferencing. The iterator should behave like an Expr **. - Make it an implementation detail of Stmt. This allows inlining of the assertions. llvm-svn: 242608
* Fix alignment issues in Clang.James Y Knight2015-07-171-4/+13
| | | | | | | | | | | | | | | | | 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
* Substitute type arguments into uses of Objective-C interface members.Douglas Gregor2015-07-071-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When messaging a method that was defined in an Objective-C class (or category or extension thereof) that has type parameters, substitute the type arguments for those type parameters. Similarly, substitute into property accesses, instance variables, and other references. This includes general infrastructure for substituting the type arguments associated with an ObjCObject(Pointer)Type into a type referenced within a particular context, handling all of the substitutions required to deal with (e.g.) inheritance involving parameterized classes. In cases where no type arguments are available (e.g., because we're messaging via some unspecialized type, id, etc.), we substitute in the type bounds for the type parameters instead. Example: @interface NSSet<T : id<NSCopying>> : NSObject <NSCopying> - (T)firstObject; @end void f(NSSet<NSString *> *stringSet, NSSet *anySet) { [stringSet firstObject]; // produces NSString* [anySet firstObject]; // produces id<NSCopying> (the bound) } When substituting for the type parameters given an unspecialized context (i.e., no specific type arguments were given), substituting the type bounds unconditionally produces type signatures that are too strong compared to the pre-generics signatures. Instead, use the following rule: - In covariant positions, such as method return types, replace type parameters with “id” or “Class” (the latter only when the type parameter bound is “Class” or qualified class, e.g, “Class<NSCopying>”) - In other positions (e.g., parameter types), replace type parameters with their type bounds. - When a specialized Objective-C object or object pointer type contains a type parameter in its type arguments (e.g., NSArray<T>*, but not NSArray<NSString *> *), replace the entire object/object pointer type with its unspecialized version (e.g., NSArray *). llvm-svn: 241543
* Switch users of the 'for (StmtRange range = stmt->children(); range; ↵Benjamin Kramer2015-07-021-4/+4
| | | | | | | | | ++range)‘ pattern to range for loops. The pattern was born out of the lack of range-based for loops in C++98 and is somewhat obscure. No functionality change intended. llvm-svn: 241300
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-221-3/+3
| | | | llvm-svn: 240353
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-221-3/+3
| | | | | | | | | | | | 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
* some StmtExprs do not have side-effectsScott Douglass2015-06-101-1/+29
| | | | | | Differential Revision: http://reviews.llvm.org/D10211 llvm-svn: 239476
* add ConstEvaluatedExprVisitorScott Douglass2015-06-101-14/+14
| | | | | | Differential Revision: http://reviews.llvm.org/D10210 llvm-svn: 239474
* Implementing C99 partial re-initialization behavior (DR-253)Yunzhong Gao2015-06-101-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | Based on previous discussion on the mailing list, clang currently lacks support for C99 partial re-initialization behavior: Reference: http://lists.cs.uiuc.edu/pipermail/cfe-dev/2013-April/029188.html Reference: http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_253.htm This patch attempts to fix this problem. Given the following code snippet, struct P1 { char x[6]; }; struct LP1 { struct P1 p1; }; struct LP1 l = { .p1 = { "foo" }, .p1.x[2] = 'x' }; // this example is adapted from the example for "struct fred x[]" in DR-253; // currently clang produces in l: { "\0\0x" }, // whereas gcc 4.8 produces { "fox" }; // with this fix, clang will also produce: { "fox" }; Differential Review: http://reviews.llvm.org/D5789 llvm-svn: 239446
* Properly implement warn_unused_result checking for classes/structs.Kaelyn Takata2015-04-091-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous implementation would copy the attribute from the class to functions that have the class as their return type when the functions are first declared. This proved to have two flaws: 1) if the class is forward-declared without the attribute and a function or method with the class as a its return type is declared, and afterward the class is defined with warn_unused_result, the function or method would never inherit the attribute, and 2) the check simply failed for functions and methods that are part of a template instantiation, regardless of whether the class with warn_unused_result is part of a specific instantiation or part of the template itself (presumably because those function/method declaration does not hit the same code path as a non-template one and so never inherits the attribute). The new approach is to instead modify the two places where a function or method call is checked for the warn_unused_result attribute on the decl by extending the checks to also look for the attribute on the decl's return type. Additionally, the check for return types that have the warn_unused_result now excludes pointers and references to such types, as such return types do not necessarily imply a transfer of ownership for the underlying object being referred to by the return value. This does not change the behavior of functions that are directly given the warn_unused_result attribute. llvm-svn: 234526
* HasSideEffects() should return false for calls to pure and const functions.Michael Kuperstein2015-04-061-3/+11
| | | | | | Differential Revision: http://reviews.llvm.org/D8548 llvm-svn: 234152
* Track the source location of the dot or arrow operator in a MemberExpr.Aaron Ballman2015-03-241-12/+8
| | | | | | Patch by Joe Ranieri! llvm-svn: 233085
* Use delegating ctors to reduce code duplication. NFC.Benjamin Kramer2015-03-061-30/+3
| | | | llvm-svn: 231476
* Sema: Parenthesized bound destructor member expressions can be calledDavid Majnemer2015-02-251-10/+15
| | | | | | | | | We would wrongfully reject (a.~A)() in both the destructor and pseudo-destructor cases. This fixes PR22668. llvm-svn: 230512
* [Objctive-C sema]. Do not do the unused-getter-return-valueFariborz Jahanian2015-02-161-3/+1
| | | | | | | warning when property getter is used in direct method call and return value of property is unused. rdar://19773512 llvm-svn: 229458
* AST: alignof might be dependent because of alignment attributesDavid Majnemer2015-01-151-0/+38
| | | | | | | Dependent alignment attributes should make an alignof expression dependent as well. llvm-svn: 226156
* Rename RefersToCapturedVariable to RefersToEnclosingVariableOrCapture, NFCAlexey Bataev2015-01-121-6/+7
| | | | llvm-svn: 225624
* Sema: Dependent array designators cannot be checkedDavid Majnemer2015-01-091-2/+2
| | | | | | | | | | | We forgot to mark designated initializer expression that contain type dependent array designators as type dependent. This would lead to crashes when we try to determine which array element we were trying to initialize. This fixes PR22056. llvm-svn: 225494
* Volatile reads are side-effecting operations, but in the general case of ↵Aaron Ballman2015-01-031-0/+7
| | | | | | | | | | | access through a volatile-qualified type, we're not certain of the underlying object's side-effects on access. Treat volatile accesses as "maybe" instead of "definite" side effects for the purposes of warning on evaluations in an unevaluated context. No longer diagnose on idiomatic code like: int * volatile v; (void)sizeof(*v); llvm-svn: 225116
* Adding a -Wunused-value warning for expressions with side effects used in an ↵Aaron Ballman2014-12-171-20/+37
| | | | | | unevaluated expression context, such as sizeof(), or decltype(). Also adds a similar warning when the expression passed to typeid() *is* evaluated, since it is equally likely that the user would expect the expression operand to be unevaluated in that case. llvm-svn: 224465
* Renamed RefersToEnclosingLocal bitfield to RefersToCapturedVariable.Alexey Bataev2014-12-161-6/+6
| | | | | | | Bitfield RefersToEnclosingLocal of Stmt::DeclRefExprBitfields renamed to RefersToCapturedVariable to reflect latest changes introduced in commit 224323. Also renamed method Expr::refersToEnclosingLocal() to Expr::refersToCapturedVariable() and comments for constant arguments. No functional changes. llvm-svn: 224329
OpenPOWER on IntegriCloud