Changeset 8f557161 for src/Common/Eval.h


Ignore:
Timestamp:
Jun 13, 2023, 4:33:16 PM (13 months ago)
Author:
Michael Brooks <mlbrooks@…>
Branches:
master
Children:
5668740, fec8bd1
Parents:
576aadb
Message:

Clarify and fix accuracy in eval public API, on reporting "unable to evaluate."

While the eval internals always used the flag pair valid and cfavalid almost correctly, the public interface exposed the outcome as a single flag, and the various interpretations of this flag were a mess.

Old cfacc treated sizeof(whatever) in some contexts as "known to be zero," which is wrong.
The generally correct answer, which new cfacc now uses is, "unknown now, but GCC will see it as a fine constant."
New tests/eval.cfa captures this fact: is runnable and would fail on old cfacc; it passes with new cfacc.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Common/Eval.h

    r576aadb r8f557161  
    2323}
    2424
     25struct Evaluation {
     26        long long int knownValue;
     27        bool hasKnownValue;
     28        bool isEvaluableInGCC;
     29};
     30
    2531/// Evaluates expr as a long long int.
    2632/// If second is false, expr could not be evaluated.
    2733std::pair<long long int, bool> eval(const Expression * expr);
    28 std::pair<long long int, bool> eval(const ast::Expr * expr);
     34Evaluation eval(const ast::Expr * expr);
    2935
    3036// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.