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

Skip to content

Commit 79e3bf8

Browse files
authored
C++: Simplify code.
1 parent 2a3d20d commit 79e3bf8

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,19 @@ class Declaration extends Locatable, @declaration {
139139
this.hasQualifiedName("std", "", name)
140140
}
141141

142+
/**
143+
* Holds if this declaration has the given name in the global namespace,
144+
* the `std` namespace or the `bsl` namespace.
145+
* We treat `std` and `bsl` as the same in a bunch of our models.
146+
*/
147+
predicate hasGlobalOrStdishName(string name) {
148+
this.hasGlobalName(name)
149+
or
150+
this.hasQualifiedName("std", "", name)
151+
or
152+
this.hasQualifiedName("bsl", "", name)
153+
}
154+
142155
/** Gets a specifier of this declaration. */
143156
Specifier getASpecifier() { none() } // overridden in subclasses
144157

cpp/ql/src/semmle/code/cpp/models/implementations/Memset.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import semmle.code.cpp.models.interfaces.SideEffect
1515
private class MemsetFunction extends ArrayFunction, DataFlowFunction, AliasFunction,
1616
SideEffectFunction {
1717
MemsetFunction() {
18-
this.hasQualifiedName(["", "std", "bsl"], "memset")
18+
this.hasGlobalOrStdishName("memset")
1919
or
2020
this.hasGlobalOrStdName("wmemset")
2121
or

0 commit comments

Comments
 (0)