Skip to content

Commit 4d2ec75

Browse files
authored
Merge pull request #18588 from jketema/decl-entry
C++: Fix join-order problem in `UserType::getADeclarationEntry`
2 parents 41ee84b + 2e33a42 commit 4d2ec75

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

cpp/ql/lib/semmle/code/cpp/UserType.qll

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,16 @@ class UserType extends Type, Declaration, NameQualifyingElement, AccessHolder, @
4747
else result = this.getADeclarationLocation()
4848
}
4949

50+
pragma[nomagic]
51+
private TypeDeclarationEntry getADeclarationEntryBase() {
52+
type_decls(underlyingElement(result), unresolveElement(this), _)
53+
}
54+
5055
override TypeDeclarationEntry getADeclarationEntry() {
51-
if type_decls(_, unresolveElement(this), _)
52-
then type_decls(underlyingElement(result), unresolveElement(this), _)
53-
else exists(Class t | this.(Class).isConstructedFrom(t) and result = t.getADeclarationEntry())
56+
pragma[only_bind_into](result) = pragma[only_bind_into](this).getADeclarationEntryBase()
57+
or
58+
not exists(this.getADeclarationEntryBase()) and
59+
exists(Class t | this.(Class).isConstructedFrom(t) and result = t.getADeclarationEntry())
5460
}
5561

5662
override Location getADeclarationLocation() { result = this.getADeclarationEntry().getLocation() }

0 commit comments

Comments
 (0)