mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
C#: Rename getSourceDeclaration() to getUnboundDeclaration()
This commit is contained in:
@@ -17,7 +17,7 @@ where
|
||||
add.hasName("Add") and
|
||||
add
|
||||
.getDeclaringType()
|
||||
.getSourceDeclaration()
|
||||
.getUnboundDeclaration()
|
||||
.hasQualifiedName("System.Collections.Generic.ICollection<>") and
|
||||
call.getAnArgument() instanceof NullLiteral
|
||||
select call
|
||||
|
||||
@@ -56,7 +56,7 @@ class LocalScopeDisposableCreation extends Call {
|
||||
exists(Method create | this.getTarget() = create |
|
||||
create.hasName("Create") and
|
||||
create.isStatic() and
|
||||
create.getDeclaringType().getSourceDeclaration() = t.getSourceDeclaration()
|
||||
create.getDeclaringType().getUnboundDeclaration() = t.getUnboundDeclaration()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ predicate nonOverridingMethod(Method m, Method vm) {
|
||||
not m.overrides() and
|
||||
not m.isOverride() and
|
||||
not m.isNew() and
|
||||
m = m.getSourceDeclaration() and
|
||||
m.isUnboundDeclaration() and
|
||||
m.getNumberOfParameters() = vm.getNumberOfParameters() and
|
||||
forall(int i, Parameter p1, Parameter p2 | p1 = m.getParameter(i) and p2 = vm.getParameter(i) |
|
||||
p1.getType() = p2.getType()
|
||||
@@ -41,4 +41,4 @@ where
|
||||
m.fromSource() and
|
||||
nonOverridingMethod(m, vm)
|
||||
select m, "Method '" + m.getName() + "' looks like it should override $@ but does not do so.",
|
||||
vm.getSourceDeclaration(), vm.getQualifiedName()
|
||||
vm.getUnboundDeclaration(), vm.getQualifiedName()
|
||||
|
||||
@@ -15,7 +15,7 @@ import semmle.code.csharp.frameworks.System
|
||||
|
||||
from MethodCall c, EqualsMethod equals
|
||||
where
|
||||
c.getTarget().getSourceDeclaration() = equals and
|
||||
c.getTarget().getUnboundDeclaration() = equals and
|
||||
c.getArgument(0) instanceof NullLiteral and
|
||||
not c.getQualifier().getType() instanceof NullableType
|
||||
select c, "Equality test with 'null' will never be true, but may throw a 'NullReferenceException'."
|
||||
|
||||
@@ -32,7 +32,7 @@ predicate important(Method m) {
|
||||
/** Holds if the return type of `m` is an instantiated type parameter from `m`. */
|
||||
predicate methodHasGenericReturnType(ConstructedMethod cm) {
|
||||
exists(UnboundGenericMethod ugm |
|
||||
ugm = cm.getSourceDeclaration() and
|
||||
ugm = cm.getUnboundGeneric() and
|
||||
ugm.getReturnType() = ugm.getATypeParameter()
|
||||
)
|
||||
}
|
||||
@@ -46,16 +46,16 @@ predicate dubious(Method m, int percentage) {
|
||||
// Suppress on methods designed for chaining
|
||||
not designedForChaining(m) and
|
||||
exists(int used, int total, Method target |
|
||||
target = m.getSourceDeclaration() and
|
||||
target = m.getUnboundDeclaration() and
|
||||
used =
|
||||
count(MethodCall mc |
|
||||
mc.getTarget().getSourceDeclaration() = target and
|
||||
mc.getTarget().getUnboundDeclaration() = target and
|
||||
not mc instanceof DiscardedMethodCall and
|
||||
(methodHasGenericReturnType(m) implies m.getReturnType() = mc.getTarget().getReturnType())
|
||||
) and
|
||||
total =
|
||||
count(MethodCall mc |
|
||||
mc.getTarget().getSourceDeclaration() = target and
|
||||
mc.getTarget().getUnboundDeclaration() = target and
|
||||
(methodHasGenericReturnType(m) implies m.getReturnType() = mc.getTarget().getReturnType())
|
||||
) and
|
||||
used != total and
|
||||
|
||||
@@ -16,10 +16,10 @@ import csharp
|
||||
|
||||
Member getAUsedMember(Method m) {
|
||||
exists(MemberAccess ma | ma.getEnclosingCallable() = m |
|
||||
result = ma.getTarget().getSourceDeclaration()
|
||||
result = ma.getTarget().getUnboundDeclaration()
|
||||
)
|
||||
or
|
||||
exists(Call c | c.getEnclosingCallable() = m | result = c.getTarget().getSourceDeclaration())
|
||||
exists(Call c | c.getEnclosingCallable() = m | result = c.getTarget().getUnboundDeclaration())
|
||||
}
|
||||
|
||||
int dependencyCount(Method source, RefType target) {
|
||||
@@ -50,8 +50,8 @@ predicate query(Method m, RefType targetType, int selfCount, int depCount) {
|
||||
not m instanceof ExtensionMethod and
|
||||
// Do not move up/down the class hierarchy
|
||||
not (
|
||||
sourceType.getABaseType*().getSourceDeclaration() = targetType or
|
||||
targetType.getABaseType*().getSourceDeclaration() = sourceType
|
||||
sourceType.getABaseType*().getUnboundDeclaration() = targetType or
|
||||
targetType.getABaseType*().getUnboundDeclaration() = sourceType
|
||||
) and
|
||||
// Do not move between nested types
|
||||
not (sourceType.getDeclaringType*() = targetType or targetType.getDeclaringType*() = sourceType) and
|
||||
|
||||
@@ -22,9 +22,9 @@ class CollectionInterface extends Interface {
|
||||
CollectionInterface() {
|
||||
exists(Interface i | i = this.getABaseInterface*() |
|
||||
i instanceof SystemCollectionsICollectionInterface or
|
||||
i.getSourceDeclaration() instanceof SystemCollectionsGenericICollectionInterface or
|
||||
i.getUnboundDeclaration() instanceof SystemCollectionsGenericICollectionInterface or
|
||||
i instanceof SystemCollectionsIEnumerableInterface or
|
||||
i.getSourceDeclaration() instanceof SystemCollectionsGenericIEnumerableTInterface
|
||||
i.getUnboundDeclaration() instanceof SystemCollectionsGenericIEnumerableTInterface
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import semmle.code.csharp.commons.Collections
|
||||
import DataFlow
|
||||
|
||||
predicate storesCollection(Callable c, Parameter p, Field f) {
|
||||
f.getDeclaringType() = c.getDeclaringType().getABaseType*().getSourceDeclaration() and
|
||||
f.getDeclaringType() = c.getDeclaringType().getABaseType*().getUnboundDeclaration() and
|
||||
f.getType() instanceof CollectionType and
|
||||
p = c.getAParameter() and
|
||||
f.getAnAssignedValue() = p.getAnAccess() and
|
||||
@@ -23,7 +23,7 @@ predicate storesCollection(Callable c, Parameter p, Field f) {
|
||||
}
|
||||
|
||||
predicate returnsCollection(Callable c, Field f) {
|
||||
f.getDeclaringType() = c.getDeclaringType().getABaseType*().getSourceDeclaration() and
|
||||
f.getDeclaringType() = c.getDeclaringType().getABaseType*().getUnboundDeclaration() and
|
||||
f.getType() instanceof CollectionType and
|
||||
c.canReturn(f.getAnAccess()) and
|
||||
not c.(Modifiable).isStatic()
|
||||
|
||||
@@ -36,8 +36,8 @@ Expr getAnAccessByDynamicCall(Method m) {
|
||||
Expr getAMethodAccess(Method m) {
|
||||
result = getAnAccessByDynamicCall(m) or
|
||||
result = getAnAccessByReflection(m) or
|
||||
result.(MethodCall).getTarget().getSourceDeclaration() = m or
|
||||
result.(MethodAccess).getTarget().getSourceDeclaration() = m
|
||||
result.(MethodCall).getTarget().getUnboundDeclaration() = m or
|
||||
result.(MethodAccess).getTarget().getUnboundDeclaration() = m
|
||||
}
|
||||
|
||||
predicate potentiallyAccessedByForEach(Method m) {
|
||||
@@ -63,7 +63,7 @@ predicate isRecursivelyLiveMethod(Method m) {
|
||||
or
|
||||
potentiallyAccessedByForEach(m)
|
||||
or
|
||||
isRecursivelyLiveMethod(m.(ConstructedMethod).getSourceDeclaration())
|
||||
isRecursivelyLiveMethod(m.(ConstructedMethod).getUnboundDeclaration())
|
||||
or
|
||||
nunitValueSource(m)
|
||||
or
|
||||
@@ -78,7 +78,7 @@ predicate nunitValueSource(Method m) {
|
||||
}
|
||||
|
||||
predicate nunitTestCaseSource(Declaration f) {
|
||||
exists(TestCaseSourceAttribute attribute | attribute.getSourceDeclaration() = f)
|
||||
exists(TestCaseSourceAttribute attribute | attribute.getUnboundDeclaration() = f)
|
||||
}
|
||||
|
||||
predicate isDeadMethod(Method m) {
|
||||
@@ -89,9 +89,9 @@ predicate isDeadMethod(Method m) {
|
||||
predicate isDeadField(Field f) {
|
||||
f.isPrivate() and
|
||||
not f.getDeclaringType() instanceof AnonymousClass and
|
||||
f.getSourceDeclaration() = f and
|
||||
f.getUnboundDeclaration() = f and
|
||||
not nunitTestCaseSource(f) and
|
||||
forall(FieldAccess fc | fc.getTarget().getSourceDeclaration() = f |
|
||||
forall(FieldAccess fc | fc.getTarget().getUnboundDeclaration() = f |
|
||||
isDeadMethod(fc.getEnclosingCallable())
|
||||
or
|
||||
not fc instanceof FieldRead and not fc.isRefArgument()
|
||||
|
||||
@@ -32,7 +32,7 @@ from RefType t
|
||||
where
|
||||
not extractionIsStandalone() and
|
||||
t.fromSource() and
|
||||
t = t.getSourceDeclaration() and
|
||||
t.isUnboundDeclaration() and
|
||||
not t instanceof AnonymousClass and
|
||||
not (t.isPublic() or t.isProtected()) and
|
||||
not exists(ValueOrRefType dependent | depends(dependent, t) and dependent != t) and
|
||||
|
||||
@@ -85,31 +85,31 @@ where
|
||||
not f.getType() instanceof Struct and
|
||||
not exists(Assignment ae, Field g |
|
||||
ae.getLValue().(FieldAccess).getTarget() = g and
|
||||
g.getSourceDeclaration() = f and
|
||||
g.getUnboundDeclaration() = f and
|
||||
not ae.getRValue() instanceof NullLiteral
|
||||
) and
|
||||
not exists(MethodCall mc, int i, Field g |
|
||||
exists(Parameter p | mc.getTarget().getParameter(i) = p | p.isOut() or p.isRef()) and
|
||||
mc.getArgument(i) = g.getAnAccess() and
|
||||
g.getSourceDeclaration() = f
|
||||
g.getUnboundDeclaration() = f
|
||||
) and
|
||||
not isFieldExternallyInitialized(f) and
|
||||
not exists(f.getAnAttribute()) and
|
||||
not exists(Expr init, Field g |
|
||||
g.getSourceDeclaration() = f and
|
||||
g.getUnboundDeclaration() = f and
|
||||
g.getInitializer() = init and
|
||||
not init instanceof NullLiteral
|
||||
) and
|
||||
not exists(AssignOperation ua, Field g |
|
||||
ua.getLValue().(FieldAccess).getTarget() = g and
|
||||
g.getSourceDeclaration() = f
|
||||
g.getUnboundDeclaration() = f
|
||||
) and
|
||||
not exists(MutatorOperation op |
|
||||
op.getAnOperand().(FieldAccess).getTarget().getSourceDeclaration() = f
|
||||
op.getAnOperand().(FieldAccess).getTarget().getUnboundDeclaration() = f
|
||||
) and
|
||||
exists(Field g |
|
||||
fa.getTarget() = g and
|
||||
g.getSourceDeclaration() = f
|
||||
g.getUnboundDeclaration() = f
|
||||
)
|
||||
select f,
|
||||
"The field '" + f.getName() + "' is never explicitly assigned a value, yet it is read $@.", fa,
|
||||
|
||||
@@ -44,7 +44,7 @@ predicate declarationHasXmlComment(Declaration d) { exists(getADeclarationXmlCom
|
||||
|
||||
/** Whether a declaration should have documentation. */
|
||||
predicate isDocumentationNeeded(Modifiable decl) {
|
||||
decl.getSourceDeclaration() = decl and // Exclude constructed types and methods
|
||||
decl.isUnboundDeclaration() and // Exclude constructed types and methods
|
||||
not exists(decl.(Attributable).getAnAttribute()) and // An attribute may serve to document
|
||||
decl.isPublic() and
|
||||
(
|
||||
|
||||
@@ -19,7 +19,7 @@ int isCountForIfChain(IfStmt is) {
|
||||
exists(int rest |
|
||||
(if is.getElse() instanceof IfStmt then rest = isCountForIfChain(is.getElse()) else rest = 0) and
|
||||
(
|
||||
if getTypeCondition(is).getCheckedType().getSourceDeclaration().fromSource()
|
||||
if getTypeCondition(is).getCheckedType().fromSource()
|
||||
then result = 1 + rest
|
||||
else result = rest
|
||||
)
|
||||
|
||||
@@ -78,7 +78,7 @@ Element getCollectionAssignmentTarget(Expr e) {
|
||||
MethodCall mc, Method m, LibraryTypeDataFlow ltdf, CallableFlowSource source,
|
||||
CallableFlowSink sink
|
||||
|
|
||||
m = mc.getTarget().getSourceDeclaration() and
|
||||
m = mc.getTarget().getUnboundDeclaration() and
|
||||
ltdf.callableFlow(source, AccessPath::empty(), sink, AccessPath::element(), m, _) and
|
||||
e = source.getSource(mc) and
|
||||
result.(Variable).getAnAccess() = sink.getSink(mc)
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
import csharp
|
||||
|
||||
predicate defTargetsField(AssignableDefinition def, Field f) {
|
||||
def.getTarget().getSourceDeclaration() = f
|
||||
def.getTarget().getUnboundDeclaration() = f
|
||||
}
|
||||
|
||||
predicate isReadonlyCompatibleDefinition(AssignableDefinition def, Field f) {
|
||||
|
||||
@@ -15,7 +15,7 @@ import semmle.code.csharp.commons.Assertions
|
||||
|
||||
private predicate propertyOverrides(Property p, string baseClass, string property) {
|
||||
exists(Property p2 |
|
||||
p2.getSourceDeclaration().getDeclaringType().hasQualifiedName(baseClass) and
|
||||
p2.getUnboundDeclaration().getDeclaringType().hasQualifiedName(baseClass) and
|
||||
p2.hasName(property)
|
||||
|
|
||||
p.overridesOrImplementsOrEquals(p2)
|
||||
|
||||
@@ -18,7 +18,7 @@ where
|
||||
compareTo = any(SystemIComparableInterface i).getCompareToMethod()
|
||||
or
|
||||
compareTo = any(SystemIComparableTInterface i).getAConstructedGeneric().getAMethod() and
|
||||
compareTo.getSourceDeclaration() = any(SystemIComparableTInterface i).getCompareToMethod()
|
||||
compareTo.getUnboundDeclaration() = any(SystemIComparableTInterface i).getCompareToMethod()
|
||||
) and
|
||||
compareToImpl = c.getAMethod() and
|
||||
compareToImpl = compareTo.getAnUltimateImplementor() and
|
||||
|
||||
@@ -17,7 +17,7 @@ predicate generateRandomNumberMethod(string s) { s = "Next" or s = "NextBytes" o
|
||||
|
||||
from ObjectCreation c, MethodCall m
|
||||
where
|
||||
c.getType().getSourceDeclaration().(ValueOrRefType).hasQualifiedName("System", "Random") and
|
||||
c.getType().getUnboundDeclaration().(ValueOrRefType).hasQualifiedName("System", "Random") and
|
||||
m.getQualifier() = c and
|
||||
generateRandomNumberMethod(m.getTarget().getName())
|
||||
select m, "Random object created and used only once."
|
||||
|
||||
@@ -150,16 +150,18 @@ private class IndirectType extends GeneratedType {
|
||||
or
|
||||
this.(UnboundGenericType).getAConstructedGeneric().getASubType() instanceof GeneratedType
|
||||
or
|
||||
exists(GeneratedType t | this = getAContainedType(t.getAGeneratedType()).getSourceDeclaration())
|
||||
exists(GeneratedType t |
|
||||
this = getAContainedType(t.getAGeneratedType()).getUnboundDeclaration()
|
||||
)
|
||||
or
|
||||
exists(GeneratedDeclaration decl |
|
||||
decl.(Member).getDeclaringType().getSourceDeclaration() = this
|
||||
decl.(Member).getDeclaringType().getUnboundDeclaration() = this
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private class RootGeneratedType extends GeneratedType {
|
||||
RootGeneratedType() { this = any(GeneratedDeclaration decl).getSourceDeclaration() }
|
||||
RootGeneratedType() { this = any(GeneratedDeclaration decl).getUnboundDeclaration() }
|
||||
}
|
||||
|
||||
private Type getAContainedType(Type t) {
|
||||
@@ -169,7 +171,7 @@ private Type getAContainedType(Type t) {
|
||||
}
|
||||
|
||||
private class RootGeneratedMember extends GeneratedMember {
|
||||
RootGeneratedMember() { this = any(GeneratedDeclaration d).getSourceDeclaration() }
|
||||
RootGeneratedMember() { this = any(GeneratedDeclaration d).getUnboundDeclaration() }
|
||||
}
|
||||
|
||||
private predicate declarationExists(Virtualizable m) {
|
||||
|
||||
@@ -19,7 +19,7 @@ predicate methodInClass(ValueOrRefType t, Method m, string name) {
|
||||
predicate callIn(MethodCall mc, Method fromMethod) { fromMethod = mc.getEnclosingCallable() }
|
||||
|
||||
predicate callTo(MethodCall mc, Method toMethod) {
|
||||
toMethod = mc.getTarget().getSourceDeclaration()
|
||||
toMethod = mc.getTarget().getUnboundDeclaration()
|
||||
}
|
||||
|
||||
predicate candidates(Method forwarder, Method forwardee) {
|
||||
@@ -45,6 +45,6 @@ where
|
||||
candidates(forwarder, forwardee) and
|
||||
forex(MethodCall c | callTo(c, forwardee) | callIn(c, forwarder)) and
|
||||
forex(MethodCall c | callIn(c, forwarder) | callTo(c, forwardee))
|
||||
select forwarder.getSourceDeclaration(),
|
||||
select forwarder.getUnboundDeclaration(),
|
||||
"This method is a forwarder for $@, which is not called independently - the methods can be merged.",
|
||||
forwardee.getSourceDeclaration(), forwardee.getName()
|
||||
forwardee.getUnboundDeclaration(), forwardee.getName()
|
||||
|
||||
@@ -83,7 +83,7 @@ private class MethodUse extends Use, QualifiableExpr {
|
||||
)
|
||||
}
|
||||
|
||||
override Method getDefinition() { result = getQualifiedDeclaration().getSourceDeclaration() }
|
||||
override Method getDefinition() { result = getQualifiedDeclaration().getUnboundDeclaration() }
|
||||
|
||||
override string getUseType() { result = "M" }
|
||||
|
||||
@@ -122,7 +122,7 @@ private class AccessUse extends Access, Use {
|
||||
Use.super.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
|
||||
}
|
||||
|
||||
override Declaration getDefinition() { result = this.getTarget().getSourceDeclaration() }
|
||||
override Declaration getDefinition() { result = this.getTarget().getUnboundDeclaration() }
|
||||
|
||||
override string getUseType() {
|
||||
if this instanceof Call or this instanceof LocalFunctionAccess
|
||||
@@ -169,7 +169,7 @@ private class TypeMentionUse extends Use, TypeMention {
|
||||
Use.super.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
|
||||
}
|
||||
|
||||
override Type getDefinition() { result = this.getType().getSourceDeclaration() }
|
||||
override Type getDefinition() { result = this.getType().getUnboundDeclaration() }
|
||||
|
||||
override string getUseType() {
|
||||
if this.getTarget() instanceof ObjectCreation
|
||||
|
||||
@@ -380,7 +380,7 @@ class TypeIsBothConstructedAndUnbound extends TypeViolation {
|
||||
*/
|
||||
class InconsistentTypeLocation extends TypeViolation {
|
||||
InconsistentTypeLocation() {
|
||||
this.getType().getLocation() != this.getType().getSourceDeclaration().getLocation()
|
||||
this.getType().getLocation() != this.getType().getUnboundDeclaration().getLocation()
|
||||
}
|
||||
|
||||
override string getMessage() { result = "Inconsistent constructed type location" }
|
||||
@@ -423,7 +423,7 @@ class MethodViolation extends ConsistencyViolation, DeclarationCheck {
|
||||
*/
|
||||
class InconsistentMethodLocation extends MethodViolation {
|
||||
InconsistentMethodLocation() {
|
||||
this.getMethod().getLocation() != this.getMethod().getSourceDeclaration().getLocation()
|
||||
this.getMethod().getLocation() != this.getMethod().getUnboundDeclaration().getLocation()
|
||||
}
|
||||
|
||||
override string getMessage() { result = "Inconsistent constructed method location" }
|
||||
@@ -435,13 +435,13 @@ class InconsistentMethodLocation extends MethodViolation {
|
||||
class ConstructedMethodTypeParams extends MethodViolation {
|
||||
ConstructedMethodTypeParams() {
|
||||
getMethod().(ConstructedGeneric).getNumberOfTypeArguments() !=
|
||||
getMethod().getSourceDeclaration().(UnboundGeneric).getNumberOfTypeParameters()
|
||||
getMethod().getUnboundDeclaration().(UnboundGeneric).getNumberOfTypeParameters()
|
||||
}
|
||||
|
||||
override string getMessage() {
|
||||
result =
|
||||
"The constructed method " + getMethod().toStringWithTypes() +
|
||||
" does not match unbound method " + getMethod().getSourceDeclaration().toStringWithTypes()
|
||||
" does not match unbound method " + getMethod().getUnboundDeclaration().toStringWithTypes()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -530,7 +530,9 @@ class KindViolation extends TypeViolation {
|
||||
* unbound generic.
|
||||
*/
|
||||
class InconsistentKind extends TypeViolation {
|
||||
InconsistentKind() { typeKind(this.getType()) != typeKind(this.getType().getSourceDeclaration()) }
|
||||
InconsistentKind() {
|
||||
typeKind(this.getType()) != typeKind(this.getType().getUnboundDeclaration())
|
||||
}
|
||||
|
||||
override string getMessage() { result = "Inconsistent type kind of source declaration" }
|
||||
}
|
||||
@@ -672,7 +674,7 @@ class MissingCilDeclaration extends ConsistencyViolation, MissingCSharpCheck {
|
||||
* Holds if the C# declaration is expected to have a CIl declaration.
|
||||
*/
|
||||
private predicate expectedCilDeclaration(CS::Declaration decl) {
|
||||
decl = decl.getSourceDeclaration() and
|
||||
decl = decl.getUnboundDeclaration() and
|
||||
not decl instanceof CS::ArrayType and
|
||||
decl.getALocation() instanceof CS::Assembly and
|
||||
not decl.(CS::Modifiable).isInternal() and
|
||||
@@ -724,7 +726,7 @@ class ConstructedSourceDeclarationMethod extends MethodViolation {
|
||||
|
||||
ConstructedSourceDeclarationMethod() {
|
||||
method = getMethod() and
|
||||
method = method.getSourceDeclaration() and
|
||||
method = method.getUnboundDeclaration() and
|
||||
(
|
||||
method instanceof ConstructedGeneric or
|
||||
method.getDeclaringType() instanceof ConstructedGeneric
|
||||
|
||||
@@ -22,10 +22,17 @@ class Declaration extends DotNet::Declaration, Element, @cil_declaration {
|
||||
result = toCSharpTypeParameter(this)
|
||||
}
|
||||
|
||||
override Declaration getSourceDeclaration() { result = this }
|
||||
override Declaration getUnboundDeclaration() { result = this }
|
||||
|
||||
/** Holds if this declaration is a source declaration. */
|
||||
final predicate isSourceDeclaration() { this = getSourceDeclaration() }
|
||||
final predicate isUnboundDeclaration() { this = getUnboundDeclaration() }
|
||||
|
||||
/**
|
||||
* DEPRECATED: Use `isUnboundDeclaration()` instead.
|
||||
*
|
||||
* Holds if this declaration is a source declaration.
|
||||
*/
|
||||
deprecated final predicate isSourceDeclaration() { this.isUnboundDeclaration() }
|
||||
}
|
||||
|
||||
private CS::Declaration toCSharpNonTypeParameter(Declaration d) { result.matchesHandle(d) }
|
||||
|
||||
@@ -86,7 +86,7 @@ class Method extends DotNet::Callable, Element, Member, TypeContainer, DataFlowN
|
||||
|
||||
override Location getLocation() { result = Element.super.getLocation() }
|
||||
|
||||
override Location getALocation() { cil_method_location(this.getSourceDeclaration(), result) }
|
||||
override Location getALocation() { cil_method_location(this.getUnboundDeclaration(), result) }
|
||||
|
||||
override Parameter getRawParameter(int n) { cil_parameter(result, this, n, _) }
|
||||
|
||||
@@ -128,7 +128,7 @@ class Method extends DotNet::Callable, Element, Member, TypeContainer, DataFlowN
|
||||
/** Gets the unbound declaration of this method, or the method itself. */
|
||||
Method getUnboundMethod() { cil_method_source_declaration(this, result) }
|
||||
|
||||
override Method getSourceDeclaration() { result = getUnboundMethod() }
|
||||
override Method getUnboundDeclaration() { result = getUnboundMethod() }
|
||||
|
||||
/** Holds if this method is an instance constructor. */
|
||||
predicate isInstanceConstructor() { isSpecial() and getName() = ".ctor" }
|
||||
|
||||
@@ -57,7 +57,7 @@ class Type extends DotNet::Type, Declaration, TypeContainer, @cil_type {
|
||||
qualifier = this.getParent().getQualifiedName()
|
||||
}
|
||||
|
||||
override Location getALocation() { cil_type_location(this.getSourceDeclaration(), result) }
|
||||
override Location getALocation() { cil_type_location(this.getUnboundDeclaration(), result) }
|
||||
|
||||
/** Holds if this type is a class. */
|
||||
predicate isClass() { cil_class(this) }
|
||||
@@ -112,5 +112,5 @@ class Type extends DotNet::Type, Declaration, TypeContainer, @cil_type {
|
||||
*/
|
||||
int getConversionIndex() { result = 0 }
|
||||
|
||||
override Type getSourceDeclaration() { cil_type(this, _, _, _, result) }
|
||||
override Type getUnboundDeclaration() { cil_type(this, _, _, _, result) }
|
||||
}
|
||||
|
||||
@@ -108,8 +108,8 @@ class Parameter extends DotNet::Parameter, StackVariable, @cil_parameter {
|
||||
result = getMethod().getOverriddenMethod().getRawParameter(getRawPosition())
|
||||
}
|
||||
|
||||
override Parameter getSourceDeclaration() {
|
||||
result = getMethod().getSourceDeclaration().getRawParameter(getRawPosition())
|
||||
override Parameter getUnboundDeclaration() {
|
||||
result = getMethod().getUnboundDeclaration().getRawParameter(getRawPosition())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -192,8 +192,8 @@ private class RefArg extends AssignableAccess {
|
||||
)
|
||||
}
|
||||
|
||||
private Callable getSourceDeclarationTarget(Parameter p) {
|
||||
p = this.getParameter().getSourceDeclaration() and
|
||||
private Callable getUnboundDeclarationTarget(Parameter p) {
|
||||
p = this.getParameter().getUnboundDeclaration() and
|
||||
result.getAParameter() = p
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ private class RefArg extends AssignableAccess {
|
||||
* source.
|
||||
*/
|
||||
predicate isAnalyzable(Parameter p) {
|
||||
exists(Callable callable | callable = this.getSourceDeclarationTarget(p) |
|
||||
exists(Callable callable | callable = this.getUnboundDeclarationTarget(p) |
|
||||
not callable.(Virtualizable).isOverridableOrImplementable() and
|
||||
callable.hasBody()
|
||||
)
|
||||
@@ -223,7 +223,7 @@ private class RefArg extends AssignableAccess {
|
||||
private predicate isNonAnalyzable() {
|
||||
call instanceof @delegate_invocation_expr
|
||||
or
|
||||
exists(Callable callable | callable = this.getSourceDeclarationTarget(_) |
|
||||
exists(Callable callable | callable = this.getUnboundDeclarationTarget(_) |
|
||||
callable.(Virtualizable).isOverridableOrImplementable() or
|
||||
not callable.hasBody()
|
||||
)
|
||||
|
||||
@@ -26,7 +26,9 @@ class Callable extends DotNet::Callable, Parameterizable, ExprOrStmtParent, @cal
|
||||
/** Gets the annotated return type of this callable. */
|
||||
final AnnotatedType getAnnotatedReturnType() { result.appliesTo(this) }
|
||||
|
||||
override Callable getSourceDeclaration() { result = Parameterizable.super.getSourceDeclaration() }
|
||||
override Callable getUnboundDeclaration() {
|
||||
result = Parameterizable.super.getUnboundDeclaration()
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the body of this callable, if any.
|
||||
@@ -241,7 +243,7 @@ class Method extends Callable, Virtualizable, Attributable, @method {
|
||||
|
||||
override Type getReturnType() { methods(this, _, _, getTypeRef(result), _) }
|
||||
|
||||
override Method getSourceDeclaration() { methods(this, _, _, _, result) }
|
||||
override Method getUnboundDeclaration() { methods(this, _, _, _, result) }
|
||||
|
||||
override Method getOverridee() { result = Virtualizable.super.getOverridee() }
|
||||
|
||||
@@ -350,7 +352,7 @@ class Constructor extends DotNet::Constructor, Callable, Member, Attributable, @
|
||||
|
||||
override ValueOrRefType getDeclaringType() { constructors(this, _, result, _) }
|
||||
|
||||
override Constructor getSourceDeclaration() { constructors(this, _, _, result) }
|
||||
override Constructor getUnboundDeclaration() { constructors(this, _, _, result) }
|
||||
|
||||
override Location getALocation() { constructor_location(this, result) }
|
||||
|
||||
@@ -420,7 +422,7 @@ class Destructor extends DotNet::Destructor, Callable, Member, Attributable, @de
|
||||
|
||||
override ValueOrRefType getDeclaringType() { destructors(this, _, result, _) }
|
||||
|
||||
override Destructor getSourceDeclaration() { destructors(this, _, _, result) }
|
||||
override Destructor getUnboundDeclaration() { destructors(this, _, _, result) }
|
||||
|
||||
override Location getALocation() { destructor_location(this, result) }
|
||||
|
||||
@@ -450,7 +452,7 @@ class Operator extends Callable, Member, Attributable, @operator {
|
||||
|
||||
override Type getReturnType() { operators(this, _, _, _, getTypeRef(result), _) }
|
||||
|
||||
override Operator getSourceDeclaration() { operators(this, _, _, _, _, result) }
|
||||
override Operator getUnboundDeclaration() { operators(this, _, _, _, _, result) }
|
||||
|
||||
override Location getALocation() { operator_location(this, result) }
|
||||
|
||||
@@ -973,14 +975,14 @@ class ExplicitConversionOperator extends ConversionOperator {
|
||||
class LocalFunction extends Callable, Modifiable, @local_function {
|
||||
override string getName() { local_functions(this, result, _, _) }
|
||||
|
||||
override LocalFunction getSourceDeclaration() { local_functions(this, _, _, result) }
|
||||
override LocalFunction getUnboundDeclaration() { local_functions(this, _, _, result) }
|
||||
|
||||
override Type getReturnType() { local_functions(this, _, result, _) }
|
||||
|
||||
override Element getParent() { result = getStatement().getParent() }
|
||||
|
||||
/** Gets the local function statement defining this function. */
|
||||
LocalFunctionStmt getStatement() { result.getLocalFunction() = getSourceDeclaration() }
|
||||
LocalFunctionStmt getStatement() { result.getLocalFunction() = getUnboundDeclaration() }
|
||||
|
||||
override Callable getEnclosingCallable() { result = this.getStatement().getEnclosingCallable() }
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ class Event extends DeclarationWithAccessors, @event {
|
||||
not this.getAnEventAccessor().hasBody()
|
||||
}
|
||||
|
||||
override Event getSourceDeclaration() { events(this, _, _, _, result) }
|
||||
override Event getUnboundDeclaration() { events(this, _, _, _, result) }
|
||||
|
||||
override Event getOverridee() { result = DeclarationWithAccessors.super.getOverridee() }
|
||||
|
||||
@@ -88,7 +88,7 @@ class EventAccessor extends Accessor, @event_accessor {
|
||||
|
||||
override string getAssemblyName() { event_accessors(this, _, result, _, _) }
|
||||
|
||||
override EventAccessor getSourceDeclaration() { event_accessors(this, _, _, _, result) }
|
||||
override EventAccessor getUnboundDeclaration() { event_accessors(this, _, _, _, result) }
|
||||
|
||||
override Event getDeclaration() { event_accessors(this, _, _, result, _) }
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* and its constructed generics (`ConstructedGeneric*`).
|
||||
*
|
||||
* Generics can be partially constructed if they are unbound generics contained
|
||||
* within constructed generic types. The predicate `getSourceDeclaration` refers
|
||||
* within constructed generic types. The predicate `getUnboundDeclaration` refers
|
||||
* to the ultimate `UnboundGeneric` type/method as defined in the source code.
|
||||
*/
|
||||
|
||||
@@ -58,8 +58,8 @@ class ConstructedGeneric extends DotNet::ConstructedGeneric, Generic {
|
||||
|
||||
override UnboundGeneric getUnboundGeneric() { constructed_generic(this, result) }
|
||||
|
||||
override UnboundGeneric getSourceDeclaration() {
|
||||
result = getUnboundGeneric().getSourceDeclaration()
|
||||
override UnboundGeneric getUnboundDeclaration() {
|
||||
result = getUnboundGeneric().getUnboundDeclaration()
|
||||
}
|
||||
|
||||
override int getNumberOfTypeArguments() { result = count(int i | type_arguments(_, i, this)) }
|
||||
@@ -114,8 +114,8 @@ class UnboundGenericType extends ValueOrRefType, UnboundGeneric {
|
||||
result = getNameWithoutBrackets() + "<" + this.typeParametersToString() + ">"
|
||||
}
|
||||
|
||||
override UnboundGenericType getSourceDeclaration() {
|
||||
result = ValueOrRefType.super.getSourceDeclaration()
|
||||
override UnboundGenericType getUnboundDeclaration() {
|
||||
result = ValueOrRefType.super.getUnboundDeclaration()
|
||||
}
|
||||
|
||||
final override Type getChild(int n) { result = getTypeParameter(n) }
|
||||
@@ -168,7 +168,7 @@ class TypeParameter extends DotNet::TypeParameter, Type, @type_parameter {
|
||||
// A<int>.B<int> is a ConstructedGenericClass.
|
||||
exists(ConstructedGeneric c, UnboundGeneric u, int tpi |
|
||||
this = u.getTypeParameter(tpi) and
|
||||
(u = c.getUnboundGeneric() or u = c.getSourceDeclaration()) and
|
||||
(u = c.getUnboundGeneric() or u = c.getUnboundDeclaration()) and
|
||||
result = c.getTypeArgument(tpi)
|
||||
)
|
||||
}
|
||||
@@ -251,8 +251,8 @@ class UnboundGenericStruct extends Struct, UnboundGenericType {
|
||||
result = UnboundGenericType.super.getAConstructedGeneric()
|
||||
}
|
||||
|
||||
override UnboundGenericStruct getSourceDeclaration() {
|
||||
result = UnboundGenericType.super.getSourceDeclaration()
|
||||
override UnboundGenericStruct getUnboundDeclaration() {
|
||||
result = UnboundGenericType.super.getUnboundDeclaration()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,8 +274,8 @@ class UnboundGenericClass extends Class, UnboundGenericType {
|
||||
result = UnboundGenericType.super.getAConstructedGeneric()
|
||||
}
|
||||
|
||||
override UnboundGenericClass getSourceDeclaration() {
|
||||
result = UnboundGenericType.super.getSourceDeclaration()
|
||||
override UnboundGenericClass getUnboundDeclaration() {
|
||||
result = UnboundGenericType.super.getUnboundDeclaration()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,8 +297,8 @@ class UnboundGenericInterface extends Interface, UnboundGenericType {
|
||||
result = UnboundGenericType.super.getAConstructedGeneric()
|
||||
}
|
||||
|
||||
override UnboundGenericInterface getSourceDeclaration() {
|
||||
result = UnboundGenericType.super.getSourceDeclaration()
|
||||
override UnboundGenericInterface getUnboundDeclaration() {
|
||||
result = UnboundGenericType.super.getUnboundDeclaration()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,8 +321,8 @@ class UnboundGenericDelegateType extends DelegateType, UnboundGenericType {
|
||||
result = UnboundGenericType.super.getAConstructedGeneric()
|
||||
}
|
||||
|
||||
override UnboundGenericDelegateType getSourceDeclaration() {
|
||||
result = UnboundGenericType.super.getSourceDeclaration()
|
||||
override UnboundGenericDelegateType getUnboundDeclaration() {
|
||||
result = UnboundGenericType.super.getUnboundDeclaration()
|
||||
}
|
||||
|
||||
override string toStringWithTypes() {
|
||||
@@ -345,11 +345,11 @@ class UnboundGenericDelegateType extends DelegateType, UnboundGenericType {
|
||||
* or constructed method (`ConstructedMethod`).
|
||||
*/
|
||||
class ConstructedType extends ValueOrRefType, ConstructedGeneric {
|
||||
override UnboundGenericType getSourceDeclaration() {
|
||||
result = ConstructedGeneric.super.getSourceDeclaration()
|
||||
override UnboundGenericType getUnboundDeclaration() {
|
||||
result = ConstructedGeneric.super.getUnboundDeclaration()
|
||||
}
|
||||
|
||||
override Location getALocation() { result = this.getSourceDeclaration().getALocation() }
|
||||
override Location getALocation() { result = this.getUnboundDeclaration().getALocation() }
|
||||
|
||||
override Type getTypeArgument(int n) { type_arguments(getTypeRef(result), n, getTypeRef(this)) }
|
||||
|
||||
@@ -387,8 +387,8 @@ class ConstructedType extends ValueOrRefType, ConstructedGeneric {
|
||||
* ```
|
||||
*/
|
||||
class ConstructedStruct extends Struct, ConstructedType {
|
||||
override UnboundGenericStruct getSourceDeclaration() {
|
||||
result = ConstructedType.super.getSourceDeclaration()
|
||||
override UnboundGenericStruct getUnboundDeclaration() {
|
||||
result = ConstructedType.super.getUnboundDeclaration()
|
||||
}
|
||||
|
||||
override UnboundGenericStruct getUnboundGeneric() {
|
||||
@@ -410,8 +410,8 @@ class ConstructedStruct extends Struct, ConstructedType {
|
||||
* ```
|
||||
*/
|
||||
class ConstructedClass extends Class, ConstructedType {
|
||||
override UnboundGenericClass getSourceDeclaration() {
|
||||
result = ConstructedType.super.getSourceDeclaration()
|
||||
override UnboundGenericClass getUnboundDeclaration() {
|
||||
result = ConstructedType.super.getUnboundDeclaration()
|
||||
}
|
||||
|
||||
override UnboundGenericClass getUnboundGeneric() {
|
||||
@@ -433,8 +433,8 @@ class ConstructedClass extends Class, ConstructedType {
|
||||
* ```
|
||||
*/
|
||||
class ConstructedInterface extends Interface, ConstructedType {
|
||||
override UnboundGenericInterface getSourceDeclaration() {
|
||||
result = ConstructedType.super.getSourceDeclaration()
|
||||
override UnboundGenericInterface getUnboundDeclaration() {
|
||||
result = ConstructedType.super.getUnboundDeclaration()
|
||||
}
|
||||
|
||||
override UnboundGenericInterface getUnboundGeneric() {
|
||||
@@ -456,8 +456,8 @@ class ConstructedInterface extends Interface, ConstructedType {
|
||||
* ```
|
||||
*/
|
||||
class ConstructedDelegateType extends DelegateType, ConstructedType {
|
||||
override UnboundGenericDelegateType getSourceDeclaration() {
|
||||
result = ConstructedType.super.getSourceDeclaration()
|
||||
override UnboundGenericDelegateType getUnboundDeclaration() {
|
||||
result = ConstructedType.super.getUnboundDeclaration()
|
||||
}
|
||||
|
||||
override UnboundGenericDelegateType getUnboundGeneric() {
|
||||
@@ -510,7 +510,7 @@ class UnboundGenericMethod extends Method, UnboundGeneric {
|
||||
* corresponds to `UnboundGenericType`.
|
||||
*/
|
||||
class ConstructedMethod extends Method, ConstructedGeneric {
|
||||
override Location getALocation() { result = this.getSourceDeclaration().getALocation() }
|
||||
override Location getALocation() { result = this.getUnboundDeclaration().getALocation() }
|
||||
|
||||
override Type getTypeArgument(int n) { type_arguments(getTypeRef(result), n, this) }
|
||||
|
||||
@@ -521,8 +521,8 @@ class ConstructedMethod extends Method, ConstructedGeneric {
|
||||
getName() + "<" + this.typeArgumentsToString() + ">" + "(" + parameterTypesToString() + ")"
|
||||
}
|
||||
|
||||
override UnboundGenericMethod getSourceDeclaration() {
|
||||
result = Method.super.getSourceDeclaration()
|
||||
override UnboundGenericMethod getUnboundDeclaration() {
|
||||
result = Method.super.getUnboundDeclaration()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -557,8 +557,8 @@ class UnboundLocalFunction extends LocalFunction, UnboundGeneric {
|
||||
* ```
|
||||
*/
|
||||
class ConstructedLocalFunction extends LocalFunction, ConstructedGeneric {
|
||||
override UnboundLocalFunction getSourceDeclaration() {
|
||||
result = LocalFunction.super.getSourceDeclaration()
|
||||
override UnboundLocalFunction getUnboundDeclaration() {
|
||||
result = LocalFunction.super.getUnboundDeclaration()
|
||||
}
|
||||
|
||||
override UnboundLocalFunction getUnboundGeneric() {
|
||||
|
||||
@@ -351,7 +351,7 @@ private module Gvn {
|
||||
|
||||
private Unification::GenericType getConstructedGenericDeclaringTypeAt(int i) {
|
||||
i = 0 and
|
||||
result = this.getKind().getConstructedSourceDeclaration()
|
||||
result = this.getKind().getConstructedUnboundDeclaration()
|
||||
or
|
||||
result = this.getConstructedGenericDeclaringTypeAt(i - 1).getGenericDeclaringType()
|
||||
}
|
||||
|
||||
@@ -16,8 +16,11 @@ private import TypeRef
|
||||
class Declaration extends DotNet::Declaration, Element, @declaration {
|
||||
override ValueOrRefType getDeclaringType() { none() }
|
||||
|
||||
/** Holds if this declaration is unbound. */
|
||||
final predicate isUnboundDeclaration() { this = this.getUnboundDeclaration() }
|
||||
|
||||
/** Holds if this declaration is unconstructed and in source code. */
|
||||
predicate isSourceDeclaration() { fromSource() and this = getSourceDeclaration() }
|
||||
final predicate isSourceDeclaration() { this.fromSource() and this.isUnboundDeclaration() }
|
||||
|
||||
override string toString() { result = this.getName() }
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ class Property extends DotNet::Property, DeclarationWithGetSetAccessors, @proper
|
||||
not this.getAnAccessor().hasBody()
|
||||
}
|
||||
|
||||
override Property getSourceDeclaration() { properties(this, _, _, _, result) }
|
||||
override Property getUnboundDeclaration() { properties(this, _, _, _, result) }
|
||||
|
||||
override Property getOverridee() { result = DeclarationWithGetSetAccessors.super.getOverridee() }
|
||||
|
||||
@@ -274,7 +274,7 @@ class Indexer extends DeclarationWithGetSetAccessors, Parameterizable, @indexer
|
||||
result = DeclarationWithGetSetAccessors.super.getExpressionBody()
|
||||
}
|
||||
|
||||
override Indexer getSourceDeclaration() { indexers(this, _, _, _, result) }
|
||||
override Indexer getUnboundDeclaration() { indexers(this, _, _, _, result) }
|
||||
|
||||
override Indexer getOverridee() { result = DeclarationWithGetSetAccessors.super.getOverridee() }
|
||||
|
||||
@@ -370,7 +370,7 @@ class Accessor extends Callable, Modifiable, Attributable, @callable_accessor {
|
||||
not (result instanceof AccessModifier and exists(getAnAccessModifier()))
|
||||
}
|
||||
|
||||
override Accessor getSourceDeclaration() { accessors(this, _, _, _, result) }
|
||||
override Accessor getUnboundDeclaration() { accessors(this, _, _, _, result) }
|
||||
|
||||
override Location getALocation() { accessor_location(this, result) }
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ private import TypeRef
|
||||
class Type extends DotNet::Type, Member, TypeContainer, @type {
|
||||
override string getName() { types(this, _, result) }
|
||||
|
||||
override Type getSourceDeclaration() { result = this }
|
||||
override Type getUnboundDeclaration() { result = this }
|
||||
|
||||
/** Holds if this type is implicitly convertible to `that` type. */
|
||||
predicate isImplicitlyConvertibleTo(Type that) { implicitConversion(this, that) }
|
||||
@@ -367,11 +367,11 @@ class ValueOrRefType extends DotNet::ValueOrRefType, Type, Attributable, @value_
|
||||
/** Gets the number of callables in this type. */
|
||||
int getNumberOfCallables() { result = count(Callable c | this.getAMember() = c) }
|
||||
|
||||
override ValueOrRefType getSourceDeclaration() {
|
||||
override ValueOrRefType getUnboundDeclaration() {
|
||||
result = this and
|
||||
not this instanceof NestedType
|
||||
or
|
||||
// We must use `nested_types` here, rather than overriding `getSourceDeclaration`
|
||||
// We must use `nested_types` here, rather than overriding `getUnboundDeclaration`
|
||||
// in the class `NestedType` below. Otherwise, the overrides in `UnboundGenericType`
|
||||
// and its subclasses will not work
|
||||
nested_types(this, _, result)
|
||||
|
||||
@@ -94,13 +94,13 @@ module Gvn {
|
||||
or
|
||||
this = TArrayTypeKind(_, _) and result = 1
|
||||
or
|
||||
exists(GenericType t | this = TConstructedType(t.getSourceDeclaration()) |
|
||||
exists(GenericType t | this = TConstructedType(t.getUnboundDeclaration()) |
|
||||
result = t.getNumberOfArguments()
|
||||
)
|
||||
}
|
||||
|
||||
/** Gets the source declaration type that this kind corresponds to, if any. */
|
||||
GenericType getConstructedSourceDeclaration() { this = TConstructedType(result) }
|
||||
/** Gets the unbound declaration type that this kind corresponds to, if any. */
|
||||
GenericType getConstructedUnboundDeclaration() { this = TConstructedType(result) }
|
||||
|
||||
/**
|
||||
* Gets a textual representation of this kind when applied to arguments `args`.
|
||||
@@ -123,7 +123,7 @@ module Gvn {
|
||||
string toString() {
|
||||
result = this.toStringBuiltin("")
|
||||
or
|
||||
result = this.getConstructedSourceDeclaration().toStringNested()
|
||||
result = this.getConstructedUnboundDeclaration().toStringNested()
|
||||
}
|
||||
|
||||
/** Gets the location of this kind. */
|
||||
@@ -138,9 +138,9 @@ module Gvn {
|
||||
or
|
||||
t = any(ArrayType at | result = TArrayTypeKind(at.getDimension(), at.getRank()))
|
||||
or
|
||||
result = TConstructedType(t.getSourceDeclaration())
|
||||
result = TConstructedType(t.getUnboundDeclaration())
|
||||
or
|
||||
result = TConstructedType(t.(TupleType).getUnderlyingType().getSourceDeclaration())
|
||||
result = TConstructedType(t.(TupleType).getUnderlyingType().getUnboundDeclaration())
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -230,7 +230,7 @@ module Gvn {
|
||||
|
||||
private GenericType getConstructedGenericDeclaringTypeAt(int i) {
|
||||
i = 0 and
|
||||
result = this.getKind().getConstructedSourceDeclaration()
|
||||
result = this.getKind().getConstructedUnboundDeclaration()
|
||||
or
|
||||
result = this.getConstructedGenericDeclaringTypeAt(i - 1).getGenericDeclaringType()
|
||||
}
|
||||
@@ -499,12 +499,12 @@ module Gvn {
|
||||
TArrayTypeKind(int dim, int rnk) {
|
||||
exists(ArrayType at | dim = at.getDimension() and rnk = at.getRank())
|
||||
} or
|
||||
TConstructedType(GenericType sourceDecl) {
|
||||
sourceDecl = any(GenericType t).getSourceDeclaration() and
|
||||
not sourceDecl instanceof PointerType and
|
||||
not sourceDecl instanceof NullableType and
|
||||
not sourceDecl instanceof ArrayType and
|
||||
not sourceDecl instanceof TupleType
|
||||
TConstructedType(GenericType unboundDecl) {
|
||||
unboundDecl = any(GenericType t).getUnboundDeclaration() and
|
||||
not unboundDecl instanceof PointerType and
|
||||
not unboundDecl instanceof NullableType and
|
||||
not unboundDecl instanceof ArrayType and
|
||||
not unboundDecl instanceof TupleType
|
||||
}
|
||||
|
||||
cached
|
||||
|
||||
@@ -15,7 +15,7 @@ private import TypeRef
|
||||
* A variable. Either a variable with local scope (`LocalScopeVariable`) or a field (`Field`).
|
||||
*/
|
||||
class Variable extends Assignable, DotNet::Variable, @variable {
|
||||
override Variable getSourceDeclaration() { result = this }
|
||||
override Variable getUnboundDeclaration() { result = this }
|
||||
|
||||
override VariableAccess getAnAccess() { result.getTarget() = this }
|
||||
|
||||
@@ -179,7 +179,7 @@ class Parameter extends DotNet::Parameter, LocalScopeVariable, Attributable, Top
|
||||
/** Gets the declaring element of this parameter. */
|
||||
Parameterizable getDeclaringElement() { params(this, _, _, _, _, result, _) }
|
||||
|
||||
override Parameter getSourceDeclaration() { params(this, _, _, _, _, _, result) }
|
||||
override Parameter getUnboundDeclaration() { params(this, _, _, _, _, _, result) }
|
||||
|
||||
override ValueOrRefType getDeclaringType() {
|
||||
exists(Parameterizable p | p = this.getDeclaringElement() |
|
||||
@@ -207,7 +207,7 @@ class Parameter extends DotNet::Parameter, LocalScopeVariable, Attributable, Top
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
Expr getDefaultValue() { result = this.getSourceDeclaration().getChildExpr(0) }
|
||||
Expr getDefaultValue() { result = this.getUnboundDeclaration().getChildExpr(0) }
|
||||
|
||||
/** Holds if this parameter has a default value. */
|
||||
predicate hasDefaultValue() { exists(getDefaultValue()) }
|
||||
@@ -397,7 +397,7 @@ class Field extends Variable, AssignableMember, Attributable, TopLevelExprParent
|
||||
/** Holds if this field is `readonly`. */
|
||||
predicate isReadOnly() { this.hasModifier("readonly") }
|
||||
|
||||
override Field getSourceDeclaration() { fields(this, _, _, _, _, result) }
|
||||
override Field getUnboundDeclaration() { fields(this, _, _, _, _, result) }
|
||||
|
||||
override FieldAccess getAnAccess() { result = Variable.super.getAnAccess() }
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ private newtype TComparisonTest =
|
||||
m = any(SystemIComparableInterface i).getCompareToMethod()
|
||||
or
|
||||
m = any(SystemIComparableTInterface i).getAConstructedGeneric().getAMethod() and
|
||||
m.getSourceDeclaration() = any(SystemIComparableTInterface i).getCompareToMethod()
|
||||
m.getUnboundDeclaration() = any(SystemIComparableTInterface i).getCompareToMethod()
|
||||
)
|
||||
} or
|
||||
TCompareCall(MethodCall mc) {
|
||||
@@ -116,7 +116,7 @@ private newtype TComparisonTest =
|
||||
m = any(SystemCollectionsIComparerInterface i).getCompareMethod()
|
||||
or
|
||||
m = any(SystemCollectionsGenericIComparerTInterface i).getAConstructedGeneric().getAMethod() and
|
||||
m.getSourceDeclaration() =
|
||||
m.getUnboundDeclaration() =
|
||||
any(SystemCollectionsGenericIComparerTInterface i).getCompareMethod()
|
||||
)
|
||||
} or
|
||||
|
||||
@@ -23,7 +23,7 @@ private predicate disposedCilVariable(CIL::Variable variable) {
|
||||
)
|
||||
or
|
||||
// A parameter is disposed if its source declaration is disposed
|
||||
disposedCilVariable(variable.(CIL::Parameter).getSourceDeclaration())
|
||||
disposedCilVariable(variable.(CIL::Parameter).getUnboundDeclaration())
|
||||
or
|
||||
// A variable is disposed if it's assigned to another variable
|
||||
// that may be disposed.
|
||||
@@ -59,7 +59,7 @@ private predicate disposedCSharpVariable(Variable variable) {
|
||||
)
|
||||
or
|
||||
// A parameter is disposed if its source declaration is disposed
|
||||
disposedCSharpVariable(variable.(Parameter).getSourceDeclaration())
|
||||
disposedCSharpVariable(variable.(Parameter).getUnboundDeclaration())
|
||||
or
|
||||
// A variable is disposed if it's assigned to another variable that is disposed
|
||||
exists(AssignableDefinition assign |
|
||||
|
||||
@@ -484,14 +484,14 @@ class CollectionExpr extends Expr {
|
||||
pr
|
||||
.getTarget()
|
||||
.overridesOrImplementsOrEquals(any(Property p |
|
||||
p.getSourceDeclaration() =
|
||||
p.getUnboundDeclaration() =
|
||||
any(SystemCollectionsGenericICollectionInterface x).getCountProperty()
|
||||
))
|
||||
)
|
||||
or
|
||||
result =
|
||||
any(MethodCall mc |
|
||||
mc.getTarget().getSourceDeclaration() =
|
||||
mc.getTarget().getUnboundDeclaration() =
|
||||
any(SystemLinq::SystemLinqEnumerableClass x).getACountMethod() and
|
||||
this = mc.getArgument(0) and
|
||||
if mc.getNumberOfArguments() = 1 then lowerBound = false else lowerBound = true
|
||||
@@ -544,7 +544,7 @@ class CollectionExpr extends Expr {
|
||||
or
|
||||
result =
|
||||
any(MethodCall mc |
|
||||
mc.getTarget().getSourceDeclaration() =
|
||||
mc.getTarget().getUnboundDeclaration() =
|
||||
any(SystemLinq::SystemLinqEnumerableClass x).getAnAnyMethod() and
|
||||
this = mc.getArgument(0) and
|
||||
branch = isEmpty.booleanNot() and
|
||||
@@ -842,7 +842,7 @@ module Internal {
|
||||
or
|
||||
e instanceof DefaultValueExpr and e.getType().isRefType()
|
||||
or
|
||||
e.(Call).getTarget().getSourceDeclaration() instanceof NullCallable
|
||||
e.(Call).getTarget().getUnboundDeclaration() instanceof NullCallable
|
||||
}
|
||||
|
||||
/** Holds if expression `e2` is a `null` value whenever `e1` is. */
|
||||
@@ -893,7 +893,7 @@ module Internal {
|
||||
or
|
||||
e.(DefaultValueExpr).getType().isValueType()
|
||||
or
|
||||
e.(Call).getTarget().getSourceDeclaration() instanceof NonNullCallable and
|
||||
e.(Call).getTarget().getUnboundDeclaration() instanceof NonNullCallable and
|
||||
not e.(QualifiableExpr).isConditional()
|
||||
or
|
||||
e instanceof SuppressNullableWarningExpr
|
||||
@@ -1428,8 +1428,8 @@ module Internal {
|
||||
cached
|
||||
predicate isCustomNullCheck(Call call, Expr arg, BooleanValue v, boolean isNull) {
|
||||
exists(Callable callable, Parameter p |
|
||||
arg = call.getArgumentForParameter(any(Parameter p0 | p0.getSourceDeclaration() = p)) and
|
||||
call.getTarget().getSourceDeclaration() = callable and
|
||||
arg = call.getArgumentForParameter(any(Parameter p0 | p0.getUnboundDeclaration() = p)) and
|
||||
call.getTarget().getUnboundDeclaration() = callable and
|
||||
callable = customNullCheck(p, v, isNull)
|
||||
)
|
||||
}
|
||||
@@ -1645,7 +1645,7 @@ module Internal {
|
||||
exists(PreSsa::Definition def | emptyDef(def) | firstReadSameVarUniquePredecesssor(def, e))
|
||||
or
|
||||
exists(MethodCall mc |
|
||||
mc.getTarget().getAnUltimateImplementee().getSourceDeclaration() =
|
||||
mc.getTarget().getAnUltimateImplementee().getUnboundDeclaration() =
|
||||
any(SystemCollectionsGenericICollectionInterface c).getClearMethod() and
|
||||
adjacentReadPairSameVarUniquePredecessor(mc.getQualifier(), e)
|
||||
)
|
||||
@@ -1670,7 +1670,7 @@ module Internal {
|
||||
)
|
||||
or
|
||||
exists(MethodCall mc |
|
||||
mc.getTarget().getAnUltimateImplementee().getSourceDeclaration() =
|
||||
mc.getTarget().getAnUltimateImplementee().getUnboundDeclaration() =
|
||||
any(SystemCollectionsGenericICollectionInterface c).getAddMethod() and
|
||||
adjacentReadPairSameVarUniquePredecessor(mc.getQualifier(), e)
|
||||
)
|
||||
|
||||
@@ -245,7 +245,7 @@ module InitializerSplitting {
|
||||
* of member `m`.
|
||||
*/
|
||||
predicate constructorInitializes(Constructor c, InitializedInstanceMember m) {
|
||||
c = c.getSourceDeclaration() and
|
||||
c.isUnboundDeclaration() and
|
||||
not c.isStatic() and
|
||||
c.getDeclaringType().hasMember(m) and
|
||||
(
|
||||
|
||||
@@ -27,13 +27,13 @@ module ContentList {
|
||||
/** Gets a singleton property content list. */
|
||||
ContentList property(Property p) {
|
||||
result =
|
||||
singleton(any(DataFlowPublic::PropertyContent c | c.getProperty() = p.getSourceDeclaration()))
|
||||
singleton(any(DataFlowPublic::PropertyContent c | c.getProperty() = p.getUnboundDeclaration()))
|
||||
}
|
||||
|
||||
/** Gets a singleton field content list. */
|
||||
ContentList field(Field f) {
|
||||
result =
|
||||
singleton(any(DataFlowPublic::FieldContent c | c.getField() = f.getSourceDeclaration()))
|
||||
singleton(any(DataFlowPublic::FieldContent c | c.getField() = f.getUnboundDeclaration()))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -94,12 +94,12 @@ module AccessPath {
|
||||
|
||||
/** Gets a singleton property access path. */
|
||||
AccessPath property(Property p) {
|
||||
result = singleton(any(PropertyContent c | c.getProperty() = p.getSourceDeclaration()))
|
||||
result = singleton(any(PropertyContent c | c.getProperty() = p.getUnboundDeclaration()))
|
||||
}
|
||||
|
||||
/** Gets a singleton field access path. */
|
||||
AccessPath field(Field f) {
|
||||
result = singleton(any(FieldContent c | c.getField() = f.getSourceDeclaration()))
|
||||
result = singleton(any(FieldContent c | c.getField() = f.getUnboundDeclaration()))
|
||||
}
|
||||
|
||||
/** Gets an access path representing a property inside a collection. */
|
||||
@@ -108,7 +108,7 @@ module AccessPath {
|
||||
|
||||
/** An unbound callable. */
|
||||
class SourceDeclarationCallable extends Callable {
|
||||
SourceDeclarationCallable() { this = this.getSourceDeclaration() }
|
||||
SourceDeclarationCallable() { this.isUnboundDeclaration() }
|
||||
}
|
||||
|
||||
/** An unbound method. */
|
||||
@@ -301,7 +301,7 @@ class CallableFlowSinkDelegateArg extends CallableFlowSink, TCallableFlowSinkDel
|
||||
|
||||
/** A specification of data flow for a library (non-source code) type. */
|
||||
abstract class LibraryTypeDataFlow extends Type {
|
||||
LibraryTypeDataFlow() { this = this.getSourceDeclaration() }
|
||||
LibraryTypeDataFlow() { this = this.getUnboundDeclaration() }
|
||||
|
||||
/**
|
||||
* Holds if data may flow from `source` to `sink` when calling callable `c`.
|
||||
@@ -779,7 +779,7 @@ class SystemLazyFlow extends LibraryTypeDataFlow, SystemLazyClass {
|
||||
preservesValue = true and
|
||||
exists(SystemFuncDelegateType t, int i | t.getNumberOfTypeParameters() = 1 |
|
||||
c.(Constructor).getDeclaringType() = this and
|
||||
c.getParameter(i).getType().getSourceDeclaration() = t and
|
||||
c.getParameter(i).getType().getUnboundDeclaration() = t and
|
||||
source = getDelegateFlowSourceArg(c, i) and
|
||||
sourceAp = AccessPath::empty() and
|
||||
sink = TCallableFlowSinkReturn() and
|
||||
@@ -917,7 +917,7 @@ class IEnumerableFlow extends LibraryTypeDataFlow, RefType {
|
||||
CallableFlowSource source, AccessPath sourceAp, CallableFlowSink sink, AccessPath sinkAp,
|
||||
SourceDeclarationMethod m
|
||||
) {
|
||||
m.(ExtensionMethod).getExtendedType().getSourceDeclaration() = this and
|
||||
m.(ExtensionMethod).getExtendedType().getUnboundDeclaration() = this and
|
||||
exists(string name, int arity | name = m.getName() and arity = m.getNumberOfParameters() |
|
||||
name = "Aggregate" and
|
||||
(
|
||||
@@ -1123,7 +1123,7 @@ class IEnumerableFlow extends LibraryTypeDataFlow, RefType {
|
||||
sink = getDelegateFlowSinkArg(m, 2, 0) and
|
||||
sinkAp = AccessPath::empty()
|
||||
or
|
||||
not m.getParameter(2).getType().getSourceDeclaration() instanceof
|
||||
not m.getParameter(2).getType().getUnboundDeclaration() instanceof
|
||||
SystemCollectionsGenericIEqualityComparerTInterface and
|
||||
source = getDelegateFlowSourceArg(m, 2) and
|
||||
sourceAp = AccessPath::empty() and
|
||||
@@ -1437,7 +1437,7 @@ class IEnumerableFlow extends LibraryTypeDataFlow, RefType {
|
||||
/** Data flow for `System.Collections.[Generic.]ICollection` (and sub types). */
|
||||
class ICollectionFlow extends LibraryTypeDataFlow, RefType {
|
||||
ICollectionFlow() {
|
||||
exists(Interface i | i = this.getABaseType*().getSourceDeclaration() |
|
||||
exists(Interface i | i = this.getABaseType*().getUnboundDeclaration() |
|
||||
i instanceof SystemCollectionsICollectionInterface
|
||||
or
|
||||
i instanceof SystemCollectionsGenericICollectionInterface
|
||||
@@ -1486,7 +1486,7 @@ class ICollectionFlow extends LibraryTypeDataFlow, RefType {
|
||||
/** Data flow for `System.Collections.[Generic.]IList` (and sub types). */
|
||||
class IListFlow extends LibraryTypeDataFlow, RefType {
|
||||
IListFlow() {
|
||||
exists(Interface i | i = this.getABaseType*().getSourceDeclaration() |
|
||||
exists(Interface i | i = this.getABaseType*().getUnboundDeclaration() |
|
||||
i instanceof SystemCollectionsIListInterface
|
||||
or
|
||||
i instanceof SystemCollectionsGenericIListInterface
|
||||
@@ -1536,7 +1536,7 @@ class IListFlow extends LibraryTypeDataFlow, RefType {
|
||||
/** Data flow for `System.Collections.[Generic.]IDictionary` (and sub types). */
|
||||
class IDictionaryFlow extends LibraryTypeDataFlow, RefType {
|
||||
IDictionaryFlow() {
|
||||
exists(Interface i | i = this.getABaseType*().getSourceDeclaration() |
|
||||
exists(Interface i | i = this.getABaseType*().getUnboundDeclaration() |
|
||||
i instanceof SystemCollectionsIDictionaryInterface
|
||||
or
|
||||
i instanceof SystemCollectionsGenericIDictionaryInterface
|
||||
@@ -1776,13 +1776,13 @@ class SystemTupleFlow extends LibraryTypeDataFlow, ValueOrRefType {
|
||||
t = this
|
||||
or
|
||||
c = this.getAMethod(any(string name | name.regexpMatch("Create(<,*>)?"))) and
|
||||
t = c.getReturnType().getSourceDeclaration()
|
||||
t = c.getReturnType().getUnboundDeclaration()
|
||||
)
|
||||
or
|
||||
c =
|
||||
any(ExtensionMethod m |
|
||||
m.hasName("Deconstruct") and
|
||||
this = m.getExtendedType().getSourceDeclaration() and
|
||||
this = m.getExtendedType().getUnboundDeclaration() and
|
||||
exists(int i |
|
||||
m.getParameter(i).isOut() and
|
||||
source = getFlowSourceArg(c, 0, _) and
|
||||
@@ -2179,7 +2179,7 @@ library class SystemTextEncodingFlow extends LibraryTypeDataFlow, SystemTextEnco
|
||||
) {
|
||||
preservesValue = false and
|
||||
c = this.getAMethod() and
|
||||
exists(Method m | m.getAnOverrider*().getSourceDeclaration() = c |
|
||||
exists(Method m | m.getAnOverrider*().getUnboundDeclaration() = c |
|
||||
m = getGetBytesMethod() and
|
||||
source = getFlowSourceArg(m, 0, sourceAp) and
|
||||
sink = TCallableFlowSinkReturn() and
|
||||
|
||||
@@ -153,7 +153,7 @@ private predicate isMaybeNullArgument(Ssa::ExplicitDefinition def, MaybeNullExpr
|
||||
exists(AssignableDefinitions::ImplicitParameterDefinition pdef, Parameter p |
|
||||
pdef = def.getADefinition()
|
||||
|
|
||||
p = pdef.getParameter().getSourceDeclaration() and
|
||||
p = pdef.getParameter().getUnboundDeclaration() and
|
||||
arg = p.getAnAssignedArgument() and
|
||||
not arg.getEnclosingCallable().getEnclosingCallable*() instanceof TestMethod
|
||||
)
|
||||
@@ -163,7 +163,7 @@ private predicate isNullDefaultArgument(Ssa::ExplicitDefinition def, AlwaysNullE
|
||||
exists(AssignableDefinitions::ImplicitParameterDefinition pdef, Parameter p |
|
||||
pdef = def.getADefinition()
|
||||
|
|
||||
p = pdef.getParameter().getSourceDeclaration() and
|
||||
p = pdef.getParameter().getUnboundDeclaration() and
|
||||
arg = p.getDefaultValue() and
|
||||
not arg.getEnclosingCallable().getEnclosingCallable*() instanceof TestMethod
|
||||
)
|
||||
@@ -498,7 +498,7 @@ class Dereference extends G::DereferenceableExpr {
|
||||
|
|
||||
pdef = def.getADefinition()
|
||||
|
|
||||
p.getSourceDeclaration() = pdef.getParameter() and
|
||||
p.getUnboundDeclaration() = pdef.getParameter() and
|
||||
def.getARead() instanceof Dereference
|
||||
)
|
||||
)
|
||||
|
||||
@@ -1050,7 +1050,7 @@ module Ssa {
|
||||
Callable getARuntimeTarget(Call c, boolean libraryDelegateCall) {
|
||||
// Non-delegate call: use dispatch library
|
||||
exists(DispatchCall dc | dc.getCall() = c |
|
||||
result = dc.getADynamicTarget().getSourceDeclaration() and
|
||||
result = dc.getADynamicTarget().getUnboundDeclaration() and
|
||||
libraryDelegateCall = false
|
||||
)
|
||||
or
|
||||
@@ -1090,7 +1090,7 @@ module Ssa {
|
||||
or
|
||||
e =
|
||||
any(CallableAccess ca |
|
||||
c = ca.getTarget().getSourceDeclaration() and
|
||||
c = ca.getTarget().getUnboundDeclaration() and
|
||||
dt = ca.getType()
|
||||
)
|
||||
}
|
||||
@@ -1099,7 +1099,7 @@ module Ssa {
|
||||
Steps::stepClosed(pred, succ)
|
||||
or
|
||||
exists(Call call, Callable callable |
|
||||
callable.getSourceDeclaration().canReturn(pred) and
|
||||
callable.getUnboundDeclaration().canReturn(pred) and
|
||||
call = succ
|
||||
|
|
||||
callable = call.getTarget() or
|
||||
|
||||
@@ -17,30 +17,30 @@ private import semmle.code.csharp.frameworks.system.collections.Generic
|
||||
* code version.
|
||||
*/
|
||||
DotNet::Callable getCallableForDataFlow(DotNet::Callable c) {
|
||||
exists(DotNet::Callable sourceDecl | sourceDecl = c.getSourceDeclaration() |
|
||||
result = sourceDecl and
|
||||
exists(DotNet::Callable unboundDecl | unboundDecl = c.getUnboundDeclaration() |
|
||||
result = unboundDecl and
|
||||
result instanceof SummarizedCallable
|
||||
or
|
||||
result = sourceDecl and
|
||||
result = unboundDecl and
|
||||
FlowSummaryImpl::Private::summary(_, _, _, SummaryOutput::jump(result, _), _, _)
|
||||
or
|
||||
result.hasBody() and
|
||||
if sourceDecl.getFile().fromSource()
|
||||
if unboundDecl.getFile().fromSource()
|
||||
then
|
||||
// C# callable with C# implementation in the database
|
||||
result = sourceDecl
|
||||
result = unboundDecl
|
||||
else
|
||||
if sourceDecl instanceof CIL::Callable
|
||||
if unboundDecl instanceof CIL::Callable
|
||||
then
|
||||
// CIL callable with C# implementation in the database
|
||||
sourceDecl.matchesHandle(result.(Callable))
|
||||
unboundDecl.matchesHandle(result.(Callable))
|
||||
or
|
||||
// CIL callable without C# implementation in the database
|
||||
not sourceDecl.matchesHandle(any(Callable k | k.hasBody())) and
|
||||
result = sourceDecl
|
||||
not unboundDecl.matchesHandle(any(Callable k | k.hasBody())) and
|
||||
result = unboundDecl
|
||||
else
|
||||
// C# callable without C# implementation in the database
|
||||
sourceDecl.matchesHandle(result.(CIL::Callable))
|
||||
unboundDecl.matchesHandle(result.(CIL::Callable))
|
||||
)
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ private module DispatchImpl {
|
||||
.(NonDelegateDataFlowCall)
|
||||
.getDispatchCall()
|
||||
.getADynamicTargetInCallContext(ctx.(NonDelegateDataFlowCall).getDispatchCall())
|
||||
.getSourceDeclaration()
|
||||
.getUnboundDeclaration()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -459,9 +459,9 @@ private predicate fieldOrPropertyStore(Expr e, Content c, Expr src, Expr q, bool
|
||||
|
||||
/** Holds if property `p1` overrides or implements source declaration property `p2`. */
|
||||
private predicate overridesOrImplementsSourceDecl(Property p1, Property p2) {
|
||||
p1.getOverridee*().getSourceDeclaration() = p2
|
||||
p1.getOverridee*().getUnboundDeclaration() = p2
|
||||
or
|
||||
p1.getAnUltimateImplementee().getSourceDeclaration() = p2
|
||||
p1.getAnUltimateImplementee().getUnboundDeclaration() = p2
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -706,8 +706,8 @@ private module Cached {
|
||||
|
||||
cached
|
||||
newtype TContent =
|
||||
TFieldContent(Field f) { f = f.getSourceDeclaration() } or
|
||||
TPropertyContent(Property p) { p = p.getSourceDeclaration() } or
|
||||
TFieldContent(Field f) { f.isUnboundDeclaration() } or
|
||||
TPropertyContent(Property p) { p.isUnboundDeclaration() } or
|
||||
TElementContent()
|
||||
|
||||
/**
|
||||
@@ -1448,7 +1448,7 @@ private module OutNodes {
|
||||
/** A valid return type for a method that uses `yield return`. */
|
||||
private class YieldReturnType extends Type {
|
||||
YieldReturnType() {
|
||||
exists(Type t | t = this.getSourceDeclaration() |
|
||||
exists(Type t | t = this.getUnboundDeclaration() |
|
||||
t instanceof SystemCollectionsIEnumerableInterface
|
||||
or
|
||||
t instanceof SystemCollectionsIEnumeratorInterface
|
||||
@@ -1562,7 +1562,7 @@ private module OutNodes {
|
||||
override DataFlowCall getCall(ReturnKind kind) {
|
||||
result = csharpCall(_, cfn) and
|
||||
exists(Parameter p |
|
||||
p.getSourceDeclaration().getPosition() = kind.(OutRefReturnKind).getPosition() and
|
||||
p.getUnboundDeclaration().getPosition() = kind.(OutRefReturnKind).getPosition() and
|
||||
outRefDef.getTargetAccess() = result.getExpr().(Call).getArgumentForParameter(p)
|
||||
)
|
||||
}
|
||||
@@ -1674,9 +1674,9 @@ class FieldOrProperty extends Assignable, Modifiable {
|
||||
|
||||
/** Gets the content that matches this field or property. */
|
||||
Content getContent() {
|
||||
result.(FieldContent).getField() = this.getSourceDeclaration()
|
||||
result.(FieldContent).getField() = this.getUnboundDeclaration()
|
||||
or
|
||||
result.(PropertyContent).getProperty() = this.getSourceDeclaration()
|
||||
result.(PropertyContent).getProperty() = this.getUnboundDeclaration()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ private class DelegateFlowSource extends DataFlow::ExprNode {
|
||||
this.getExpr() =
|
||||
any(Expr e |
|
||||
c = e.(AnonymousFunctionExpr) or
|
||||
c = e.(CallableAccess).getTarget().getSourceDeclaration()
|
||||
c = e.(CallableAccess).getTarget().getUnboundDeclaration()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ module Public {
|
||||
|
||||
/** An unbound callable. */
|
||||
class SummarizableCallable extends Callable {
|
||||
SummarizableCallable() { this = this.getSourceDeclaration() }
|
||||
SummarizableCallable() { this.isUnboundDeclaration() }
|
||||
}
|
||||
|
||||
/** A flow-summary input specification. */
|
||||
|
||||
@@ -52,7 +52,7 @@ module Steps {
|
||||
private predicate flowIn(Parameter p, Expr pred, AssignableRead succ) {
|
||||
exists(AssignableDefinitions::ImplicitParameterDefinition def, Call c | succ = getARead(def) |
|
||||
pred = getArgumentForOverridderParameter(c, p) and
|
||||
p.getSourceDeclaration() = def.getParameter()
|
||||
p.getUnboundDeclaration() = def.getParameter()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ private module Impl {
|
||||
*/
|
||||
predicate propertyOverrides(Property p, string baseClass, string property) {
|
||||
exists(Property p2 |
|
||||
p2.getSourceDeclaration().getDeclaringType().hasQualifiedName(baseClass) and
|
||||
p2.getUnboundDeclaration().getDeclaringType().hasQualifiedName(baseClass) and
|
||||
p2.hasName(property)
|
||||
|
|
||||
p.overridesOrImplementsOrEquals(p2)
|
||||
|
||||
@@ -239,7 +239,7 @@ private module Internal {
|
||||
|
||||
pragma[noinline]
|
||||
private predicate hasCallable(OverridableCallable source, ValueOrRefType t, OverridableCallable c) {
|
||||
c.getSourceDeclaration() = source and
|
||||
c.getUnboundDeclaration() = source and
|
||||
t.hasCallable(c) and
|
||||
hasOverrider(c, t) and
|
||||
hasQualifierTypeOverridden0(t, _) and
|
||||
@@ -284,9 +284,9 @@ private module Internal {
|
||||
OverridableCallable c, DispatchMethodOrAccessorCall call
|
||||
) {
|
||||
exists(OverridableCallable target | call.getAStaticTarget() = target |
|
||||
c = target.getSourceDeclaration()
|
||||
c = target.getUnboundDeclaration()
|
||||
or
|
||||
c = target.getAnUltimateImplementor().getSourceDeclaration()
|
||||
c = target.getAnUltimateImplementor().getUnboundDeclaration()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -309,8 +309,8 @@ private module Internal {
|
||||
* have a more precise type.
|
||||
*/
|
||||
predicate mayBenefitFromCallContext(Callable c, int i) {
|
||||
1 < strictcount(this.getADynamicTarget().getSourceDeclaration()) and
|
||||
c = this.getCall().getEnclosingCallable().getSourceDeclaration() and
|
||||
1 < strictcount(this.getADynamicTarget().getUnboundDeclaration()) and
|
||||
c = this.getCall().getEnclosingCallable().getUnboundDeclaration() and
|
||||
(
|
||||
exists(AssignableDefinitions::ImplicitParameterDefinition pdef, Parameter p |
|
||||
this.getQualifier() = BaseSsa::getARead(pdef, p) and
|
||||
@@ -331,7 +331,7 @@ private module Internal {
|
||||
*/
|
||||
pragma[nomagic]
|
||||
private predicate relevantContext(DispatchCall ctx, int i) {
|
||||
this.mayBenefitFromCallContext(ctx.getADynamicTarget().getSourceDeclaration(), i)
|
||||
this.mayBenefitFromCallContext(ctx.getADynamicTarget().getUnboundDeclaration(), i)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -356,7 +356,7 @@ private module Internal {
|
||||
exists(Callable staticTarget, Type declType |
|
||||
staticTarget = this.getAStaticTarget() and
|
||||
declType = staticTarget.getDeclaringType() and
|
||||
result = staticTarget.getSourceDeclaration() and
|
||||
result = staticTarget.getUnboundDeclaration() and
|
||||
Unification::subsumes(declType, t)
|
||||
)
|
||||
}
|
||||
@@ -370,7 +370,7 @@ private module Internal {
|
||||
private Callable getASubsumedStaticTarget() {
|
||||
result = this.getAStaticTarget()
|
||||
or
|
||||
result.getSourceDeclaration() = this.getASubsumedStaticTarget0(result.getDeclaringType())
|
||||
result.getUnboundDeclaration() = this.getASubsumedStaticTarget0(result.getDeclaringType())
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -278,7 +278,7 @@ private int getAccessorKind(Accessor a) {
|
||||
event_accessors(a, -result, _, _, _)
|
||||
}
|
||||
|
||||
/** A source declared type. */
|
||||
class SourceDeclarationType extends Type {
|
||||
SourceDeclarationType() { this = this.getSourceDeclaration() }
|
||||
/** An unbound type. */
|
||||
class UnboundDeclarationType extends Type {
|
||||
UnboundDeclarationType() { this.isUnboundDeclaration() }
|
||||
}
|
||||
|
||||
@@ -410,11 +410,11 @@ class ConstructorInitializer extends Call, @constructor_init_expr {
|
||||
override string getAPrimaryQlClass() { result = "ConstructorInitializer" }
|
||||
|
||||
private ValueOrRefType getTargetType() {
|
||||
result = this.getTarget().getDeclaringType().getSourceDeclaration()
|
||||
result = this.getTarget().getDeclaringType().getUnboundDeclaration()
|
||||
}
|
||||
|
||||
private ValueOrRefType getConstructorType() {
|
||||
result = this.getConstructor().getDeclaringType().getSourceDeclaration()
|
||||
result = this.getConstructor().getDeclaringType().getUnboundDeclaration()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -415,7 +415,7 @@ class AnonymousFunctionExpr extends Expr, Callable, @anonymous_function_expr {
|
||||
this.getType().(SystemLinqExpressions::DelegateExtType).getDelegateType().getReturnType()
|
||||
}
|
||||
|
||||
override AnonymousFunctionExpr getSourceDeclaration() { result = this }
|
||||
override AnonymousFunctionExpr getUnboundDeclaration() { result = this }
|
||||
|
||||
override Callable getEnclosingCallable() { result = Expr.super.getEnclosingCallable() }
|
||||
|
||||
|
||||
@@ -263,7 +263,7 @@ module EntityFramework {
|
||||
|
||||
/** A DB Context. */
|
||||
private class DbContextClass extends Class {
|
||||
DbContextClass() { this.getBaseClass*().getSourceDeclaration() instanceof DbContext }
|
||||
DbContextClass() { this.getBaseClass*().getUnboundDeclaration() instanceof DbContext }
|
||||
|
||||
/**
|
||||
* Gets a `DbSet<elementType>` property belonging to this DB context.
|
||||
@@ -281,9 +281,9 @@ module EntityFramework {
|
||||
private Property getADbSetProperty(Class elementType) {
|
||||
exists(ConstructedClass c |
|
||||
result.getType() = c and
|
||||
c.getSourceDeclaration() instanceof DbSet and
|
||||
c.getUnboundDeclaration() instanceof DbSet and
|
||||
elementType = c.getTypeArgument(0) and
|
||||
this.hasMember(any(Property p | result = p.getSourceDeclaration())) and
|
||||
this.hasMember(any(Property p | result = p.getUnboundDeclaration())) and
|
||||
not isNotMapped([result.(Attributable), elementType])
|
||||
)
|
||||
}
|
||||
@@ -320,7 +320,7 @@ module EntityFramework {
|
||||
c1 instanceof PropertyContent and
|
||||
t1.(ValueOrRefType).getABaseType*() = ci and
|
||||
not t1 instanceof StringType and
|
||||
ci.getSourceDeclaration() instanceof SystemCollectionsGenericIEnumerableTInterface and
|
||||
ci.getUnboundDeclaration() instanceof SystemCollectionsGenericIEnumerableTInterface and
|
||||
c2 instanceof ElementContent and
|
||||
t2 = ci.getTypeArgument(0)
|
||||
)
|
||||
|
||||
@@ -554,7 +554,7 @@ class IEquatableEqualsMethod extends Method {
|
||||
IEquatableEqualsMethod() {
|
||||
exists(Method m |
|
||||
m = any(SystemIEquatableTInterface i).getAConstructedGeneric().getAMethod() and
|
||||
m.getSourceDeclaration() = any(SystemIEquatableTInterface i).getEqualsMethod()
|
||||
m.getUnboundDeclaration() = any(SystemIEquatableTInterface i).getEqualsMethod()
|
||||
|
|
||||
this = m or getAnUltimateImplementee() = m
|
||||
)
|
||||
@@ -626,8 +626,8 @@ private IEquatableEqualsMethod getInvokedIEquatableEqualsMethod(ValueOrRefType t
|
||||
/** Whether `eq` calls `ieem` */
|
||||
private predicate callsEqualsMethod(EqualsMethod eq, IEquatableEqualsMethod ieem) {
|
||||
exists(MethodCall callToDerivedEquals |
|
||||
callToDerivedEquals.getEnclosingCallable() = eq.getSourceDeclaration() and
|
||||
callToDerivedEquals.getTarget() = ieem.getSourceDeclaration()
|
||||
callToDerivedEquals.getEnclosingCallable() = eq.getUnboundDeclaration() and
|
||||
callToDerivedEquals.getTarget() = ieem.getUnboundDeclaration()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -709,8 +709,8 @@ private DisposeBoolMethod getInvokedDiposeBoolMethod(ValueOrRefType t, DisposeMe
|
||||
not disp.fromSource()
|
||||
or
|
||||
exists(MethodCall callToDerivedDispose |
|
||||
callToDerivedDispose.getEnclosingCallable() = disp.getSourceDeclaration() and
|
||||
callToDerivedDispose.getTarget() = dbm.getSourceDeclaration()
|
||||
callToDerivedDispose.getEnclosingCallable() = disp.getUnboundDeclaration() and
|
||||
callToDerivedDispose.getTarget() = dbm.getUnboundDeclaration()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ module SystemDataEntity {
|
||||
/** The `System.Data.Entity.DbSet` class. */
|
||||
class DbSet extends Class {
|
||||
DbSet() {
|
||||
this.getSourceDeclaration().(csharp::UnboundGenericClass).getNameWithoutBrackets() = "DbSet"
|
||||
this.getUnboundDeclaration().(csharp::UnboundGenericClass).getNameWithoutBrackets() = "DbSet"
|
||||
}
|
||||
|
||||
/** Gets the `SqlQuery` method. */
|
||||
@@ -99,7 +99,7 @@ module SystemDataEntityInfrastructure {
|
||||
DbRawSqlQuery() {
|
||||
this
|
||||
.getABaseType*()
|
||||
.getSourceDeclaration()
|
||||
.getUnboundDeclaration()
|
||||
.(csharp::UnboundGenericClass)
|
||||
.getNameWithoutBrackets() = "DbRawSqlQuery"
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ class TestCaseSourceAttribute extends Attribute {
|
||||
}
|
||||
|
||||
/** Gets the declaration where the values are declared. */
|
||||
Declaration getSourceDeclaration() {
|
||||
Declaration getUnboundDeclaration() {
|
||||
result.getDeclaringType() = this.getSourceType() and
|
||||
result.getName() = this.getFieldName()
|
||||
}
|
||||
|
||||
@@ -57,41 +57,41 @@ predicate depends(ValueOrRefType t, ValueOrRefType u) {
|
||||
exists(MethodCall mc, Method m |
|
||||
mc.getEnclosingCallable().getDeclaringType() = t and
|
||||
mc.getTarget() = m and
|
||||
usesType(m.getSourceDeclaration().getDeclaringType(), u)
|
||||
usesType(m.getUnboundDeclaration().getDeclaringType(), u)
|
||||
)
|
||||
or
|
||||
exists(ObjectCreation oc |
|
||||
oc.getEnclosingCallable().getDeclaringType() = t and
|
||||
usesType(oc.getObjectType().getSourceDeclaration(), u)
|
||||
usesType(oc.getObjectType().getUnboundDeclaration(), u)
|
||||
)
|
||||
or
|
||||
exists(ObjectCreation oc, Field f |
|
||||
f.getDeclaringType() = t and
|
||||
f.getInitializer().getAChild*() = oc and
|
||||
usesType(oc.getObjectType().getSourceDeclaration(), u)
|
||||
usesType(oc.getObjectType().getUnboundDeclaration(), u)
|
||||
)
|
||||
or
|
||||
exists(DelegateCreation oc |
|
||||
oc.getEnclosingCallable().getDeclaringType() = t and
|
||||
usesType(oc.getDelegateType().getSourceDeclaration(), u)
|
||||
usesType(oc.getDelegateType().getUnboundDeclaration(), u)
|
||||
)
|
||||
or
|
||||
exists(DelegateCall dc, DelegateType dt |
|
||||
dc.getEnclosingCallable().getDeclaringType() = t and
|
||||
dc.getDelegateExpr().getType() = dt and
|
||||
usesType(dt.getSourceDeclaration(), u)
|
||||
usesType(dt.getUnboundDeclaration(), u)
|
||||
)
|
||||
or
|
||||
exists(OperatorCall oc, Operator o |
|
||||
oc.getEnclosingCallable().getDeclaringType() = t and
|
||||
oc.getTarget() = o and
|
||||
usesType(o.getSourceDeclaration().getDeclaringType(), u)
|
||||
usesType(o.getUnboundDeclaration().getDeclaringType(), u)
|
||||
)
|
||||
or
|
||||
exists(MemberAccess ma, Member m |
|
||||
ma.getEnclosingCallable().getDeclaringType() = t and
|
||||
ma.getTarget() = m and
|
||||
usesType(m.getSourceDeclaration().getDeclaringType(), u)
|
||||
usesType(m.getUnboundDeclaration().getDeclaringType(), u)
|
||||
)
|
||||
or
|
||||
exists(LocalVariableDeclExpr e, LocalVariable v |
|
||||
@@ -121,7 +121,7 @@ predicate depends(ValueOrRefType t, ValueOrRefType u) {
|
||||
|
||||
/** does t use dep in any way? */
|
||||
predicate usesType(Type t, Type u) {
|
||||
t.(ValueOrRefType).getSourceDeclaration() = u or
|
||||
t.(ValueOrRefType).getUnboundDeclaration() = u or
|
||||
usesType(t.(ConstructedType).getATypeArgument(), u) or
|
||||
usesType(t.(ArrayType).getElementType(), u)
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ class Callable extends Declaration, @dotnet_callable {
|
||||
/** Holds if this callable has a body or an implementation. */
|
||||
predicate hasBody() { none() }
|
||||
|
||||
override Callable getSourceDeclaration() { result = Declaration.super.getSourceDeclaration() }
|
||||
override Callable getUnboundDeclaration() { result = Declaration.super.getUnboundDeclaration() }
|
||||
|
||||
/** Gets the number of parameters of this callable. */
|
||||
int getNumberOfParameters() { result = count(getAParameter()) }
|
||||
|
||||
@@ -18,8 +18,40 @@ class Declaration extends NamedElement, @dotnet_declaration {
|
||||
/** Gets the type containing this declaration, if any. */
|
||||
Type getDeclaringType() { none() }
|
||||
|
||||
/** Gets the unbound version of this declaration. */
|
||||
Declaration getSourceDeclaration() { result = this }
|
||||
/**
|
||||
* DEPRECATED: Use `getUnboundDeclaration()` instaed.
|
||||
*
|
||||
* Gets the unbound version of this declaration.
|
||||
*/
|
||||
deprecated final Declaration getSourceDeclaration() { result = this.getUnboundDeclaration() }
|
||||
|
||||
/**
|
||||
* Gets the unbound version of this declaration, that is, the declaration where
|
||||
* all type arguments have been removed. For example, in
|
||||
*
|
||||
* ```csharp
|
||||
* class C<T>
|
||||
* {
|
||||
* class Nested
|
||||
* {
|
||||
* }
|
||||
*
|
||||
* void Method<S>() { }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* we have the following
|
||||
*
|
||||
* | Declaration | Unbound declaration |
|
||||
* |-------------------------|---------------------|
|
||||
* | `C<int>` | `C<>` |
|
||||
* | `C<>.Nested` | `C<>.Nested` |
|
||||
* | `C<int>.Nested` | `C<>.Nested` |
|
||||
* | `C<>.Method<>` | `C<>.Method<>` |
|
||||
* | `C<int>.Method<>` | `C<>.Method<>` |
|
||||
* | `C<int>.Method<string>` | `C<>.Method<>` |
|
||||
*/
|
||||
Declaration getUnboundDeclaration() { result = this }
|
||||
}
|
||||
|
||||
/** A member of a type. */
|
||||
|
||||
@@ -5,7 +5,7 @@ from DispatchCall call, Method m
|
||||
where
|
||||
call.getCall().getEnclosingCallable().getName() = "Run" and
|
||||
call.getLocation().getFile().getStem() = "ExactCallable" and
|
||||
strictcount(call.getADynamicTarget().getSourceDeclaration()) = 1 and
|
||||
m = call.getADynamicTarget().getSourceDeclaration() and
|
||||
strictcount(call.getADynamicTarget().getUnboundDeclaration()) = 1 and
|
||||
m = call.getADynamicTarget().getUnboundDeclaration() and
|
||||
m.fromSource()
|
||||
select call, m.toString(), m.getDeclaringType().toString()
|
||||
|
||||
@@ -4,7 +4,7 @@ import semmle.code.csharp.dispatch.Dispatch
|
||||
from DispatchCall call, Callable c
|
||||
where
|
||||
call.getLocation().getFile().getStem() = "ViableCallable" and
|
||||
c = call.getADynamicTarget().getSourceDeclaration() and
|
||||
c = call.getADynamicTarget().getUnboundDeclaration() and
|
||||
(c.fromSource() implies c.getFile().getStem() = "ViableCallable") and
|
||||
(c instanceof Method implies c.getName().regexpMatch("M[0-9]*")) and
|
||||
(c instanceof Accessor implies c.fromSource()) and
|
||||
|
||||
@@ -6,7 +6,7 @@ import semmle.code.csharp.frameworks.system.collections.Generic
|
||||
predicate implementsMethod(Method m, int i) {
|
||||
exists(Method other, Method imp |
|
||||
m.overridesOrImplementsOrEquals(imp) and
|
||||
other = imp.getSourceDeclaration()
|
||||
other = imp.getUnboundDeclaration()
|
||||
|
|
||||
other = any(SystemObjectClass c).getEqualsMethod() and i = 1
|
||||
or
|
||||
|
||||
@@ -2,4 +2,4 @@ import csharp
|
||||
import semmle.code.csharp.frameworks.test.NUnit
|
||||
|
||||
from TestCaseSourceAttribute attribute
|
||||
select attribute.getTarget(), attribute.getSourceDeclaration()
|
||||
select attribute.getTarget(), attribute.getUnboundDeclaration()
|
||||
|
||||
@@ -9,7 +9,7 @@ where
|
||||
framework = e.(TestMethod).getAQlClass() and type = "TestMethod"
|
||||
) and
|
||||
not framework = "NonNestedType" and
|
||||
not framework = "SourceDeclarationType" and
|
||||
not framework = "UnboundDeclarationType" and
|
||||
not framework = "SourceDeclarationCallable" and
|
||||
not framework = "SourceDeclarationMethod" and
|
||||
not framework = "NonConstructedMethod" and
|
||||
|
||||
@@ -45,8 +45,8 @@ query predicate test6(ConstructedClass at, UnboundGenericClass b, ConstructedCla
|
||||
query predicate test7(ConstructedClass aString, ConstructedClass bString) {
|
||||
aString.hasName("A<String>") and
|
||||
bString.hasName("B<String>") and
|
||||
aString.getSourceDeclaration().hasName("A<>") and
|
||||
bString.getSourceDeclaration().hasName("B<>")
|
||||
aString.getUnboundDeclaration().hasName("A<>") and
|
||||
bString.getUnboundDeclaration().hasName("B<>")
|
||||
}
|
||||
|
||||
query predicate test8(ConstructedClass bString, Method m) {
|
||||
@@ -54,7 +54,7 @@ query predicate test8(ConstructedClass bString, Method m) {
|
||||
m.getDeclaringType() = bString and
|
||||
m.hasName("fooParams") and
|
||||
m.getParameter(0).getType().(ArrayType).getElementType() instanceof StringType and
|
||||
m.getSourceDeclaration().getDeclaringType() = m.getDeclaringType().getSourceDeclaration()
|
||||
m.getUnboundDeclaration().getDeclaringType() = m.getDeclaringType().getUnboundDeclaration()
|
||||
}
|
||||
|
||||
query predicate test9(ConstructedClass bString, Setter sourceSetter, Setter setter) {
|
||||
@@ -62,11 +62,11 @@ query predicate test9(ConstructedClass bString, Setter sourceSetter, Setter sett
|
||||
bString.hasName("B<String>") and
|
||||
p.getDeclaringType() = bString and
|
||||
p.hasName("Name") and
|
||||
p.getSourceDeclaration().getDeclaringType() = p.getDeclaringType().getSourceDeclaration() and
|
||||
p.getUnboundDeclaration().getDeclaringType() = p.getDeclaringType().getUnboundDeclaration() and
|
||||
p.getSetter().getParameter(0).getType() instanceof StringType and
|
||||
p.getSetter().getSourceDeclaration() = p.getSourceDeclaration().getSetter() and
|
||||
p.getGetter().getSourceDeclaration() = p.getSourceDeclaration().getGetter() and
|
||||
sourceSetter = p.getSourceDeclaration().getSetter() and
|
||||
p.getSetter().getUnboundDeclaration() = p.getUnboundDeclaration().getSetter() and
|
||||
p.getGetter().getUnboundDeclaration() = p.getUnboundDeclaration().getGetter() and
|
||||
sourceSetter = p.getUnboundDeclaration().getSetter() and
|
||||
setter = p.getSetter()
|
||||
)
|
||||
}
|
||||
@@ -75,26 +75,26 @@ query predicate test10(ConstructedClass bString, Event e) {
|
||||
bString.hasName("B<String>") and
|
||||
e.getDeclaringType() = bString and
|
||||
e.hasName("myEvent") and
|
||||
e.getSourceDeclaration().getDeclaringType() = e.getDeclaringType().getSourceDeclaration() and
|
||||
e.getUnboundDeclaration().getDeclaringType() = e.getDeclaringType().getUnboundDeclaration() and
|
||||
e.getType().(ConstructedDelegateType).getTypeArgument(0) instanceof StringType and
|
||||
e.getAddEventAccessor().getSourceDeclaration() = e.getSourceDeclaration().getAddEventAccessor() and
|
||||
e.getRemoveEventAccessor().getSourceDeclaration() =
|
||||
e.getSourceDeclaration().getRemoveEventAccessor()
|
||||
e.getAddEventAccessor().getUnboundDeclaration() = e.getUnboundDeclaration().getAddEventAccessor() and
|
||||
e.getRemoveEventAccessor().getUnboundDeclaration() =
|
||||
e.getUnboundDeclaration().getRemoveEventAccessor()
|
||||
}
|
||||
|
||||
query predicate test11(ConstructedClass bString, Operator o) {
|
||||
bString.hasName("B<String>") and
|
||||
o.getDeclaringType() = bString and
|
||||
o instanceof IncrementOperator and
|
||||
o.getSourceDeclaration().getDeclaringType() = o.getDeclaringType().getSourceDeclaration()
|
||||
o.getUnboundDeclaration().getDeclaringType() = o.getDeclaringType().getUnboundDeclaration()
|
||||
}
|
||||
|
||||
query predicate test12(ConstructedClass gridInt, Indexer i) {
|
||||
gridInt.hasName("Grid<Int32>") and
|
||||
i.getDeclaringType() = gridInt and
|
||||
i.getSourceDeclaration().getDeclaringType() = i.getDeclaringType().getSourceDeclaration() and
|
||||
i.getGetter().getSourceDeclaration() = i.getSourceDeclaration().getGetter() and
|
||||
i.getSetter().getSourceDeclaration() = i.getSourceDeclaration().getSetter()
|
||||
i.getUnboundDeclaration().getDeclaringType() = i.getDeclaringType().getUnboundDeclaration() and
|
||||
i.getGetter().getUnboundDeclaration() = i.getUnboundDeclaration().getGetter() and
|
||||
i.getSetter().getUnboundDeclaration() = i.getUnboundDeclaration().getSetter()
|
||||
}
|
||||
|
||||
query predicate test13(ConstructedClass gridInt, Indexer i) {
|
||||
@@ -198,11 +198,11 @@ query predicate test25(ConstructedMethod cm) {
|
||||
cm.getParameter(0).getType() instanceof DoubleType and
|
||||
cm.getParameter(1).getType() instanceof IntType and
|
||||
cm.getReturnType() instanceof DoubleType and
|
||||
exists(Method sourceDeclaration |
|
||||
sourceDeclaration = cm.getSourceDeclaration() and
|
||||
sourceDeclaration.getParameter(0).getType().(TypeParameter).hasName("T2") and
|
||||
sourceDeclaration.getParameter(1).getType().(TypeParameter).hasName("T1") and
|
||||
sourceDeclaration.getReturnType().(TypeParameter).hasName("T2")
|
||||
exists(Method unboundDeclaration |
|
||||
unboundDeclaration = cm.getUnboundDeclaration() and
|
||||
unboundDeclaration.getParameter(0).getType().(TypeParameter).hasName("T2") and
|
||||
unboundDeclaration.getParameter(1).getType().(TypeParameter).hasName("T1") and
|
||||
unboundDeclaration.getReturnType().(TypeParameter).hasName("T2")
|
||||
) and
|
||||
exists(Method unbound |
|
||||
unbound = cm.getUnboundGeneric() and
|
||||
@@ -215,7 +215,7 @@ query predicate test25(ConstructedMethod cm) {
|
||||
query predicate test26(ConstructedGeneric cg, string s) {
|
||||
// Source declaration and unbound generic must be unique
|
||||
(
|
||||
strictcount(cg.getSourceDeclaration+()) > 1 or
|
||||
strictcount(cg.getUnboundDeclaration+()) > 1 or
|
||||
strictcount(cg.getUnboundGeneric()) > 1
|
||||
) and
|
||||
s = "Non-unique source decl or unbound generic"
|
||||
@@ -224,7 +224,7 @@ query predicate test26(ConstructedGeneric cg, string s) {
|
||||
query predicate test27(ConstructedType ct, UnboundGenericType ugt, UnboundGenericType sourceDecl) {
|
||||
ct instanceof NestedType and
|
||||
ugt = ct.getUnboundGeneric() and
|
||||
sourceDecl = ct.getSourceDeclaration() and
|
||||
sourceDecl = ct.getUnboundDeclaration() and
|
||||
ugt != sourceDecl
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ query predicate test30(Declaration d, string s) {
|
||||
d.fromSource() and
|
||||
d instanceof @generic and
|
||||
s = d.getQualifiedNameWithTypes() and
|
||||
d != d.getSourceDeclaration() and
|
||||
d != d.getUnboundDeclaration() and
|
||||
not d instanceof Generic
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user