summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ExprConstant.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Remove some dead variables clang-analyzer found.Benjamin Kramer2009-12-251-2/+0
| | | | llvm-svn: 92162
* Update for the intrinsic changes in llvm: the object size intrinsicEric Christopher2009-12-231-1/+2
| | | | | | | only takes a boolean second argument now. Update tests accordingly. Currently the builtin still accepts the full range for compatibility. llvm-svn: 91983
* Use StringRef.getAsInteger instead of temporary string + strtol. No intended ↵Benjamin Kramer2009-12-111-9/+3
| | | | | | functionality change. llvm-svn: 91118
* Clean up enum constants so that they're finally sane. Fixes PR3173 and aEli Friedman2009-12-101-10/+2
| | | | | | recently introduced crash. llvm-svn: 91070
* Fix for PR5447: teach Evaluate to deal with floating-point conditionals.Eli Friedman2009-12-041-2/+10
| | | | llvm-svn: 90521
* Add recursion guards to ice-checking and evaluation for declrefs, so weEli Friedman2009-12-031-4/+13
| | | | | | don't infinitely recurse for cases we can't evaluate. llvm-svn: 90480
* Remove VISIBILITY_HIDDEN from lib/AST.Benjamin Kramer2009-11-281-8/+7
| | | | llvm-svn: 90043
* Teach Evaluate to handle member expressions referring to enum constants andEli Friedman2009-11-241-8/+21
| | | | | | | | static member constants. No significant visible difference at the moment because it conservatively assumes the base has side effects. I'm planning to use this for CodeGen. llvm-svn: 89738
* Intercept sizeof and alignof references before they get into ASTContext ↵Sebastian Redl2009-11-231-2/+16
| | | | | | methods. This fixes a crash when writing sizeof(Incomplete&), and lets ASTContext's methods do the right thing for CodeGen, which fixes PR5590. llvm-svn: 89668
* Add constant evaluation for comma operator with floating-point operand. FixesEli Friedman2009-11-161-1/+13
| | | | | | PR5449. llvm-svn: 88885
* Added support for static variables which requireFariborz Jahanian2009-11-051-8/+7
| | | | | | initialization before main. Fixes pr5396. llvm-svn: 86145
* Refine volatile handling, specifically, we must have the canonicalMike Stump2009-11-031-2/+2
| | | | | | | type to look at the volatile specifier. I found these all from just hand auditing the code. llvm-svn: 85967
* silence a warning.Chris Lattner2009-11-031-1/+1
| | | | llvm-svn: 85931
* When determining whether a reference to a static data member is anDouglas Gregor2009-11-011-6/+10
| | | | | | | | | integral constant expression, make sure to find where the initializer was provided---inside or outside the class definition---since that can affect whether we have an integral constant expression (and, we need to see the initializer itself). llvm-svn: 85741
* Fix one more bug with __builtin_object_size.Mike Stump2009-10-291-1/+1
| | | | llvm-svn: 85538
* Fix some issues Daniel pointed out.Mike Stump2009-10-291-3/+4
| | | | llvm-svn: 85526
* optimize out some ifdefs.Chris Lattner2009-10-291-4/+0
| | | | llvm-svn: 85453
* Implement clang support for indirect branch and address of labelChris Lattner2009-10-281-0/+5
| | | | | | | | using the new LLVM support for this. This is temporarily hiding behind horrible and ugly #ifdefs until the time when the optimizer is stable (hopefully a week or so). Until then, lets make it "opt in" :) llvm-svn: 85446
* Refine __builtin_object_size. Don't try and get a size for thingsMike Stump2009-10-281-7/+12
| | | | | | that don't have sizes. llvm-svn: 85435
* __builtin_object_size refinements. Ensure we handle expressions withMike Stump2009-10-271-2/+62
| | | | | | | | | | side-effects up front, as when we switch to the llvm intrinsic call for __builtin_object_size later, it will have two evaluations. We also finish off the intrinsic version of the code so we can just turn it on once llvm has the intrinsic. llvm-svn: 85324
* __builtin_object_size refinements. Also handle stack based objects. WIP.Mike Stump2009-10-261-1/+28
| | | | llvm-svn: 85174
* __builtin_object_size refinements. When we run out of object, be sureMike Stump2009-10-261-1/+5
| | | | | | to clamp at 0 bytes left. WIP. llvm-svn: 85157
* Be sure to zero-extend. And refactor.Mike Stump2009-10-261-6/+1
| | | | llvm-svn: 85140
* __builtin_object_size refinements. WIP.Mike Stump2009-10-261-0/+30
| | | | llvm-svn: 85136
* Ignore No-op casts when evaluating lvalue expressions. Fixes PR5122.Anders Carlsson2009-10-031-0/+10
| | | | llvm-svn: 83267
* Refactor the representation of qualifiers to bring ExtQualType out of theJohn McCall2009-09-241-1/+1
| | | | | | | | Type hierarchy. Demote 'volatile' to extended-qualifier status. Audit our use of qualifiers and fix a few places that weren't dealing with qualifiers quite right; many more remain. llvm-svn: 82705
* implement support for __builtin_eh_return_data_regno on x86-32 and x86-64.Chris Lattner2009-09-231-0/+6
| | | | | | This implements PR5034 and rdar://6836445. llvm-svn: 82614
OpenPOWER on IntegriCloud