Skip to content

Commit 972d86c

Browse files
committed
C++: Add column to mangled_name table with completeness information
1 parent a486481 commit 972d86c

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

cpp/ql/lib/semmle/code/cpp/internal/ResolveClass.qll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import semmle.code.cpp.Type
33
/** For upgraded databases without mangled name info. */
44
pragma[noinline]
55
private string getTopLevelClassName(@usertype c) {
6-
not mangled_name(_, _) and
6+
not mangled_name(_, _, _) and
77
isClass(c) and
88
usertypes(c, result, _) and
99
not namespacembrs(_, c) and // not in a namespace
@@ -17,7 +17,7 @@ private string getTopLevelClassName(@usertype c) {
1717
*/
1818
pragma[noinline]
1919
private predicate existsCompleteWithName(string name, @usertype d) {
20-
not mangled_name(_, _) and
20+
not mangled_name(_, _, _) and
2121
is_complete(d) and
2222
name = getTopLevelClassName(d) and
2323
onlyOneCompleteClassExistsWithName(name)
@@ -26,7 +26,7 @@ private predicate existsCompleteWithName(string name, @usertype d) {
2626
/** For upgraded databases without mangled name info. */
2727
pragma[noinline]
2828
private predicate onlyOneCompleteClassExistsWithName(string name) {
29-
not mangled_name(_, _) and
29+
not mangled_name(_, _, _) and
3030
strictcount(@usertype c | is_complete(c) and getTopLevelClassName(c) = name) = 1
3131
}
3232

@@ -36,7 +36,7 @@ private predicate onlyOneCompleteClassExistsWithName(string name) {
3636
*/
3737
pragma[noinline]
3838
private predicate existsIncompleteWithName(string name, @usertype c) {
39-
not mangled_name(_, _) and
39+
not mangled_name(_, _, _) and
4040
not is_complete(c) and
4141
name = getTopLevelClassName(c)
4242
}
@@ -47,7 +47,7 @@ private predicate existsIncompleteWithName(string name, @usertype c) {
4747
* with the same name.
4848
*/
4949
private predicate oldHasCompleteTwin(@usertype c, @usertype d) {
50-
not mangled_name(_, _) and
50+
not mangled_name(_, _, _) and
5151
exists(string name |
5252
existsIncompleteWithName(name, c) and
5353
existsCompleteWithName(name, d)
@@ -57,7 +57,7 @@ private predicate oldHasCompleteTwin(@usertype c, @usertype d) {
5757
pragma[noinline]
5858
private @mangledname getClassMangledName(@usertype c) {
5959
isClass(c) and
60-
mangled_name(c, result)
60+
mangled_name(c, result, _)
6161
}
6262

6363
/** Holds if `d` is a unique complete class named `name`. */

cpp/ql/lib/semmle/code/cpp/internal/ResolveGlobalVariable.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ private predicate hasDefinition(@globalvariable g) {
33
}
44

55
private predicate onlyOneCompleteGlobalVariableExistsWithMangledName(@mangledname name) {
6-
strictcount(@globalvariable g | hasDefinition(g) and mangled_name(g, name)) = 1
6+
strictcount(@globalvariable g | hasDefinition(g) and mangled_name(g, name, _)) = 1
77
}
88

99
/** Holds if `g` is a unique global variable with a definition named `name`. */
1010
private predicate isGlobalWithMangledNameAndWithDefinition(@mangledname name, @globalvariable g) {
1111
hasDefinition(g) and
12-
mangled_name(g, name) and
12+
mangled_name(g, name, _) and
1313
onlyOneCompleteGlobalVariableExistsWithMangledName(name)
1414
}
1515

1616
/** Holds if `g` is a global variable without a definition named `name`. */
1717
private predicate isGlobalWithMangledNameAndWithoutDefinition(@mangledname name, @globalvariable g) {
1818
not hasDefinition(g) and
19-
mangled_name(g, name)
19+
mangled_name(g, name, _)
2020
}
2121

2222
/**

cpp/ql/lib/semmlecode.cpp.dbscheme

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,8 @@ usertype_uuid(
747747

748748
mangled_name(
749749
unique int id: @declaration ref,
750-
int mangled_name : @mangledname
750+
int mangled_name : @mangledname,
751+
boolean is_complete: boolean ref
751752
);
752753

753754
is_pod_class(unique int id: @usertype ref);

0 commit comments

Comments
 (0)