C++: Allow querying for "C" language linkage on routine types.

This commit is contained in:
Alexandre Boulgakov
2021-08-17 16:33:30 +01:00
parent 21d03cd365
commit 3ba308a69f
7 changed files with 29 additions and 0 deletions

View File

@@ -1621,6 +1621,19 @@ class RoutineType extends Type, @routinetype {
*/
Type getReturnType() { routinetypes(underlyingElement(this), unresolveElement(result)) }
/**
* Holds if this function type has "C" language linkage.
*
* This includes any function declared in a C source file, or explicitly marked as having "C" linkage:
* ```
* extern "C" void f();
* extern "C" {
* void g();
* }
* ```
*/
predicate hasCLinkage() { this.hasSpecifier("c_linkage") }
override string explain() {
result =
"function returning {" + this.getReturnType().explain() + "} with arguments (" +