C++: upgrade script for member_function_this_type

This commit is contained in:
Nick Rolfe
2020-06-25 15:10:34 +01:00
committed by Nick Rolfe
parent 3b15d39ec6
commit ca25971955
4 changed files with 4269 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
/*
* Upgrade script to populate the member_function_this_type table. It's a rough
* approximation of what the extractor would do - for a member function C::f,
* we say its type is C* (if that pointer type exists in the database).
* CV-qualifiers are ignored.
*/
class Class extends @usertype {
Class() {
usertypes(this, _, 1) or
usertypes(this, _, 2) or
usertypes(this, _, 3) or
usertypes(this, _, 6) or
usertypes(this, _, 10) or
usertypes(this, _, 11) or
usertypes(this, _, 12)
}
string toString() { usertypes(this, result, _) }
}
class ClassPointerType extends @derivedtype {
ClassPointerType() { derivedtypes(this, _, 1, _) }
Class getBaseType() { derivedtypes(this, _, _, result) }
string toString() { result = getBaseType().toString() + "*" }
}
class DefinedMemberFunction extends @function {
DefinedMemberFunction() {
exists(@fun_decl fd |
fun_def(fd) and
(
fun_decls(fd, this, _, _, _)
or
exists(@function f | function_instantiation(this, f) and fun_decls(fd, f, _, _, _))
)
)
}
ClassPointerType getTypeOfThis() { member(result.getBaseType(), _, this) }
string toString() { functions(this, result, _) }
}
from DefinedMemberFunction f
select f, f.getTypeOfThis()

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,3 @@
description: Add table relating a member function to the type of `this`.
compatibility: partial
member_function_this_type.rel: run member_function_this_type.qlo