Skip to content

Commit 41a540e

Browse files
committed
C++: Make isMicrosoft() faster.
1 parent 4a8299e commit 41a540e

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,11 @@ class File extends Container, @file {
358358
string getShortName() { files(underlyingElement(this), _, result, _, _) }
359359
}
360360

361+
/**
362+
* Holds if any file was compiled by a Microsoft compiler.
363+
*/
364+
cached predicate anyFileCompiledAsMicrosoft() { any(File f).compiledAsMicrosoft() }
365+
361366
/**
362367
* A C/C++ header file, as determined (mainly) by file extension.
363368
*

cpp/ql/src/semmle/code/cpp/commons/Printf.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ class FormatLiteral extends Literal {
306306
* Holds if this `FormatLiteral` is in a context that supports
307307
* Microsoft rules and extensions.
308308
*/
309-
predicate isMicrosoft() { any(File f).compiledAsMicrosoft() }
309+
predicate isMicrosoft() { anyFileCompiledAsMicrosoft() }
310310

311311
/**
312312
* Gets the format string, with '%%' and '%@' replaced by '_' (to avoid processing

cpp/ql/src/semmle/code/cpp/models/interfaces/FormattingFunction.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ abstract class FormattingFunction extends ArrayFunction, TaintFunction {
5050
* Holds if this `FormattingFunction` is in a context that supports
5151
* Microsoft rules and extensions.
5252
*/
53-
predicate isMicrosoft() { any(File f).compiledAsMicrosoft() }
53+
predicate isMicrosoft() { anyFileCompiledAsMicrosoft() }
5454

5555
/**
5656
* Holds if the default meaning of `%s` is a `wchar_t *`, rather than

0 commit comments

Comments
 (0)