File tree Expand file tree Collapse file tree 1 file changed +14
-18
lines changed
cpp/ql/lib/semmle/code/cpp/internal Expand file tree Collapse file tree 1 file changed +14
-18
lines changed Original file line number Diff line number Diff line change @@ -37,28 +37,24 @@ private string getMultiLocationFilePath(@element e) {
3737 //TODO: add other kinds of elements with multiple locations
3838}
3939
40- /** Holds if `e` exists in the base variant. */
41- overlay [ local]
42- private predicate existsInBase ( @element e ) {
43- not isOverlay ( ) and
44- ( exists ( getSingleLocationFilePath ( e ) ) or exists ( getMultiLocationFilePath ( e ) ) )
45- }
46-
4740/**
48- * Discard an element with a single location if it is in a changed file.
41+ * A local helper predicate that holds in the base variant and never in the
42+ * overlay variant.
4943 */
50- overlay [ discard_entity]
51- private predicate discardSingleLocationElement ( @element e ) {
52- existsInBase ( e ) and
53- overlayChangedFiles ( getSingleLocationFilePath ( e ) )
54- }
44+ overlay [ local]
45+ private predicate holdsInBase ( ) { not isOverlay ( ) }
5546
5647/**
57- * Discard an element with multiple locations only if all its locations are in changed files.
48+ * Discards an element from the base variant if:
49+ * - It has a single location in a changed file, or
50+ * - All of its locations are in changed files.
5851 */
5952overlay [ discard_entity]
60- private predicate discardMultiLocationElement ( @element e ) {
61- existsInBase ( e ) and
62- exists ( getMultiLocationFilePath ( e ) ) and
63- forall ( string path | path = getMultiLocationFilePath ( e ) | overlayChangedFiles ( path ) )
53+ private predicate discardElement ( @element e ) {
54+ holdsInBase ( ) and
55+ (
56+ overlayChangedFiles ( getSingleLocationFilePath ( e ) )
57+ or
58+ forex ( string path | path = getMultiLocationFilePath ( e ) | overlayChangedFiles ( path ) )
59+ )
6460}
You can’t perform that action at this time.
0 commit comments