aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/ExprConstant.cpp
AgeCommit message (Collapse)Author
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
2009-02-19More codegen for blocks. The type of block literals should be better.Mike Stump
The size calculation is improved. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64994 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18Codegen for int (^bp)(int) = 0;Mike Stump
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64951 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-17Rename UnaryTypeTraitExpr::Evaluate to EvaluateTrait to not collideDaniel Dunbar
with Expr::Evaluate(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64850 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-17Eek! getDeclAlign sometimes returned alignment in bits.Daniel Dunbar
- Renamed to getDeclAlignInBytes since most other query functions work in bits. - Fun to track down as isIntegerConstantExpr was getting it right, but Evaluate() was getting it wrong. Maybe we should assert they compute the same thing when they succeed? git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64828 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-17Renamed ASQualType to ExtQualType to reflect its moreFariborz Jahanian
general use; as for, objc2's gc type attributes. No change in functionality. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64778 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-14Add hook to add attributes to function declarations that we knowDouglas Gregor
about, whether they are builtins or not. Use this to add the appropriate "format" attribute to NSLog, NSLogv, asprintf, and vasprintf, and to translate builtin attributes (from Builtins.def) into actual attributes on the function declaration. Use the "printf" format attribute on function declarations to determine whether we should do format string checking, rather than looking at an ad hoc list of builtins and "known" function names. Be a bit more careful about when we consider a function a "builtin" in C++. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64561 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-08Teach the constant evaluator about C++ const integral variables.Sebastian Redl
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64086 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-29Evaluate ==,!= for complex types.Daniel Dunbar
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63280 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-29Evaluate casts to complex.Daniel Dunbar
- Lift (int,float) -> (int,float) conversion into separate routines. - Fix handling of, e.g., char -> _Complex int, which was producing a _Complex char value instead. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63278 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-29move library-specific diagnostic headers into library private dirs. ReduceChris Lattner
redundant #includes. Patch by Anders Johnsen! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63271 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-29Add folding for complex mul and fix some major bugs in complex floatDaniel Dunbar
evaluation (alternate part of real/imag init was being set to 3 not 0 because the wrong APFloat constructor was being called). - Test cases coming once some more support is in. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63264 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-28Implement basic _Complex integer constant folding.Daniel Dunbar
- Merged into single ComplexEvaluator, these share too much logic to be worth splitting for float/int (IMHO). Will split on request. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63248 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-27Split the single monolithic DiagnosticKinds.def file into oneChris Lattner
.def file for each library. This means that adding a diagnostic to sema doesn't require all the other libraries to be rebuilt. Patch by Anders Johnsen! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63111 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-25Make the constant folder aware of Eli Friedman
__builtin___CFStringMakeConstantString. (We get into trouble in GenerateStaticBlockVarDecl if the constant folder isn't accurate.) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62949 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-25Fix the address of a label to be properly considered and emitted as aEli Friedman
constant. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62948 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-24Refactor sizeof handling to use constant folding logic for constant Eli Friedman
sizeof expressions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62941 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-24add initial support for the gcc "alignof(decl) is the alignment of the declChris Lattner
not the type" semantics. This can definitely be improved, but is better than what we had. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62939 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-24Improve handling of alignof. alignof(VLA) now works properly for example.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62932 91177308-0d34-0410-b5e6-96231b3b80d8