Hi, Attached here is the second of five patches for PR12850.
This patch is where all the main functionality resides. A new class, FunctionCache, has been created inside the lib/AST directory. This class implements two caches of previously evaluated constexpr functions according to their FunctionDecl* and evaluated arguments (as APValues). The two caches are divided into a global cache where the evaluation can be determined as valid across all evaluation contexts, and a local cache that is specific to the current evaluation context (see IsSupported). When a potentially cachable constexpr function is being evaluated, a marker will be inserted into the cache. Once the evaluation has been completed successfully, this marker is replaced with the resultant value of the evaluation. If this value itself is determined to be uncachable, or if the evaluation cannot be completed, the marker is removed completely from the cache. Additionally to this, now if a circular dependency is discovered, an error message can now be shown to the user. If, later, the same function is evaluated with the same evaluated parameters (and it was previously cached), the previously evaluated result can be pulled from the cache. In order to be sure that the parameters really are the same, firstly it must match the same hash value (see CalculateHash) and then the cached and current values are directly compared (see IsAPValueEqual). The comparison is intended to be on the conservative side so that cache misses should occur rather than invalid matches. For the majority of APValue kinds (i.e. Int, Float, ComplexInt, ComplexFloat, Vector, Array, Struct) the comparison is straight forward. For LValue it is more involved, since it must walk through the LValue path and additionally StringLiterals are handled as a special case so that two identical strings will still match. At the present time Union, AddrLabelDiff and MemberPointer kinds are *not* supported. Hopefully this gives enough detail to understand the code in the patch. I will be very willing to give more explanations to specific questions that come up... :o) Thanks Andy
part2.diff
Description: Binary data
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
