summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Expr.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Properly track l-paren of a CXXFucntionalCastExpr.Eli Friedman2013-08-151-1/+1
| | | | | | | | | | In addition to storing more useful information in the AST, this fixes a semantic check in template instantiation which checks whether the l-paren location is valid. Fixes PR16903. llvm-svn: 188495
* report unused-value warning also for warn_unused typesLubos Lunak2013-07-211-1/+10
| | | | llvm-svn: 186793
* Make IgnoreParens() look through ChooseExprs.Eli Friedman2013-07-201-74/+25
| | | | | | | | | | | | | This is the same way GenericSelectionExpr works, and it's generally a more consistent approach. A large part of this patch is devoted to caching the value of the condition of a ChooseExpr; it's needed to avoid threading an ASTContext into IgnoreParens(). Fixes <rdar://problem/14438917>. llvm-svn: 186738
* Fix another place where clang check objc selector name instead of checking ↵Jean-Daniel Dupas2013-07-191-3/+1
| | | | | | | | | | | | the selector family Summary: In ARC mode, clang emits a warning if the result of an 'init' method is unused but miss cases where the method does not follows the Cocoa naming convention but is properly declared as an init family method. CC: cfe-commits, eli.friedman Differential Revision: http://llvm-reviews.chandlerc.com/D1163 llvm-svn: 186718
* Make Expr::isConstantInitializer match IRGen.Eli Friedman2013-07-161-45/+69
| | | | | | | | | | Sema needs to be able to accurately determine what will be emitted as a constant initializer and what will not, so we get accurate errors in C and accurate -Wglobal-constructors warnings in C++. This makes Expr::isConstantInitializer match CGExprConstant as closely as possible. llvm-svn: 186464
* PR16263: Implement current direction of core issue 1376. Binding a reference toRichard Smith2013-06-151-2/+2
| | | | | | | | | | | the result of a cast-to-reference-type lifetime-extends the object to which the reference inside the cast binds. This requires us to look for subobject adjustments on both the inside and the outside of the MaterializeTemporaryExpr when looking for a temporary to lifetime-extend (which we also need for core issue 616, and possibly 1213). llvm-svn: 184024
* Implement core issue 903: only integer literals with value 0 and prvalues ofRichard Smith2013-06-131-8/+9
| | | | | | type std::nullptr_t are null pointer constants from C++11 onwards. llvm-svn: 183883
* PR12086, PR15117Richard Smith2013-06-121-1/+1
| | | | | | | | | | | | | | | | | | | Introduce CXXStdInitializerListExpr node, representing the implicit construction of a std::initializer_list<T> object from its underlying array. The AST representation of such an expression goes from an InitListExpr with a flag set, to a CXXStdInitializerListExpr containing a MaterializeTemporaryExpr containing an InitListExpr (possibly wrapped in a CXXBindTemporaryExpr). This more detailed representation has several advantages, the most important of which is that the new MaterializeTemporaryExpr allows us to directly model lifetime extension of the underlying temporary array. Using that, this patch *drastically* simplifies the IR generation of this construct, provides IR generation support for nested global initializer_list objects, fixes several bugs where the destructors for the underlying array would accidentally not get invoked, and provides constant expression evaluation support for std::initializer_list objects. llvm-svn: 183872
* Do not walk through member-accesses on bitfields when looking for the objectRichard Smith2013-06-031-3/+5
| | | | | | | | which is lifetime-extended by a reference binding. An additional temporary is created for such a bitfield access (although we have no explicit AST representation for it). llvm-svn: 183095
* Fix handling of pointers-to-members and comma expressions whenRichard Smith2013-06-031-3/+8
| | | | | | lifetime-extending temporaries in reference bindings. llvm-svn: 183089
* Use only explicit bool conversion operatorDavid Blaikie2013-05-151-1/+1
| | | | | | | | | | | | | | | | | | | The most common (non-buggy) case are where such objects are used as return expressions in bool-returning functions or as boolean function arguments. In those cases I've used (& added if necessary) a named function to provide the equivalent (or sometimes negative, depending on convenient wording) test. DiagnosticBuilder kept its implicit conversion operator owing to the prevalent use of it in return statements. One bug was found in ExprConstant.cpp involving a comparison of two PointerUnions (PointerUnion did not previously have an operator==, so instead both operands were converted to bool & then compared). A test is included in test/SemaCXX/constant-expression-cxx1y.cpp for the fix (adding operator== to PointerUnion in LLVM). llvm-svn: 181869
* Allocate memory for the new number of subexpressions. Fixup for r181572Dmitri Gribenko2013-05-101-1/+1
| | | | llvm-svn: 181611
* ArrayRef'ize ShuffleVectorExpr::setExprsDmitri Gribenko2013-05-101-4/+3
| | | | | | But ShuffleVectorExpr should be tail-allocating the storage for expressions. llvm-svn: 181572
* Grab-bag of bit-field fixes:John McCall2013-05-061-3/+8
| | | | | | | | | | | | | | - References to ObjC bit-field ivars are bit-field lvalues; fixes rdar://13794269, which got me started down this. - Introduce Expr::refersToBitField, switch a couple users to it where semantically important, and comment the difference between this and the existing API. - Discourage Expr::getBitField by making it a bit longer and less general-sounding. - Lock down on const_casts of bit-field gl-values until we hear back from the committee as to whether they're allowed. llvm-svn: 181252
* C++1y constexpr extensions, round 1: Allow most forms of declaration andRichard Smith2013-04-221-1/+1
| | | | | | | | statement in constexpr functions. Everything which doesn't require variable mutation is also allowed as an extension in C++11. 'void' becomes a literal type to support constexpr functions which return 'void'. llvm-svn: 180022
* C++1y: Allow aggregates to have default initializers.Richard Smith2013-04-201-2/+24
| | | | | | | | | | | Add a CXXDefaultInitExpr, analogous to CXXDefaultArgExpr, and use it both in CXXCtorInitializers and in InitListExprs to represent a default initializer. There's an additional complication here: because the default initializer can refer to the initialized object via its 'this' pointer, we need to make sure that 'this' points to the right thing within the evaluation. llvm-svn: 179958
* Basic support for Microsoft property declarations andJohn McCall2013-04-161-0/+1
| | | | | | | | references thereto. Patch by Tong Shen! llvm-svn: 179585
* Add streamed versions of getQualifiedNameAsString.Benjamin Kramer2013-02-231-1/+2
| | | | | | Move the cold virtual method getNameForDiagnostic out of line. llvm-svn: 175966
* Excise <cctype> from Clang (except clang-tblgen) in favor of CharInfo.h.Jordan Rose2013-02-081-1/+2
| | | | | | | Nearly all of these changes are one-to-one replacements; the few that aren't have to do with custom identifier validation. llvm-svn: 174768
* Use const visitors in ASTDumper.Alexander Kornienko2013-02-011-1/+1
| | | | | | | http://llvm-reviews.chandlerc.com/D355 Patch by Philip Craig! llvm-svn: 174171
* Constify some getters of DesignatedInitExprDmitri Gribenko2013-01-261-6/+9
| | | | llvm-svn: 173574
* Switch to APFloat constructor taking fltSemantics.Tim Northover2013-01-221-4/+37
| | | | | | | | This change also makes the serialisation store the required semantics, fixing an issue where PPC128 was always assumed when re-reading a 128-bit value. llvm-svn: 173139
* Implement OpenCL event_t as Clang builtin type, including event_t related ↵Guy Benyei2013-01-201-0/+3
| | | | | | OpenCL restrictions (OpenCL 1.2 spec 6.9) llvm-svn: 172973
* Some builtins do not evaluate their arguments. Teach EvaluatedExprVisitor notRichard Smith2013-01-171-0/+6
| | | | | | to visit them. llvm-svn: 172769
OpenPOWER on IntegriCloud