Skip to content

Commit

Permalink
Merge pull request #18588 from jketema/decl-entry
Browse files Browse the repository at this point in the history
C++: Fix join-order problem in `UserType::getADeclarationEntry`
  • Loading branch information
jketema authored Jan 24, 2025
2 parents 41ee84b + 2e33a42 commit 4d2ec75
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions cpp/ql/lib/semmle/code/cpp/UserType.qll
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,16 @@ class UserType extends Type, Declaration, NameQualifyingElement, AccessHolder, @
else result = this.getADeclarationLocation()
}

pragma[nomagic]
private TypeDeclarationEntry getADeclarationEntryBase() {
type_decls(underlyingElement(result), unresolveElement(this), _)
}

override TypeDeclarationEntry getADeclarationEntry() {
if type_decls(_, unresolveElement(this), _)
then type_decls(underlyingElement(result), unresolveElement(this), _)
else exists(Class t | this.(Class).isConstructedFrom(t) and result = t.getADeclarationEntry())
pragma[only_bind_into](result) = pragma[only_bind_into](this).getADeclarationEntryBase()
or
not exists(this.getADeclarationEntryBase()) and
exists(Class t | this.(Class).isConstructedFrom(t) and result = t.getADeclarationEntry())
}

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

0 comments on commit 4d2ec75

Please sign in to comment.