Skip to content

Commit 79f456e

Browse files
authored
Merge pull request #1905 from ian-semmle/mangling_more
C++: Resolve all classes
2 parents 79a750d + 4190a53 commit 79f456e

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,32 +55,29 @@ private predicate oldHasCompleteTwin(@usertype c, @usertype d) {
5555
}
5656

5757
pragma[noinline]
58-
private @mangledname getTopLevelClassMangledName(@usertype c) {
58+
private @mangledname getClassMangledName(@usertype c) {
5959
isClass(c) and
60-
mangled_name(c, result) and
61-
not namespacembrs(_, c) and // not in a namespace
62-
not member(_, _, c) and // not in some structure
63-
not class_instantiation(c, _) // not a template instantiation
60+
mangled_name(c, result)
6461
}
6562

6663
/** Holds if `d` is a unique complete class named `name`. */
6764
pragma[noinline]
6865
private predicate existsCompleteWithMangledName(@mangledname name, @usertype d) {
6966
is_complete(d) and
70-
name = getTopLevelClassMangledName(d) and
67+
name = getClassMangledName(d) and
7168
onlyOneCompleteClassExistsWithMangledName(name)
7269
}
7370

7471
pragma[noinline]
7572
private predicate onlyOneCompleteClassExistsWithMangledName(@mangledname name) {
76-
strictcount(@usertype c | is_complete(c) and getTopLevelClassMangledName(c) = name) = 1
73+
strictcount(@usertype c | is_complete(c) and getClassMangledName(c) = name) = 1
7774
}
7875

7976
/** Holds if `c` is an incomplete class named `name`. */
8077
pragma[noinline]
8178
private predicate existsIncompleteWithMangledName(@mangledname name, @usertype c) {
8279
not is_complete(c) and
83-
name = getTopLevelClassMangledName(c)
80+
name = getClassMangledName(c)
8481
}
8582

8683
/**
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
| decls.cpp:4:6:4:6 | x | decls.cpp:2:9:2:9 | C |
1+
| decls.cpp:4:6:4:6 | x | defs.cpp:2:9:2:9 | C |
22
| defs.cpp:18:21:18:38 | definedAndDeclared | defs.cpp:11:7:11:24 | DefinedAndDeclared |
33
| defs.cpp:25:28:25:32 | mdbsh | header.h:1:8:1:32 | MultipleDefsButSameHeader |
44
| defs.cpp:29:24:29:28 | odidf | c1.cpp:7:8:7:28 | OneDefInDifferentFile |

0 commit comments

Comments
 (0)