Commit Graph

28 Commits

Author SHA1 Message Date
David Blaikie 2d7c57ec1d Remove the ref/value inconsistency in filter_decl_iterator.
filter_decl_iterator had a weird mismatch where both op* and op-> returned T*
making it difficult to generalize this filtering behavior into a reusable
library of any kind.

This change errs on the side of value, making op-> return T* and op* return
T&.

(reviewed by Richard Smith)

llvm-svn: 155808
2012-04-30 02:36:29 +00:00
Richard Smith 5614ca7715 Teach APValue printer to print boolean 0 and 1 as 'false' and 'true'. Fix up
some calling code to actually pass in a non-null type, to avoid a crash.

llvm-svn: 153358
2012-03-23 23:55:39 +00:00
Richard Smith 4e9e523fcf Assign APValues by swapping from a temporary. Removes a bunch of unnecessary
copy-construction, which Daniel Dunbar reports as giving a 0.75% speedup on
403.gcc/combine.c. The performance differences on my constexpr torture tests
are below the noise floor.

llvm-svn: 152455
2012-03-10 00:28:11 +00:00
Daniel Dunbar b743157df3 [AST] APValue: Split the fast path of MakeUninit to be inline.
- This change seems to be a tiny loss on 403.gcc/combine.c (.2%), but I think
   it is the right thing to do.

llvm-svn: 152330
2012-03-08 20:28:55 +00:00
Richard Smith b228a86fcf Implement DR1454. This allows all intermediate results in constant expressions
to be core constant expressions (including pointers and references to
temporaries), and makes constexpr calculations Turing-complete. A Turing machine
simulator is included as a testcase.

This opens up the possibilty of removing CCValue entirely, and removing some
copies from the constant evaluator in the process, but that cleanup is not part
of this change.

llvm-svn: 150557
2012-02-15 02:18:13 +00:00
Eli Friedman fd5e54da2d Add an APValue representation for the difference between two address-of-label expressions. Add support to Evaluate and CGExprConstant for generating/handling them. Remove the special-case for such differences in Expr::isConstantInitializer.
With that done, remove a bunch of buggy code from CGExprConstant for handling scalar expressions which is no longer necessary.

Fixes PR11705.

llvm-svn: 147561
2012-01-04 23:13:47 +00:00
Eli Friedman 375f09f5bf Add missing flush call. This is an attempt to fix a broken Windows buildbot.
llvm-svn: 146760
2011-12-16 22:12:23 +00:00
Richard Smith f6f003af6a C++11 constexpr: Add note stacks containing backtraces if constant evaluation
fails within a call to a constexpr function. Add -fconstexpr-backtrace-limit
argument to driver and frontend, to control the maximum number of notes so
produced (default 10). Fix APValue printing to be able to pretty-print all
APValue types, and move the testing for this functionality from a unittest to
a -verify test now that it's visible in clang's output.

llvm-svn: 146749
2011-12-16 19:06:07 +00:00
Richard Smith 027bf11eb3 Constant expression evaluation: add support for evaluation of member pointers
and base-to-derived casts, and add proper handling of temporaries.

llvm-svn: 144926
2011-11-17 22:56:20 +00:00
Richard Smith ce40ad677e Represent an APValue based on a Decl as that Decl, rather than a DeclRefExpr
or MemberExpr which refers to it. As a side-effect, MemberExprs which refer to
static member functions and static data members are now emitted as constant
expressions.

llvm-svn: 144468
2011-11-12 22:28:03 +00:00
Richard Smith d62306a481 Constant expression evaluation: support for evaluation of structs and unions of
literal types, as well as derived-to-base casts for lvalues and
derived-to-virtual-base casts.

llvm-svn: 144265
2011-11-10 06:34:14 +00:00
Richard Smith f3e9e43da4 Constant expression evaluation: support for arrays.
llvm-svn: 143922
2011-11-07 09:22:26 +00:00
Richard Smith bcb4eb2813 Fix 32-bit build bots and remove some casting-away-const warnings.
llvm-svn: 143914
2011-11-07 07:31:09 +00:00
Richard Smith 8081560048 Constant expression evaluation: preserve subobject designator when flattening a
core constant value down to an APValue.

llvm-svn: 143909
2011-11-07 05:07:52 +00:00
Richard Smith 0b0a0b6174 constexpr function substitution:
Track the function invocation where an lvalue referring to a constexpr function
parameter originated from, and use it to substitute the correct argument and to
determine whether such an argument's lifetime has ended.

llvm-svn: 143296
2011-10-29 20:57:55 +00:00
David Blaikie 76bd3c80d4 Fix missing includes for llvm_unreachable
llvm-svn: 140368
2011-09-23 05:35:21 +00:00
David Blaikie 83d382b1ca Switch assert(0/false) llvm_unreachable.
llvm-svn: 140367
2011-09-23 05:06:16 +00:00
Chris Lattner 0e62c1cc0b remove unneeded llvm:: namespace qualifiers on some core types now that LLVM.h imports
them into the clang namespace.

llvm-svn: 135852
2011-07-23 10:55:15 +00:00
Jeffrey Yasskin d2af962eee Define DiagnosticBuilder<<APValue so it's easy to include APValues in
diagnostics.

llvm-svn: 135398
2011-07-18 16:43:53 +00:00
Peter Collingbourne e92006860d Refactoring of constant expression evaluator
This introduces a generic base class for the expression evaluator
classes, which handles a few common expression types which were
previously handled separately in each class.  Also, the expression
evaluator now uses ConstStmtVisitor.

llvm-svn: 131281
2011-05-13 03:29:01 +00:00
Dan Gohman 145f3f1e83 Fix -Wcast-qual warnings.
llvm-svn: 101786
2010-04-19 16:39:44 +00:00
Ken Dyck 02990837ad Convert the type of the LValue offset variable in APValue to CharUnits, moving
the LValue-related methods of APValue out of line to avoid header file leaching.

llvm-svn: 93512
2010-01-15 12:37:54 +00:00
Mike Stump 11289f4280 Remove tabs, and whitespace cleanups.
llvm-svn: 81346
2009-09-09 15:08:12 +00:00
Douglas Gregor 5b5559b272 Make sure to access APValue's data via a char array (rather than
through an array of void*), so that we don't run afoul of the
strict-aliasing rules in C++ 3.10p15. Unfortunately, GCC 4.4 still
complains about this code.

llvm-svn: 81251
2009-09-08 19:57:33 +00:00
Daniel Dunbar 4095d89532 Remove some now-unneeded calls to llvm::errs().flush().
llvm-svn: 66555
2009-03-10 18:00:19 +00:00
Nate Begeman 2f2bdeb5df Support evaluation of vector constant expressions, and codegen of same.
llvm-svn: 62455
2009-01-18 03:20:47 +00:00
Nate Begeman 1e31b168fa Add support for vectors to APValue. Vector constant evaluator and tests coming.
llvm-svn: 62438
2009-01-18 01:01:34 +00:00
Chris Lattner 981f33b0b6 add dump and print methods, add operator<< for APValue.
llvm-svn: 59411
2008-11-16 07:46:48 +00:00