summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Expr.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Handle use of default member initializers before end of outermost classReid Kleckner2014-11-171-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Specifically, when we have this situation: struct A { template <typename T> struct B { int m1 = sizeof(A); }; B<int> m2; }; We can't parse m1's initializer eagerly because we need A to be complete. Therefore we wait until the end of A's class scope to parse it. However, we can trigger instantiation of B before the end of A, which will attempt to instantiate the field decls eagerly, and it would build a bad field decl instantiation that said it had an initializer but actually lacked one. Fixed by deferring instantiation of default member initializers until they are needed during constructor analysis. This addresses a long standing FIXME in the code. Fixes PR19195. Reviewed By: rsmith Differential Revision: http://reviews.llvm.org/D5690 llvm-svn: 222192
* [c++1z] N4295: fold-expressions.Richard Smith2014-11-081-0/+1
| | | | | | | | | | | | | | | | This is a new form of expression of the form: (expr op ... op expr) where one of the exprs is a parameter pack. It expands into (expr1 op (expr2onwards op ... op expr)) (and likewise if the pack is on the right). The non-pack operand can be omitted; in that case, an empty pack gives a fallback value or an error, depending on the operator. llvm-svn: 221573
* Objective-C. revert patch for rdar://17554063.Fariborz Jahanian2014-10-281-11/+4
| | | | llvm-svn: 220812
* Add the initial TypoExpr AST node for delayed typo correction.Kaelyn Takata2014-10-271-0/+1
| | | | llvm-svn: 220692
* Add frontend support for __vectorcallReid Kleckner2014-10-241-0/+1
| | | | | | | | | | | | | Wire it through everywhere we have support for fastcall, essentially. This allows us to parse the MSVC "14" CTP headers, but we will miscompile them because LLVM doesn't support __vectorcall yet. Reviewed By: Aaron Ballman Differential Revision: http://reviews.llvm.org/D5808 llvm-svn: 220573
* Towards PR21289: don't lose track of unexpanded parameter packs withRichard Smith2014-10-171-28/+17
| | | | | | | non-dependent types, in CXXScalarValueInitExprs and in the nested-name-specifier or template arguments of a DeclRefExpr in particular. llvm-svn: 220028
* Bugfix for predefined expressions in dependent context.Alexey Bataev2014-10-101-1/+1
| | | | | | This bug break compilation with precompiled headers and predefined expressions in dependent context. llvm-svn: 219525
* Fix for bug http://llvm.org/PR17427.Alexey Bataev2014-10-091-3/+50
| | | | | | | | Assertion failed: "Computed __func__ length differs from type!" Reworked PredefinedExpr representation with internal StringLiteral field for function declaration. Differential Revision: http://reviews.llvm.org/D5365 llvm-svn: 219393
* Fix handling of preincrement on bit-fields. This gives a bit-field in C++, butRichard Smith2014-09-241-0/+4
| | | | | | | | | | | we were failing to find that bit-field when performing integer promotions. This brings us closer to following the standard, and closer to GCC. In C, this change is technically a regression: we get bit-field promotions completely wrong in C, promoting cases that are categorically not bit-field designators. This change makes us do so slightly more consistently, though. llvm-svn: 218428
* Range'ify some for loops over RecordDecl::fields()Hans Wennborg2014-08-211-3/+2
| | | | | | No functionality change. llvm-svn: 216183
* Make sure CallExpr::getLocStart doesn't segfaultKeno Fischer2014-08-151-2/+2
| | | | | | | | | | | | | | | | | Summary: When the CallExpr passed to Sema::ConvertArgumentsForCall has all default parameters, and the number of actual arguments passed is zero, this function will segfault in the call to Call->getLocStart() if the Callee has an invalid getLocStart(), the reason being that since ConvertArgumentsForCall has set the correct number of arguments, but has not filled them in yet, getLocStart() will try to access the first (not yet existent) argument and thus segfaults. This fixes that by making getLocStart return an invalid source location if the queried argument is NULL rather than segfaulting. Reviewers: rnk Reviewed By: rnk Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4917 llvm-svn: 215686
* Objective-C ARC. First patch toward generating new APIsFariborz Jahanian2014-08-061-4/+11
| | | | | | | for Objective-C's array and dictionary literals. rdar://17554063. This is wip. llvm-svn: 214983
* Improve -UNDEBUG binary size. We don't need a different assert fail message forRichard Smith2014-07-261-2/+2
| | | | | | each different enum value here. llvm-svn: 213996
* Objective-C. Patch to warn if the result of calling a property getter Fariborz Jahanian2014-07-181-6/+9
| | | | | | | | is unused (this is match behavior when property-dot syntax is used to use same getter). rdar://17514245 Patch by Anders Carlsson with minor refactoring by me. llvm-svn: 213423
* Convert StringLiteralParser constructor to use ArrayRef instead of a pointer ↵Craig Topper2014-06-261-1/+1
| | | | | | and count. llvm-svn: 211763
* Improved location for non-constant initializers diagnostics.Abramo Bagnara2014-05-221-18/+33
| | | | llvm-svn: 209466
* Ignore void returning overloaded functions fom -Wunused-comparison. PR19791.Richard Trieu2014-05-201-1/+2
| | | | llvm-svn: 209186
* When an overloaded comparison operator returns a reference, do not considerRichard Trieu2014-05-141-0/+2
| | | | | | it for -Wunused-comparion warnings. This fixes PR19724. llvm-svn: 208824
* [C++11] Use 'nullptr'. AST edition.Craig Topper2014-05-121-22/+23
| | | | llvm-svn: 208517
* -Wunreachable-code: refine recognition of unreachable "sigil" to cope with ↵Ted Kremenek2014-04-161-0/+21
| | | | | | | | implicit casts in C++. Fixes <rdar://problem/16631033>. llvm-svn: 206360
* Add support for MSVC's __FUNCSIG__Reid Kleckner2014-04-081-2/+14
| | | | | | | | | | | It is very similar to GCC's __PRETTY_FUNCTION__, except it prints the calling convention. Reviewers: majnemer Differential Revision: http://reviews.llvm.org/D3311 llvm-svn: 205780
* Extend -Wtautological-constant-out-of-range-compare to handle boolean valuesRichard Trieu2014-04-041-0/+2
| | | | | | | | | | | | | | | better. This warning will now trigger on the following conditionals: bool b; int i; if (b > 1) {} // always false if (0 <= (i > 5)) {} // always true if (-1 > b) {} // always false Patch by Per Viberg. llvm-svn: 205608
* Move the warning about unused relational comparison from -Wunused-value toRichard Trieu2014-03-111-4/+11
| | | | | | | -Wunused-comparison. Also, newly warn on unused result from overloaded relational comparisons, now also in -Wunused-comparison. llvm-svn: 203535
* Replace OwningPtr with std::unique_ptr.Ahmed Charles2014-03-071-1/+1
| | | | | | This compiles cleanly with lldb/lld/clang-tools-extra/llvm. llvm-svn: 203279
* Sema: When merging objc string literals, give the result a constant array type.Benjamin Kramer2014-02-251-0/+3
| | | | | | | | Also assert that we never create non-array string literals again. PR18939. llvm-svn: 202147
* [Sema] Revert the change in r200622 that allowed integer casts to silence ↵Argyrios Kyrtzidis2014-02-111-3/+0
| | | | | | | | | | -Wnon-literal-null-conversion in C code. It is actually useful to warn in such cases, thanks to Dmitri for pushing on this and making us see the light! Related to rdar://15925483 and rdar://15922612. The latter radar is where the usefulness of the warning is most clear. llvm-svn: 201165
* Clean up some particularly ugly casting.Benjamin Kramer2014-02-051-12/+3
| | | | | | No functionality change. llvm-svn: 200877
* Fix typo in CastExpr::getCastKindName.Jordan Rose2014-02-051-1/+1
| | | | | | Patch by Mathieu Baudet! llvm-svn: 200817
* [Sema] Follow-up on r200521 for the -Wnon-literal-null-conversion warning ↵Argyrios Kyrtzidis2014-02-021-0/+3
| | | | | | and revert its behavior for C++. llvm-svn: 200622
* Rename getResultType() on function and method declarations to getReturnType()Alp Toker2014-01-251-5/+7
| | | | | | | | | | | | | | | A return type is the declared or deduced part of the function type specified in the declaration. A result type is the (potentially adjusted) type of the value of an expression that calls the function. Rule of thumb: * Declarations have return types and parameters. * Expressions have result types and arguments. llvm-svn: 200082
* Harden InitListExpr::isStringLiteralInit() against getInit() returning null.Ted Kremenek2014-01-191-1/+5
| | | | | | | | This led to a crash on invalid code (sorry, no good test case). Fixes <rdar://problem/15831804>. llvm-svn: 199571
* Rename language option MicrosoftMode to MSVCCompatAlp Toker2014-01-141-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | There's been long-standing confusion over the role of these two options. This commit makes the necessary changes to differentiate them clearly, following up from r198936. MicrosoftExt (aka. fms-extensions): Enable largely unobjectionable Microsoft language extensions to ease portability. This mode, also supported by gcc, is used for building software like FreeBSD and Linux kernel extensions that share code with Windows drivers. MSVCCompat (aka. -fms-compatibility, formerly MicrosoftMode): Turn on a special mode supporting 'heinous' extensions for drop-in compatibility with the Microsoft Visual C++ product. Standards-compilant C and C++ code isn't guaranteed to work in this mode. Implies MicrosoftExt. Note that full -fms-compatibility mode is currently enabled by default on the Windows target, which may need tuning to serve as a reasonable default. See cfe-commits for the full discourse, thread 'r198497 - Move MS predefined type_info out of InitializePredefinedMacros' No change in behaviour. llvm-svn: 199209
* Fixed a FIXME; created a print method for Selectors that accepts a ↵Aaron Ballman2014-01-031-1/+1
| | | | | | | | raw_ostream, and started using it in places it made sense. No functional changes intended, just API cleanliness. llvm-svn: 198428
* Eliminate UnaryTypeTraitExprAlp Toker2014-01-011-1/+0
| | | | | | | | | | | | | Remove UnaryTypeTraitExpr and switch all remaining type trait related handling over to TypeTraitExpr. The UTT/BTT/TT enum prefix and evaluation code is retained pending further cleanup. This is part of the ongoing work to unify type traits following the removal of BinaryTypeTraitExpr in r197273. llvm-svn: 198271
* Rename isBuiltinCall() to getBuiltinCallee()Alp Toker2013-12-281-3/+3
| | | | | | | | This better describes what the function does. Cleanup only. llvm-svn: 198127
* Replacing calls to getAttr with calls to hasAttr for clarity. No functional ↵Aaron Ballman2013-12-191-3/+3
| | | | | | change intended -- this only replaces Boolean uses of getAttr. llvm-svn: 197648
* Eliminate BinaryTypeTraitExprAlp Toker2013-12-131-1/+0
| | | | | | | | | | | | | | | | | There's nothing special about type traits accepting two arguments. This commit eliminates BinaryTypeTraitExpr and switches all related handling over to TypeTraitExpr. Also fixes a CodeGen failure with variadic type traits appearing in a non-constant expression. The BTT/TT prefix and evaluation code is retained as-is for now but will soon be further cleaned up. This is part of the ongoing work to unify type traits. llvm-svn: 197273
* PR18217: Rewrite JumpDiagnostics' handling of temporaries, to correctly handleRichard Smith2013-12-121-31/+0
| | | | | | | | | declarations that might lifetime-extend multiple temporaries. In passing, fix a crasher (PR18217) if an initializer was dependent and exactly the wrong shape, and remove a bogus function (Expr::findMaterializedTemporary) now its last use is gone. llvm-svn: 197103
* Add front-end infrastructure now address space casts are in LLVM IR.David Tweed2013-12-111-0/+7
| | | | | | | | | | With the introduction of explicit address space casts into LLVM, there's a need to provide a new cast kind the front-end can create for C/OpenCL/CUDA and code to produce address space casts from those kinds when appropriate. Patch by Michele Scandale! llvm-svn: 197036
* Eliminate the last trivial NDEBUG uses in clang headersAlp Toker2013-12-071-1/+2
| | | | | | assert(sanity()) reads so much better than preprocessor conditional blocks. llvm-svn: 196657
* PR18152: When computing the semantic form for an initializer list, keep trackRichard Smith2013-12-061-2/+2
| | | | | | of whether the initializer list is dependent. llvm-svn: 196558
* DR408: If a static data member of incomplete array type is declared in a classRichard Smith2013-11-141-0/+3
| | | | | | | | | | template, that member has a dependent type (even if we can see the definition of the member of the primary template), because the array size could change in a member specialization. Patch by Karthik Bhat! llvm-svn: 194740
* -fms-compatibility: Use C++98 null pointer constant rulesReid Kleckner2013-11-121-2/+8
| | | | | | Patch by Will Wilson! llvm-svn: 194441
* [-fms-extensions] Add support for __FUNCDNAME__David Majnemer2013-11-061-0/+25
| | | | | | | | | | | | | | | | Summary: Similar to __FUNCTION__, MSVC exposes the name of the enclosing mangled function name via __FUNCDNAME__. This implementation is very naive and unoptimized, it is expected that __FUNCDNAME__ would be used rarely in practice. Reviewers: rnk, rsmith, thakis CC: cfe-commits, silvas Differential Revision: http://llvm-reviews.chandlerc.com/D2109 llvm-svn: 194181
* Tweak changes in r186464 to avoid a crash.Eli Friedman2013-10-011-3/+0
| | | | | | | | | | | | | Currently, IR generation can't handle file-scope compound literals with non-constant initializers in C++. Fixes PR17415 (the first crash in the bug). (We should probably change (T){1,2,3} to use the same codepath as T{1,2,3} in C++ eventually, given that the semantics of the latter are actually defined by the standard.) llvm-svn: 191719
* Add the intrinsic __builtin_convertvectorHal Finkel2013-09-181-0/+1
| | | | | | | | | | | | | | | | | | LLVM supports applying conversion instructions to vectors of the same number of elements (fptrunc, fptosi, etc.) but there had been no way for a Clang user to cause such instructions to be generated when using builtin vector types. C-style casting on vectors is already defined in terms of bitcasts, and so cannot be used for these conversions as well (without leading to a very confusing set of semantics). As a result, this adds a __builtin_convertvector intrinsic (patterned after the OpenCL __builtin_astype intrinsic). This is intended to aid the creation of vector intrinsic headers that create generic IR instead of target-dependent intrinsics (in other words, this is a generic _mm_cvtepi32_ps). As noted in the documentation, the action of __builtin_convertvector is defined in terms of the action of a C-style cast on each vector element. llvm-svn: 190915
* Handle predefined expression for a captured statementWei Pan2013-08-261-0/+10
| | | | | | | | | | | - __func__ or __FUNCTION__ returns captured statement's parent function name, not the one compiler generated. Differential Revision: http://llvm-reviews.chandlerc.com/D1491 Reviewed by bkramer llvm-svn: 189219
* Constify the ASTContext& passed to Expr creation functions. Also constify ↵Craig Topper2013-08-221-18/+18
| | | | | | the context in couple other functions that are called from creation functions. llvm-svn: 188985
* Sema: Use the right type for PredefinedExpr when it's in a lambda.Benjamin Kramer2013-08-211-1/+12
| | | | | | | | | | | | | 1. We now print the return type of lambdas and return type deduced functions as "auto". Trailing return types with decltype print the underlying type. 2. Use the lambda or block scope for the PredefinedExpr type instead of the parent function. This fixes PR16946, a strange mismatch between type of the expression and the actual result. 3. Verify the type in CodeGen. 4. The type for blocks is still wrong. They are numbered and the name is not known until CodeGen. llvm-svn: 188900
* Make expression allocation methods use a 'const' reference to the ASTContext ↵Craig Topper2013-08-181-42/+46
| | | | | | since the underlying operator new only needs a const reference. llvm-svn: 188636
OpenPOWER on IntegriCloud