Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c00f84d

Browse files
committed
C++: Work around the 'wrong' function name for conversion operators.
1 parent 2c7d0de commit c00f84d

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

cpp/ql/lib/semmle/code/cpp/dataflow/ExternalFlow.qll

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,22 @@ private predicate elementSpecMatchesSignature(
754754
signatureMatches(func, signature, type, name, 0)
755755
}
756756

757+
/**
758+
* Holds when `method` has name `nameWithoutArgs`, and gets the enclosing
759+
* class of `method`. Unlike `method.getClassAndName` this predicate does
760+
* not strip typedefs from the name when `method` is an `ConversionOperator`.
761+
*/
762+
bindingset[nameWithoutArgs]
763+
pragma[inline_late]
764+
private Class getClassAndNameImpl(Function method, string nameWithoutArgs) {
765+
exists(string memberName | result = method.getClassAndName(memberName) |
766+
nameWithoutArgs = "operator " + method.(ConversionOperator).getDestType()
767+
or
768+
not method instanceof ConversionOperator and
769+
memberName = nameWithoutArgs
770+
)
771+
}
772+
757773
/**
758774
* Holds if `classWithMethod` has `method` named `name` (excluding any
759775
* template parameters).
@@ -763,7 +779,7 @@ pragma[inline_late]
763779
private predicate hasClassAndName(Class classWithMethod, Function method, string name) {
764780
exists(string nameWithoutArgs |
765781
parseAngles(name, nameWithoutArgs, _, "") and
766-
classWithMethod = method.getClassAndName(nameWithoutArgs)
782+
classWithMethod = getClassAndNameImpl(method, nameWithoutArgs)
767783
)
768784
}
769785

0 commit comments

Comments
 (0)