summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ExprConstant.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Support strlen() and __builtin_strlen() as constant expressions withDouglas Gregor2010-09-101-0/+18
| | | | | | | the call argument is a string literal. Fixes <rdar://problem/8413477>. llvm-svn: 113580
* Fix warnings caused by new CXXUuidofExprClass enumerator.Francois Pichet2010-09-081-0/+1
| | | | llvm-svn: 113444
* Get rid of unnecessary return.Eli Friedman2010-09-061-1/+0
| | | | llvm-svn: 113132
* PR7242: Make sure to use a different context for evaluating constantEli Friedman2010-09-061-1/+4
| | | | | | | | initializers, so the result of the evaluation doesn't leak through inconsistently. Also, don't evaluate references to variables with initializers with side-effects. llvm-svn: 113128
* Eliminate CXXBindReferenceExpr, which was used in a ton ofDouglas Gregor2010-09-021-1/+0
| | | | | | well-intentioned but completely unused code. llvm-svn: 112868
* Revert my user-defined literal commits - r1124{58,60,67} pendingAlexis Hunt2010-08-301-2/+1
| | | | | | some issues being sorted out. llvm-svn: 112493
* Implement C++0x user-defined string literals.Alexis Hunt2010-08-291-1/+2
| | | | | | | | | | The extra data stored on user-defined literal Tokens is stored in extra allocated memory, which is managed by the PreprocessorLexer because there isn't a better place to put it that makes sure it gets deallocated, but only after it's used up. My testing has shown no significant slowdown as a result, but independent testing would be appreciated. llvm-svn: 112458
* GCC didn't care for my attempt at API compatibility, so brute-force everythingJohn McCall2010-08-251-116/+116
| | | | | | to the new constants. llvm-svn: 112047
* Move a bunch of code out of the ComplexExprEvaluator class definition;Eli Friedman2010-08-161-105/+109
| | | | | | no functionality change. llvm-svn: 111207
* PR7884: Fix the implementations of __real__ and __imag__ on real floats.Eli Friedman2010-08-141-9/+21
| | | | llvm-svn: 111080
* Zap unused UnaryOperator::OffsetOf.Eli Friedman2010-08-131-15/+0
| | | | llvm-svn: 110996
* Get rid of isObjectType; when C++ says "object type", it generallyEli Friedman2010-08-051-1/+1
| | | | | | | just means "not a function type", not "not a function type or void". This changes behavior slightly, but generally in a way which accepts more code. llvm-svn: 110303
* Fix namespace polution.Dan Gohman2010-07-261-1/+5
| | | | llvm-svn: 109440
* Introduce a new cast kind for an "lvalue bitcast", which handlesDouglas Gregor2010-07-131-0/+1
| | | | | | | | | | | | | | | | reinterpret_casts (possibly indirectly via C-style/functional casts) on values, e.g., int i; reinterpret_cast<short&>(i); The IR generated for this is essentially the same as for *reinterpret_cast<short*>(&i). Fixes PR6437, PR7593, and PR7344. llvm-svn: 108294
* Reinstate the fix for PR7556. A silly use of isTrivial() wasDouglas Gregor2010-07-081-4/+4
| | | | | | suppressing copies of objects with trivial copy constructors. llvm-svn: 107857
* Revert r107828 and r107827, the fix for PR7556, which seems to beDouglas Gregor2010-07-071-4/+4
| | | | | | breaking bootstrap on Linux. llvm-svn: 107837
* Rename CXXZeroInitValueExpr to CXXScalarValueInitExpr, to reflect itsDouglas Gregor2010-07-071-4/+4
| | | | | | newly-narrowed scope. No functionality change. llvm-svn: 107828
* Don't consider casted non-global pointers to be evaluatable.John McCall2010-07-071-0/+2
| | | | | | Fixes rdar://problem/8154689 llvm-svn: 107755
* Introduce Type::isIntegralOrEnumerationType(), to cover those placesDouglas Gregor2010-06-161-14/+17
| | | | | | | | | | in C++ that involve both integral and enumeration types. Convert all of the callers to Type::isIntegralType() that are meant to work with both integral and enumeration types over to Type::isIntegralOrEnumerationType(), to prepare to eliminate enumeration types as integral types. llvm-svn: 106071
* Fix the constant evaluator for AltiVec-style vector literals so that theJohn McCall2010-06-111-13/+34
| | | | | | | vector is filled with the given constant; we were just initializing the first element. llvm-svn: 105824
* When constant folding reference variables with an initializer to theChandler Carruth2010-05-161-0/+4
| | | | | | | | initializer, don't fold paramters. Their initializers are just default arguments which can be overridden. This fixes some spectacular regressions due to more things making it into the constant folding. llvm-svn: 103904
* Added Expr::EvaluateAsAnyLValue.Abramo Bagnara2010-05-141-5/+21
| | | | llvm-svn: 103780
* Refactor the constant-evaluator so that it only supports a single formJohn McCall2010-05-101-62/+80
| | | | | | | | | of constant-evaluation. Formerly you could control whether it accepted local l-values or not; now it always evaluates local l-values in the core routines, but filters them out where consumed by the top-level routines. This will make it much easier to cache evaluability. llvm-svn: 103444
* The FP constant evaluator was missing a few cases of unary operators that ↵John McCall2010-05-071-2/+20
| | | | | | | | | | | return floats but whose operand isn't a float: specifically, __real__ and __imag__. Instead of filtering these out, just implement them. Fixes <rdar://problem/7958272>. llvm-svn: 103307
* Make that null-dereference fix a little clearer by rearranging some code.John McCall2010-05-071-2/+14
| | | | llvm-svn: 103298
* Fix a potential null dereference in the pointer-to-bool evaluator; caught byJohn McCall2010-05-071-1/+1
| | | | | | Eli Friedman. llvm-svn: 103297
* Change the pointer / lvalue constant evaluators to build into a target referenceJohn McCall2010-05-071-205/+199
| | | | | | and return a bool. llvm-svn: 103296
* Change the complex constant evaluator to return a bool instead of an APValue.John McCall2010-05-071-102/+138
| | | | llvm-svn: 103268
* Fix PR4386 by implementing gcc's old behaviour (4.2) when initializingRafael Espindola2010-05-071-3/+14
| | | | | | variables with a comparison of a function pointer with 0. llvm-svn: 103253
* Change Evaluate* in the constant evaluator to enforce being given an argument ofJohn McCall2010-05-071-5/+6
| | | | | | the right type. It turns out that the code was already doing this. llvm-svn: 103238
* Move CheckICE and isIntegerConstantExpr to ExprConstant.cpp because it seemedJohn McCall2010-05-071-0/+379
| | | | | | like a good idea at the time. llvm-svn: 103237
* A not equal for an unordered relation should return true as specified in ↵Mon P Wang2010-04-291-3/+6
| | | | | | | | IEEE-754, e.g., NAN != NAN ? 1 : 0 should return 1. Also fix the case for complex. llvm-svn: 102598
* Teach __builtin_offsetof to compute the offsets of members of baseDouglas Gregor2010-04-291-5/+29
| | | | | | | | classes, since we only warn (not error) on offsetof() for non-POD types. We store the base path within the OffsetOfExpr itself, then evaluate the offsets within the constant evaluator. llvm-svn: 102571
* Completely reimplement __builtin_offsetof, based on a patch by RobertoDouglas Gregor2010-04-281-4/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Amadini. This change introduces a new expression node type, OffsetOfExpr, that describes __builtin_offsetof. Previously, __builtin_offsetof was implemented using a unary operator whose subexpression involved various synthesized array-subscript and member-reference expressions, which was ugly and made it very hard to instantiate as a template. OffsetOfExpr represents the AST more faithfully, with proper type source information and a more compact representation. OffsetOfExpr also has support for dependent __builtin_offsetof expressions; it can be value-dependent, but will never be type-dependent (like sizeof or alignof). This commit introduces template instantiation for __builtin_offsetof as well. There are two major caveats to this patch: 1) CodeGen cannot handle the case where __builtin_offsetof is not a constant expression, so it produces an error. So, to avoid regressing in C, we retain the old UnaryOperator-based __builtin_offsetof implementation in C while using the shiny new OffsetOfExpr implementation in C++. The old implementation can go away once we have proper CodeGen support for this case, which we expect won't cause much trouble in C++. 2) __builtin_offsetof doesn't work well with non-POD class types, particularly when the designated field is found within a base class. I will address this in a subsequent patch. Fixes PR5880 and a bunch of assertions when building Boost.Python tests. llvm-svn: 102542
* Introduce Type::isStructureOrClassType(), which does the obviousDouglas Gregor2010-04-261-1/+1
| | | | | | | | thing. Audit all uses of Type::isStructure(), changing those calls to isStructureOrClassType() as needed (which is alsmost everywhere). Fixes the remaining failure in Boost.Utility/Swap. llvm-svn: 102386
* remove some extraneous qualifiers.Chris Lattner2010-04-201-2/+2
| | | | llvm-svn: 101912
* Teach HasSideEffect about InitListExprs. Not havingChris Lattner2010-04-131-0/+7
| | | | | | | | | | | | | this caused us to codegen dead globals like this: struct foo { int a; int b; }; static struct foo fooarray[] = { {1, 2}, {4}, }; llvm-svn: 101150
* Evaluate: Fix a subtle bug in the pointer evaluator in which we would do anDaniel Dunbar2010-03-201-10/+17
| | | | | | | | expression computation in the wrong bit-width, and end up generating a totally bogus array reference (_g0+8589934546). - This showed up on Prolangs/cdecl. llvm-svn: 99042
* Support constant-evaluation of __builtin_nans* as well as the correct constantJohn McCall2010-02-281-13/+33
| | | | | | | | evaluation of __builtin_nan*. Most of the work to make this work is in LLVM. Fixes <rdar://problem/7696712> and part of PR 5255. llvm-svn: 97383
* Fix for PR6274: teach constant folding to evaluate __builtin_expect.Eli Friedman2010-02-131-2/+5
| | | | llvm-svn: 96054
* Don't try to fold DeclRefExprs that point to ParmVarDecls. This had the ↵Anders Carlsson2010-02-031-0/+4
| | | | | | | | | | | | | | side-effect of always folding the expression to the default argument of the parameter. For example: void f(int a = 10) { return a; } would always return 10, regardless of the passed in argument. This fixes another 600 test failures. We're now down to only 137 failures! llvm-svn: 95262
* In C++, an initializer on a variable doesn't necessarily mean it's the ↵Sebastian Redl2010-02-011-4/+2
| | | | | | definition. With that in mind, rename getDefinition to getAnyInitializer (to distinguish it from getInit) and reimplement it in terms of isThisDeclarationADefinition. Update all code to use this new function. llvm-svn: 94999
* Change the return type of ASTContext::getDeclAlignInBytes() to CharUnits and,Ken Dyck2010-01-271-10/+12
| | | | | | | now that the "InBytes" part of the name is implied by the return type, rename it to getDeclAlign(). llvm-svn: 94681
* Created __builtin___NSStringMakeConstantString() builtin, which generates ↵David Chisnall2010-01-231-1/+3
| | | | | | constant Objective-C strings. llvm-svn: 94274
* Update and move around comments.Eric Christopher2010-01-191-1/+4
| | | | llvm-svn: 93942
* Convert the type of the LValue offset variable in APValue to CharUnits, movingKen Dyck2010-01-151-35/+42
| | | | | | the LValue-related methods of APValue out of line to avoid header file leaching. llvm-svn: 93512
* Roll out ASTContext::getTypeSizeInChars(), replacing instances ofKen Dyck2010-01-111-17/+18
| | | | | | | | | | "ASTContext::getTypeSize() / 8". Replace [u]int64_t variables with CharUnits ones as appropriate. Also rename RawType, fromRaw(), and getRaw() in CharUnits to QuantityType, fromQuantity(), and getQuantity() for clarity. llvm-svn: 93153
* Add Expr::EvaluateAsBooleanCondition(), which does unprincipled folding toJohn McCall2010-01-051-1/+9
| | | | | | | try to evaluate an expression as a constant boolean condition. This has the same intended semantics as used in folding conditional operators. llvm-svn: 92805
* __builtin_object_size(ptr, type) returns -1 for type = {0,1} if there are ↵Benjamin Kramer2010-01-031-1/+1
| | | | | | any side-effects. llvm-svn: 92453
* Fix PointerExprEvaluator::VisitCastExpr so it doesn't misfold C++ casts whichEli Friedman2009-12-271-25/+42
| | | | | | it doesn't know how to fold, like derived-to-base casts. llvm-svn: 92173
OpenPOWER on IntegriCloud