C++: Simplify code.

This commit is contained in:
Cornelius Riemenschneider
2021-02-15 12:13:25 +00:00
committed by GitHub
parent 2a3d20d9a9
commit 79e3bf80c3
2 changed files with 14 additions and 1 deletions

View File

@@ -139,6 +139,19 @@ class Declaration extends Locatable, @declaration {
this.hasQualifiedName("std", "", name)
}
/**
* Holds if this declaration has the given name in the global namespace,
* the `std` namespace or the `bsl` namespace.
* We treat `std` and `bsl` as the same in a bunch of our models.
*/
predicate hasGlobalOrStdishName(string name) {
this.hasGlobalName(name)
or
this.hasQualifiedName("std", "", name)
or
this.hasQualifiedName("bsl", "", name)
}
/** Gets a specifier of this declaration. */
Specifier getASpecifier() { none() } // overridden in subclasses

View File

@@ -15,7 +15,7 @@ import semmle.code.cpp.models.interfaces.SideEffect
private class MemsetFunction extends ArrayFunction, DataFlowFunction, AliasFunction,
SideEffectFunction {
MemsetFunction() {
this.hasQualifiedName(["", "std", "bsl"], "memset")
this.hasGlobalOrStdishName("memset")
or
this.hasGlobalOrStdName("wmemset")
or