|
| 1 | +/** |
| 2 | + * A module for representing names from the C and C++ Standard Library. |
| 3 | + */ |
| 4 | + |
| 5 | +import cpp |
| 6 | + |
| 7 | +/** |
| 8 | + * Holds if the given standard defines the given macro in the given namespace. |
| 9 | + */ |
| 10 | +extensible predicate libraryMacroModel( |
| 11 | + string standard, string header, string name, string parameters |
| 12 | +); |
| 13 | + |
| 14 | +/** |
| 15 | + * Holds if the given standard defines the given type in the given namespace. |
| 16 | + */ |
| 17 | +extensible predicate libraryTypeModel(string standard, string header, string namespace, string name); |
| 18 | + |
| 19 | +/** |
| 20 | + * Holds if the given standard defines the object or value name in the given namespace. |
| 21 | + */ |
| 22 | +extensible predicate libraryObjectModel( |
| 23 | + string standard, string header, string namespace, string name, string type, string linkage |
| 24 | +); |
| 25 | + |
| 26 | +/** |
| 27 | + * Holds if the given standard defines the function name in the given namespace. |
| 28 | + */ |
| 29 | +extensible predicate libraryFunctionModel( |
| 30 | + string standard, string header, string namespace, string declaringType, string name, |
| 31 | + string return_signature, string parameter_signature, string linkage |
| 32 | +); |
| 33 | + |
| 34 | +/** |
| 35 | + * Holds if the given standard defines the given member variable in the given declaring type and namespace. |
| 36 | + */ |
| 37 | +extensible predicate libraryMemberVariableModel( |
| 38 | + string standard, string header, string namespace, string declaringType, string name, string type |
| 39 | +); |
| 40 | + |
| 41 | +signature module StandardLibrary { |
| 42 | + string getName(); |
| 43 | + |
| 44 | + default predicate hasMacroName(string header, string name, string parameters) { |
| 45 | + libraryMacroModel(getName(), header, name, parameters) |
| 46 | + } |
| 47 | + |
| 48 | + default predicate hasTypeName(string header, string namespace, string name) { |
| 49 | + libraryTypeModel(getName(), header, namespace, name) |
| 50 | + } |
| 51 | + |
| 52 | + default predicate hasObjectName( |
| 53 | + string header, string namespace, string name, string type, string linkage |
| 54 | + ) { |
| 55 | + libraryObjectModel(getName(), header, namespace, name, type, linkage) |
| 56 | + } |
| 57 | + |
| 58 | + default predicate hasFunctionName( |
| 59 | + string header, string namespace, string declaringType, string name, string return_signature, |
| 60 | + string parameter_signature, string linkage |
| 61 | + ) { |
| 62 | + libraryFunctionModel(getName(), header, namespace, declaringType, name, return_signature, |
| 63 | + parameter_signature, linkage) |
| 64 | + } |
| 65 | +} |
| 66 | + |
| 67 | +module CStandardLibrary { |
| 68 | + module C99 implements StandardLibrary { |
| 69 | + string getName() { result = "C99" } |
| 70 | + } |
| 71 | + |
| 72 | + module C11 implements StandardLibrary { |
| 73 | + string getName() { result = "C11" } |
| 74 | + } |
| 75 | +} |
| 76 | + |
| 77 | +module CppStandardLibrary { |
| 78 | + module Cpp14 implements StandardLibrary { |
| 79 | + string getName() { result = "C++14" } |
| 80 | + } |
| 81 | +} |
0 commit comments