summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ExprConstant.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Change all the Type::getAsFoo() methods to specializations of Type::getAs().John McCall2009-09-211-5/+5
| | | | | | | | | | | Several of the existing methods were identical to their respective specializations, and so have been removed entirely. Several more 'leaf' optimizations were introduced. The getAsFoo() methods which imposed extra conditions, like getAsObjCInterfacePointerType(), have been left in place. llvm-svn: 82501
* Codegen support for nullptr from C++0x.Anders Carlsson2009-09-151-1/+2
| | | | llvm-svn: 81835
* Add utility to evaluate lvalues which are an offset relative to a stack Eli Friedman2009-09-131-6/+16
| | | | | | location. Patch by Enea Zaffanella. llvm-svn: 81672
* Remove tabs, and whitespace cleanups.Mike Stump2009-09-091-112/+106
| | | | llvm-svn: 81346
* Get rid of mostly-unused, buggy method.Eli Friedman2009-08-291-3/+3
| | | | llvm-svn: 80432
* Change uses of:Ted Kremenek2009-07-291-4/+4
| | | | | | | | | | | | | | | | | | | | Type::getAsReferenceType() -> Type::getAs<ReferenceType>() Type::getAsRecordType() -> Type::getAs<RecordType>() Type::getAsPointerType() -> Type::getAs<PointerType>() Type::getAsBlockPointerType() -> Type::getAs<BlockPointerType>() Type::getAsLValueReferenceType() -> Type::getAs<LValueReferenceType>() Type::getAsRValueReferenceType() -> Type::getAs<RValueReferenceType>() Type::getAsMemberPointerType() -> Type::getAs<MemberPointerType>() Type::getAsReferenceType() -> Type::getAs<ReferenceType>() Type::getAsTagType() -> Type::getAs<TagType>() And remove Type::getAsReferenceType(), etc. This change is similar to one I made a couple weeks ago, but that was partly reverted pending some additional design discussion. With Doug's pending smart pointer changes for Types, it seemed natural to take this approach. llvm-svn: 77510
* This patch fixes the implementations of the __has_trivial_destructorDouglas Gregor2009-07-231-1/+1
| | | | | | | | and __has_trivial_constructor builtin pseudo-functions and additionally implements __has_trivial_copy and __has_trivial_assign, from John McCall! llvm-svn: 76916
* Revert r75641.Anders Carlsson2009-07-181-1/+1
| | | | llvm-svn: 76327
* Per offline discussion with Steve Naroff, add back Type::getAsXXXType() methodsTed Kremenek2009-07-171-4/+4
| | | | | | | | | until Doug Gregor's Type smart pointer code lands (or more discussion occurs). These methods just call the new Type::getAs<XXX> methods, so we still have reduced implementation redundancy. Having explicit getAsXXXType() methods makes it easier to set breakpoints in the debugger. llvm-svn: 76193
* Replaced Type::getAsLValueReferenceType(), Type::getAsRValueReferenceType(), ↵Ted Kremenek2009-07-171-1/+1
| | | | | | Type::getAsMemberPointerType(), Type::getAsTagType(), and Type::getAsRecordType() with their Type::getAs<XXX> equivalents. llvm-svn: 76139
* Add member template 'Type::getAs<T>', which converts a Type* to a respective T*.Ted Kremenek2009-07-161-3/+3
| | | | | | | | | | | | | | | | | | | | | This method is intended to eventually replace the individual Type::getAsXXXType<> methods. The motivation behind this change is twofold: 1) Reduce redundant implementations of Type::getAsXXXType() methods. Most of them are basically copy-and-paste. 2) By centralizing the implementation of the getAs<Type> logic we can more smoothly move over to Doug Gregor's proposed canonical type smart pointer scheme. Along with this patch: a) Removed 'Type::getAsPointerType()'; now clients use getAs<PointerType>. b) Removed 'Type::getAsBlockPointerTypE()'; now clients use getAs<BlockPointerType>. llvm-svn: 76098
OpenPOWER on IntegriCloud