aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/ExprConstant.cpp
AgeCommit message (Collapse)Author
2009-07-01Implement Eli's feedback for vecto constant expressions;Nate Begeman
For ExtVectorType, initializer is splatted to all elements. For VectorType, initializer is bitcast to vector type. Verified that for VectorType, output is identical to gcc. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74600 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-30De-ASTContext-ify DeclContext.Argyrios Kyrtzidis
Remove ASTContext parameter from DeclContext's methods. This change cascaded down to other Decl's methods and changes to call sites started "escalating". Timings using pre-tokenized "cocoa.h" showed only a ~1% increase in time run between and after this commit. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74506 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-26OpenCL 1.0 Support:Nate Begeman
Add support for scalar to vector and partially initialized vector constant initializers. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74299 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-14PR4351: Add constant evaluation for constructs like "foo == NULL", where Eli Friedman
foo has a constant address. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73321 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-14Sink the BuiltinInfo object from ASTContext into theChris Lattner
preprocessor and initialize it early in clang-cc. This ensures that __has_builtin works in all modes, not just when ASTContext is around. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73319 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-04Minor simplification.Eli Friedman
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72887 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-04PR4326: Handle constant evaluation for void* pointer subtraction Eli Friedman
correctly. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72886 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-30Some small fixes for fields of reference type.Eli Friedman
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72636 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-30Cleqnup ideas from Chris, thanks.Mike Stump
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72621 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-30Improve __builtin_nanf support; we now can deal with them as constants.Mike Stump
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72607 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-27Fix up constant expression handling to deal with the address Eli Friedman
of a reference correctly. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72463 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-26When evaluating a VarDecl as a constant or determining whether it isDouglas Gregor
an integral constant expression, maintain a cache of the value and the is-an-ICE flag within the VarDecl itself. This eliminates exponential-time behavior of the Fibonacci template metaprogram. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72428 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-10Implement C++0x nullptr.Sebastian Redl
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71405 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-03Remove an unneeded special case.Daniel Dunbar
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70689 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-30Properly compute the alignment of typedefs that make use of theDouglas Gregor
"aligned" attribute. Previously, we were skipping over these attributes when we jumped directly to the canonical type. Now, ASTContext::getTypeInfo walks through typedefs and other "non-canonical" types manually, looking for "aligned" attributes on typedefs. As part of this change, I moved the GNU-specific logic (such as determining the alignment of void or of a function pointer) out of the expression evaluator and into ASTContext::getTypeInfo. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70497 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-29Minor simplification; also silences gcc warning.Eli Friedman
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70406 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-28PR4097: add logic to Evaluate to handle pointer equality comparisons.Eli Friedman
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70317 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-22Add handling for complex->int, int->complex float, and float->complex Eli Friedman
int. Note that constant int->complex float and float->complex int casts were being miscompiled. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69821 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-21Use an ASTRecordLayout to compute the sizeof an interface, notDaniel Dunbar
addRecordToClass. - Among other things, this fixes a crash when applying sizeof to an interface with synthesized ivars, although things still aren't "correct" here. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69675 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-16Fix <rdar://problem/6765383> clang-6: clang does not appear to support ↵Steve Naroff
declaring a static Block 'const'. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69306 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-10Add Expr::EvaluateAsLValue which will (believe it or not) try to evaluate an ↵Anders Carlsson
Expr as an LValue. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68763 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-09Propagate the ASTContext to various AST traversal and lookup functions.Douglas Gregor
No functionality change (really). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68726 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-30Slight generalization for Evaluate with const variables.Eli Friedman
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68075 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-24Fix PR3868 by making Evaluate handle cases like "(long)&a + 4".Eli Friedman
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67593 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-23Minor Evaluate cleanup; add some boilerplate implementations to Eli Friedman
Evaluate for __extension__ and __builtin_choose_expr. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67506 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-23Minor enhancements to Evaluate.Eli Friedman
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67503 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-16Almost complete implementation of rvalue references. One bug, and a few ↵Sebastian Redl
unclear areas. Maybe Doug can shed some light on some of the fixmes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67059 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-04Minor cleanup for choose expressions: add a helper that returns the Eli Friedman
chosen sub-expression, rather than just evaluating the condition. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66018 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-28Fix obvious shortcoming in the implementations of Evaluate for Eli Friedman
integer __real__ and __imag__. Not sure how I missed this. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65677 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-27Change the AST generated for offsetof a bit so that it looks like a Eli Friedman
normal expression, and change Evaluate and IRGen to evaluate it like a normal expression. This simplifies the code significantly, and fixes PR3396. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65622 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-27Some minor improvements to Evaluate.Eli Friedman
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65613 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-26Add Type::hasPointerRepresentation predicate.Daniel Dunbar
- For types whose native representation is a pointer. - Use to replace ExprConstant.cpp:HasPointerEvalType, CodeGenFunction::isObjCPointerType. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65569 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-26Remove short-circuit evaluation and the extension warnings. I'm Eli Friedman
pretty sure we want to keep constant expression verification outside of Evaluate. Because of that, the short-circuit evaluation doesn't generally make sense, and the comma warning doesn't make sense in its current form. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65525 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-24first wave of fixes for @encode sema support. This is part of PR3648.Chris Lattner
The big difference here is that (like string literal) @encode has array type, not pointer type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65391 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-23Revert http://llvm.org/viewvc/llvm-project?view=rev&revision=65244.Steve Naroff
Remove support for "Class<P>". Will be making this an error. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65332 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-23A few small improvements to Evaluate for stuff I noted in FIXMEs.Eli Friedman
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65305 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-22A bit of Evaluate cleanup. Also, a full audit of what's missing that Eli Friedman
someone would reasonably expect Evaluate to handle for C/ObjC. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65284 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-22Enhance Evaluate to handle ObjC qualified id and class types; as far as Eli Friedman
I know, these follow the exact same rules as pointers, so I just made them use the same codepath. Someone more familiar with ObjC should double-check this, though. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65261 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-22Fix for PR3433: map __alignof__ to preferred alignment. (This was Eli Friedman
partially done in r65258.) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65260 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-21Evaluation of unary deref could call integer evaluator on non-integralDaniel Dunbar
expr; hilarity ensued. - PR3640. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65234 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-20Handle constant int -> ptr casts of lvalue results.Daniel Dunbar
- PR3463 (again). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65133 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-20Add support for * (unary dereference) operator to ExprConstant.Eli Friedman
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65105 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-20ExprConstant handling for a couple more cases of pointer-to-int casts Eli Friedman
from the testsuite. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65098 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-19Extend Evaluate() to fold (int) <pointer type>.Daniel Dunbar
- PR3463, PR3398, <rdar://problem/6553401> crash on relocatable symbol addresses as constants in static locals. - There are many more scenarious we could handle (like arithmetic on such an int) but this is the main use case. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65074 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-19Simplify, no functionality change.Daniel Dunbar
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65073 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-19Add enough checking to ensure that non-constant block literals don'tMike Stump
appear to be constant. I'll probably redo this and throw it all away later once we have codegen for BlockDeclRefExprs. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65070 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-19Change IntExprEvaluator to operate on an APValue not an APSInt.Daniel Dunbar
- Prep for handling lvalues, no intended functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65063 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-19Add another IntExprEvaluator::Success overload to suck up remained ofDaniel Dunbar
manual setting of the Result. - Idiom now enforces that result will always have correct width and type; this exposed three new bugs: o Enum constant decl value can have different width than type (PR3173). o EvaluateInteger should not run an IntExprEvaluator over non-integral expressions. o FloatExprEvaluate was not handling casts correctly (it was evaluating the cast in the IntExprEvaluator!). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65053 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-19Add IntExprEvaluator::Success method.Daniel Dunbar
- Handles assignment to Result with appropriate type. - Simplifies & encapsulates most direct handling of the Result value; prep for allowing IntExprEvaluator to deal with LValue APValues. - No intended functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65038 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-19Handle the GNU void* and function pointer arithmetic extensions for constant ↵Anders Carlsson
expressions as well. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65013 91177308-0d34-0410-b5e6-96231b3b80d8