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

Skip to content

Commit 8524b95

Browse files
committed
C++: Simplify has{Copy,Move}Signature
These functions were overly complicated, and the comments explaining the complications did not auto-format well. A reference type cannot have specifiers on it, so it's fine to call `getUnspecifiedType` before checking if it's a reference type.
1 parent 8e98d42 commit 8524b95

1 file changed

Lines changed: 2 additions & 10 deletions

File tree

cpp/ql/src/semmle/code/cpp/Function.qll

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -979,19 +979,11 @@ class ConversionConstructor extends Constructor, ImplicitConversionFunction {
979979
}
980980

981981
private predicate hasCopySignature(MemberFunction f) {
982-
f.getParameter(0).getType()
983-
.getUnderlyingType() // resolve typedefs
984-
.(LValueReferenceType).getBaseType() // step through lvalue reference type
985-
.getUnspecifiedType() = // resolve typedefs, strip const/volatile
986-
f.getDeclaringType()
982+
f.getParameter(0).getUnspecifiedType().(LValueReferenceType).getBaseType() = f.getDeclaringType()
987983
}
988984

989985
private predicate hasMoveSignature(MemberFunction f) {
990-
f.getParameter(0).getType()
991-
.getUnderlyingType() // resolve typedefs
992-
.(RValueReferenceType).getBaseType() // step through rvalue reference type
993-
.getUnspecifiedType() = // resolve typedefs, strip const/volatile
994-
f.getDeclaringType()
986+
f.getParameter(0).getUnspecifiedType().(RValueReferenceType).getBaseType() = f.getDeclaringType()
995987
}
996988

997989
/**

0 commit comments

Comments
 (0)