mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
Merge pull request #1905 from ian-semmle/mangling_more
C++: Resolve all classes
This commit is contained in:
@@ -55,32 +55,29 @@ private predicate oldHasCompleteTwin(@usertype c, @usertype d) {
|
||||
}
|
||||
|
||||
pragma[noinline]
|
||||
private @mangledname getTopLevelClassMangledName(@usertype c) {
|
||||
private @mangledname getClassMangledName(@usertype c) {
|
||||
isClass(c) and
|
||||
mangled_name(c, result) and
|
||||
not namespacembrs(_, c) and // not in a namespace
|
||||
not member(_, _, c) and // not in some structure
|
||||
not class_instantiation(c, _) // not a template instantiation
|
||||
mangled_name(c, result)
|
||||
}
|
||||
|
||||
/** Holds if `d` is a unique complete class named `name`. */
|
||||
pragma[noinline]
|
||||
private predicate existsCompleteWithMangledName(@mangledname name, @usertype d) {
|
||||
is_complete(d) and
|
||||
name = getTopLevelClassMangledName(d) and
|
||||
name = getClassMangledName(d) and
|
||||
onlyOneCompleteClassExistsWithMangledName(name)
|
||||
}
|
||||
|
||||
pragma[noinline]
|
||||
private predicate onlyOneCompleteClassExistsWithMangledName(@mangledname name) {
|
||||
strictcount(@usertype c | is_complete(c) and getTopLevelClassMangledName(c) = name) = 1
|
||||
strictcount(@usertype c | is_complete(c) and getClassMangledName(c) = name) = 1
|
||||
}
|
||||
|
||||
/** Holds if `c` is an incomplete class named `name`. */
|
||||
pragma[noinline]
|
||||
private predicate existsIncompleteWithMangledName(@mangledname name, @usertype c) {
|
||||
not is_complete(c) and
|
||||
name = getTopLevelClassMangledName(c)
|
||||
name = getClassMangledName(c)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
| decls.cpp:4:6:4:6 | x | decls.cpp:2:9:2:9 | C |
|
||||
| decls.cpp:4:6:4:6 | x | defs.cpp:2:9:2:9 | C |
|
||||
| defs.cpp:18:21:18:38 | definedAndDeclared | defs.cpp:11:7:11:24 | DefinedAndDeclared |
|
||||
| defs.cpp:25:28:25:32 | mdbsh | header.h:1:8:1:32 | MultipleDefsButSameHeader |
|
||||
| defs.cpp:29:24:29:28 | odidf | c1.cpp:7:8:7:28 | OneDefInDifferentFile |
|
||||
|
||||
Reference in New Issue
Block a user