|
1 | 1 | import semmle.code.cpp.Type |
2 | 2 |
|
3 | | -/** For upgraded databases without mangled name info. */ |
4 | | -pragma[noinline] |
5 | | -private string getTopLevelClassName(@usertype c) { |
6 | | - not mangled_name(_, _, _) and |
7 | | - isClass(c) and |
8 | | - usertypes(c, result, _) and |
9 | | - not namespacembrs(_, c) and // not in a namespace |
10 | | - not member(_, _, c) and // not in some structure |
11 | | - not class_instantiation(c, _) // not a template instantiation |
12 | | -} |
13 | | - |
14 | | -/** |
15 | | - * For upgraded databases without mangled name info. |
16 | | - * Holds if `d` is a unique complete class named `name`. |
17 | | - */ |
18 | | -pragma[noinline] |
19 | | -private predicate existsCompleteWithName(string name, @usertype d) { |
20 | | - not mangled_name(_, _, _) and |
21 | | - is_complete(d) and |
22 | | - name = getTopLevelClassName(d) and |
23 | | - onlyOneCompleteClassExistsWithName(name) |
24 | | -} |
25 | | - |
26 | | -/** For upgraded databases without mangled name info. */ |
27 | | -pragma[noinline] |
28 | | -private predicate onlyOneCompleteClassExistsWithName(string name) { |
29 | | - not mangled_name(_, _, _) and |
30 | | - strictcount(@usertype c | is_complete(c) and getTopLevelClassName(c) = name) = 1 |
31 | | -} |
32 | | - |
33 | | -/** |
34 | | - * For upgraded databases without mangled name info. |
35 | | - * Holds if `c` is an incomplete class named `name`. |
36 | | - */ |
37 | | -pragma[noinline] |
38 | | -private predicate existsIncompleteWithName(string name, @usertype c) { |
39 | | - not mangled_name(_, _, _) and |
40 | | - not is_complete(c) and |
41 | | - name = getTopLevelClassName(c) |
42 | | -} |
43 | | - |
44 | | -/** |
45 | | - * For upgraded databases without mangled name info. |
46 | | - * Holds if `c` is an incomplete class, and there exists a unique complete class `d` |
47 | | - * with the same name. |
48 | | - */ |
49 | | -private predicate oldHasCompleteTwin(@usertype c, @usertype d) { |
50 | | - not mangled_name(_, _, _) and |
51 | | - exists(string name | |
52 | | - existsIncompleteWithName(name, c) and |
53 | | - existsCompleteWithName(name, d) |
54 | | - ) |
55 | | -} |
56 | | - |
57 | 3 | pragma[noinline] |
58 | 4 | private @mangledname getClassMangledName(@usertype c) { |
59 | 5 | isClass(c) and |
@@ -103,10 +49,7 @@ private module Cached { |
103 | 49 | @usertype resolveClass(@usertype c) { |
104 | 50 | hasCompleteTwin(c, result) |
105 | 51 | or |
106 | | - oldHasCompleteTwin(c, result) |
107 | | - or |
108 | 52 | not hasCompleteTwin(c, _) and |
109 | | - not oldHasCompleteTwin(c, _) and |
110 | 53 | result = c |
111 | 54 | } |
112 | 55 |
|
|
0 commit comments