C++: Add constexpr support for functions

This commit is contained in:
Ian Lynagh
2019-01-25 11:43:23 +00:00
parent 5db38ef14b
commit 4bd03d52f1

View File

@@ -103,6 +103,27 @@ class Function extends Declaration, ControlFlowNode, AccessHolder, @function {
function_defaulted(underlyingElement(this))
}
/**
* Holds if this function is declared to be `constexpr`.
*/
predicate isDeclaredConstexpr() {
this.hasSpecifier("declared_constexpr")
}
/**
* Holds if this function is `constexpr`. Normally, this holds if and
* only if `isDeclaredConstexpr()` holds, but in some circumstances
* they differ. For example, with
* ```
* int f(int i) { return 6; }
* template <typename T> constexpr int g(T x) { return f(x); }
* ```
* `g<int>` is declared constexpr, but is not constexpr.
*/
predicate isConstexpr() {
this.hasSpecifier("is_constexpr")
}
/**
* Holds if this function is declared with `__attribute__((naked))` or
* `__declspec(naked)`.