summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [Sema] Teach overload resolution about unaddressable functions.George Burgess IV2016-01-071-3/+14
| | | | | | | | | | | | Given an expression like `(&Foo)();`, we perform overload resolution as if we are calling `Foo` directly. This causes problems if `Foo` is a function that can't have its address taken. This patch teaches overload resolution to ignore functions that can't have their address taken in such cases. Differential Revision: http://reviews.llvm.org/D15590 llvm-svn: 257016
* Properly bind up any cleanups in an ExprWithCleanups afterJohn McCall2016-01-061-6/+5
| | | | | | | | | | instantiating a default argument expression. This was previously just working implicitly by reinstantiating in the current context, but caching means that we weren't registering cleanups in subsequent uses. llvm-svn: 256996
* Only instantiate a default argument once.John McCall2016-01-061-1/+8
| | | | | | | | | | | | | | | | | | | 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 OffsetOfExpr.James Y Knight2015-12-291-1/+0
| | | | | | That necessitated moving the OffsetOfNode class out of OffsetOfExpr. llvm-svn: 256590
* fix typos; NFCSanjay Patel2015-12-291-2/+2
| | | | llvm-svn: 256576
* Teach typo correction to properly handle mapping declarations to theirRichard Smith2015-12-291-15/+14
| | | | | | | | | | underlying decls. Preserve the found declaration throughout, and only map to the underlying declaration when we want to check whether it's the right kind. This allows us to provide the right source location for the found declaration, and prepares for the possibility of underlying decls with a different name from the found decl. llvm-svn: 256575
* Replace isa+cast with dyn_cast and obey the no else after return rule.Yaron Keren2015-12-231-6/+2
| | | | llvm-svn: 256349
* [Sema] Use range-based for loops. NFCCraig Topper2015-12-211-56/+39
| | | | llvm-svn: 256135
* Split RequireCompleteType into a function that actually requires that the typeRichard Smith2015-12-181-3/+6
| | | | | | | | | | | | | | | | | | | is complete (with an error produced if not) and a function that merely queries whether the type is complete. Either way we'll trigger instantiation if necessary, but only the former will diagnose and recover from missing module imports. The intent of this change is to prevent a class of bugs where code would call RequireCompleteType(..., 0) and then ignore the result. With modules, we must check the return value and use it to determine whether the definition of the type is visible. This also fixes a debug info quality issue: calls to isCompleteType do not trigger the emission of debug information for a type in limited-debug-info mode. This allows us to avoid emitting debug information for type definitions in more cases where we believe it is safe to do so. llvm-svn: 256049
* Wire a SourceLocation into IsDerivedFrom and move the RequireCompleteType callRichard Smith2015-12-181-3/+4
| | | | | | | | for the derived class into it. This is mostly just a cleanup, but could in principle be a bugfix if there is some codepath that reaches here and didn't previously require a complete type (I couldn't find any such codepath, though). llvm-svn: 256037
* [Sema] Add -Wparentheses warnings for '^' in '|' expressions and '&' in '^' ↵Craig Topper2015-12-131-24/+19
| | | | | | expressions to compliment '&' in '|' that is already present. Matches gcc behavior. llvm-svn: 255450
* [Sema] Write some checks for groups of BinaryOperatorKinds in terms of the ↵Craig Topper2015-12-131-6/+4
| | | | | | predicates already available in BinaryOperator. NFC llvm-svn: 255449
* Minor formatting cleanup. NFCCraig Topper2015-12-121-1/+1
| | | | llvm-svn: 255428
* [Sema] Simplify a couple if statements. Explicitly check up front that only ↵Craig Topper2015-12-121-3/+3
| | | | | | one of the expressions is a comparision op. Then if we find that either is a bitwise op, we know it must be the other one. NFC llvm-svn: 255427
* [OpenCL 2.0] In OpenCL v2.0 s6.5 all pointers are implicitly in genericAnastasia Stulova2015-12-111-1/+2
| | | | | | | | | | | 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-2/+1
| | | | llvm-svn: 255339
* [OpenCL 2.0] In OpenCL v2.0 s6.5 all pointers are implicitly in genericAnastasia Stulova2015-12-111-1/+2
| | | | | | | | | | | 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
* [Sema] Use UnaryOperatorKind and BinaryOperatorKind in parameter lists ↵Craig Topper2015-12-101-13/+13
| | | | | | instead of just unsigned. Removes a few explicit casts. NFC llvm-svn: 255232
* [Sema] Remove tab characters. NFCCraig Topper2015-12-081-2/+2
| | | | llvm-svn: 255004
* Add the `pass_object_size` attribute to clang.George Burgess IV2015-12-021-5/+43
| | | | | | | | | | | | | `pass_object_size` is our way of enabling `__builtin_object_size` to produce high quality results without requiring inlining to happen everywhere. A link to the design doc for this attribute is available at the Differential review link below. Differential Revision: http://reviews.llvm.org/D13263 llvm-svn: 254554
* [OpenMP] Update target directive codegen to use 4.5 implicit data mappings.Samuel Antao2015-12-021-5/+18
| | | | | | | | | | | | | | | Summary: This patch implements the 4.5 specification for the implicit data maps. OpenMP 4.5 specification changes the default way data is captured into a target region. All the non-aggregate kinds are passed by value by default. This required activating the capturing by value during SEMA for the target region. All the non-aggregate values that can be encoded in the size of a pointer are properly casted and forwarded to the runtime library. On top of fixing the previous weird behavior for mapping pointers in nested data regions (an explicit map was always required), this also improves performance as the number of allocations/transactions to the device per non-aggregate map are reduced from two to only one - instead of passing a reference and the value, only the value passed. Explicit maps will be added later on once firstprivate, private, and map clauses' SEMA and parsing are available. Reviewers: hfinkel, rjmccall, ABataev Subscribers: cfe-commits, carlo.bertolli Differential Revision: http://reviews.llvm.org/D14940 llvm-svn: 254521
* P0002R1: increment on expressions of type bool is no longer allowed in C++1z.Richard Smith2015-11-261-1/+3
| | | | llvm-svn: 254122
* [MSVC] 'property' with an empty array in array subscript expression.Alexey Bataev2015-11-251-3/+30
| | | | | | | | | | | | 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
* [Sema] Combine similar diagnostics using %select. NFCCraig Topper2015-11-171-3/+2
| | | | llvm-svn: 253315
* Use Sema::getLocForEndOfToken instead of Preprocessor::getLocForEndOfToken. NFCCraig Topper2015-11-151-18/+14
| | | | llvm-svn: 253155
* Add support for GCC's '__auto_type' extension, per the GCC manual:Richard Smith2015-11-111-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | https://gcc.gnu.org/onlinedocs/gcc/Typeof.html Differences from the GCC extension: * __auto_type is also permitted in C++ (but only in places where it could appear in C), allowing its use in headers that might be shared across C and C++, or used from C++98 * __auto_type can be combined with a declarator, as with C++ auto (for instance, "__auto_type *p") * multiple variables can be declared in a single __auto_type declaration, with the C++ semantics (the deduced type must be the same in each case) This patch also adds a missing restriction on applying typeof to a bit-field, which GCC has historically rejected in C (due to lack of clarity as to whether the operand should be promoted). The same restriction also applies to __auto_type in C (in both GCC and Clang). This also fixes PR25449. Patch by Nicholas Allegra! llvm-svn: 252690
* Use makeArrayRef instead of explicitly mentioning the type. NFCCraig Topper2015-11-071-1/+1
| | | | llvm-svn: 252398
* The control expression for a _Generic selection expression should haveAaron Ballman2015-11-051-5/+7
| | | | | | | its type decayed and qualifiers stripped when determining which selection it matches. Fixes PR16340. llvm-svn: 252104
* [coroutines] Creation of promise object, lookup of operator co_await, buildingRichard Smith2015-10-271-0/+1
| | | | | | of await_* calls, and AST representation for same. llvm-svn: 251387
* Define weak and __weak to mean ARC-style weak references, even in MRC.John McCall2015-10-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, __weak was silently accepted and ignored in MRC mode. That makes this a potentially source-breaking change that we have to roll out cautiously. Accordingly, for the time being, actual support for __weak references in MRC is experimental, and the compiler will reject attempts to actually form such references. The intent is to eventually enable the feature by default in all non-GC modes. (It is, of course, incompatible with ObjC GC's interpretation of __weak.) If you like, you can enable this feature with -Xclang -fobjc-weak but like any -Xclang option, this option may be removed at any point, e.g. if/when it is eventually enabled by default. This patch also enables the use of the ARC __unsafe_unretained qualifier in MRC. Unlike __weak, this is being enabled immediately. Since variables are essentially __unsafe_unretained by default in MRC, the only practical uses are (1) communication and (2) changing the default behavior of by-value block capture. As an implementation matter, this means that the ObjC ownership qualifiers may appear in any ObjC language mode, and so this patch removes a number of checks for getLangOpts().ObjCAutoRefCount that were guarding the processing of these qualifiers. I don't expect this to be a significant drain on performance; it may even be faster to just check for these qualifiers directly on a type (since it's probably in a register anyway) than to do N dependent loads to grab the LangOptions. rdar://9674298 llvm-svn: 251041
* Use an ArrayRef<OffsetOfComponent> instead of pointer and size throughout ↵Craig Topper2015-10-221-11/+7
| | | | | | offsetof handling code. Also use a range-based for loop. NFC llvm-svn: 250989
* Use front() instead of [0] to make code more consistent with the next line ↵Craig Topper2015-10-221-1/+1
| | | | | | that uses back(). llvm-svn: 250970
* [Sema] Make `&function_with_enable_if_attrs` an errorGeorge Burgess IV2015-10-121-1/+10
| | | | | | | | | | | | | | | | | | This fixes a bug where one can take the address of a conditionally enabled function to drop its enable_if guards. For example: int foo(int a) __attribute__((enable_if(a > 0, ""))); int (*p)(int) = &foo; int result = p(-1); // compilation succeeds; calls foo(-1) Overloading logic has been updated to reflect this change, as well. Functions with enable_if attributes that are always true are still allowed to have their address taken. Differential Revision: http://reviews.llvm.org/D13607 llvm-svn: 250090
* [Sema] Allow C conversions in C overload logicGeorge Burgess IV2015-10-111-15/+27
| | | | | | | | | | C allows for some implicit conversions that C++ does not, e.g. void* -> char*. This patch teaches clang that these conversions are okay when dealing with overloads in C. Differential Revision: http://reviews.llvm.org/D13604 llvm-svn: 249995
* [Sema] Add "Ty" suffix to QualType variables for clarity (NFC)Vedant Kumar2015-10-091-5/+5
| | | | llvm-svn: 249801
* Revert r107690 (for PR7417) and add a testcase that it breaks. The approach ofRichard Smith2015-10-051-42/+1
| | | | | | | | | that change turns out to not be reasonable: mutating the AST of a parsed template during instantiation is not a sound thing to do, does not work across chained PCH / modules builds, and is in any case a special-case workaround to a more general problem that should be solved centrally. llvm-svn: 249342
* SourceRanges are small and trivially copyable, don't them by reference.Craig Topper2015-10-041-1/+1
| | | | llvm-svn: 249259
* [OpenMP] Capture global variables in target regions.Samuel Antao2015-10-021-3/+11
| | | | | | | | | All global variables that are not enclosed in a declare target region must be captured in the target region as local variables do. Currently, there is no support for declare target, so this patch adds support for capturing all the global variables used in a the target region. llvm-svn: 249154
* [Sema] Avoid crashing during this-> insertion recoveryReid Kleckner2015-09-301-8/+15
| | | | | | | | | We get into this bad state when someone defines a new member function for a class but forgets to add the declaration to the class body. Calling the new member function from a member function template of the class will crash during instantiation. llvm-svn: 248925
* [OpenCL] Add missing OpenCL LangOpts in address space compatibility checksAnastasia Stulova2015-09-301-7/+9
| | | | | | | | | and test checking broken (due to CL specific diagnostics) C functionality M test/Sema/address_spaces.c M lib/Sema/SemaExpr.cpp llvm-svn: 248902
* [OpenCL 2.0] This change adds extra diagnostics to atomic typesAnastasia Stulova2015-09-301-0/+22
| | | | | | | | | Applied restrictions from OpenCL v2.0 s6.13.11.8 that mainly disallow operations on atomic types (except for taking their address - &). The patch is taken from SPIR2.0 provisional branch, contributed by Guy Benyei! llvm-svn: 248896
* [OPENMP 4.1] Sema analysis for array sections in 'reduction' clause.Alexey Bataev2015-09-301-23/+1
| | | | | | OpenMP 4.1 allows to use array sections|subscript expressions in 'reduction' clauses. Added sema analysis, updated tests. llvm-svn: 248880
* Support __builtin_ms_va_list.Charles Davis2015-09-171-30/+44
| | | | | | | | | | | | | | | | | | Summary: This change adds support for `__builtin_ms_va_list`, a GCC extension for variadic `ms_abi` functions. The existing `__builtin_va_list` support is inadequate for this because `va_list` is defined differently in the Win64 ABI vs. the System V/AMD64 ABI. Depends on D1622. Reviewers: rsmith, rnk, rjmccall CC: cfe-commits Differential Revision: http://reviews.llvm.org/D1623 llvm-svn: 247941
* Prevent implicit re-interpret casts between ExtVector and Scalar types.Stephen Canon2015-09-151-0/+8
| | | | | | Previously, in certain cases lax vector conversions could occur between scalar floating-point values and ExtVector types; these conversions would be simple bitcasts. We need to allow them with other vector types to support some common headers, but we don't need them for ExtVector. Preventing them here makes them behave like other operations involving scalars and ExtVectors. llvm-svn: 247643
* [MS ABI] Select a pointer to member representation more oftenDavid Majnemer2015-09-101-0/+4
| | | | | | | | | Given a reference to a pointer to member whose class's inheritance model is unspecified, make sure we come up with an inheritance model in plausible places. One place we were missing involved LValue to RValue conversion, another involved unary type traits. llvm-svn: 247248
* [OPENMP] Fix for http://llvm.org/PR24687: ICE on compilation of R package TPmsm.Alexey Bataev2015-09-031-15/+15
| | | | | | Fixed capturing of VLAs in 'private' clause of the OpenMP directives. llvm-svn: 246757
* Add a new frontend warning for referencing members from the handler of a ↵Aaron Ballman2015-09-011-7/+5
| | | | | | | | constructor or destructor function-try-block, which is UB in C++. This corresponds to the CERT secure coding rule ERR53-CPP. llvm-svn: 246548
* [OpenCL] Improve diagnostics detecting implicit vector conversion.Alexey Bader2015-08-301-0/+12
| | | | | | | | Reviewers: pekka.jaaskelainen Differential Revision: http://reviews.llvm.org/D12470 llvm-svn: 246393
* [Sema] Don't assume CallExpr::getDirectCallee will succeedDavid Majnemer2015-08-261-1/+1
| | | | | | | | | | We tried to provide a very nice diagnostic when diagnosing an assignment to a const int & produced by a function call. However, we cannot always determine what function was called. This fixes PR24568. llvm-svn: 246014
* Fix possible crash on null base or type for array elements.Alexey Bataev2015-08-251-1/+2
| | | | llvm-svn: 245939
OpenPOWER on IntegriCloud