Skip to content

Commit d99bb65

Browse files
committed
C++: Implement ContentSet
1 parent 725d76e commit d99bb65

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowUtil.qll

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,34 @@ private class CollectionContent extends Content, TCollectionContent {
821821
override string toString() { result = "<element>" }
822822
}
823823

824+
/**
825+
* An entity that represents a set of `Content`s.
826+
*
827+
* The set may be interpreted differently depending on whether it is
828+
* stored into (`getAStoreContent`) or read from (`getAReadContent`).
829+
*/
830+
class ContentSet instanceof Content {
831+
/** Gets a content that may be stored into when storing into this set. */
832+
Content getAStoreContent() { result = this }
833+
834+
/** Gets a content that may be read from when reading from this set. */
835+
Content getAReadContent() { result = this }
836+
837+
/** Gets a textual representation of this content set. */
838+
string toString() { result = super.toString() }
839+
840+
/**
841+
* Holds if this element is at the specified location.
842+
* The location spans column `startcolumn` of line `startline` to
843+
* column `endcolumn` of line `endline` in file `filepath`.
844+
* For more information, see
845+
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
846+
*/
847+
predicate hasLocationInfo(string path, int sl, int sc, int el, int ec) {
848+
super.hasLocationInfo(path, sl, sc, el, ec)
849+
}
850+
}
851+
824852
/**
825853
* A guard that validates some expression.
826854
*

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,6 +1063,34 @@ private class CollectionContent extends Content, TCollectionContent {
10631063
override string toString() { result = "<element>" }
10641064
}
10651065

1066+
/**
1067+
* An entity that represents a set of `Content`s.
1068+
*
1069+
* The set may be interpreted differently depending on whether it is
1070+
* stored into (`getAStoreContent`) or read from (`getAReadContent`).
1071+
*/
1072+
class ContentSet instanceof Content {
1073+
/** Gets a content that may be stored into when storing into this set. */
1074+
Content getAStoreContent() { result = this }
1075+
1076+
/** Gets a content that may be read from when reading from this set. */
1077+
Content getAReadContent() { result = this }
1078+
1079+
/** Gets a textual representation of this content set. */
1080+
string toString() { result = super.toString() }
1081+
1082+
/**
1083+
* Holds if this element is at the specified location.
1084+
* The location spans column `startcolumn` of line `startline` to
1085+
* column `endcolumn` of line `endline` in file `filepath`.
1086+
* For more information, see
1087+
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
1088+
*/
1089+
predicate hasLocationInfo(string path, int sl, int sc, int el, int ec) {
1090+
super.hasLocationInfo(path, sl, sc, el, ec)
1091+
}
1092+
}
1093+
10661094
/**
10671095
* A guard that validates some instruction.
10681096
*

0 commit comments

Comments
 (0)